/** * @dn-sdk/minigame v1.5.6 * (c) 2025 * @license ISC */ function _createForOfIteratorHelper(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n-1?p:t.indexOf("IOS")>-1?v:t.indexOf("MAC")>-1?h:t.indexOf("WINDOWS")>-1?_:y}(o[0]),a=function(e){return!e||e.length<=0?"":2===e.length?e[1]:3===e.length&&"Windows"===e[0]?"".concat(e[1]," ").concat(e[2]):e[e.length-1]}(o);e={benchmark_level:t.benchmarkLevel,device_brand:t.brand,screen_height:Math.floor(t.screenHeight),screen_width:Math.floor(t.screenWidth),wx_lib_version:t.SDKVersion,wx_version:t.version,wx_platform:t.platform,device_model:t.model,os:i,os_version:a}}return e}}(),V=function(){var e;return function(){try{if(e)return e;e||(e=j.getSync(r)||""),e||(e=ie(),j.setSync(r,e))}catch(e){}return e}}();var K=function(){var e="unknown",t=!1;return function(){if(!t)try{wx.getNetworkType({success:function(t){e=t.networkType},fail:function(){e="unknown"}}),wx.onNetworkStatusChange((function(t){e=t.networkType})),t=!0}catch(e){}return e}}();K();var Q=function(){var e="";return function(){return e||(e=j.getSync(s)||""),e}}(),W=function(){var e;return function(){if(e)return e;try{var t=wx.getAccountInfoSync();return te(t.miniProgram)?e=t.miniProgram:{}}catch(t){return{}}}}();function Y(e){var t=null==e?void 0:e.query;if(!te(t))return"";var n="";return t.gdt_vid||[1045,1046,1084].indexOf(null==e?void 0:e.scene)>-1?n=N:t.clue_token||t.clickid&&t.item_id?n=L:t.callback&&"kuaishou"===t.ksChannel?n=P:t.bd_vid||t.ai&&t.d&&t.q&&t.c?n=D:t.uctrackid?n=M:(t.trackid||t.imp||[1065,1069,1194].indexOf(null==e?void 0:e.scene)>-1&&(t.callback||t.u))&&(n=U),n}function H(e,t){try{var n=G(),r=W(),o={sdk_version:"1.5.6",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void 0:n.device_brand,device_model:null==n?void 0:n.device_model,wx_version:null==n?void 0:n.wx_version,wx_lib_version:null==n?void 0:n.wx_lib_version,wx_platform:null==n?void 0:n.wx_platform,os:null==n?void 0:n.os,os_version:null==n?void 0:n.os_version,local_id:V(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},i=Object.assign(o,e);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:i,method:"POST",timeout:f.requestTimeout,success:function(e){"function"==typeof t&&200===(null==e?void 0:e.statusCode)&&t()}})}catch(n){ye.error(n)}}var J=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"revise",value:function(e){e>0&&!this.isRevised&&(this.offsetTime=e-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),e}();function z(e){return new Promise((function(t,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:e,timeout:f.requestTimeout,success:function(e){$(e,t,"config/get",n),Z(e)},fail:function(e){X(e,"config/get",n)}})}))}function $(e,t,n,r){var o,i,a,u,c=null==e?void 0:e.statusCode,s=null==(o=null==e?void 0:e.data)?void 0:o.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),H({log_type:d.REQUEST_CONFIG_ERROR,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==e?void 0:e.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==e?void 0:e.data)?void 0:u.data)}else t(null==(i=e.data)?void 0:i.data)}function X(e,t,n){H({log_type:d.REQUEST_CONFIG_ERROR,message:"cgiName: ".concat(t," , message: ").concat(null==e?void 0:e.errMsg," "),code:"number"==typeof(null==e?void 0:e.errno)?-1*e.errno:-999}),null==n||n(e)}function Z(e){var t,n=1*(null==(t=null==e?void 0:e.header)?void 0:t["Server-Time"]);n>17266752e5&&J.revise(n)}J.offsetTime=0,J.isRevised=!1;var ee=Object.prototype.toString,te=function(e){return"[object Object]"===ee.call(e)},ne=function(e){return"[object Array]"===ee.call(e)},re=function(e){return"[object Function]"===ee.call(e)},oe=(new Date).getTime();function ie(){var e=(new Date).getTime(),t=Math.abs(1e3*(e-oe));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")}))}var ae=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,ue=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");if(!ae.test(e))throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"))},ce=function(e){return isNaN(Number(e))?e:Number(e)},se=function(e){var t=e.replace(/^v/,"").replace(/\+.*$/,""),n=function(e,t){return-1===e.indexOf(t)?e.length:e.indexOf(t)}(t,"-"),r=t.substring(0,n).split(".");return r.push(t.substring(n+1)),r},le=function(e,t){[e,t].forEach(ue);for(var n=se(e),r=se(t),o=0;oa)return 1;if(a>i)return-1}var u=n[n.length-1],c=r[r.length-1];if(u&&c)for(var s=u.split(".").map(ce),l=c.split(".").map(ce),f=0;fl[f])return 1;if(l[f]>s[f])return-1}else if(u||c)return u?-1:1;return 0},fe=function(e){return te(e)?(function(e){var t=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(var n in e)t.includes(n)||ye.warn("Invalid property '".concat(n,"' found in config"))}(e),"number"!=typeof e.user_action_set_id?"user_action_set_id 参数需为 number 类型":e.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof e.secret_key?"secret_key 参数需为 string 类型":""===e.secret_key.trim()?"缺少 secret_key 参数":32!==e.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof e.appid?"appid 参数需为 string 类型":""!==e.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"};function de(e){return pe()[e]}function pe(){return f}function ve(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var _e=function(e){try{return e&&"string"==typeof e?-1===(e=e.replace(/\s/g,"")).indexOf(".")?e:e.split(".").slice(0,2).join("."):""}catch(t){return e}},he=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"error",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1?r-1:0),i=1;i1?r-1:0),i=1;i1?n-1:0),o=1;o1?r-1:0),i=1;i1e4&&(r=JSON.stringify({cut:1,scene:t.scene})),e={source_scene:t.scene,pkg_channel_id:t.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:Y(t)}}catch(t){e={},ye.log("获取场景值和渠道号失败",t)}return e}}();function me(e,t,n){var r=n.value;return n.value=function(){for(var n=arguments.length,o=new Array(n),i=0;i1?void 0:r?Re(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ae(t,n,i),i},Te=function(){function e(t){var n=t.userActionSetId,r=t.maxLength,i=void 0===r?500:r;_classCallCheck(this,e),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat(o,"_").concat(null==n?void 0:n.toString()),this.maxLength=i,this.userActionSetId=n,this.setTimeStamp(),this.init()}return _createClass(e,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var e,t=(null==(e=j)?void 0:e.getSync(this.localStorageKey))||"[]";return JSON.parse(t)}},{key:"reportLostNum",value:function(){var e=this,t=Object.assign({},this.lostActionMaps),n=[];for(var r in t){var o=null==r?void 0:r.split("_");n.push({queue_lost_session_id:o[0],queue_lost_timestamp:o[1],queue_lost_num:t[r]})}n.length&&(this.setTimeStamp(),n.forEach((function(t){var n=Object.assign({},{user_action_set_id:e.userActionSetId,log_type:d.QUEUE_LOST_NUM},t),r=null==t?void 0:t.queue_lost_session_id,o=null==t?void 0:t.queue_lost_timestamp,i="".concat(r,"_").concat(o);H(n,(function(){ve(e.lostActionMaps,i)&&(delete e.lostActionMaps[i],j.setSync(a,JSON.stringify(e.lostActionMaps)))}))})))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var e=this,t=this.getStorage(),n=null==t?void 0:t.map((function(e){var t,n;return e.inner_status===(null==(t=l)?void 0:t.reporting)?Object.assign({},e,{inner_status:null==(n=l)?void 0:n.fail,is_retry:!0,retry_count:e.retry_count+1}):e}));this.stack=n,this.lostActionMaps=JSON.parse(j.getSync(a)||"{}"),setTimeout((function(){e.reportLostNum()}),1e3)}},{key:"addItem",value:function(e){var t;null==(t=null==this?void 0:this.stack)||t.push(e)}},{key:"removeItems",value:function(e){var t,n=null==(t=null==this?void 0:this.stack)?void 0:t.filter((function(t){return!(null!=e&&e.includes(null==t?void 0:t.action_id))}));this.stack=n}},{key:"updateForReportFail",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map((function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=l)?void 0:n.fail,retry_count:t.retry_count+1,is_retry:!0}):t}))}},{key:"updateForReporting",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map((function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=l)?void 0:n.reporting}):t}))}},{key:"updateAllStack",value:function(e){this.stack=e}},{key:"updateToStorage",value:function(){j.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(e){if(e){var t="".concat(e,"_").concat(this.timeStamp),n=this.lostActionMaps[t]||0;this.lostActionMaps[t]=n+1,j.setSync(a,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),e}();ke([me],Te.prototype,"getItems",1),ke([me],Te.prototype,"getStorage",1),ke([me],Te.prototype,"reportLostNum",1),ke([me],Te.prototype,"getLostMaps",1),ke([me],Te.prototype,"init",1),ke([me],Te.prototype,"addItem",1),ke([me],Te.prototype,"removeItems",1),ke([me],Te.prototype,"updateForReportFail",1),ke([me],Te.prototype,"updateForReporting",1),ke([me],Te.prototype,"updateAllStack",1),ke([me],Te.prototype,"updateToStorage",1),ke([me],Te.prototype,"updateLostAction",1);var be=_createClass((function e(){_classCallCheck(this,e)}));be.hasDirectGameMask=!1,be.activeDuration=0;var Ee=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,Oe=function(e,t,n,r){for(var o,i=r>1?void 0:r?Se(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ee(t,n,i),i},Ce=function(e){_inherits(n,e);var t=_createSuper(n);function n(e){var r,o=e.userActionSetId,i=e.maxLength,a=void 0===i?500:i,u=e.ogEvents,c=void 0===u?[]:u;return _classCallCheck(this,n),(r=t.call(this,{userActionSetId:o,maxLength:a})).ogEvents=c,r}return _createClass(n,[{key:"getReportableActions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,t=this.getItems(),n=[];return null==t||t.forEach((function(t){var r;(null==n?void 0:n.length)=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");ye.warn(r),H({user_action_set_id:this.userActionSetId,log_type:d.JS_QUEUE_LOG,message:"队列长度超过限制"});var o=this.sortQueue(e,n);ye.debug&&ye.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),o.concat([]));var i=o.pop();this.updateAllStack(o),this.updateLostAction((null==i?void 0:i.session_id)||""),(null==i?void 0:i.action_id)===e.action_id&&(t={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(e);return be.hasDirectGameMask||this.updateToStorage(),t}},{key:"removeActions",value:function(e){this.removeItems(e),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(e){this.updateForReportFail(e),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(e){this.updateForReporting(e),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var e=this.getItems().filter((function(e){var t;return(null==e?void 0:e.inner_status)!==(null==(t=l)?void 0:t.reporting)}));return null==e?void 0:e.length}},{key:"sortQueue",value:function(e,t){var n=this,r={},o=null==e?void 0:e.action_time,i=t.concat([e]),a=function(e){return r[e.action_id]||(r[e.action_id]=n.caculateWeight(o,e)),r[e.action_id]};return i.sort((function(e,t){return a(t)-a(e)}))}},{key:"caculateWeight",value:function(e,t){var n,r=0,o=this.formatWeight(e,null==t?void 0:t.action_time),i=o.ogWeight,a=o.sdkWeight,u=o.userWeight;null!=(n=this.ogEvents)&&n.includes(null==t?void 0:t.action_type)&&(r+=i),null!=t&&t.is_sdk_auto_track?r+=a:r+=u;var c=e-(null==t?void 0:t.action_time)+1;return r=c>0?r+1/c:r}},{key:"formatWeight",value:function(e,t){var n=g,r=A,o=m;return e-t>2592e6&&(n/=100,r/=100,o/=100),{ogWeight:n,sdkWeight:r,userWeight:o}}}]),n}(Te);Oe([me],Ce.prototype,"getReportableActions",1),Oe([me],Ce.prototype,"addAction",1),Oe([me],Ce.prototype,"removeActions",1),Oe([me],Ce.prototype,"updateActionsForReportFail",1),Oe([me],Ce.prototype,"updateActionsForReporting",1),Oe([me],Ce.prototype,"getReportableActionsLength",1),Oe([me],Ce.prototype,"sortQueue",1),Oe([me],Ce.prototype,"caculateWeight",1),Oe([me],Ce.prototype,"formatWeight",1);var Ie=function(){function e(){_classCallCheck(this,e),this.events={}}return _createClass(e,[{key:"subscribe",value:function(t,n){e.checkCallback(n),ne(this.events[t])?this.events[t].push(n):this.events[t]=[n]}},{key:"once",value:function(t,n){e.checkCallback(n),this.subscribe(this.onceEventName(t),n)}},{key:"unsubscribe",value:function(t,n){e.checkCallback(n),ne(this.events[t])&&(this.events[t]=this.events[t].filter((function(e){return e!==n}))),ne(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)]=this.events[this.onceEventName(t)].filter((function(e){return e!==n})))}},{key:"publish",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1&&e.ticketInterval!==this.ticketInterval&&(this.ticketInterval=e.ticketInterval,xe.publish(F)),e.requestTimeout&&"number"==typeof e.requestTimeout&&e.requestTimeout>5e3&&(this.requestTimeout=e.requestTimeout)}}]),e}(),Je=new He,ze=Le,$e=Pe,Xe=Me,Ze=De,et=function(){var e=!0,t=!0,n=!0,r=!0,o=!0,i=!1;return function(){if(!i){i=!0;var a=j.getSync(u);if((null==a?void 0:a.bg)===w?e=!0:(null==a?void 0:a.bg)===x&&(e=!1),(null==a?void 0:a.fg)===w?t=!0:(null==a?void 0:a.fg)===x&&(t=!1),(null==a?void 0:a.st)===w?n=!0:(null==a?void 0:a.st)===x&&(n=!1),(null==a?void 0:a.ti)===w?r=!0:(null==a?void 0:a.ti)===x&&(r=!1),ye.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",e,t,n,r),n&&xe.publish(ze),r){var c=function(){o&&xe.publish($e)},s=setInterval(c,1e3*Je.getTicketInterval());xe.subscribe(F,(function(){s&&clearInterval(s),s=setInterval(c,1e3*Je.getTicketInterval())}))}wx.onShow((function(e){if(o=!0,t){var n="";try{(n=JSON.stringify(e)).length>1e4&&(n=JSON.stringify({cut:1,scene:e.scene}))}catch(e){}xe.publish(Xe,{enter_options:n})}})),wx.onHide((function(){if(o=!1,e){var t=0;0!==be.activeDuration&&(t=Date.now()-be.activeDuration,be.activeDuration=0),xe.publish(Ze,{duration:t>0?t:0})}}))}}}(),tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var rt,ot=nt((function(){var e,t=null;function n(e){return!!e&&("object"==_typeof(e)||"function"==typeof e)}function r(e){if(null!==e&&!n(e))throw new TypeError("Object prototype may only be an Object or null: "+e)}var o=Object,i=!(!o.create&&{__proto__:null}instanceof o),a=o.create||(i?function(e){return r(e),{__proto__:e}}:function(e){if(r(e),null===e)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var t=function(){};return t.prototype=e,new t}),u=function(){return null},c=o.getPrototypeOf||([].__proto__===Array.prototype?function(e){var t=e.__proto__;return n(t)?t:null}:u);return e=function(s,l){if(void 0===(this&&this instanceof e?this.constructor:void 0))throw new TypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))throw new TypeError("Cannot create proxy with a non-object as target or handler");var f=function(){};t=function(){s=null,f=function(e){throw new TypeError("Cannot perform '".concat(e,"' on a proxy that has been revoked"))}},setTimeout((function(){t=null}),0);var d=l;for(var p in l={get:null,set:null,apply:null,construct:null},d){if(!(p in l))throw new TypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=d[p]}"function"==typeof d&&(l.apply=d.apply.bind(d));var v,_=c(s),h=!1,y=!1;"function"==typeof s?(v=function(){var e=this&&this.constructor===v,t=Array.prototype.slice.call(arguments);return f(e?"construct":"apply"),e&&l.construct?l.construct.call(this,s,t):!e&&l.apply?l.apply(s,this,t):e?(t.unshift(s),new(s.bind.apply(s,t))):s.apply(this,t)},h=!0):s instanceof Array?(v=[],y=!0):v=i||null!==_?a(_):{};var g=l.get?function(e){return f("get"),l.get(this,e,v)}:function(e){return f("get"),this[e]},m=l.set?function(e,t){f("set"),l.set(this,e,t,v)}:function(e,t){f("set"),this[e]=t},A=o.getOwnPropertyNames(s),R={};A.forEach((function(e){if(!h&&!y||!(e in v)){var t={enumerable:!!o.getOwnPropertyDescriptor(s,e).enumerable,get:g.bind(s,e),set:m.bind(s,e)};o.defineProperty(v,e,t),R[e]=!0}}));var k=!0;if(h||y){var T=o.setPrototypeOf||([].__proto__===Array.prototype?function(e,t){return r(t),e.__proto__=t,e}:u);_&&T(v,_)||(k=!1)}if(l.get||!k)for(var b in s)R[b]||o.defineProperty(v,b,{get:g.bind(s,b)});return o.seal(s),o.seal(v),v},e.revocable=function(n,r){return{proxy:new e(n,r),revoke:t}},e})),it={};try{rt||(rt=ot())}catch(t){lt(t)}function at(e,t,n,r){try{if(!rt||null==e||!e[t])return;e[t]=new rt(e[t],{apply:function(e,t,o){var i,a;r&&st((function(){return r.apply(void 0,_toConsumableArray(o))}));var u=!!(null!=(i=o[0])&&i.success||null!=(a=o[0])&&a.fail);u&&["success","fail"].forEach((function(e){if(o[0][e])try{o[0][e]=new rt(o[0][e],{apply:function(t,r,i){return st((function(){return n.apply(void 0,[e,o[0]].concat(_toConsumableArray(i)))})),t.apply(r,i)}})}catch(e){lt(e)}}));var c=e.apply(t,o);return!u&&c&&"[object Promise]"===Object.prototype.toString.call(c)?c.then((function(e){return st((function(){return n("success",o[0],e)})),e})).catch((function(e){throw st((function(){return n("fail",o[0],e)})),e})):c}})}catch(e){lt(e)}}function ut(e,t,n){try{if(!rt||null==e||!e[t])return;e[t]=new rt(e[t],{apply:function(e,t,r){var o="function"==typeof r[0];if(o)try{r[0]=new rt(r[0],{apply:function(e,t,r){var o=e.call.apply(e,[t].concat(_toConsumableArray(r)));return st((function(){return n(o)})),o}})}catch(e){lt(e)}var i=e.call.apply(e,[t].concat(_toConsumableArray(r)));return o||st((function(){return n(i)})),i}})}catch(e){lt(e)}}function ct(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void 0;try{if(!rt||null==e||!e[t])return;e[t]=new rt(e[t],{apply:function(e,i,a){var u=e.call.apply(e,[i].concat(_toConsumableArray(a)));return(!n||!it[t])&&(st((function(){return null==o?void 0:o(u)})),r.forEach((function(e){var t=e.eventName,n=e.isAsync,r=e.proxyEvent;n?at(u,t,r):ut(u,t,r)}))),n&&(it[t]=!0),u}})}catch(e){lt(e)}}function st(e){try{e()}catch(e){lt(e)}}function lt(e){H({log_type:d.PROXY_ERROR,message:null==e?void 0:e.message,err_stack:null==e?void 0:e.stack})}var ft=Ue,dt=Qe,pt=qe,vt=Fe,_t=je,ht=Ge,yt=Ke,gt=Ve,mt=function(){var e=!1;return function(){e||(e=!0,at(wx,"login",(function(e){"success"===e&&xe.publish(ft)})),ut(wx,"onAddToFavorites",(function(){xe.publish(dt)})),ut(wx,"onShareTimeline",(function(){xe.publish(pt,{target:"TIME_LINE",trigger:"MENU"})})),ut(wx,"onShareAppMessage",(function(){xe.publish(pt,{target:"APP_MESSAGE",trigger:"MENU"})})),ut(wx,"shareAppMessage",(function(){xe.publish(pt,{target:"APP_MESSAGE",trigger:"BUTTON"})})),ct(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){xe.publish(vt)}}],(function(){xe.publish(_t)})),ct(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(e){"success"===e&&xe.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(e){"success"===e&&xe.publish(ht)}}]),at(wx,"requestMidasPayment",(function(e,t){xe.publish(gt,{status:"success"===e?"SUCCESS":"FAIL",quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",payType:"Midas"})}),(function(e){xe.publish(yt,{quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",payType:"Midas"})})),at(wx,"requestMidasPaymentGameItem",(function(e,t){var n=(t||{}).signData;xe.publish(gt,{status:"success"===e?"SUCCESS":"FAIL",quantity:(null==n?void 0:n.buyQuantity)||0,mode:(null==n?void 0:n.mode)||"",platform:(null==n?void 0:n.platform)||"",no:(null==n?void 0:n.outTradeNo)||"",p:(null==n?void 0:n.goodsPrice)||0,productId:(null==n?void 0:n.productId)||"",payType:"MidasGameItem"})}),(function(e){var t=(e||{}).signData;xe.publish(yt,{quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",p:(null==t?void 0:t.goodsPrice)||0,productId:(null==t?void 0:t.productId)||"",payType:"MidasGameItem"})})))}}(),At=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"isEmpty",value:function(e){return null==e||"string"==typeof e&&""===e.trim()}},{key:"format",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,o,i,a){return n(function(e,t){return e<>>32-t}(n(n(t,e),n(o,a)),i),r)}function o(e,t,n,o,i,a,u){return r(t&n|~t&o,e,t,i,a,u)}function i(e,t,n,o,i,a,u){return r(t&o|n&~o,e,t,i,a,u)}function a(e,t,n,o,i,a,u){return r(t^n^o,e,t,i,a,u)}function u(e,t,n,o,i,a,u){return r(n^(t|~o),e,t,i,a,u)}function c(e,t){e[t>>5]|=128<>>9<<4)]=t;var r,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,_=271733878;for(r=0;r>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function d(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return s(c(l(e),8*e.length))}(d(e))}function v(e,t){return function(e,t){var n,r,o=l(e),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],a[n]=1549556828^o[n];return r=c(i.concat(l(t)),512+8*t.length),s(c(a.concat(r),640))}(d(e),d(t))}function _(e,t,n){return t?n?v(t,e):function(e,t){return f(v(e,t))}(t,e):n?p(e):function(e){return f(p(e))}(e)}e.exports?e.exports=_:t.md5=_}(tt)}(Et);var St=nt(Et.exports),Ot="function"==typeof btoa,Ct="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var It="function"==typeof TextEncoder?new TextEncoder:void 0,wt=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");!function(e){var t={};e.forEach((function(e,n){return t[e]=n}))}(wt);var xt=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Nt=Ot?function(e){return btoa(e)}:Ct?function(e){return Buffer.from(e,"binary").toString("base64")}:function(e){for(var t,n,r,o,i="",a=e.length%3,u=0;u255||(r=e.charCodeAt(u++))>255||(o=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");i+=wt[(t=n<<16|r<<8|o)>>18&63]+wt[t>>12&63]+wt[t>>6&63]+wt[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i},Lt=Ct?function(e){return Buffer.from(e).toString("base64")}:function(e){for(var t=[],n=0,r=e.length;n>>6)+xt(128|63&t):xt(224|t>>>12&15)+xt(128|t>>>6&63)+xt(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return xt(240|t>>>18&7)+xt(128|t>>>12&63)+xt(128|t>>>6&63)+xt(128|63&t)},Mt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Dt=Ct?function(e){return Buffer.from(e,"utf8").toString("base64")}:It?function(e){return Lt(It.encode(e))}:function(e){return Nt(function(e){return e.replace(Mt,Pt)}(e))};var Ut=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Ft=function(e,t,n,r){for(var o,i=r>1?void 0:r?qt(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ut(t,n,i),i},jt=function(){function e(t){var n=this;_classCallCheck(this,e),this.cgiBatchSize=f.cgiBatchSize,this.reportThreshold=f.reportThreshold,this.reportDelay=f.reportDelay,this.triggerExecuteSend=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];return function(){for(var o=arguments.length,i=new Array(o),a=0;a=this.reportThreshold)this.executeSend();else{var n=(null==(e=this.configManager)?void 0:e.getRealTimeActionList())||f.realTimeActionList;t.some((function(e){return n.indexOf(e.action_type)>-1&&!e.is_retry}))?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var t=this;if(!be.hasDirectGameMask)if(e.currentRequestCount>=e.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(e.requestConcurrency-e.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),o=this.getBaseInfo();if(!o.openid&&!o.unionid&&(ye.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter((function(e){return null==e?void 0:e.ad_trace_id}))),!(r.length<=0)){n=0}));t.isNeedContinueSend&&n&&t.executeSend()})).catch((function(e){ye.error(e),t.reportLog({message:"executeSend catch: ".concat(e.message),log_type:d.JS_RUN_ERROR,err_stack:e.stack})}))}}}},{key:"generateActionReportParams",value:function(e){var t=[],n=[],r=this.getBaseInfo();return e.forEach((function(e){n.push(e.action_id);var r=Object.assign({},e);delete r.inner_status,t.push(r)})),{data:{info:r,actions:t},actionIdList:n}}},{key:"dealSuccessData",value:function(e,t,n){[51001,51003].indexOf(null==e?void 0:e.code)>-1?this.queueManager.updateActionsForReportFail(t):this.queueManager.removeActions(t),0!==(null==e?void 0:e.code)&&(this.reportLog({log_type:d.REQUEST_ERROR,code:null==e?void 0:e.code,message:"trace_id: ".concat(null==e?void 0:e.trace_id,",msg: ").concat(null==e?void 0:e.message)}),ye.error("上报失败:",e)),this.doTrackCallbackFn(this.onReportComplete,e,n),-1===[0,51001,51003].indexOf(null==e?void 0:e.code)&&this.doTrackCallbackFn(this.onReportFail,e,n)}},{key:"dealFailData",value:function(e,t,n){this.queueManager.updateActionsForReportFail(t),this.reportLog({log_type:d.REQUEST_ERROR,code:e.code,message:e.message}),ye.error("上报失败:",e),this.doTrackCallbackFn(this.onReportComplete,e,n)}},{key:"report",value:function(t){var n=this,r=t.data,o=t.actionIdList;return this.queueManager.updateActionsForReporting(o),ye.debug&&(ye.info("上报行为类型: ","【".concat(r.actions.map((function(e){return e.action_type})).join("、"),"】")),ye.info("上报请求参数: ",r)),new Promise((function(t){var i,a,u,c,s,l,p,v,_=Date.now();try{var h=function(e){var t="",n=null==e?void 0:e.appid,r=null==e?void 0:e.secret_key,o=null==e?void 0:e.sdk_version,i=null==e?void 0:e.timestamp;if(!(n&&r&&o&&i&&32===r.length))return t;for(var a=St(o+n+i),u=0;u<32;u++)t+=u%2==0?r[u]:a[u];return t}({appid:null==(i=null==r?void 0:r.info)?void 0:i.appid,secret_key:null==(a=null==r?void 0:r.info)?void 0:a.secret_key,sdk_version:null==(u=null==r?void 0:r.info)?void 0:u.sdk_version,timestamp:_}),y=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(e){return e.replace(/=/g,"").replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"}))}(Dt(e)):Dt(e)}(JSON.stringify(r));p={"Client-Time":_,"Sign-Value":St(y+(null==(c=null==r?void 0:r.info)?void 0:c.user_action_set_id)+(null==(s=null==r?void 0:r.info)?void 0:s.secret_key)+h),"Sign-Version":f.signVersion,"content-type":"text/plain;charset=UTF-8"},v=y}catch(h){p={"Client-Time":_},v=r,n.reportLog({log_type:d.SIGN_ERROR,message:"sign error msg: ".concat(null==h?void 0:h.message),err_stack:null==h?void 0:h.stack}),ye.error(h)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(l=n.configManager)?void 0:l.getRequestTimeout())||f.requestTimeout,header:p,data:v,success:function(i){var a,u;ye.devLog("上报接口返回码:",null==(a=null==i?void 0:i.data)?void 0:a.code);var c=(null==(u=null==i?void 0:i.header)?void 0:u["Server-Time"])||-1;if(J.revise(c),e.currentRequestCount-=1,200===(null==i?void 0:i.statusCode))return n.dealSuccessData(null==i?void 0:i.data,o,r),void t((null==i?void 0:i.data).code);var s="";try{s="object"==_typeof(null==i?void 0:i.data)?JSON.stringify(null==i?void 0:i.data):null==i?void 0:i.data}catch(e){ye.error(e)}var l={code:"number"==typeof(null==i?void 0:i.statusCode)?-1*i.statusCode:-888,message:"statusCode: ".concat(null==i?void 0:i.statusCode,", data: ").concat(s)};n.dealFailData(l,o,r),t(l.code)},fail:function(i){ye.devLog("上报失败:",i),e.currentRequestCount-=1;var a={code:"number"==typeof(null==i?void 0:i.errno)?-1*i.errno:-999,message:null==i?void 0:i.errMsg};n.dealFailData(a,o,r),t(a.code)}})}))}},{key:"startInspectTimer",value:function(){var t=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout((function(){e.currentRequestCount>=e.requestConcurrency&&(e.currentRequestCount=e.requestConcurrency-1),t.executeSend(),t.startInspectTimer()}),1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(e,t,n){if("function"==typeof e)try{for(var r=[],o=0;o10?ye.error("网络请求最大并发量不能大于10"):e.requestConcurrency=t:ye.error("网络请求最大并发量需设置为数字")}}]),e}(),Bt=jt;Bt.currentRequestCount=0,Bt.requestConcurrency=f.requestConcurrency,Ft([me],Bt.prototype,"batchSend",1),Ft([me],Bt.prototype,"flushSend",1),Ft([me],Bt.prototype,"executeSend",1);var Gt=Le,Vt=Pe,Kt=Me,Qt=De,Wt=Ue,Yt=Qe,Ht=qe,Jt=Fe,zt=je,$t=Ge,Xt=Ke,Zt=Ve,en=Be,tn=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"install",value:function(e,t){var n=function(t){xe.subscribe(t,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};be.hasDirectGameMask||("ENTER_FOREGROUND"===t&&(be.activeDuration=Date.now()),e.track(t,Object.assign(n||{},o,_defineProperty(_defineProperty({},vn,!0),_n,r))))}}(t))};n(Vt),n(Gt),n(Kt),n(Qt),"all"===t&&(n(Wt),n(Yt),n(Ht),n(zt),n(Jt),n(en),n($t),n(Xt),n(Zt))}}]),e}(),nn=function(){function e(){_classCallCheck(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return _createClass(e,[{key:"onPurchase",value:function(e){return"number"!=typeof e&&ye.warn("付费金额需要为数字"),e<=0&&ye.warn("付费金额需要大于0"),this.wrapTrack(E,{value:e})}},{key:"onEnterForeground",value:function(){return this.wrapTrack(k)}},{key:"onEnterBackground",value:function(){return this.wrapTrack(T)}},{key:"onAppStart",value:function(){return this.wrapTrack(R)}},{key:"onAppQuit",value:function(){return this.wrapTrack(S)}},{key:"onAddToWishlist",value:function(){return this.wrapTrack(b)}},{key:"wrapTrack",value:function(e,t){return this.track(e,Object.assign(t||{},_defineProperty({},this.special_method_symbol,1)))}}]),e}(),rn=function(e){_inherits(n,e);var t=_createSuper(n);function n(){return _classCallCheck(this,n),t.apply(this,arguments)}return _createClass(n,[{key:"onRegister",value:function(){return this.wrapTrack(O)}},{key:"onCreateRole",value:function(e){return e&&"string"!=typeof e&&ye.warn("角色名称需要为字符串"),this.wrapTrack(C,e?{name:e}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack(I)}}]),n}(nn),on="(如果确认无误,请忽略该提示)",an=function(){var e=[];return{requestActionList:function(){try{z({conf_name:"data_nexus_common",conf_key:"action_types"}).then((function(t){ne(t)&&(e=t)}))}catch(e){ye.error(e)}},getActionList:function(){return e}}}();function un(e,t){try{e.is_sdk_auto_track||(function(e){try{var t=an.getActionList();if(!t.includes(e)){var n,r=_createForOfIteratorHelper(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(cn(o,e)<=parseInt((.3*o.length).toString())){ye.warn("通过SDK上报的".concat(e,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(on));break}}}catch(e){r.e(e)}finally{r.f()}}}catch(t){ye.error(t)}}(e.action_type),"minigame"===t?function(e,t){var n,r,o;try{["PURCHASE","ADD_TO_CART"].includes(e.action_type)&&e.action_param&&ve(e.action_param,"value")&&("number"!=typeof(null==(n=e.action_param)?void 0:n.value)?ye.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要为数字!")):(null==(r=e.action_param)?void 0:r.value)<=0?ye.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要大于0!")):"minigame"===t&&(null==(o=e.action_param)?void 0:o.value)<100&&ye.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(on)))}catch(e){ye.error(e)}}(e,t):"miniprogram"===t&&function(e){try{var t=null==e?void 0:e.action_type,n=(null==e?void 0:e.action_param)||{};"PURCHASE"===t&&ve(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?ye.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&ye.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要大于0!")))}catch(t){ye.error(t)}}(e))}catch(e){ye.error(e)}}function cn(e,t){try{if(0===e.length)return t.length;if(0===t.length)return e.length;for(var n=[],r=0;r<=t.length;r++)n[r]=[r];for(var o=0;o<=e.length;o++)n[0][o]=o;for(var i=1;i<=t.length;i++)for(var a=1;a<=e.length;a++)t.charAt(i-1)===e.charAt(a-1)?n[i][a]=n[i-1][a-1]:n[i][a]=Math.min(n[i-1][a-1]+1,n[i][a-1]+1,n[i-1][a]+1);return n[t.length][e.length]}catch(n){ye.error(n)}}function sn(e){try{e&&!/^[a-zA-Z0-9_\-]+$/.test(e)&&ye.warn("通过SDK上报的openid:".concat(e,"可能有误,请检查openid是否正确!").concat(on))}catch(e){ye.error(e)}}var ln=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,dn=function(e,t,n,r){for(var o,i=r>1?void 0:r?fn(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ln(t,n,i),i},pn=Symbol("initializedInstance"),vn=Symbol("autoTrack"),_n=Symbol("actionTime"),hn=function(e){_inherits(n,e);var t=_createSuper(n);function n(e){var r;if(_classCallCheck(this,n),(r=t.call(this)).env="production",r.sdk_version="1.5.6",r.sdk_name="@dn-sdk/minigame",r.deviceInfo={},r.gameInfo={},r.session_id="",r.log_id=0,r.inited=!1,r.initErrMsg="",null==wx||!wx.createCanvas)return r.initErrMsg="不支持非微信小游戏中使用",ye.error(r.initErrMsg),_possibleConstructorReturn(r);var o=pe();if(n[pn].length>=o.maxSdkInstance)return r.initErrMsg="初始化超过上限",ye.error(r.initErrMsg),_possibleConstructorReturn(r);var i=fe(e),a=W();if(!0!==i)return r.initErrMsg=i,ye.error(i),_possibleConstructorReturn(r);var u=null==a?void 0:a.appId;if(u&&u!==e.appid)return r.initErrMsg="初始化传入的appid与当前小游戏appid不一致",ye.error(r.initErrMsg),_possibleConstructorReturn(r);r.config=e,ve(e,"auto_track")||(r.config.auto_track=de("autoTrack")),r.openid=e.openid,r.unionid=e.unionid,r.user_unique_id=e.user_unique_id,r.onReportComplete=e.on_report_complete,r.onReportFail=e.on_report_fail,r.saveValidOpenidToStorage();var c=e.user_action_set_id;return n[pn].includes(c)?(r.initErrMsg="同个数据源[".concat(c,"]只能初始化一次"),ye.error(r.initErrMsg),r.reportLog({log_type:d.JS_RUN_ERROR,message:r.initErrMsg}),_possibleConstructorReturn(r)):(r.reportLog=r.reportLog.bind(_assertThisInitialized(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(_assertThisInitialized(r)),be.activeDuration=Date.now(),r.deviceInfo=G(),r.gameInfo=ge(),r.session_id=ie(),r.queueManage=new Ce({userActionSetId:c,maxLength:o.maxQueueLength,ogEvents:Ne}),r.actionReporter=new Bt({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:Je,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,n[pn].push(c),r.useAutoTrack(),r.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(ye.info("初始化成功"),_possibleConstructorReturn(r)):(function(e){var t=e.conf_name,n=e.conf_key,r=e.sdk_version,o=e.default_download_url,i=e.fail_handler;z({conf_name:t,conf_key:n}).then((function(e){if(te(e)){var t=null==e?void 0:e.blackVersions,n=null==e?void 0:e.minVersion,a=null==e?void 0:e.bestVersion,u=null==e?void 0:e.downloadUrl,c=o;return u&&/^https/.test(u)&&(c=u),ne(t)&&(null==t?void 0:t.indexOf(r))>-1?(null==i||i(),void ye.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):n&&le(r,n)<0?(null==i||i(),void ye.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&le(r,a)<0&&ye.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void ye.info("初始化成功"))}ye.info("初始化成功")})).catch((function(){ye.info("初始化成功")}))}({conf_name:"mini_game_sdk_common",conf_key:"version",sdk_version:r.sdk_version,default_download_url:"https://sr-home-1257214331.cos.ap-guangzhou.myqcloud.com/sdk/dn-sdk-minigame/dn-sdk-minigame.zip",fail_handler:function(){r.inited=!1}}),an.requestActionList(),sn(e.openid),_possibleConstructorReturn(r)))}return _createClass(n,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(e,t){var n,r;if(!this.inited||!this.queueManage)return ye.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var o=bt.validateActionType(e),i=bt.validateActionParam(t);if(o&&i){!this.openid&&!this.unionid&&ye.warn("缺少 openid 或 unionid");var a=de("actionParamMaxLength");if(JSON.stringify(t||{}).length>a)return ye.error("监测到超过".concat(a,"的上报日志:").concat(e," ").concat(t)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==t||!t[vn]),c=this.createAction(e,t||{},u);"release"!==(null==(n=W())?void 0:n.envVersion)&&un(c,"minigame");var s=this.queueManage.addAction(c);return null==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){var e;null==(e=this.actionReporter)||e.flushSend()}},{key:"setOpenId",value:function(e){var t;if(e&&"string"==typeof e)return this.openid=e,this.gameInfo.ad_trace_id&&!j.getSync(s)&&xe.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(t=W())?void 0:t.envVersion)&&sn(e),{code:0,message:"成功"};var n="openid 格式错误";return ye.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(e){if(e&&"string"==typeof e)return this.unionid=e,this.flush(),{code:0,message:"成功"};var t="unionid 格式错误";return ye.error(t),{code:101,message:t}}},{key:"setUserUniqueId",value:function(e){if(e&&"string"==typeof e)return this.user_unique_id=e,{code:0,message:"成功"};var t="user_unique_id 格式错误";return ye.error(t),{code:101,message:t}}},{key:"doReportOnEnterBackground",value:function(){var e=this;wx.onHide((function(){var t,n;null==(t=e.actionReporter)||t.flushSend(),null==(n=e.queueManage)||n.reportLostNum()}))}},{key:"getTrackBaseInfo",value:function(){var e=W();return Object.assign({},this.deviceInfo,function(e,t){var n={};return t.forEach((function(t){ve(e,t)&&(n[t]=e[t])})),n}(this.config,["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"]),{local_id:V(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||Q(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:e.envVersion,app_version:e.version}})}},{key:"createAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=t&&t[vn]&&delete t[vn];var r=Date.now();null!=t&&t[_n]&&(r=null==t?void 0:t[_n],delete t[_n]);var o={action_id:ie(),action_param:t,action_time:r,action_type:e,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:J.getRevisedcurrentTimeMillis(),log_id:++this.log_id,session_id:this.session_id,pkg_channel_id:this.gameInfo.pkg_channel_id,source_scene:this.gameInfo.source_scene,network_type:K(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(e)};return null!=t&&t[this.special_method_symbol]&&(this.addActionInnerParam(o,"is_special_method",!0),delete t[this.special_method_symbol]),Je.getChannelClaimActionList().indexOf(e)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(o,"launch_options",this.gameInfo.launch_options),o}},{key:"addActionInnerParam",value:function(e,t,n){e.inner_param&&te(e.inner_param)?e.inner_param[t]=n:e.inner_param=_defineProperty({},t,n)}},{key:"getChannelByActionType",value:function(e){var t="";return Je.getChannelClaimActionList().indexOf(e)>-1?t=this.gameInfo.channel||"":Je.getNoClaimActionList().indexOf(e)>-1&&(t=q),t}},{key:"reportLog",value:function(e){var t,n,r={user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};H(Object.assign(r,e))}},{key:"useAutoTrack",value:function(){var e;if(null!=(e=this.config)&&e.auto_track){var t=!0,n=j.getSync(u);(null==n?void 0:n.ap)===w?t=!0:(null==n?void 0:n.ap)===x&&(t=!1),"devtools"===G().wx_platform&&(t=!0),(new tn).install(this,t?"all":"lifecycle"),et(),t&&mt(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var e,t,n=G();n.os&&n.os_version&&null!=(e=this.config)&&e.user_action_set_id&&function(e){return new Promise((function(t){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:e,timeout:f.requestTimeout,success:function(e){$(e,t,"minigame/get"),Z(e)},fail:function(e){X(e,"minigame/get")}})}))}({conf_name:"MG",conf_param:{user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:_e(n.os_version),device_brand:(null==n?void 0:n.device_brand)||"",weixin_lib_version:(null==n?void 0:n.wx_lib_version)||"",weixin_version:(null==n?void 0:n.wx_version)||""}}).then((function(e){te(e)&&j.setSync(u,e)}))}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(e){return/^[a-zA-Z0-9_-]{28,30}$/.test(e)}(this.openid)&&j.setSync(s,this.openid)}}],[{key:"setRequestConcurrency",value:function(e){Bt.setRequestConcurrency(e)}},{key:"setDebug",value:function(e){ye.debug=e}}]),n}(rn),yn=hn;yn[pn]=[],dn([me],yn.prototype,"track",1),dn([me,function(e,t,n){var r=n.value;return n.value=function(){if(this.inited){for(var e=arguments.length,t=new Array(e),n=0;n