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