functiont(t,e,n){return(e=v(e))int?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}functione(t){returnfunction(t){if(Array.isArray(t))returnr(t)}(t)||function(t){if("undefined"!=typeofSymbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])returnArray.from(t)}(t)||n(t)||function(){thrownewTypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable,non-array objects must have a[Symbol.iterator]()method.")}()}functionn(t,e){if(t){if("string"==typeoft)returnr(t,e);varn=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void0}}functionr(t,e){(null==e||e>t.length)&&(e=t.length);for(varn=0,r=newArray(e);n<e;n++)r[n]=t[n];returnr}functioni(t,e){if("function"!=typeofe&&null!==e)thrownewTypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}functiono(t,e){returno=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){returnt.__proto__=e,t},o(t,e)}functiona(t){vare=function(){if("undefined"==typeofReflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeofProxy)return!0;try{returnBoolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();returnfunction(){varn,r=s(t);if(e){vari=s(this).constructor;n=Reflect.construct(r,arguments,i)}elsen=r.apply(this,arguments);returnu(this,n)}}functionu(t,e){if(e&&("object"===l(e)||"function"==typeofe))returne;if(void0!==e)thrownewTypeError("Derived constructors may only return object or undefined");returnc(t)}functionc(t){if(void0===t)thrownewReferenceError("this hasn't been initialised-super()hasn't been called");returnt}functions(t){returns=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){returnt.__proto__||Object.getPrototypeOf(t)},s(t)}functionl(t){returnl="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(t){returntypeoft}:function(t){returnt&&"function"==typeofSymbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeoft},l(t)}functionf(t,e){if(!(tinstanceofe))thrownewTypeError("Cannot call a class as a function")}functiond(t,e){for(varn=0;n<e.length;n++){varr=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(t,v(r.key),r)}}functionp(t,e,n){returne&&d(t.prototype,e),n&&d(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}functionv(t){vare=function(t){if("object"!==l(t)||null===t)returnt;vare=t[Symbol.toPrimitive];if(void0!==e){varn=e.call(t,"string");if("object"!==l(n))returnn;thrownewTypeError("@@toPrimitive must return a primitive value.")}returnString(t)}(t);return"symbol"===l(e)?e:String(e)}varh,_,g="LOCAL_ID",y="QUEUE_ACTIONS",m="CLICK_ID",A="QUEUE_LOST_MAP",R="REMOTE_CONFIG",k="REMOTE_COMMON_CONFIG",S="OPENID",T={init:"init",reporting:"reporting",fail:"fail"},E={maxSdkInstance:4,maxQueueLength:500,actionParamMaxLength:1e4,autoTrack:!0,reportThreshold:5,reportDelay:1,inspectDelay:30,cgiBatchSize:50,requestConcurrency:4,requestTimeout:1e4,signVersion:"1.0",realTimeActionList:["START_APP","REGISTER","PURCHASE"]},b={JS_RUN_ERROR:"JS_RUN_ERROR",REQUEST_ERROR:"REQUEST_ERROR",REQUEST_CONFIG_ERROR:"REQUEST_CONFIG_ERROR",JS_QUEUE_LOG:"JS_QUEUE_LOG",PROXY_ERROR:"PROXY_ERROR",PROXY_POLYFILL:"PROXY_POLYFILL",QUEUE_LOST_NUM:"QUEUE_LOST_NUM",REQ_TOTAL:"REQ_TOTAL",SIGN_ERROR:"SIGN_ERROR"},O="ANDROID",I="IOS",w="WINDOWS",C="OSX",x="UNKNOWN",N=1e3,L=100,D=10,M="START_APP",P="ENTER_FOREGROUND",U="ENTER_BACKGROUND",q="ADD_TO_WISHLIST",F="PURCHASE",j="APP_QUIT",G="REGISTER",B="CREATE_ROLE",V="TUTORIAL_FINISH",K="TRUE",Q="FALSE",Y="TENCENT",W="BYTEDANCE",J="KUAISHOU",H="ALIBABA",z="BAIDU",$="OTHERS",X="UNKNOWN",Z="TICKET_INTERVAL_CHANGE",tt=(_=function(t){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(t)},{getSync:function(t){vare;try{e=wx.getStorageSync(_(t))}catch(t){returnconsole.error("storage get error",t),e}returne},setSync:function(t,e){try{wx.setStorageSync(_(t),e)}catch(t){returnconsole.error("storage set error",t),!1}return!0}}),et=function(){if(h)returnh;try{returnh=wx.getSystemInfoSync()}catch(t){return{}}},nt=function(){vart;returnfunction(){if(!t){vare=et(),n=e.system,r=void0===n?"":n,i=(null==r?void0:r.split(" "))||[],o=function(t){if(!t)returnx;vare=(null==t?void0:t.toUpperCase())||"";returne.indexOf("ANDROID")>-1?O:e.indexOf("IOS")>-1?I:e.indexOf("MAC")>-1?C:e.indexOf("WINDOWS")>-1?w:x}(i[0]),a=function(t){return!t||t.length<=0?"":2===t.length?t[1]:3===t.length&&"Windows"===t[0]?"".concat(t[1]," ").concat(t[2]):t[t.length-1]}(i);t={benchmark_level:e.benchmarkLevel,device_brand:e.brand,screen_height:Math.floor(e.screenHeight),screen_width:Math.floor(e.screenWidth),wx_lib_version:e.SDKVersion,wx_version:e.version,wx_platform:e.platform,device_model:e.model,os:o,os_version:a}}returnt}}(),rt=function(){vart;returnfunction(){try{if(t)returnt;t||(t=tt.getSync(g)||""),t||(t=mt(),tt.setSync(g,t))}catch(t){}returnt}}(),it=function(){vart="unknown",e=!1;returnfunction(){if(!e)try{wx.getNetworkType({success:function(e){t=e.networkType},fail:function(){t="unknown"}}),wx.onNetworkStatusChange(function(e){t=e.networkType}),e=!0}catch(t){}returnt}}();it();varot=function(){vart="";returnfunction(){returnt||(t=tt.getSync(S)||""),t}}(),at=function(){vart;returnfunction(){if(t)returnt;try{vare=wx.getAccountInfoSync();returnht(e.miniProgram)?t=e.miniProgram:{}}catch(e){return{}}}}();functionut(t){vare=null==t?void0:t.query;if(!ht(e))return"";varn="";returne.gdt_vid||[1045,1046,1084].indexOf(null==t?void0:t.scene)>-1?n=Y:e.clue_token||e.clickid&&e.item_id?n=W:e.callback&&"kuaishou"===e.ksChannel?n=J:e.bd_vid||e.ai&&e.d&&e.q&&e.c?n=z:e.uctrackid?n=H:(e.trackid||e.imp||[1065,1069,1194].indexOf(null==t?void0:t.scene)>-1&&(e.callback||e.u))&&(n=$),n}functionct(t,e){try{varn=nt(),r=at(),i={sdk_version:"1.5.7",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void0:n.device_brand,device_model:null==n?void0:n.device_model,wx_version:null==n?void0:n.wx_version,wx_lib_version:null==n?void0:n.wx_lib_version,wx_platform:null==n?void0:n.wx_platform,os:null==n?void0:n.os,os_version:null==n?void0:n.os_version,local_id:rt(),env_version:null==r?void0:r.envVersion,appid:null==r?void0:r.appId},o=Object.assign(i,t);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:o,method:"POST",timeout:E.requestTimeout,success:function(t){"function"==typeofe&&200===(null==t?void0:t.statusCode)&&e()}})}catch(n){xt.error(n)}}varst=function(){functiont(){f(this,t)}returnp(t,null,[{key:"revise",value:function(t){t>0&&!this.isRevised&&(this.offsetTime=t-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){returnthis.isRevised?Date.now()+this.offsetTime:-1}}]),t}();functionlt(t){returnnewPromise(function(e,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:t,timeout:E.requestTimeout,success:function(t){ft(t,e,"config/get",n),pt(t)},fail:function(t){dt(t,"config/get",n)}})})}functionft(t,e,n,r){vari,o,a,u,c=null==t?void0:t.statusCode,s=null==(i=null==t?void0:t.data)?void0:i.code;if(200!==c||0!==s){varl=s;200!==c&&(l="number"==typeofc?-1*c:-888),ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName:".concat(n,",statusCode:").concat(c,",code:").concat(s,",traceid:").concat(null==(a=null==t?void0:t.data)?void0:a.trace_id),code:l}),null==r||r(null==(u=null==t?void0:t.data)?void0:u.data)}elsee(null==(o=t.data)?void0:o.data)}functiondt(t,e,n){ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName:".concat(e,",message:").concat(null==t?void0:t.errMsg," "),code:"number"==typeof(null==t?void0:t.errno)?-1*t.errno:-999}),null==n||n(t)}functionpt(t){vare,n=1*(null==(e=null==t?void0:t.header)?void0:e["Server-Time"]);n>17266752e5&&st.revise(n)}st.offsetTime=0,st.isRevised=!1;varvt=Object.prototype.toString,ht=function(t){return"[object Object]"===vt.call(t)},_t=function(t){return"[object Array]"===vt.call(t)},gt=function(t){return"[object Function]"===vt.call(t)},yt=(newDate).getTime();functionmt(){vart=(newDate).getTime(),e=Math.abs(1e3*(t-yt));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(n){varr=16*Math.random();returnt>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")})}varAt=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Rt=function(t){if("string"!=typeoft)thrownewTypeError("Invalid argument expected string");if(!At.test(t))thrownewError("Invalid argument not valid semver('".concat(t,"' received)"))},kt=function(t){returnisNaN(Number(t))?t:Number(t)},St=function(t){vare=t.replace(/^v/,"").replace(/\+.*$/,""),n=function(t){return-1===t.indexOf("-")?t.length:t.indexOf("-")}(e),r=e.substring(0,n).split(".");returnr.push(e.substring(n+1)),r},Tt=function(t,e){[t,e].forEach(Rt);for(varn=St(t),r=St(e),i=0;i<Math.max(n.length-1,r.length-1);i++){varo=parseInt(n[i]||"0",10),a=parseInt(r[i]||"0",10);if(o>a)return1;if(a>o)return-1}varu=n[n.length-1],c=r[r.length-1];if(u&&c)for(vars=u.split(".").map(kt),l=c.split(".").map(kt),f=0;f<Math.max(s.length,l.length);f++){if(void0===s[f]||"string"==typeofl[f]&&"number"==typeofs[f])return-1;if(void0===l[f]||"string"==typeofs[f]&&"number"==typeofl[f]||s[f]>l[f])return1;if(l[f]>s[f])return-1}elseif(u||c)returnu?-1:1;return0},Et=function(t){returnht(t)?(function(t){vare=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(varnint)e.includes(n)||xt.warn("Invalid property '".concat(n,"' found in config"))}(t),"number"!=typeoft.user_action_set_id?"user_action_set_id 参数需为 number 类型":t.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeoft.secret_key?"secret_key 参数需为 string 类型":""===t.secret_key.trim()?"缺少 secret_key 参数":32!==t.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeoft.appid?"appid 参数需为 string 类型":""!==t.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"};functionbt(t){returnOt()[t]}functionOt(){returnE}functionIt(t,e){returnObject.prototype.hasOwnProperty.call(t,e)}varwt=function(t){try{returnt&&"string"==typeoft?-1===(t=t.replace(/\s/g,"")).indexOf(".")?t:t.split(".").slice(0,2).join("."):""}catch(e){returnt}},Ct=function(){functiont(){f(this,t)}returnp(t,null,[{key:"error",value:function(t){for(vare,n=arguments.length,r=newArray(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];(e=console).error.apply(e,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(t)].concat(r))}},{key:"info",value:function(e){for(varn,r=arguments.length,i=newArray(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(e)].concat(i))}},{key:"log",value:function(e){for(varn,r=arguments.length,i=newArray(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(e)].concat(i))}},{key:"warn",value:function(t){for(vare,n=arguments.length,r=newArray(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];(e=console).warn.apply(e,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(t)].concat(r))}},{key:"devLog",value:function(e){for(varn,r=arguments.length,i=newArray(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(e)].concat(i))}}]),t}(),xt=Ct;xt.debug=!1,xt.isDev=!1;varNt=p(functiont(){f(this,t)});Nt.hasDirectGameMask=!1,Nt.activeDuration=0;varLt=function(){vart;returnfunction(){if(!t)try{vare=wx.getLaunchOptionsSync(),n=e.query.gdt_vid||"";n?Nt.hasDirectGameMask||tt.setSync(m,n):n=tt.getSync(m)||"";varr=JSON.stringify(e);r.length>1e4&&(r=JSON.stringify({cut:1,scene:e.scene})),t={source_scene:e.scene,pkg_channel_id:e.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ut(e)}}catch(e){t={},xt.log("获取场景值和渠道号失败",e)}returnt}}();functionDt(t,e,n){varr=n.value;returnn.value=function(){for(varn=arguments.length,i=newArray(n),o=0;o<n;o++)i[o]=arguments[o];try{returnr.apply(this,i)}catch(n){try{xt.error.apply(xt,["calling ".concat(t.constructor.name,".").concat(e," error with arguments")].concat(i)),xt.error(n);vara={log_type:b.JS_RUN_ERROR,message:"[safeExcutable]".concat(t.constructor.name,".").concat(e,":").concat(null==n?void0:n.message),err_stack:null==n?void0:n.stack};gt(this.reportLog)?this.reportLog(a):ct(a)}catch(a){}}},n}varMt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ut=function(t,e,n,r){for(vari,o=r>1?void0:r?Pt(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&Mt(e,n,o),o},qt=function(){functiont(e){varn=e.userActionSetId,r=e.maxLength,i=void0===r?500:r;f(this,t),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat(y,"_").concat(null==n?void0:n.toString()),this.maxLength=i,this.userActionSetId=n,this.setTimeStamp(),this.init()}returnp(t,[{key:"getItems",value:function(){returnthis.stack}},{key:"getStorage",value:function(){vart,e=(null==(t=tt)?void0:t.getSync(this.localStorageKey))||"[]";returnJSON.parse(e)}},{key:"reportLostNum",value:function(){vart=this,e=Object.assign({},this.lostActionMaps),n=[];for(varrine){vari=null==r?void0:r.split("_");n.push({queue_lost_session_id:i[0],queue_lost_timestamp:i[1],queue_lost_num:e[r]})}n.length&&(this.setTimeStamp(),n.forEach(function(e){varn=Object.assign({},{user_action_set_id:t.userActionSetId,log_type:b.QUEUE_LOST_NUM},e),r=null==e?void0:e.queue_lost_session_id,i=null==e?void0:e.queue_lost_timestamp,o="".concat(r,"_").concat(i);ct(n,function(){It(t.lostActionMaps,o)&&(deletet.lostActionMaps[o],tt.setSync(A,JSON.stringify(t.lostActionMaps)))})}))}},{key:"getLostMaps",value:function(){returnthis.lostActionMaps}},{key:"init",value:function(){vart=this,e=this.getStorage(),n=null==e?void0:e.map(function(t){vare,n;returnt.inner_status===(null==(e=T)?void0:e.reporting)?Object.assign({},t,{inner_status:null==(n=T)?void0:n.fail,is_retry:!0,retry_count:t.retry_count+1}):t});this.stack=n,this.lostActionMaps=JSON.parse(tt.getSync(A)||"{}"),setTimeout(function(){t.reportLostNum()},1e3)}},{key:"addItem",value:function(t){vare;null==(e=null==this?void0:this.stack)||e.push(t)}},{key:"removeItems",value:function(t){vare,n=null==(e=null==this?void0:this.stack)?void0:e.filter(function(e){return!(null!=t&&t.includes(null==e?void0:e.action_id))});this.stack=n}},{key:"updateForReportFail",value:function(t){vare;this.stack=null==(e=this.stack)?void0:e.map(function(e){varn;returnnull!=t&&t.includes(null==e?void0:e.action_id)?Object.assign({},e,{inner_status:null==(n=T)?void0:n.fail,retry_count:e.retry_count+1,is_retry:!0}):e})}},{key:"updateForReporting",value:function(t){vare;this.stack=null==(e=this.stack)?void0:e.map(function(e){varn;returnnull!=t&&t.includes(null==e?void0:e.action_id)?Object.assign({},e,{inner_status:null==(n=T)?void0:n.reporting}):e})}},{key:"updateAllStack",value:function(t){this.stack=t}},{key:"updateToStorage",value:function(){tt.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(t){if(t){vare="".concat(t,"_").concat(this.timeStamp),n=this.lostActionMaps[e]||0;this.lostActionMaps[e]=n+1,tt.setSync(A,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),t}();Ut([Dt],qt.prototype,"getItems",1),Ut([Dt],qt.prototype,"getStorage",1),Ut([Dt],qt.prototype,"reportLostNum",1),Ut([Dt],qt.prototype,"getLostMaps",1),Ut([Dt],qt.prototype,"init",1),Ut([Dt],qt.prototype,"addItem",1),Ut([Dt],qt.prototype,"removeItems",1),Ut([Dt],qt.prototype,"updateForReportFail",1),Ut([Dt],qt.prototype,"updateForReporting",1),Ut([Dt],qt.prototype,"updateAllStack",1),Ut([Dt],qt.prototype,"updateToStorage",1),Ut([Dt],qt.prototype,"updateLostAction",1);varFt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Gt=function(t,e,n,r){for(vari,o=r>1?void0:r?jt(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&Ft(e,n,o),o},Bt=function(){i(e,qt);vart=a(e);functione(n){varr,i=n.userActionSetId,o=n.maxLength,a=void0===o?500:o,u=n.ogEvents,c=void0===u?[]:u;returnf(this,e),(r=t.call(this,{userActionSetId:i,maxLength:a})).ogEvents=c,r}returnp(e,[{key:"getReportableActions",value:function(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:100,e=this.getItems(),n=[];returnnull==e||e.forEach(function(e){varr;(null==n?void0:n.length)<t&&(null==e?void0:e.inner_status)!==(null==(r=T)?void0:r.reporting)&&(null==n||n.push(e))}),n}},{key:"addAction",value:function(t){vare={code:0,message:"成功",actionId:t.action_id},n=this.getItems();if((null==n?void0:n.length)>=this.maxLength){varr="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");xt.warn(r),ct({user_action_set_id:this.userActionSetId,log_type:b.JS_QUEUE_LOG,message:"队列长度超过限制"});vari=this.sortQueue(t,n);xt.debug&&xt.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),i.concat([]));varo=i.pop();this.updateAllStack(i),this.updateLostAction((null==o?void0:o.session_id)||""),(null==o?void0:o.action_id)===t.action_id&&(e={code:103,message:"缓存队列已满,主动丢弃行为"})}elsethis.addItem(t);returnNt.hasDirectGameMask||this.updateToStorage(),e}},{key:"removeActions",value:function(t){this.removeItems(t),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(t){this.updateForReportFail(t),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(t){this.updateForReporting(t),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){vart=this.getItems().filter(function(t){vare;return(null==t?void0:t.inner_status)!==(null==(e=T)?void0:e.reporting)});returnnull==t?void0:t.length}},{key:"sortQueue",value:function(t,e){varn=this,r={},i=null==t?void0:t.action_time,o=e.concat([t]),a=function(t){returnr[t.action_id]||(r[t.action_id]=n.caculateWeight(i,t)),r[t.action_id]};returno.sort(function(t,e){returna(e)-a(t)})}},{key:"caculateWeight",value:function(t,e){varn,r=0,i=this.formatWeight(t,null==e?void0:e.action_time),o=i.ogWeight,a=i.sdkWeight,u=i.userWeight;null!=(n=this.ogEvents)&&n.includes(null==e?void0:e.action_type)&&(r+=o),null!=e&&e.is_sdk_auto_track?r+=a:r+=u;varc=t-(null==e?void0:e.action_time)+1;returnc>0?r+1/c:r}},{key:"formatWeight",value:function(t,e){varn=N,r=D,i=L;returnt-e>2592e6&&(n/=100,r/=100,i/=100),{ogWeight:n,sdkWeight:r,userWeight:i}}}]),e}();Gt([Dt],Bt.prototype,"getReportableActions",1),Gt([Dt],Bt.prototype,"addAction",1),Gt([Dt],Bt.prototype,"removeActions",1),Gt([Dt],Bt.prototype,"updateActionsForReportFail",1),Gt([Dt],Bt.prototype,"updateActionsForReporting",1),Gt([Dt],Bt.prototype,"getReportableActionsLength",1),Gt([Dt],Bt.prototype,"sortQueue",1),Gt([Dt],Bt.prototype,"caculateWeight",1),Gt([Dt],Bt.prototype,"formatWeight",1);varVt=function(){functiont(){f(this,t),this.events={}}returnp(t,[{key:"subscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])?this.events[e].push(n):this.events[e]=[n]}},{key:"once",value:function(e,n){t.checkCallback(n),this.subscribe(this.onceEventName(e),n)}},{key:"unsubscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])&&(this.events[e]=this.events[e].filter(function(t){returnt!==n})),_t(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)]=this.events[this.onceEventName(e)].filter(function(t){returnt!==n}))}},{key:"publish",value:function(t){for(vare=arguments.length,n=newArray(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];vari=Date.now();_t(this.events[t])&&this.events[t].forEach(function(t){returnt.apply(void0,[i].concat(n))}),_t(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)].forEach(function(t){returnt.apply(void0,[i].concat(n))}),this.events[this.onceEventName(t)]=[])}},{key:"onceEventName",value:function(t){return"once_event_prefix_".concat(t)}}],[{key:"checkCallback",value:function(e){gt(e)||xt.error(t.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),t}(),Kt=Vt;Kt.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";varQt=newKt,Yt=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],Wt="START_APP",Jt="TICKET",Ht="ENTER_FOREGROUND",zt="ENTER_BACKGROUND",$t="LOGIN",Xt="SHARE",Zt="TAP_GAME_CLUB",te="CREATE_GAME_CLUB",ee="CREATE_GAME_ROOM",ne="JOIN_GAME_ROOM",re="FINISH_PAY",ie="START_PAY",oe="ADD_TO_WISHLIST",ae=["REGISTER","START_APP","RE_ACTIVE"],ue=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],ce=function(){functiont(){f(this,t),this.channelClaimActionList=ae,this.noClaimActionList=ue,this.realTimeActionList=E.realTimeActionList,this.ticketInterval=60,this.requestTimeout=E.requestTimeout,this.loadConfig()}returnp(t,[{key:"getChannelClaimActionList",value:function(){returnthis.channelClaimActionList}},{key:"getNoClaimActionList",value:function(){returnthis.noClaimActionList}},{key:"getRealTimeActionList",value:function(){returnthis.realTimeActionList}},{key:"getTicketInterval",value:function(){returnthis.ticketInterval}},{key:"getRequestTimeout",value:function(){returnthis.requestTimeout}},{key:"loadConfig",value:function(){vart=this;try{if("undefined"==typeofwx)return;vare=tt.getSync(k);e&&this.updateConfig(e),lt({conf_name:"mini_game_sdk_common",conf_key:"config"}).then(function(e){e&&ht(e)&&(t.updateConfig(e),tt.setSync(k,e))})}catch(e){console.error(e)}}},{key:"updateConfig",value:function(t){t.channelClaimActionList&&_t(t.channelClaimActionList)&&(this.channelClaimActionList=t.channelClaimActionList),t.noClaimActionList&&_t(t.noClaimActionList)&&(this.noClaimActionList=t.noClaimActionList),t.realTimeActionList&&_t(t.realTimeActionList)&&(this.realTimeActionList=t.realTimeActionList),t.ticketInterval&&"number"==typeoft.ticketInterval&&t.ticketInterval>1&&t.ticketInterval!==this.ticketInterval&&(this.ticketInterval=t.ticketInterval,Qt.publish(Z)),t.requestTimeout&&"number"==typeoft.requestTimeout&&t.requestTimeout>5e3&&(this.requestTimeout=t.requestTimeout)}}]),t}(),se=newce,le=Wt,fe=Jt,de=Ht,pe=zt,ve=function(){vart=!0,e=!0,n=!0,r=!0,i=!0,o=!1;returnfunction(){if(!o){o=!0;vara=tt.getSync(R);if((null==a?void0:a.bg)===K?t=!0:(null==a?void0:a.bg)===Q&&(t=!1),(null==a?void0:a.fg)===K?e=!0:(null==a?void0:a.fg)===Q&&(e=!1),(null==a?void0:a.st)===K?n=!0:(null==a?void0:a.st)===Q&&(n=!1),(null==a?void0:a.ti)===K?r=!0:(null==a?void0:a.ti)===Q&&(r=!1),xt.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",t,e,n,r),n&&Qt.publish(le),r){varu=function(){i&&Qt.publish(fe)},c=setInterval(u,1e3*se.getTicketInterval());Qt.subscribe(Z,function(){c&&clearInterval(c),c=setInterval(u,1e3*se.getTicketInterval())})}wx.onShow(function(t){if(i=!0,e){varn="";try{(n=JSON.stringify(t)).length>1e4&&(n=JSON.stringify({cut:1,scene:t.scene}))}catch(t){}Qt.publish(de,{enter_options:n})}}),wx.onHide(function(){if(i=!1,t){vare=0;0!==Nt.activeDuration&&(e=Date.now()-Nt.activeDuration,Nt.activeDuration=0),Qt.publish(pe,{duration:e>0?e:0})}})}}}(),he="undefined"!=typeofglobalThis?globalThis:"undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:{};wx.$adqSdkReport=Qt;function_e(t){returnt&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}varge,ye=_e(function(){vart,e=null;functionn(t){return!!t&&("object"==l(t)||"function"==typeoft)}functionr(t){if(null!==t&&!n(t))thrownewTypeError("Object prototype may only be an Object or null:"+t)}vari=Object,o=!(!i.create&&{__proto__:null}instanceofi),a=i.create||(o?function(t){returnr(t),{__proto__:t}}:function(t){if(r(t),null===t)thrownewSyntaxError("Native Object.create is required to create objects with null prototype");vare=function(){};returne.prototype=t,newe}),u=function(){returnnull},c=i.getPrototypeOf||([].__proto__===Array.prototype?function(t){vare=t.__proto__;returnn(e)?e:null}:u);returnt=function(s,l){if(void0===(this&&thisinstanceoft?this.constructor:void0))thrownewTypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))thrownewTypeError("Cannot create proxy with a non-object as target or handler");varf=function(){};e=function(){s=null,f=function(t){thrownewTypeError("Cannot perform '".concat(t,"' on a proxy that has been revoked"))}},setTimeout(function(){e=null},0);vard=l;for(varpinl={get:null,set:null,apply:null,construct:null},d){if(!(pinl))thrownewTypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=d[p]}"function"==typeofd&&(l.apply=d.apply.bind(d));varv,h=c(s),_=!1,g=!1;"function"==typeofs?(v=function(){vart=this&&this.constructor===v,e=Array.prototype.slice.call(arguments);returnf(t?"construct":"apply"),t&&l.construct?l.construct.call(this,s,e):!t&&l.apply?l.apply(s,this,e):t?(e.unshift(s),new(s.bind.apply(s,e))):s.apply(this,e)},_=!0):sinstanceofArray?(v=[],g=!0):v=o||null!==h?a(h):{};vary=l.get?function(t){returnf("get"),l.get(this,t,v)}:function(t){returnf("get"),this[t]},m=l.set?function(t,e){f("set"),l.set(this,t,e,v)}:function(t,e){f("set"),this[t]=e},A=i.getOwnPropertyNames(s),R={};A.forEach(function(t){if(!_&&!g||!(tinv)){vare={enumerable:!!i.getOwnPropertyDescriptor(s,t).enumerable,get:y.bind(s,t),set:m.bind(s,t)};i.defineProperty(v,t,e),R[t]=!0}});vark=!0;if(_||g){varS=i.setPrototypeOf||([].__proto__===Array.prototype?function(t,e){returnr(e),t.__proto__=e,t}:u);h&&S(v,h)||(k=!1)}if(l.get||!k)for(varTins)R[T]||i.defineProperty(v,T,{get:y.bind(s,T)});returni.seal(s),i.seal(v),v},t.revocable=function(n,r){return{proxy:newt(n,r),revoke:e}},t}),me={};try{ge||(ge=ye())}catch(h){Te(h)}functionAe(t,n,r,i){try{if(!ge||null==t||!t[n])return;t[n]=newge(t[n],{apply:function(t,n,o){vara,u;i&&Se(function(){returni.apply(void0,e(o))});varc=!!(null!=(a=o[0])&&a.success||null!=(u=o[0])&&u.fail);c&&["success","fail"].forEach(function(t){if(o[0][t])try{o[0][t]=newge(o[0][t],{apply:function(n,i,a){returnSe(function(){returnr.apply(void0,[t,o[0]].concat(e(a)))}),n.apply(i,a)}})}catch(t){Te(t)}});vars=t.apply(n,o);return!c&&s&&"[object Promise]"===Object.prototype.toString.call(s)?s.then(function(t){returnSe(function(){returnr("success",o[0],t)}),t}).catch(function(t){throwSe(function(){returnr("fail",o[0],t)}),t}):s}})}catch(t){Te(t)}}functionRe(t,n,r){try{if(!ge||null==t||!t[n])return;t[n]=newge(t[n],{apply:function(t,n,i){varo="function"==typeofi[0];if(o)try{i[0]=newge(i[0],{apply:function(t,n,i){varo=t.call.apply(t,[n].concat(e(i)));returnSe(function(){returnr(o)}),o}})}catch(t){Te(t)}vara=t.call.apply(t,[n].concat(e(i)));returno||Se(function(){returnr(a)}),a}})}catch(t){Te(t)}}functionke(t){varn=arguments.length>1&&void0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void0,i=arguments.length>3&&void0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void0;try{if(!ge||null==t||!t[n])return;t[n]=newge(t[n],{apply:function(t,a,u){varc=t.call.apply(t,[a].concat(e(u)));return(!r||!me[n])&&(Se(function(){returnnull==o?void0:o(c)}),i.forEach(function(t){vare=t.eventName,n=t.isAsync,r=t.proxyEvent;n?Ae(c,e,r):Re(c,e,r)})),r&&(me[n]=!0),c}})}catch(t){Te(t)}}functionSe(t){try{t()}catch(t){Te(t)}}functionTe(t){ct({log_type:b.PROXY_ERROR,message:null==t?void0:t.message,err_stack:null==t?void0:t.stack})}varEe=$t,be=oe,Oe=Xt,Ie=Zt,we=te,Ce=ne,xe=ie,Ne=re,Le=function(){vart=!1;returnfunction(){t||(t=!0,Ae(wx,"login",function(t){"success"===t&&Qt.publish(Ee)}),Re(wx,"onAddToFavorites",function(){Qt.publish(be)}),Re(wx,"onShareTimeline",function(){Qt.publish(Oe,{target:"TIME_LINE",trigger:"MENU"})}),Re(wx,"onShareAppMessage",function(){Qt.publish(Oe,{target:"APP_MESSAGE",trigger:"MENU"})}),Re(wx,"shareAppMessage",function(){Qt.publish(Oe,{target:"APP_MESSAGE",trigger:"BUTTON"})}),ke(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Qt.publish(Ie)}}],function(){Qt.publish(we)}),ke(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(t){"success"===t&&Qt.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(t){"success"===t&&Qt.publish(Ce)}}]))}}(),De=function(){functiont(){f(this,t)}returnp(t,null,[{key:"isEmpty",value:function(t){returnnull==t||"string"==typeoft&&""===t.trim()}},{key:"format",value:function(t){for(vare=arguments.length,n=newArray(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];returnt.replace(/\${(\d+)}/g,function(t,e){returnn[e]})}},{key:"customStringify",value:function(t){vare=[];try{returnJSON.stringify(t,function(t,n){if(void0===n)return"undefined";if("object"==l(n)&&null!==n){if(-1!==e.indexOf(n))return"[Circular]";e.push(n)}return"bigint"==typeofn?n.toString():n})}catch(t){return"[Param Error]"}}}]),t}(),Me=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,Pe=/^ams_reserved_(.*)/i,Ue=function(){functiont(){f(this,t)}returnp(t,null,[{key:"validateActionType",value:function(e){returnDe.isEmpty(e)?(xt.error(t.ERROR_ACTION_TYPE_NULL),!1):!!Me.test(e)||(xt.error(t.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(e){if(!e)return!0;if(!ht(e))returnxt.error(t.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(varnine){if(De.isEmpty(n))returnxt.error(t.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!Me.test(n))returnxt.error(t.ERROR_ACTION_PARAM_KEY_INVALID),!1;Pe.test(n)&&xt.warn(t.WARN_ACTION_PARAM_KEY_RESERVED);varr=e[n];if(!t.isValidValue(r))returnxt.error(De.format(t.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(_t(r)){if(!t.isValidArrayValue(r)){for(vari=0;i<r.length;i++)xt.error(De.format(t.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,De.customStringify(r),i,r[i]));return!1}if(!t.checkArrayElementTypes(r))returnxt.error(t.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(t){returnnull==t||"string"==typeoft||"number"==typeoft||"boolean"==typeoft||_t(t)}},{key:"isValidArrayValue",value:function(t){for(vare=0;e<t.length;e++){varn=t[e];if("string"!=typeofn&&"number"!=typeofn&&"boolean"!=typeofn)return!1}return!0}},{key:"checkArrayElementTypes",value:function(t){if(!t||t.length<=1)return!0;for(vare=l(t[0]),n=1;n<t.length;n++)if(l(t[n])!==e)return!1;return!0}}]),t}(),qe=Ue;qe.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",qe.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",qe.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",qe.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",qe.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",qe.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0},value=${1}]",qe.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0},value=${1},数组的第${2}个元素为${3}]",qe.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",qe.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";varFe={exports:{}};!function(t){!function(e){functionn(t,e){varn=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}functionr(t,e,r,i,o,a){returnn(function(t,e){returnt<<e|t>>>32-e}(n(n(e,t),n(i,a)),o),r)}functioni(t,e,n,i,o,a,u){returnr(e&n|~e&i,t,e,o,a,u)}functiono(t,e,n,i,o,a,u){returnr(e&i|n&~i,t,e,o,a,u)}functiona(t,e,n,i,o,a,u){returnr(e^n^i,t,e,o,a,u)}functionu(t,e,n,i,o,a,u){returnr(n^(e|~i),t,e,o,a,u)}functionc(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;varr,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r<t.length;r+=16)c=d,s=p,l=v,f=h,d=i(d,p,v,h,t[r],7,-680876936),h=i(h,d,p,v,t[r+1],12,-389564586),v=i(v,h,d,p,t[r+2],17,606105819),p=i(p,v,h,d,t[r+3],22,-1044525330),d=i(d,p,v,h,t[r+4],7,-176418897),h=i(h,d,p,v,t[r+5],12,1200080426),v=i(v,h,d,p,t[r+6],17,-1473231341),p=i(p,v,h,d,t[r+7],22,-45705983),d=i(d,p,v,h,t[r+8],7,1770035416),h=i(h,d,p,v,t[r+9],12,-1958414417),v=i(v,h,d,p,t[r+10],17,-42063),p=i(p,v,h,d,t[r+11],22,-1990404162),d=i(d,p,v,h,t[r+12],7,1804603682),h=i(h,d,p,v,t[r+13],12,-40341101),v=i(v,h,d,p,t[r+14],17,-1502002290),d=o(d,p=i(p,v,h,d,t[r+15],22,1236535329),v,h,t[r+1],5,-165796510),h=o(h,d,p,v,t[r+6],9,-1069501632),v=o(v,h,d,p,t[r+11],14,643717713),p=o(p,v,h,d,t[r],20,-373897302),d=o(d,p,v,h,t[r+5],5,-701558691),h=o(h,d,p,v,t[r+10],9,38016083),v=o(v,h,d,p,t[r+15],14,-660478335),p=o(p,v,h,d,t[r+4],20,-405537848),d=o(d,p,v,h,t[r+9],5,568446438),h=o(h,d,p,v,t[r+14],9,-1019803690),v=o(v,h,d,p,t[r+3],14,-187363961),p=o(p,v,h,d,t[r+8],20,1163531501),d=o(d,p,v,h,t[r+13],5,-1444681467),h=o(h,d,p,v,t[r+2],9,-51403784),v=o(v,h,d,p,t[r+7],14,1735328473),d=a(d,p=o(p,v,h,d,t[r+12],20,-1926607734),v,h,t[r+5],4,-378558),h=a(h,d,p,v,t[r+8],11,-2022574463),v=a(v,h,d,p,t[r+11],16,1839030562),p=a(p,v,h,d,t[r+14],23,-35309556),d=a(d,p,v,h,t[r+1],4,-1530992060),h=a(h,d,p,v,t[r+4],11,1272893353),v=a(v,h,d,p,t[r+7],16,-155497632),p=a(p,v,h,d,t[r+10],23,-1094730640),d=a(d,p,v,h,t[r+13],4,681279174),h=a(h,d,p,v,t[r],11,-358537222),v=a(v,h,d,p,t[r+3],16,-722521979),p=a(p,v,h,d,t[r+6],23,76029189),d=a(d,p,v,h,t[r+9],4,-640364487),h=a(h,d,p,v,t[r+12],11,-421815835),v=a(v,h,d,p,t[r+15],16,530742520),d=u(d,p=a(p,v,h,d,t[r+2],23,-995338651),v,h,t[r],6,-198630844),h=u(h,d,p,v,t[r+7],10,1126891415),v=u(v,h,d,p,t[r+14],15,-1416354905),p=u(p,v,h,d,t[r+5],21,-57434055),d=u(d,p,v,h,t[r+12],6,1700485571),h=u(h,d,p,v,t[r+3],10,-1894986606),v=u(v,h,d,p,t[r+10],15,-1051523),p=u(p,v,h,d,t[r+1],21,-2054922799),d=u(d,p,v,h,t[r+8],6,1873313359),h=u(h,d,p,v,t[r+15],10,-30611744),v=u(v,h,d,p,t[r+6],15,-1560198380),p=u(p,v,h,d,t[r+13],21,1309151649),d=u(d,p,v,h,t[r+4],6,-145523070),h=u(h,d,p,v,t[r+11],10,-1120210379),v=u(v,h,d,p,t[r+2],15,718787259),p=u(p,v,h,d,t[r+9],21,-343485551),d=n(d,c),p=n(p,s),v=n(v,l),h=n(h,f);return[d,p,v,h]}functions(t){vare,n="",r=32*t.length;for(e=0;e<r;e+=8)n+=String.fromCharCode(t[e>>5]>>>e%32&255);returnn}functionl(t){vare,n=[];for(n[(t.length>>2)-1]=void0,e=0;e<n.length;e+=1)n[e]=0;varr=8*t.length;for(e=0;e<r;e+=8)n[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;returnn}functionf(t){vare,n,r="0123456789abcdef",i="";for(n=0;n<t.length;n+=1)e=t.charCodeAt(n),i+=r.charAt(e>>>4&15)+r.charAt(15&e);returni}functiond(t){returnunescape(encodeURIComponent(t))}functionp(t){returnfunction(t){returns(c(l(t),8*t.length))}(d(t))}functionv(t,e){returnfunction(t,e){varn,r,i=l(t),o=[],a=[];for(o[15]=a[15]=void0,i.length>16&&(i=c(i,8*t.length)),n=0;n<16;n+=1)o[n]=909522486^i[n],a[n]=1549556828^i[n];returnr=c(o.concat(l(e)),512+8*e.length),s(c(a.concat(r),640))}(d(t),d(e))}functionh(t,e,n){returne?n?v(e,t):function(t,e){returnf(v(t,e))}(e,t):n?p(t):function(t){returnf(p(t))}(t)}t.exports?t.exports=h:e.md5=h}(he)}(Fe);varje=_e(Fe.exports),Ge="function"==typeofbtoa,Be="function"==typeofBuffer;"function"==typeofTextDecoder&&newTextDecoder;varVe,Ke="function"==typeofTextEncoder?newTextEncoder:void0,Qe=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Ve={},Qe.forEach(function(t,e){returnVe[t]=e});varYe=String.fromCharCode.bind(String);"function"==typeofUint8Array.from&&Uint8Array.from.bind(Uint8Array);varWe=Ge?function(t){returnbtoa(t)}:Be?function(t){returnBuffer.from(t,"binary").toString("base64")}:function(t){for(vare,n,r,i,o="",a=t.length%3,u=0;u<t.length;){if((n=t.charCodeAt(u++))>255||(r=t.charCodeAt(u++))>255||(i=t.charCodeAt(u++))>255)thrownewTypeError("invalid character found");o+=Qe[(e=n<<16|r<<8|i)>>18&63]+Qe[e>>12&63]+Qe[e>>6&63]+Qe[63&e]}returna?o.slice(0,a-3)+"===".substring(a):o},Je=Be?function(t){returnBuffer.from(t).toString("base64")}:function(t){for(vare=[],n=0,r=t.length;n<r;n+=4096)e.push(Ye.apply(null,t.subarray(n,n+4096)));returnWe(e.join(""))},He=function(t){if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?Ye(192|e>>>6)+Ye(128|63&e):Ye(224|e>>>12&15)+Ye(128|e>>>6&63)+Ye(128|63&e);vare=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);returnYe(240|e>>>18&7)+Ye(128|e>>>12&63)+Ye(128|e>>>6&63)+Ye(128|63&e)},ze=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,$e=Be?function(t){returnBuffer.from(t,"utf8").toString("base64")}:Ke?function(t){returnJe(Ke.encode(t))}:function(t){returnWe(function(t){returnt.replace(ze,He)}(t))},Xe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,tn=function(t,e,n,r){for(vari,o=r>1?void0:r?Ze(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&Xe(e,n,o),o},en=function(){functiont(e){varn=this;f(this,t),this.cgiBatchSize=E.cgiBatchSize,this.reportThreshold=E.reportThreshold,this.reportDelay=E.reportDelay,this.triggerExecuteSend=function(t){vare,n=arguments.length>1&&void0!==arguments[1]?arguments[1]:0,r=[];returnfunction(){for(vari=arguments.length,o=newArray(i),a=0;a<i;a++)o[a]=arguments[a];returnclearTimeout(e),e=setTimeout(function(){vare=t.apply(void0,o);r.forEach(function(t){returnt(e)}),r=[]},n),newPromise(function(t){returnr.push(t)})}}(function(){n.executeSend()},1e3*this.reportDelay),this.inspectDelay=E.inspectDelay,this.inspectTimer=void0,this.isNeedContinueSend=!1,this.getBaseInfo=e.getBaseInfo,this.reportLog=e.reportLog,this.queueManager=e.queueManager,this.configManager=e.configManager,this.onReportComplete=e.onReportComplete,this.onReportFail=e.onReportFail,this.flushSend(),this.startInspectTimer()}returnp(t,[{key:"batchSend",value:function(){vart,e=this.queueManager.getReportableActions(this.reportThreshold);if(e.length>=this.reportThreshold)this.executeSend();else{varn=(null==(t=this.configManager)?void0:t.getRealTimeActionList())||E.realTimeActionList;e.some(function(t){returnn.indexOf(t.action_type)>-1&&!t.is_retry})?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){vare=this;if(!Nt.hasDirectGameMask)if(t.currentRequestCount>=t.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;varn=(t.requestConcurrency-t.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),i=this.getBaseInfo();if(!i.openid&&!i.unionid&&(xt.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter(function(t){returnnull==t?void0:t.ad_trace_id})),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),t.currentRequestCount+=Math.ceil(r.length/this.cgiBatchSize);for(varo=[],a=0;a<r.length;a+=this.cgiBatchSize){varu=this.generateActionReportParams(r.slice(a,a+this.cgiBatchSize));o.push(this.report(u))}Promise.all(o).then(function(t){varn=t.some(function(t){returnt>=0});e.isNeedContinueSend&&n&&e.executeSend()}).catch(function(t){xt.error(t),e.reportLog({message:"executeSend catch:".concat(t.message),log_type:b.JS_RUN_ERROR,err_stack:t.stack})})}}}},{key:"generateActionReportParams",value:function(t){vare=[],n=[],r=this.getBaseInfo();returnt.forEach(function(t){n.push(t.action_id);varr=Object.assign({},t);deleter.inner_status,e.push(r)}),{data:{info:r,actions:e},actionIdList:n}}},{key:"dealSuccessData",value:function(t,e,n){[51001,51003].indexOf(null==t?void0:t.code)>-1?this.queueManager.updateActionsForReportFail(e):this.queueManager.removeActions(e),0!==(null==t?void0:t.code)&&(this.reportLog({log_type:b.REQUEST_ERROR,code:null==t?void0:t.code,message:"trace_id:".concat(null==t?void0:t.trace_id,",msg:").concat(null==t?void0:t.message)}),xt.error("上报失败:",t)),this.doTrackCallbackFn(this.onReportComplete,t,n),-1===[0,51001,51003].indexOf(null==t?void0:t.code)&&this.doTrackCallbackFn(this.onReportFail,t,n)}},{key:"dealFailData",value:function(t,e,n){this.queueManager.updateActionsForReportFail(e),this.reportLog({log_type:b.REQUEST_ERROR,code:t.code,message:t.message}),xt.error("上报失败:",t),this.doTrackCallbackFn(this.onReportComplete,t,n)}},{key:"report",value:function(e){varn=this,r=e.data,i=e.actionIdList;returnthis.queueManager.updateActionsForReporting(i),xt.debug&&(xt.info("上报行为类型:","【".concat(r.actions.map(function(t){returnt.action_type}).join("、"),"】")),xt.info("上报请求参数:",r)),newPromise(function(e){varo,a,u,c,s,f,d,p,v=Date.now();try{varh=function(t){vare="",n=null==t?void0:t.appid,r=null==t?void0:t.secret_key,i=null==t?void0:t.sdk_version,o=null==t?void0:t.timestamp;if(!(n&&r&&i&&o&&32===r.length))returne;for(vara=je(i+n+o),u=0;u<32;u++)e+=u%2==0?r[u]:a[u];returne}({appid:null==(o=null==r?void0:r.info)?void0:o.appid,secret_key:null==(a=null==r?void0:r.info)?void0:a.secret_key,sdk_version:null==(u=null==r?void0:r.info)?void0:u.sdk_version,timestamp:v}),_=function(t){returnarguments.length>1&&void0!==arguments[1]&&arguments[1]?function(t){returnt.replace(/=/g,"").replace(/[+\/]/g,function(t){return"+"==t?"-":"_"})}($e(t)):$e(t)}(JSON.stringify(r));d={"Client-Time":v,"Sign-Value":je(_+(null==(c=null==r?void0:r.info)?void0:c.user_action_set_id)+(null==(s=null==r?void0:r.info)?void0:s.secret_key)+h),"Sign-Version":E.signVersion,"content-type":"text/plain;charset=UTF-8"},p=_}catch(h){d={"Client-Time":v},p=r,n.reportLog({log_type:b.SIGN_ERROR,message:"sign error msg:".concat(null==h?void0:h.message),err_stack:null==h?void0:h.stack}),xt.error(h)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(f=n.configManager)?void0:f.getRequestTimeout())||E.requestTimeout,header:d,data:p,success:function(o){vara,u;xt.devLog("上报接口返回码:",null==(a=null==o?void0:o.data)?void0:a.code);varc=(null==(u=null==o?void0:o.header)?void0:u["Server-Time"])||-1;if(st.revise(c),t.currentRequestCount-=1,200===(null==o?void0:o.statusCode))returnn.dealSuccessData(null==o?void0:o.data,i,r),voide((null==o?void0:o.data).code);vars="";try{s="object"==l(null==o?void0:o.data)?JSON.stringify(null==o?void0:o.data):null==o?void0:o.data}catch(t){xt.error(t)}varf={code:"number"==typeof(null==o?void0:o.statusCode)?-1*o.statusCode:-888,message:"statusCode:".concat(null==o?void0:o.statusCode,",data:").concat(s)};n.dealFailData(f,i,r),e(f.code)},fail:function(o){xt.devLog("上报失败:",o),t.currentRequestCount-=1;vara={code:"number"==typeof(null==o?void0:o.errno)?-1*o.errno:-999,message:null==o?void0:o.errMsg};n.dealFailData(a,i,r),e(a.code)}})})}},{key:"startInspectTimer",value:function(){vare=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout(function(){t.currentRequestCount>=t.requestConcurrency&&(t.currentRequestCount=t.requestConcurrency-1),e.executeSend(),e.startInspectTimer()},1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(t,e,n){if("function"==typeoft)try{for(varr=[],i=0;i<n.actions.length;i++)if(!n.actions[i].is_sdk_auto_track){varo=n.actions[i],a=o.action_type,u=o.action_param,c=o.action_id,s=o.action_time;r.push({action_type:a,action_param:u,action_id:c,action_time:s})}if(r.length){varl=n.info,f=l.user_action_set_id,d=l.appid,p=l.openid,v=l.unionid,h=l.user_unique_id;t({code:null==e?void0:e.code,message:null==e?void0:e.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:h}}})}}catch(r){xt.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(e){"number"==typeofe?e<1?xt.error("网络请求最大并发量不能小于1"):e>10?xt.error("网络请求最大并发量不能大于10"):t.requestConcurrency=e:xt.error("网络请求最大并发量需设置为数字")}}]),t}(),nn=en;nn.currentRequestCount=0,nn.requestConcurrency=E.requestConcurrency,tn([Dt],nn.prototype,"batchSend",1),tn([Dt],nn.prototype,"flushSend",1),tn([Dt],nn.prototype,"executeSend",1);varrn=Wt,on=Jt,an=Ht,un=zt,cn=$t,sn=oe,ln=Xt,fn=Zt,dn=te,pn=ne,vn=ie,hn=re,_n=ee,gn=function(){functione(){f(this,e)}returnp(e,[{key:"install",value:function(e,n){varr=function(n){Qt.subscribe(n,function(n){varr=arguments.length>1&&void0!==arguments[1]?arguments[1]:{};returnfunction(i){varo=arguments.length>1&&void0!==arguments[1]?arguments[1]:{};Nt.hasDirectGameMask||("ENTER_FOREGROUND"===n&&(Nt.activeDuration=Date.now()),e.track(n,Object.assign(r||{},o,t(t({},wn,!0),Cn,i))))}}(n))};r(on),r(rn),r(an),r(un),"all"===n&&(r(cn),r(sn),r(ln),r(dn),r(fn),r(_n),r(pn),r(vn),r(hn))}}]),e}(),yn=function(){functione(){f(this,e),this.special_method_symbol=Symbol("special_method_symbol")}returnp(e,[{key:"onPurchase",value:function(t){return"number"!=typeoft&&xt.warn("付费金额需要为数字"),t<=0&&xt.warn("付费金额需要大于0"),this.wrapTrack(F,{value:t})}},{key:"onEnterForeground",value:function(){returnthis.wrapTrack(P)}},{key:"onEnterBackground",value:function(){returnthis.wrapTrack(U)}},{key:"onAppStart",value:function(){returnthis.wrapTrack(M)}},{key:"onAppQuit",value:function(){returnthis.wrapTrack(j)}},{key:"onAddToWishlist",value:function(){returnthis.wrapTrack(q)}},{key:"wrapTrack",value:function(e,n){returnthis.track(e,Object.assign(n||{},t({},this.special_method_symbol,1)))}}]),e}(),mn=function(){i(e,yn);vart=a(e);functione(){returnf(this,e),t.apply(this,arguments)}returnp(e,[{key:"onRegister",value:function(){returnthis.wrapTrack(G)}},{key:"onCreateRole",value:function(t){returnt&&"string"!=typeoft&&xt.warn("角色名称需要为字符串"),this.wrapTrack(B,t?{name:t}:{})}},{key:"onTutorialFinish",value:function(){returnthis.wrapTrack(V)}}]),e}(),An="(如果确认无误,请忽略该提示)",Rn=function(){vart=[];return{requestActionList:function(){try{lt({conf_name:"data_nexus_common",conf_key:"action_types"}).then(function(e){_t(e)&&(t=e)})}catch(t){xt.error(t)}},getActionList:function(){returnt}}}();functionkn(t,e){try{t.is_sdk_auto_track||(function(t){try{vare=Rn.getActionList();if(!e.includes(t)){varr,i=function(t){vare="undefined"!=typeofSymbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=n(t))){e&&(t=e);varr=0,i=function(){};return{s:i,n:function(){returnr>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throwt},f:i}}thrownewTypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable,non-array objects must have a[Symbol.iterator]()method.")}varo,a=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){vart=e.next();returna=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throwo}}}}(e);try{for(i.s();!(r=i.n()).done;){varo=r.value;if(Sn(o,t)<=parseInt((.3*o.length).toString())){xt.warn("通过SDK上报的".concat(t,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(An));break}}}catch(t){i.e(t)}finally{i.f()}}}catch(e){xt.error(e)}}(t.action_type),"minigame"===e?function(t,e){varn,r,i;try{["PURCHASE","ADD_TO_CART"].includes(t.action_type)&&t.action_param&&It(t.action_param,"value")&&("number"!=typeof(null==(n=t.action_param)?void0:n.value)?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要为数字!")):(null==(r=t.action_param)?void0:r.value)<=0?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要大于0!")):"minigame"===e&&(null==(i=t.action_param)?void0:i.value)<100&&xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(An)))}catch(t){xt.error(t)}}(t,e):"miniprogram"===e&&function(t){try{vare=null==t?void0:t.action_type,n=(null==t?void0:t.action_param)||{};"PURCHASE"===e&&It(n,"value")&&("number"!=typeof(null==n?void0:n.value)?xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要为数字!")):(null==n?void0:n.value)<=0&&xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要大于0!")))}catch(e){xt.error(e)}}(t))}catch(t){xt.error(t)}}functionSn(t,e){try{if(0===t.length)returne.length;if(0===e.length)returnt.length;for(varn=[],r=0;r<=e.length;r++)n[r]=[r];for(vari=0;i<=t.length;i++)n[0][i]=i;for(varo=1;o<=e.length;o++)for(vara=1;a<=t.length;a++)e.charAt(o-1)===t.charAt(a-1)?n[o][a]=n[o-1][a-1]:n[o][a]=Math.min(n[o-1][a-1]+1,n[o][a-1]+1,n[o-1][a]+1);returnn[e.length][t.length]}catch(n){xt.error(n)}}functionTn(t){try{t&&!/^[a-zA-Z0-9_\-]+$/.test(t)&&xt.warn("通过SDK上报的openid:".concat(t,"可能有误,请检查openid是否正确!").concat(An))}catch(t){xt.error(t)}}varEn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,On=function(t,e,n,r){for(vari,o=r>1?void0:r?bn(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&En(e,n,o),o},In=Symbol("initializedInstance"),wn=Symbol("autoTrack"),Cn=Symbol("actionTime"),xn=function(){i(n,mn);vare=a(n);functionn(t){varr;if(f(this,n),(r=e.call(this)).env="production",r.sdk_version="1.5.7",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)returnr.initErrMsg="不支持非微信小游戏中使用",xt.error(r.initErrMsg),u(r);vari=Ot();if(n[In].length>=i.maxSdkInstance)returnr.initErrMsg="初始化超过上限",xt.error(r.initErrMsg),u(r);varo=Et(t),a=at();if(!0!==o)returnr.initErrMsg=o,xt.error(o),u(r);vars=null==a?void0:a.appId;if(s&&s!==t.appid)returnr.initErrMsg="初始化传入的appid与当前小游戏appid不一致",xt.error(r.initErrMsg),u(r);r.config=t,It(t,"auto_track")||(r.config.auto_track=bt("autoTrack")),r.openid=t.openid,r.unionid=t.unionid,r.user_unique_id=t.user_unique_id,r.onReportComplete=t.on_report_complete,r.onReportFail=t.on_report_fail,r.saveValidOpenidToStorage();varl=t.user_action_set_id;returnn[In].includes(l)?(r.initErrMsg="同个数据源[".concat(l,"]只能初始化一次"),xt.error(r.initErrMsg),r.reportLog({log_type:b.JS_RUN_ERROR,message:r.initErrMsg}),u(r)):(r.reportLog=r.reportLog.bind(c(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(c(r)),Nt.activeDuration=Date.now(),r.initDirectGameConfig(),r.deviceInfo=nt(),r.gameInfo=Lt(),r.session_id=mt(),r.queueManage=newBt({userActionSetId:l,maxLength:i.maxQueueLength,ogEvents:Yt}),r.actionReporter=newnn({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:se,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,n[In].push(l),r.useAutoTrack(),r.addDirectGameStatusListener(),r.doReportOnEnterBackground(),"release"===(null==a?void0:a.envVersion)?(xt.info("初始化成功"),u(r)):(function(t){vare=t.sdk_version,n=t.default_download_url,r=t.fail_handler;lt({conf_name:t.conf_name,conf_key:t.conf_key}).then(function(t){if(ht(t)){vari=null==t?void0:t.blackVersions,o=null==t?void0:t.minVersion,a=null==t?void0:t.bestVersion,u=null==t?void0:t.downloadUrl,c=n;returnu&&/^https/.test(u)&&(c=u),_t(i)&&(null==i?void0:i.indexOf(e))>-1?(null==r||r(),voidxt.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):o&&Tt(e,o)<0?(null==r||r(),voidxt.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Tt(e,a)<0&&xt.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),voidxt.info("初始化成功"))}xt.info("初始化成功")}).catch(function(){xt.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}}),Rn.requestActionList(),Tn(t.openid),u(r)))}returnp(n,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(t,e){varn,r;if(!this.inited||!this.queueManage)returnxt.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};vari=qe.validateActionType(t),o=qe.validateActionParam(e);if(i&&o){!this.openid&&!this.unionid&&xt.warn("缺少 openid 或 unionid");vara=bt("actionParamMaxLength");if(JSON.stringify(e||{}).length>a)returnxt.error("监测到超过".concat(a,"的上报日志:").concat(t," ").concat(e)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};varu=!(null==e||!e[wn]),c=this.createAction(t,e||{},u);"release"!==(null==(n=at())?void0:n.envVersion)&&kn(c,"minigame");vars=this.queueManage.addAction(c);returnnull==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){vart;null==(t=this.actionReporter)||t.flushSend()}},{key:"setOpenId",value:function(t){vare;if(t&&"string"==typeoft)returnthis.openid=t,this.gameInfo.ad_trace_id&&!tt.getSync(S)&&Qt.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(e=at())?void0:e.envVersion)&&Tn(t),{code:0,message:"成功"};varn="openid 格式错误";returnxt.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(t){if(t&&"string"==typeoft)returnthis.unionid=t,this.flush(),{code:0,message:"成功"};vare="unionid 格式错误";returnxt.error(e),{code:101,message:e}}},{key:"setUserUniqueId",value:function(t){if(t&&"string"==typeoft)returnthis.user_unique_id=t,{code:0,message:"成功"};vare="user_unique_id 格式错误";returnxt.error(e),{code:101,message:e}}},{key:"doReportOnEnterBackground",value:function(){vart=this;wx.onHide(function(){vare,n;null==(e=t.actionReporter)||e.flushSend(),null==(n=t.queueManage)||n.reportLostNum()})}},{key:"getTrackBaseInfo",value:function(){vart=at();returnObject.assign({},this.deviceInfo,function(t){vare={};return["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"].forEach(function(n){It(t,n)&&(e[n]=t[n])}),e}(this.config),{local_id:rt(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||ot(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:t.envVersion,app_version:t.version}})}},{key:"createAction",value:function(t,e){varn=arguments.length>2&&void0!==arguments[2]&&arguments[2];null!=e&&e[wn]&&deletee[wn];varr=Date.now();null!=e&&e[Cn]&&(r=null==e?void0:e[Cn],deletee[Cn]);vari={action_id:mt(),action_param:e,action_time:r,action_type:t,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:st.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:it(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(t)};returnnull!=e&&e[this.special_method_symbol]&&(this.addActionInnerParam(i,"is_special_method",!0),deletee[this.special_method_symbol]),se.getChannelClaimActionList().indexOf(t)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(i,"launch_options",this.gameInfo.launch_options),i}},{key:"addActionInnerParam",value:function(e,n,r){e.inner_param&&ht(e.inner_param)?e.inner_param[n]=r:e.inner_param=t({},n,r)}},{key:"getChannelByActionType",value:function(t){vare="";returnse.getChannelClaimActionList().indexOf(t)>-1?e=this.gameInfo.channel||"":se.getNoClaimActionList().indexOf(t)>-1&&(e=X),e}},{key:"reportLog",value:function(t){vare,n,r={user_action_set_id:null==(e=this.config)?void0:e.user_action_set_id,appid:null==(n=this.config)?void0:n.appid,session_id:this.session_id};ct(Object.assign(r,t))}},{key:"useAutoTrack",value:function(){vart;if(null!=(t=this.config)&&t.auto_track){vare=!0,n=tt.getSync(R);(null==n?void0:n.ap)===K?e=!0:(null==n?void0:n.ap)===Q&&(e=!1),"devtools"===nt().wx_platform&&(e=!0),(newgn).install(this,e?"all":"lifecycle"),ve(),e&&Le(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){vart,e,n=nt();n.os&&n.os_version&&null!=(t=this.config)&&t.user_action_set_id&&function(t){returnnewPromise(function(e){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:t,timeout:E.requestTimeout,success:function(t){ft(t,e,"minigame/get"),pt(t)},fail:function(t){dt(t,"minigame/get")}})})}({conf_name:"MG",conf_param:{user_action_set_id:null==(e=this.config)?void0:e.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void0:n.os)||"",os_version:wt(n.os_version),device_brand:(null==n?void0:n.device_brand)||"",weixin_lib_version:(null==n?void0:n.wx_lib_version)||"",weixin_version:(null==n?void0:n.wx_version)||""}}).then(function(t){ht(t)&&tt.setSync(R,t)})}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(t){return/^[a-zA-Z0-9_-]{28,30}$/.test(t)}(this.openid)&&tt.setSync(S,this.openid)}},{key:"initDirectGameConfig",value:function(){try{if(xt.log("wx.getDirectAdStatusSync方法是否存在:",wx.getDirectAdStatusSync),wx.getDirectAdStatusSync){vart=wx.getDirectAdStatusSync();xt.log("wx.getDirectAdStatusSync方法返回的值info:",t),t.isInMask&&t.isInDirectGameAd&&(Nt.hasDirectGameMask=!0,xt.log("SDK初始获取的直玩蒙层状态值:",Nt.hasDirectGameMask))}}catch(t){xt.log("获取直玩状态异常:",t)}}},{key:"addDirectGameStatusListener",value:function(){vart=this;try{xt.log("wx.onDirectAdStatusChange方法是否存在:",wx.onDirectAdStatusChange),wx.onDirectAdStatusChange&&wx.onDirectAdStatusChange(function(e){varn=e.isInMask,r=e.isEndByAbnormal;xt.log("wx.onDirectAdStatusChange方法返回的值res:",e),xt.log("状态切换前,SDK的直玩蒙层状态值:",Nt.hasDirectGameMask),Nt.hasDirectGameMask&&!n&&(Nt.hasDirectGameMask=!1,xt.log("状态切换后,SDK的直玩蒙层状态值:",Nt.hasDirectGameMask),t.gameInfo.ad_trace_id&&tt.setSync(m,t.gameInfo.ad_trace_id),Qt.publish("START_APP",{isEndByAbnormal:!!r}),Qt.publish("ENTER_FOREGROUND"))})}catch(t){xt.log("监听直玩状态异常:",t)}}}],[{key:"setRequestConcurrency",value:function(t){nn.setRequestConcurrency(t)}},{key:"setDebug",value:function(t){xt.debug=t}}]),n}(),Nn=xn;Nn[In]=[],On([Dt],Nn.prototype,"track",1),On([Dt,function(t,e,n){varr=n.value;returnn.value=function(){if(this.inited){for(vart=arguments.length,e=newArray(t),n=0;n<t;n++)e[n]=arguments[n];returnr.apply(this,e)}xt.error("上报失败,请先完成初始化")},n}],Nn.prototype,"flush",1),On([Dt],Nn.prototype,"setOpenId",1),On([Dt],Nn.prototype,"setUnionId",1),On([Dt],Nn.prototype,"setUserUniqueId",1),On([Dt],Nn.prototype,"doReportOnEnterBackground",1),On([Dt],Nn.prototype,"getTrackBaseInfo",1),On([Dt],Nn.prototype,"useAutoTrack",1),On([Dt],Nn.prototype,"initDirectGameConfig",1),On([Dt],Nn.prototype,"addDirectGameStatusListener",1),window.WX_AD_SDK=Nn,module.exports={SDK:Nn};
functiont(t,e,n){return(e=v(e))int?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}functione(t){returnfunction(t){if(Array.isArray(t))returnr(t)}(t)||function(t){if("undefined"!=typeofSymbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])returnArray.from(t)}(t)||n(t)||function(){thrownewTypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable,non-array objects must have a[Symbol.iterator]()method.")}()}functionn(t,e){if(t){if("string"==typeoft)returnr(t,e);varn=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void0}}functionr(t,e){(null==e||e>t.length)&&(e=t.length);for(varn=0,r=newArray(e);n<e;n++)r[n]=t[n];returnr}functioni(t,e){if("function"!=typeofe&&null!==e)thrownewTypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}functiono(t,e){returno=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){returnt.__proto__=e,t},o(t,e)}functiona(t){vare=function(){if("undefined"==typeofReflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeofProxy)return!0;try{returnBoolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();returnfunction(){varn,r=s(t);if(e){vari=s(this).constructor;n=Reflect.construct(r,arguments,i)}elsen=r.apply(this,arguments);returnu(this,n)}}functionu(t,e){if(e&&("object"===l(e)||"function"==typeofe))returne;if(void0!==e)thrownewTypeError("Derived constructors may only return object or undefined");returnc(t)}functionc(t){if(void0===t)thrownewReferenceError("this hasn't been initialised-super()hasn't been called");returnt}functions(t){returns=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){returnt.__proto__||Object.getPrototypeOf(t)},s(t)}functionl(t){returnl="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(t){returntypeoft}:function(t){returnt&&"function"==typeofSymbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeoft},l(t)}functionf(t,e){if(!(tinstanceofe))thrownewTypeError("Cannot call a class as a function")}functiond(t,e){for(varn=0;n<e.length;n++){varr=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(t,v(r.key),r)}}functionp(t,e,n){returne&&d(t.prototype,e),n&&d(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}functionv(t){vare=function(t){if("object"!==l(t)||null===t)returnt;vare=t[Symbol.toPrimitive];if(void0!==e){varn=e.call(t,"string");if("object"!==l(n))returnn;thrownewTypeError("@@toPrimitive must return a primitive value.")}returnString(t)}(t);return"symbol"===l(e)?e:String(e)}varh,_,g="LOCAL_ID",y="QUEUE_ACTIONS",m="CLICK_ID",A="QUEUE_LOST_MAP",R="REMOTE_CONFIG",k="REMOTE_COMMON_CONFIG",S="OPENID",T={init:"init",reporting:"reporting",fail:"fail"},E={maxSdkInstance:4,maxQueueLength:500,actionParamMaxLength:1e4,autoTrack:!0,reportThreshold:5,reportDelay:1,inspectDelay:30,cgiBatchSize:50,requestConcurrency:4,requestTimeout:1e4,signVersion:"1.0",realTimeActionList:["START_APP","REGISTER","PURCHASE"]},b={JS_RUN_ERROR:"JS_RUN_ERROR",REQUEST_ERROR:"REQUEST_ERROR",REQUEST_CONFIG_ERROR:"REQUEST_CONFIG_ERROR",JS_QUEUE_LOG:"JS_QUEUE_LOG",PROXY_ERROR:"PROXY_ERROR",PROXY_POLYFILL:"PROXY_POLYFILL",QUEUE_LOST_NUM:"QUEUE_LOST_NUM",REQ_TOTAL:"REQ_TOTAL",SIGN_ERROR:"SIGN_ERROR"},O="ANDROID",I="IOS",w="WINDOWS",C="OSX",x="UNKNOWN",N=1e3,L=100,D=10,M="START_APP",P="ENTER_FOREGROUND",U="ENTER_BACKGROUND",q="ADD_TO_WISHLIST",F="PURCHASE",j="APP_QUIT",G="REGISTER",B="CREATE_ROLE",V="TUTORIAL_FINISH",K="TRUE",Q="FALSE",Y="TENCENT",W="BYTEDANCE",J="KUAISHOU",H="ALIBABA",z="BAIDU",$="OTHERS",X="UNKNOWN",Z="TICKET_INTERVAL_CHANGE",tt=(_=function(t){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(t)},{getSync:function(t){vare;try{e=wx.getStorageSync(_(t))}catch(t){returnconsole.error("storage get error",t),e}returne},setSync:function(t,e){try{wx.setStorageSync(_(t),e)}catch(t){returnconsole.error("storage set error",t),!1}return!0}}),et=function(){if(h)returnh;try{returnh=wx.getSystemInfoSync()}catch(t){return{}}},nt=function(){vart;returnfunction(){if(!t){vare=et(),n=e.system,r=void0===n?"":n,i=(null==r?void0:r.split(" "))||[],o=function(t){if(!t)returnx;vare=(null==t?void0:t.toUpperCase())||"";returne.indexOf("ANDROID")>-1?O:e.indexOf("IOS")>-1?I:e.indexOf("MAC")>-1?C:e.indexOf("WINDOWS")>-1?w:x}(i[0]),a=function(t){return!t||t.length<=0?"":2===t.length?t[1]:3===t.length&&"Windows"===t[0]?"".concat(t[1]," ").concat(t[2]):t[t.length-1]}(i);t={benchmark_level:e.benchmarkLevel,device_brand:e.brand,screen_height:Math.floor(e.screenHeight),screen_width:Math.floor(e.screenWidth),wx_lib_version:e.SDKVersion,wx_version:e.version,wx_platform:e.platform,device_model:e.model,os:o,os_version:a}}returnt}}(),rt=function(){vart;returnfunction(){try{if(t)returnt;t||(t=tt.getSync(g)||""),t||(t=mt(),tt.setSync(g,t))}catch(t){}returnt}}(),it=function(){vart="unknown",e=!1;returnfunction(){if(!e)try{wx.getNetworkType({success:function(e){t=e.networkType},fail:function(){t="unknown"}}),wx.onNetworkStatusChange(function(e){t=e.networkType}),e=!0}catch(t){}returnt}}();it();varot=function(){vart="";returnfunction(){returnt||(t=tt.getSync(S)||""),t}}(),at=function(){vart;returnfunction(){if(t)returnt;try{vare=wx.getAccountInfoSync();returnht(e.miniProgram)?t=e.miniProgram:{}}catch(e){return{}}}}();functionut(t){vare=null==t?void0:t.query;if(!ht(e))return"";varn="";returne.gdt_vid||[1045,1046,1084].indexOf(null==t?void0:t.scene)>-1?n=Y:e.clue_token||e.clickid&&e.item_id?n=W:e.callback&&"kuaishou"===e.ksChannel?n=J:e.bd_vid||e.ai&&e.d&&e.q&&e.c?n=z:e.uctrackid?n=H:(e.trackid||e.imp||[1065,1069,1194].indexOf(null==t?void0:t.scene)>-1&&(e.callback||e.u))&&(n=$),n}functionct(t,e){try{varn=nt(),r=at(),i={sdk_version:"1.5.7",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void0:n.device_brand,device_model:null==n?void0:n.device_model,wx_version:null==n?void0:n.wx_version,wx_lib_version:null==n?void0:n.wx_lib_version,wx_platform:null==n?void0:n.wx_platform,os:null==n?void0:n.os,os_version:null==n?void0:n.os_version,local_id:rt(),env_version:null==r?void0:r.envVersion,appid:null==r?void0:r.appId},o=Object.assign(i,t);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:o,method:"POST",timeout:E.requestTimeout,success:function(t){"function"==typeofe&&200===(null==t?void0:t.statusCode)&&e()}})}catch(n){xt.error(n)}}varst=function(){functiont(){f(this,t)}returnp(t,null,[{key:"revise",value:function(t){t>0&&!this.isRevised&&(this.offsetTime=t-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){returnthis.isRevised?Date.now()+this.offsetTime:-1}}]),t}();functionlt(t){returnnewPromise(function(e,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:t,timeout:E.requestTimeout,success:function(t){ft(t,e,"config/get",n),pt(t)},fail:function(t){dt(t,"config/get",n)}})})}functionft(t,e,n,r){vari,o,a,u,c=null==t?void0:t.statusCode,s=null==(i=null==t?void0:t.data)?void0:i.code;if(200!==c||0!==s){varl=s;200!==c&&(l="number"==typeofc?-1*c:-888),ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName:".concat(n,",statusCode:").concat(c,",code:").concat(s,",traceid:").concat(null==(a=null==t?void0:t.data)?void0:a.trace_id),code:l}),null==r||r(null==(u=null==t?void0:t.data)?void0:u.data)}elsee(null==(o=t.data)?void0:o.data)}functiondt(t,e,n){ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName:".concat(e,",message:").concat(null==t?void0:t.errMsg," "),code:"number"==typeof(null==t?void0:t.errno)?-1*t.errno:-999}),null==n||n(t)}functionpt(t){vare,n=1*(null==(e=null==t?void0:t.header)?void0:e["Server-Time"]);n>17266752e5&&st.revise(n)}st.offsetTime=0,st.isRevised=!1;varvt=Object.prototype.toString,ht=function(t){return"[object Object]"===vt.call(t)},_t=function(t){return"[object Array]"===vt.call(t)},gt=function(t){return"[object Function]"===vt.call(t)},yt=(newDate).getTime();functionmt(){vart=(newDate).getTime(),e=Math.abs(1e3*(t-yt));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(n){varr=16*Math.random();returnt>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")})}varAt=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Rt=function(t){if("string"!=typeoft)thrownewTypeError("Invalid argument expected string");if(!At.test(t))thrownewError("Invalid argument not valid semver('".concat(t,"' received)"))},kt=function(t){returnisNaN(Number(t))?t:Number(t)},St=function(t){vare=t.replace(/^v/,"").replace(/\+.*$/,""),n=function(t){return-1===t.indexOf("-")?t.length:t.indexOf("-")}(e),r=e.substring(0,n).split(".");returnr.push(e.substring(n+1)),r},Tt=function(t,e){[t,e].forEach(Rt);for(varn=St(t),r=St(e),i=0;i<Math.max(n.length-1,r.length-1);i++){varo=parseInt(n[i]||"0",10),a=parseInt(r[i]||"0",10);if(o>a)return1;if(a>o)return-1}varu=n[n.length-1],c=r[r.length-1];if(u&&c)for(vars=u.split(".").map(kt),l=c.split(".").map(kt),f=0;f<Math.max(s.length,l.length);f++){if(void0===s[f]||"string"==typeofl[f]&&"number"==typeofs[f])return-1;if(void0===l[f]||"string"==typeofs[f]&&"number"==typeofl[f]||s[f]>l[f])return1;if(l[f]>s[f])return-1}elseif(u||c)returnu?-1:1;return0},Et=function(t){returnht(t)?(function(t){vare=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(varnint)e.includes(n)||xt.warn("Invalid property '".concat(n,"' found in config"))}(t),"number"!=typeoft.user_action_set_id?"user_action_set_id 参数需为 number 类型":t.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeoft.secret_key?"secret_key 参数需为 string 类型":""===t.secret_key.trim()?"缺少 secret_key 参数":32!==t.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeoft.appid?"appid 参数需为 string 类型":""!==t.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"};functionbt(t){returnOt()[t]}functionOt(){returnE}functionIt(t,e){returnObject.prototype.hasOwnProperty.call(t,e)}varwt=function(t){try{returnt&&"string"==typeoft?-1===(t=t.replace(/\s/g,"")).indexOf(".")?t:t.split(".").slice(0,2).join("."):""}catch(e){returnt}},Ct=function(){functiont(){f(this,t)}returnp(t,null,[{key:"error",value:function(t){for(vare,n=arguments.length,r=newArray(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];(e=console).error.apply(e,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(t)].concat(r))}},{key:"info",value:function(e){for(varn,r=arguments.length,i=newArray(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(e)].concat(i))}},{key:"log",value:function(e){for(varn,r=arguments.length,i=newArray(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(e)].concat(i))}},{key:"warn",value:function(t){for(vare,n=arguments.length,r=newArray(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];(e=console).warn.apply(e,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(t)].concat(r))}},{key:"devLog",value:function(e){for(varn,r=arguments.length,i=newArray(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.7]",":").concat(e)].concat(i))}}]),t}(),xt=Ct;xt.debug=!1,xt.isDev=!1;varNt=p(functiont(){f(this,t)});Nt.hasDirectGameMask=!1,Nt.activeDuration=0;varLt=function(){vart;returnfunction(){if(!t)try{vare=wx.getLaunchOptionsSync(),n=e.query.gdt_vid||"";n?Nt.hasDirectGameMask||tt.setSync(m,n):n=tt.getSync(m)||"";varr=JSON.stringify(e);r.length>1e4&&(r=JSON.stringify({cut:1,scene:e.scene})),t={source_scene:e.scene,pkg_channel_id:e.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ut(e)}}catch(e){t={},xt.log("获取场景值和渠道号失败",e)}returnt}}();functionDt(t,e,n){varr=n.value;returnn.value=function(){for(varn=arguments.length,i=newArray(n),o=0;o<n;o++)i[o]=arguments[o];try{returnr.apply(this,i)}catch(n){try{xt.error.apply(xt,["calling ".concat(t.constructor.name,".").concat(e," error with arguments")].concat(i)),xt.error(n);vara={log_type:b.JS_RUN_ERROR,message:"[safeExcutable]".concat(t.constructor.name,".").concat(e,":").concat(null==n?void0:n.message),err_stack:null==n?void0:n.stack};gt(this.reportLog)?this.reportLog(a):ct(a)}catch(a){}}},n}varMt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ut=function(t,e,n,r){for(vari,o=r>1?void0:r?Pt(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&Mt(e,n,o),o},qt=function(){functiont(e){varn=e.userActionSetId,r=e.maxLength,i=void0===r?500:r;f(this,t),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat(y,"_").concat(null==n?void0:n.toString()),this.maxLength=i,this.userActionSetId=n,this.setTimeStamp(),this.init()}returnp(t,[{key:"getItems",value:function(){returnthis.stack}},{key:"getStorage",value:function(){vart,e=(null==(t=tt)?void0:t.getSync(this.localStorageKey))||"[]";returnJSON.parse(e)}},{key:"reportLostNum",value:function(){vart=this,e=Object.assign({},this.lostActionMaps),n=[];for(varrine){vari=null==r?void0:r.split("_");n.push({queue_lost_session_id:i[0],queue_lost_timestamp:i[1],queue_lost_num:e[r]})}n.length&&(this.setTimeStamp(),n.forEach(function(e){varn=Object.assign({},{user_action_set_id:t.userActionSetId,log_type:b.QUEUE_LOST_NUM},e),r=null==e?void0:e.queue_lost_session_id,i=null==e?void0:e.queue_lost_timestamp,o="".concat(r,"_").concat(i);ct(n,function(){It(t.lostActionMaps,o)&&(deletet.lostActionMaps[o],tt.setSync(A,JSON.stringify(t.lostActionMaps)))})}))}},{key:"getLostMaps",value:function(){returnthis.lostActionMaps}},{key:"init",value:function(){vart=this,e=this.getStorage(),n=null==e?void0:e.map(function(t){vare,n;returnt.inner_status===(null==(e=T)?void0:e.reporting)?Object.assign({},t,{inner_status:null==(n=T)?void0:n.fail,is_retry:!0,retry_count:t.retry_count+1}):t});this.stack=n,this.lostActionMaps=JSON.parse(tt.getSync(A)||"{}"),setTimeout(function(){t.reportLostNum()},1e3)}},{key:"addItem",value:function(t){vare;null==(e=null==this?void0:this.stack)||e.push(t)}},{key:"removeItems",value:function(t){vare,n=null==(e=null==this?void0:this.stack)?void0:e.filter(function(e){return!(null!=t&&t.includes(null==e?void0:e.action_id))});this.stack=n}},{key:"updateForReportFail",value:function(t){vare;this.stack=null==(e=this.stack)?void0:e.map(function(e){varn;returnnull!=t&&t.includes(null==e?void0:e.action_id)?Object.assign({},e,{inner_status:null==(n=T)?void0:n.fail,retry_count:e.retry_count+1,is_retry:!0}):e})}},{key:"updateForReporting",value:function(t){vare;this.stack=null==(e=this.stack)?void0:e.map(function(e){varn;returnnull!=t&&t.includes(null==e?void0:e.action_id)?Object.assign({},e,{inner_status:null==(n=T)?void0:n.reporting}):e})}},{key:"updateAllStack",value:function(t){this.stack=t}},{key:"updateToStorage",value:function(){tt.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(t){if(t){vare="".concat(t,"_").concat(this.timeStamp),n=this.lostActionMaps[e]||0;this.lostActionMaps[e]=n+1,tt.setSync(A,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),t}();Ut([Dt],qt.prototype,"getItems",1),Ut([Dt],qt.prototype,"getStorage",1),Ut([Dt],qt.prototype,"reportLostNum",1),Ut([Dt],qt.prototype,"getLostMaps",1),Ut([Dt],qt.prototype,"init",1),Ut([Dt],qt.prototype,"addItem",1),Ut([Dt],qt.prototype,"removeItems",1),Ut([Dt],qt.prototype,"updateForReportFail",1),Ut([Dt],qt.prototype,"updateForReporting",1),Ut([Dt],qt.prototype,"updateAllStack",1),Ut([Dt],qt.prototype,"updateToStorage",1),Ut([Dt],qt.prototype,"updateLostAction",1);varFt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Gt=function(t,e,n,r){for(vari,o=r>1?void0:r?jt(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&Ft(e,n,o),o},Bt=function(){i(e,qt);vart=a(e);functione(n){varr,i=n.userActionSetId,o=n.maxLength,a=void0===o?500:o,u=n.ogEvents,c=void0===u?[]:u;returnf(this,e),(r=t.call(this,{userActionSetId:i,maxLength:a})).ogEvents=c,r}returnp(e,[{key:"getReportableActions",value:function(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:100,e=this.getItems(),n=[];returnnull==e||e.forEach(function(e){varr;(null==n?void0:n.length)<t&&(null==e?void0:e.inner_status)!==(null==(r=T)?void0:r.reporting)&&(null==n||n.push(e))}),n}},{key:"addAction",value:function(t){vare={code:0,message:"成功",actionId:t.action_id},n=this.getItems();if((null==n?void0:n.length)>=this.maxLength){varr="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");xt.warn(r),ct({user_action_set_id:this.userActionSetId,log_type:b.JS_QUEUE_LOG,message:"队列长度超过限制"});vari=this.sortQueue(t,n);xt.debug&&xt.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),i.concat([]));varo=i.pop();this.updateAllStack(i),this.updateLostAction((null==o?void0:o.session_id)||""),(null==o?void0:o.action_id)===t.action_id&&(e={code:103,message:"缓存队列已满,主动丢弃行为"})}elsethis.addItem(t);returnNt.hasDirectGameMask||this.updateToStorage(),e}},{key:"removeActions",value:function(t){this.removeItems(t),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(t){this.updateForReportFail(t),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(t){this.updateForReporting(t),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){vart=this.getItems().filter(function(t){vare;return(null==t?void0:t.inner_status)!==(null==(e=T)?void0:e.reporting)});returnnull==t?void0:t.length}},{key:"sortQueue",value:function(t,e){varn=this,r={},i=null==t?void0:t.action_time,o=e.concat([t]),a=function(t){returnr[t.action_id]||(r[t.action_id]=n.caculateWeight(i,t)),r[t.action_id]};returno.sort(function(t,e){returna(e)-a(t)})}},{key:"caculateWeight",value:function(t,e){varn,r=0,i=this.formatWeight(t,null==e?void0:e.action_time),o=i.ogWeight,a=i.sdkWeight,u=i.userWeight;null!=(n=this.ogEvents)&&n.includes(null==e?void0:e.action_type)&&(r+=o),null!=e&&e.is_sdk_auto_track?r+=a:r+=u;varc=t-(null==e?void0:e.action_time)+1;returnc>0?r+1/c:r}},{key:"formatWeight",value:function(t,e){varn=N,r=D,i=L;returnt-e>2592e6&&(n/=100,r/=100,i/=100),{ogWeight:n,sdkWeight:r,userWeight:i}}}]),e}();Gt([Dt],Bt.prototype,"getReportableActions",1),Gt([Dt],Bt.prototype,"addAction",1),Gt([Dt],Bt.prototype,"removeActions",1),Gt([Dt],Bt.prototype,"updateActionsForReportFail",1),Gt([Dt],Bt.prototype,"updateActionsForReporting",1),Gt([Dt],Bt.prototype,"getReportableActionsLength",1),Gt([Dt],Bt.prototype,"sortQueue",1),Gt([Dt],Bt.prototype,"caculateWeight",1),Gt([Dt],Bt.prototype,"formatWeight",1);varVt=function(){functiont(){f(this,t),this.events={}}returnp(t,[{key:"subscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])?this.events[e].push(n):this.events[e]=[n]}},{key:"once",value:function(e,n){t.checkCallback(n),this.subscribe(this.onceEventName(e),n)}},{key:"unsubscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])&&(this.events[e]=this.events[e].filter(function(t){returnt!==n})),_t(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)]=this.events[this.onceEventName(e)].filter(function(t){returnt!==n}))}},{key:"publish",value:function(t){for(vare=arguments.length,n=newArray(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];vari=Date.now();_t(this.events[t])&&this.events[t].forEach(function(t){returnt.apply(void0,[i].concat(n))}),_t(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)].forEach(function(t){returnt.apply(void0,[i].concat(n))}),this.events[this.onceEventName(t)]=[])}},{key:"onceEventName",value:function(t){return"once_event_prefix_".concat(t)}}],[{key:"checkCallback",value:function(e){gt(e)||xt.error(t.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),t}(),Kt=Vt;Kt.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";varQt=newKt,Yt=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],Wt="START_APP",Jt="TICKET",Ht="ENTER_FOREGROUND",zt="ENTER_BACKGROUND",$t="LOGIN",Xt="SHARE",Zt="TAP_GAME_CLUB",te="CREATE_GAME_CLUB",ee="CREATE_GAME_ROOM",ne="JOIN_GAME_ROOM",re="FINISH_PAY",ie="START_PAY",oe="ADD_TO_WISHLIST",ae=["REGISTER","START_APP","RE_ACTIVE"],ue=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],ce=function(){functiont(){f(this,t),this.channelClaimActionList=ae,this.noClaimActionList=ue,this.realTimeActionList=E.realTimeActionList,this.ticketInterval=60,this.requestTimeout=E.requestTimeout,this.loadConfig()}returnp(t,[{key:"getChannelClaimActionList",value:function(){returnthis.channelClaimActionList}},{key:"getNoClaimActionList",value:function(){returnthis.noClaimActionList}},{key:"getRealTimeActionList",value:function(){returnthis.realTimeActionList}},{key:"getTicketInterval",value:function(){returnthis.ticketInterval}},{key:"getRequestTimeout",value:function(){returnthis.requestTimeout}},{key:"loadConfig",value:function(){vart=this;try{if("undefined"==typeofwx)return;vare=tt.getSync(k);e&&this.updateConfig(e),lt({conf_name:"mini_game_sdk_common",conf_key:"config"}).then(function(e){e&&ht(e)&&(t.updateConfig(e),tt.setSync(k,e))})}catch(e){console.error(e)}}},{key:"updateConfig",value:function(t){t.channelClaimActionList&&_t(t.channelClaimActionList)&&(this.channelClaimActionList=t.channelClaimActionList),t.noClaimActionList&&_t(t.noClaimActionList)&&(this.noClaimActionList=t.noClaimActionList),t.realTimeActionList&&_t(t.realTimeActionList)&&(this.realTimeActionList=t.realTimeActionList),t.ticketInterval&&"number"==typeoft.ticketInterval&&t.ticketInterval>1&&t.ticketInterval!==this.ticketInterval&&(this.ticketInterval=t.ticketInterval,Qt.publish(Z)),t.requestTimeout&&"number"==typeoft.requestTimeout&&t.requestTimeout>5e3&&(this.requestTimeout=t.requestTimeout)}}]),t}(),se=newce,le=Wt,fe=Jt,de=Ht,pe=zt,ve=function(){vart=!0,e=!0,n=!0,r=!0,i=!0,o=!1;returnfunction(){if(!o){o=!0;vara=tt.getSync(R);if((null==a?void0:a.bg)===K?t=!0:(null==a?void0:a.bg)===Q&&(t=!1),(null==a?void0:a.fg)===K?e=!0:(null==a?void0:a.fg)===Q&&(e=!1),(null==a?void0:a.st)===K?n=!0:(null==a?void0:a.st)===Q&&(n=!1),(null==a?void0:a.ti)===K?r=!0:(null==a?void0:a.ti)===Q&&(r=!1),xt.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",t,e,n,r),n&&Qt.publish(le),r){varu=function(){i&&Qt.publish(fe)},c=setInterval(u,1e3*se.getTicketInterval());Qt.subscribe(Z,function(){c&&clearInterval(c),c=setInterval(u,1e3*se.getTicketInterval())})}wx.onShow(function(t){if(i=!0,e){varn="";try{(n=JSON.stringify(t)).length>1e4&&(n=JSON.stringify({cut:1,scene:t.scene}))}catch(t){}Qt.publish(de,{enter_options:n})}}),wx.onHide(function(){if(i=!1,t){vare=0;0!==Nt.activeDuration&&(e=Date.now()-Nt.activeDuration,Nt.activeDuration=0),Qt.publish(pe,{duration:e>0?e:0})}})}}}(),he="undefined"!=typeofglobalThis?globalThis:"undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:{};wx.$adqSdkReport=Qt;function_e(t){returnt&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}varge,ye=_e(function(){vart,e=null;functionn(t){return!!t&&("object"==l(t)||"function"==typeoft)}functionr(t){if(null!==t&&!n(t))thrownewTypeError("Object prototype may only be an Object or null:"+t)}vari=Object,o=!(!i.create&&{__proto__:null}instanceofi),a=i.create||(o?function(t){returnr(t),{__proto__:t}}:function(t){if(r(t),null===t)thrownewSyntaxError("Native Object.create is required to create objects with null prototype");vare=function(){};returne.prototype=t,newe}),u=function(){returnnull},c=i.getPrototypeOf||([].__proto__===Array.prototype?function(t){vare=t.__proto__;returnn(e)?e:null}:u);returnt=function(s,l){if(void0===(this&&thisinstanceoft?this.constructor:void0))thrownewTypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))thrownewTypeError("Cannot create proxy with a non-object as target or handler");varf=function(){};e=function(){s=null,f=function(t){thrownewTypeError("Cannot perform '".concat(t,"' on a proxy that has been revoked"))}},setTimeout(function(){e=null},0);vard=l;for(varpinl={get:null,set:null,apply:null,construct:null},d){if(!(pinl))thrownewTypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=d[p]}"function"==typeofd&&(l.apply=d.apply.bind(d));varv,h=c(s),_=!1,g=!1;"function"==typeofs?(v=function(){vart=this&&this.constructor===v,e=Array.prototype.slice.call(arguments);returnf(t?"construct":"apply"),t&&l.construct?l.construct.call(this,s,e):!t&&l.apply?l.apply(s,this,e):t?(e.unshift(s),new(s.bind.apply(s,e))):s.apply(this,e)},_=!0):sinstanceofArray?(v=[],g=!0):v=o||null!==h?a(h):{};vary=l.get?function(t){returnf("get"),l.get(this,t,v)}:function(t){returnf("get"),this[t]},m=l.set?function(t,e){f("set"),l.set(this,t,e,v)}:function(t,e){f("set"),this[t]=e},A=i.getOwnPropertyNames(s),R={};A.forEach(function(t){if(!_&&!g||!(tinv)){vare={enumerable:!!i.getOwnPropertyDescriptor(s,t).enumerable,get:y.bind(s,t),set:m.bind(s,t)};i.defineProperty(v,t,e),R[t]=!0}});vark=!0;if(_||g){varS=i.setPrototypeOf||([].__proto__===Array.prototype?function(t,e){returnr(e),t.__proto__=e,t}:u);h&&S(v,h)||(k=!1)}if(l.get||!k)for(varTins)R[T]||i.defineProperty(v,T,{get:y.bind(s,T)});returni.seal(s),i.seal(v),v},t.revocable=function(n,r){return{proxy:newt(n,r),revoke:e}},t}),me={};try{ge||(ge=ye())}catch(h){Te(h)}functionAe(t,n,r,i){try{if(!ge||null==t||!t[n])return;t[n]=newge(t[n],{apply:function(t,n,o){vara,u;i&&Se(function(){returni.apply(void0,e(o))});varc=!!(null!=(a=o[0])&&a.success||null!=(u=o[0])&&u.fail);c&&["success","fail"].forEach(function(t){if(o[0][t])try{o[0][t]=newge(o[0][t],{apply:function(n,i,a){returnSe(function(){returnr.apply(void0,[t,o[0]].concat(e(a)))}),n.apply(i,a)}})}catch(t){Te(t)}});vars=t.apply(n,o);return!c&&s&&"[object Promise]"===Object.prototype.toString.call(s)?s.then(function(t){returnSe(function(){returnr("success",o[0],t)}),t}).catch(function(t){throwSe(function(){returnr("fail",o[0],t)}),t}):s}})}catch(t){Te(t)}}functionRe(t,n,r){try{if(!ge||null==t||!t[n])return;t[n]=newge(t[n],{apply:function(t,n,i){varo="function"==typeofi[0];if(o)try{i[0]=newge(i[0],{apply:function(t,n,i){varo=t.call.apply(t,[n].concat(e(i)));returnSe(function(){returnr(o)}),o}})}catch(t){Te(t)}vara=t.call.apply(t,[n].concat(e(i)));returno||Se(function(){returnr(a)}),a}})}catch(t){Te(t)}}functionke(t){varn=arguments.length>1&&void0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void0,i=arguments.length>3&&void0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void0;try{if(!ge||null==t||!t[n])return;t[n]=newge(t[n],{apply:function(t,a,u){varc=t.call.apply(t,[a].concat(e(u)));return(!r||!me[n])&&(Se(function(){returnnull==o?void0:o(c)}),i.forEach(function(t){vare=t.eventName,n=t.isAsync,r=t.proxyEvent;n?Ae(c,e,r):Re(c,e,r)})),r&&(me[n]=!0),c}})}catch(t){Te(t)}}functionSe(t){try{t()}catch(t){Te(t)}}functionTe(t){ct({log_type:b.PROXY_ERROR,message:null==t?void0:t.message,err_stack:null==t?void0:t.stack})}varEe=$t,be=oe,Oe=Xt,Ie=Zt,we=te,Ce=ne,xe=ie,Ne=re,Le=function(){vart=!1;returnfunction(){t||(t=!0,Ae(wx,"login",function(t){"success"===t&&Qt.publish(Ee)}),Re(wx,"onAddToFavorites",function(){Qt.publish(be)}),Re(wx,"onShareTimeline",function(){Qt.publish(Oe,{target:"TIME_LINE",trigger:"MENU"})}),Re(wx,"onShareAppMessage",function(){Qt.publish(Oe,{target:"APP_MESSAGE",trigger:"MENU"})}),Re(wx,"shareAppMessage",function(){Qt.publish(Oe,{target:"APP_MESSAGE",trigger:"BUTTON"})}),ke(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Qt.publish(Ie)}}],function(){Qt.publish(we)}),ke(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(t){"success"===t&&Qt.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(t){"success"===t&&Qt.publish(Ce)}}]))}}(),De=function(){functiont(){f(this,t)}returnp(t,null,[{key:"isEmpty",value:function(t){returnnull==t||"string"==typeoft&&""===t.trim()}},{key:"format",value:function(t){for(vare=arguments.length,n=newArray(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];returnt.replace(/\${(\d+)}/g,function(t,e){returnn[e]})}},{key:"customStringify",value:function(t){vare=[];try{returnJSON.stringify(t,function(t,n){if(void0===n)return"undefined";if("object"==l(n)&&null!==n){if(-1!==e.indexOf(n))return"[Circular]";e.push(n)}return"bigint"==typeofn?n.toString():n})}catch(t){return"[Param Error]"}}}]),t}(),Me=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,Pe=/^ams_reserved_(.*)/i,Ue=function(){functiont(){f(this,t)}returnp(t,null,[{key:"validateActionType",value:function(e){returnDe.isEmpty(e)?(xt.error(t.ERROR_ACTION_TYPE_NULL),!1):!!Me.test(e)||(xt.error(t.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(e){if(!e)return!0;if(!ht(e))returnxt.error(t.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(varnine){if(De.isEmpty(n))returnxt.error(t.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!Me.test(n))returnxt.error(t.ERROR_ACTION_PARAM_KEY_INVALID),!1;Pe.test(n)&&xt.warn(t.WARN_ACTION_PARAM_KEY_RESERVED);varr=e[n];if(!t.isValidValue(r))returnxt.error(De.format(t.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(_t(r)){if(!t.isValidArrayValue(r)){for(vari=0;i<r.length;i++)xt.error(De.format(t.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,De.customStringify(r),i,r[i]));return!1}if(!t.checkArrayElementTypes(r))returnxt.error(t.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(t){returnnull==t||"string"==typeoft||"number"==typeoft||"boolean"==typeoft||_t(t)}},{key:"isValidArrayValue",value:function(t){for(vare=0;e<t.length;e++){varn=t[e];if("string"!=typeofn&&"number"!=typeofn&&"boolean"!=typeofn)return!1}return!0}},{key:"checkArrayElementTypes",value:function(t){if(!t||t.length<=1)return!0;for(vare=l(t[0]),n=1;n<t.length;n++)if(l(t[n])!==e)return!1;return!0}}]),t}(),qe=Ue;qe.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",qe.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",qe.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",qe.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",qe.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",qe.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0},value=${1}]",qe.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0},value=${1},数组的第${2}个元素为${3}]",qe.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",qe.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";varFe={exports:{}};!function(t){!function(e){functionn(t,e){varn=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}functionr(t,e,r,i,o,a){returnn(function(t,e){returnt<<e|t>>>32-e}(n(n(e,t),n(i,a)),o),r)}functioni(t,e,n,i,o,a,u){returnr(e&n|~e&i,t,e,o,a,u)}functiono(t,e,n,i,o,a,u){returnr(e&i|n&~i,t,e,o,a,u)}functiona(t,e,n,i,o,a,u){returnr(e^n^i,t,e,o,a,u)}functionu(t,e,n,i,o,a,u){returnr(n^(e|~i),t,e,o,a,u)}functionc(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;varr,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r<t.length;r+=16)c=d,s=p,l=v,f=h,d=i(d,p,v,h,t[r],7,-680876936),h=i(h,d,p,v,t[r+1],12,-389564586),v=i(v,h,d,p,t[r+2],17,606105819),p=i(p,v,h,d,t[r+3],22,-1044525330),d=i(d,p,v,h,t[r+4],7,-176418897),h=i(h,d,p,v,t[r+5],12,1200080426),v=i(v,h,d,p,t[r+6],17,-1473231341),p=i(p,v,h,d,t[r+7],22,-45705983),d=i(d,p,v,h,t[r+8],7,1770035416),h=i(h,d,p,v,t[r+9],12,-1958414417),v=i(v,h,d,p,t[r+10],17,-42063),p=i(p,v,h,d,t[r+11],22,-1990404162),d=i(d,p,v,h,t[r+12],7,1804603682),h=i(h,d,p,v,t[r+13],12,-40341101),v=i(v,h,d,p,t[r+14],17,-1502002290),d=o(d,p=i(p,v,h,d,t[r+15],22,1236535329),v,h,t[r+1],5,-165796510),h=o(h,d,p,v,t[r+6],9,-1069501632),v=o(v,h,d,p,t[r+11],14,643717713),p=o(p,v,h,d,t[r],20,-373897302),d=o(d,p,v,h,t[r+5],5,-701558691),h=o(h,d,p,v,t[r+10],9,38016083),v=o(v,h,d,p,t[r+15],14,-660478335),p=o(p,v,h,d,t[r+4],20,-405537848),d=o(d,p,v,h,t[r+9],5,568446438),h=o(h,d,p,v,t[r+14],9,-1019803690),v=o(v,h,d,p,t[r+3],14,-187363961),p=o(p,v,h,d,t[r+8],20,1163531501),d=o(d,p,v,h,t[r+13],5,-1444681467),h=o(h,d,p,v,t[r+2],9,-51403784),v=o(v,h,d,p,t[r+7],14,1735328473),d=a(d,p=o(p,v,h,d,t[r+12],20,-1926607734),v,h,t[r+5],4,-378558),h=a(h,d,p,v,t[r+8],11,-2022574463),v=a(v,h,d,p,t[r+11],16,1839030562),p=a(p,v,h,d,t[r+14],23,-35309556),d=a(d,p,v,h,t[r+1],4,-1530992060),h=a(h,d,p,v,t[r+4],11,1272893353),v=a(v,h,d,p,t[r+7],16,-155497632),p=a(p,v,h,d,t[r+10],23,-1094730640),d=a(d,p,v,h,t[r+13],4,681279174),h=a(h,d,p,v,t[r],11,-358537222),v=a(v,h,d,p,t[r+3],16,-722521979),p=a(p,v,h,d,t[r+6],23,76029189),d=a(d,p,v,h,t[r+9],4,-640364487),h=a(h,d,p,v,t[r+12],11,-421815835),v=a(v,h,d,p,t[r+15],16,530742520),d=u(d,p=a(p,v,h,d,t[r+2],23,-995338651),v,h,t[r],6,-198630844),h=u(h,d,p,v,t[r+7],10,1126891415),v=u(v,h,d,p,t[r+14],15,-1416354905),p=u(p,v,h,d,t[r+5],21,-57434055),d=u(d,p,v,h,t[r+12],6,1700485571),h=u(h,d,p,v,t[r+3],10,-1894986606),v=u(v,h,d,p,t[r+10],15,-1051523),p=u(p,v,h,d,t[r+1],21,-2054922799),d=u(d,p,v,h,t[r+8],6,1873313359),h=u(h,d,p,v,t[r+15],10,-30611744),v=u(v,h,d,p,t[r+6],15,-1560198380),p=u(p,v,h,d,t[r+13],21,1309151649),d=u(d,p,v,h,t[r+4],6,-145523070),h=u(h,d,p,v,t[r+11],10,-1120210379),v=u(v,h,d,p,t[r+2],15,718787259),p=u(p,v,h,d,t[r+9],21,-343485551),d=n(d,c),p=n(p,s),v=n(v,l),h=n(h,f);return[d,p,v,h]}functions(t){vare,n="",r=32*t.length;for(e=0;e<r;e+=8)n+=String.fromCharCode(t[e>>5]>>>e%32&255);returnn}functionl(t){vare,n=[];for(n[(t.length>>2)-1]=void0,e=0;e<n.length;e+=1)n[e]=0;varr=8*t.length;for(e=0;e<r;e+=8)n[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;returnn}functionf(t){vare,n,r="0123456789abcdef",i="";for(n=0;n<t.length;n+=1)e=t.charCodeAt(n),i+=r.charAt(e>>>4&15)+r.charAt(15&e);returni}functiond(t){returnunescape(encodeURIComponent(t))}functionp(t){returnfunction(t){returns(c(l(t),8*t.length))}(d(t))}functionv(t,e){returnfunction(t,e){varn,r,i=l(t),o=[],a=[];for(o[15]=a[15]=void0,i.length>16&&(i=c(i,8*t.length)),n=0;n<16;n+=1)o[n]=909522486^i[n],a[n]=1549556828^i[n];returnr=c(o.concat(l(e)),512+8*e.length),s(c(a.concat(r),640))}(d(t),d(e))}functionh(t,e,n){returne?n?v(e,t):function(t,e){returnf(v(t,e))}(e,t):n?p(t):function(t){returnf(p(t))}(t)}t.exports?t.exports=h:e.md5=h}(he)}(Fe);varje=_e(Fe.exports),Ge="function"==typeofbtoa,Be="function"==typeofBuffer;"function"==typeofTextDecoder&&newTextDecoder;varVe,Ke="function"==typeofTextEncoder?newTextEncoder:void0,Qe=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Ve={},Qe.forEach(function(t,e){returnVe[t]=e});varYe=String.fromCharCode.bind(String);"function"==typeofUint8Array.from&&Uint8Array.from.bind(Uint8Array);varWe=Ge?function(t){returnbtoa(t)}:Be?function(t){returnBuffer.from(t,"binary").toString("base64")}:function(t){for(vare,n,r,i,o="",a=t.length%3,u=0;u<t.length;){if((n=t.charCodeAt(u++))>255||(r=t.charCodeAt(u++))>255||(i=t.charCodeAt(u++))>255)thrownewTypeError("invalid character found");o+=Qe[(e=n<<16|r<<8|i)>>18&63]+Qe[e>>12&63]+Qe[e>>6&63]+Qe[63&e]}returna?o.slice(0,a-3)+"===".substring(a):o},Je=Be?function(t){returnBuffer.from(t).toString("base64")}:function(t){for(vare=[],n=0,r=t.length;n<r;n+=4096)e.push(Ye.apply(null,t.subarray(n,n+4096)));returnWe(e.join(""))},He=function(t){if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?Ye(192|e>>>6)+Ye(128|63&e):Ye(224|e>>>12&15)+Ye(128|e>>>6&63)+Ye(128|63&e);vare=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);returnYe(240|e>>>18&7)+Ye(128|e>>>12&63)+Ye(128|e>>>6&63)+Ye(128|63&e)},ze=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,$e=Be?function(t){returnBuffer.from(t,"utf8").toString("base64")}:Ke?function(t){returnJe(Ke.encode(t))}:function(t){returnWe(function(t){returnt.replace(ze,He)}(t))},Xe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,tn=function(t,e,n,r){for(vari,o=r>1?void0:r?Ze(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&Xe(e,n,o),o},en=function(){functiont(e){varn=this;f(this,t),this.cgiBatchSize=E.cgiBatchSize,this.reportThreshold=E.reportThreshold,this.reportDelay=E.reportDelay,this.triggerExecuteSend=function(t){vare,n=arguments.length>1&&void0!==arguments[1]?arguments[1]:0,r=[];returnfunction(){for(vari=arguments.length,o=newArray(i),a=0;a<i;a++)o[a]=arguments[a];returnclearTimeout(e),e=setTimeout(function(){vare=t.apply(void0,o);r.forEach(function(t){returnt(e)}),r=[]},n),newPromise(function(t){returnr.push(t)})}}(function(){n.executeSend()},1e3*this.reportDelay),this.inspectDelay=E.inspectDelay,this.inspectTimer=void0,this.isNeedContinueSend=!1,this.getBaseInfo=e.getBaseInfo,this.reportLog=e.reportLog,this.queueManager=e.queueManager,this.configManager=e.configManager,this.onReportComplete=e.onReportComplete,this.onReportFail=e.onReportFail,this.flushSend(),this.startInspectTimer()}returnp(t,[{key:"batchSend",value:function(){vart,e=this.queueManager.getReportableActions(this.reportThreshold);if(e.length>=this.reportThreshold)this.executeSend();else{varn=(null==(t=this.configManager)?void0:t.getRealTimeActionList())||E.realTimeActionList;e.some(function(t){returnn.indexOf(t.action_type)>-1&&!t.is_retry})?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){vare=this;if(!Nt.hasDirectGameMask)if(t.currentRequestCount>=t.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;varn=(t.requestConcurrency-t.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),i=this.getBaseInfo();if(!i.openid&&!i.unionid&&(xt.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter(function(t){returnnull==t?void0:t.ad_trace_id})),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),t.currentRequestCount+=Math.ceil(r.length/this.cgiBatchSize);for(varo=[],a=0;a<r.length;a+=this.cgiBatchSize){varu=this.generateActionReportParams(r.slice(a,a+this.cgiBatchSize));o.push(this.report(u))}Promise.all(o).then(function(t){varn=t.some(function(t){returnt>=0});e.isNeedContinueSend&&n&&e.executeSend()}).catch(function(t){xt.error(t),e.reportLog({message:"executeSend catch:".concat(t.message),log_type:b.JS_RUN_ERROR,err_stack:t.stack})})}}}},{key:"generateActionReportParams",value:function(t){vare=[],n=[],r=this.getBaseInfo();returnt.forEach(function(t){n.push(t.action_id);varr=Object.assign({},t);deleter.inner_status,e.push(r)}),{data:{info:r,actions:e},actionIdList:n}}},{key:"dealSuccessData",value:function(t,e,n){[51001,51003].indexOf(null==t?void0:t.code)>-1?this.queueManager.updateActionsForReportFail(e):this.queueManager.removeActions(e),0!==(null==t?void0:t.code)&&(this.reportLog({log_type:b.REQUEST_ERROR,code:null==t?void0:t.code,message:"trace_id:".concat(null==t?void0:t.trace_id,",msg:").concat(null==t?void0:t.message)}),xt.error("上报失败:",t)),this.doTrackCallbackFn(this.onReportComplete,t,n),-1===[0,51001,51003].indexOf(null==t?void0:t.code)&&this.doTrackCallbackFn(this.onReportFail,t,n)}},{key:"dealFailData",value:function(t,e,n){this.queueManager.updateActionsForReportFail(e),this.reportLog({log_type:b.REQUEST_ERROR,code:t.code,message:t.message}),xt.error("上报失败:",t),this.doTrackCallbackFn(this.onReportComplete,t,n)}},{key:"report",value:function(e){varn=this,r=e.data,i=e.actionIdList;returnthis.queueManager.updateActionsForReporting(i),xt.debug&&(xt.info("上报行为类型:","【".concat(r.actions.map(function(t){returnt.action_type}).join("、"),"】")),xt.info("上报请求参数:",r)),newPromise(function(e){varo,a,u,c,s,f,d,p,v=Date.now();try{varh=function(t){vare="",n=null==t?void0:t.appid,r=null==t?void0:t.secret_key,i=null==t?void0:t.sdk_version,o=null==t?void0:t.timestamp;if(!(n&&r&&i&&o&&32===r.length))returne;for(vara=je(i+n+o),u=0;u<32;u++)e+=u%2==0?r[u]:a[u];returne}({appid:null==(o=null==r?void0:r.info)?void0:o.appid,secret_key:null==(a=null==r?void0:r.info)?void0:a.secret_key,sdk_version:null==(u=null==r?void0:r.info)?void0:u.sdk_version,timestamp:v}),_=function(t){returnarguments.length>1&&void0!==arguments[1]&&arguments[1]?function(t){returnt.replace(/=/g,"").replace(/[+\/]/g,function(t){return"+"==t?"-":"_"})}($e(t)):$e(t)}(JSON.stringify(r));d={"Client-Time":v,"Sign-Value":je(_+(null==(c=null==r?void0:r.info)?void0:c.user_action_set_id)+(null==(s=null==r?void0:r.info)?void0:s.secret_key)+h),"Sign-Version":E.signVersion,"content-type":"text/plain;charset=UTF-8"},p=_}catch(h){d={"Client-Time":v},p=r,n.reportLog({log_type:b.SIGN_ERROR,message:"sign error msg:".concat(null==h?void0:h.message),err_stack:null==h?void0:h.stack}),xt.error(h)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(f=n.configManager)?void0:f.getRequestTimeout())||E.requestTimeout,header:d,data:p,success:function(o){vara,u;xt.devLog("上报接口返回码:",null==(a=null==o?void0:o.data)?void0:a.code);varc=(null==(u=null==o?void0:o.header)?void0:u["Server-Time"])||-1;if(st.revise(c),t.currentRequestCount-=1,200===(null==o?void0:o.statusCode))returnn.dealSuccessData(null==o?void0:o.data,i,r),voide((null==o?void0:o.data).code);vars="";try{s="object"==l(null==o?void0:o.data)?JSON.stringify(null==o?void0:o.data):null==o?void0:o.data}catch(t){xt.error(t)}varf={code:"number"==typeof(null==o?void0:o.statusCode)?-1*o.statusCode:-888,message:"statusCode:".concat(null==o?void0:o.statusCode,",data:").concat(s)};n.dealFailData(f,i,r),e(f.code)},fail:function(o){xt.devLog("上报失败:",o),t.currentRequestCount-=1;vara={code:"number"==typeof(null==o?void0:o.errno)?-1*o.errno:-999,message:null==o?void0:o.errMsg};n.dealFailData(a,i,r),e(a.code)}})})}},{key:"startInspectTimer",value:function(){vare=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout(function(){t.currentRequestCount>=t.requestConcurrency&&(t.currentRequestCount=t.requestConcurrency-1),e.executeSend(),e.startInspectTimer()},1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(t,e,n){if("function"==typeoft)try{for(varr=[],i=0;i<n.actions.length;i++)if(!n.actions[i].is_sdk_auto_track){varo=n.actions[i],a=o.action_type,u=o.action_param,c=o.action_id,s=o.action_time;r.push({action_type:a,action_param:u,action_id:c,action_time:s})}if(r.length){varl=n.info,f=l.user_action_set_id,d=l.appid,p=l.openid,v=l.unionid,h=l.user_unique_id;t({code:null==e?void0:e.code,message:null==e?void0:e.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:h}}})}}catch(r){xt.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(e){"number"==typeofe?e<1?xt.error("网络请求最大并发量不能小于1"):e>10?xt.error("网络请求最大并发量不能大于10"):t.requestConcurrency=e:xt.error("网络请求最大并发量需设置为数字")}}]),t}(),nn=en;nn.currentRequestCount=0,nn.requestConcurrency=E.requestConcurrency,tn([Dt],nn.prototype,"batchSend",1),tn([Dt],nn.prototype,"flushSend",1),tn([Dt],nn.prototype,"executeSend",1);varrn=Wt,on=Jt,an=Ht,un=zt,cn=$t,sn=oe,ln=Xt,fn=Zt,dn=te,pn=ne,vn=ie,hn=re,_n=ee,gn=function(){functione(){f(this,e)}returnp(e,[{key:"install",value:function(e,n){varr=function(n){Qt.subscribe(n,function(n){varr=arguments.length>1&&void0!==arguments[1]?arguments[1]:{};returnfunction(i){varo=arguments.length>1&&void0!==arguments[1]?arguments[1]:{};Nt.hasDirectGameMask||("ENTER_FOREGROUND"===n&&(Nt.activeDuration=Date.now()),e.track(n,Object.assign(r||{},o,t(t({},wn,!0),Cn,i))))}}(n))};r(on),r(rn),r(an),r(un),"all"===n&&(r(cn),r(sn),r(ln),r(dn),r(fn),r(_n),r(pn),r(vn),r(hn))}}]),e}(),yn=function(){functione(){f(this,e),this.special_method_symbol=Symbol("special_method_symbol")}returnp(e,[{key:"onPurchase",value:function(t){return"number"!=typeoft&&xt.warn("付费金额需要为数字"),t<=0&&xt.warn("付费金额需要大于0"),this.wrapTrack(F,{value:t})}},{key:"onEnterForeground",value:function(){returnthis.wrapTrack(P)}},{key:"onEnterBackground",value:function(){returnthis.wrapTrack(U)}},{key:"onAppStart",value:function(){returnthis.wrapTrack(M)}},{key:"onAppQuit",value:function(){returnthis.wrapTrack(j)}},{key:"onAddToWishlist",value:function(){returnthis.wrapTrack(q)}},{key:"wrapTrack",value:function(e,n){returnthis.track(e,Object.assign(n||{},t({},this.special_method_symbol,1)))}}]),e}(),mn=function(){i(e,yn);vart=a(e);functione(){returnf(this,e),t.apply(this,arguments)}returnp(e,[{key:"onRegister",value:function(){returnthis.wrapTrack(G)}},{key:"onCreateRole",value:function(t){returnt&&"string"!=typeoft&&xt.warn("角色名称需要为字符串"),this.wrapTrack(B,t?{name:t}:{})}},{key:"onTutorialFinish",value:function(){returnthis.wrapTrack(V)}}]),e}(),An="(如果确认无误,请忽略该提示)",Rn=function(){vart=[];return{requestActionList:function(){try{lt({conf_name:"data_nexus_common",conf_key:"action_types"}).then(function(e){_t(e)&&(t=e)})}catch(t){xt.error(t)}},getActionList:function(){returnt}}}();functionkn(t,e){try{t.is_sdk_auto_track||(function(t){try{vare=Rn.getActionList();if(!e.includes(t)){varr,i=function(t){vare="undefined"!=typeofSymbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=n(t))){e&&(t=e);varr=0,i=function(){};return{s:i,n:function(){returnr>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throwt},f:i}}thrownewTypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable,non-array objects must have a[Symbol.iterator]()method.")}varo,a=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){vart=e.next();returna=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throwo}}}}(e);try{for(i.s();!(r=i.n()).done;){varo=r.value;if(Sn(o,t)<=parseInt((.3*o.length).toString())){xt.warn("通过SDK上报的".concat(t,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(An));break}}}catch(t){i.e(t)}finally{i.f()}}}catch(e){xt.error(e)}}(t.action_type),"minigame"===e?function(t,e){varn,r,i;try{["PURCHASE","ADD_TO_CART"].includes(t.action_type)&&t.action_param&&It(t.action_param,"value")&&("number"!=typeof(null==(n=t.action_param)?void0:n.value)?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要为数字!")):(null==(r=t.action_param)?void0:r.value)<=0?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要大于0!")):"minigame"===e&&(null==(i=t.action_param)?void0:i.value)<100&&xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(An)))}catch(t){xt.error(t)}}(t,e):"miniprogram"===e&&function(t){try{vare=null==t?void0:t.action_type,n=(null==t?void0:t.action_param)||{};"PURCHASE"===e&&It(n,"value")&&("number"!=typeof(null==n?void0:n.value)?xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要为数字!")):(null==n?void0:n.value)<=0&&xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要大于0!")))}catch(e){xt.error(e)}}(t))}catch(t){xt.error(t)}}functionSn(t,e){try{if(0===t.length)returne.length;if(0===e.length)returnt.length;for(varn=[],r=0;r<=e.length;r++)n[r]=[r];for(vari=0;i<=t.length;i++)n[0][i]=i;for(varo=1;o<=e.length;o++)for(vara=1;a<=t.length;a++)e.charAt(o-1)===t.charAt(a-1)?n[o][a]=n[o-1][a-1]:n[o][a]=Math.min(n[o-1][a-1]+1,n[o][a-1]+1,n[o-1][a]+1);returnn[e.length][t.length]}catch(n){xt.error(n)}}functionTn(t){try{t&&!/^[a-zA-Z0-9_\-]+$/.test(t)&&xt.warn("通过SDK上报的openid:".concat(t,"可能有误,请检查openid是否正确!").concat(An))}catch(t){xt.error(t)}}varEn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,On=function(t,e,n,r){for(vari,o=r>1?void0:r?bn(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);returnr&&o&&En(e,n,o),o},In=Symbol("initializedInstance"),wn=Symbol("autoTrack"),Cn=Symbol("actionTime"),xn=function(){i(n,mn);vare=a(n);functionn(t){varr;if(f(this,n),(r=e.call(this)).env="production",r.sdk_version="1.5.7",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)returnr.initErrMsg="不支持非微信小游戏中使用",xt.error(r.initErrMsg),u(r);vari=Ot();if(n[In].length>=i.maxSdkInstance)returnr.initErrMsg="初始化超过上限",xt.error(r.initErrMsg),u(r);varo=Et(t),a=at();if(!0!==o)returnr.initErrMsg=o,xt.error(o),u(r);vars=null==a?void0:a.appId;if(s&&s!==t.appid)returnr.initErrMsg="初始化传入的appid与当前小游戏appid不一致",xt.error(r.initErrMsg),u(r);r.config=t,It(t,"auto_track")||(r.config.auto_track=bt("autoTrack")),r.openid=t.openid,r.unionid=t.unionid,r.user_unique_id=t.user_unique_id,r.onReportComplete=t.on_report_complete,r.onReportFail=t.on_report_fail,r.saveValidOpenidToStorage();varl=t.user_action_set_id;returnn[In].includes(l)?(r.initErrMsg="同个数据源[".concat(l,"]只能初始化一次"),xt.error(r.initErrMsg),r.reportLog({log_type:b.JS_RUN_ERROR,message:r.initErrMsg}),u(r)):(r.reportLog=r.reportLog.bind(c(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(c(r)),Nt.activeDuration=Date.now(),r.initDirectGameConfig(),r.deviceInfo=nt(),r.gameInfo=Lt(),r.session_id=mt(),r.queueManage=newBt({userActionSetId:l,maxLength:i.maxQueueLength,ogEvents:Yt}),r.actionReporter=newnn({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:se,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,n[In].push(l),r.useAutoTrack(),r.addDirectGameStatusListener(),r.doReportOnEnterBackground(),"release"===(null==a?void0:a.envVersion)?(xt.info("初始化成功"),u(r)):(function(t){vare=t.sdk_version,n=t.default_download_url,r=t.fail_handler;lt({conf_name:t.conf_name,conf_key:t.conf_key}).then(function(t){if(ht(t)){vari=null==t?void0:t.blackVersions,o=null==t?void0:t.minVersion,a=null==t?void0:t.bestVersion,u=null==t?void0:t.downloadUrl,c=n;returnu&&/^https/.test(u)&&(c=u),_t(i)&&(null==i?void0:i.indexOf(e))>-1?(null==r||r(),voidxt.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):o&&Tt(e,o)<0?(null==r||r(),voidxt.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Tt(e,a)<0&&xt.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),voidxt.info("初始化成功"))}xt.info("初始化成功")}).catch(function(){xt.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}}),Rn.requestActionList(),Tn(t.openid),u(r)))}returnp(n,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(t,e){varn,r;if(!this.inited||!this.queueManage)returnxt.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};vari=qe.validateActionType(t),o=qe.validateActionParam(e);if(i&&o){!this.openid&&!this.unionid&&xt.warn("缺少 openid 或 unionid");vara=bt("actionParamMaxLength");if(JSON.stringify(e||{}).length>a)returnxt.error("监测到超过".concat(a,"的上报日志:").concat(t," ").concat(e)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};varu=!(null==e||!e[wn]),c=this.createAction(t,e||{},u);"release"!==(null==(n=at())?void0:n.envVersion)&&kn(c,"minigame");vars=this.queueManage.addAction(c);returnnull==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){vart;null==(t=this.actionReporter)||t.flushSend()}},{key:"setOpenId",value:function(t){vare;if(t&&"string"==typeoft)returnthis.openid=t,this.gameInfo.ad_trace_id&&!tt.getSync(S)&&Qt.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(e=at())?void0:e.envVersion)&&Tn(t),{code:0,message:"成功"};varn="openid 格式错误";returnxt.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(t){if(t&&"string"==typeoft)returnthis.unionid=t,this.flush(),{code:0,message:"成功"};vare="unionid 格式错误";returnxt.error(e),{code:101,message:e}}},{key:"setUserUniqueId",value:function(t){if(t&&"string"==typeoft)returnthis.user_unique_id=t,{code:0,message:"成功"};vare="user_unique_id 格式错误";returnxt.error(e),{code:101,message:e}}},{key:"doReportOnEnterBackground",value:function(){vart=this;wx.onHide(function(){vare,n;null==(e=t.actionReporter)||e.flushSend(),null==(n=t.queueManage)||n.reportLostNum()})}},{key:"getTrackBaseInfo",value:function(){vart=at();returnObject.assign({},this.deviceInfo,function(t){vare={};return["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"].forEach(function(n){It(t,n)&&(e[n]=t[n])}),e}(this.config),{local_id:rt(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||ot(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:t.envVersion,app_version:t.version}})}},{key:"createAction",value:function(t,e){varn=arguments.length>2&&void0!==arguments[2]&&arguments[2];null!=e&&e[wn]&&deletee[wn];varr=Date.now();null!=e&&e[Cn]&&(r=null==e?void0:e[Cn],deletee[Cn]);vari={action_id:mt(),action_param:e,action_time:r,action_type:t,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:st.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:it(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(t)};returnnull!=e&&e[this.special_method_symbol]&&(this.addActionInnerParam(i,"is_special_method",!0),deletee[this.special_method_symbol]),se.getChannelClaimActionList().indexOf(t)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(i,"launch_options",this.gameInfo.launch_options),i}},{key:"addActionInnerParam",value:function(e,n,r){e.inner_param&&ht(e.inner_param)?e.inner_param[n]=r:e.inner_param=t({},n,r)}},{key:"getChannelByActionType",value:function(t){vare="";returnse.getChannelClaimActionList().indexOf(t)>-1?e=this.gameInfo.channel||"":se.getNoClaimActionList().indexOf(t)>-1&&(e=X),e}},{key:"reportLog",value:function(t){vare,n,r={user_action_set_id:null==(e=this.config)?void0:e.user_action_set_id,appid:null==(n=this.config)?void0:n.appid,session_id:this.session_id};ct(Object.assign(r,t))}},{key:"useAutoTrack",value:function(){vart;if(null!=(t=this.config)&&t.auto_track){vare=!0,n=tt.getSync(R);(null==n?void0:n.ap)===K?e=!0:(null==n?void0:n.ap)===Q&&(e=!1),"devtools"===nt().wx_platform&&(e=!0),(newgn).install(this,e?"all":"lifecycle"),ve(),e&&Le(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){vart,e,n=nt();n.os&&n.os_version&&null!=(t=this.config)&&t.user_action_set_id&&function(t){returnnewPromise(function(e){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:t,timeout:E.requestTimeout,success:function(t){ft(t,e,"minigame/get"),pt(t)},fail:function(t){dt(t,"minigame/get")}})})}({conf_name:"MG",conf_param:{user_action_set_id:null==(e=this.config)?void0:e.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void0:n.os)||"",os_version:wt(n.os_version),device_brand:(null==n?void0:n.device_brand)||"",weixin_lib_version:(null==n?void0:n.wx_lib_version)||"",weixin_version:(null==n?void0:n.wx_version)||""}}).then(function(t){ht(t)&&tt.setSync(R,t)})}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(t){return/^[a-zA-Z0-9_-]{28,30}$/.test(t)}(this.openid)&&tt.setSync(S,this.openid)}},{key:"initDirectGameConfig",value:function(){try{if(xt.log("wx.getDirectAdStatusSync方法是否存在:",wx.getDirectAdStatusSync),wx.getDirectAdStatusSync){vart=wx.getDirectAdStatusSync();xt.log("wx.getDirectAdStatusSync方法返回的值info:",t),t.isInMask&&t.isInDirectGameAd&&(Nt.hasDirectGameMask=!0,xt.log("SDK初始获取的直玩蒙层状态值:",Nt.hasDirectGameMask))}}catch(t){xt.log("获取直玩状态异常:",t)}}},{key:"addDirectGameStatusListener",value:function(){vart=this;try{xt.log("wx.onDirectAdStatusChange方法是否存在:",wx.onDirectAdStatusChange),wx.onDirectAdStatusChange&&wx.onDirectAdStatusChange(function(e){varn=e.isInMask,r=e.isEndByAbnormal;xt.log("wx.onDirectAdStatusChange方法返回的值res:",e),xt.log("状态切换前,SDK的直玩蒙层状态值:",Nt.hasDirectGameMask),Nt.hasDirectGameMask&&!n&&(Nt.hasDirectGameMask=!1,xt.log("状态切换后,SDK的直玩蒙层状态值:",Nt.hasDirectGameMask),t.gameInfo.ad_trace_id&&tt.setSync(m,t.gameInfo.ad_trace_id),Qt.publish("START_APP",{isEndByAbnormal:!!r}),Qt.publish("ENTER_FOREGROUND"))})}catch(t){xt.log("监听直玩状态异常:",t)}}}],[{key:"setRequestConcurrency",value:function(t){nn.setRequestConcurrency(t)}},{key:"setDebug",value:function(t){xt.debug=t}}]),n}(),Nn=xn;Nn[In]=[],On([Dt],Nn.prototype,"track",1),On([Dt,function(t,e,n){varr=n.value;returnn.value=function(){if(this.inited){for(vart=arguments.length,e=newArray(t),n=0;n<t;n++)e[n]=arguments[n];returnr.apply(this,e)}xt.error("上报失败,请先完成初始化")},n}],Nn.prototype,"flush",1),On([Dt],Nn.prototype,"setOpenId",1),On([Dt],Nn.prototype,"setUnionId",1),On([Dt],Nn.prototype,"setUserUniqueId",1),On([Dt],Nn.prototype,"doReportOnEnterBackground",1),On([Dt],Nn.prototype,"getTrackBaseInfo",1),On([Dt],Nn.prototype,"useAutoTrack",1),On([Dt],Nn.prototype,"initDirectGameConfig",1),On([Dt],Nn.prototype,"addDirectGameStatusListener",1),window.WX_AD_SDK=Nn,module.exports={SDK:Nn};