jf-gamekit 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ttSdk.es.js +3 -3
- package/es/wxSdk.es.js +1 -1
- package/index.d.ts +1 -1
- package/lib/ttSdk.js +3 -3
- package/lib/wxSdk.js +1 -1
- package/package.json +2 -1
- package/umd/ttSdk.umd.js +18 -0
- package/umd/wxSdk.umd.js +7 -0
package/es/wxSdk.es.js
CHANGED
|
@@ -4,4 +4,4 @@ function e(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e
|
|
|
4
4
|
* (c) 2025
|
|
5
5
|
* @license ISC
|
|
6
6
|
*/
|
|
7
|
-
function y(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){if(e){if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(e,t):void 0}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=R(e);if(t){var o=R(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return T(this,n)}}function T(e,t){if(t&&("object"===O(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,C(r.key),r)}}function x(e,t,n){return t&&I(e.prototype,t),n&&I(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function C(e){var t=function(e){if("object"!==O(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==O(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===O(t)?t:String(t)}var N,P,L="LOCAL_ID",M="CLICK_ID",D="QUEUE_LOST_MAP",q="REMOTE_CONFIG",U="REMOTE_COMMON_CONFIG",j="OPENID",F={init:"init",reporting:"reporting",fail:"fail"},B={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"]},V="JS_RUN_ERROR",K="REQUEST_ERROR",G="REQUEST_CONFIG_ERROR",W="JS_QUEUE_LOG",J="PROXY_ERROR",H="QUEUE_LOST_NUM",Y="SIGN_ERROR",Q="UNKNOWN",z="TRUE",$="FALSE",Z="TICKET_INTERVAL_CHANGE",X=(P=function(e){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(e)},{getSync:function(e){var t;try{t=wx.getStorageSync(P(e))}catch(e){return console.error("storage get error",e),t}return t},setSync:function(e,t){try{wx.setStorageSync(P(e),t)}catch(e){return console.error("storage set error",e),!1}return!0}}),ee=function(){var e;return function(){if(!e){var t=function(){if(N)return N;try{return N=wx.getSystemInfoSync()}catch(e){return{}}}(),n=t.system,r=void 0===n?"":n,o=(null==r?void 0:r.split(" "))||[],i=function(e){if(!e)return Q;var t=(null==e?void 0:e.toUpperCase())||"";return t.indexOf("ANDROID")>-1?"ANDROID":t.indexOf("IOS")>-1?"IOS":t.indexOf("MAC")>-1?"OSX":t.indexOf("WINDOWS")>-1?"WINDOWS":Q}(o[0]),a=function(e){return!e||e.length<=0?"":2===e.length?e[1]:3===e.length&&"Windows"===e[0]?"".concat(e[1]," ").concat(e[2]):e[e.length-1]}(o);e={benchmark_level:t.benchmarkLevel,device_brand:t.brand,screen_height:Math.floor(t.screenHeight),screen_width:Math.floor(t.screenWidth),wx_lib_version:t.SDKVersion,wx_version:t.version,wx_platform:t.platform,device_model:t.model,os:i,os_version:a}}return e}}(),te=function(){var e;return function(){try{if(e)return e;e||(e=X.getSync(L)||""),e||(e=ye(),X.setSync(L,e))}catch(e){}return e}}(),ne=function(){var e="unknown",t=!1;return function(){if(!t)try{wx.getNetworkType({success:function(t){e=t.networkType},fail:function(){e="unknown"}}),wx.onNetworkStatusChange(function(t){e=t.networkType}),t=!0}catch(e){}return e}}();ne();var re=function(){var e="";return function(){return e||(e=X.getSync(j)||""),e}}(),oe=function(){var e;return function(){if(e)return e;try{var t=wx.getAccountInfoSync();return pe(t.miniProgram)?e=t.miniProgram:{}}catch(t){return{}}}}();function ie(e){var t=null==e?void 0:e.query;if(!pe(t))return"";var n="";return t.gdt_vid||[1045,1046,1084].indexOf(null==e?void 0:e.scene)>-1?n="TENCENT":t.clue_token||t.clickid&&t.item_id?n="BYTEDANCE":t.callback&&"kuaishou"===t.ksChannel?n="KUAISHOU":t.bd_vid||t.ai&&t.d&&t.q&&t.c?n="BAIDU":t.uctrackid?n="ALIBABA":(t.trackid||t.imp||[1065,1069,1194].indexOf(null==e?void 0:e.scene)>-1&&(t.callback||t.u))&&(n="OTHERS"),n}function ae(e,t){try{var n=ee(),r=oe(),o={sdk_version:"1.5.5",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void 0:n.device_brand,device_model:null==n?void 0:n.device_model,wx_version:null==n?void 0:n.wx_version,wx_lib_version:null==n?void 0:n.wx_lib_version,wx_platform:null==n?void 0:n.wx_platform,os:null==n?void 0:n.os,os_version:null==n?void 0:n.os_version,local_id:te(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},i=Object.assign(o,e);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:i,method:"POST",timeout:B.requestTimeout,success:function(e){"function"==typeof t&&200===(null==e?void 0:e.statusCode)&&t()}})}catch(n){Ee.error(n)}}var ue=function(){function e(){E(this,e)}return x(e,null,[{key:"revise",value:function(e){e>0&&!this.isRevised&&(this.offsetTime=e-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),e}();function ce(e){return new Promise(function(t,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:e,timeout:B.requestTimeout,success:function(e){se(e,t,"config/get",n),fe(e)},fail:function(e){le(e,"config/get",n)}})})}function se(e,t,n,r){var o,i,a,u,c=null==e?void 0:e.statusCode,s=null==(o=null==e?void 0:e.data)?void 0:o.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),ae({log_type:G,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==e?void 0:e.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==e?void 0:e.data)?void 0:u.data)}else t(null==(i=e.data)?void 0:i.data)}function le(e,t,n){ae({log_type:G,message:"cgiName: ".concat(t," , message: ").concat(null==e?void 0:e.errMsg," "),code:"number"==typeof(null==e?void 0:e.errno)?-1*e.errno:-999}),null==n||n(e)}function fe(e){var t,n=1*(null==(t=null==e?void 0:e.header)?void 0:t["Server-Time"]);n>17266752e5&&ue.revise(n)}ue.offsetTime=0,ue.isRevised=!1;var de=Object.prototype.toString,pe=function(e){return"[object Object]"===de.call(e)},ve=function(e){return"[object Array]"===de.call(e)},he=function(e){return"[object Function]"===de.call(e)},ge=(new Date).getTime();function ye(){var e=(new Date).getTime(),t=Math.abs(1e3*(e-ge));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")})}var me=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,_e=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");if(!me.test(e))throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"))},Ae=function(e){return isNaN(Number(e))?e:Number(e)},ke=function(e){var t=e.replace(/^v/,"").replace(/\+.*$/,""),n=function(e){return-1===e.indexOf("-")?e.length:e.indexOf("-")}(t),r=t.substring(0,n).split(".");return r.push(t.substring(n+1)),r},Se=function(e,t){[e,t].forEach(_e);for(var n=ke(e),r=ke(t),o=0;o<Math.max(n.length-1,r.length-1);o++){var i=parseInt(n[o]||"0",10),a=parseInt(r[o]||"0",10);if(i>a)return 1;if(a>i)return-1}var u=n[n.length-1],c=r[r.length-1];if(u&&c)for(var s=u.split(".").map(Ae),l=c.split(".").map(Ae),f=0;f<Math.max(s.length,l.length);f++){if(void 0===s[f]||"string"==typeof l[f]&&"number"==typeof s[f])return-1;if(void 0===l[f]||"string"==typeof s[f]&&"number"==typeof l[f]||s[f]>l[f])return 1;if(l[f]>s[f])return-1}else if(u||c)return u?-1:1;return 0};function be(e){return Te()[e]}function Te(){return B}function we(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Re=function(e){try{return e&&"string"==typeof e?-1===(e=e.replace(/\s/g,"")).indexOf(".")?e:e.split(".").slice(0,2).join("."):""}catch(t){return e}},Oe=function(){function e(){E(this,e)}return x(e,null,[{key:"error",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).error.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"info",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"log",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"warn",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).warn.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"devLog",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}}]),e}(),Ee=Oe;Ee.debug=!1,Ee.isDev=!1;var Ie=function(){var e;return function(){if(!e)try{var t=wx.getLaunchOptionsSync(),n=t.query.gdt_vid||"";n?X.setSync(M,n):n=X.getSync(M)||"";var r=JSON.stringify(t);r.length>1e4&&(r=JSON.stringify({cut:1,scene:t.scene})),e={source_scene:t.scene,pkg_channel_id:t.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ie(t)}}catch(t){e={},Ee.log("获取场景值和渠道号失败",t)}return e}}();function xe(e,t,n){var r=n.value;return n.value=function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];try{return r.apply(this,o)}catch(n){try{Ee.error.apply(Ee,["calling ".concat(e.constructor.name,".").concat(t," error with arguments")].concat(o)),Ee.error(n);var a={log_type:V,message:"[safeExcutable] ".concat(e.constructor.name,".").concat(t,": ").concat(null==n?void 0:n.message),err_stack:null==n?void 0:n.stack};he(this.reportLog)?this.reportLog(a):ae(a)}catch(a){}}},n}var Ce=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Pe=function(e,t,n,r){for(var o,i=r>1?void 0:r?Ne(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ce(t,n,i),i},Le=function(){function e(t){var n=t.userActionSetId,r=t.maxLength,o=void 0===r?500:r;E(this,e),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat("QUEUE_ACTIONS","_").concat(null==n?void 0:n.toString()),this.maxLength=o,this.userActionSetId=n,this.setTimeStamp(),this.init()}return x(e,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var e,t=(null==(e=X)?void 0:e.getSync(this.localStorageKey))||"[]";return JSON.parse(t)}},{key:"reportLostNum",value:function(){var e=this,t=Object.assign({},this.lostActionMaps),n=[];for(var r in t){var o=null==r?void 0:r.split("_");n.push({queue_lost_session_id:o[0],queue_lost_timestamp:o[1],queue_lost_num:t[r]})}n.length&&(this.setTimeStamp(),n.forEach(function(t){var n=Object.assign({},{user_action_set_id:e.userActionSetId,log_type:H},t),r=null==t?void 0:t.queue_lost_session_id,o=null==t?void 0:t.queue_lost_timestamp,i="".concat(r,"_").concat(o);ae(n,function(){we(e.lostActionMaps,i)&&(delete e.lostActionMaps[i],X.setSync(D,JSON.stringify(e.lostActionMaps)))})}))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var e=this,t=this.getStorage(),n=null==t?void 0:t.map(function(e){var t,n;return e.inner_status===(null==(t=F)?void 0:t.reporting)?Object.assign({},e,{inner_status:null==(n=F)?void 0:n.fail,is_retry:!0,retry_count:e.retry_count+1}):e});this.stack=n,this.lostActionMaps=JSON.parse(X.getSync(D)||"{}"),setTimeout(function(){e.reportLostNum()},1e3)}},{key:"addItem",value:function(e){var t;null==(t=null==this?void 0:this.stack)||t.push(e)}},{key:"removeItems",value:function(e){var t,n=null==(t=null==this?void 0:this.stack)?void 0:t.filter(function(t){return!(null!=e&&e.includes(null==t?void 0:t.action_id))});this.stack=n}},{key:"updateForReportFail",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=F)?void 0:n.fail,retry_count:t.retry_count+1,is_retry:!0}):t})}},{key:"updateForReporting",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=F)?void 0:n.reporting}):t})}},{key:"updateAllStack",value:function(e){this.stack=e}},{key:"updateToStorage",value:function(){X.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(e){if(e){var t="".concat(e,"_").concat(this.timeStamp),n=this.lostActionMaps[t]||0;this.lostActionMaps[t]=n+1,X.setSync(D,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),e}();Pe([xe],Le.prototype,"getItems",1),Pe([xe],Le.prototype,"getStorage",1),Pe([xe],Le.prototype,"reportLostNum",1),Pe([xe],Le.prototype,"getLostMaps",1),Pe([xe],Le.prototype,"init",1),Pe([xe],Le.prototype,"addItem",1),Pe([xe],Le.prototype,"removeItems",1),Pe([xe],Le.prototype,"updateForReportFail",1),Pe([xe],Le.prototype,"updateForReporting",1),Pe([xe],Le.prototype,"updateAllStack",1),Pe([xe],Le.prototype,"updateToStorage",1),Pe([xe],Le.prototype,"updateLostAction",1);var Me=Object.defineProperty,De=Object.getOwnPropertyDescriptor,qe=function(e,t,n,r){for(var o,i=r>1?void 0:r?De(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Me(t,n,i),i},Ue=function(){k(t,Le);var e=b(t);function t(n){var r,o=n.userActionSetId,i=n.maxLength,a=void 0===i?500:i,u=n.ogEvents,c=void 0===u?[]:u;return E(this,t),(r=e.call(this,{userActionSetId:o,maxLength:a})).ogEvents=c,r}return x(t,[{key:"getReportableActions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,t=this.getItems(),n=[];return null==t||t.forEach(function(t){var r;(null==n?void 0:n.length)<e&&(null==t?void 0:t.inner_status)!==(null==(r=F)?void 0:r.reporting)&&(null==n||n.push(t))}),n}},{key:"addAction",value:function(e){var t={code:0,message:"成功",actionId:e.action_id},n=this.getItems();if((null==n?void 0:n.length)>=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");Ee.warn(r),ae({user_action_set_id:this.userActionSetId,log_type:W,message:"队列长度超过限制"});var o=this.sortQueue(e,n);Ee.debug&&Ee.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),o.concat([]));var i=o.pop();this.updateAllStack(o),this.updateLostAction((null==i?void 0:i.session_id)||""),(null==i?void 0:i.action_id)===e.action_id&&(t={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(e);return this.updateToStorage(),t}},{key:"removeActions",value:function(e){this.removeItems(e),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(e){this.updateForReportFail(e),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(e){this.updateForReporting(e),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var e=this.getItems().filter(function(e){var t;return(null==e?void 0:e.inner_status)!==(null==(t=F)?void 0:t.reporting)});return null==e?void 0:e.length}},{key:"sortQueue",value:function(e,t){var n=this,r={},o=null==e?void 0:e.action_time,i=t.concat([e]),a=function(e){return r[e.action_id]||(r[e.action_id]=n.caculateWeight(o,e)),r[e.action_id]};return i.sort(function(e,t){return a(t)-a(e)})}},{key:"caculateWeight",value:function(e,t){var n,r=0,o=this.formatWeight(e,null==t?void 0:t.action_time),i=o.ogWeight,a=o.sdkWeight,u=o.userWeight;null!=(n=this.ogEvents)&&n.includes(null==t?void 0:t.action_type)&&(r+=i),null!=t&&t.is_sdk_auto_track?r+=a:r+=u;var c=e-(null==t?void 0:t.action_time)+1;return c>0?r+1/c:r}},{key:"formatWeight",value:function(e,t){var n=1e3,r=10,o=100;return e-t>2592e6&&(n/=100,r/=100,o/=100),{ogWeight:n,sdkWeight:r,userWeight:o}}}]),t}();qe([xe],Ue.prototype,"getReportableActions",1),qe([xe],Ue.prototype,"addAction",1),qe([xe],Ue.prototype,"removeActions",1),qe([xe],Ue.prototype,"updateActionsForReportFail",1),qe([xe],Ue.prototype,"updateActionsForReporting",1),qe([xe],Ue.prototype,"getReportableActionsLength",1),qe([xe],Ue.prototype,"sortQueue",1),qe([xe],Ue.prototype,"caculateWeight",1),qe([xe],Ue.prototype,"formatWeight",1);var je=function(){function e(){E(this,e),this.events={}}return x(e,[{key:"subscribe",value:function(t,n){e.checkCallback(n),ve(this.events[t])?this.events[t].push(n):this.events[t]=[n]}},{key:"once",value:function(t,n){e.checkCallback(n),this.subscribe(this.onceEventName(t),n)}},{key:"unsubscribe",value:function(t,n){e.checkCallback(n),ve(this.events[t])&&(this.events[t]=this.events[t].filter(function(e){return e!==n})),ve(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)]=this.events[this.onceEventName(t)].filter(function(e){return e!==n}))}},{key:"publish",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=Date.now();ve(this.events[e])&&this.events[e].forEach(function(e){return e.apply(void 0,[o].concat(n))}),ve(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)].forEach(function(e){return e.apply(void 0,[o].concat(n))}),this.events[this.onceEventName(e)]=[])}},{key:"onceEventName",value:function(e){return"once_event_prefix_".concat(e)}}],[{key:"checkCallback",value:function(t){he(t)||Ee.error(e.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),e}(),Fe=je;Fe.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";var Be=new Fe,Ve=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],Ke="START_APP",Ge="TICKET",We="ENTER_FOREGROUND",Je="ENTER_BACKGROUND",He="LOGIN",Ye="SHARE",Qe="TAP_GAME_CLUB",ze="CREATE_GAME_CLUB",$e="JOIN_GAME_ROOM",Ze="FINISH_PAY",Xe="START_PAY",et="ADD_TO_WISHLIST",tt=["REGISTER","START_APP","RE_ACTIVE"],nt=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],rt=function(){function e(){E(this,e),this.channelClaimActionList=tt,this.noClaimActionList=nt,this.realTimeActionList=B.realTimeActionList,this.ticketInterval=60,this.requestTimeout=B.requestTimeout,this.loadConfig()}return x(e,[{key:"getChannelClaimActionList",value:function(){return this.channelClaimActionList}},{key:"getNoClaimActionList",value:function(){return this.noClaimActionList}},{key:"getRealTimeActionList",value:function(){return this.realTimeActionList}},{key:"getTicketInterval",value:function(){return this.ticketInterval}},{key:"getRequestTimeout",value:function(){return this.requestTimeout}},{key:"loadConfig",value:function(){var e=this;try{if("undefined"==typeof wx)return;var t=X.getSync(U);t&&this.updateConfig(t),ce({conf_name:"mini_game_sdk_common",conf_key:"config"}).then(function(t){t&&pe(t)&&(e.updateConfig(t),X.setSync(U,t))})}catch(t){console.error(t)}}},{key:"updateConfig",value:function(e){e.channelClaimActionList&&ve(e.channelClaimActionList)&&(this.channelClaimActionList=e.channelClaimActionList),e.noClaimActionList&&ve(e.noClaimActionList)&&(this.noClaimActionList=e.noClaimActionList),e.realTimeActionList&&ve(e.realTimeActionList)&&(this.realTimeActionList=e.realTimeActionList),e.ticketInterval&&"number"==typeof e.ticketInterval&&e.ticketInterval>1&&e.ticketInterval!==this.ticketInterval&&(this.ticketInterval=e.ticketInterval,Be.publish(Z)),e.requestTimeout&&"number"==typeof e.requestTimeout&&e.requestTimeout>5e3&&(this.requestTimeout=e.requestTimeout)}}]),e}(),ot=new rt,it=Ke,at=Ge,ut=We,ct=Je,st=function(){var e=!1,t=!1,n=!0,r=!0,o=!0,i=!1;return function(){if(!i){i=!0;var a=X.getSync(q);if((null==a?void 0:a.bg)===z?e=!0:(null==a?void 0:a.bg)===$&&(e=!1),(null==a?void 0:a.fg)===z?t=!0:(null==a?void 0:a.fg)===$&&(t=!1),(null==a?void 0:a.st)===z?n=!0:(null==a?void 0:a.st)===$&&(n=!1),(null==a?void 0:a.ti)===z?r=!0:(null==a?void 0:a.ti)===$&&(r=!1),Ee.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",e,t,n,r),n&&Be.publish(it),r){var u=function(){o&&Be.publish(at)},c=setInterval(u,1e3*ot.getTicketInterval());Be.subscribe(Z,function(){c&&clearInterval(c),c=setInterval(u,1e3*ot.getTicketInterval())})}wx.onShow(function(e){if(o=!0,t){var n="";try{(n=JSON.stringify(e)).length>1e4&&(n=JSON.stringify({cut:1,scene:e.scene}))}catch(e){}Be.publish(ut,{enter_options:n})}}),wx.onHide(function(){o=!1,e&&Be.publish(ct)})}}}(),lt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ft(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dt,pt=ft(function(){var e,t=null;function n(e){return!!e&&("object"==O(e)||"function"==typeof e)}function r(e){if(null!==e&&!n(e))throw new TypeError("Object prototype may only be an Object or null: "+e)}var o=Object,i=!(!o.create&&{__proto__:null}instanceof o),a=o.create||(i?function(e){return r(e),{__proto__:e}}:function(e){if(r(e),null===e)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var t=function(){};return t.prototype=e,new t}),u=function(){return null},c=o.getPrototypeOf||([].__proto__===Array.prototype?function(e){var t=e.__proto__;return n(t)?t:null}:u);return e=function(s,l){if(void 0===(this&&this instanceof e?this.constructor:void 0))throw new TypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))throw new TypeError("Cannot create proxy with a non-object as target or handler");var f=function(){};t=function(){s=null,f=function(e){throw new TypeError("Cannot perform '".concat(e,"' on a proxy that has been revoked"))}},setTimeout(function(){t=null},0);var d=l;for(var p in l={get:null,set:null,apply:null,construct:null},d){if(!(p in l))throw new TypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=d[p]}"function"==typeof d&&(l.apply=d.apply.bind(d));var v,h=c(s),g=!1,y=!1;"function"==typeof s?(v=function(){var e=this&&this.constructor===v,t=Array.prototype.slice.call(arguments);return f(e?"construct":"apply"),e&&l.construct?l.construct.call(this,s,t):!e&&l.apply?l.apply(s,this,t):e?(t.unshift(s),new(s.bind.apply(s,t))):s.apply(this,t)},g=!0):s instanceof Array?(v=[],y=!0):v=i||null!==h?a(h):{};var m=l.get?function(e){return f("get"),l.get(this,e,v)}:function(e){return f("get"),this[e]},_=l.set?function(e,t){f("set"),l.set(this,e,t,v)}:function(e,t){f("set"),this[e]=t},A=o.getOwnPropertyNames(s),k={};A.forEach(function(e){if(!g&&!y||!(e in v)){var t={enumerable:!!o.getOwnPropertyDescriptor(s,e).enumerable,get:m.bind(s,e),set:_.bind(s,e)};o.defineProperty(v,e,t),k[e]=!0}});var S=!0;if(g||y){var b=o.setPrototypeOf||([].__proto__===Array.prototype?function(e,t){return r(t),e.__proto__=t,e}:u);h&&b(v,h)||(S=!1)}if(l.get||!S)for(var T in s)k[T]||o.defineProperty(v,T,{get:m.bind(s,T)});return o.seal(s),o.seal(v),v},e.revocable=function(n,r){return{proxy:new e(n,r),revoke:t}},e}),vt={};try{dt||(dt=pt())}catch(N){_t(N)}function ht(e,t,n,r){try{if(!dt||null==e||!e[t])return;e[t]=new dt(e[t],{apply:function(e,t,o){var i,a;r&&mt(function(){return r.apply(void 0,m(o))});var u=!!(null!=(i=o[0])&&i.success||null!=(a=o[0])&&a.fail);u&&["success","fail"].forEach(function(e){if(o[0][e])try{o[0][e]=new dt(o[0][e],{apply:function(t,r,i){return mt(function(){return n.apply(void 0,[e,o[0]].concat(m(i)))}),t.apply(r,i)}})}catch(e){_t(e)}});var c=e.apply(t,o);return!u&&c&&"[object Promise]"===Object.prototype.toString.call(c)?c.then(function(e){return mt(function(){return n("success",o[0],e)}),e}).catch(function(e){throw mt(function(){return n("fail",o[0],e)}),e}):c}})}catch(e){_t(e)}}function gt(e,t,n){try{if(!dt||null==e||!e[t])return;e[t]=new dt(e[t],{apply:function(e,t,r){var o="function"==typeof r[0];if(o)try{r[0]=new dt(r[0],{apply:function(e,t,r){var o=e.call.apply(e,[t].concat(m(r)));return mt(function(){return n(o)}),o}})}catch(e){_t(e)}var i=e.call.apply(e,[t].concat(m(r)));return o||mt(function(){return n(i)}),i}})}catch(e){_t(e)}}function yt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void 0;try{if(!dt||null==e||!e[t])return;e[t]=new dt(e[t],{apply:function(e,i,a){var u=e.call.apply(e,[i].concat(m(a)));return(!n||!vt[t])&&(mt(function(){return null==o?void 0:o(u)}),r.forEach(function(e){var t=e.eventName,n=e.isAsync,r=e.proxyEvent;n?ht(u,t,r):gt(u,t,r)})),n&&(vt[t]=!0),u}})}catch(e){_t(e)}}function mt(e){try{e()}catch(e){_t(e)}}function _t(e){ae({log_type:J,message:null==e?void 0:e.message,err_stack:null==e?void 0:e.stack})}var At=He,kt=et,St=Ye,bt=Qe,Tt=ze,wt=$e,Rt=Xe,Ot=Ze,Et=function(){var e=!1;return function(){e||(e=!0,ht(wx,"login",function(e){"success"===e&&Be.publish(At)}),gt(wx,"onAddToFavorites",function(){Be.publish(kt)}),gt(wx,"onShareTimeline",function(){Be.publish(St,{target:"TIME_LINE",trigger:"MENU"})}),gt(wx,"onShareAppMessage",function(){Be.publish(St,{target:"APP_MESSAGE",trigger:"MENU"})}),gt(wx,"shareAppMessage",function(){Be.publish(St,{target:"APP_MESSAGE",trigger:"BUTTON"})}),yt(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Be.publish(bt)}}],function(){Be.publish(Tt)}),yt(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(e){"success"===e&&Be.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(e){"success"===e&&Be.publish(wt)}}]),ht(wx,"requestMidasPayment",function(e,t){Be.publish(Ot,{status:"success"===e?"SUCCESS":"FAIL",quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",payType:"Midas"})},function(e){Be.publish(Rt,{quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",payType:"Midas"})}),ht(wx,"requestMidasPaymentGameItem",function(e,t){var n=(t||{}).signData;Be.publish(Ot,{status:"success"===e?"SUCCESS":"FAIL",quantity:(null==n?void 0:n.buyQuantity)||0,mode:(null==n?void 0:n.mode)||"",platform:(null==n?void 0:n.platform)||"",no:(null==n?void 0:n.outTradeNo)||"",p:(null==n?void 0:n.goodsPrice)||0,productId:(null==n?void 0:n.productId)||"",payType:"MidasGameItem"})},function(e){var t=(e||{}).signData;Be.publish(Rt,{quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",p:(null==t?void 0:t.goodsPrice)||0,productId:(null==t?void 0:t.productId)||"",payType:"MidasGameItem"})}))}}(),It=function(){function e(){E(this,e)}return x(e,null,[{key:"isEmpty",value:function(e){return null==e||"string"==typeof e&&""===e.trim()}},{key:"format",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.replace(/\${(\d+)}/g,function(e,t){return n[t]})}},{key:"customStringify",value:function(e){var t=[];try{return JSON.stringify(e,function(e,n){if(void 0===n)return"undefined";if("object"==O(n)&&null!==n){if(-1!==t.indexOf(n))return"[Circular]";t.push(n)}return"bigint"==typeof n?n.toString():n})}catch(e){return"[Param Error]"}}}]),e}(),xt=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,Ct=/^ams_reserved_(.*)/i,Nt=function(){function e(){E(this,e)}return x(e,null,[{key:"validateActionType",value:function(t){return It.isEmpty(t)?(Ee.error(e.ERROR_ACTION_TYPE_NULL),!1):!!xt.test(t)||(Ee.error(e.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(t){if(!t)return!0;if(!pe(t))return Ee.error(e.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(var n in t){if(It.isEmpty(n))return Ee.error(e.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!xt.test(n))return Ee.error(e.ERROR_ACTION_PARAM_KEY_INVALID),!1;Ct.test(n)&&Ee.warn(e.WARN_ACTION_PARAM_KEY_RESERVED);var r=t[n];if(!e.isValidValue(r))return Ee.error(It.format(e.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(ve(r)){if(!e.isValidArrayValue(r)){for(var o=0;o<r.length;o++)Ee.error(It.format(e.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,It.customStringify(r),o,r[o]));return!1}if(!e.checkArrayElementTypes(r))return Ee.error(e.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(e){return null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||ve(e)}},{key:"isValidArrayValue",value:function(e){for(var t=0;t<e.length;t++){var n=e[t];if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return!1}return!0}},{key:"checkArrayElementTypes",value:function(e){if(!e||e.length<=1)return!0;for(var t=O(e[0]),n=1;n<e.length;n++)if(O(e[n])!==t)return!1;return!0}}]),e}(),Pt=Nt;Pt.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",Pt.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",Pt.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",Pt.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",Pt.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",Pt.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0}, value=${1}]",Pt.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0}, value=${1}, 数组的第${2}个元素为${3}]",Pt.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",Pt.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";var Lt={exports:{}};!function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,o,i,a){return n(function(e,t){return e<<t|e>>>32-t}(n(n(t,e),n(o,a)),i),r)}function o(e,t,n,o,i,a,u){return r(t&n|~t&o,e,t,i,a,u)}function i(e,t,n,o,i,a,u){return r(t&o|n&~o,e,t,i,a,u)}function a(e,t,n,o,i,a,u){return r(t^n^o,e,t,i,a,u)}function u(e,t,n,o,i,a,u){return r(n^(t|~o),e,t,i,a,u)}function c(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var r,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r<e.length;r+=16)c=d,s=p,l=v,f=h,d=o(d,p,v,h,e[r],7,-680876936),h=o(h,d,p,v,e[r+1],12,-389564586),v=o(v,h,d,p,e[r+2],17,606105819),p=o(p,v,h,d,e[r+3],22,-1044525330),d=o(d,p,v,h,e[r+4],7,-176418897),h=o(h,d,p,v,e[r+5],12,1200080426),v=o(v,h,d,p,e[r+6],17,-1473231341),p=o(p,v,h,d,e[r+7],22,-45705983),d=o(d,p,v,h,e[r+8],7,1770035416),h=o(h,d,p,v,e[r+9],12,-1958414417),v=o(v,h,d,p,e[r+10],17,-42063),p=o(p,v,h,d,e[r+11],22,-1990404162),d=o(d,p,v,h,e[r+12],7,1804603682),h=o(h,d,p,v,e[r+13],12,-40341101),v=o(v,h,d,p,e[r+14],17,-1502002290),d=i(d,p=o(p,v,h,d,e[r+15],22,1236535329),v,h,e[r+1],5,-165796510),h=i(h,d,p,v,e[r+6],9,-1069501632),v=i(v,h,d,p,e[r+11],14,643717713),p=i(p,v,h,d,e[r],20,-373897302),d=i(d,p,v,h,e[r+5],5,-701558691),h=i(h,d,p,v,e[r+10],9,38016083),v=i(v,h,d,p,e[r+15],14,-660478335),p=i(p,v,h,d,e[r+4],20,-405537848),d=i(d,p,v,h,e[r+9],5,568446438),h=i(h,d,p,v,e[r+14],9,-1019803690),v=i(v,h,d,p,e[r+3],14,-187363961),p=i(p,v,h,d,e[r+8],20,1163531501),d=i(d,p,v,h,e[r+13],5,-1444681467),h=i(h,d,p,v,e[r+2],9,-51403784),v=i(v,h,d,p,e[r+7],14,1735328473),d=a(d,p=i(p,v,h,d,e[r+12],20,-1926607734),v,h,e[r+5],4,-378558),h=a(h,d,p,v,e[r+8],11,-2022574463),v=a(v,h,d,p,e[r+11],16,1839030562),p=a(p,v,h,d,e[r+14],23,-35309556),d=a(d,p,v,h,e[r+1],4,-1530992060),h=a(h,d,p,v,e[r+4],11,1272893353),v=a(v,h,d,p,e[r+7],16,-155497632),p=a(p,v,h,d,e[r+10],23,-1094730640),d=a(d,p,v,h,e[r+13],4,681279174),h=a(h,d,p,v,e[r],11,-358537222),v=a(v,h,d,p,e[r+3],16,-722521979),p=a(p,v,h,d,e[r+6],23,76029189),d=a(d,p,v,h,e[r+9],4,-640364487),h=a(h,d,p,v,e[r+12],11,-421815835),v=a(v,h,d,p,e[r+15],16,530742520),d=u(d,p=a(p,v,h,d,e[r+2],23,-995338651),v,h,e[r],6,-198630844),h=u(h,d,p,v,e[r+7],10,1126891415),v=u(v,h,d,p,e[r+14],15,-1416354905),p=u(p,v,h,d,e[r+5],21,-57434055),d=u(d,p,v,h,e[r+12],6,1700485571),h=u(h,d,p,v,e[r+3],10,-1894986606),v=u(v,h,d,p,e[r+10],15,-1051523),p=u(p,v,h,d,e[r+1],21,-2054922799),d=u(d,p,v,h,e[r+8],6,1873313359),h=u(h,d,p,v,e[r+15],10,-30611744),v=u(v,h,d,p,e[r+6],15,-1560198380),p=u(p,v,h,d,e[r+13],21,1309151649),d=u(d,p,v,h,e[r+4],6,-145523070),h=u(h,d,p,v,e[r+11],10,-1120210379),v=u(v,h,d,p,e[r+2],15,718787259),p=u(p,v,h,d,e[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]}function s(e){var t,n="",r=32*e.length;for(t=0;t<r;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function f(e){var t,n,r="0123456789abcdef",o="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),o+=r.charAt(t>>>4&15)+r.charAt(15&t);return o}function d(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return s(c(l(e),8*e.length))}(d(e))}function v(e,t){return function(e,t){var n,r,o=l(e),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],a[n]=1549556828^o[n];return r=c(i.concat(l(t)),512+8*t.length),s(c(a.concat(r),640))}(d(e),d(t))}function h(e,t,n){return t?n?v(t,e):function(e,t){return f(v(e,t))}(t,e):n?p(e):function(e){return f(p(e))}(e)}e.exports?e.exports=h:t.md5=h}(lt)}(Lt);var Mt=ft(Lt.exports),Dt="function"==typeof btoa,qt="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var Ut,jt="function"==typeof TextEncoder?new TextEncoder:void 0,Ft=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Ut={},Ft.forEach(function(e,t){return Ut[e]=t});var Bt=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Vt=Dt?function(e){return btoa(e)}:qt?function(e){return Buffer.from(e,"binary").toString("base64")}:function(e){for(var t,n,r,o,i="",a=e.length%3,u=0;u<e.length;){if((n=e.charCodeAt(u++))>255||(r=e.charCodeAt(u++))>255||(o=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");i+=Ft[(t=n<<16|r<<8|o)>>18&63]+Ft[t>>12&63]+Ft[t>>6&63]+Ft[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i},Kt=qt?function(e){return Buffer.from(e).toString("base64")}:function(e){for(var t=[],n=0,r=e.length;n<r;n+=4096)t.push(Bt.apply(null,e.subarray(n,n+4096)));return Vt(t.join(""))},Gt=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?Bt(192|t>>>6)+Bt(128|63&t):Bt(224|t>>>12&15)+Bt(128|t>>>6&63)+Bt(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return Bt(240|t>>>18&7)+Bt(128|t>>>12&63)+Bt(128|t>>>6&63)+Bt(128|63&t)},Wt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Jt=qt?function(e){return Buffer.from(e,"utf8").toString("base64")}:jt?function(e){return Kt(jt.encode(e))}:function(e){return Vt(function(e){return e.replace(Wt,Gt)}(e))},Ht=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Qt=function(e,t,n,r){for(var o,i=r>1?void 0:r?Yt(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ht(t,n,i),i},zt=function(){function e(t){var n=this;E(this,e),this.cgiBatchSize=B.cgiBatchSize,this.reportThreshold=B.reportThreshold,this.reportDelay=B.reportDelay,this.triggerExecuteSend=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return clearTimeout(t),t=setTimeout(function(){var t=e.apply(void 0,i);r.forEach(function(e){return e(t)}),r=[]},n),new Promise(function(e){return r.push(e)})}}(function(){n.executeSend()},1e3*this.reportDelay),this.inspectDelay=B.inspectDelay,this.inspectTimer=void 0,this.isNeedContinueSend=!1,this.getBaseInfo=t.getBaseInfo,this.reportLog=t.reportLog,this.queueManager=t.queueManager,this.configManager=t.configManager,this.onReportComplete=t.onReportComplete,this.onReportFail=t.onReportFail,this.flushSend(),this.startInspectTimer()}return x(e,[{key:"batchSend",value:function(){var e,t=this.queueManager.getReportableActions(this.reportThreshold);if(t.length>=this.reportThreshold)this.executeSend();else{var n=(null==(e=this.configManager)?void 0:e.getRealTimeActionList())||B.realTimeActionList;t.some(function(e){return n.indexOf(e.action_type)>-1&&!e.is_retry})?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var t=this;if(e.currentRequestCount>=e.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(e.requestConcurrency-e.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),o=this.getBaseInfo();if(!o.openid&&!o.unionid&&(Ee.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter(function(e){return null==e?void 0:e.ad_trace_id})),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),e.currentRequestCount+=Math.ceil(r.length/this.cgiBatchSize);for(var i=[],a=0;a<r.length;a+=this.cgiBatchSize){var u=this.generateActionReportParams(r.slice(a,a+this.cgiBatchSize));i.push(this.report(u))}Promise.all(i).then(function(e){var n=e.some(function(e){return e>=0});t.isNeedContinueSend&&n&&t.executeSend()}).catch(function(e){Ee.error(e),t.reportLog({message:"executeSend catch: ".concat(e.message),log_type:V,err_stack:e.stack})})}}}},{key:"generateActionReportParams",value:function(e){var t=[],n=[],r=this.getBaseInfo();return e.forEach(function(e){n.push(e.action_id);var r=Object.assign({},e);delete r.inner_status,t.push(r)}),{data:{info:r,actions:t},actionIdList:n}}},{key:"dealSuccessData",value:function(e,t,n){[51001,51003].indexOf(null==e?void 0:e.code)>-1?this.queueManager.updateActionsForReportFail(t):this.queueManager.removeActions(t),0!==(null==e?void 0:e.code)&&(this.reportLog({log_type:K,code:null==e?void 0:e.code,message:"trace_id: ".concat(null==e?void 0:e.trace_id,",msg: ").concat(null==e?void 0:e.message)}),Ee.error("上报失败:",e)),this.doTrackCallbackFn(this.onReportComplete,e,n),-1===[0,51001,51003].indexOf(null==e?void 0:e.code)&&this.doTrackCallbackFn(this.onReportFail,e,n)}},{key:"dealFailData",value:function(e,t,n){this.queueManager.updateActionsForReportFail(t),this.reportLog({log_type:K,code:e.code,message:e.message}),Ee.error("上报失败:",e),this.doTrackCallbackFn(this.onReportComplete,e,n)}},{key:"report",value:function(t){var n=this,r=t.data,o=t.actionIdList;return this.queueManager.updateActionsForReporting(o),Ee.debug&&(Ee.info("上报行为类型: ","【".concat(r.actions.map(function(e){return e.action_type}).join("、"),"】")),Ee.info("上报请求参数: ",r)),new Promise(function(t){var i,a,u,c,s,l,f,d,p=Date.now();try{var v=function(e){var t="",n=null==e?void 0:e.appid,r=null==e?void 0:e.secret_key,o=null==e?void 0:e.sdk_version,i=null==e?void 0:e.timestamp;if(!(n&&r&&o&&i&&32===r.length))return t;for(var a=Mt(o+n+i),u=0;u<32;u++)t+=u%2==0?r[u]:a[u];return t}({appid:null==(i=null==r?void 0:r.info)?void 0:i.appid,secret_key:null==(a=null==r?void 0:r.info)?void 0:a.secret_key,sdk_version:null==(u=null==r?void 0:r.info)?void 0:u.sdk_version,timestamp:p}),h=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(e){return e.replace(/=/g,"").replace(/[+\/]/g,function(e){return"+"==e?"-":"_"})}(Jt(e)):Jt(e)}(JSON.stringify(r));f={"Client-Time":p,"Sign-Value":Mt(h+(null==(c=null==r?void 0:r.info)?void 0:c.user_action_set_id)+(null==(s=null==r?void 0:r.info)?void 0:s.secret_key)+v),"Sign-Version":B.signVersion,"content-type":"text/plain;charset=UTF-8"},d=h}catch(v){f={"Client-Time":p},d=r,n.reportLog({log_type:Y,message:"sign error msg: ".concat(null==v?void 0:v.message),err_stack:null==v?void 0:v.stack}),Ee.error(v)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(l=n.configManager)?void 0:l.getRequestTimeout())||B.requestTimeout,header:f,data:d,success:function(i){var a,u;Ee.devLog("上报接口返回码:",null==(a=null==i?void 0:i.data)?void 0:a.code);var c=(null==(u=null==i?void 0:i.header)?void 0:u["Server-Time"])||-1;if(ue.revise(c),e.currentRequestCount-=1,200===(null==i?void 0:i.statusCode))return n.dealSuccessData(null==i?void 0:i.data,o,r),void t((null==i?void 0:i.data).code);var s="";try{s="object"==O(null==i?void 0:i.data)?JSON.stringify(null==i?void 0:i.data):null==i?void 0:i.data}catch(e){Ee.error(e)}var l={code:"number"==typeof(null==i?void 0:i.statusCode)?-1*i.statusCode:-888,message:"statusCode: ".concat(null==i?void 0:i.statusCode,", data: ").concat(s)};n.dealFailData(l,o,r),t(l.code)},fail:function(i){Ee.devLog("上报失败:",i),e.currentRequestCount-=1;var a={code:"number"==typeof(null==i?void 0:i.errno)?-1*i.errno:-999,message:null==i?void 0:i.errMsg};n.dealFailData(a,o,r),t(a.code)}})})}},{key:"startInspectTimer",value:function(){var t=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout(function(){e.currentRequestCount>=e.requestConcurrency&&(e.currentRequestCount=e.requestConcurrency-1),t.executeSend(),t.startInspectTimer()},1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(e,t,n){if("function"==typeof e)try{for(var r=[],o=0;o<n.actions.length;o++)if(!n.actions[o].is_sdk_auto_track){var i=n.actions[o],a=i.action_type,u=i.action_param,c=i.action_id,s=i.action_time;r.push({action_type:a,action_param:u,action_id:c,action_time:s})}if(r.length){var l=n.info,f=l.user_action_set_id,d=l.appid,p=l.openid,v=l.unionid,h=l.user_unique_id;e({code:null==t?void 0:t.code,message:null==t?void 0:t.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:h}}})}}catch(r){Ee.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(t){"number"==typeof t?t<1?Ee.error("网络请求最大并发量不能小于1"):t>10?Ee.error("网络请求最大并发量不能大于10"):e.requestConcurrency=t:Ee.error("网络请求最大并发量需设置为数字")}}]),e}(),$t=zt;$t.currentRequestCount=0,$t.requestConcurrency=B.requestConcurrency,Qt([xe],$t.prototype,"batchSend",1),Qt([xe],$t.prototype,"flushSend",1),Qt([xe],$t.prototype,"executeSend",1);var Zt=Ke,Xt=Ge,en=We,tn=Je,nn=He,rn=et,on=Ye,an=Qe,un=ze,cn=$e,sn=Xe,ln=Ze,fn=function(){function e(){E(this,e)}return x(e,[{key:"install",value:function(e,t){var n=function(t){Be.subscribe(t,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.track(t,Object.assign(n||{},o,y(y({},Tn,!0),wn,r)))}}(t))};n(Xt),n(Zt),n(en),n(tn),"all"===t&&(n(nn),n(rn),n(on),n(un),n(an),n("CREATE_GAME_ROOM"),n(cn),n(sn),n(ln))}}]),e}(),dn=function(){function e(){E(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return x(e,[{key:"onPurchase",value:function(e){return"number"!=typeof e&&Ee.warn("付费金额需要为数字"),e<=0&&Ee.warn("付费金额需要大于0"),this.wrapTrack("PURCHASE",{value:e})}},{key:"onEnterForeground",value:function(){return this.wrapTrack("ENTER_FOREGROUND")}},{key:"onEnterBackground",value:function(){return this.wrapTrack("ENTER_BACKGROUND")}},{key:"onAppStart",value:function(){return this.wrapTrack("START_APP")}},{key:"onAppQuit",value:function(){return this.wrapTrack("APP_QUIT")}},{key:"onAddToWishlist",value:function(){return this.wrapTrack("ADD_TO_WISHLIST")}},{key:"wrapTrack",value:function(e,t){return this.track(e,Object.assign(t||{},y({},this.special_method_symbol,1)))}}]),e}(),pn=function(){k(t,dn);var e=b(t);function t(){return E(this,t),e.apply(this,arguments)}return x(t,[{key:"onRegister",value:function(){return this.wrapTrack("REGISTER")}},{key:"onCreateRole",value:function(e){return e&&"string"!=typeof e&&Ee.warn("角色名称需要为字符串"),this.wrapTrack("CREATE_ROLE",e?{name:e}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack("TUTORIAL_FINISH")}}]),t}(),vn="(如果确认无误,请忽略该提示)",hn=function(){var e=[];return{requestActionList:function(){try{ce({conf_name:"data_nexus_common",conf_key:"action_types"}).then(function(t){ve(t)&&(e=t)})}catch(e){Ee.error(e)}},getActionList:function(){return e}}}();function gn(e,t){try{e.is_sdk_auto_track||(function(e){try{var t=hn.getActionList();if(!t.includes(e)){var n,r=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(yn(o,e)<=parseInt((.3*o.length).toString())){Ee.warn("通过SDK上报的".concat(e,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(vn));break}}}catch(e){r.e(e)}finally{r.f()}}}catch(t){Ee.error(t)}}(e.action_type),"minigame"===t?function(e,t){var n,r,o;try{["PURCHASE","ADD_TO_CART"].includes(e.action_type)&&e.action_param&&we(e.action_param,"value")&&("number"!=typeof(null==(n=e.action_param)?void 0:n.value)?Ee.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要为数字!")):(null==(r=e.action_param)?void 0:r.value)<=0?Ee.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要大于0!")):"minigame"===t&&(null==(o=e.action_param)?void 0:o.value)<100&&Ee.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(vn)))}catch(e){Ee.error(e)}}(e,t):"miniprogram"===t&&function(e){try{var t=null==e?void 0:e.action_type,n=(null==e?void 0:e.action_param)||{};"PURCHASE"===t&&we(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?Ee.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&Ee.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要大于0!")))}catch(t){Ee.error(t)}}(e))}catch(e){Ee.error(e)}}function yn(e,t){try{if(0===e.length)return t.length;if(0===t.length)return e.length;for(var n=[],r=0;r<=t.length;r++)n[r]=[r];for(var o=0;o<=e.length;o++)n[0][o]=o;for(var i=1;i<=t.length;i++)for(var a=1;a<=e.length;a++)t.charAt(i-1)===e.charAt(a-1)?n[i][a]=n[i-1][a-1]:n[i][a]=Math.min(n[i-1][a-1]+1,n[i][a-1]+1,n[i-1][a]+1);return n[t.length][e.length]}catch(n){Ee.error(n)}}function mn(e){try{e&&!/^[a-zA-Z0-9_\-]+$/.test(e)&&Ee.warn("通过SDK上报的openid:".concat(e,"可能有误,请检查openid是否正确!").concat(vn))}catch(e){Ee.error(e)}}var _n,An=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Sn=function(e,t,n,r){for(var o,i=r>1?void 0:r?kn(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&An(t,n,i),i},bn=Symbol("initializedInstance"),Tn=Symbol("autoTrack"),wn=Symbol("actionTime"),Rn=function(){k(t,pn);var e=b(t);function t(n){var r;if(E(this,t),(r=e.call(this)).env="production",r.sdk_version="1.5.5",r.sdk_name="@dn-sdk/minigame",r.deviceInfo={},r.gameInfo={},r.session_id="",r.log_id=0,r.inited=!1,r.initErrMsg="",null==wx||!wx.createCanvas)return r.initErrMsg="不支持非微信小游戏中使用",Ee.error(r.initErrMsg),T(r);var o=Te();if(t[bn].length>=o.maxSdkInstance)return r.initErrMsg="初始化超过上限",Ee.error(r.initErrMsg),T(r);var i=function(e){return pe(e)?(function(e){var t=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(var n in e)t.includes(n)||Ee.warn("Invalid property '".concat(n,"' found in config"))}(e),"number"!=typeof e.user_action_set_id?"user_action_set_id 参数需为 number 类型":e.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof e.secret_key?"secret_key 参数需为 string 类型":""===e.secret_key.trim()?"缺少 secret_key 参数":32!==e.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof e.appid?"appid 参数需为 string 类型":""!==e.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"}(n),a=oe();if(!0!==i)return r.initErrMsg=i,Ee.error(i),T(r);var u=null==a?void 0:a.appId;if(u&&u!==n.appid)return r.initErrMsg="初始化传入的appid与当前小游戏appid不一致",Ee.error(r.initErrMsg),T(r);r.config=n,we(n,"auto_track")||(r.config.auto_track=be("autoTrack")),r.openid=n.openid,r.unionid=n.unionid,r.user_unique_id=n.user_unique_id,r.onReportComplete=n.on_report_complete,r.onReportFail=n.on_report_fail,r.saveValidOpenidToStorage();var c=n.user_action_set_id;return t[bn].includes(c)?(r.initErrMsg="同个数据源[".concat(c,"]只能初始化一次"),Ee.error(r.initErrMsg),r.reportLog({log_type:V,message:r.initErrMsg}),T(r)):(r.reportLog=r.reportLog.bind(w(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(w(r)),r.deviceInfo=ee(),r.gameInfo=Ie(),r.session_id=ye(),r.queueManage=new Ue({userActionSetId:c,maxLength:o.maxQueueLength,ogEvents:Ve}),r.actionReporter=new $t({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:ot,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,t[bn].push(c),r.useAutoTrack(),r.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(Ee.info("初始化成功"),T(r)):(function(e){var t=e.sdk_version,n=e.default_download_url,r=e.fail_handler;ce({conf_name:e.conf_name,conf_key:e.conf_key}).then(function(e){if(pe(e)){var o=null==e?void 0:e.blackVersions,i=null==e?void 0:e.minVersion,a=null==e?void 0:e.bestVersion,u=null==e?void 0:e.downloadUrl,c=n;return u&&/^https/.test(u)&&(c=u),ve(o)&&(null==o?void 0:o.indexOf(t))>-1?(null==r||r(),void Ee.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):i&&Se(t,i)<0?(null==r||r(),void Ee.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Se(t,a)<0&&Ee.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void Ee.info("初始化成功"))}Ee.info("初始化成功")}).catch(function(){Ee.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}}),hn.requestActionList(),mn(n.openid),T(r)))}return x(t,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(e,t){var n,r;if(!this.inited||!this.queueManage)return Ee.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var o=Pt.validateActionType(e),i=Pt.validateActionParam(t);if(o&&i){!this.openid&&!this.unionid&&Ee.warn("缺少 openid 或 unionid");var a=be("actionParamMaxLength");if(JSON.stringify(t||{}).length>a)return Ee.error("监测到超过".concat(a,"的上报日志:").concat(e," ").concat(t)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==t||!t[Tn]),c=this.createAction(e,t||{},u);"release"!==(null==(n=oe())?void 0:n.envVersion)&&gn(c,"minigame");var s=this.queueManage.addAction(c);return null==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){var e;null==(e=this.actionReporter)||e.flushSend()}},{key:"setOpenId",value:function(e){var t;if(e&&"string"==typeof e)return this.openid=e,this.gameInfo.ad_trace_id&&!X.getSync(j)&&Be.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(t=oe())?void 0:t.envVersion)&&mn(e),{code:0,message:"成功"};var n="openid 格式错误";return Ee.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(e){if(e&&"string"==typeof e)return this.unionid=e,this.flush(),{code:0,message:"成功"};var t="unionid 格式错误";return Ee.error(t),{code:101,message:t}}},{key:"setUserUniqueId",value:function(e){if(e&&"string"==typeof e)return this.user_unique_id=e,{code:0,message:"成功"};var t="user_unique_id 格式错误";return Ee.error(t),{code:101,message:t}}},{key:"doReportOnEnterBackground",value:function(){var e=this;wx.onHide(function(){var t,n;null==(t=e.actionReporter)||t.flushSend(),null==(n=e.queueManage)||n.reportLostNum()})}},{key:"getTrackBaseInfo",value:function(){var e=oe();return Object.assign({},this.deviceInfo,function(e){var t={};return["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"].forEach(function(n){we(e,n)&&(t[n]=e[n])}),t}(this.config),{local_id:te(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||re(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:e.envVersion,app_version:e.version}})}},{key:"createAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=t&&t[Tn]&&delete t[Tn];var r=Date.now();null!=t&&t[wn]&&(r=null==t?void 0:t[wn],delete t[wn]);var o={action_id:ye(),action_param:t,action_time:r,action_type:e,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:ue.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:ne(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(e)};return null!=t&&t[this.special_method_symbol]&&(this.addActionInnerParam(o,"is_special_method",!0),delete t[this.special_method_symbol]),ot.getChannelClaimActionList().indexOf(e)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(o,"launch_options",this.gameInfo.launch_options),o}},{key:"addActionInnerParam",value:function(e,t,n){e.inner_param&&pe(e.inner_param)?e.inner_param[t]=n:e.inner_param=y({},t,n)}},{key:"getChannelByActionType",value:function(e){var t="";return ot.getChannelClaimActionList().indexOf(e)>-1?t=this.gameInfo.channel||"":ot.getNoClaimActionList().indexOf(e)>-1&&(t="UNKNOWN"),t}},{key:"reportLog",value:function(e){var t,n,r={user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};ae(Object.assign(r,e))}},{key:"useAutoTrack",value:function(){var e;if(null!=(e=this.config)&&e.auto_track){var t=!0,n=X.getSync(q);(null==n?void 0:n.ap)===z?t=!0:(null==n?void 0:n.ap)===$&&(t=!1),"devtools"===ee().wx_platform&&(t=!0),(new fn).install(this,t?"all":"lifecycle"),st(),t&&Et(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var e,t,n=ee();n.os&&n.os_version&&null!=(e=this.config)&&e.user_action_set_id&&function(e){return new Promise(function(t){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:e,timeout:B.requestTimeout,success:function(e){se(e,t,"minigame/get"),fe(e)},fail:function(e){le(e,"minigame/get")}})})}({conf_name:"MG",conf_param:{user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:Re(n.os_version),device_brand:(null==n?void 0:n.device_brand)||"",weixin_lib_version:(null==n?void 0:n.wx_lib_version)||"",weixin_version:(null==n?void 0:n.wx_version)||""}}).then(function(e){pe(e)&&X.setSync(q,e)})}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(e){return/^[a-zA-Z0-9_-]{28,30}$/.test(e)}(this.openid)&&X.setSync(j,this.openid)}}],[{key:"setRequestConcurrency",value:function(e){$t.setRequestConcurrency(e)}},{key:"setDebug",value:function(e){Ee.debug=e}}]),t}(),On=Rn;On[bn]=[],Sn([xe],On.prototype,"track",1),Sn([xe,function(e,t,n){var r=n.value;return n.value=function(){if(this.inited){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(this,t)}Ee.error("上报失败,请先完成初始化")},n}],On.prototype,"flush",1),Sn([xe],On.prototype,"setOpenId",1),Sn([xe],On.prototype,"setUnionId",1),Sn([xe],On.prototype,"setUserUniqueId",1),Sn([xe],On.prototype,"doReportOnEnterBackground",1),Sn([xe],On.prototype,"getTrackBaseInfo",1),Sn([xe],On.prototype,"useAutoTrack",1);var En=0,In={moid:""},xn=!1,Cn=JSON.stringify(wx.getLaunchOptionsSync()||""),Nn={token:"",uid:"",uname:"",openid:""},Pn={partner_id:"",game_id:"",pkg_name:"",version:""},Ln={doid:"",dsid:"",dsname:"",dext:"",drid:"",drname:"",drlevel:"",dmoney:"",money:""},Mn="wx-adapter sdk >>>>>>>:";wx.hideShareMenu(),wx.onShow(function(e){e.query&&(Cn=JSON.stringify(e))});var Dn=function(e){var t=n(n({},v()),d),r=l(n(n(n(n(n({},Ln),Nn),Pn),t),{},{launchoption:Cn,onshow:Cn}));c(u,"/wxgamemds/index/",r).then(function(t){t.state&&(t.data.balance>=e?Un(""):qn(t.data,e))}).catch(function(e){console.log(e)})},qn=function(e,t){wx.requestMidasPayment({mode:"game",env:e.env,offerId:e.offerId,currencyType:e.currencyType,platform:e.platform,buyQuantity:e.buyQuantity,outTradeNo:In.moid,success:function(e){_n&&_n.onPurchase(100*t),Un(e)},fail:function(e){console.log(e)}})},Un=function(e){var t;En++;var r=n(n({},v()),d);t=l(e?n(n(n(n(n(n({},Ln),Pn),Nn),r),In),{},{res:JSON.stringify(e),launchoption:Cn,onshow:Cn}):n(n(n(n(n(n({},Ln),Pn),Nn),In),r),{},{launchoption:Cn,onshow:Cn})),c(u,"/wxgamemds/send/",t).then(function(e){console.log(e)}).catch(function(t){console.log(t),En<3&&setTimeout(function(){Un(e)},1e3)})},jn=function(e){return new Promise(function(t,n){if(!e)return n({state:100001,msg:"激活入参缺失"});if(null==e||!e.wx)return n({state:100002,msg:"激活入参 wx 属性缺失"});var r=e.wx,o=r.game_id,i=r.version,a=r.dn_sdk_id,u=r.dn_secret_key;if(!o)return n({state:100003,msg:"激活入参 game_id 属性缺失"});Pn.game_id=o,Pn.version=i,Pn.pkg_name="wxgame",Pn.partner_id=4,xn=!0,console.log("active 激活成功!"),a&&u&&function(e){var t=e.dn_sdk_id,n=e.dn_secret_key,r=e.app_id,o=(_n=new On({appid:r,secret_key:n,user_action_set_id:t})).getInitResult();null!=o&&o.inited||console.error("dnSdk init failed: ",o.initErrMsg),_n.onAppStart(),wx.onAddToFavorites(function(e){console.log(Mn+"click onAddToFavorites"),_n&&_n.track("DD_TO_WISHLIST",{type:"default"})}),wx.onShareAppMessage(function(){console.log(Mn+"click onShareAppMessage"),_n&&_n.track("SHARE",{target:"APP_MESSAGE"})}),wx.onShareTimeline(function(){console.log(Mn+"click onShareTimeline"),_n&&_n.track("SHARE",{target:"TIME_LINE"})}),console.log(Mn+"广点通初始化成功!")}(wx),t()})},Fn=function(){return new Promise(function(e,t){if(!xn)return t({state:100003,msg:"登录前请先激活"});wx.login({success:function(r){var o=l(n(n(n({code:r.code},Pn),g()),{},{launchoption:Cn,onshow:Cn}));c(u,"/wxgamelogin/initlogin/",o).then(function(n){if(1==n.state){var r=n.data,o=r.token,i=r.uid,u=r.uname,c=r.openid,s=r.show_page;if(Nn.token=o,Nn.uid=i,Nn.uname=u,Nn.openid=c,e({token:o,uid:i,uname:u,partner_id:4,show_page:s}),console.log(Mn+"登录成功"),c&&_n){var l=n||{},f=l.backFlowDay,d=l.isRegisterUser;!function(e){var t=e.openid,n=e.nsSdk,r=e.backFlowDay,o=e.isRegisterUser;n.setOpenId(t),o?n.onRegister():r&&r>=30&&n.track("RE_ACTIVE",{backFlowDay:30})}({openid:c,nsSdk:_n,backFlowDay:f,isRegisterUser:d})}}else a(n.msg),t({state:n.state,msg:n.msg})}).catch(function(e){a(e),t({state:100001,msg:e})})},fail:function(e){t({state:100002,msg:e})}})})},Bn=function(){return new Promise(function(e,t){wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100001,msg:JSON.stringify(e)})}}):wx.getUserProfile({desc:"获取用户信息",success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100002,msg:JSON.stringify(e)})}})}})})},Vn=function(e){return new Promise(function(t,r){var o=Nn||{},i=o.token,s=o.uid,p=o.uname;if(!(xn&&i&&s&&p))return a("失败!请先激活登录"),r({state:100001,msg:"未激活或未登录,请重新进入游戏"});wx.showLoading({title:"加载中"});var y=e.dmoney;(Ln=f(e)||{}).money=y;var m=l(n(n(n(n(n({},e),Pn),Nn),n(n(n({},v()),h()),d)),{},{money:y,launchoption:Cn,onshow:Cn}));c(u,"/wxgameorder/index/",m).then(function(e){var n=e||{},o=n.state,i=n.msg,s=n.data,f=void 0===s?{}:s;if(1==o){var d=f.aid,p=f.moid,v=f.thumb_url;In.moid=p,1==d?(Dn(y),t({msg:"ok"})):2==d?wx.showModal({title:"支付提示",content:"即将打开充值入口,输入“充值”或点击右下角卡片即可充值。",showCancel:!1,confirmText:"点我充值",success:function(e){e.confirm?wx.openCustomerServiceConversation({sessionFrom:p,sendMessagePath:"/path/index/index?moid="+p,showMessageCard:!0,sendMessageImg:v,success:function(e){console.log("openCustomerServiceConversation success",e),t()},fail:function(e){console.error("openCustomerServiceConversation fail ",e),r({state:100003,msg:"支付失败"})},complete:function(e){console.log("openCustomerServiceConversation compelte: ",p),function(e){var t=g(),n=l({partner_id:Pn.partner_id,pkg_name:Pn.pkg_name,game_id:Pn.game_id,uid:Nn.uid,openid:Nn.openid,token:Nn.token,uname:Nn.uname,duid:t.duid,moid:e});c(u,"/wxgameorder/get/",n).then(function(e){1==e.data.status&&_n.onPurchase(100*e.data.money)})}(p)}}):(a("用户取消支付"),r({state:100005,msg:"取消支付"}))},fail:function(){a("用户取消支付"),r({state:100006,msg:"支付失败"})}}):(a("失败!设备未识别"),r({state:100004,msg:"支付失败"}))}else a(i),r({state:o,msg:i});wx.hideLoading()}).catch(function(e){a(e),r({state:100002,msg:"支付失败"}),wx.hideLoading()})})},Kn=function(e){return new Promise(function(t,r){var o=Nn||{},i=o.token,s=o.uid,f=o.uname;if(!(xn&&i&&s&&f))return a("未激活或未登录,请重新进入游戏"),r({state:100001,msg:"未激活或未登录,请检查"});var p=l(n(n(n(n(n({},e),Nn),Pn),n(n({},v()),d)),{},{launchoption:Cn,onshow:Cn}));c(u,"/wxgameevent/index/",p).then(function(){t(),_n&&("create"===p.event&&_n.onCreateRole(p.drname),"levelup"===p.event&&_n.track("UPDATE_LEVEL",{level:p.drlevel,power:0}))}).catch(function(e){console.log(e),r({state:100002,msg:"角色上报失败"})})})},Gn=function(e){wx.shareAppMessage(),Kn(n(n({},f(e)),{},{event:"fxclick"}))},Wn=function(e){wx.openCustomerServiceConversation({success:function(){Kn(n(n({},f(e)),{},{event:"kfclick"}))}})},Jn=function(e){return new Promise(function(t,r){var o=l(n(n(n(n(n({},e),Pn),Nn),g()),{},{launchoption:Cn,onshow:Cn,partner_id:4}));c(u,"/wxgamesafe/verify/",o).then(function(e){var n=e.data,o=n.code,i=n.msg;1==o?t():r({state:100001,msg:i})}).catch(function(e){r({state:100002,msg:e})})})},Hn=function(e){return new Promise(function(t,n){_n?(_n.track("VIEW_CONTENT",{item:e}),t()):n({state:100001,msg:"上报失败!广点通 sdk 未初始化"})})},Yn=function(e){return new Promise(function(t,n){var r=!1,o=wx.createInterstitialAd({adUnitId:e});o.onError(function(e){r=!0}),o.load().then(function(){if(!r)return o.show();n({state:100001,msg:"广告加载后发生错误"})}).then(t).catch(function(e){return n({state:100002,msg:JSON.stringify(e)})}),o.onClose(function(e){console.log("广告关闭:",e.isEnded?"正常播放完成":"用户提前关闭")})})},Qn=function(e){var t=null,n=!1,r=!1,o=function(){return n||r?Promise.resolve():(n=!0,new Promise(function(o,i){(t=wx.createRewardedVideoAd({adUnitId:e})).onError(function(e){n=!1,r=!1,t=null,i({state:100004,msg:"广告平台异常",originalErr:e})}),t.load().then(function(){r=!0,n=!1,o()}).catch(function(e){console.log(399),n=!1,r=!1,t=null,i(e)})}))},i=function(){return r?new Promise(function(e,n){t?(t.onClose(function(e){console.log("广告关闭:",e.isEnded?"正常播放完成":"用户提前关闭")}),t.show().then(function(){console.log("激励视频广告展示成功"),e()}).catch(function(e){r=!1,n({state:100003,msg:JSON.stringify(e)})})):n({state:100002,msg:"广告实例不存在"})}):o().then(i).catch(function(e){return Promise.reject({state:100001,msg:JSON.stringify(e)})})};return{preload:o,show:i}};export{jn as jf_active,Qn as jf_createRewardedVideoAd,Wn as jf_customerService,Bn as jf_getUserInfo,Fn as jf_login,Vn as jf_pay,Jn as jf_profanityCheck,Gn as jf_share,Yn as jf_showInterstitialAd,Kn as jf_trace,Hn as jf_tracePageView};
|
|
7
|
+
function y(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){if(e){if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(e,t):void 0}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=R(e);if(t){var o=R(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return T(this,n)}}function T(e,t){if(t&&("object"===E(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function O(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,C(r.key),r)}}function x(e,t,n){return t&&I(e.prototype,t),n&&I(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function C(e){var t=function(e){if("object"!==E(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==E(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===E(t)?t:String(t)}var N,P,L="LOCAL_ID",M="CLICK_ID",D="QUEUE_LOST_MAP",q="REMOTE_CONFIG",j="REMOTE_COMMON_CONFIG",U="OPENID",F={init:"init",reporting:"reporting",fail:"fail"},B={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"]},V="JS_RUN_ERROR",K="REQUEST_ERROR",G="REQUEST_CONFIG_ERROR",W="JS_QUEUE_LOG",J="PROXY_ERROR",H="QUEUE_LOST_NUM",Y="SIGN_ERROR",Q="UNKNOWN",z="TRUE",$="FALSE",Z="TICKET_INTERVAL_CHANGE",X=(P=function(e){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(e)},{getSync:function(e){var t;try{t=wx.getStorageSync(P(e))}catch(e){return console.error("storage get error",e),t}return t},setSync:function(e,t){try{wx.setStorageSync(P(e),t)}catch(e){return console.error("storage set error",e),!1}return!0}}),ee=function(){var e;return function(){if(!e){var t=function(){if(N)return N;try{return N=wx.getSystemInfoSync()}catch(e){return{}}}(),n=t.system,r=void 0===n?"":n,o=(null==r?void 0:r.split(" "))||[],i=function(e){if(!e)return Q;var t=(null==e?void 0:e.toUpperCase())||"";return t.indexOf("ANDROID")>-1?"ANDROID":t.indexOf("IOS")>-1?"IOS":t.indexOf("MAC")>-1?"OSX":t.indexOf("WINDOWS")>-1?"WINDOWS":Q}(o[0]),a=function(e){return!e||e.length<=0?"":2===e.length?e[1]:3===e.length&&"Windows"===e[0]?"".concat(e[1]," ").concat(e[2]):e[e.length-1]}(o);e={benchmark_level:t.benchmarkLevel,device_brand:t.brand,screen_height:Math.floor(t.screenHeight),screen_width:Math.floor(t.screenWidth),wx_lib_version:t.SDKVersion,wx_version:t.version,wx_platform:t.platform,device_model:t.model,os:i,os_version:a}}return e}}(),te=function(){var e;return function(){try{if(e)return e;e||(e=X.getSync(L)||""),e||(e=ye(),X.setSync(L,e))}catch(e){}return e}}(),ne=function(){var e="unknown",t=!1;return function(){if(!t)try{wx.getNetworkType({success:function(t){e=t.networkType},fail:function(){e="unknown"}}),wx.onNetworkStatusChange(function(t){e=t.networkType}),t=!0}catch(e){}return e}}();ne();var re=function(){var e="";return function(){return e||(e=X.getSync(U)||""),e}}(),oe=function(){var e;return function(){if(e)return e;try{var t=wx.getAccountInfoSync();return pe(t.miniProgram)?e=t.miniProgram:{}}catch(t){return{}}}}();function ie(e){var t=null==e?void 0:e.query;if(!pe(t))return"";var n="";return t.gdt_vid||[1045,1046,1084].indexOf(null==e?void 0:e.scene)>-1?n="TENCENT":t.clue_token||t.clickid&&t.item_id?n="BYTEDANCE":t.callback&&"kuaishou"===t.ksChannel?n="KUAISHOU":t.bd_vid||t.ai&&t.d&&t.q&&t.c?n="BAIDU":t.uctrackid?n="ALIBABA":(t.trackid||t.imp||[1065,1069,1194].indexOf(null==e?void 0:e.scene)>-1&&(t.callback||t.u))&&(n="OTHERS"),n}function ae(e,t){try{var n=ee(),r=oe(),o={sdk_version:"1.5.5",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void 0:n.device_brand,device_model:null==n?void 0:n.device_model,wx_version:null==n?void 0:n.wx_version,wx_lib_version:null==n?void 0:n.wx_lib_version,wx_platform:null==n?void 0:n.wx_platform,os:null==n?void 0:n.os,os_version:null==n?void 0:n.os_version,local_id:te(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},i=Object.assign(o,e);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:i,method:"POST",timeout:B.requestTimeout,success:function(e){"function"==typeof t&&200===(null==e?void 0:e.statusCode)&&t()}})}catch(n){Oe.error(n)}}var ue=function(){function e(){O(this,e)}return x(e,null,[{key:"revise",value:function(e){e>0&&!this.isRevised&&(this.offsetTime=e-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),e}();function ce(e){return new Promise(function(t,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:e,timeout:B.requestTimeout,success:function(e){se(e,t,"config/get",n),fe(e)},fail:function(e){le(e,"config/get",n)}})})}function se(e,t,n,r){var o,i,a,u,c=null==e?void 0:e.statusCode,s=null==(o=null==e?void 0:e.data)?void 0:o.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),ae({log_type:G,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==e?void 0:e.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==e?void 0:e.data)?void 0:u.data)}else t(null==(i=e.data)?void 0:i.data)}function le(e,t,n){ae({log_type:G,message:"cgiName: ".concat(t," , message: ").concat(null==e?void 0:e.errMsg," "),code:"number"==typeof(null==e?void 0:e.errno)?-1*e.errno:-999}),null==n||n(e)}function fe(e){var t,n=1*(null==(t=null==e?void 0:e.header)?void 0:t["Server-Time"]);n>17266752e5&&ue.revise(n)}ue.offsetTime=0,ue.isRevised=!1;var de=Object.prototype.toString,pe=function(e){return"[object Object]"===de.call(e)},ve=function(e){return"[object Array]"===de.call(e)},he=function(e){return"[object Function]"===de.call(e)},ge=(new Date).getTime();function ye(){var e=(new Date).getTime(),t=Math.abs(1e3*(e-ge));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")})}var me=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,_e=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");if(!me.test(e))throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"))},Ae=function(e){return isNaN(Number(e))?e:Number(e)},ke=function(e){var t=e.replace(/^v/,"").replace(/\+.*$/,""),n=function(e){return-1===e.indexOf("-")?e.length:e.indexOf("-")}(t),r=t.substring(0,n).split(".");return r.push(t.substring(n+1)),r},Se=function(e,t){[e,t].forEach(_e);for(var n=ke(e),r=ke(t),o=0;o<Math.max(n.length-1,r.length-1);o++){var i=parseInt(n[o]||"0",10),a=parseInt(r[o]||"0",10);if(i>a)return 1;if(a>i)return-1}var u=n[n.length-1],c=r[r.length-1];if(u&&c)for(var s=u.split(".").map(Ae),l=c.split(".").map(Ae),f=0;f<Math.max(s.length,l.length);f++){if(void 0===s[f]||"string"==typeof l[f]&&"number"==typeof s[f])return-1;if(void 0===l[f]||"string"==typeof s[f]&&"number"==typeof l[f]||s[f]>l[f])return 1;if(l[f]>s[f])return-1}else if(u||c)return u?-1:1;return 0};function be(e){return Te()[e]}function Te(){return B}function we(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Re=function(e){try{return e&&"string"==typeof e?-1===(e=e.replace(/\s/g,"")).indexOf(".")?e:e.split(".").slice(0,2).join("."):""}catch(t){return e}},Ee=function(){function e(){O(this,e)}return x(e,null,[{key:"error",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).error.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"info",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"log",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"warn",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).warn.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"devLog",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}}]),e}(),Oe=Ee;Oe.debug=!1,Oe.isDev=!1;var Ie=function(){var e;return function(){if(!e)try{var t=wx.getLaunchOptionsSync(),n=t.query.gdt_vid||"";n?X.setSync(M,n):n=X.getSync(M)||"";var r=JSON.stringify(t);r.length>1e4&&(r=JSON.stringify({cut:1,scene:t.scene})),e={source_scene:t.scene,pkg_channel_id:t.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ie(t)}}catch(t){e={},Oe.log("获取场景值和渠道号失败",t)}return e}}();function xe(e,t,n){var r=n.value;return n.value=function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];try{return r.apply(this,o)}catch(n){try{Oe.error.apply(Oe,["calling ".concat(e.constructor.name,".").concat(t," error with arguments")].concat(o)),Oe.error(n);var a={log_type:V,message:"[safeExcutable] ".concat(e.constructor.name,".").concat(t,": ").concat(null==n?void 0:n.message),err_stack:null==n?void 0:n.stack};he(this.reportLog)?this.reportLog(a):ae(a)}catch(a){}}},n}var Ce=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Pe=function(e,t,n,r){for(var o,i=r>1?void 0:r?Ne(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ce(t,n,i),i},Le=function(){function e(t){var n=t.userActionSetId,r=t.maxLength,o=void 0===r?500:r;O(this,e),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat("QUEUE_ACTIONS","_").concat(null==n?void 0:n.toString()),this.maxLength=o,this.userActionSetId=n,this.setTimeStamp(),this.init()}return x(e,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var e,t=(null==(e=X)?void 0:e.getSync(this.localStorageKey))||"[]";return JSON.parse(t)}},{key:"reportLostNum",value:function(){var e=this,t=Object.assign({},this.lostActionMaps),n=[];for(var r in t){var o=null==r?void 0:r.split("_");n.push({queue_lost_session_id:o[0],queue_lost_timestamp:o[1],queue_lost_num:t[r]})}n.length&&(this.setTimeStamp(),n.forEach(function(t){var n=Object.assign({},{user_action_set_id:e.userActionSetId,log_type:H},t),r=null==t?void 0:t.queue_lost_session_id,o=null==t?void 0:t.queue_lost_timestamp,i="".concat(r,"_").concat(o);ae(n,function(){we(e.lostActionMaps,i)&&(delete e.lostActionMaps[i],X.setSync(D,JSON.stringify(e.lostActionMaps)))})}))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var e=this,t=this.getStorage(),n=null==t?void 0:t.map(function(e){var t,n;return e.inner_status===(null==(t=F)?void 0:t.reporting)?Object.assign({},e,{inner_status:null==(n=F)?void 0:n.fail,is_retry:!0,retry_count:e.retry_count+1}):e});this.stack=n,this.lostActionMaps=JSON.parse(X.getSync(D)||"{}"),setTimeout(function(){e.reportLostNum()},1e3)}},{key:"addItem",value:function(e){var t;null==(t=null==this?void 0:this.stack)||t.push(e)}},{key:"removeItems",value:function(e){var t,n=null==(t=null==this?void 0:this.stack)?void 0:t.filter(function(t){return!(null!=e&&e.includes(null==t?void 0:t.action_id))});this.stack=n}},{key:"updateForReportFail",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=F)?void 0:n.fail,retry_count:t.retry_count+1,is_retry:!0}):t})}},{key:"updateForReporting",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=F)?void 0:n.reporting}):t})}},{key:"updateAllStack",value:function(e){this.stack=e}},{key:"updateToStorage",value:function(){X.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(e){if(e){var t="".concat(e,"_").concat(this.timeStamp),n=this.lostActionMaps[t]||0;this.lostActionMaps[t]=n+1,X.setSync(D,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),e}();Pe([xe],Le.prototype,"getItems",1),Pe([xe],Le.prototype,"getStorage",1),Pe([xe],Le.prototype,"reportLostNum",1),Pe([xe],Le.prototype,"getLostMaps",1),Pe([xe],Le.prototype,"init",1),Pe([xe],Le.prototype,"addItem",1),Pe([xe],Le.prototype,"removeItems",1),Pe([xe],Le.prototype,"updateForReportFail",1),Pe([xe],Le.prototype,"updateForReporting",1),Pe([xe],Le.prototype,"updateAllStack",1),Pe([xe],Le.prototype,"updateToStorage",1),Pe([xe],Le.prototype,"updateLostAction",1);var Me=Object.defineProperty,De=Object.getOwnPropertyDescriptor,qe=function(e,t,n,r){for(var o,i=r>1?void 0:r?De(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Me(t,n,i),i},je=function(){k(t,Le);var e=b(t);function t(n){var r,o=n.userActionSetId,i=n.maxLength,a=void 0===i?500:i,u=n.ogEvents,c=void 0===u?[]:u;return O(this,t),(r=e.call(this,{userActionSetId:o,maxLength:a})).ogEvents=c,r}return x(t,[{key:"getReportableActions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,t=this.getItems(),n=[];return null==t||t.forEach(function(t){var r;(null==n?void 0:n.length)<e&&(null==t?void 0:t.inner_status)!==(null==(r=F)?void 0:r.reporting)&&(null==n||n.push(t))}),n}},{key:"addAction",value:function(e){var t={code:0,message:"成功",actionId:e.action_id},n=this.getItems();if((null==n?void 0:n.length)>=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");Oe.warn(r),ae({user_action_set_id:this.userActionSetId,log_type:W,message:"队列长度超过限制"});var o=this.sortQueue(e,n);Oe.debug&&Oe.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),o.concat([]));var i=o.pop();this.updateAllStack(o),this.updateLostAction((null==i?void 0:i.session_id)||""),(null==i?void 0:i.action_id)===e.action_id&&(t={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(e);return this.updateToStorage(),t}},{key:"removeActions",value:function(e){this.removeItems(e),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(e){this.updateForReportFail(e),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(e){this.updateForReporting(e),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var e=this.getItems().filter(function(e){var t;return(null==e?void 0:e.inner_status)!==(null==(t=F)?void 0:t.reporting)});return null==e?void 0:e.length}},{key:"sortQueue",value:function(e,t){var n=this,r={},o=null==e?void 0:e.action_time,i=t.concat([e]),a=function(e){return r[e.action_id]||(r[e.action_id]=n.caculateWeight(o,e)),r[e.action_id]};return i.sort(function(e,t){return a(t)-a(e)})}},{key:"caculateWeight",value:function(e,t){var n,r=0,o=this.formatWeight(e,null==t?void 0:t.action_time),i=o.ogWeight,a=o.sdkWeight,u=o.userWeight;null!=(n=this.ogEvents)&&n.includes(null==t?void 0:t.action_type)&&(r+=i),null!=t&&t.is_sdk_auto_track?r+=a:r+=u;var c=e-(null==t?void 0:t.action_time)+1;return c>0?r+1/c:r}},{key:"formatWeight",value:function(e,t){var n=1e3,r=10,o=100;return e-t>2592e6&&(n/=100,r/=100,o/=100),{ogWeight:n,sdkWeight:r,userWeight:o}}}]),t}();qe([xe],je.prototype,"getReportableActions",1),qe([xe],je.prototype,"addAction",1),qe([xe],je.prototype,"removeActions",1),qe([xe],je.prototype,"updateActionsForReportFail",1),qe([xe],je.prototype,"updateActionsForReporting",1),qe([xe],je.prototype,"getReportableActionsLength",1),qe([xe],je.prototype,"sortQueue",1),qe([xe],je.prototype,"caculateWeight",1),qe([xe],je.prototype,"formatWeight",1);var Ue=function(){function e(){O(this,e),this.events={}}return x(e,[{key:"subscribe",value:function(t,n){e.checkCallback(n),ve(this.events[t])?this.events[t].push(n):this.events[t]=[n]}},{key:"once",value:function(t,n){e.checkCallback(n),this.subscribe(this.onceEventName(t),n)}},{key:"unsubscribe",value:function(t,n){e.checkCallback(n),ve(this.events[t])&&(this.events[t]=this.events[t].filter(function(e){return e!==n})),ve(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)]=this.events[this.onceEventName(t)].filter(function(e){return e!==n}))}},{key:"publish",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=Date.now();ve(this.events[e])&&this.events[e].forEach(function(e){return e.apply(void 0,[o].concat(n))}),ve(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)].forEach(function(e){return e.apply(void 0,[o].concat(n))}),this.events[this.onceEventName(e)]=[])}},{key:"onceEventName",value:function(e){return"once_event_prefix_".concat(e)}}],[{key:"checkCallback",value:function(t){he(t)||Oe.error(e.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),e}(),Fe=Ue;Fe.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";var Be=new Fe,Ve=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],Ke="START_APP",Ge="TICKET",We="ENTER_FOREGROUND",Je="ENTER_BACKGROUND",He="LOGIN",Ye="SHARE",Qe="TAP_GAME_CLUB",ze="CREATE_GAME_CLUB",$e="JOIN_GAME_ROOM",Ze="FINISH_PAY",Xe="START_PAY",et="ADD_TO_WISHLIST",tt=["REGISTER","START_APP","RE_ACTIVE"],nt=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],rt=function(){function e(){O(this,e),this.channelClaimActionList=tt,this.noClaimActionList=nt,this.realTimeActionList=B.realTimeActionList,this.ticketInterval=60,this.requestTimeout=B.requestTimeout,this.loadConfig()}return x(e,[{key:"getChannelClaimActionList",value:function(){return this.channelClaimActionList}},{key:"getNoClaimActionList",value:function(){return this.noClaimActionList}},{key:"getRealTimeActionList",value:function(){return this.realTimeActionList}},{key:"getTicketInterval",value:function(){return this.ticketInterval}},{key:"getRequestTimeout",value:function(){return this.requestTimeout}},{key:"loadConfig",value:function(){var e=this;try{if("undefined"==typeof wx)return;var t=X.getSync(j);t&&this.updateConfig(t),ce({conf_name:"mini_game_sdk_common",conf_key:"config"}).then(function(t){t&&pe(t)&&(e.updateConfig(t),X.setSync(j,t))})}catch(t){console.error(t)}}},{key:"updateConfig",value:function(e){e.channelClaimActionList&&ve(e.channelClaimActionList)&&(this.channelClaimActionList=e.channelClaimActionList),e.noClaimActionList&&ve(e.noClaimActionList)&&(this.noClaimActionList=e.noClaimActionList),e.realTimeActionList&&ve(e.realTimeActionList)&&(this.realTimeActionList=e.realTimeActionList),e.ticketInterval&&"number"==typeof e.ticketInterval&&e.ticketInterval>1&&e.ticketInterval!==this.ticketInterval&&(this.ticketInterval=e.ticketInterval,Be.publish(Z)),e.requestTimeout&&"number"==typeof e.requestTimeout&&e.requestTimeout>5e3&&(this.requestTimeout=e.requestTimeout)}}]),e}(),ot=new rt,it=Ke,at=Ge,ut=We,ct=Je,st=function(){var e=!1,t=!1,n=!0,r=!0,o=!0,i=!1;return function(){if(!i){i=!0;var a=X.getSync(q);if((null==a?void 0:a.bg)===z?e=!0:(null==a?void 0:a.bg)===$&&(e=!1),(null==a?void 0:a.fg)===z?t=!0:(null==a?void 0:a.fg)===$&&(t=!1),(null==a?void 0:a.st)===z?n=!0:(null==a?void 0:a.st)===$&&(n=!1),(null==a?void 0:a.ti)===z?r=!0:(null==a?void 0:a.ti)===$&&(r=!1),Oe.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",e,t,n,r),n&&Be.publish(it),r){var u=function(){o&&Be.publish(at)},c=setInterval(u,1e3*ot.getTicketInterval());Be.subscribe(Z,function(){c&&clearInterval(c),c=setInterval(u,1e3*ot.getTicketInterval())})}wx.onShow(function(e){if(o=!0,t){var n="";try{(n=JSON.stringify(e)).length>1e4&&(n=JSON.stringify({cut:1,scene:e.scene}))}catch(e){}Be.publish(ut,{enter_options:n})}}),wx.onHide(function(){o=!1,e&&Be.publish(ct)})}}}(),lt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ft(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dt,pt=ft(function(){var e,t=null;function n(e){return!!e&&("object"==E(e)||"function"==typeof e)}function r(e){if(null!==e&&!n(e))throw new TypeError("Object prototype may only be an Object or null: "+e)}var o=Object,i=!(!o.create&&{__proto__:null}instanceof o),a=o.create||(i?function(e){return r(e),{__proto__:e}}:function(e){if(r(e),null===e)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var t=function(){};return t.prototype=e,new t}),u=function(){return null},c=o.getPrototypeOf||([].__proto__===Array.prototype?function(e){var t=e.__proto__;return n(t)?t:null}:u);return e=function(s,l){if(void 0===(this&&this instanceof e?this.constructor:void 0))throw new TypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))throw new TypeError("Cannot create proxy with a non-object as target or handler");var f=function(){};t=function(){s=null,f=function(e){throw new TypeError("Cannot perform '".concat(e,"' on a proxy that has been revoked"))}},setTimeout(function(){t=null},0);var d=l;for(var p in l={get:null,set:null,apply:null,construct:null},d){if(!(p in l))throw new TypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=d[p]}"function"==typeof d&&(l.apply=d.apply.bind(d));var v,h=c(s),g=!1,y=!1;"function"==typeof s?(v=function(){var e=this&&this.constructor===v,t=Array.prototype.slice.call(arguments);return f(e?"construct":"apply"),e&&l.construct?l.construct.call(this,s,t):!e&&l.apply?l.apply(s,this,t):e?(t.unshift(s),new(s.bind.apply(s,t))):s.apply(this,t)},g=!0):s instanceof Array?(v=[],y=!0):v=i||null!==h?a(h):{};var m=l.get?function(e){return f("get"),l.get(this,e,v)}:function(e){return f("get"),this[e]},_=l.set?function(e,t){f("set"),l.set(this,e,t,v)}:function(e,t){f("set"),this[e]=t},A=o.getOwnPropertyNames(s),k={};A.forEach(function(e){if(!g&&!y||!(e in v)){var t={enumerable:!!o.getOwnPropertyDescriptor(s,e).enumerable,get:m.bind(s,e),set:_.bind(s,e)};o.defineProperty(v,e,t),k[e]=!0}});var S=!0;if(g||y){var b=o.setPrototypeOf||([].__proto__===Array.prototype?function(e,t){return r(t),e.__proto__=t,e}:u);h&&b(v,h)||(S=!1)}if(l.get||!S)for(var T in s)k[T]||o.defineProperty(v,T,{get:m.bind(s,T)});return o.seal(s),o.seal(v),v},e.revocable=function(n,r){return{proxy:new e(n,r),revoke:t}},e}),vt={};try{dt||(dt=pt())}catch(N){_t(N)}function ht(e,t,n,r){try{if(!dt||null==e||!e[t])return;e[t]=new dt(e[t],{apply:function(e,t,o){var i,a;r&&mt(function(){return r.apply(void 0,m(o))});var u=!!(null!=(i=o[0])&&i.success||null!=(a=o[0])&&a.fail);u&&["success","fail"].forEach(function(e){if(o[0][e])try{o[0][e]=new dt(o[0][e],{apply:function(t,r,i){return mt(function(){return n.apply(void 0,[e,o[0]].concat(m(i)))}),t.apply(r,i)}})}catch(e){_t(e)}});var c=e.apply(t,o);return!u&&c&&"[object Promise]"===Object.prototype.toString.call(c)?c.then(function(e){return mt(function(){return n("success",o[0],e)}),e}).catch(function(e){throw mt(function(){return n("fail",o[0],e)}),e}):c}})}catch(e){_t(e)}}function gt(e,t,n){try{if(!dt||null==e||!e[t])return;e[t]=new dt(e[t],{apply:function(e,t,r){var o="function"==typeof r[0];if(o)try{r[0]=new dt(r[0],{apply:function(e,t,r){var o=e.call.apply(e,[t].concat(m(r)));return mt(function(){return n(o)}),o}})}catch(e){_t(e)}var i=e.call.apply(e,[t].concat(m(r)));return o||mt(function(){return n(i)}),i}})}catch(e){_t(e)}}function yt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void 0;try{if(!dt||null==e||!e[t])return;e[t]=new dt(e[t],{apply:function(e,i,a){var u=e.call.apply(e,[i].concat(m(a)));return(!n||!vt[t])&&(mt(function(){return null==o?void 0:o(u)}),r.forEach(function(e){var t=e.eventName,n=e.isAsync,r=e.proxyEvent;n?ht(u,t,r):gt(u,t,r)})),n&&(vt[t]=!0),u}})}catch(e){_t(e)}}function mt(e){try{e()}catch(e){_t(e)}}function _t(e){ae({log_type:J,message:null==e?void 0:e.message,err_stack:null==e?void 0:e.stack})}var At=He,kt=et,St=Ye,bt=Qe,Tt=ze,wt=$e,Rt=Xe,Et=Ze,Ot=function(){var e=!1;return function(){e||(e=!0,ht(wx,"login",function(e){"success"===e&&Be.publish(At)}),gt(wx,"onAddToFavorites",function(){Be.publish(kt)}),gt(wx,"onShareTimeline",function(){Be.publish(St,{target:"TIME_LINE",trigger:"MENU"})}),gt(wx,"onShareAppMessage",function(){Be.publish(St,{target:"APP_MESSAGE",trigger:"MENU"})}),gt(wx,"shareAppMessage",function(){Be.publish(St,{target:"APP_MESSAGE",trigger:"BUTTON"})}),yt(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Be.publish(bt)}}],function(){Be.publish(Tt)}),yt(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(e){"success"===e&&Be.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(e){"success"===e&&Be.publish(wt)}}]),ht(wx,"requestMidasPayment",function(e,t){Be.publish(Et,{status:"success"===e?"SUCCESS":"FAIL",quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",payType:"Midas"})},function(e){Be.publish(Rt,{quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",payType:"Midas"})}),ht(wx,"requestMidasPaymentGameItem",function(e,t){var n=(t||{}).signData;Be.publish(Et,{status:"success"===e?"SUCCESS":"FAIL",quantity:(null==n?void 0:n.buyQuantity)||0,mode:(null==n?void 0:n.mode)||"",platform:(null==n?void 0:n.platform)||"",no:(null==n?void 0:n.outTradeNo)||"",p:(null==n?void 0:n.goodsPrice)||0,productId:(null==n?void 0:n.productId)||"",payType:"MidasGameItem"})},function(e){var t=(e||{}).signData;Be.publish(Rt,{quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",p:(null==t?void 0:t.goodsPrice)||0,productId:(null==t?void 0:t.productId)||"",payType:"MidasGameItem"})}))}}(),It=function(){function e(){O(this,e)}return x(e,null,[{key:"isEmpty",value:function(e){return null==e||"string"==typeof e&&""===e.trim()}},{key:"format",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.replace(/\${(\d+)}/g,function(e,t){return n[t]})}},{key:"customStringify",value:function(e){var t=[];try{return JSON.stringify(e,function(e,n){if(void 0===n)return"undefined";if("object"==E(n)&&null!==n){if(-1!==t.indexOf(n))return"[Circular]";t.push(n)}return"bigint"==typeof n?n.toString():n})}catch(e){return"[Param Error]"}}}]),e}(),xt=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,Ct=/^ams_reserved_(.*)/i,Nt=function(){function e(){O(this,e)}return x(e,null,[{key:"validateActionType",value:function(t){return It.isEmpty(t)?(Oe.error(e.ERROR_ACTION_TYPE_NULL),!1):!!xt.test(t)||(Oe.error(e.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(t){if(!t)return!0;if(!pe(t))return Oe.error(e.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(var n in t){if(It.isEmpty(n))return Oe.error(e.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!xt.test(n))return Oe.error(e.ERROR_ACTION_PARAM_KEY_INVALID),!1;Ct.test(n)&&Oe.warn(e.WARN_ACTION_PARAM_KEY_RESERVED);var r=t[n];if(!e.isValidValue(r))return Oe.error(It.format(e.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(ve(r)){if(!e.isValidArrayValue(r)){for(var o=0;o<r.length;o++)Oe.error(It.format(e.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,It.customStringify(r),o,r[o]));return!1}if(!e.checkArrayElementTypes(r))return Oe.error(e.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(e){return null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||ve(e)}},{key:"isValidArrayValue",value:function(e){for(var t=0;t<e.length;t++){var n=e[t];if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return!1}return!0}},{key:"checkArrayElementTypes",value:function(e){if(!e||e.length<=1)return!0;for(var t=E(e[0]),n=1;n<e.length;n++)if(E(e[n])!==t)return!1;return!0}}]),e}(),Pt=Nt;Pt.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",Pt.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",Pt.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",Pt.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",Pt.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",Pt.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0}, value=${1}]",Pt.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0}, value=${1}, 数组的第${2}个元素为${3}]",Pt.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",Pt.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";var Lt={exports:{}};!function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,o,i,a){return n(function(e,t){return e<<t|e>>>32-t}(n(n(t,e),n(o,a)),i),r)}function o(e,t,n,o,i,a,u){return r(t&n|~t&o,e,t,i,a,u)}function i(e,t,n,o,i,a,u){return r(t&o|n&~o,e,t,i,a,u)}function a(e,t,n,o,i,a,u){return r(t^n^o,e,t,i,a,u)}function u(e,t,n,o,i,a,u){return r(n^(t|~o),e,t,i,a,u)}function c(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var r,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r<e.length;r+=16)c=d,s=p,l=v,f=h,d=o(d,p,v,h,e[r],7,-680876936),h=o(h,d,p,v,e[r+1],12,-389564586),v=o(v,h,d,p,e[r+2],17,606105819),p=o(p,v,h,d,e[r+3],22,-1044525330),d=o(d,p,v,h,e[r+4],7,-176418897),h=o(h,d,p,v,e[r+5],12,1200080426),v=o(v,h,d,p,e[r+6],17,-1473231341),p=o(p,v,h,d,e[r+7],22,-45705983),d=o(d,p,v,h,e[r+8],7,1770035416),h=o(h,d,p,v,e[r+9],12,-1958414417),v=o(v,h,d,p,e[r+10],17,-42063),p=o(p,v,h,d,e[r+11],22,-1990404162),d=o(d,p,v,h,e[r+12],7,1804603682),h=o(h,d,p,v,e[r+13],12,-40341101),v=o(v,h,d,p,e[r+14],17,-1502002290),d=i(d,p=o(p,v,h,d,e[r+15],22,1236535329),v,h,e[r+1],5,-165796510),h=i(h,d,p,v,e[r+6],9,-1069501632),v=i(v,h,d,p,e[r+11],14,643717713),p=i(p,v,h,d,e[r],20,-373897302),d=i(d,p,v,h,e[r+5],5,-701558691),h=i(h,d,p,v,e[r+10],9,38016083),v=i(v,h,d,p,e[r+15],14,-660478335),p=i(p,v,h,d,e[r+4],20,-405537848),d=i(d,p,v,h,e[r+9],5,568446438),h=i(h,d,p,v,e[r+14],9,-1019803690),v=i(v,h,d,p,e[r+3],14,-187363961),p=i(p,v,h,d,e[r+8],20,1163531501),d=i(d,p,v,h,e[r+13],5,-1444681467),h=i(h,d,p,v,e[r+2],9,-51403784),v=i(v,h,d,p,e[r+7],14,1735328473),d=a(d,p=i(p,v,h,d,e[r+12],20,-1926607734),v,h,e[r+5],4,-378558),h=a(h,d,p,v,e[r+8],11,-2022574463),v=a(v,h,d,p,e[r+11],16,1839030562),p=a(p,v,h,d,e[r+14],23,-35309556),d=a(d,p,v,h,e[r+1],4,-1530992060),h=a(h,d,p,v,e[r+4],11,1272893353),v=a(v,h,d,p,e[r+7],16,-155497632),p=a(p,v,h,d,e[r+10],23,-1094730640),d=a(d,p,v,h,e[r+13],4,681279174),h=a(h,d,p,v,e[r],11,-358537222),v=a(v,h,d,p,e[r+3],16,-722521979),p=a(p,v,h,d,e[r+6],23,76029189),d=a(d,p,v,h,e[r+9],4,-640364487),h=a(h,d,p,v,e[r+12],11,-421815835),v=a(v,h,d,p,e[r+15],16,530742520),d=u(d,p=a(p,v,h,d,e[r+2],23,-995338651),v,h,e[r],6,-198630844),h=u(h,d,p,v,e[r+7],10,1126891415),v=u(v,h,d,p,e[r+14],15,-1416354905),p=u(p,v,h,d,e[r+5],21,-57434055),d=u(d,p,v,h,e[r+12],6,1700485571),h=u(h,d,p,v,e[r+3],10,-1894986606),v=u(v,h,d,p,e[r+10],15,-1051523),p=u(p,v,h,d,e[r+1],21,-2054922799),d=u(d,p,v,h,e[r+8],6,1873313359),h=u(h,d,p,v,e[r+15],10,-30611744),v=u(v,h,d,p,e[r+6],15,-1560198380),p=u(p,v,h,d,e[r+13],21,1309151649),d=u(d,p,v,h,e[r+4],6,-145523070),h=u(h,d,p,v,e[r+11],10,-1120210379),v=u(v,h,d,p,e[r+2],15,718787259),p=u(p,v,h,d,e[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]}function s(e){var t,n="",r=32*e.length;for(t=0;t<r;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function f(e){var t,n,r="0123456789abcdef",o="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),o+=r.charAt(t>>>4&15)+r.charAt(15&t);return o}function d(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return s(c(l(e),8*e.length))}(d(e))}function v(e,t){return function(e,t){var n,r,o=l(e),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],a[n]=1549556828^o[n];return r=c(i.concat(l(t)),512+8*t.length),s(c(a.concat(r),640))}(d(e),d(t))}function h(e,t,n){return t?n?v(t,e):function(e,t){return f(v(e,t))}(t,e):n?p(e):function(e){return f(p(e))}(e)}e.exports?e.exports=h:t.md5=h}(lt)}(Lt);var Mt=ft(Lt.exports),Dt="function"==typeof btoa,qt="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var jt,Ut="function"==typeof TextEncoder?new TextEncoder:void 0,Ft=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");jt={},Ft.forEach(function(e,t){return jt[e]=t});var Bt=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Vt=Dt?function(e){return btoa(e)}:qt?function(e){return Buffer.from(e,"binary").toString("base64")}:function(e){for(var t,n,r,o,i="",a=e.length%3,u=0;u<e.length;){if((n=e.charCodeAt(u++))>255||(r=e.charCodeAt(u++))>255||(o=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");i+=Ft[(t=n<<16|r<<8|o)>>18&63]+Ft[t>>12&63]+Ft[t>>6&63]+Ft[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i},Kt=qt?function(e){return Buffer.from(e).toString("base64")}:function(e){for(var t=[],n=0,r=e.length;n<r;n+=4096)t.push(Bt.apply(null,e.subarray(n,n+4096)));return Vt(t.join(""))},Gt=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?Bt(192|t>>>6)+Bt(128|63&t):Bt(224|t>>>12&15)+Bt(128|t>>>6&63)+Bt(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return Bt(240|t>>>18&7)+Bt(128|t>>>12&63)+Bt(128|t>>>6&63)+Bt(128|63&t)},Wt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Jt=qt?function(e){return Buffer.from(e,"utf8").toString("base64")}:Ut?function(e){return Kt(Ut.encode(e))}:function(e){return Vt(function(e){return e.replace(Wt,Gt)}(e))},Ht=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Qt=function(e,t,n,r){for(var o,i=r>1?void 0:r?Yt(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ht(t,n,i),i},zt=function(){function e(t){var n=this;O(this,e),this.cgiBatchSize=B.cgiBatchSize,this.reportThreshold=B.reportThreshold,this.reportDelay=B.reportDelay,this.triggerExecuteSend=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return clearTimeout(t),t=setTimeout(function(){var t=e.apply(void 0,i);r.forEach(function(e){return e(t)}),r=[]},n),new Promise(function(e){return r.push(e)})}}(function(){n.executeSend()},1e3*this.reportDelay),this.inspectDelay=B.inspectDelay,this.inspectTimer=void 0,this.isNeedContinueSend=!1,this.getBaseInfo=t.getBaseInfo,this.reportLog=t.reportLog,this.queueManager=t.queueManager,this.configManager=t.configManager,this.onReportComplete=t.onReportComplete,this.onReportFail=t.onReportFail,this.flushSend(),this.startInspectTimer()}return x(e,[{key:"batchSend",value:function(){var e,t=this.queueManager.getReportableActions(this.reportThreshold);if(t.length>=this.reportThreshold)this.executeSend();else{var n=(null==(e=this.configManager)?void 0:e.getRealTimeActionList())||B.realTimeActionList;t.some(function(e){return n.indexOf(e.action_type)>-1&&!e.is_retry})?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var t=this;if(e.currentRequestCount>=e.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(e.requestConcurrency-e.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),o=this.getBaseInfo();if(!o.openid&&!o.unionid&&(Oe.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter(function(e){return null==e?void 0:e.ad_trace_id})),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),e.currentRequestCount+=Math.ceil(r.length/this.cgiBatchSize);for(var i=[],a=0;a<r.length;a+=this.cgiBatchSize){var u=this.generateActionReportParams(r.slice(a,a+this.cgiBatchSize));i.push(this.report(u))}Promise.all(i).then(function(e){var n=e.some(function(e){return e>=0});t.isNeedContinueSend&&n&&t.executeSend()}).catch(function(e){Oe.error(e),t.reportLog({message:"executeSend catch: ".concat(e.message),log_type:V,err_stack:e.stack})})}}}},{key:"generateActionReportParams",value:function(e){var t=[],n=[],r=this.getBaseInfo();return e.forEach(function(e){n.push(e.action_id);var r=Object.assign({},e);delete r.inner_status,t.push(r)}),{data:{info:r,actions:t},actionIdList:n}}},{key:"dealSuccessData",value:function(e,t,n){[51001,51003].indexOf(null==e?void 0:e.code)>-1?this.queueManager.updateActionsForReportFail(t):this.queueManager.removeActions(t),0!==(null==e?void 0:e.code)&&(this.reportLog({log_type:K,code:null==e?void 0:e.code,message:"trace_id: ".concat(null==e?void 0:e.trace_id,",msg: ").concat(null==e?void 0:e.message)}),Oe.error("上报失败:",e)),this.doTrackCallbackFn(this.onReportComplete,e,n),-1===[0,51001,51003].indexOf(null==e?void 0:e.code)&&this.doTrackCallbackFn(this.onReportFail,e,n)}},{key:"dealFailData",value:function(e,t,n){this.queueManager.updateActionsForReportFail(t),this.reportLog({log_type:K,code:e.code,message:e.message}),Oe.error("上报失败:",e),this.doTrackCallbackFn(this.onReportComplete,e,n)}},{key:"report",value:function(t){var n=this,r=t.data,o=t.actionIdList;return this.queueManager.updateActionsForReporting(o),Oe.debug&&(Oe.info("上报行为类型: ","【".concat(r.actions.map(function(e){return e.action_type}).join("、"),"】")),Oe.info("上报请求参数: ",r)),new Promise(function(t){var i,a,u,c,s,l,f,d,p=Date.now();try{var v=function(e){var t="",n=null==e?void 0:e.appid,r=null==e?void 0:e.secret_key,o=null==e?void 0:e.sdk_version,i=null==e?void 0:e.timestamp;if(!(n&&r&&o&&i&&32===r.length))return t;for(var a=Mt(o+n+i),u=0;u<32;u++)t+=u%2==0?r[u]:a[u];return t}({appid:null==(i=null==r?void 0:r.info)?void 0:i.appid,secret_key:null==(a=null==r?void 0:r.info)?void 0:a.secret_key,sdk_version:null==(u=null==r?void 0:r.info)?void 0:u.sdk_version,timestamp:p}),h=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(e){return e.replace(/=/g,"").replace(/[+\/]/g,function(e){return"+"==e?"-":"_"})}(Jt(e)):Jt(e)}(JSON.stringify(r));f={"Client-Time":p,"Sign-Value":Mt(h+(null==(c=null==r?void 0:r.info)?void 0:c.user_action_set_id)+(null==(s=null==r?void 0:r.info)?void 0:s.secret_key)+v),"Sign-Version":B.signVersion,"content-type":"text/plain;charset=UTF-8"},d=h}catch(v){f={"Client-Time":p},d=r,n.reportLog({log_type:Y,message:"sign error msg: ".concat(null==v?void 0:v.message),err_stack:null==v?void 0:v.stack}),Oe.error(v)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(l=n.configManager)?void 0:l.getRequestTimeout())||B.requestTimeout,header:f,data:d,success:function(i){var a,u;Oe.devLog("上报接口返回码:",null==(a=null==i?void 0:i.data)?void 0:a.code);var c=(null==(u=null==i?void 0:i.header)?void 0:u["Server-Time"])||-1;if(ue.revise(c),e.currentRequestCount-=1,200===(null==i?void 0:i.statusCode))return n.dealSuccessData(null==i?void 0:i.data,o,r),void t((null==i?void 0:i.data).code);var s="";try{s="object"==E(null==i?void 0:i.data)?JSON.stringify(null==i?void 0:i.data):null==i?void 0:i.data}catch(e){Oe.error(e)}var l={code:"number"==typeof(null==i?void 0:i.statusCode)?-1*i.statusCode:-888,message:"statusCode: ".concat(null==i?void 0:i.statusCode,", data: ").concat(s)};n.dealFailData(l,o,r),t(l.code)},fail:function(i){Oe.devLog("上报失败:",i),e.currentRequestCount-=1;var a={code:"number"==typeof(null==i?void 0:i.errno)?-1*i.errno:-999,message:null==i?void 0:i.errMsg};n.dealFailData(a,o,r),t(a.code)}})})}},{key:"startInspectTimer",value:function(){var t=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout(function(){e.currentRequestCount>=e.requestConcurrency&&(e.currentRequestCount=e.requestConcurrency-1),t.executeSend(),t.startInspectTimer()},1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(e,t,n){if("function"==typeof e)try{for(var r=[],o=0;o<n.actions.length;o++)if(!n.actions[o].is_sdk_auto_track){var i=n.actions[o],a=i.action_type,u=i.action_param,c=i.action_id,s=i.action_time;r.push({action_type:a,action_param:u,action_id:c,action_time:s})}if(r.length){var l=n.info,f=l.user_action_set_id,d=l.appid,p=l.openid,v=l.unionid,h=l.user_unique_id;e({code:null==t?void 0:t.code,message:null==t?void 0:t.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:h}}})}}catch(r){Oe.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(t){"number"==typeof t?t<1?Oe.error("网络请求最大并发量不能小于1"):t>10?Oe.error("网络请求最大并发量不能大于10"):e.requestConcurrency=t:Oe.error("网络请求最大并发量需设置为数字")}}]),e}(),$t=zt;$t.currentRequestCount=0,$t.requestConcurrency=B.requestConcurrency,Qt([xe],$t.prototype,"batchSend",1),Qt([xe],$t.prototype,"flushSend",1),Qt([xe],$t.prototype,"executeSend",1);var Zt=Ke,Xt=Ge,en=We,tn=Je,nn=He,rn=et,on=Ye,an=Qe,un=ze,cn=$e,sn=Xe,ln=Ze,fn=function(){function e(){O(this,e)}return x(e,[{key:"install",value:function(e,t){var n=function(t){Be.subscribe(t,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.track(t,Object.assign(n||{},o,y(y({},Tn,!0),wn,r)))}}(t))};n(Xt),n(Zt),n(en),n(tn),"all"===t&&(n(nn),n(rn),n(on),n(un),n(an),n("CREATE_GAME_ROOM"),n(cn),n(sn),n(ln))}}]),e}(),dn=function(){function e(){O(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return x(e,[{key:"onPurchase",value:function(e){return"number"!=typeof e&&Oe.warn("付费金额需要为数字"),e<=0&&Oe.warn("付费金额需要大于0"),this.wrapTrack("PURCHASE",{value:e})}},{key:"onEnterForeground",value:function(){return this.wrapTrack("ENTER_FOREGROUND")}},{key:"onEnterBackground",value:function(){return this.wrapTrack("ENTER_BACKGROUND")}},{key:"onAppStart",value:function(){return this.wrapTrack("START_APP")}},{key:"onAppQuit",value:function(){return this.wrapTrack("APP_QUIT")}},{key:"onAddToWishlist",value:function(){return this.wrapTrack("ADD_TO_WISHLIST")}},{key:"wrapTrack",value:function(e,t){return this.track(e,Object.assign(t||{},y({},this.special_method_symbol,1)))}}]),e}(),pn=function(){k(t,dn);var e=b(t);function t(){return O(this,t),e.apply(this,arguments)}return x(t,[{key:"onRegister",value:function(){return this.wrapTrack("REGISTER")}},{key:"onCreateRole",value:function(e){return e&&"string"!=typeof e&&Oe.warn("角色名称需要为字符串"),this.wrapTrack("CREATE_ROLE",e?{name:e}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack("TUTORIAL_FINISH")}}]),t}(),vn="(如果确认无误,请忽略该提示)",hn=function(){var e=[];return{requestActionList:function(){try{ce({conf_name:"data_nexus_common",conf_key:"action_types"}).then(function(t){ve(t)&&(e=t)})}catch(e){Oe.error(e)}},getActionList:function(){return e}}}();function gn(e,t){try{e.is_sdk_auto_track||(function(e){try{var t=hn.getActionList();if(!t.includes(e)){var n,r=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(yn(o,e)<=parseInt((.3*o.length).toString())){Oe.warn("通过SDK上报的".concat(e,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(vn));break}}}catch(e){r.e(e)}finally{r.f()}}}catch(t){Oe.error(t)}}(e.action_type),"minigame"===t?function(e,t){var n,r,o;try{["PURCHASE","ADD_TO_CART"].includes(e.action_type)&&e.action_param&&we(e.action_param,"value")&&("number"!=typeof(null==(n=e.action_param)?void 0:n.value)?Oe.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要为数字!")):(null==(r=e.action_param)?void 0:r.value)<=0?Oe.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要大于0!")):"minigame"===t&&(null==(o=e.action_param)?void 0:o.value)<100&&Oe.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(vn)))}catch(e){Oe.error(e)}}(e,t):"miniprogram"===t&&function(e){try{var t=null==e?void 0:e.action_type,n=(null==e?void 0:e.action_param)||{};"PURCHASE"===t&&we(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?Oe.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&Oe.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要大于0!")))}catch(t){Oe.error(t)}}(e))}catch(e){Oe.error(e)}}function yn(e,t){try{if(0===e.length)return t.length;if(0===t.length)return e.length;for(var n=[],r=0;r<=t.length;r++)n[r]=[r];for(var o=0;o<=e.length;o++)n[0][o]=o;for(var i=1;i<=t.length;i++)for(var a=1;a<=e.length;a++)t.charAt(i-1)===e.charAt(a-1)?n[i][a]=n[i-1][a-1]:n[i][a]=Math.min(n[i-1][a-1]+1,n[i][a-1]+1,n[i-1][a]+1);return n[t.length][e.length]}catch(n){Oe.error(n)}}function mn(e){try{e&&!/^[a-zA-Z0-9_\-]+$/.test(e)&&Oe.warn("通过SDK上报的openid:".concat(e,"可能有误,请检查openid是否正确!").concat(vn))}catch(e){Oe.error(e)}}var _n,An=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Sn=function(e,t,n,r){for(var o,i=r>1?void 0:r?kn(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&An(t,n,i),i},bn=Symbol("initializedInstance"),Tn=Symbol("autoTrack"),wn=Symbol("actionTime"),Rn=function(){k(t,pn);var e=b(t);function t(n){var r;if(O(this,t),(r=e.call(this)).env="production",r.sdk_version="1.5.5",r.sdk_name="@dn-sdk/minigame",r.deviceInfo={},r.gameInfo={},r.session_id="",r.log_id=0,r.inited=!1,r.initErrMsg="",null==wx||!wx.createCanvas)return r.initErrMsg="不支持非微信小游戏中使用",Oe.error(r.initErrMsg),T(r);var o=Te();if(t[bn].length>=o.maxSdkInstance)return r.initErrMsg="初始化超过上限",Oe.error(r.initErrMsg),T(r);var i=function(e){return pe(e)?(function(e){var t=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(var n in e)t.includes(n)||Oe.warn("Invalid property '".concat(n,"' found in config"))}(e),"number"!=typeof e.user_action_set_id?"user_action_set_id 参数需为 number 类型":e.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof e.secret_key?"secret_key 参数需为 string 类型":""===e.secret_key.trim()?"缺少 secret_key 参数":32!==e.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof e.appid?"appid 参数需为 string 类型":""!==e.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"}(n),a=oe();if(!0!==i)return r.initErrMsg=i,Oe.error(i),T(r);var u=null==a?void 0:a.appId;if(u&&u!==n.appid)return r.initErrMsg="初始化传入的appid与当前小游戏appid不一致",Oe.error(r.initErrMsg),T(r);r.config=n,we(n,"auto_track")||(r.config.auto_track=be("autoTrack")),r.openid=n.openid,r.unionid=n.unionid,r.user_unique_id=n.user_unique_id,r.onReportComplete=n.on_report_complete,r.onReportFail=n.on_report_fail,r.saveValidOpenidToStorage();var c=n.user_action_set_id;return t[bn].includes(c)?(r.initErrMsg="同个数据源[".concat(c,"]只能初始化一次"),Oe.error(r.initErrMsg),r.reportLog({log_type:V,message:r.initErrMsg}),T(r)):(r.reportLog=r.reportLog.bind(w(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(w(r)),r.deviceInfo=ee(),r.gameInfo=Ie(),r.session_id=ye(),r.queueManage=new je({userActionSetId:c,maxLength:o.maxQueueLength,ogEvents:Ve}),r.actionReporter=new $t({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:ot,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,t[bn].push(c),r.useAutoTrack(),r.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(Oe.info("初始化成功"),T(r)):(function(e){var t=e.sdk_version,n=e.default_download_url,r=e.fail_handler;ce({conf_name:e.conf_name,conf_key:e.conf_key}).then(function(e){if(pe(e)){var o=null==e?void 0:e.blackVersions,i=null==e?void 0:e.minVersion,a=null==e?void 0:e.bestVersion,u=null==e?void 0:e.downloadUrl,c=n;return u&&/^https/.test(u)&&(c=u),ve(o)&&(null==o?void 0:o.indexOf(t))>-1?(null==r||r(),void Oe.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):i&&Se(t,i)<0?(null==r||r(),void Oe.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Se(t,a)<0&&Oe.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void Oe.info("初始化成功"))}Oe.info("初始化成功")}).catch(function(){Oe.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}}),hn.requestActionList(),mn(n.openid),T(r)))}return x(t,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(e,t){var n,r;if(!this.inited||!this.queueManage)return Oe.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var o=Pt.validateActionType(e),i=Pt.validateActionParam(t);if(o&&i){!this.openid&&!this.unionid&&Oe.warn("缺少 openid 或 unionid");var a=be("actionParamMaxLength");if(JSON.stringify(t||{}).length>a)return Oe.error("监测到超过".concat(a,"的上报日志:").concat(e," ").concat(t)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==t||!t[Tn]),c=this.createAction(e,t||{},u);"release"!==(null==(n=oe())?void 0:n.envVersion)&&gn(c,"minigame");var s=this.queueManage.addAction(c);return null==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){var e;null==(e=this.actionReporter)||e.flushSend()}},{key:"setOpenId",value:function(e){var t;if(e&&"string"==typeof e)return this.openid=e,this.gameInfo.ad_trace_id&&!X.getSync(U)&&Be.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(t=oe())?void 0:t.envVersion)&&mn(e),{code:0,message:"成功"};var n="openid 格式错误";return Oe.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(e){if(e&&"string"==typeof e)return this.unionid=e,this.flush(),{code:0,message:"成功"};var t="unionid 格式错误";return Oe.error(t),{code:101,message:t}}},{key:"setUserUniqueId",value:function(e){if(e&&"string"==typeof e)return this.user_unique_id=e,{code:0,message:"成功"};var t="user_unique_id 格式错误";return Oe.error(t),{code:101,message:t}}},{key:"doReportOnEnterBackground",value:function(){var e=this;wx.onHide(function(){var t,n;null==(t=e.actionReporter)||t.flushSend(),null==(n=e.queueManage)||n.reportLostNum()})}},{key:"getTrackBaseInfo",value:function(){var e=oe();return Object.assign({},this.deviceInfo,function(e){var t={};return["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"].forEach(function(n){we(e,n)&&(t[n]=e[n])}),t}(this.config),{local_id:te(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||re(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:e.envVersion,app_version:e.version}})}},{key:"createAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=t&&t[Tn]&&delete t[Tn];var r=Date.now();null!=t&&t[wn]&&(r=null==t?void 0:t[wn],delete t[wn]);var o={action_id:ye(),action_param:t,action_time:r,action_type:e,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:ue.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:ne(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(e)};return null!=t&&t[this.special_method_symbol]&&(this.addActionInnerParam(o,"is_special_method",!0),delete t[this.special_method_symbol]),ot.getChannelClaimActionList().indexOf(e)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(o,"launch_options",this.gameInfo.launch_options),o}},{key:"addActionInnerParam",value:function(e,t,n){e.inner_param&&pe(e.inner_param)?e.inner_param[t]=n:e.inner_param=y({},t,n)}},{key:"getChannelByActionType",value:function(e){var t="";return ot.getChannelClaimActionList().indexOf(e)>-1?t=this.gameInfo.channel||"":ot.getNoClaimActionList().indexOf(e)>-1&&(t="UNKNOWN"),t}},{key:"reportLog",value:function(e){var t,n,r={user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};ae(Object.assign(r,e))}},{key:"useAutoTrack",value:function(){var e;if(null!=(e=this.config)&&e.auto_track){var t=!0,n=X.getSync(q);(null==n?void 0:n.ap)===z?t=!0:(null==n?void 0:n.ap)===$&&(t=!1),"devtools"===ee().wx_platform&&(t=!0),(new fn).install(this,t?"all":"lifecycle"),st(),t&&Ot(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var e,t,n=ee();n.os&&n.os_version&&null!=(e=this.config)&&e.user_action_set_id&&function(e){return new Promise(function(t){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:e,timeout:B.requestTimeout,success:function(e){se(e,t,"minigame/get"),fe(e)},fail:function(e){le(e,"minigame/get")}})})}({conf_name:"MG",conf_param:{user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:Re(n.os_version),device_brand:(null==n?void 0:n.device_brand)||"",weixin_lib_version:(null==n?void 0:n.wx_lib_version)||"",weixin_version:(null==n?void 0:n.wx_version)||""}}).then(function(e){pe(e)&&X.setSync(q,e)})}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(e){return/^[a-zA-Z0-9_-]{28,30}$/.test(e)}(this.openid)&&X.setSync(U,this.openid)}}],[{key:"setRequestConcurrency",value:function(e){$t.setRequestConcurrency(e)}},{key:"setDebug",value:function(e){Oe.debug=e}}]),t}(),En=Rn;En[bn]=[],Sn([xe],En.prototype,"track",1),Sn([xe,function(e,t,n){var r=n.value;return n.value=function(){if(this.inited){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(this,t)}Oe.error("上报失败,请先完成初始化")},n}],En.prototype,"flush",1),Sn([xe],En.prototype,"setOpenId",1),Sn([xe],En.prototype,"setUnionId",1),Sn([xe],En.prototype,"setUserUniqueId",1),Sn([xe],En.prototype,"doReportOnEnterBackground",1),Sn([xe],En.prototype,"getTrackBaseInfo",1),Sn([xe],En.prototype,"useAutoTrack",1);var On=0,In={moid:""},xn=!1,Cn=JSON.stringify(wx.getLaunchOptionsSync()||""),Nn={token:"",uid:"",uname:"",openid:""},Pn={partner_id:"",game_id:"",pkg_name:"",version:""},Ln={doid:"",dsid:"",dsname:"",dext:"",drid:"",drname:"",drlevel:"",dmoney:"",money:""},Mn="wx-adapter sdk >>>>>>>:";wx.hideShareMenu(),wx.onShow(function(e){e.query&&(Cn=JSON.stringify(e))});var Dn=function(e){var t=n(n({},v()),d),r=l(n(n(n(n(n({},Ln),Nn),Pn),t),{},{launchoption:Cn,onshow:Cn}));c(u,"/wxgamemds/index/",r).then(function(t){t.state&&(t.data.balance>=e?jn(""):qn(t.data,e))}).catch(function(e){console.log(e)})},qn=function(e,t){wx.requestMidasPayment({mode:"game",env:e.env,offerId:e.offerId,currencyType:e.currencyType,platform:e.platform,buyQuantity:e.buyQuantity,outTradeNo:In.moid,success:function(e){_n&&_n.onPurchase(100*t),jn(e)},fail:function(e){console.log(e)}})},jn=function(e){var t;On++;var r=n(n({},v()),d);t=l(e?n(n(n(n(n(n({},Ln),Pn),Nn),r),In),{},{res:JSON.stringify(e),launchoption:Cn,onshow:Cn}):n(n(n(n(n(n({},Ln),Pn),Nn),In),r),{},{launchoption:Cn,onshow:Cn})),c(u,"/wxgamemds/send/",t).then(function(e){console.log(e)}).catch(function(t){console.log(t),On<3&&setTimeout(function(){jn(e)},1e3)})},Un=function(e){return new Promise(function(t,n){if(!e)return n({state:100001,msg:"激活入参缺失"});if(null==e||!e.wx)return n({state:100002,msg:"激活入参 wx 属性缺失"});var r=e.wx,o=r.game_id,i=r.version,a=r.dn_sdk_id,u=r.dn_secret_key;if(!o)return n({state:100003,msg:"激活入参 game_id 属性缺失"});Pn.game_id=o,Pn.version=i,Pn.pkg_name="wxgame",Pn.partner_id=4,xn=!0,console.log("active 激活成功!"),a&&u&&function(e){var t=e.dn_sdk_id,n=e.dn_secret_key,r=e.app_id,o=(_n=new En({appid:r,secret_key:n,user_action_set_id:t})).getInitResult();null!=o&&o.inited||console.error("dnSdk init failed: ",o.initErrMsg),_n.onAppStart(),wx.onAddToFavorites(function(e){console.log(Mn+"click onAddToFavorites"),_n&&_n.track("DD_TO_WISHLIST",{type:"default"})}),wx.onShareAppMessage(function(){console.log(Mn+"click onShareAppMessage"),_n&&_n.track("SHARE",{target:"APP_MESSAGE"})}),wx.onShareTimeline(function(){console.log(Mn+"click onShareTimeline"),_n&&_n.track("SHARE",{target:"TIME_LINE"})}),console.log(Mn+"广点通初始化成功!")}(wx),t()})},Fn=function(){return new Promise(function(e,t){if(!xn)return t({state:100003,msg:"登录前请先激活"});wx.login({success:function(r){var o=l(n(n(n({code:r.code},Pn),g()),{},{launchoption:Cn,onshow:Cn}));c(u,"/wxgamelogin/initlogin/",o).then(function(n){if(1==n.state){var r=n.data,o=r.token,i=r.uid,u=r.uname,c=r.openid,s=r.show_page;if(Nn.token=o,Nn.uid=i,Nn.uname=u,Nn.openid=c,e({token:o,uid:i,uname:u,partner_id:4,show_page:s}),console.log(Mn+"登录成功"),c&&_n){var l=n||{},f=l.backFlowDay,d=l.isRegisterUser;!function(e){var t=e.openid,n=e.nsSdk,r=e.backFlowDay,o=e.isRegisterUser;n.setOpenId(t),o?n.onRegister():r&&r>=30&&n.track("RE_ACTIVE",{backFlowDay:30})}({openid:c,nsSdk:_n,backFlowDay:f,isRegisterUser:d})}}else a(n.msg),t({state:n.state,msg:n.msg})}).catch(function(e){a(e),t({state:100001,msg:e})})},fail:function(e){t({state:100002,msg:e})}})})},Bn=function(){return new Promise(function(e,t){wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100001,msg:JSON.stringify(e)})}}):wx.getUserProfile({desc:"获取用户信息",success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100002,msg:JSON.stringify(e)})}})}})})},Vn=function(e){return new Promise(function(t,r){var o=Nn||{},i=o.token,s=o.uid,p=o.uname;if(!(xn&&i&&s&&p))return a("失败!请先激活登录"),r({state:100001,msg:"未激活或未登录,请重新进入游戏"});wx.showLoading({title:"加载中"});var y=e.dmoney;(Ln=f(e)||{}).money=y;var m=l(n(n(n(n(n({},e),Pn),Nn),n(n(n({},v()),h()),d)),{},{money:y,launchoption:Cn,onshow:Cn}));c(u,"/wxgameorder/index/",m).then(function(e){var n=e||{},o=n.state,i=n.msg,s=n.data,f=void 0===s?{}:s;if(1==o){var d=f.aid,p=f.moid,v=f.thumb_url;In.moid=p,1==d?(Dn(y),t({msg:"ok"})):2==d?wx.showModal({title:"支付提示",content:"即将打开充值入口,输入“充值”或点击右下角卡片即可充值。",showCancel:!1,confirmText:"点我充值",success:function(e){e.confirm?wx.openCustomerServiceConversation({sessionFrom:p,sendMessagePath:"/path/index/index?moid="+p,showMessageCard:!0,sendMessageImg:v,success:function(e){console.log("openCustomerServiceConversation success",e),t()},fail:function(e){console.error("openCustomerServiceConversation fail ",e),r({state:100003,msg:"支付失败"})},complete:function(e){console.log("openCustomerServiceConversation compelte: ",p),function(e){var t=g(),n=l({partner_id:Pn.partner_id,pkg_name:Pn.pkg_name,game_id:Pn.game_id,uid:Nn.uid,openid:Nn.openid,token:Nn.token,uname:Nn.uname,duid:t.duid,moid:e});c(u,"/wxgameorder/get/",n).then(function(e){1==e.data.status&&_n.onPurchase(100*e.data.money)})}(p)}}):(a("用户取消支付"),r({state:100005,msg:"取消支付"}))},fail:function(){a("用户取消支付"),r({state:100006,msg:"支付失败"})}}):(a("失败!设备未识别"),r({state:100004,msg:"支付失败"}))}else a(i),r({state:o,msg:i});wx.hideLoading()}).catch(function(e){a(e),r({state:100002,msg:"支付失败"}),wx.hideLoading()})})},Kn=function(e){return new Promise(function(t,r){var o=Nn||{},i=o.token,s=o.uid,f=o.uname;if(!(xn&&i&&s&&f))return a("未激活或未登录,请重新进入游戏"),r({state:100001,msg:"未激活或未登录,请检查"});var p=l(n(n(n(n(n({},e),Nn),Pn),n(n({},v()),d)),{},{launchoption:Cn,onshow:Cn}));c(u,"/wxgameevent/index/",p).then(function(){t(),_n&&("create"===p.event&&_n.onCreateRole(p.drname),"levelup"===p.event&&_n.track("UPDATE_LEVEL",{level:p.drlevel,power:0}))}).catch(function(e){console.log(e),r({state:100002,msg:"角色上报失败"})})})},Gn=function(e){wx.shareAppMessage(),Kn(n(n({},f(e)),{},{event:"fxclick"}))},Wn=function(e){wx.openCustomerServiceConversation({success:function(){Kn(n(n({},f(e)),{},{event:"kfclick"}))}})},Jn=function(e){return new Promise(function(t,r){var o=l(n(n(n(n(n({},e),Pn),Nn),g()),{},{launchoption:Cn,onshow:Cn,partner_id:4}));c(u,"/wxgamesafe/verify/",o).then(function(e){var n=e.data,o=n.code,i=n.msg;1==o?t():r({state:100001,msg:i})}).catch(function(e){r({state:100002,msg:e})})})},Hn=function(e){return new Promise(function(t,n){_n?(_n.track("VIEW_CONTENT",{item:e}),t()):n({state:100001,msg:"上报失败!广点通 sdk 未初始化"})})},Yn=function(e){return new Promise(function(t,n){var r=!1,o=wx.createInterstitialAd({adUnitId:e});o.onError(function(e){r=!0}),o.load().then(function(){if(!r)return o.show();n({state:100001,msg:"广告加载后发生错误"})}).then(t).catch(function(e){return n({state:100002,msg:JSON.stringify(e)})}),o.onClose(function(e){console.log("广告关闭:",e.isEnded?"正常播放完成":"用户提前关闭")})})},Qn=null,zn=!1,$n=!1,Zn=function(e){var t=function(){return new Promise(function(t,n){if(zn)return t();Qn&&(Qn=null),(Qn=wx.createRewardedVideoAd({adUnitId:e})).onError(function(e){zn=!1,Qn=null,n({state:100004,msg:"广告平台异常",originalErr:e})}),Qn.load().then(function(){console.log("激励视频广告预加载成功"),zn=!0,t()}).catch(function(e){console.error("激励视频广告预加载失败:",e),zn=!1,Qn=null,n(e)})})},n=function(){return $n?Promise.reject({state:100004,msg:"广告正在展示中,请稍后再试"}):zn?Qn?($n=!0,new Promise(function(e,t){Qn.onClose(function(t){console.log("激励视频广告关闭,是否看完:",t.isEnded),e({isEnded:t.isEnded}),$n=!1,Qn.offClose()}),Qn.show().then(function(){console.log("激励视频广告展示成功")}).catch(function(e){zn=!1,$n=!1,t({state:100003,msg:JSON.stringify(e)})})})):Promise.reject({state:100002,msg:"广告实例不存在"}):t().then(n).catch(function(e){return Promise.reject({state:100001,msg:JSON.stringify(e)})})};return{preload:t,show:n}};export{Un as jf_active,Zn as jf_createRewardedVideoAd,Wn as jf_customerService,Bn as jf_getUserInfo,Fn as jf_login,Vn as jf_pay,Jn as jf_profanityCheck,Gn as jf_share,Yn as jf_showInterstitialAd,Kn as jf_trace,Hn as jf_tracePageView};
|