@jolibox/implement 1.1.7-beta.3 → 1.1.7

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.
@@ -3,12 +3,12 @@
3
3
  "packages/implement/.rush/temp/shrinkwrap-deps.json": "455e6ae3ec587dee276871042f8e2f0747c69b80",
4
4
  "packages/implement/.eslintrc.js": "7a3d2747dc887655ca9e2d3ff621f7dfd98500b9",
5
5
  "packages/implement/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
- "packages/implement/esbuild.config.js": "889e44fb2f426aae078b59a42fcfb9c2f28ebd89",
7
- "packages/implement/package.json": "8890595fc45d109c1d6238cf6bfb291ddcd331bf",
6
+ "packages/implement/esbuild.config.js": "86f1fd21722a2cb05216751578dcca66326e664a",
7
+ "packages/implement/package.json": "d314fd76b3bae17c96760bb5efc348f4ba605730",
8
8
  "packages/implement/src/common/ads/ads-action-detection.ts": "5a7b9f85d7eab9e744f8a9fc7638063f43baa214",
9
9
  "packages/implement/src/common/ads/anti-cheating.ts": "62e1b5d24aa246849a17ac8cde6cfdc66e577cab",
10
10
  "packages/implement/src/common/ads/channel-policy.ts": "c6d036be5cedf0c5d545fac271c6c8447ca55d8a",
11
- "packages/implement/src/common/ads/index.ts": "08ac129caeb0188f92eb8c3dc52d9cda7c6e40a4",
11
+ "packages/implement/src/common/ads/index.ts": "8e2df7852b9baf10a18bca1e0c22a42de3a7edf5",
12
12
  "packages/implement/src/common/api-factory/index.ts": "a2b60f027384e37492ddde550dd46f3fb3e14cfe",
13
13
  "packages/implement/src/common/api-factory/validator/__tests__/validate/any.test.ts": "6e225e09fce401b374221ad2e4fe33bc91df4152",
14
14
  "packages/implement/src/common/api-factory/validator/__tests__/validate/array.test.ts": "8a9cc32be03e952f1176a970fea033d597c176cb",
@@ -45,7 +45,7 @@
45
45
  "packages/implement/src/common/report/task-track/index.ts": "056d4ce9121648e94aa177e8e6b261adb455d244",
46
46
  "packages/implement/src/common/report/track.ts": "1c71050f8caadfe7065f0db5a4a0708c264c21b4",
47
47
  "packages/implement/src/common/report/types.ts": "fd127bfd31586f1d712152ef60a4e9175f8bfe8f",
48
- "packages/implement/src/h5/api/ads.ts": "7a40ea4d3937a1d193e5bd1abd88f5f2cdd28f78",
48
+ "packages/implement/src/h5/api/ads.ts": "4662b71a10b03a2c7c8dbdc08a8e58609fde2c89",
49
49
  "packages/implement/src/h5/api/base.ts": "ead2c3cdcbe174b0e725c31a3885c7985bd8f667",
50
50
  "packages/implement/src/h5/api/get-system-info.ts": "c7a866b5b06695774a7fd94df73156c4e15658a8",
51
51
  "packages/implement/src/h5/api/index.ts": "81b815f5ac8e1bd3e3f019f94c28bd5522a36193",
@@ -58,9 +58,9 @@
58
58
  "packages/implement/src/h5/http/utils/index.ts": "05f4d94be09b9bfdcbb1365b31a5559e44a74991",
59
59
  "packages/implement/src/h5/http/utils/session.ts": "4762a6a56762484f91ca5f2a456ab2cff3107659",
60
60
  "packages/implement/src/h5/report/errors/index.ts": "22ef4184d6a6d272a5fefc1453a4a6d78ae8f2ff",
61
- "packages/implement/src/h5/report/event-tracker.ts": "eb52379559e584a5b3f7a5241a3555b667b18c8c",
61
+ "packages/implement/src/h5/report/event-tracker.ts": "20f87b2f4d6dc538a4d2869507afc5144808c76c",
62
62
  "packages/implement/src/h5/report/index.ts": "7154000726a72f477183d069eea5de87d12ceb7d",
63
- "packages/implement/src/h5/report/task-tracker.ts": "184708c10b610b305f4f87af1639d9005486218e",
63
+ "packages/implement/src/h5/report/task-tracker.ts": "e3da251b65d6fdc37d46b8493477d0125359bab2",
64
64
  "packages/implement/src/index.native.ts": "96cc46c8919ba2333600e9c3ee100f47c511a79a",
65
65
  "packages/implement/src/index.ts": "d0ca7b5312b0a258ae8887e725440c70190442f7",
66
66
  "packages/implement/src/native/api/ads.ts": "bec8c772e1f881dc49030082e48b32af0c7db0fb",
@@ -74,11 +74,11 @@
74
74
  "packages/implement/src/native/api/storage.ts": "7f56694e3a7f47605512f9cee7fce48ac620c169",
75
75
  "packages/implement/src/native/api/task.ts": "26e06a3d6bbeaed34fd704d096e712448296607e",
76
76
  "packages/implement/src/native/bootstrap/bridge.ts": "3dfce00262f240342d7e29ae155ce8c1732a02cd",
77
- "packages/implement/src/native/bootstrap/index.ts": "31d2b3d4c6ba91c7e585e15db7a7ad2f290772b4",
77
+ "packages/implement/src/native/bootstrap/index.ts": "e5d28be30f3cccf4cc6de5c094003f22b8189398",
78
78
  "packages/implement/src/native/bootstrap/init-env.ts": "b7514d5d2db60da990575c1426243777aee57748",
79
79
  "packages/implement/src/native/js-bridge/const.ts": "96156a123e89d20b51d59865e21f216ea5a30821",
80
80
  "packages/implement/src/native/js-bridge/index.ts": "b65e1e20edcce8ce270381a9c7c79cc981761ad4",
81
- "packages/implement/src/native/js-bridge/invoke.ts": "755402c39f887769242b3a3cee7c51c8eb0d9f11",
81
+ "packages/implement/src/native/js-bridge/invoke.ts": "f7fd744c9491e4eb21b8d5ec6ef314a602a5adcb",
82
82
  "packages/implement/src/native/js-bridge/js-bridge.ts": "a4b3c18e243aedf7d4aabc3b3791911bffb7b6ff",
83
83
  "packages/implement/src/native/js-bridge/report.ts": "056a4b6eea59219d1ea3af08a39fd35a4627abd2",
84
84
  "packages/implement/src/native/js-bridge/subscribe.ts": "757943dc68dcd8b87815126b2aa4b5fe291fea4f",
@@ -239,6 +239,12 @@ export declare class JoliboxAdsImpl {
239
239
  * @param params
240
240
  */
241
241
  private push;
242
+ /**
243
+ * Wrap adBreak params to track google adsense event and control adEventEmitter
244
+ * @param params IAdBreakParams
245
+ * @returns IAdBreakParams
246
+ */
247
+ private wrapAdBreakParams;
242
248
  /**
243
249
  * The adConfig() call communicates the game's current configuration to the Ad Placement API. The Ad Placement API can use this to tune the way it preloads ads and to filter the kinds of ads it requests so they're suitable (eg. video ads that require sound).
244
250
  * @param params
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var ao=Object.create;var Ir=Object.defineProperty;var co=Object.getOwnPropertyDescriptor;var lo=Object.getOwnPropertyNames;var uo=Object.getPrototypeOf,fo=Object.prototype.hasOwnProperty;var Ie=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var mo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ho=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of lo(t))!fo.call(e,l)&&l!==n&&Ir(e,l,{get:()=>t[l],enumerable:!(i=co(t,l))||i.enumerable});return e};var po=(e,t,n)=>(n=e!=null?ao(uo(e)):{},ho(t||!e||!e.__esModule?Ir(n,"default",{value:e,enumerable:!0}):n,e));var rn=mo((tn,er)=>{(function(e){if(typeof tn=="object"&&typeof er<"u")er.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,n;return function i(l,d,h){function _(I,x){if(!d[I]){if(!l[I]){var m=typeof Ie=="function"&&Ie;if(!x&&m)return m(I,!0);if(E)return E(I,!0);var b=new Error("Cannot find module '"+I+"'");throw b.code="MODULE_NOT_FOUND",b}var k=d[I]={exports:{}};l[I][0].call(k.exports,function(N){var K=l[I][1][N];return _(K||N)},k,k.exports,i,l,d,h)}return d[I].exports}for(var E=typeof Ie=="function"&&Ie,A=0;A<h.length;A++)_(h[A]);return _}({1:[function(i,l,d){(function(h){"use strict";var _=h.MutationObserver||h.WebKitMutationObserver,E;if(_){var A=0,I=new _(N),x=h.document.createTextNode("");I.observe(x,{characterData:!0}),E=function(){x.data=A=++A%2}}else if(!h.setImmediate&&typeof h.MessageChannel<"u"){var m=new h.MessageChannel;m.port1.onmessage=N,E=function(){m.port2.postMessage(0)}}else"document"in h&&"onreadystatechange"in h.document.createElement("script")?E=function(){var V=h.document.createElement("script");V.onreadystatechange=function(){N(),V.onreadystatechange=null,V.parentNode.removeChild(V),V=null},h.document.documentElement.appendChild(V)}:E=function(){setTimeout(N,0)};var b,k=[];function N(){b=!0;for(var V,re,J=k.length;J;){for(re=k,k=[],V=-1;++V<J;)re[V]();J=k.length}b=!1}l.exports=K;function K(V){k.push(V)===1&&!b&&E()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,l,d){"use strict";var h=i(1);function _(){}var E={},A=["REJECTED"],I=["FULFILLED"],x=["PENDING"];l.exports=m;function m(T){if(typeof T!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,T!==_&&K(this,T)}m.prototype.catch=function(T){return this.then(null,T)},m.prototype.then=function(T,D){if(typeof T!="function"&&this.state===I||typeof D!="function"&&this.state===A)return this;var P=new this.constructor(_);if(this.state!==x){var U=this.state===I?T:D;k(P,U,this.outcome)}else this.queue.push(new b(P,T,D));return P};function b(T,D,P){this.promise=T,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof P=="function"&&(this.onRejected=P,this.callRejected=this.otherCallRejected)}b.prototype.callFulfilled=function(T){E.resolve(this.promise,T)},b.prototype.otherCallFulfilled=function(T){k(this.promise,this.onFulfilled,T)},b.prototype.callRejected=function(T){E.reject(this.promise,T)},b.prototype.otherCallRejected=function(T){k(this.promise,this.onRejected,T)};function k(T,D,P){h(function(){var U;try{U=D(P)}catch(G){return E.reject(T,G)}U===T?E.reject(T,new TypeError("Cannot resolve promise with itself")):E.resolve(T,U)})}E.resolve=function(T,D){var P=V(N,D);if(P.status==="error")return E.reject(T,P.value);var U=P.value;if(U)K(T,U);else{T.state=I,T.outcome=D;for(var G=-1,z=T.queue.length;++G<z;)T.queue[G].callFulfilled(D)}return T},E.reject=function(T,D){T.state=A,T.outcome=D;for(var P=-1,U=T.queue.length;++P<U;)T.queue[P].callRejected(D);return T};function N(T){var D=T&&T.then;if(T&&(typeof T=="object"||typeof T=="function")&&typeof D=="function")return function(){D.apply(T,arguments)}}function K(T,D){var P=!1;function U(q){P||(P=!0,E.reject(T,q))}function G(q){P||(P=!0,E.resolve(T,q))}function z(){D(G,U)}var Y=V(z);Y.status==="error"&&U(Y.value)}function V(T,D){var P={};try{P.value=T(D),P.status="success"}catch(U){P.status="error",P.value=U}return P}m.resolve=re;function re(T){return T instanceof this?T:E.resolve(new this(_),T)}m.reject=J;function J(T){var D=new this(_);return E.reject(D,T)}m.all=yt;function yt(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=T.length,U=!1;if(!P)return this.resolve([]);for(var G=new Array(P),z=0,Y=-1,q=new this(_);++Y<P;)ne(T[Y],Y);return q;function ne(_e,Ce){D.resolve(_e).then(bt,function(me){U||(U=!0,E.reject(q,me))});function bt(me){G[Ce]=me,++z===P&&!U&&(U=!0,E.resolve(q,G))}}}m.race=ue;function ue(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=T.length,U=!1;if(!P)return this.resolve([]);for(var G=-1,z=new this(_);++G<P;)Y(T[G]);return z;function Y(q){D.resolve(q).then(function(ne){U||(U=!0,E.resolve(z,ne))},function(ne){U||(U=!0,E.reject(z,ne))})}}},{1:1}],3:[function(i,l,d){(function(h){"use strict";typeof h.Promise!="function"&&(h.Promise=i(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(i,l,d){"use strict";var h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r};function _(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function E(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var A=E();function I(){try{if(!A||!A.open)return!1;var r=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!r||s)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function x(r,s){r=r||[],s=s||{};try{return new Blob(r,s)}catch(a){if(a.name!=="TypeError")throw a;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,c=new o,u=0;u<r.length;u+=1)c.append(r[u]);return c.getBlob(s.type)}}typeof Promise>"u"&&i(3);var m=Promise;function b(r,s){s&&r.then(function(o){s(null,o)},function(o){s(o)})}function k(r,s,o){typeof s=="function"&&r.then(s),typeof o=="function"&&r.catch(o)}function N(r){return typeof r!="string"&&(console.warn(r+" used as a key, but it is not a string."),r=String(r)),r}function K(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var V="local-forage-detect-blob-support",re=void 0,J={},yt=Object.prototype.toString,ue="readonly",T="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),c=new Uint8Array(o),u=0;u<s;u++)c[u]=r.charCodeAt(u);return o}function P(r){return new m(function(s){var o=r.transaction(V,T),c=x([""]);o.objectStore(V).put(c,"key"),o.onabort=function(u){u.preventDefault(),u.stopPropagation(),s(!1)},o.oncomplete=function(){var u=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);s(a||!u||parseInt(u[1],10)>=43)}}).catch(function(){return!1})}function U(r){return typeof re=="boolean"?m.resolve(re):P(r).then(function(s){return re=s,re})}function G(r){var s=J[r.name],o={};o.promise=new m(function(c,u){o.resolve=c,o.reject=u}),s.deferredOperations.push(o),s.dbReady?s.dbReady=s.dbReady.then(function(){return o.promise}):s.dbReady=o.promise}function z(r){var s=J[r.name],o=s.deferredOperations.pop();if(o)return o.resolve(),o.promise}function Y(r,s){var o=J[r.name],c=o.deferredOperations.pop();if(c)return c.reject(s),c.promise}function q(r,s){return new m(function(o,c){if(J[r.name]=J[r.name]||nr(),r.db)if(s)G(r),r.db.close();else return o(r.db);var u=[r.name];s&&u.push(r.version);var a=A.open.apply(A,u);s&&(a.onupgradeneeded=function(f){var p=a.result;try{p.createObjectStore(r.storeName),f.oldVersion<=1&&p.createObjectStore(V)}catch(g){if(g.name==="ConstraintError")console.warn('The database "'+r.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+r.storeName+'" already exists.');else throw g}}),a.onerror=function(f){f.preventDefault(),c(a.error)},a.onsuccess=function(){var f=a.result;f.onversionchange=function(p){p.target.close()},o(f),z(r)}})}function ne(r){return q(r,!1)}function _e(r){return q(r,!0)}function Ce(r,s){if(!r.db)return!0;var o=!r.db.objectStoreNames.contains(r.storeName),c=r.version<r.db.version,u=r.version>r.db.version;if(c&&(r.version!==s&&console.warn('The database "'+r.name+`" can't be downgraded from version `+r.db.version+" to version "+r.version+"."),r.version=r.db.version),u||o){if(o){var a=r.db.version+1;a>r.version&&(r.version=a)}return!0}return!1}function bt(r){return new m(function(s,o){var c=new FileReader;c.onerror=o,c.onloadend=function(u){var a=btoa(u.target.result||"");s({__local_forage_encoded_blob:!0,data:a,type:r.type})},c.readAsBinaryString(r)})}function me(r){var s=D(atob(r.data));return x([s],{type:r.type})}function rr(r){return r&&r.__local_forage_encoded_blob}function cn(r){var s=this,o=s._initReady().then(function(){var c=J[s._dbInfo.name];if(c&&c.dbReady)return c.dbReady});return k(o,r,r),o}function ln(r){G(r);for(var s=J[r.name],o=s.forages,c=0;c<o.length;c++){var u=o[c];u._dbInfo.db&&(u._dbInfo.db.close(),u._dbInfo.db=null)}return r.db=null,ne(r).then(function(a){return r.db=a,Ce(r)?_e(r):a}).then(function(a){r.db=s.db=a;for(var f=0;f<o.length;f++)o[f]._dbInfo.db=a}).catch(function(a){throw Y(r,a),a})}function oe(r,s,o,c){c===void 0&&(c=1);try{var u=r.db.transaction(r.storeName,s);o(null,u)}catch(a){if(c>0&&(!r.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return m.resolve().then(function(){if(!r.db||a.name==="NotFoundError"&&!r.db.objectStoreNames.contains(r.storeName)&&r.version<=r.db.version)return r.db&&(r.version=r.db.version+1),_e(r)}).then(function(){return ln(r).then(function(){oe(r,s,o,c-1)})}).catch(o);o(a)}}function nr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function un(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=r[c];var u=J[o.name];u||(u=nr(),J[o.name]=u),u.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=cn);var a=[];function f(){return m.resolve()}for(var p=0;p<u.forages.length;p++){var g=u.forages[p];g!==s&&a.push(g._initReady().catch(f))}var v=u.forages.slice(0);return m.all(a).then(function(){return o.db=u.db,ne(o)}).then(function(y){return o.db=y,Ce(o,s._defaultConfig.version)?_e(o):y}).then(function(y){o.db=u.db=y,s._dbInfo=o;for(var w=0;w<v.length;w++){var C=v[w];C!==s&&(C._dbInfo.db=o.db,C._dbInfo.version=o.version)}})}function dn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.get(r);v.onsuccess=function(){var y=v.result;y===void 0&&(y=null),rr(y)&&(y=me(y)),u(y)},v.onerror=function(){a(v.error)}}catch(y){a(y)}})}).catch(a)});return b(c,s),c}function fn(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.openCursor(),y=1;v.onsuccess=function(){var w=v.result;if(w){var C=w.value;rr(C)&&(C=me(C));var O=r(C,w.key,y++);O!==void 0?u(O):w.continue()}else u()},v.onerror=function(){a(v.error)}}catch(w){a(w)}})}).catch(a)});return b(c,s),c}function mn(r,s,o){var c=this;r=N(r);var u=new m(function(a,f){var p;c.ready().then(function(){return p=c._dbInfo,yt.call(s)==="[object Blob]"?U(p.db).then(function(g){return g?s:bt(s)}):s}).then(function(g){oe(c._dbInfo,T,function(v,y){if(v)return f(v);try{var w=y.objectStore(c._dbInfo.storeName);g===null&&(g=void 0);var C=w.put(g,r);y.oncomplete=function(){g===void 0&&(g=null),a(g)},y.onabort=y.onerror=function(){var O=C.error?C.error:C.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return b(u,o),u}function hn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,T,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.delete(r);p.oncomplete=function(){u()},p.onerror=function(){a(v.error)},p.onabort=function(){var y=v.error?v.error:v.transaction.error;a(y)}}catch(y){a(y)}})}).catch(a)});return b(c,s),c}function pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,T,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.clear();f.oncomplete=function(){c()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;u(v)}}catch(v){u(v)}})}).catch(u)});return b(o,r),o}function gn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,ue,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.count();g.onsuccess=function(){c(g.result)},g.onerror=function(){u(g.error)}}catch(v){u(v)}})}).catch(u)});return b(o,r),o}function vn(r,s){var o=this,c=new m(function(u,a){if(r<0){u(null);return}o.ready().then(function(){oe(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=!1,y=g.openKeyCursor();y.onsuccess=function(){var w=y.result;if(!w){u(null);return}r===0||v?u(w.key):(v=!0,w.advance(r))},y.onerror=function(){a(y.error)}}catch(w){a(w)}})}).catch(a)});return b(c,s),c}function yn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,ue,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.openKeyCursor(),v=[];g.onsuccess=function(){var y=g.result;if(!y){c(v);return}v.push(y.key),y.continue()},g.onerror=function(){u(g.error)}}catch(y){u(y)}})}).catch(u)});return b(o,r),o}function bn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,u;if(!r.name)u=m.reject("Invalid arguments");else{var a=r.name===o.name&&c._dbInfo.db,f=a?m.resolve(c._dbInfo.db):ne(r).then(function(p){var g=J[r.name],v=g.forages;g.db=p;for(var y=0;y<v.length;y++)v[y]._dbInfo.db=p;return p});r.storeName?u=f.then(function(p){if(p.objectStoreNames.contains(r.storeName)){var g=p.version+1;G(r);var v=J[r.name],y=v.forages;p.close();for(var w=0;w<y.length;w++){var C=y[w];C._dbInfo.db=null,C._dbInfo.version=g}var O=new m(function(F,M){var B=A.open(r.name,g);B.onerror=function(Q){var Te=B.result;Te.close(),M(Q)},B.onupgradeneeded=function(){var Q=B.result;Q.deleteObjectStore(r.storeName)},B.onsuccess=function(){var Q=B.result;Q.close(),F(Q)}});return O.then(function(F){v.db=F;for(var M=0;M<y.length;M++){var B=y[M];B._dbInfo.db=F,z(B._dbInfo)}}).catch(function(F){throw(Y(r,F)||m.resolve()).catch(function(){}),F})}}):u=f.then(function(p){G(r);var g=J[r.name],v=g.forages;p.close();for(var y=0;y<v.length;y++){var w=v[y];w._dbInfo.db=null}var C=new m(function(O,F){var M=A.deleteDatabase(r.name);M.onerror=function(){var B=M.result;B&&B.close(),F(M.error)},M.onblocked=function(){console.warn('dropInstance blocked for database "'+r.name+'" until all open connections are closed')},M.onsuccess=function(){var B=M.result;B&&B.close(),O(B)}});return C.then(function(O){g.db=O;for(var F=0;F<v.length;F++){var M=v[F];z(M._dbInfo)}}).catch(function(O){throw(Y(r,O)||m.resolve()).catch(function(){}),O})})}return b(u,s),u}var _n={_driver:"asyncStorage",_initStorage:un,_support:I(),iterate:fn,getItem:dn,setItem:mn,removeItem:hn,clear:pn,length:gn,key:vn,keys:yn,dropInstance:bn};function En(){return typeof openDatabase=="function"}var se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tn="~~local_forage_type~",or=/^~~local_forage_type~([^~]+)~/,Pe="__lfsc__:",_t=Pe.length,Et="arbf",Tt="blob",ir="si08",sr="ui08",ar="uic8",cr="si16",lr="si32",ur="ur16",dr="ui32",fr="fl32",mr="fl64",hr=_t+Et.length,pr=Object.prototype.toString;function gr(r){var s=r.length*.75,o=r.length,c,u=0,a,f,p,g;r[r.length-1]==="="&&(s--,r[r.length-2]==="="&&s--);var v=new ArrayBuffer(s),y=new Uint8Array(v);for(c=0;c<o;c+=4)a=se.indexOf(r[c]),f=se.indexOf(r[c+1]),p=se.indexOf(r[c+2]),g=se.indexOf(r[c+3]),y[u++]=a<<2|f>>4,y[u++]=(f&15)<<4|p>>2,y[u++]=(p&3)<<6|g&63;return v}function It(r){var s=new Uint8Array(r),o="",c;for(c=0;c<s.length;c+=3)o+=se[s[c]>>2],o+=se[(s[c]&3)<<4|s[c+1]>>4],o+=se[(s[c+1]&15)<<2|s[c+2]>>6],o+=se[s[c+2]&63];return s.length%3===2?o=o.substring(0,o.length-1)+"=":s.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function In(r,s){var o="";if(r&&(o=pr.call(r)),r&&(o==="[object ArrayBuffer]"||r.buffer&&pr.call(r.buffer)==="[object ArrayBuffer]")){var c,u=Pe;r instanceof ArrayBuffer?(c=r,u+=Et):(c=r.buffer,o==="[object Int8Array]"?u+=ir:o==="[object Uint8Array]"?u+=sr:o==="[object Uint8ClampedArray]"?u+=ar:o==="[object Int16Array]"?u+=cr:o==="[object Uint16Array]"?u+=ur:o==="[object Int32Array]"?u+=lr:o==="[object Uint32Array]"?u+=dr:o==="[object Float32Array]"?u+=fr:o==="[object Float64Array]"?u+=mr:s(new Error("Failed to get type for BinaryArray"))),s(u+It(c))}else if(o==="[object Blob]"){var a=new FileReader;a.onload=function(){var f=Tn+r.type+"~"+It(this.result);s(Pe+Tt+f)},a.readAsArrayBuffer(r)}else try{s(JSON.stringify(r))}catch(f){console.error("Couldn't convert value into a JSON string: ",r),s(null,f)}}function wn(r){if(r.substring(0,_t)!==Pe)return JSON.parse(r);var s=r.substring(hr),o=r.substring(_t,hr),c;if(o===Tt&&or.test(s)){var u=s.match(or);c=u[1],s=s.substring(u[0].length)}var a=gr(s);switch(o){case Et:return a;case Tt:return x([a],{type:c});case ir:return new Int8Array(a);case sr:return new Uint8Array(a);case ar:return new Uint8ClampedArray(a);case cr:return new Int16Array(a);case ur:return new Uint16Array(a);case lr:return new Int32Array(a);case dr:return new Uint32Array(a);case fr:return new Float32Array(a);case mr:return new Float64Array(a);default:throw new Error("Unkown type: "+o)}}var wt={serialize:In,deserialize:wn,stringToBuffer:gr,bufferToString:It};function vr(r,s,o,c){r.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,c)}function Sn(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=typeof r[c]!="string"?r[c].toString():r[c];var u=new m(function(a,f){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(p){return f(p)}o.db.transaction(function(p){vr(p,o,function(){s._dbInfo=o,a()},function(g,v){f(v)})},f)});return o.serializer=wt,u}function ae(r,s,o,c,u,a){r.executeSql(o,c,u,function(f,p){p.code===p.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(g,v){v.rows.length?a(g,p):vr(g,s,function(){g.executeSql(o,c,u,a)},a)},a):a(f,p)},a)}function An(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ae(p,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[r],function(g,v){var y=v.rows.length?v.rows.item(0).value:null;y&&(y=f.serializer.deserialize(y)),u(y)},function(g,v){a(v)})})}).catch(a)});return b(c,s),c}function Rn(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ae(p,f,"SELECT * FROM "+f.storeName,[],function(g,v){for(var y=v.rows,w=y.length,C=0;C<w;C++){var O=y.item(C),F=O.value;if(F&&(F=f.serializer.deserialize(F)),F=r(F,O.key,C+1),F!==void 0){u(F);return}}u()},function(g,v){a(v)})})}).catch(a)});return b(c,s),c}function yr(r,s,o,c){var u=this;r=N(r);var a=new m(function(f,p){u.ready().then(function(){s===void 0&&(s=null);var g=s,v=u._dbInfo;v.serializer.serialize(s,function(y,w){w?p(w):v.db.transaction(function(C){ae(C,v,"INSERT OR REPLACE INTO "+v.storeName+" (key, value) VALUES (?, ?)",[r,y],function(){f(g)},function(O,F){p(F)})},function(C){if(C.code===C.QUOTA_ERR){if(c>0){f(yr.apply(u,[r,g,o,c-1]));return}p(C)}})})}).catch(p)});return b(a,o),a}function xn(r,s,o){return yr.apply(this,[r,s,o,1])}function kn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ae(p,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[r],function(){u()},function(g,v){a(v)})})}).catch(a)});return b(c,s),c}function Cn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ae(f,a,"DELETE FROM "+a.storeName,[],function(){c()},function(p,g){u(g)})})}).catch(u)});return b(o,r),o}function Pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ae(f,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(p,g){var v=g.rows.item(0).c;c(v)},function(p,g){u(g)})})}).catch(u)});return b(o,r),o}function Dn(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ae(p,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[r+1],function(g,v){var y=v.rows.length?v.rows.item(0).key:null;u(y)},function(g,v){a(v)})})}).catch(a)});return b(c,s),c}function On(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ae(f,a,"SELECT key FROM "+a.storeName,[],function(p,g){for(var v=[],y=0;y<g.rows.length;y++)v.push(g.rows.item(y).key);c(v)},function(p,g){u(g)})})}).catch(u)});return b(o,r),o}function Fn(r){return new m(function(s,o){r.transaction(function(c){c.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(u,a){for(var f=[],p=0;p<a.rows.length;p++)f.push(a.rows.item(p).name);s({db:r,storeNames:f})},function(u,a){o(a)})},function(c){o(c)})})}function Nn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,u;return r.name?u=new m(function(a){var f;r.name===o.name?f=c._dbInfo.db:f=openDatabase(r.name,"","",0),r.storeName?a({db:f,storeNames:[r.storeName]}):a(Fn(f))}).then(function(a){return new m(function(f,p){a.db.transaction(function(g){function v(O){return new m(function(F,M){g.executeSql("DROP TABLE IF EXISTS "+O,[],function(){F()},function(B,Q){M(Q)})})}for(var y=[],w=0,C=a.storeNames.length;w<C;w++)y.push(v(a.storeNames[w]));m.all(y).then(function(){f()}).catch(function(O){p(O)})},function(g){p(g)})})}):u=m.reject("Invalid arguments"),b(u,s),u}var Un={_driver:"webSQLStorage",_initStorage:Sn,_support:En(),iterate:Rn,getItem:An,setItem:xn,removeItem:kn,clear:Cn,length:Pn,key:Dn,keys:On,dropInstance:Nn};function Ln(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function br(r,s){var o=r.name+"/";return r.storeName!==s.storeName&&(o+=r.storeName+"/"),o}function Bn(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Mn(){return!Bn()||localStorage.length>0}function $n(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=br(r,s._defaultConfig),Mn()?(s._dbInfo=o,o.serializer=wt,m.resolve()):m.reject()}function Vn(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo.keyPrefix,u=localStorage.length-1;u>=0;u--){var a=localStorage.key(u);a.indexOf(c)===0&&localStorage.removeItem(a)}});return b(o,r),o}function jn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo,a=localStorage.getItem(u.keyPrefix+r);return a&&(a=u.serializer.deserialize(a)),a});return b(c,s),c}function Kn(r,s){var o=this,c=o.ready().then(function(){for(var u=o._dbInfo,a=u.keyPrefix,f=a.length,p=localStorage.length,g=1,v=0;v<p;v++){var y=localStorage.key(v);if(y.indexOf(a)===0){var w=localStorage.getItem(y);if(w&&(w=u.serializer.deserialize(w)),w=r(w,y.substring(f),g++),w!==void 0)return w}}});return b(c,s),c}function Jn(r,s){var o=this,c=o.ready().then(function(){var u=o._dbInfo,a;try{a=localStorage.key(r)}catch{a=null}return a&&(a=a.substring(u.keyPrefix.length)),a});return b(c,s),c}function Gn(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo,u=localStorage.length,a=[],f=0;f<u;f++){var p=localStorage.key(f);p.indexOf(c.keyPrefix)===0&&a.push(p.substring(c.keyPrefix.length))}return a});return b(o,r),o}function Hn(r){var s=this,o=s.keys().then(function(c){return c.length});return b(o,r),o}function Wn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+r)});return b(c,s),c}function zn(r,s,o){var c=this;r=N(r);var u=c.ready().then(function(){s===void 0&&(s=null);var a=s;return new m(function(f,p){var g=c._dbInfo;g.serializer.serialize(s,function(v,y){if(y)p(y);else try{localStorage.setItem(g.keyPrefix+r,v),f(a)}catch(w){(w.name==="QuotaExceededError"||w.name==="NS_ERROR_DOM_QUOTA_REACHED")&&p(w),p(w)}})})});return b(u,o),u}function Yn(r,s){if(s=K.apply(this,arguments),r=typeof r!="function"&&r||{},!r.name){var o=this.config();r.name=r.name||o.name,r.storeName=r.storeName||o.storeName}var c=this,u;return r.name?u=new m(function(a){r.storeName?a(br(r,c._defaultConfig)):a(r.name+"/")}).then(function(a){for(var f=localStorage.length-1;f>=0;f--){var p=localStorage.key(f);p.indexOf(a)===0&&localStorage.removeItem(p)}}):u=m.reject("Invalid arguments"),b(u,s),u}var qn={_driver:"localStorageWrapper",_initStorage:$n,_support:Ln(),iterate:Kn,getItem:jn,setItem:zn,removeItem:Wn,clear:Vn,length:Hn,key:Jn,keys:Gn,dropInstance:Yn},Qn=function(s,o){return s===o||typeof s=="number"&&typeof o=="number"&&isNaN(s)&&isNaN(o)},Xn=function(s,o){for(var c=s.length,u=0;u<c;){if(Qn(s[u],o))return!0;u++}return!1},_r=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"},Ee={},Er={},he={INDEXEDDB:_n,WEBSQL:Un,LOCALSTORAGE:qn},Zn=[he.INDEXEDDB._driver,he.WEBSQL._driver,he.LOCALSTORAGE._driver],De=["dropInstance"],St=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(De),eo={description:"",driver:Zn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function to(r,s){r[s]=function(){var o=arguments;return r.ready().then(function(){return r[s].apply(r,o)})}}function At(){for(var r=1;r<arguments.length;r++){var s=arguments[r];if(s)for(var o in s)s.hasOwnProperty(o)&&(_r(s[o])?arguments[0][o]=s[o].slice():arguments[0][o]=s[o])}return arguments[0]}var ro=function(){function r(s){_(this,r);for(var o in he)if(he.hasOwnProperty(o)){var c=he[o],u=c._driver;this[o]=u,Ee[u]||this.defineDriver(c)}this._defaultConfig=At({},eo),this._config=At({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return r.prototype.config=function(o){if((typeof o>"u"?"undefined":h(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var c in o){if(c==="storeName"&&(o[c]=o[c].replace(/\W/g,"_")),c==="version"&&typeof o[c]!="number")return new Error("Database version must be a number.");this._config[c]=o[c]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},r.prototype.defineDriver=function(o,c,u){var a=new m(function(f,p){try{var g=o._driver,v=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){p(v);return}for(var y=St.concat("_initStorage"),w=0,C=y.length;w<C;w++){var O=y[w],F=!Xn(De,O);if((F||o[O])&&typeof o[O]!="function"){p(v);return}}var M=function(){for(var Te=function(io){return function(){var so=new Error("Method "+io+" is not implemented by the current driver"),Tr=m.reject(so);return b(Tr,arguments[arguments.length-1]),Tr}},Rt=0,oo=De.length;Rt<oo;Rt++){var xt=De[Rt];o[xt]||(o[xt]=Te(xt))}};M();var B=function(Te){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Er[g]=Te,f()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(B,p):B(!!o._support):B(!0)}catch(Q){p(Q)}});return k(a,c,u),a},r.prototype.driver=function(){return this._driver||null},r.prototype.getDriver=function(o,c,u){var a=Ee[o]?m.resolve(Ee[o]):m.reject(new Error("Driver not found."));return k(a,c,u),a},r.prototype.getSerializer=function(o){var c=m.resolve(wt);return k(c,o),c},r.prototype.ready=function(o){var c=this,u=c._driverSet.then(function(){return c._ready===null&&(c._ready=c._initDriver()),c._ready});return k(u,o,o),u},r.prototype.setDriver=function(o,c,u){var a=this;_r(o)||(o=[o]);var f=this._getSupportedDrivers(o);function p(){a._config.driver=a.driver()}function g(w){return a._extend(w),p(),a._ready=a._initStorage(a._config),a._ready}function v(w){return function(){var C=0;function O(){for(;C<w.length;){var F=w[C];return C++,a._dbInfo=null,a._ready=null,a.getDriver(F).then(g).catch(O)}p();var M=new Error("No available storage method found.");return a._driverSet=m.reject(M),a._driverSet}return O()}}var y=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=y.then(function(){var w=f[0];return a._dbInfo=null,a._ready=null,a.getDriver(w).then(function(C){a._driver=C._driver,p(),a._wrapLibraryMethodsWithReady(),a._initDriver=v(f)})}).catch(function(){p();var w=new Error("No available storage method found.");return a._driverSet=m.reject(w),a._driverSet}),k(this._driverSet,c,u),this._driverSet},r.prototype.supports=function(o){return!!Er[o]},r.prototype._extend=function(o){At(this,o)},r.prototype._getSupportedDrivers=function(o){for(var c=[],u=0,a=o.length;u<a;u++){var f=o[u];this.supports(f)&&c.push(f)}return c},r.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,c=St.length;o<c;o++)to(this,St[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),no=new ro;l.exports=no},{3:3}]},{},[4])(4)})});var Ar=Object.defineProperty,go=Object.getOwnPropertyDescriptor,vo=(e,t)=>{for(var n in t)Ar(e,n,{get:t[n],enumerable:!0})},Rr=(e,t,n,i)=>{for(var l=i>1?void 0:i?go(t,n):t,d=e.length-1,h;d>=0;d--)(h=e[d])&&(l=(i?h(t,n,l):h(l))||l);return i&&l&&Ar(t,n,l),l};function yo(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ot(e){return typeof e=="string"}function xr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function kr(e){return typeof e=="object"&&Array.isArray(e)}function bo(e){return typeof e>"u"}function _o(e){return bo(e)||e===null}function Eo(e){return typeof e=="function"}function Cr(e){let t=e,n=null,i=function(...l){return n||(n=new t(...l)),n};return i.prototype=t.prototype,i}function Pr(e,t,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function i(l,d){for(let h in d)if(Object.prototype.hasOwnProperty.call(d,h)){let _=l[h],E=d[h],A=n(_,E,h,l,d);A!==void 0?l[h]=A:wr(E)&&wr(_)?l[h]=i({..._},E):Array.isArray(E)&&Array.isArray(_)?l[h]=[..._,...E]:l[h]=E}return l}return i(e,t)}function wr(e){return e&&typeof e=="object"&&e.constructor===Object}function Dr(e,t){if(Array.isArray(e))return e.concat(t)}function Ae(e,t,n={}){let i=null,l,d,h,{leading:_=!1,trailing:E=!0}=n,A=()=>(h=e.apply(d,l),l=void 0,d=void 0,h),I=function(...x){l=x,d=this;let m=_&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,E&&!m&&A()},t),m)return A()};return I.cancel=()=>{i&&clearTimeout(i),i=null,l=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,A()},I}var To=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(To||{}),Ft=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Nt=class extends Ft{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Or=class extends Ft{constructor(){super(...arguments),this.kind="USER_ERROR"}},Fr=class extends Or{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}};var Io=class extends Or{constructor(e,t,n){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,n&&(this.extra=Object.assign({},this.extra,n))}};var Nr=class extends Nt{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Ur=class extends Nt{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Be=class extends Ft{constructor(e,t,n,i,l){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",n&&(this.errorType=n),i!==void 0&&(this.stack=i),l&&(this.priority=l)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};var Ut=class extends Nt{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function wo(e,t){return(...n)=>t(e,...n)}function Lr(e){return t=>wo(t,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(l){e(new Io(`${l}`))}})}function we(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var H={log:we("log"),warn:we("warn"),info:we("info"),error:we("error"),debug:we("debug")};Object.assign(globalThis,{logger:H});var Br=Symbol.for("Jolibox.canIUseMap"),So={};globalThis[Br]=So;var Lt={get config(){return globalThis[Br]}};var Re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Re||{}),pe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(pe||{}),Ao=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Ao||{}),Sr=["name","params"],Ro=["name","type","location","target","extra","timestamp","userId"],xo=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function Ne(e,t){return t.map(n=>{if(n==="params"&&e[n]){let i=e[n];return Object.keys(i).reduce((l,d)=>(l[d]=String(i[d]),l),{})}return e[n]})}function ko(e){let t=e.location?Ne(e.location,Sr):null,n=e.target?Ne(e.target,Sr):null;return Ne({...e,location:t,target:n},Ro)}function Bt(e){let t=e.events.map(i=>ko(i)),n=Ne(e.device,xo);return[e.protocolVersion,t,n,e.project]}var Co=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var Oe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Po=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",Do="device_id",Oo="advertising_id",Mr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Co()),localStorage.getItem(e)),Mt=()=>Mr(Do),Fo=()=>Mr(Oo),No=e=>e.charAt(0).toUpperCase()+e.slice(1),Uo=()=>{let e=new URLSearchParams(window.location.search);return No(e.get("utm_source")??"")||"JoliboxSDK"},$r=e=>{let t="JoliboxWebSDK",n=Po(),i=navigator.language,l=Mt(),d=Fo();return`${t} (${Uo()}${n}; UnknownModel; UnknownSystemVersion; ${i}) uuid/${l} adid/${d} version/${e||""}`},L=class Ue{static{this.Undefined=new Ue(void 0)}constructor(t){this.element=t,this.next=Ue.Undefined,this.prev=Ue.Undefined}},Lo=class{constructor(){this._first=L.Undefined,this._last=L.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new L(e);if(this._first===L.Undefined)this._first=n,this._last=n;else if(t){let l=this._last;this._last=n,n.prev=l,l.next=n}else{let l=this._first;this._first=n,n.next=l,l.prev=n}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(n))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}},Bo=0,Fe=class{constructor(e){this.value=e,this.id=Bo++}},Se=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Fe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let n=new Fe(e);this._listeners?this._listeners instanceof Fe?this._listeners=[this._listeners,n]:this._listeners.push(n):(this.options?.onWillAddFirstListener?.(this),this._listeners=n,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let n=this.options?.onListenerError||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Fe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let n=this.listeners.get(e)??new Se,i=d=>t(...d.args);this.listerHandlerMap.set(t,i),n.event(i),this.listeners.set(e,n);let l=this.cachedEventQueue.get(e);if(l)for(;l.size>0;)n.fire({event:e,...l.shift()})}off(e,t){let n=this.listeners.get(e);if(n){let i=this.listerHandlerMap.get(t);n.dispose(i)}}emit(e,...t){let n=this.listeners.get(e);if(n)n.fire({event:e,args:t});else{let i=this.cachedEventQueue.get(e);i||(i=new Lo,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},Pt={};vo(Pt,{None:()=>Mo,filter:()=>Vo,once:()=>Vr,toPromise:()=>$o});var Mo=()=>{console.log("[Jolibox SDK] None Event")};function $o(e){return new Promise(t=>Vr(e)(t))}function Vr(e){return(t,n=null)=>{let i=!1;return e(l=>{if(!i)return i=!0,t.call(n,l)},null)}}function Vo(e,t){return(n=>{let i,l={onWillAddFirstListener(){i=n(d.fire,d)}},d=new Se(l);return d.event})((n,i=null)=>e(l=>t(l)&&n.call(i,l),null))}var kt=Symbol.for("Jolibox.hostEmitter"),jo=()=>{let e=new ce;return globalThis[kt]||(globalThis[kt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[kt]},xe=jo();function Ko(e,t){let n=Math.min(e.length,t.length);for(let i=0;i<n;i++)Jo(e[i],t[i])}function Jo(e,t){if(Ot(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Eo(t)){try{if(e instanceof t)return}catch{}if(!_o(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var Le=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Se,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let n=[];for(let l of e.metadata.args)n.push(l.constraint);let i=e.handler;e.handler=function(...l){return Ko(l,n),i(...l)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let n=this.getCommand(t);n&&e.set(t,n)}return e}};Le=Rr([Cr],Le);var Dt=class{constructor(){this._onWillExecuteCommand=new Se,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Se,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Le,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=yo(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),Pt.toPromise(Pt.filter(this.registry.onDidRegisterCommand,n=>n===e))])]),this._tryExecuteCommand(e,t))}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let n=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(n.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_tryExecuteCommand(e,t){let n=this.registry.getCommand(e);if(!n)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(n.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(i)}catch(i){return Promise.reject(i)}}invokeFunction(e,...t){let n=!1;try{return e(...t)}finally{n=!0}}};Dt=Rr([Cr],Dt);var Ct=Symbol.for("Jolibox.commands");function X(){if(globalThis[Ct])return globalThis[Ct];let e=new Le,t=new Dt,n={registerCommand(i,l,d){e.registerCommand({id:i,handler:l,metadata:d})},executeCommand(i,...l){return t.executeCommand(i,...l)},excuteCommandSync(i,...l){return t.executeCommandThowErr(i,...l)}};return globalThis[Ct]=n,n}var $t=new ce,de=new ce;function ee(e,t={}){$t.emit("ERROR_REPORT",{error:e,options:t})}ee.debounce=Ae(ee,50,{leading:!0});var Vt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4),i=atob(t+n);try{return JSON.parse(i)}catch{return{}}},jr=e=>{try{let i=new URL(e).searchParams.get("joliSource")?.split(".");if(i?.length){let[l,d,h]=i;return{headerJson:Vt(l),payloadJson:Vt(d),signature:Vt(h)}}else throw"joli_source is missing"}catch(t){return ee(new Nr(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}};var Go="1.1.7-beta.3",Me=()=>Go,Kr=()=>{let e=Me();return`${$r(e)}`};var Ho={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Mt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Me()},schema:window.location.href,platform:"h5"},Wo=globalThis.joliboxJSCore?.env,W=Object.assign({},Wo?.()??Ho),zo=()=>{let{payloadJson:e,headerJson:t}=W.schema.length?jr(W.schema):{},n=`${W.deviceInfo.did}-${new Date().getTime()}`,l=new URL(W.schema.length?W.schema:window.location.href).searchParams,d=l.get("mpId")??l.get("appId")??l.get("gameId")??"",h=e?.sessionId??l.get("sessionId")??n,_=!!(e?.testAdsMode??l.get("testAdsMode")==="true"),E=e?.joliboxEnv??l.get("joliboxEnv")??"production",A=E==="staging",I=t?.channel;return{get testMode(){return A},get testAdsMode(){return _},get joliboxEnv(){return E},get joliSource(){return l.get("joliSource")??null},get mpId(){return d??e?.id??""},get mpVersion(){return t?.ver??Me()},get platform(){return W.platform??W.deviceInfo.platform},get deviceInfo(){return W.deviceInfo},get sdkInfo(){return W.sdkInfo},get hostInfo(){return W.hostInfo},get hostUserInfo(){return W.hostUserInfo},get sessionId(){return W.clientSessionId??h??n},get channel(){return I},get webviewId(){return W.webviewId??-1},onEnvConfigChanged:x=>{Pr(W,x,Dr)}}},R=zo();var jt=!1,Gr=(e,t)=>e==null?!1:t in e,Yo=e=>Gr(e,"kind"),qo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Jr=(e,t={},n)=>{let l={...{user_id:R.hostUserInfo?.uid??"",device_id:R.deviceInfo.did??"",timestamp:Date.now(),tag:qo(e.name)},env:t.environment,isFromUser:n};n?de.emit("GLOBAL_USER_ERROR",e,l):de.emit("GLOBAL_ERROR",e,l)},Qo=e=>Gr(e,"kind")&&e.kind==="USER_ERROR";$t.on("ERROR_REPORT",({error:e,options:t})=>{if(jt)return;jt=!0;let n=Yo(e)&&e.raw?e.raw:e;try{let i=Qo(e);Jr(e,t,i)}catch(i){let l=i instanceof Error?i.message:String(i),d=new Ut(`${l}, origin error: ${n.message}`);H.error(d),Jr(new Ut(d.message),{environment:t.environment},!1)}finally{jt=!1}});var Kt=e=>new Fr(e);function Hr(e,t){let n=(i,l,d)=>{let h={tag:i,...t,extra:{...l}};i=="globalJsError"?ee(new Ur(JSON.stringify(h))):e("systemLog",h,d)};return n.debounce=Ae(n,500,{leading:!0}),n}function Wr(e){let t=(n,i,l)=>{let d=(l&&JSON.stringify(l))??0,h={speed_value_type:n,total_duration:i};d&&Object.assign(h,{extra:d}),e("joliboxSpeedAnalysis",h)};return t.debounce=Ae(t,500,{leading:!0}),t}function zr(e,t){let n=Hr(e,t),i=Wr(n);return{track:n,trackPerformance:i}}var $e=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.samplesConfig=null;this.pushPastTracking=t=>{this.pastTrackings.push(t),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)};this.fetchSamplesConfig()}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}async fetchSamplesConfig(){let n=`${R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/samples-config`,i=await(await fetch(n)).json();this.samplesConfig=i}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:n}=this.samplesConfig;for(let[i,l]of Object.entries(n))if(l.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(i);return!1}getDevice(){let{nativeSDKVersion:t,jssdkVersion:n}=R.sdkInfo;return{platform:1e3,os:R.deviceInfo.platform,appVersion:t??n??"1.0.0",appId:R.hostInfo?.aid??"1",model:R.deviceInfo.model??"UnknownModel",brand:R.deviceInfo.brand??"UnknownBrand",uuid:R.deviceInfo.did,jsSdkVersion:n,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),n={};return t.forEach((i,l)=>{n[l]=i}),{name:"GamePage",params:n}}async trackEvent(t,n,i){if(this.checkIsSampled(t))return;let l=t.location?t.location:await this.getLocation(),d=t.target||null,h=t.extra||null;this.deviceInfo||(this.deviceInfo=await this.getDevice());let _=this.deviceInfo,A={protocolVersion:"1.0.0",events:[{...t,location:l,target:d,extra:h,timestamp:Date.now(),userId:null}],device:_,project:n};try{i?this.doReport(Bt(A),i):this.doReport(Bt(A)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),H.log("[Jolibox SDK] report API error",I)}}};var Jt=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};AbortSignal.timeout??=Jt;var Ve=class{constructor(t){this.xua=Kr();this.getJoliSource=()=>R.joliSource;let n=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=t?.baseUrl??n}async get(t,n){let{query:i,timeout:l}=n??{},{headers:d}=n??{},_=(i?new URLSearchParams(i):null)?.toString(),E=`${this.baseUrl}${t}${_?`?${_}`:""}`,A=this.xua,I=this.getJoliSource();return d=Object.assign({},d??{},A?{"x-user-agent":A}:{},I?{"x-joli-source":I}:{}),await(await fetch(E,{method:"GET",headers:d,credentials:"include",signal:Jt(l??3e4)})).json()}async post(t,n){let{data:i,query:l,timeout:d}=n??{},{headers:h}=n??{},E=(l?new URLSearchParams(l):null)?.toString(),A=`${this.baseUrl}${t}${E?`?${E}`:""}`,I=this.xua,x=this.getJoliSource();h=Object.assign({},h??{},{"Content-Type":"application/json"},I?{"x-user-agent":I}:{},x?{"x-joli-source":x}:{});let m=await fetch(A,{method:"POST",headers:h,body:JSON.stringify(i),signal:Jt(d??3e4),credentials:"include"}),b=m.headers.get("content-type");if(b?.includes("application/octet-stream"))try{return m.blob()}catch{return await m.arrayBuffer()}if(b?.includes("multipart/form-data")||b?.includes("application/x-www-form-urlencoded"))try{return m.formData()}catch{return await m.text()}if(b?.includes("application/json"))try{return await m.json()}catch{return await m.text()}return m}async put(t,n){try{let{data:i,query:l,timeout:d}=n??{},{headers:h}=n??{},E=(l?new URLSearchParams(l):null)?.toString(),A=`${this.baseUrl}${t}${E?`?${E}`:""}`,I=this.xua,x=this.getJoliSource();h=Object.assign({},h??{},{"Content-Type":"application/json"},I?{"x-user-agent":I}:{},x?{"x-joli-source":x}:{});let m=await fetch(A,{method:"PUT",headers:h,credentials:"include",body:JSON.stringify(i??{})});if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);return await m.json()}catch(i){throw console.error("Error:",i),i}}};window.JoliboxHttpClient=Ve;var le=Ve;var Gt=class extends $e{constructor(){super(...arguments);this.hostToApiMap={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}};this.httpClient=new le({baseUrl:this.apiBaseURL})}get apiBaseURL(){let n=this.hostToApiMap[window.location.host]??this.hostToApiMap.default;return R.testMode??!1?n.test:n.prod}doReport(n){this.httpClient.post("/report",{data:n,timeout:5e3}),H.info("Track",n)}},ge=new Gt;var Xo=(e,t)=>{let n={message:t.message,stack:t.stack??"",errorType:t.name,source:0},i={name:e,type:Re.ErrorTrace,location:null,target:null,extra:n,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ge.trackEvent(i,pe.WebSDK)};de.on("GLOBAL_ERROR",(e,t)=>{Xo(t.tag,e)});de.on("GLOBAL_USER_ERROR",(e,t)=>{H.log("UserError",e,t)});var je=class{constructor(t,n){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=n??5*1e3,t.on("visible",i=>{this.visible=i})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration:t??0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let n=Date.now(),i,l,d=!1,h=0,_=()=>{if(!d)return;let b=Date.now(),k=b-n;k>=this.interval&&(this.visible&&(h+=k,t(h)),n=b),i=requestAnimationFrame(_)},E=()=>{I(),n=Date.now(),l=window.setInterval(()=>{if(!d)return;let b=Date.now();b-n>=this.interval&&(n=b)},this.interval)},A=()=>{x(),n=Date.now(),i=requestAnimationFrame(_)},I=()=>{i&&(cancelAnimationFrame(i),i=0)},x=()=>{l&&(clearInterval(l),l=0)};this.eventEmitter.on("visible",b=>{d&&(console.log("visible",b),b?A():E())});let m=this.visible;return{start(){d||(d=!0,m?A():E())},stop(){d=!1,I(),x()}}}};var Ke=class extends je{constructor(n,i,l){super(i,l);this.httpClient=new le;this.gameId=R.mpId,this.sessionId=R.sessionId,this.track=n}async reporter(n){let{event:i,params:l}=n;await this.httpClient.post("/api/base/app-event",{data:{eventType:i,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...l}}}),H.log("-----task tracker-----",i,l)}tracker(n,i=null){this.track(n,i)}};var Yr=X(),Zo={type:pe.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:ve,trackPerformance:ei}=zr((...e)=>{let[,t]=e,n=t,l={...xr(n.extra)?n.extra:Ot(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""},d={name:t.tag,type:Re.System,location:null,target:null,extra:l,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ge.trackEvent(d,pe.WebSDK)},Zo);Yr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:n})=>{ei(e,t,n)});Yr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{ve(e,t)});var Ht=new ce,te=new Ke(ve,Ht);function qr(e){let t=Lt.config[e];return t||(t={},Lt.config[e]=t),(n,i)=>{if(t[n]){H.warn(`[can i use] ${n} already registered`);return}t[n]={...i}}}var Qr=!1;function Wt(e){Qr=e}function Je(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Je(t)):Object.keys(e).reduce((t,n)=>(t[n]=Je(e[n]),t),{})}var $=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Qr)if(typeof t=="string")this.errors.push(t);else{let n=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?n+=" or undefined, ":n+=", ",n+=`but got ${zt(t.actual)}`,this.errors.push(n)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Je(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Je(this._default)}optional(){return this._optional=!0,this}};function ie(e){return typeof e=="number"}function zt(e){let t=Yt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Yt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Ge=class extends ${validate(t){return this._optional&&t===void 0?!0:ie(t)?ie(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ie(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ie(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},He=class extends ${validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},We=class extends ${validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ie(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ie(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},ze=class extends ${validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ye=class extends ${validate(t){return!0}},Ye=class extends ${validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},qe=class extends ${validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Qe=class extends ${validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Xe=class extends ${constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let n=this._items.map(i=>JSON.stringify(i)).join(", ");return this.fail(`expect ${this.path} to be one of ${n}, but got ${zt(t)}`)}return!0}},Ze=class extends ${constructor(n){super();this._item=n}validate(n){if(this._optional&&n===void 0)return!0;if(!Array.isArray(n))return this.fail({expect:"array",actual:n});if(ie(this._minItems)&&n.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ie(this._maxItems)&&n.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ie(this._length)&&n.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let i=this._item;if(!i)return!0;let l=!0;if(n.forEach((d,h)=>{if(i.path=`${this.path}[${h}]`,i.errors=this.errors,d===void 0&&i.hasDefault){n[h]=i.defaultValue;return}i.validate(d)||(i.hasFallback?n[h]=i.fallbackValue:l=!1)}),this._uniqueItems){let d=new Map;for(let h in n)d.has(n[h])?l=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${d.get(n[h])}] and ${this.path}[${h}] are identical)`):d.set(n[h],h)}return l}minItems(n){return this._minItems=n,this}maxItems(n){return this._maxItems=n,this}uniqueItems(){return this._uniqueItems=!0,this}length(n){return this._length=n,this}},et=class extends ${constructor(n){super();this._value=n}validate(n){if(this._optional&&n===void 0)return!0;if(Yt(n)!=="object")return this.fail({expect:"object",actual:n});let l=n,d=this._value;d.errors=this.errors;let h=!0;for(let _ in l){let E=l[_];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(_)?d.path=`${this.path}.${_}`:d.path=`${this.path}["${_}"]`,!(E===void 0&&d._optional)){if(E===void 0&&d.hasDefault){l[_]=d.defaultValue;continue}d.validate(E)||(d.hasFallback?l[_]=d.fallbackValue:h=!1)}}return h}},tt=class extends ${constructor(n={}){super();this._object=n}validate(n){if(this._optional&&n===void 0)return!0;if(Yt(n)!=="object")return this.fail({expect:"object",actual:n});let i=n,l=!0;for(let d in this._object){let h=i[d],_=this._object[d];if(_.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?_.path=`${this.path}.${d}`:_.path=`${this.path}["${d}"]`,!(_._optional&&h===void 0)){if(h===void 0&&_.hasDefault){i[d]=_.defaultValue;continue}_.validate(h)||(_.hasFallback?i[d]=_.fallbackValue:l=!1)}}return l}},rt=class extends ${constructor(n){super();this.value=n}validate(n){return n===void 0&&this._optional?!0:n!==this.value?this.fail({expect:zt(this.value),actual:n}):!0}},nt=class extends ${constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let n=[],i=!1,l=this._items.length;for(let d=0;d<l;d++){let h=this._items[d];if(h.errors=[],h.path=this.path,!h.validate(t))n.push(h.errors.join("; "));else if(!i){i=!0;break}}if(!i){let d=n.join(`
2
- or `);this.errors.push(d)}return i}},ot=class extends ${constructor(...t){super(),this._items=t;let n=0,i=t.length-1;for(;i>=0;i--){let l=t[i];if(l._optional||l.hasDefault)n+=1;else break}this._minItems=t.length-n}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let n=!0;return this._items.forEach((i,l)=>{if(i.path=`${this.path}[${l}]`,i.errors=this.errors,t[l]===void 0&&i.hasDefault){t[l]=i.defaultValue;return}i.validate(t[l])||(i.hasFallback?t[l]=i._fallback:n=!1)}),n}},it=class extends ${validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},st=class extends ${constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}};var S={object(e){return new tt(e)},array(e){return new Ze(e)},tuple(...e){return new ot(...e)},literal(e){return new rt(e)},or(...e){return new nt(...e)},symbol(){return new ze},record(e){return new et(e)},function(){return new Qe},boolean(){return new He},string(){return new We},number(){return new Ge},undefined(){return new Ye},null(){return new qe},unknown(){return new ye},any(){return new ye},as(){return new ye},arraybuffer(){return new it},enum(...e){return new Xe(...e)},typedarray(e){return new st(e)}};function qt(e,t,n="param"){if(e.errors=[],e.path=n,Wt(!0),!e.validate(t)){let i=e.errors.join(`
3
- `);throw e.errors.length=0,Wt(!1),new TypeError(i)}}var at=1,Xr=e=>{function t(i,l){return(...d)=>{let h=Date.now(),_={method:i,trace_id:at};at+=1;let E="SUCCESS",A=`${i}:ok`,I=0;try{if(l.paramsSchema)try{qt(l.paramsSchema,d,"params")}catch(k){throw Kt(`${i}:fail ${k.message}`)}let x=l.implement(...d),m=x,b=`${i}:ok`;if(x&&"code"in x){let{code:k,data:N,message:K}=x;E=k,m=N,b=K}return{code:E,message:b,data:m}}catch(x){let m=x;I=m.code??m.errNo??2e3,E="FAILURE";let b=m.message??m.errMsg??`${x}`;return A=`${i}:${E} ${b.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Be(A,I)),{code:E,message:A}}finally{let x=Date.now()-h;e("apiInvoked",{..._,duration:x,status:E})}}}function n(i,l){return async(...d)=>{let h=kr(d)?d:[d],_=Date.now(),E={method:i,trace_id:at};at+=1;let A=`${i}:ok`,I="SUCCESS",x={code:I,message:A};try{if(l.paramsSchema)try{qt(l.paramsSchema,h,"params")}catch(k){throw Kt(k.message)}let b=await l.implement(...h);if(b&&"code"in b){let{code:k,data:N,message:K}=b;I=k,A=K,b=N}return Object.assign(x,{code:I,message:A,data:b}),x}catch(m){let b=m,k=b.code??b.errNo??2e3;I="FAILURE";let N=b.message??b.errMsg??`${m}`,K=`${i}:${I} ${N.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:I,message:K}),ee(new Be(K,k)),x}finally{let m=Date.now()-_;e("apiInvoked",{...E,duration:m,status:I})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:fe}=Xr(ve),j=qr("h5");var Zr=X(),ri="env",ni="getSystemInfoSync",oi=()=>{let e={system:R.deviceInfo.system,platform:R.deviceInfo.platform,brand:R.deviceInfo.brand,pixelRatio:R.deviceInfo.pixelRatio,language:R.deviceInfo.lang,version:R.sdkInfo.jssdkVersion,appName:R.hostInfo?.appName,SDKVersion:R.sdkInfo.nativeSDKVersion},t=R.hostInfo?.version;t&&(e={...e,version:t});let n=R.hostInfo?.appName;n&&(e={...e,appName:n});let i=R.sdkInfo?.jssdkVersion;return i&&(e={...e,SDKVersion:i}),e},ii=fe(ni,{implement:oi}),si=fe(ri,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Zr.registerCommand("API.env",si);Zr.registerCommand("API.getSystemInfoSync",ii);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var ai="onJoliboxShow",ci="onJoliboxHide",li="onReady",Xt=X(),Zt=Lr(ee),Qt=!0,ke=!0,ct=0,lt=Ht;function ui(){let e=Date.now();if(e-ct<100)return;ct=e;let t=document.visibilityState==="visible";t!==Qt&&(Qt=t,lt.emit("visible",Qt))}function en(e){let t=Date.now();t-ct<100||(ct=t,e==="focus"&&!ke?ke=!0:e==="blur"&&ke&&(ke=!1),lt.emit("visible",ke))}document.addEventListener("visibilitychange",ui);window.addEventListener("focus",()=>en("focus"));window.addEventListener("blur",()=>en("blur"));var di=fe(ai,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);lt.on("visible",n=>{n&&t()})}}),fi=fe(ci,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);lt.on("visible",n=>{!n&&t()})}}),mi=fe(li,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Xt.registerCommand("LifecycleSDK.onReady",mi);Xt.registerCommand("LifecycleSDK.onJoliboxShow",di);Xt.registerCommand("LifecycleSDK.onJoliboxHide",fi);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var nn=po(rn()),ut=X(),tr=class{constructor(){this.getGameId=()=>R.mpId;this.getItem=async t=>{let{code:n,data:i,message:l}=await this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),d=i?.value,h=l;return n!=="SUCCESS"&&(d=await this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",d),h+="fallback to localstorage"),{code:n,message:h,data:d&&d!=="undefined"?d:null}};this.setItem=async(t,n)=>{let i=typeof n=="string"?n:String(n),{code:l,message:d}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:i}});return await this.gameStore.setItem(t,i),{code:l,message:d}};this.removeItem=async t=>{await this.gameStore.removeItem(t);let{code:n,message:i}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:n,message:i}};this.clear=async()=>{await this.gameStore.clear();let{code:t,message:n}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:n}};this.gameId=this.getGameId(),this.httpClient=new le({baseUrl:R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}),this.gameStore=nn.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},dt=new tr,hi=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.getItem(e)}});ut.registerCommand("StorageSDK.getItem",hi);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var pi=Z("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),async implement(e,t){return await dt.setItem(e,t)}});ut.registerCommand("StorageSDK.setItem",pi);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var gi=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.removeItem(e)}});ut.registerCommand("StorageSDK.removeItem",gi);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var vi=Z("clearStorage",{async implement(){return await dt.clear()}});ut.registerCommand("StorageSDK.clear",vi);j("storage.clear",{version:"1.0.0"});var be=X(),yi=Z("levelFinished",{paramsSchema:S.tuple(S.string(),S.object({result:S.boolean(),duration:S.number()})),implement:async(e,t)=>{let{result:n,duration:i}=t;H.info("onLevelFinished",n,i),await Promise.all([te.reporter({event:"COMPLETE_GAME_LEVEL"}),te.tracker("LevelFinished",{levelId:e,result:n,duration:i})])}}),bi=Z("taskFinished",{paramsSchema:S.tuple(S.string(),S.object({duration:S.number()})),implement:async(e,t)=>{let{duration:n}=t;await te.tracker("TaskFinished",{duration:n,taskId:e})}}),_i=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(e,t)=>await te.tracker("LevelUpgrade",{name:t,levelId:e})}),Ei=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserLevel",{level:e})}),Ti=Z("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserScore",{score:e})}),Ii=Z("taskEvent",{paramsSchema:S.tuple(S.string(),S.object({tools:S.array(S.object({id:S.string(),name:S.string(),count:S.number(),description:S.string().optional(),price:S.object({amount:S.number(),unit:S.string()}).optional()})).optional(),awards:S.array(S.object({id:S.string(),name:S.string()})).optional()})),implement:async(e,t)=>{t.tools?.length&&await Promise.all([te.reporter({event:"USE_GAME_ITEM"}),te.tracker("UseGameItem",{taskId:e,...t})])}});be.registerCommand("TaskTrackerSDK.levelFinished",yi);be.registerCommand("TaskTrackerSDK.taskFinished",bi);be.registerCommand("TaskTrackerSDK.levelUpgrade",_i);be.registerCommand("TaskTrackerSDK.historyUserLevel",Ei);be.registerCommand("TaskTrackerSDK.historyUserScore",Ti);be.registerCommand("TaskTrackerSDK.taskEvent",Ii);j("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});j("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});j("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});j("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}});var ft=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",n=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};var on="jolibox-sdk-ads-callbreak-timestamps",mt=class{constructor(t,n){this.checkNetwork=t;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{try{let t=JSON.parse(window.localStorage.getItem(on)??"[]");Array.isArray(t)?this._callAdsTimestampsForTime=t:this._callAdsTimestampsForTime=[]}catch{this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let n=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:n,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&n-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let n=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:n,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&n-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let n=this.checkShouldBannedInitial();if(n)return n;let i=this.checkShouldBannedForSession(t);if(i)return i;let l=this.checkShouldBannedForTime(t);return l||"ALLOWED"};if(this.maxAllowedAdsForTime=n?.maxAllowedAdsForTime??8,this.bannedForTimeThreshold=n?.bannedForTimeThreshold??6e4,this.bannedReleaseTime=n?.bannedReleaseTime??6e4,this.maxAllowedAdsForSession=n?.maxAllowedAdsForSession??200,this.bannedForSessionThreshold=n?.bannedForSessionThreshold??6e5,this.initialThreshold=n?.initialThreshold??2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(on,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};var ht=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}async init(){try{this.configs=await this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch{}}shouldBypassCallingInterstitial(){let t;if(!this.configs)this.init(),t=!this.firstRun;else{let n=R.channel??"",l=this.configs[n]?.interstitialRate??1;t=Math.random()<l}return this.firstRun=!1,t}};var sn=new ce,pt=class{constructor(t,n,i){this.track=t;this.httpClient=n;this.checkNetwork=i;this.configured=!1;this.config={};this.getGameId=()=>R.mpId;this.getTestAdsMode=()=>R.testAdsMode;this.asyncLoad=async()=>{let t="ca-pub-7171363994453626",n,i,l=window.encodeURIComponent(window.btoa(this.getGameId()??"")),d=this.getTestAdsMode()??!1;try{let h=await this.httpClient.get("/public/ads",{query:{objectId:l,testAdsMode:`${d}`}});t=h.data?.clientId,n=h.data?.channelId,i=h.data?.unitId}catch(h){console.error("Failed to fetch client info",h)}this.clientId=t,this.channelId=n,this.unitId=i};this.asyncInit=async t=>{if(typeof window>"u")return;await this.asyncLoad();let n="google-adsense",i=this.getTestAdsMode()??!1;if(!document.getElementById(n)&&this.clientId){let l=document.createElement("script");l.id=n,l.async=!0,l.crossOrigin="anonymous",l.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,i&&l.setAttribute("data-adbreak-test","on"),this.channelId&&l.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(l),this.track("LoadAdsenseCompleted",null)}};this.push=(t={})=>{window.adsbygoogle.push(t)};this.adConfig=t=>{let{onReady:n,...i}=t;this.track("CallAdConfig",i),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){t.adBreakDone?.({breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let n=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(n){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",n),t.adBreakDone?.({breakType:t.type,breakName:n,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.track("PreventAdsCheating",{reason:n});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",n),t.adBreakDone?.({breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),this.track("PreventAdsCheating",{reason:n});return;default:break}let i=t.type,l=t.adBreakDone,d=_=>{this.adsActionDetection.adBreakIsShowing=!1,sn.emit("isAdShowing",!1),this.track("CallAdBreakDone",{breakType:_.breakType,breakName:_.breakName??"",breakFormat:_.breakFormat,breakStatus:_.breakStatus}),l&&l(_)};if(t.adBreakDone=d,t.type==="reward"){let _=t.beforeReward,E=I=>()=>{this.track("CallShowAdFn",null),I()},A=I=>{_&&_(E(I))};t.beforeReward=A}let h;switch(i){case"preroll":h={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":h={type:i,name:t.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,sn.emit("isAdShowing",!0),this.track("CallAdBreak",h),this.push(t),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=async t=>{if(this.track("CallAdUnit",{adFormat:t.adFormat?.toString()??null,fullWidthResponsive:t.fullWidthResponsive??null}),this.clientId||await this.asyncLoad(),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:n,slot:i,adFormat:l,fullWidthResponsive:d,style:h}=t,_;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?_=document.querySelector(n):_=n,!_)throw new Error("targeting element not found");let E=i;if(E||(E=this.unitId),!E)throw new Error("slot is required");let A=typeof l=="object"&&Array.isArray(l)?l.join(", "):l,I=document.createElement("ins");if(I.className="adsbygoogle",I.id="jolibox-ads",I.style.display="block",I.setAttribute("data-ad-client",this.clientId),I.setAttribute("data-ad-slot",E),A&&I.setAttribute("data-ad-format",A),d&&I.setAttribute("data-full-width-responsive",d),h&&I.setAttribute("style",h),this.getTestAdsMode()??!1){let m=document.createElement("div");m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.width="100%",m.style.height="100%",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.backgroundColor="rgba(0, 0, 0, 0.5)",m.style.color="white",m.innerHTML="Test Ad",I.style.position="relative",_.appendChild(I),I.appendChild(m)}else _.appendChild(I),new MutationObserver(b=>{b.forEach(k=>{if(k.type==="attributes"&&k.attributeName==="data-ad-status"){let N=I.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:N??"null"})}})}).observe(I,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new mt(i),this.adsActionDetection=new ft(this.track),this.channelPolicy=new ht(n)}init(t){this.track("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};var gt=X(),vt=new pt(ve,new le,()=>ge.networkIsOk);gt.registerCommand("AdsSDK.init",e=>{vt.init(e)});gt.registerCommand("AdsSDK.adConfig",e=>{vt.adConfig(e)});gt.registerCommand("AdsSDK.adBreak",e=>{vt.adBreak(e)});gt.registerCommand("AdsSDK.adUnit",e=>{vt.adUnit(e)});function wi(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),te.start(Date.now()-e)})}function an(){wi()}an();
1
+ var zo=Object.create;var Kt=Object.defineProperty,Yo=Object.defineProperties,qo=Object.getOwnPropertyDescriptor,Qo=Object.getOwnPropertyDescriptors,Xo=Object.getOwnPropertyNames,We=Object.getOwnPropertySymbols,Zo=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty,Wr=Object.prototype.propertyIsEnumerable;var Jr=(e,t,r)=>t in e?Kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,M=(e,t)=>{for(var r in t||(t={}))Gt.call(t,r)&&Jr(e,r,t[r]);if(We)for(var r of We(t))Wr.call(t,r)&&Jr(e,r,t[r]);return e},W=(e,t)=>Yo(e,Qo(t));var Ne=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var zr=(e,t)=>{var r={};for(var i in e)Gt.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&We)for(var i of We(e))t.indexOf(i)<0&&Wr.call(e,i)&&(r[i]=e[i]);return r};var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var Yr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ei=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Xo(t))!Gt.call(e,s)&&s!==r&&Kt(e,s,{get:()=>t[s],enumerable:!(i=qo(t,s))||i.enumerable});return e};var qr=(e,t,r)=>(r=e!=null?zo(Zo(e)):{},ei(t||!e||!e.__esModule?Kt(r,"default",{value:e,enumerable:!0}):r,e));var U=(e,t,r)=>new Promise((i,s)=>{var d=v=>{try{p(r.next(v))}catch(w){s(w)}},f=v=>{try{p(r.throw(v))}catch(w){s(w)}},p=v=>v.done?i(v.value):Promise.resolve(v.value).then(d,f);p((r=r.apply(e,t)).next())});function ni(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Yt(e){return typeof e=="string"}function tn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function rn(e){return typeof e=="object"&&Array.isArray(e)}function oi(e){return typeof e>"u"}function ii(e){return oi(e)||e===null}function si(e){return typeof e=="function"}function nn(e){let t=e,r=null,i=function(...s){return r||(r=new t(...s)),r};return i.prototype=t.prototype,i}function on(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function i(s,d){for(let f in d)if(Object.prototype.hasOwnProperty.call(d,f)){let p=s[f],v=d[f],w=r(p,v,f,s,d);w!==void 0?s[f]=w:Qr(v)&&Qr(p)?s[f]=i(M({},p),v):Array.isArray(v)&&Array.isArray(p)?s[f]=[...p,...v]:s[f]=v}return s}return i(e,t)}function Qr(e){return e&&typeof e=="object"&&e.constructor===Object}function sn(e,t){if(Array.isArray(e))return e.concat(t)}function Be(e,t,r={}){let i=null,s,d,f,{leading:p=!1,trailing:v=!0}=r,w=()=>(f=e.apply(d,s),s=void 0,d=void 0,f),T=function(...k){s=k,d=this;let h=p&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,v&&!h&&w()},t),h)return w()};return T.cancel=()=>{i&&clearTimeout(i),i=null,s=d=void 0},T.flush=()=>{if(i)return clearTimeout(i),i=null,w()},T}function li(e,t){return(...r)=>t(e,...r)}function dn(e){return t=>li(t,function(r,...i){if(typeof r=="function")try{return r.apply(this,i)}catch(s){e(new ci(`${s}`))}})}function Ue(e){return(...t)=>{var r,i;((i=(r=globalThis.VConsole)==null?void 0:r[e])!=null?i:globalThis.console[e])(...t)}}function qe(e,t){return t.map(r=>{if(r==="params"&&e[r]){let i=e[r];return Object.keys(i).reduce((s,d)=>(s[d]=String(i[d]),s),{})}return e[r]})}function hi(e){let t=e.location?qe(e.location,Xr):null,r=e.target?qe(e.target,Xr):null;return qe(W(M({},e),{location:t,target:r}),fi)}function er(e){let t=e.events.map(i=>hi(i)),r=qe(e.device,mi);return[e.protocolVersion,t,r,e.project]}function Ai(e){return new Promise(t=>pn(e)(t))}function pn(e){return(t,r=null)=>{let i=!1;return e(s=>{if(!i)return i=!0,t.call(r,s)},null)}}function Si(e,t){return(r=>{let i,s={onWillAddFirstListener(){i=r(d.fire,d)}},d=new Le(s);return d.event})((r,i=null)=>e(s=>t(s)&&r.call(i,s),null))}function xi(e,t){let r=Math.min(e.length,t.length);for(let i=0;i<r;i++)ki(e[i],t[i])}function ki(e,t){if(Yt(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(si(t)){try{if(e instanceof t)return}catch(r){}if(!ii(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function oe(){if(globalThis[Jt])return globalThis[Jt];let e=new Qe,t=new zt,r={registerCommand(i,s,d){e.registerCommand({id:i,handler:s,metadata:d})},executeCommand(i,...s){return t.executeCommand(i,...s)},excuteCommandSync(i,...s){return t.executeCommandThowErr(i,...s)}};return globalThis[Jt]=r,r}var Zr,ti,ri,en,ai,qt,Qt,an,cn,ci,ln,un,Xe,Xt,ae,fn,ui,Zt,Me,Se,di,Xr,fi,mi,pi,ze,gi,vi,yi,mn,tr,bi,_i,Ei,hn,fe,H,Ti,Ii,Ye,Le,ge,Wt,wi,Ht,Ri,$e,Qe,zt,Jt,j=G(()=>{"use strict";Zr=Object.defineProperty,ti=Object.getOwnPropertyDescriptor,ri=(e,t)=>{for(var r in t)Zr(e,r,{get:t[r],enumerable:!0})},en=(e,t,r,i)=>{for(var s=i>1?void 0:i?ti(t,r):t,d=e.length-1,f;d>=0;d--)(f=e[d])&&(s=(i?f(t,r,s):f(s))||s);return i&&s&&Zr(t,r,s),s};ai=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(ai||{}),qt=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Qt=class extends qt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},an=class extends qt{constructor(){super(...arguments),this.kind="USER_ERROR"}},cn=class extends an{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},ci=class extends an{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},ln=class extends Qt{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},un=class extends Qt{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Xe=class extends qt{constructor(e,t,r,i,s){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),i!==void 0&&(this.stack=i),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Xt=class extends Qt{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ae={log:Ue("log"),warn:Ue("warn"),info:Ue("info"),error:Ue("error"),debug:Ue("debug")};Object.assign(globalThis,{logger:ae});fn=Symbol.for("Jolibox.canIUseMap"),ui={};globalThis[fn]=ui;Zt={get config(){return globalThis[fn]}},Me=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Me||{}),Se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Se||{}),di=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(di||{}),Xr=["name","params"],fi=["name","type","location","target","extra","timestamp","userId"],mi=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];pi=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ze={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},gi=()=>ze.isiOS?"iOS":ze.isAndroid?"Android":ze.isMac?"Mac":ze.isFacebook?"Facebook":"PC",vi="device_id",yi="advertising_id",mn=e=>(localStorage.getItem(e)||localStorage.setItem(e,pi()),localStorage.getItem(e)),tr=()=>mn(vi),bi=()=>mn(yi),_i=e=>e.charAt(0).toUpperCase()+e.slice(1),Ei=()=>{var t;let e=new URLSearchParams(window.location.search);return _i((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},hn=e=>{let t="JoliboxWebSDK",r=gi(),i=navigator.language,s=tr(),d=bi();return`${t} (${Ei()}${r}; UnknownModel; UnknownSystemVersion; ${i}) uuid/${s} adid/${d} version/${e||""}`},H=(fe=class{constructor(t){this.element=t,this.next=fe.Undefined,this.prev=fe.Undefined}},fe.Undefined=new fe(void 0),fe),Ti=class{constructor(){this._first=H.Undefined,this._last=H.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===H.Undefined}clear(){let e=this._first;for(;e!==H.Undefined;){let t=e.next;e.prev=H.Undefined,e.next=H.Undefined,e=t}this._first=H.Undefined,this._last=H.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new H(e);if(this._first===H.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(r))}}shift(){if(this._first!==H.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==H.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==H.Undefined&&e.next!==H.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===H.Undefined&&e.next===H.Undefined?(this._first=H.Undefined,this._last=H.Undefined):e.next===H.Undefined?(this._last=this._last.prev,this._last.next=H.Undefined):e.prev===H.Undefined&&(this._first=this._first.next,this._first.prev=H.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==H.Undefined;)yield e.element,e=e.next}},Ii=0,Ye=class{constructor(e){this.value=e,this.id=Ii++}},Le=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Ye&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(i=>(i==null?void 0:i.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,d,f,p,v,w;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new Ye(t);this._listeners?this._listeners instanceof Ye?this._listeners=[this._listeners,i]:this._listeners.push(i):((d=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||d.call(s,this),this._listeners=i,(p=(f=this.options)==null?void 0:f.onDidFirstListener)==null||p.call(f,this)),(w=(v=this.options)==null?void 0:v.onDidAddListener)==null||w.call(v,this),this._size++}),this._event}_deliver(e,t){var i;if(!e)return;let r=((i=this.options)==null?void 0:i.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof Ye?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ge=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var d;let r=(d=this.listeners.get(e))!=null?d:new Le,i=f=>t(...f.args);this.listerHandlerMap.set(t,i),r.event(i),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(M({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let i=this.listerHandlerMap.get(t);r.dispose(i)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let i=this.cachedEventQueue.get(e);i||(i=new Ti,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},Wt={};ri(Wt,{None:()=>wi,filter:()=>Si,once:()=>pn,toPromise:()=>Ai});wi=()=>{console.log("[Jolibox SDK] None Event")};Ht=Symbol.for("Jolibox.hostEmitter"),Ri=()=>{let e=new ge;return globalThis[Ht]||(globalThis[Ht]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Ht]},$e=Ri();Qe=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Le,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let i=e.handler;e.handler=function(...s){return xi(s,r),i(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Qe=en([nn],Qe);zt=class{constructor(){this._onWillExecuteCommand=new Le,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Le,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Qe,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=ni(3e4)),this._starActivation}executeCommand(e,...t){return U(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Wt.toPromise(Wt.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(i)}catch(i){return Promise.reject(i)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};zt=en([nn],zt);Jt=Symbol.for("Jolibox.commands")});function ce(e,t={}){rr.emit("ERROR_REPORT",{error:e,options:t})}var rr,_e,ve=G(()=>{"use strict";j();j();rr=new ge,_e=new ge;ce.debounce=Be(ce,50,{leading:!0})});var nr,gn,vn=G(()=>{"use strict";j();ve();nr=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),i=atob(t+r);try{return JSON.parse(i)}catch(s){return{}}},gn=e=>{var t;try{let s=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(s!=null&&s.length){let[d,f,p]=s;return{headerJson:nr(d),payloadJson:nr(f),signature:nr(p)}}else throw"joli_source is missing"}catch(r){return ce(new ln(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Ci,Ze,yn,or=G(()=>{"use strict";j();Ci="1.1.7",Ze=()=>Ci,yn=()=>{let e=Ze();return`${hn(e)}`}});var Pi,bn,ir,_n,X,Di,R,ie=G(()=>{"use strict";j();vn();or();j();Pi={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:tr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ze()},schema:window.location.href,platform:"h5"},ir=(bn=globalThis.joliboxJSCore)==null?void 0:bn.env,X=Object.assign({},(_n=ir==null?void 0:ir())!=null?_n:Pi),Di=()=>{var k,h,E,D,C,P,O,K;let{payloadJson:e,headerJson:t}=X.schema.length?gn(X.schema):{},r=`${X.deviceInfo.did}-${new Date().getTime()}`,s=new URL(X.schema.length?X.schema:window.location.href).searchParams,d=(E=(h=(k=s.get("mpId"))!=null?k:s.get("appId"))!=null?h:s.get("gameId"))!=null?E:"",f=(C=(D=e==null?void 0:e.sessionId)!=null?D:s.get("sessionId"))!=null?C:r,p=!!((P=e==null?void 0:e.testAdsMode)!=null?P:s.get("testAdsMode")==="true"),v=(K=(O=e==null?void 0:e.joliboxEnv)!=null?O:s.get("joliboxEnv"))!=null?K:"production",w=v==="staging",T=t==null?void 0:t.channel;return{get testMode(){return w},get testAdsMode(){return p},get joliboxEnv(){return v},get joliSource(){var x;return(x=s.get("joliSource"))!=null?x:null},get mpId(){var x;return(x=d!=null?d:e==null?void 0:e.id)!=null?x:""},get mpVersion(){var x;return(x=t==null?void 0:t.ver)!=null?x:Ze()},get platform(){var x;return(x=X.platform)!=null?x:X.deviceInfo.platform},get deviceInfo(){return X.deviceInfo},get sdkInfo(){return X.sdkInfo},get hostInfo(){return X.hostInfo},get hostUserInfo(){return X.hostUserInfo},get sessionId(){var x,Z;return(Z=(x=X.clientSessionId)!=null?x:f)!=null?Z:r},get channel(){return T},get webviewId(){var x;return(x=X.webviewId)!=null?x:-1},onEnvConfigChanged:x=>{on(X,x,sn)}}},R=Di()});var sr,Tn,Oi,Fi,En,Ni,In=G(()=>{"use strict";j();ve();ie();j();sr=!1,Tn=(e,t)=>e==null?!1:t in e,Oi=e=>Tn(e,"kind"),Fi=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},En=(e,t={},r)=>{var d,f,p;let i={user_id:(f=(d=R.hostUserInfo)==null?void 0:d.uid)!=null?f:"",device_id:(p=R.deviceInfo.did)!=null?p:"",timestamp:Date.now(),tag:Fi(e.name)},s=W(M({},i),{env:t.environment,isFromUser:r});r?_e.emit("GLOBAL_USER_ERROR",e,s):_e.emit("GLOBAL_ERROR",e,s)},Ni=e=>Tn(e,"kind")&&e.kind==="USER_ERROR";rr.on("ERROR_REPORT",({error:e,options:t})=>{if(sr)return;sr=!0;let r=Oi(e)&&e.raw?e.raw:e;try{let i=Ni(e);En(e,t,i)}catch(i){let s=i instanceof Error?i.message:String(i),d=new Xt(`${s}, origin error: ${r.message}`);ae.error(d),En(new Xt(d.message),{environment:t.environment},!1)}finally{sr=!1}})});var ar,cr=G(()=>{"use strict";ve();j();ve();ar=e=>new cn(e)});function wn(e,t){let r=(i,s,d)=>{let f=W(M({tag:i},t),{extra:M({},s)});i=="globalJsError"?ce(new un(JSON.stringify(f))):e("systemLog",f,d)};return r.debounce=Be(r,500,{leading:!0}),r}function An(e){let t=(r,i,s)=>{var p;let d=(p=s&&JSON.stringify(s))!=null?p:0,f={speed_value_type:r,total_duration:i};d&&Object.assign(f,{extra:d}),e("joliboxSpeedAnalysis",f)};return t.debounce=Be(t,500,{leading:!0}),t}var Sn=G(()=>{"use strict";j();j();ve()});function Rn(e,t){let r=wn(e,t),i=An(r);return{track:r,trackPerformance:i}}var xn=G(()=>{"use strict";Sn()});var lr=G(()=>{"use strict"});var et,kn=G(()=>{"use strict";ie();j();j();et=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.samplesConfig=null;this.pushPastTracking=t=>{this.pastTrackings.push(t),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)};this.fetchSamplesConfig()}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}fetchSamplesConfig(){return U(this,null,function*(){let r=`${R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/samples-config`,i=yield(yield fetch(r)).json();this.samplesConfig=i})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[i,s]of Object.entries(r))if(s.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(i);return!1}getDevice(){var i,s,d,f,p;let{nativeSDKVersion:t,jssdkVersion:r}=R.sdkInfo;return{platform:1e3,os:R.deviceInfo.platform,appVersion:(i=t!=null?t:r)!=null?i:"1.0.0",appId:(d=(s=R.hostInfo)==null?void 0:s.aid)!=null?d:"1",model:(f=R.deviceInfo.model)!=null?f:"UnknownModel",brand:(p=R.deviceInfo.brand)!=null?p:"UnknownBrand",uuid:R.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((i,s)=>{r[s]=i}),{name:"GamePage",params:r}}trackEvent(t,r,i){return U(this,null,function*(){if(this.checkIsSampled(t))return;let s=t.location?t.location:yield this.getLocation(),d=t.target||null,f=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let p=this.deviceInfo,w={protocolVersion:"1.0.0",events:[W(M({},t),{location:s,target:d,extra:f,timestamp:Date.now(),userId:null})],device:p,project:r};try{i?this.doReport(er(w),i):this.doReport(er(w)),this.pushPastTracking(!0)}catch(T){this.pushPastTracking(!1),ae.log("[Jolibox SDK] report API error",T)}})}}});var ur=G(()=>{"use strict";xn();lr();kn()});var dr,Cn,tt,ye,Ve=G(()=>{"use strict";or();ie();dr=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(Cn=AbortSignal.timeout)!=null||(AbortSignal.timeout=dr);tt=class{constructor(t){this.xua=yn();this.getJoliSource=()=>R.joliSource;var i;let r=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=(i=t==null?void 0:t.baseUrl)!=null?i:r}get(t,r){return U(this,null,function*(){let{query:i,timeout:s}=r!=null?r:{},{headers:d}=r!=null?r:{},f=i?new URLSearchParams(i):null,p=f==null?void 0:f.toString(),v=`${this.baseUrl}${t}${p?`?${p}`:""}`,w=this.xua,T=this.getJoliSource();return d=Object.assign({},d!=null?d:{},w?{"x-user-agent":w}:{},T?{"x-joli-source":T}:{}),yield(yield fetch(v,{method:"GET",headers:d,credentials:"include",signal:dr(s!=null?s:3e4)})).json()})}post(t,r){return U(this,null,function*(){let{data:i,query:s,timeout:d}=r!=null?r:{},{headers:f}=r!=null?r:{},p=s?new URLSearchParams(s):null,v=p==null?void 0:p.toString(),w=`${this.baseUrl}${t}${v?`?${v}`:""}`,T=this.xua,k=this.getJoliSource();f=Object.assign({},f!=null?f:{},{"Content-Type":"application/json"},T?{"x-user-agent":T}:{},k?{"x-joli-source":k}:{});let h=yield fetch(w,{method:"POST",headers:f,body:JSON.stringify(i),signal:dr(d!=null?d:3e4),credentials:"include"}),E=h.headers.get("content-type");if(E!=null&&E.includes("application/octet-stream"))try{return h.blob()}catch(D){return yield h.arrayBuffer()}if(E!=null&&E.includes("multipart/form-data")||E!=null&&E.includes("application/x-www-form-urlencoded"))try{return h.formData()}catch(D){return yield h.text()}if(E!=null&&E.includes("application/json"))try{return yield h.json()}catch(D){return yield h.text()}return h})}put(t,r){return U(this,null,function*(){try{let{data:i,query:s,timeout:d}=r!=null?r:{},{headers:f}=r!=null?r:{},p=s?new URLSearchParams(s):null,v=p==null?void 0:p.toString(),w=`${this.baseUrl}${t}${v?`?${v}`:""}`,T=this.xua,k=this.getJoliSource();f=Object.assign({},f!=null?f:{},{"Content-Type":"application/json"},T?{"x-user-agent":T}:{},k?{"x-joli-source":k}:{});let h=yield fetch(w,{method:"PUT",headers:f,credentials:"include",body:JSON.stringify(i!=null?i:{})});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return yield h.json()}catch(i){throw console.error("Error:",i),i}})}};window.JoliboxHttpClient=tt;ye=tt});var fr,Re,rt=G(()=>{"use strict";ie();ur();Ve();fr=class extends et{constructor(){super(...arguments);this.hostToApiMap={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}};this.httpClient=new ye({baseUrl:this.apiBaseURL})}get apiBaseURL(){var i,s;let r=(i=this.hostToApiMap[window.location.host])!=null?i:this.hostToApiMap.default;return(s=R.testMode)!=null&&s?r.test:r.prod}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3})}},Re=new fr});var Ui,Pn=G(()=>{"use strict";In();j();cr();j();rt();ie();Ui=(e,t)=>{var s,d,f;let r={message:t.message,stack:(s=t.stack)!=null?s:"",errorType:t.name,source:0},i={name:e,type:Me.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(f=(d=R.hostUserInfo)==null?void 0:d.uid)!=null?f:null};Re.trackEvent(i,Se.WebSDK)};_e.on("GLOBAL_ERROR",(e,t)=>{Ui(t.tag,e)});_e.on("GLOBAL_USER_ERROR",(e,t)=>{ae.log("UserError",e,t)})});var nt,Dn=G(()=>{"use strict";nt=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",i=>{this.visible=i})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),i,s,d=!1,f=0,p=()=>{if(!d)return;let E=Date.now(),D=E-r;D>=this.interval&&(this.visible&&(f+=D,t(f)),r=E),i=requestAnimationFrame(p)},v=()=>{T(),r=Date.now(),s=window.setInterval(()=>{if(!d)return;let E=Date.now();E-r>=this.interval&&(r=E)},this.interval)},w=()=>{k(),r=Date.now(),i=requestAnimationFrame(p)},T=()=>{i&&(cancelAnimationFrame(i),i=0)},k=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",E=>{d&&(console.log("visible",E),E?w():v())});let h=this.visible;return{start(){d||(d=!0,h?w():v())},stop(){d=!1,T(),k()}}}}});var ot,On=G(()=>{"use strict";ie();Dn();Ve();ot=class extends nt{constructor(r,i,s){super(i,s);this.httpClient=new ye;this.gameId=R.mpId,this.sessionId=R.sessionId,this.track=r}reporter(r){return U(this,null,function*(){let{event:i,params:s}=r;yield this.httpClient.post("/api/base/app-event",{data:{eventType:i,gameInfo:M({gameId:this.gameId,sessionId:this.sessionId},s)}})})}tracker(r,i=null){this.track(r,i)}}});var Fn,Li,xe,Bi,mr,le,Ee=G(()=>{"use strict";Pn();j();j();ur();rt();On();ie();lr();Fn=oe(),Li={type:Se.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:xe,trackPerformance:Bi}=Rn((...e)=>{var f,p,v,w;let[,t]=e,r=t,i=tn(r.extra)?r.extra:Yt(r.extra)?JSON.parse(r.extra):{},s=W(M({},i),{mp_id:(f=r.mp_id)!=null?f:"",mp_version:(p=r.mp_version)!=null?p:""}),d={name:t.tag,type:Me.System,location:null,target:null,extra:s,timestamp:Date.now(),userId:(w=(v=R.hostUserInfo)==null?void 0:v.uid)!=null?w:null};Re.trackEvent(d,Se.WebSDK)},Li);Fn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Bi(e,t,r)});Fn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{xe(e,t)});mr=new ge,le=new ot(xe,mr)});function Nn(e){let t=Zt.config[e];return t||(t={},Zt.config[e]=t),(r,i)=>{if(t[r]){ae.warn(`[can i use] ${r} already registered`);return}t[r]=M({},i)}}var Un=G(()=>{"use strict";j()});function hr(e){Ln=e}function it(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>it(t)):Object.keys(e).reduce((t,r)=>(t[r]=it(e[r]),t),{})}function me(e){return typeof e=="number"}function pr(e){let t=gr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function gr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Ln,Y,st,at,ct,lt,ke,ut,dt,ft,mt,ht,pt,gt,vt,yt,bt,_t,Et,vr=G(()=>{"use strict";Ln=!1;Y=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Ln)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${pr(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return it(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:it(this._default)}optional(){return this._optional=!0,this}};st=class extends Y{validate(t){return this._optional&&t===void 0?!0:me(t)?me(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):me(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):me(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},at=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ct=class extends Y{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(me(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(me(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},lt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ke=class extends Y{validate(t){return!0}},ut=class extends Y{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},dt=class extends Y{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ft=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},mt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(i=>JSON.stringify(i)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${pr(t)}`)}return!0}},ht=class extends Y{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(me(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(me(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(me(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let i=this._item;if(!i)return!0;let s=!0;if(r.forEach((d,f)=>{if(i.path=`${this.path}[${f}]`,i.errors=this.errors,d===void 0&&i.hasDefault){r[f]=i.defaultValue;return}i.validate(d)||(i.hasFallback?r[f]=i.fallbackValue:s=!1)}),this._uniqueItems){let d=new Map;for(let f in r)d.has(r[f])?s=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${d.get(r[f])}] and ${this.path}[${f}] are identical)`):d.set(r[f],f)}return s}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},pt=class extends Y{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(gr(r)!=="object")return this.fail({expect:"object",actual:r});let s=r,d=this._value;d.errors=this.errors;let f=!0;for(let p in s){let v=s[p];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(p)?d.path=`${this.path}.${p}`:d.path=`${this.path}["${p}"]`,!(v===void 0&&d._optional)){if(v===void 0&&d.hasDefault){s[p]=d.defaultValue;continue}d.validate(v)||(d.hasFallback?s[p]=d.fallbackValue:f=!1)}}return f}},gt=class extends Y{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(gr(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,s=!0;for(let d in this._object){let f=i[d],p=this._object[d];if(p.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?p.path=`${this.path}.${d}`:p.path=`${this.path}["${d}"]`,!(p._optional&&f===void 0)){if(f===void 0&&p.hasDefault){i[d]=p.defaultValue;continue}p.validate(f)||(p.hasFallback?i[d]=p.fallbackValue:s=!1)}}return s}},vt=class extends Y{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:pr(this.value),actual:r}):!0}},yt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],i=!1,s=this._items.length;for(let d=0;d<s;d++){let f=this._items[d];if(f.errors=[],f.path=this.path,!f.validate(t))r.push(f.errors.join("; "));else if(!i){i=!0;break}}if(!i){let d=r.join(`
2
+ or `);this.errors.push(d)}return i}},bt=class extends Y{constructor(...t){super(),this._items=t;let r=0,i=t.length-1;for(;i>=0;i--){let s=t[i];if(s._optional||s.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((i,s)=>{if(i.path=`${this.path}[${s}]`,i.errors=this.errors,t[s]===void 0&&i.hasDefault){t[s]=i.defaultValue;return}i.validate(t[s])||(i.hasFallback?t[s]=i._fallback:r=!1)}),r}},_t=class extends Y{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},Et=class extends Y{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function yr(e,t,r="param"){if(e.errors=[],e.path=r,hr(!0),!e.validate(t)){let i=e.errors.join(`
3
+ `);throw e.errors.length=0,hr(!1),new TypeError(i)}}var S,br=G(()=>{"use strict";vr();vr();S={object(e){return new gt(e)},array(e){return new ht(e)},tuple(...e){return new bt(...e)},literal(e){return new vt(e)},or(...e){return new yt(...e)},symbol(){return new lt},record(e){return new pt(e)},function(){return new ft},boolean(){return new at},string(){return new ct},number(){return new st},undefined(){return new ut},null(){return new dt},unknown(){return new ke},any(){return new ke},as(){return new ke},arraybuffer(){return new _t},enum(...e){return new mt(...e)},typedarray(e){return new Et(e)}}});var Tt,Bn,Mn=G(()=>{"use strict";j();ve();br();cr();Tt=1,Bn=e=>{function t(i,s){return(...d)=>{var k,h,E,D;let f=Date.now(),p={method:i,trace_id:Tt};Tt+=1;let v="SUCCESS",w=`${i}:ok`,T=0;try{if(s.paramsSchema)try{yr(s.paramsSchema,d,"params")}catch(K){throw ar(`${i}:fail ${K.message}`)}let C=s.implement(...d),P=C,O=`${i}:ok`;if(C&&"code"in C){let{code:K,data:x,message:Z}=C;v=K,P=x,O=Z}return{code:v,message:O,data:P}}catch(C){let P=C;T=(h=(k=P.code)!=null?k:P.errNo)!=null?h:2e3,v="FAILURE";let O=(D=(E=P.message)!=null?E:P.errMsg)!=null?D:`${C}`;return w=`${i}:${v} ${O.replace(/^\S+:(fail|cancel)\s?/,"")}`,ce(new Xe(w,T)),{code:v,message:w}}finally{let C=Date.now()-f;e("apiInvoked",W(M({},p),{duration:C,status:v}))}}}function r(i,s){return(...d)=>U(this,null,function*(){var h,E,D,C;let f=rn(d)?d:[d],p=Date.now(),v={method:i,trace_id:Tt};Tt+=1;let w=`${i}:ok`,T="SUCCESS",k={code:T,message:w};try{if(s.paramsSchema)try{yr(s.paramsSchema,f,"params")}catch(K){throw ar(K.message)}let O=yield s.implement(...f);if(O&&"code"in O){let{code:K,data:x,message:Z}=O;T=K,w=Z,O=x}return Object.assign(k,{code:T,message:w,data:O}),k}catch(P){let O=P,K=(E=(h=O.code)!=null?h:O.errNo)!=null?E:2e3;T="FAILURE";let x=(C=(D=O.message)!=null?D:O.errMsg)!=null?C:`${P}`,Z=`${i}:${T} ${x.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(k,{code:T,message:Z}),ce(new Xe(Z,K)),k}finally{let P=Date.now()-p;e("apiInvoked",W(M({},v),{duration:P,status:T}))}})}return{createAPI:r,createSyncAPI:t}}});var se,Te,q,je=G(()=>{"use strict";Un();Ee();Mn();br();({createAPI:se,createSyncAPI:Te}=Bn(xe)),q=Nn("h5")});var Kn=Yr((jn,Ir)=>{(function(e){if(typeof jn=="object"&&typeof Ir!="undefined")Ir.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function i(s,d,f){function p(T,k){if(!d[T]){if(!s[T]){var h=typeof Ne=="function"&&Ne;if(!k&&h)return h(T,!0);if(v)return v(T,!0);var E=new Error("Cannot find module '"+T+"'");throw E.code="MODULE_NOT_FOUND",E}var D=d[T]={exports:{}};s[T][0].call(D.exports,function(C){var P=s[T][1][C];return p(P||C)},D,D.exports,i,s,d,f)}return d[T].exports}for(var v=typeof Ne=="function"&&Ne,w=0;w<f.length;w++)p(f[w]);return p}({1:[function(i,s,d){(function(f){"use strict";var p=f.MutationObserver||f.WebKitMutationObserver,v;if(p){var w=0,T=new p(C),k=f.document.createTextNode("");T.observe(k,{characterData:!0}),v=function(){k.data=w=++w%2}}else if(!f.setImmediate&&typeof f.MessageChannel!="undefined"){var h=new f.MessageChannel;h.port1.onmessage=C,v=function(){h.port2.postMessage(0)}}else"document"in f&&"onreadystatechange"in f.document.createElement("script")?v=function(){var O=f.document.createElement("script");O.onreadystatechange=function(){C(),O.onreadystatechange=null,O.parentNode.removeChild(O),O=null},f.document.documentElement.appendChild(O)}:v=function(){setTimeout(C,0)};var E,D=[];function C(){E=!0;for(var O,K,x=D.length;x;){for(K=D,D=[],O=-1;++O<x;)K[O]();x=D.length}E=!1}s.exports=P;function P(O){D.push(O)===1&&!E&&v()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(i,s,d){"use strict";var f=i(1);function p(){}var v={},w=["REJECTED"],T=["FULFILLED"],k=["PENDING"];s.exports=h;function h(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=k,this.queue=[],this.outcome=void 0,I!==p&&P(this,I)}h.prototype.catch=function(I){return this.then(null,I)},h.prototype.then=function(I,L){if(typeof I!="function"&&this.state===T||typeof L!="function"&&this.state===w)return this;var N=new this.constructor(p);if(this.state!==k){var V=this.state===T?I:L;D(N,V,this.outcome)}else this.queue.push(new E(N,I,L));return N};function E(I,L,N){this.promise=I,typeof L=="function"&&(this.onFulfilled=L,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}E.prototype.callFulfilled=function(I){v.resolve(this.promise,I)},E.prototype.otherCallFulfilled=function(I){D(this.promise,this.onFulfilled,I)},E.prototype.callRejected=function(I){v.reject(this.promise,I)},E.prototype.otherCallRejected=function(I){D(this.promise,this.onRejected,I)};function D(I,L,N){f(function(){var V;try{V=L(N)}catch(Q){return v.reject(I,Q)}V===I?v.reject(I,new TypeError("Cannot resolve promise with itself")):v.resolve(I,V)})}v.resolve=function(I,L){var N=O(C,L);if(N.status==="error")return v.reject(I,N.value);var V=N.value;if(V)P(I,V);else{I.state=T,I.outcome=L;for(var Q=-1,ee=I.queue.length;++Q<ee;)I.queue[Q].callFulfilled(L)}return I},v.reject=function(I,L){I.state=w,I.outcome=L;for(var N=-1,V=I.queue.length;++N<V;)I.queue[N].callRejected(L);return I};function C(I){var L=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof L=="function")return function(){L.apply(I,arguments)}}function P(I,L){var N=!1;function V(re){N||(N=!0,v.reject(I,re))}function Q(re){N||(N=!0,v.resolve(I,re))}function ee(){L(Q,V)}var te=O(ee);te.status==="error"&&V(te.value)}function O(I,L){var N={};try{N.value=I(L),N.status="success"}catch(V){N.status="error",N.value=V}return N}h.resolve=K;function K(I){return I instanceof this?I:v.resolve(new this(p),I)}h.reject=x;function x(I){var L=new this(p);return v.reject(L,I)}h.all=Z;function Z(I){var L=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=I.length,V=!1;if(!N)return this.resolve([]);for(var Q=new Array(N),ee=0,te=-1,re=new this(p);++te<N;)ue(I[te],te);return re;function ue(De,Ge){L.resolve(De).then(Ot,function(we){V||(V=!0,v.reject(re,we))});function Ot(we){Q[Ge]=we,++ee===N&&!V&&(V=!0,v.resolve(re,Q))}}}h.race=be;function be(I){var L=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=I.length,V=!1;if(!N)return this.resolve([]);for(var Q=-1,ee=new this(p);++Q<N;)te(I[Q]);return ee;function te(re){L.resolve(re).then(function(ue){V||(V=!0,v.resolve(ee,ue))},function(ue){V||(V=!0,v.reject(ee,ue))})}}},{1:1}],3:[function(i,s,d){(function(f){"use strict";typeof f.Promise!="function"&&(f.Promise=i(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{2:2}],4:[function(i,s,d){"use strict";var f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function p(n,a){if(!(n instanceof a))throw new TypeError("Cannot call a class as a function")}function v(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(n){return}}var w=v();function T(){try{if(!w||!w.open)return!1;var n=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),a=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!n||a)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(o){return!1}}function k(n,a){n=n||[],a=a||{};try{return new Blob(n,a)}catch(c){if(c.name!=="TypeError")throw c;for(var o=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,l=new o,u=0;u<n.length;u+=1)l.append(n[u]);return l.getBlob(a.type)}}typeof Promise=="undefined"&&i(3);var h=Promise;function E(n,a){a&&n.then(function(o){a(null,o)},function(o){a(o)})}function D(n,a,o){typeof a=="function"&&n.then(a),typeof o=="function"&&n.catch(o)}function C(n){return typeof n!="string"&&(console.warn(n+" used as a key, but it is not a string."),n=String(n)),n}function P(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var O="local-forage-detect-blob-support",K=void 0,x={},Z=Object.prototype.toString,be="readonly",I="readwrite";function L(n){for(var a=n.length,o=new ArrayBuffer(a),l=new Uint8Array(o),u=0;u<a;u++)l[u]=n.charCodeAt(u);return o}function N(n){return new h(function(a){var o=n.transaction(O,I),l=k([""]);o.objectStore(O).put(l,"key"),o.onabort=function(u){u.preventDefault(),u.stopPropagation(),a(!1)},o.oncomplete=function(){var u=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);a(c||!u||parseInt(u[1],10)>=43)}}).catch(function(){return!1})}function V(n){return typeof K=="boolean"?h.resolve(K):N(n).then(function(a){return K=a,K})}function Q(n){var a=x[n.name],o={};o.promise=new h(function(l,u){o.resolve=l,o.reject=u}),a.deferredOperations.push(o),a.dbReady?a.dbReady=a.dbReady.then(function(){return o.promise}):a.dbReady=o.promise}function ee(n){var a=x[n.name],o=a.deferredOperations.pop();if(o)return o.resolve(),o.promise}function te(n,a){var o=x[n.name],l=o.deferredOperations.pop();if(l)return l.reject(a),l.promise}function re(n,a){return new h(function(o,l){if(x[n.name]=x[n.name]||Sr(),n.db)if(a)Q(n),n.db.close();else return o(n.db);var u=[n.name];a&&u.push(n.version);var c=w.open.apply(w,u);a&&(c.onupgradeneeded=function(m){var g=c.result;try{g.createObjectStore(n.storeName),m.oldVersion<=1&&g.createObjectStore(O)}catch(y){if(y.name==="ConstraintError")console.warn('The database "'+n.name+'" has been upgraded from version '+m.oldVersion+" to version "+m.newVersion+', but the storage "'+n.storeName+'" already exists.');else throw y}}),c.onerror=function(m){m.preventDefault(),l(c.error)},c.onsuccess=function(){var m=c.result;m.onversionchange=function(g){g.target.close()},o(m),ee(n)}})}function ue(n){return re(n,!1)}function De(n){return re(n,!0)}function Ge(n,a){if(!n.db)return!0;var o=!n.db.objectStoreNames.contains(n.storeName),l=n.version<n.db.version,u=n.version>n.db.version;if(l&&(n.version!==a&&console.warn('The database "'+n.name+`" can't be downgraded from version `+n.db.version+" to version "+n.version+"."),n.version=n.db.version),u||o){if(o){var c=n.db.version+1;c>n.version&&(n.version=c)}return!0}return!1}function Ot(n){return new h(function(a,o){var l=new FileReader;l.onerror=o,l.onloadend=function(u){var c=btoa(u.target.result||"");a({__local_forage_encoded_blob:!0,data:c,type:n.type})},l.readAsBinaryString(n)})}function we(n){var a=L(atob(n.data));return k([a],{type:n.type})}function Ar(n){return n&&n.__local_forage_encoded_blob}function zn(n){var a=this,o=a._initReady().then(function(){var l=x[a._dbInfo.name];if(l&&l.dbReady)return l.dbReady});return D(o,n,n),o}function Yn(n){Q(n);for(var a=x[n.name],o=a.forages,l=0;l<o.length;l++){var u=o[l];u._dbInfo.db&&(u._dbInfo.db.close(),u._dbInfo.db=null)}return n.db=null,ue(n).then(function(c){return n.db=c,Ge(n)?De(n):c}).then(function(c){n.db=a.db=c;for(var m=0;m<o.length;m++)o[m]._dbInfo.db=c}).catch(function(c){throw te(n,c),c})}function de(n,a,o,l){l===void 0&&(l=1);try{var u=n.db.transaction(n.storeName,a);o(null,u)}catch(c){if(l>0&&(!n.db||c.name==="InvalidStateError"||c.name==="NotFoundError"))return h.resolve().then(function(){if(!n.db||c.name==="NotFoundError"&&!n.db.objectStoreNames.contains(n.storeName)&&n.version<=n.db.version)return n.db&&(n.version=n.db.version+1),De(n)}).then(function(){return Yn(n).then(function(){de(n,a,o,l-1)})}).catch(o);o(c)}}function Sr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function qn(n){var a=this,o={db:null};if(n)for(var l in n)o[l]=n[l];var u=x[o.name];u||(u=Sr(),x[o.name]=u),u.forages.push(a),a._initReady||(a._initReady=a.ready,a.ready=zn);var c=[];function m(){return h.resolve()}for(var g=0;g<u.forages.length;g++){var y=u.forages[g];y!==a&&c.push(y._initReady().catch(m))}var b=u.forages.slice(0);return h.all(c).then(function(){return o.db=u.db,ue(o)}).then(function(_){return o.db=_,Ge(o,a._defaultConfig.version)?De(o):_}).then(function(_){o.db=u.db=_,a._dbInfo=o;for(var A=0;A<b.length;A++){var F=b[A];F!==a&&(F._dbInfo.db=o.db,F._dbInfo.version=o.version)}})}function Qn(n,a){var o=this;n=C(n);var l=new h(function(u,c){o.ready().then(function(){de(o._dbInfo,be,function(m,g){if(m)return c(m);try{var y=g.objectStore(o._dbInfo.storeName),b=y.get(n);b.onsuccess=function(){var _=b.result;_===void 0&&(_=null),Ar(_)&&(_=we(_)),u(_)},b.onerror=function(){c(b.error)}}catch(_){c(_)}})}).catch(c)});return E(l,a),l}function Xn(n,a){var o=this,l=new h(function(u,c){o.ready().then(function(){de(o._dbInfo,be,function(m,g){if(m)return c(m);try{var y=g.objectStore(o._dbInfo.storeName),b=y.openCursor(),_=1;b.onsuccess=function(){var A=b.result;if(A){var F=A.value;Ar(F)&&(F=we(F));var B=n(F,A.key,_++);B!==void 0?u(B):A.continue()}else u()},b.onerror=function(){c(b.error)}}catch(A){c(A)}})}).catch(c)});return E(l,a),l}function Zn(n,a,o){var l=this;n=C(n);var u=new h(function(c,m){var g;l.ready().then(function(){return g=l._dbInfo,Z.call(a)==="[object Blob]"?V(g.db).then(function(y){return y?a:Ot(a)}):a}).then(function(y){de(l._dbInfo,I,function(b,_){if(b)return m(b);try{var A=_.objectStore(l._dbInfo.storeName);y===null&&(y=void 0);var F=A.put(y,n);_.oncomplete=function(){y===void 0&&(y=null),c(y)},_.onabort=_.onerror=function(){var B=F.error?F.error:F.transaction.error;m(B)}}catch(B){m(B)}})}).catch(m)});return E(u,o),u}function eo(n,a){var o=this;n=C(n);var l=new h(function(u,c){o.ready().then(function(){de(o._dbInfo,I,function(m,g){if(m)return c(m);try{var y=g.objectStore(o._dbInfo.storeName),b=y.delete(n);g.oncomplete=function(){u()},g.onerror=function(){c(b.error)},g.onabort=function(){var _=b.error?b.error:b.transaction.error;c(_)}}catch(_){c(_)}})}).catch(c)});return E(l,a),l}function to(n){var a=this,o=new h(function(l,u){a.ready().then(function(){de(a._dbInfo,I,function(c,m){if(c)return u(c);try{var g=m.objectStore(a._dbInfo.storeName),y=g.clear();m.oncomplete=function(){l()},m.onabort=m.onerror=function(){var b=y.error?y.error:y.transaction.error;u(b)}}catch(b){u(b)}})}).catch(u)});return E(o,n),o}function ro(n){var a=this,o=new h(function(l,u){a.ready().then(function(){de(a._dbInfo,be,function(c,m){if(c)return u(c);try{var g=m.objectStore(a._dbInfo.storeName),y=g.count();y.onsuccess=function(){l(y.result)},y.onerror=function(){u(y.error)}}catch(b){u(b)}})}).catch(u)});return E(o,n),o}function no(n,a){var o=this,l=new h(function(u,c){if(n<0){u(null);return}o.ready().then(function(){de(o._dbInfo,be,function(m,g){if(m)return c(m);try{var y=g.objectStore(o._dbInfo.storeName),b=!1,_=y.openKeyCursor();_.onsuccess=function(){var A=_.result;if(!A){u(null);return}n===0||b?u(A.key):(b=!0,A.advance(n))},_.onerror=function(){c(_.error)}}catch(A){c(A)}})}).catch(c)});return E(l,a),l}function oo(n){var a=this,o=new h(function(l,u){a.ready().then(function(){de(a._dbInfo,be,function(c,m){if(c)return u(c);try{var g=m.objectStore(a._dbInfo.storeName),y=g.openKeyCursor(),b=[];y.onsuccess=function(){var _=y.result;if(!_){l(b);return}b.push(_.key),_.continue()},y.onerror=function(){u(y.error)}}catch(_){u(_)}})}).catch(u)});return E(o,n),o}function io(n,a){a=P.apply(this,arguments);var o=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||o.name,n.storeName=n.storeName||o.storeName);var l=this,u;if(!n.name)u=h.reject("Invalid arguments");else{var c=n.name===o.name&&l._dbInfo.db,m=c?h.resolve(l._dbInfo.db):ue(n).then(function(g){var y=x[n.name],b=y.forages;y.db=g;for(var _=0;_<b.length;_++)b[_]._dbInfo.db=g;return g});n.storeName?u=m.then(function(g){if(g.objectStoreNames.contains(n.storeName)){var y=g.version+1;Q(n);var b=x[n.name],_=b.forages;g.close();for(var A=0;A<_.length;A++){var F=_[A];F._dbInfo.db=null,F._dbInfo.version=y}var B=new h(function($,z){var J=w.open(n.name,y);J.onerror=function(ne){var Fe=J.result;Fe.close(),z(ne)},J.onupgradeneeded=function(){var ne=J.result;ne.deleteObjectStore(n.storeName)},J.onsuccess=function(){var ne=J.result;ne.close(),$(ne)}});return B.then(function($){b.db=$;for(var z=0;z<_.length;z++){var J=_[z];J._dbInfo.db=$,ee(J._dbInfo)}}).catch(function($){throw(te(n,$)||h.resolve()).catch(function(){}),$})}}):u=m.then(function(g){Q(n);var y=x[n.name],b=y.forages;g.close();for(var _=0;_<b.length;_++){var A=b[_];A._dbInfo.db=null}var F=new h(function(B,$){var z=w.deleteDatabase(n.name);z.onerror=function(){var J=z.result;J&&J.close(),$(z.error)},z.onblocked=function(){console.warn('dropInstance blocked for database "'+n.name+'" until all open connections are closed')},z.onsuccess=function(){var J=z.result;J&&J.close(),B(J)}});return F.then(function(B){y.db=B;for(var $=0;$<b.length;$++){var z=b[$];ee(z._dbInfo)}}).catch(function(B){throw(te(n,B)||h.resolve()).catch(function(){}),B})})}return E(u,a),u}var so={_driver:"asyncStorage",_initStorage:qn,_support:T(),iterate:Xn,getItem:Qn,setItem:Zn,removeItem:eo,clear:to,length:ro,key:no,keys:oo,dropInstance:io};function ao(){return typeof openDatabase=="function"}var he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",co="~~local_forage_type~",Rr=/^~~local_forage_type~([^~]+)~/,He="__lfsc__:",Ft=He.length,Nt="arbf",Ut="blob",xr="si08",kr="ui08",Cr="uic8",Pr="si16",Dr="si32",Or="ur16",Fr="ui32",Nr="fl32",Ur="fl64",Lr=Ft+Nt.length,Br=Object.prototype.toString;function Mr(n){var a=n.length*.75,o=n.length,l,u=0,c,m,g,y;n[n.length-1]==="="&&(a--,n[n.length-2]==="="&&a--);var b=new ArrayBuffer(a),_=new Uint8Array(b);for(l=0;l<o;l+=4)c=he.indexOf(n[l]),m=he.indexOf(n[l+1]),g=he.indexOf(n[l+2]),y=he.indexOf(n[l+3]),_[u++]=c<<2|m>>4,_[u++]=(m&15)<<4|g>>2,_[u++]=(g&3)<<6|y&63;return b}function Lt(n){var a=new Uint8Array(n),o="",l;for(l=0;l<a.length;l+=3)o+=he[a[l]>>2],o+=he[(a[l]&3)<<4|a[l+1]>>4],o+=he[(a[l+1]&15)<<2|a[l+2]>>6],o+=he[a[l+2]&63];return a.length%3===2?o=o.substring(0,o.length-1)+"=":a.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function lo(n,a){var o="";if(n&&(o=Br.call(n)),n&&(o==="[object ArrayBuffer]"||n.buffer&&Br.call(n.buffer)==="[object ArrayBuffer]")){var l,u=He;n instanceof ArrayBuffer?(l=n,u+=Nt):(l=n.buffer,o==="[object Int8Array]"?u+=xr:o==="[object Uint8Array]"?u+=kr:o==="[object Uint8ClampedArray]"?u+=Cr:o==="[object Int16Array]"?u+=Pr:o==="[object Uint16Array]"?u+=Or:o==="[object Int32Array]"?u+=Dr:o==="[object Uint32Array]"?u+=Fr:o==="[object Float32Array]"?u+=Nr:o==="[object Float64Array]"?u+=Ur:a(new Error("Failed to get type for BinaryArray"))),a(u+Lt(l))}else if(o==="[object Blob]"){var c=new FileReader;c.onload=function(){var m=co+n.type+"~"+Lt(this.result);a(He+Ut+m)},c.readAsArrayBuffer(n)}else try{a(JSON.stringify(n))}catch(m){console.error("Couldn't convert value into a JSON string: ",n),a(null,m)}}function uo(n){if(n.substring(0,Ft)!==He)return JSON.parse(n);var a=n.substring(Lr),o=n.substring(Ft,Lr),l;if(o===Ut&&Rr.test(a)){var u=a.match(Rr);l=u[1],a=a.substring(u[0].length)}var c=Mr(a);switch(o){case Nt:return c;case Ut:return k([c],{type:l});case xr:return new Int8Array(c);case kr:return new Uint8Array(c);case Cr:return new Uint8ClampedArray(c);case Pr:return new Int16Array(c);case Or:return new Uint16Array(c);case Dr:return new Int32Array(c);case Fr:return new Uint32Array(c);case Nr:return new Float32Array(c);case Ur:return new Float64Array(c);default:throw new Error("Unkown type: "+o)}}var Bt={serialize:lo,deserialize:uo,stringToBuffer:Mr,bufferToString:Lt};function $r(n,a,o,l){n.executeSql("CREATE TABLE IF NOT EXISTS "+a.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,l)}function fo(n){var a=this,o={db:null};if(n)for(var l in n)o[l]=typeof n[l]!="string"?n[l].toString():n[l];var u=new h(function(c,m){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(g){return m(g)}o.db.transaction(function(g){$r(g,o,function(){a._dbInfo=o,c()},function(y,b){m(b)})},m)});return o.serializer=Bt,u}function pe(n,a,o,l,u,c){n.executeSql(o,l,u,function(m,g){g.code===g.SYNTAX_ERR?m.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[a.storeName],function(y,b){b.rows.length?c(y,g):$r(y,a,function(){y.executeSql(o,l,u,c)},c)},c):c(m,g)},c)}function mo(n,a){var o=this;n=C(n);var l=new h(function(u,c){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){pe(g,m,"SELECT * FROM "+m.storeName+" WHERE key = ? LIMIT 1",[n],function(y,b){var _=b.rows.length?b.rows.item(0).value:null;_&&(_=m.serializer.deserialize(_)),u(_)},function(y,b){c(b)})})}).catch(c)});return E(l,a),l}function ho(n,a){var o=this,l=new h(function(u,c){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){pe(g,m,"SELECT * FROM "+m.storeName,[],function(y,b){for(var _=b.rows,A=_.length,F=0;F<A;F++){var B=_.item(F),$=B.value;if($&&($=m.serializer.deserialize($)),$=n($,B.key,F+1),$!==void 0){u($);return}}u()},function(y,b){c(b)})})}).catch(c)});return E(l,a),l}function Vr(n,a,o,l){var u=this;n=C(n);var c=new h(function(m,g){u.ready().then(function(){a===void 0&&(a=null);var y=a,b=u._dbInfo;b.serializer.serialize(a,function(_,A){A?g(A):b.db.transaction(function(F){pe(F,b,"INSERT OR REPLACE INTO "+b.storeName+" (key, value) VALUES (?, ?)",[n,_],function(){m(y)},function(B,$){g($)})},function(F){if(F.code===F.QUOTA_ERR){if(l>0){m(Vr.apply(u,[n,y,o,l-1]));return}g(F)}})})}).catch(g)});return E(c,o),c}function po(n,a,o){return Vr.apply(this,[n,a,o,1])}function go(n,a){var o=this;n=C(n);var l=new h(function(u,c){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){pe(g,m,"DELETE FROM "+m.storeName+" WHERE key = ?",[n],function(){u()},function(y,b){c(b)})})}).catch(c)});return E(l,a),l}function vo(n){var a=this,o=new h(function(l,u){a.ready().then(function(){var c=a._dbInfo;c.db.transaction(function(m){pe(m,c,"DELETE FROM "+c.storeName,[],function(){l()},function(g,y){u(y)})})}).catch(u)});return E(o,n),o}function yo(n){var a=this,o=new h(function(l,u){a.ready().then(function(){var c=a._dbInfo;c.db.transaction(function(m){pe(m,c,"SELECT COUNT(key) as c FROM "+c.storeName,[],function(g,y){var b=y.rows.item(0).c;l(b)},function(g,y){u(y)})})}).catch(u)});return E(o,n),o}function bo(n,a){var o=this,l=new h(function(u,c){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){pe(g,m,"SELECT key FROM "+m.storeName+" WHERE id = ? LIMIT 1",[n+1],function(y,b){var _=b.rows.length?b.rows.item(0).key:null;u(_)},function(y,b){c(b)})})}).catch(c)});return E(l,a),l}function _o(n){var a=this,o=new h(function(l,u){a.ready().then(function(){var c=a._dbInfo;c.db.transaction(function(m){pe(m,c,"SELECT key FROM "+c.storeName,[],function(g,y){for(var b=[],_=0;_<y.rows.length;_++)b.push(y.rows.item(_).key);l(b)},function(g,y){u(y)})})}).catch(u)});return E(o,n),o}function Eo(n){return new h(function(a,o){n.transaction(function(l){l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(u,c){for(var m=[],g=0;g<c.rows.length;g++)m.push(c.rows.item(g).name);a({db:n,storeNames:m})},function(u,c){o(c)})},function(l){o(l)})})}function To(n,a){a=P.apply(this,arguments);var o=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||o.name,n.storeName=n.storeName||o.storeName);var l=this,u;return n.name?u=new h(function(c){var m;n.name===o.name?m=l._dbInfo.db:m=openDatabase(n.name,"","",0),n.storeName?c({db:m,storeNames:[n.storeName]}):c(Eo(m))}).then(function(c){return new h(function(m,g){c.db.transaction(function(y){function b(B){return new h(function($,z){y.executeSql("DROP TABLE IF EXISTS "+B,[],function(){$()},function(J,ne){z(ne)})})}for(var _=[],A=0,F=c.storeNames.length;A<F;A++)_.push(b(c.storeNames[A]));h.all(_).then(function(){m()}).catch(function(B){g(B)})},function(y){g(y)})})}):u=h.reject("Invalid arguments"),E(u,a),u}var Io={_driver:"webSQLStorage",_initStorage:fo,_support:ao(),iterate:ho,getItem:mo,setItem:po,removeItem:go,clear:vo,length:yo,key:bo,keys:_o,dropInstance:To};function wo(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(n){return!1}}function jr(n,a){var o=n.name+"/";return n.storeName!==a.storeName&&(o+=n.storeName+"/"),o}function Ao(){var n="_localforage_support_test";try{return localStorage.setItem(n,!0),localStorage.removeItem(n),!1}catch(a){return!0}}function So(){return!Ao()||localStorage.length>0}function Ro(n){var a=this,o={};if(n)for(var l in n)o[l]=n[l];return o.keyPrefix=jr(n,a._defaultConfig),So()?(a._dbInfo=o,o.serializer=Bt,h.resolve()):h.reject()}function xo(n){var a=this,o=a.ready().then(function(){for(var l=a._dbInfo.keyPrefix,u=localStorage.length-1;u>=0;u--){var c=localStorage.key(u);c.indexOf(l)===0&&localStorage.removeItem(c)}});return E(o,n),o}function ko(n,a){var o=this;n=C(n);var l=o.ready().then(function(){var u=o._dbInfo,c=localStorage.getItem(u.keyPrefix+n);return c&&(c=u.serializer.deserialize(c)),c});return E(l,a),l}function Co(n,a){var o=this,l=o.ready().then(function(){for(var u=o._dbInfo,c=u.keyPrefix,m=c.length,g=localStorage.length,y=1,b=0;b<g;b++){var _=localStorage.key(b);if(_.indexOf(c)===0){var A=localStorage.getItem(_);if(A&&(A=u.serializer.deserialize(A)),A=n(A,_.substring(m),y++),A!==void 0)return A}}});return E(l,a),l}function Po(n,a){var o=this,l=o.ready().then(function(){var u=o._dbInfo,c;try{c=localStorage.key(n)}catch(m){c=null}return c&&(c=c.substring(u.keyPrefix.length)),c});return E(l,a),l}function Do(n){var a=this,o=a.ready().then(function(){for(var l=a._dbInfo,u=localStorage.length,c=[],m=0;m<u;m++){var g=localStorage.key(m);g.indexOf(l.keyPrefix)===0&&c.push(g.substring(l.keyPrefix.length))}return c});return E(o,n),o}function Oo(n){var a=this,o=a.keys().then(function(l){return l.length});return E(o,n),o}function Fo(n,a){var o=this;n=C(n);var l=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+n)});return E(l,a),l}function No(n,a,o){var l=this;n=C(n);var u=l.ready().then(function(){a===void 0&&(a=null);var c=a;return new h(function(m,g){var y=l._dbInfo;y.serializer.serialize(a,function(b,_){if(_)g(_);else try{localStorage.setItem(y.keyPrefix+n,b),m(c)}catch(A){(A.name==="QuotaExceededError"||A.name==="NS_ERROR_DOM_QUOTA_REACHED")&&g(A),g(A)}})})});return E(u,o),u}function Uo(n,a){if(a=P.apply(this,arguments),n=typeof n!="function"&&n||{},!n.name){var o=this.config();n.name=n.name||o.name,n.storeName=n.storeName||o.storeName}var l=this,u;return n.name?u=new h(function(c){n.storeName?c(jr(n,l._defaultConfig)):c(n.name+"/")}).then(function(c){for(var m=localStorage.length-1;m>=0;m--){var g=localStorage.key(m);g.indexOf(c)===0&&localStorage.removeItem(g)}}):u=h.reject("Invalid arguments"),E(u,a),u}var Lo={_driver:"localStorageWrapper",_initStorage:Ro,_support:wo(),iterate:Co,getItem:ko,setItem:No,removeItem:Fo,clear:xo,length:Oo,key:Po,keys:Do,dropInstance:Uo},Bo=function(a,o){return a===o||typeof a=="number"&&typeof o=="number"&&isNaN(a)&&isNaN(o)},Mo=function(a,o){for(var l=a.length,u=0;u<l;){if(Bo(a[u],o))return!0;u++}return!1},Kr=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"},Oe={},Gr={},Ae={INDEXEDDB:so,WEBSQL:Io,LOCALSTORAGE:Lo},$o=[Ae.INDEXEDDB._driver,Ae.WEBSQL._driver,Ae.LOCALSTORAGE._driver],Je=["dropInstance"],Mt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Je),Vo={description:"",driver:$o.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function jo(n,a){n[a]=function(){var o=arguments;return n.ready().then(function(){return n[a].apply(n,o)})}}function $t(){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(a)for(var o in a)a.hasOwnProperty(o)&&(Kr(a[o])?arguments[0][o]=a[o].slice():arguments[0][o]=a[o])}return arguments[0]}var Ko=function(){function n(a){p(this,n);for(var o in Ae)if(Ae.hasOwnProperty(o)){var l=Ae[o],u=l._driver;this[o]=u,Oe[u]||this.defineDriver(l)}this._defaultConfig=$t({},Vo),this._config=$t({},this._defaultConfig,a),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return n.prototype.config=function(o){if((typeof o=="undefined"?"undefined":f(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var l in o){if(l==="storeName"&&(o[l]=o[l].replace(/\W/g,"_")),l==="version"&&typeof o[l]!="number")return new Error("Database version must be a number.");this._config[l]=o[l]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},n.prototype.defineDriver=function(o,l,u){var c=new h(function(m,g){try{var y=o._driver,b=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){g(b);return}for(var _=Mt.concat("_initStorage"),A=0,F=_.length;A<F;A++){var B=_[A],$=!Mo(Je,B);if(($||o[B])&&typeof o[B]!="function"){g(b);return}}var z=function(){for(var Fe=function(Jo){return function(){var Wo=new Error("Method "+Jo+" is not implemented by the current driver"),Hr=h.reject(Wo);return E(Hr,arguments[arguments.length-1]),Hr}},Vt=0,Ho=Je.length;Vt<Ho;Vt++){var jt=Je[Vt];o[jt]||(o[jt]=Fe(jt))}};z();var J=function(Fe){Oe[y]&&console.info("Redefining LocalForage driver: "+y),Oe[y]=o,Gr[y]=Fe,m()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(J,g):J(!!o._support):J(!0)}catch(ne){g(ne)}});return D(c,l,u),c},n.prototype.driver=function(){return this._driver||null},n.prototype.getDriver=function(o,l,u){var c=Oe[o]?h.resolve(Oe[o]):h.reject(new Error("Driver not found."));return D(c,l,u),c},n.prototype.getSerializer=function(o){var l=h.resolve(Bt);return D(l,o),l},n.prototype.ready=function(o){var l=this,u=l._driverSet.then(function(){return l._ready===null&&(l._ready=l._initDriver()),l._ready});return D(u,o,o),u},n.prototype.setDriver=function(o,l,u){var c=this;Kr(o)||(o=[o]);var m=this._getSupportedDrivers(o);function g(){c._config.driver=c.driver()}function y(A){return c._extend(A),g(),c._ready=c._initStorage(c._config),c._ready}function b(A){return function(){var F=0;function B(){for(;F<A.length;){var $=A[F];return F++,c._dbInfo=null,c._ready=null,c.getDriver($).then(y).catch(B)}g();var z=new Error("No available storage method found.");return c._driverSet=h.reject(z),c._driverSet}return B()}}var _=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=_.then(function(){var A=m[0];return c._dbInfo=null,c._ready=null,c.getDriver(A).then(function(F){c._driver=F._driver,g(),c._wrapLibraryMethodsWithReady(),c._initDriver=b(m)})}).catch(function(){g();var A=new Error("No available storage method found.");return c._driverSet=h.reject(A),c._driverSet}),D(this._driverSet,l,u),this._driverSet},n.prototype.supports=function(o){return!!Gr[o]},n.prototype._extend=function(o){$t(this,o)},n.prototype._getSupportedDrivers=function(o){for(var l=[],u=0,c=o.length;u<c;u++){var m=o[u];this.supports(m)&&l.push(m)}return l},n.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,l=Mt.length;o<l;o++)jo(this,Mt[o])},n.prototype.createInstance=function(o){return new n(o)},n}(),Go=new Ko;s.exports=Go},{3:3}]},{},[4])(4)})});var Hn=Yr(Ie=>{"use strict";j();je();Ee();var Ce=oe(),rs=se("levelFinished",{paramsSchema:S.tuple(S.string(),S.object({result:S.boolean(),duration:S.number()})),implement:(e,t)=>U(Ie,null,function*(){let{result:r,duration:i}=t;ae.info("onLevelFinished",r,i),yield Promise.all([le.reporter({event:"COMPLETE_GAME_LEVEL"}),le.tracker("LevelFinished",{levelId:e,result:r,duration:i})])})}),ns=se("taskFinished",{paramsSchema:S.tuple(S.string(),S.object({duration:S.number()})),implement:(e,t)=>U(Ie,null,function*(){let{duration:r}=t;yield le.tracker("TaskFinished",{duration:r,taskId:e})})}),os=se("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:(e,t)=>U(Ie,null,function*(){return yield le.tracker("LevelUpgrade",{name:t,levelId:e})})}),is=se("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:e=>U(Ie,null,function*(){return yield le.tracker("HistoryUserLevel",{level:e})})}),ss=se("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:e=>U(Ie,null,function*(){return yield le.tracker("HistoryUserScore",{score:e})})}),as=se("taskEvent",{paramsSchema:S.tuple(S.string(),S.object({tools:S.array(S.object({id:S.string(),name:S.string(),count:S.number(),description:S.string().optional(),price:S.object({amount:S.number(),unit:S.string()}).optional()})).optional(),awards:S.array(S.object({id:S.string(),name:S.string()})).optional()})),implement:(e,t)=>U(Ie,null,function*(){var r;(r=t.tools)!=null&&r.length&&(yield Promise.all([le.reporter({event:"USE_GAME_ITEM"}),le.tracker("UseGameItem",M({taskId:e},t))]))})});Ce.registerCommand("TaskTrackerSDK.levelFinished",rs);Ce.registerCommand("TaskTrackerSDK.taskFinished",ns);Ce.registerCommand("TaskTrackerSDK.levelUpgrade",os);Ce.registerCommand("TaskTrackerSDK.historyUserLevel",is);Ce.registerCommand("TaskTrackerSDK.historyUserScore",ss);Ce.registerCommand("TaskTrackerSDK.taskEvent",as);q("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});q("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});q("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});q("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});q("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});q("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});Ee();ie();je();j();var $n=oe(),$i="env",Vi="getSystemInfoSync",ji=()=>{var s,d,f,p;let e={system:R.deviceInfo.system,platform:R.deviceInfo.platform,brand:R.deviceInfo.brand,pixelRatio:R.deviceInfo.pixelRatio,language:R.deviceInfo.lang,version:R.sdkInfo.jssdkVersion,appName:(s=R.hostInfo)==null?void 0:s.appName,SDKVersion:R.sdkInfo.nativeSDKVersion},t=(d=R.hostInfo)==null?void 0:d.version;t&&(e=W(M({},e),{version:t}));let r=(f=R.hostInfo)==null?void 0:f.appName;r&&(e=W(M({},e),{appName:r}));let i=(p=R.sdkInfo)==null?void 0:p.jssdkVersion;return i&&(e=W(M({},e),{SDKVersion:i})),e},Ki=Te(Vi,{implement:ji}),Gi=Te($i,{implement:()=>W(M({},R.hostInfo),{sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});$n.registerCommand("API.env",Gi);$n.registerCommand("API.getSystemInfoSync",Ki);q("env",{version:"1.0.0"});q("getSystemInfoSync",{version:"1.0.0"});j();je();ve();Ee();var Hi="onJoliboxShow",Ji="onJoliboxHide",Wi="onReady",Er=oe(),Tr=dn(ce),_r=!0,Ke=!0,It=0,wt=mr;function zi(){let e=Date.now();if(e-It<100)return;It=e;let t=document.visibilityState==="visible";t!==_r&&(_r=t,wt.emit("visible",_r))}function Vn(e){let t=Date.now();t-It<100||(It=t,e==="focus"&&!Ke?Ke=!0:e==="blur"&&Ke&&(Ke=!1),wt.emit("visible",Ke))}document.addEventListener("visibilitychange",zi);window.addEventListener("focus",()=>Vn("focus"));window.addEventListener("blur",()=>Vn("blur"));var Yi=Te(Hi,{paramsSchema:S.tuple(S.function()),implement(e){let t=Tr(e);wt.on("visible",r=>{r&&t()})}}),qi=Te(Ji,{paramsSchema:S.tuple(S.function()),implement(e){let t=Tr(e);wt.on("visible",r=>{!r&&t()})}}),Qi=Te(Wi,{paramsSchema:S.tuple(S.function()),implement(e){let t=Tr(e);$e.on("LifecycleEvent.onReady",r=>{t(r)})}});Er.registerCommand("LifecycleSDK.onReady",Qi);Er.registerCommand("LifecycleSDK.onJoliboxShow",Yi);Er.registerCommand("LifecycleSDK.onJoliboxHide",qi);q("lifeCycle.onReady",{version:"1.0.0"});q("lifeCycle.onJoliboxShow",{version:"1.0.0"});q("lifeCycle.onJoliboxHide",{version:"1.0.0"});je();j();Ve();ie();var Gn=qr(Kn());var At=oe(),wr=class{constructor(){this.getGameId=()=>R.mpId;this.getItem=t=>U(this,null,function*(){let{code:r,data:i,message:s}=yield this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),d=i==null?void 0:i.value,f=s;return r!=="SUCCESS"&&(d=yield this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",d),f+="fallback to localstorage"),{code:r,message:f,data:d&&d!=="undefined"?d:null}});this.setItem=(t,r)=>U(this,null,function*(){let i=typeof r=="string"?r:String(r),{code:s,message:d}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:i}});return yield this.gameStore.setItem(t,i),{code:s,message:d}});this.removeItem=t=>U(this,null,function*(){yield this.gameStore.removeItem(t);let{code:r,message:i}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:r,message:i}});this.clear=()=>U(this,null,function*(){yield this.gameStore.clear();let{code:t,message:r}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:r}});this.gameId=this.getGameId(),this.httpClient=new ye({baseUrl:R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}),this.gameStore=Gn.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},St=new wr,Xi=se("getLocalStorage",{paramsSchema:S.tuple(S.string()),implement(e){return U(this,null,function*(){return yield St.getItem(e)})}});At.registerCommand("StorageSDK.getItem",Xi);q("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Zi=se("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),implement(e,t){return U(this,null,function*(){return yield St.setItem(e,t)})}});At.registerCommand("StorageSDK.setItem",Zi);q("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var es=se("removeStorage",{paramsSchema:S.tuple(S.string()),implement(e){return U(this,null,function*(){return yield St.removeItem(e)})}});At.registerCommand("StorageSDK.removeItem",es);q("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var ts=se("clearStorage",{implement(){return U(this,null,function*(){return yield St.clear()})}});At.registerCommand("StorageSDK.clear",ts);q("storage.clear",{version:"1.0.0"});var dl=qr(Hn());var Rt=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};var Jn="jolibox-sdk-ads-callbreak-timestamps",xt=class{constructor(t,r){this.checkNetwork=t;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{var t;try{let r=JSON.parse((t=window.localStorage.getItem(Jn))!=null?t:"[]");Array.isArray(r)?this._callAdsTimestampsForTime=r:this._callAdsTimestampsForTime=[]}catch(r){this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let r=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:r,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&r-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let r=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:r,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&r-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let r=this.checkShouldBannedInitial();if(r)return r;let i=this.checkShouldBannedForSession(t);if(i)return i;let s=this.checkShouldBannedForTime(t);return s||"ALLOWED"};var i,s,d,f,p,v;if(this.maxAllowedAdsForTime=(i=r==null?void 0:r.maxAllowedAdsForTime)!=null?i:8,this.bannedForTimeThreshold=(s=r==null?void 0:r.bannedForTimeThreshold)!=null?s:6e4,this.bannedReleaseTime=(d=r==null?void 0:r.bannedReleaseTime)!=null?d:6e4,this.maxAllowedAdsForSession=(f=r==null?void 0:r.maxAllowedAdsForSession)!=null?f:200,this.bannedForSessionThreshold=(p=r==null?void 0:r.bannedForSessionThreshold)!=null?p:6e5,this.initialThreshold=(v=r==null?void 0:r.initialThreshold)!=null?v:2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(Jn,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};ie();ie();var kt=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return U(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,i;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let s=(r=R.channel)!=null?r:"",d=this.configs[s],f=(i=d==null?void 0:d.interstitialRate)!=null?i:1;t=Math.random()<f}return this.firstRun=!1,t}};j();var Pe=new ge,Ct=class{constructor(t,r,i){this.track=t;this.httpClient=r;this.checkNetwork=i;this.configured=!1;this.config={};this.getGameId=()=>R.mpId;this.getTestAdsMode=()=>R.testAdsMode;this.asyncLoad=()=>U(this,null,function*(){var f,p,v,w,T;let t="ca-pub-7171363994453626",r,i,s=window.encodeURIComponent(window.btoa((f=this.getGameId())!=null?f:"")),d=(p=this.getTestAdsMode())!=null?p:!1;try{let k=yield this.httpClient.get("/public/ads",{query:{objectId:s,testAdsMode:`${d}`}});t=(v=k.data)==null?void 0:v.clientId,r=(w=k.data)==null?void 0:w.channelId,i=(T=k.data)==null?void 0:T.unitId}catch(k){console.error("Failed to fetch client info",k)}this.clientId=t,this.channelId=r,this.unitId=i});this.asyncInit=t=>U(this,null,function*(){var s;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",i=(s=this.getTestAdsMode())!=null?s:!1;if(!document.getElementById(r)&&this.clientId){let d=document.createElement("script");d.id=r,d.async=!0,d.crossOrigin="anonymous",d.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,i&&d.setAttribute("data-adbreak-test","on"),this.channelId&&d.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(d),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((i=>i.type==="preroll")(t)){Pe.emit("isAdShowing",!0);let i=t.adBreakDone,s=d=>{Pe.emit("isAdShowing",!1),i&&i(d)};return W(M({},t),{adBreakDone:s})}else{let i=t.beforeAd,s=t.afterAd,d=()=>{Pe.emit("isAdShowing",!0),i&&i()},f=()=>{Pe.emit("isAdShowing",!1),s&&s()};return W(M({},t),{beforeAd:d,afterAd:f})}};this.adConfig=t=>{let s=t,{onReady:r}=s,i=zr(s,["onReady"]);this.track("CallAdConfig",i),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var v,w,T,k;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(v=t.adBreakDone)==null||v.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let r=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",r),(w=t.adBreakDone)==null||w.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.track("PreventAdsCheating",{reason:r});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",r),(T=t.adBreakDone)==null||T.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),this.track("PreventAdsCheating",{reason:r});return;default:break}let i=t.type,s=t.adBreakDone,d=h=>{var E;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:h.breakType,breakName:(E=h.breakName)!=null?E:"",breakFormat:h.breakFormat,breakStatus:h.breakStatus}),s&&s(h)};if(t.adBreakDone=d,t.type==="reward"){let h=t.beforeReward,E=C=>()=>{this.track("CallShowAdFn",null),C()},D=C=>{h&&h(E(C))};t.beforeReward=D}let f;switch(i){case"preroll":f={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":f={type:i,name:(k=t.name)!=null?k:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",f);let p=this.wrapAdBreakParams(t);this.push(p),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>U(this,null,function*(){var h,E,D,C;if(this.track("CallAdUnit",{adFormat:(E=(h=t.adFormat)==null?void 0:h.toString())!=null?E:null,fullWidthResponsive:(D=t.fullWidthResponsive)!=null?D:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:i,adFormat:s,fullWidthResponsive:d,style:f}=t,p;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?p=document.querySelector(r):p=r,!p)throw new Error("targeting element not found");let v=i;if(v||(v=this.unitId),!v)throw new Error("slot is required");let w=typeof s=="object"&&Array.isArray(s)?s.join(", "):s,T=document.createElement("ins");if(T.className="adsbygoogle",T.id="jolibox-ads",T.style.display="block",T.setAttribute("data-ad-client",this.clientId),T.setAttribute("data-ad-slot",v),w&&T.setAttribute("data-ad-format",w),d&&T.setAttribute("data-full-width-responsive",d),f&&T.setAttribute("style",f),(C=this.getTestAdsMode())!=null?C:!1){let P=document.createElement("div");P.style.position="absolute",P.style.top="0",P.style.left="0",P.style.width="100%",P.style.height="100%",P.style.display="flex",P.style.justifyContent="center",P.style.alignItems="center",P.style.backgroundColor="rgba(0, 0, 0, 0.5)",P.style.color="white",P.innerHTML="Test Ad",T.style.position="relative",p.appendChild(T),T.appendChild(P)}else p.appendChild(T),new MutationObserver(O=>{O.forEach(K=>{if(K.type==="attributes"&&K.attributeName==="data-ad-status"){let x=T.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:x!=null?x:"null"})}})}).observe(T,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new xt(i),this.adsActionDetection=new Rt(this.track),this.channelPolicy=new kt(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};Ee();rt();j();Ve();var Pt=oe(),Dt=new Ct(xe,new ye,()=>Re.networkIsOk);Pe.on("isAdShowing",e=>{window.dispatchEvent(new CustomEvent("JOLIBOX_ADS_EVENT",{detail:{isAdShowing:e}}))});Pt.registerCommand("AdsSDK.init",e=>{Dt.init(e)});Pt.registerCommand("AdsSDK.adConfig",e=>{Dt.adConfig(e)});Pt.registerCommand("AdsSDK.adBreak",e=>{Dt.adBreak(e)});Pt.registerCommand("AdsSDK.adUnit",e=>{Dt.adUnit(e)});j();Ee();function cs(){$e.on("onDocumentReady",e=>{$e.emit("LifecycleEvent.onReady",{isLogin:!1}),le.start(Date.now()-e)})}function Wn(){cs()}Wn();
4
4
  /*! Bundled license information:
5
5
 
6
6
  localforage/dist/localforage.js:
@@ -1,4 +1,4 @@
1
- var Hn=Object.create;var at=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Kn=Object.getPrototypeOf,qn=Object.prototype.hasOwnProperty;var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var Gn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),qt=(e,t)=>{for(var r in t)at(e,r,{get:t[r],enumerable:!0})},zn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $n(t))!qn.call(e,s)&&s!==r&&at(e,s,{get:()=>t[s],enumerable:!(n=Vn(t,s))||n.enumerable});return e};var Wn=(e,t,r)=>(r=e!=null?Hn(Kn(e)):{},zn(t||!e||!e.__esModule?at(r,"default",{value:e,enumerable:!0}):r,e));function Yn(e){return!!e?.__nativeBuffers__}function de(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!Yn(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let s;n.value?s=n.value:n.base64&&(s=Qn(n.base64)),typeof s<"u"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function Gt(e={},t=!1){let r=e,n=[];for(let[s,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let i=t?{value:o,key:s}:{base64:Xn(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var Qn,Xn,ct=p(()=>{"use strict";Qn=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let s=0;s<r;s++)n[s]=t.charCodeAt(s);return n.buffer};Xn=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let s=0;s<n;s++)t+=String.fromCharCode(r[s]);return btoa(t)}});function ts(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Qt(e){return typeof e=="object"&&Array.isArray(e)}function Xt(e){return e===!0||e===!1}function rs(e){return typeof e>"u"}function ns(e){return rs(e)||e===null}function Zt(e){return typeof e=="function"}function er(e){return C(e)&&Zt(e.then)}function tr(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function rr(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(s,o){for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i)){let a=s[i],u=o[i],l=r(a,u,i,s,o);l!==void 0?s[i]=l:zt(u)&&zt(a)?s[i]=n({...a},u):Array.isArray(u)&&Array.isArray(a)?s[i]=[...a,...u]:s[i]=u}return s}return n(e,t)}function zt(e){return e&&typeof e=="object"&&e.constructor===Object}function nr(e,t){if(Array.isArray(e))return e.concat(t)}function pe(e,t,r={}){let n=null,s,o,i,{leading:a=!1,trailing:u=!0}=r,l=()=>(i=e.apply(o,s),s=void 0,o=void 0,i),d=function(...f){s=f,o=this;let m=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,u&&!m&&l()},t),m)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function is(e,t){return(...r)=>t(e,...r)}function Ee(e){return t=>is(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new os(`${s}`))}})}function ue(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function Ts(e){return new Promise(t=>fr(e)(t))}function fr(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function ks(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new me(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Ss(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ws(e[n],t[n])}function ws(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Zt(t)){try{if(e instanceof t)return}catch{}if(!ns(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function I(){if(globalThis[dt])return globalThis[dt];let e=new Te,t=new mt,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[dt]=r,r}var Wt,Zn,es,Yt,Q,ss,pt,re,sr,or,os,ir,ar,cr,lr,dr,fe,ke,ft,P,ur,as,ht,cs,gt,ls,ds,ve,us,ms,ps,mr,vt,fs,hs,gs,pr,T,vs,ys,ye,me,H,ut,bs,lt,Es,K,Te,mt,dt,g=p(()=>{"use strict";Wt=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,es=(e,t)=>{for(var r in t)Wt(e,r,{get:t[r],enumerable:!0})},Yt=(e,t,r,n)=>{for(var s=n>1?void 0:n?Zn(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&Wt(t,r,s),s};Q=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};ss=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(ss||{}),pt=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},re=class extends pt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},sr=class extends pt{constructor(){super(...arguments),this.kind="USER_ERROR"}},or=class extends sr{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},os=class extends sr{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},ir=class extends re{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},ar=class extends re{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},cr=class extends re{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},lr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},dr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},fe=class extends pt{constructor(e,t,r,n,s){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},ke=class extends re{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},ft=class extends re{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};P={log:ue("log"),warn:ue("warn"),info:ue("info"),error:ue("error"),debug:ue("debug")};Object.assign(globalThis,{logger:P});ur=Symbol.for("Jolibox.canIUseMap"),as={};globalThis[ur]=as;ht={get config(){return globalThis[ur]}},cs=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(cs||{}),gt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(gt||{}),ls=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(ls||{}),ds=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ve={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},us=()=>ve.isiOS?"iOS":ve.isAndroid?"Android":ve.isMac?"Mac":ve.isFacebook?"Facebook":"PC",ms="device_id",ps="advertising_id",mr=e=>(localStorage.getItem(e)||localStorage.setItem(e,ds()),localStorage.getItem(e)),vt=()=>mr(ms),fs=()=>mr(ps),hs=e=>e.charAt(0).toUpperCase()+e.slice(1),gs=()=>{let e=new URLSearchParams(window.location.search);return hs(e.get("utm_source")??"")||"JoliboxSDK"},pr=e=>{let t="JoliboxWebSDK",r=us(),n=navigator.language,s=vt(),o=fs();return`${t} (${gs()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},T=class be{static{this.Undefined=new be(void 0)}constructor(t){this.element=t,this.next=be.Undefined,this.prev=be.Undefined}},vs=class{constructor(){this._first=T.Undefined,this._last=T.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===T.Undefined}clear(){let e=this._first;for(;e!==T.Undefined;){let t=e.next;e.prev=T.Undefined,e.next=T.Undefined,e=t}this._first=T.Undefined,this._last=T.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new T(e);if(this._first===T.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==T.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==T.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==T.Undefined&&e.next!==T.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===T.Undefined&&e.next===T.Undefined?(this._first=T.Undefined,this._last=T.Undefined):e.next===T.Undefined?(this._last=this._last.prev,this._last.next=T.Undefined):e.prev===T.Undefined&&(this._first=this._first.next,this._first.prev=T.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==T.Undefined;)yield e.element,e=e.next}},ys=0,ye=class{constructor(e){this.value=e,this.id=ys++}},me=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof ye&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let r=new ye(e);this._listeners?this._listeners instanceof ye?this._listeners=[this._listeners,r]:this._listeners.push(r):(this.options?.onWillAddFirstListener?.(this),this._listeners=r,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let r=this.options?.onListenerError||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(n){r(n)}}fire(e){this._listeners&&(this._listeners instanceof ye?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},H=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new me,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new vs,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},ut={};es(ut,{None:()=>bs,filter:()=>ks,once:()=>fr,toPromise:()=>Ts});bs=()=>{console.log("[Jolibox SDK] None Event")};lt=Symbol.for("Jolibox.hostEmitter"),Es=()=>{let e=new H;return globalThis[lt]||(globalThis[lt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[lt]},K=Es();Te=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new me,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ss(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Te=Yt([tr],Te);mt=class{constructor(){this._onWillExecuteCommand=new me,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new me,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Te,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=ts(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),ut.toPromise(ut.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};mt=Yt([tr],mt);dt=Symbol.for("Jolibox.commands")});function A(e,t={}){yt.emit("ERROR_REPORT",{error:e,options:t})}var yt,ne,L=p(()=>{"use strict";g();g();yt=new H,ne=new H;A.debounce=pe(A,50,{leading:!0})});function Se(e,t){return`[${e}]:${t}`}var se,bt,X=p(()=>{"use strict";L();g();L();se=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),bt=e=>new or(e)});var hr,gr,vr,yr=p(()=>{"use strict";hr=[],gr=[],vr=["env","createRequestTask","login"]});function Tr(e,t){br||(Tt=new oe({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),kt=new oe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Et=new oe({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),t("onJoliboxEnterBackground",()=>{Tt.flush(),kt.flush(),Et.flush()}),br=!0);function r(s){let{method:o,args:i,startTime:a,isForeground:u,errMsg:l=`${o}:fail no errMsg`,errNo:d=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:m,invokeCallback:h}=f,b=l.match(/\S:(\S+)\s?/)?.[1]??"fail";Tt.report({status:b,method:n(o,i),errNo:`${d}`,errMsg:l,isForeground:u,duration:Date.now()-a}),a&&m&&h&&(kt.report({status:b,method:o,isForeground:u,duration:Number((m-a).toFixed(3))}),Et.report({status:b,method:o,isForeground:u,duration:Number((Date.now()-h).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o?.method?`${s}-${o.method}`:s}return r}var Is,oe,br,Tt,kt,Et,St=p(()=>{"use strict";g();Is=e=>e==="pv"?e:"default",oe=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:s,tagNameOrder:o,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=s,this.tagNameOrder=o,this.metricName=i,this.type=Is(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,s,o,i)=>{let a=s.shift();if(a){let u=i[a];n[u]||(n[u]={}),r(n[u],s,o,i)}else n[o]||(n[o]=[]),n[o].push(i[o])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(s,o,i,a)=>{let u=o.shift();if(!u&&C(a))throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(u){let l=[];if(C(a))l.push(...Object.keys(a));else if(te(a)){if(o.length>0)throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new ke(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(d=>{s[d]||(s[d]={});let f=C(a)?a[d]:a;r(s[d],[...o],i,f)})}else s[i]?s[i]++:s[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},br=!1});function Er(e,t){let r=0,n=!0,s=new Map,o=Tr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,wt.forEach(async({method:l,args:d,resolve:f})=>{let m=await a(l,d);f(m)}),wt.length=0});let i=(l,d)=>{P.info("----resolveId",l,d);let f=s.get(Number(l));if(!f)return;let m=de(d);f(m),s.delete(Number(l))},a=(l,d)=>{let f=Date.now(),m=`${n}`;r+=1;let h=new Q;if(s.set(r,h.resolve),!n&&gr.includes(l))return new Promise(x=>{wt.push({method:l,args:d,resolve:x})});let _={...{method:l,startTime:f,args:d,isForeground:m},invokeType:"js-bridge"},F=!Rs&&hr.includes(l),W=Gt(d,F),Y=F?W:JSON.stringify(W),k;if(l.endsWith("Sync")||vr.includes(l)?k=e.call?.(l,W,r):typeof Y=="string"?(console.log("-----params",l,r),k=e.invoke(l,Y,r)):k=e.call?.(l,Y,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=de(k)}catch(x){P.error(x)}return s.delete(r),k.errorCode&&(k.errorCode=Se(l,k.errorCode)),o({..._,...k}),k}return l.endsWith("Sync")&&s.delete(r),h.promise.then(x=>(x.errorCode&&(x.errorCode=Se(l,x.errorCode)),o({..._,...x}),x))};return{invokeNative:a,applyNative:(l,d)=>{let f=a(l,d);return er(f)?f.then(m=>kr(l,m)):kr(l,f)},invokeHandler:i}}function kr(e,t){if(!C(t)){P.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:s,errorCode:o,...i}=t;if(r&&r!==`${e}:ok`)throw new cr(r,n,s,o);return i}var wt,Rs,Sr=p(()=>{"use strict";ct();g();X();yr();St();wt=[],Rs=!1});function wr(e){let t=new H,r=new oe({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,s,o){let i=de(s),a;if(i.__extra){a=i.params;let{type:u,startTime:l}=i.__extra;r.report({type:u,event:n,duration:Date.now()-l})}else a=i;t.emit(n,a,o)}}}var Ir=p(()=>{"use strict";g();ct();St()});function It(e){let{subscribeHandler:t,onNative:r,offNative:n}=wr(e),{invokeNative:s,invokeHandler:o,applyNative:i}=Er(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var Rr=p(()=>{"use strict";Sr();Ir()});var _r=p(()=>{"use strict"});var Ar=p(()=>{"use strict";Rr();_r()});var Z,B,xr,Cr=p(()=>{"use strict";g();L();B={trigger(){},exit(){return!1},onReady(e){B.trigger=e},doExit(e){B.exit=e}},xr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)A(new ar("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(s="")=>{B.trigger(),e.onDocumentReady.postMessage({path:s})};Z={onDocumentReady:t,doExit:s=>{let o=B.exit();e.doExit.postMessage({uuid:s,shouldInterrupt:o})},invoke(s,o,i){e.invoke.postMessage({event:s,paramsString:o,callbackId:i})},call(s,o,i){let a=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(o),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:xr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{B.trigger(),e.onDocumentReady(JSON.stringify({path:s}))};Z={onDocumentReady:t,invoke(s,o,i){e.invoke(JSON.stringify({event:s,paramsString:o,callbackId:i}))},doExit:s=>{let o=B.exit();e.doExit(JSON.stringify({uuid:s,shouldInterrupt:o}))},call(s,o,i){let a=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(o),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:xr};globalThis.joliboxJSCore={...n}}});function Rt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var _t=p(()=>{"use strict"});function At(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ie]=e.ports,ie.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ie.publish=function(t,r){let n=Rt(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,Pr=p(()=>{"use strict";_t()});var we=p(()=>{"use strict";Cr();Pr();_t()});var Or,_s,Fr,Nr,D,E,V,Gi,As,M=p(()=>{"use strict";Ar();we();X();g();we();Or=Z;if(!Or)throw new lr("No joliboxJScore is found, native bridge not found.");At();_s={...Or},Fr=It(_s),{invokeHandler:Nr}=Fr,{applyNative:D,invokeNative:E,onNative:V,offNative:Gi,subscribeHandler:As}=Fr;globalThis.joliboxJSBridge={callHandler:Nr,invokeHandler:Nr,subscribeHandler:As}});var xt,Dr,Ur=p(()=>{"use strict";g();L();xt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch{return{}}},Dr=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[s,o,i]=n;return{headerJson:xt(s),payloadJson:xt(o),signature:xt(i)}}else throw"joli_source is missing"}catch(t){return A(new ir(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var xs,Ie,Mr,Ct=p(()=>{"use strict";g();xs="1.1.7-beta.3",Ie=()=>xs,Mr=()=>{let e=Ie();return`${pr(e)}`}});var Cs,Ps,N,Ns,v,j=p(()=>{"use strict";g();Ur();Ct();g();Cs={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:vt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ie()},schema:window.location.href,platform:"h5"},Ps=globalThis.joliboxJSCore?.env,N=Object.assign({},Ps?.()??Cs),Ns=()=>{let{payloadJson:e,headerJson:t}=N.schema.length?Dr(N.schema):{},r=`${N.deviceInfo.did}-${new Date().getTime()}`,s=new URL(N.schema.length?N.schema:window.location.href).searchParams,o=s.get("mpId")??s.get("appId")??s.get("gameId")??"",i=e?.sessionId??s.get("sessionId")??r,a=!!(e?.testAdsMode??s.get("testAdsMode")==="true"),u=e?.joliboxEnv??s.get("joliboxEnv")??"production",l=u==="staging",d=t?.channel;return{get testMode(){return l},get testAdsMode(){return a},get joliboxEnv(){return u},get joliSource(){return s.get("joliSource")??null},get mpId(){return o??e?.id??""},get mpVersion(){return t?.ver??Ie()},get platform(){return N.platform??N.deviceInfo.platform},get deviceInfo(){return N.deviceInfo},get sdkInfo(){return N.sdkInfo},get hostInfo(){return N.hostInfo},get hostUserInfo(){return N.hostUserInfo},get sessionId(){return N.clientSessionId??i??r},get channel(){return d},get webviewId(){return N.webviewId??-1},onEnvConfigChanged:f=>{rr(N,f,nr)}}},v=Ns()});var Pt,Br,Os,Fs,Lr,Ds,jr=p(()=>{"use strict";g();L();j();g();Pt=!1,Br=(e,t)=>e==null?!1:t in e,Os=e=>Br(e,"kind"),Fs=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Lr=(e,t={},r)=>{let s={...{user_id:v.hostUserInfo?.uid??"",device_id:v.deviceInfo.did??"",timestamp:Date.now(),tag:Fs(e.name)},env:t.environment,isFromUser:r};r?ne.emit("GLOBAL_USER_ERROR",e,s):ne.emit("GLOBAL_ERROR",e,s)},Ds=e=>Br(e,"kind")&&e.kind==="USER_ERROR";yt.on("ERROR_REPORT",({error:e,options:t})=>{if(Pt)return;Pt=!0;let r=Os(e)&&e.raw?e.raw:e;try{let n=Ds(e);Lr(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new ft(`${s}, origin error: ${r.message}`);P.error(o),Lr(new ft(o.message),{environment:t.environment},!1)}finally{Pt=!1}})});var Jr=p(()=>{"use strict";jr();X();g();M();ne.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};E("trackAsync",{event:"reportJsError",data:r})});ne.on("GLOBAL_USER_ERROR",(e,t)=>{P.log("UserError",e,t)})});var Nt=p(()=>{"use strict"});function Hr(e,t){let r=(n,s,o)=>{let i={tag:n,...t,extra:{...s}};n=="globalJsError"?A(new dr(JSON.stringify(i))):e("systemLog",i,o)};return r.debounce=pe(r,500,{leading:!0}),r}function Vr(e){let t=(r,n,s)=>{let o=(s&&JSON.stringify(s))??0,i={speed_value_type:r,total_duration:n};o&&Object.assign(i,{extra:o}),e("joliboxSpeedAnalysis",i)};return t.debounce=pe(t,500,{leading:!0}),t}var $r=p(()=>{"use strict";g();g();L()});function Kr(e,t){let r=Hr(e,t),n=Vr(r);return{track:r,trackPerformance:n}}var qr=p(()=>{"use strict";$r()});var Gr=p(()=>{"use strict";j();g();g()});var zr=p(()=>{"use strict";qr();Nt();Gr()});var Re,Wr=p(()=>{"use strict";Re=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r??5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration:t??0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,s,o=!1,i=0,a=()=>{if(!o)return;let h=Date.now(),b=h-r;b>=this.interval&&(this.visible&&(i+=b,t(i)),r=h),n=requestAnimationFrame(a)},u=()=>{d(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let h=Date.now();h-r>=this.interval&&(r=h)},this.interval)},l=()=>{f(),r=Date.now(),n=requestAnimationFrame(a)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},f=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",h=>{o&&(console.log("visible",h),h?l():u())});let m=this.visible;return{start(){o||(o=!0,m?l():u())},stop(){o=!1,d(),f()}}}}});var Ot=p(()=>{"use strict"});function Qr(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:u={}}=n,d={duration:o-s,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:u.socketReused?1:0,request_from:i};(i==="public"&&Yr<Ms||i==="inner")&&(d.joli_request_number=Yr++,setTimeout(()=>{U("joliboxNetRequestResult",d)},500))}var Yr,Ms,Xr=p(()=>{"use strict";Ot();ee();Yr=0,Ms=10});function _e(e,t,r){let n=new Map,s=r?.baseUrl??"https://api.jolibox.com",o=r?.type??"public",i=r?.defaultHeaders??{};return V("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let l=n.get(u.requestTaskId);if(l)if(u.state==="success"){let{requestTaskId:d,state:f,...m}=u;l.resolve(m),n.delete(d)}else if(u.state==="fail"){let{requestTaskId:d,state:f,...m}=u;l.reject(m),n.delete(d)}else P.warn("onRequestTaskStateChange unknown event",u)}),K.on("onLoginComplete",({isLogin:u,token:l})=>{u&&l&&(i["X-JOLI-TOKEN"]=l)}),async(u,l={})=>{let d=Date.now(),f=Ls(u,{...l,baseUrl:s}),{method:m="GET",responseType:h="text",dataType:b="json",timeout:_,enableCache:F=!1,appendHostCookie:W=!0}=l,Y=Object.assign({"content-type":"application/json"},i,l.header),k={url:f,method:m,header:Y,enableCache:F,responseType:h,appendHostCookie:W};if(m=="POST"||m=="PUT"){let J=js(l.data,Y["content-type"]);k.data=J}_&&Object.assign(k,{timeout:_});let{data:{requestTaskId:x}}=E(e,k);if(typeof x!="string")throw se({code:-1,msg:"requestTaskId is not a string"});let le=(J,$)=>{Qr("request",f,{state:J,startTime:d,endTime:Date.now(),params:k,response:$,requestId:x,requestFrom:o=="public"?"public":"inner"})},{resolve:it,reject:Mn,promise:Ln}=new Q;n.set(x,{resolve:it,reject:Mn});try{let J=await Ln;le("success",J);let{data:$}=J;return b==="json"&&typeof $=="string"&&($=Bs($)),{url:f,timeout:_,method:m,response:{...J,data:$}}}catch(J){let $=J;if(C($)){let{errMsg:ge,prefetchDetail:Bn,isPrefetch:jn,errNo:Jn}=$;te(ge)&&(le("fail",{errMsg:ge,isPrefetch:jn,prefetchDetail:Bn}),A(se({code:-1,msg:ge},{errNo:Jn,errMsg:ge})))}throw J}}}function Bs(e){try{return JSON.parse(e.trim())}catch{return e}}function js(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var Ls,Ft=p(()=>{"use strict";g();Xr();Ot();M();L();X();Ls=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,s=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${s?`?${s}`:""}`:`${e}${s?`?${s}`:""}`}});var Dt,q,Ae=p(()=>{"use strict";Ct();Ft();j();Dt={"x-user-agent":Mr()};v.hostUserInfo?.token&&(Dt["x-joli-token"]=v.hostUserInfo.token);v.joliSource&&(Dt["x-joli-source"]=v.joliSource);q=_e("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:v.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Dt})});var xe,Zr=p(()=>{"use strict";j();Wr();Ae();M();xe=class extends Re{constructor(t,r,n){super(r,n),this.gameId=v.mpId,this.sessionId=v.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,s=[];s.push(q("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(s)}async reportToNative(t){let{event:r,params:n}=t;await D("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var rn={};qt(rn,{nativeTaskEmitter:()=>he,taskTracker:()=>O,track:()=>U,trackPerformance:()=>en});var Js,U,en,tn,he,O,ee=p(()=>{"use strict";Jr();g();Nt();zr();j();Zr();M();Js=(e,t,r)=>{let n=t,o={...C(n.extra)?n.extra:te(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};E("trackAsync",{event:e,data:o,webviewId:r})},{track:U,trackPerformance:en}=Kr(Js,{type:gt.AppSDK,platform:"native",jssdk_version:v.sdkInfo?.jssdkVersion??"1.0.0",mp_id:v.mpId,mp_version:v.mpVersion}),tn=I();tn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{en(e,t,r)});tn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{U(e,t)});he=new H,O=new xe(U,he)});function nn(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let o=`
1
+ var ds=Object.create;var _e=Object.defineProperty,us=Object.defineProperties,ms=Object.getOwnPropertyDescriptor,ps=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertyNames,Ae=Object.getOwnPropertySymbols,hs=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty,ar=Object.prototype.propertyIsEnumerable;var ir=(e,t,r)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&ir(e,r,t[r]);if(Ae)for(var r of Ae(t))ar.call(t,r)&&ir(e,r,t[r]);return e},_=(e,t)=>us(e,ps(t));var ae=(e,t)=>{var r={};for(var n in e)yt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ae)for(var n of Ae(e))t.indexOf(n)<0&&ar.call(e,n)&&(r[n]=e[n]);return r};var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var cr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lr=(e,t)=>{for(var r in t)_e(e,r,{get:t[r],enumerable:!0})},gs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fs(t))!yt.call(e,s)&&s!==r&&_e(e,s,{get:()=>t[s],enumerable:!(n=ms(t,s))||n.enumerable});return e};var dr=(e,t,r)=>(r=e!=null?ds(hs(e)):{},gs(t||!e||!e.__esModule?_e(r,"default",{value:e,enumerable:!0}):r,e));var y=(e,t,r)=>new Promise((n,s)=>{var o=c=>{try{a(r.next(c))}catch(l){s(l)}},i=c=>{try{a(r.throw(c))}catch(l){s(l)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,i);a((r=r.apply(e,t)).next())});function vs(e){return!!(e!=null&&e.__nativeBuffers__)}function Te(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!vs(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let s;n.value?s=n.value:n.base64&&(s=ys(n.base64)),typeof s!="undefined"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function ur(e={},t=!1){let r=e,n=[];for(let[s,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let i=t?{value:o,key:s}:{base64:bs(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var ys,bs,bt=f(()=>{"use strict";ys=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let s=0;s<r;s++)n[s]=t.charCodeAt(s);return n.buffer};bs=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let s=0;s<n;s++)t+=String.fromCharCode(r[s]);return btoa(t)}});function Es(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ce(e){return typeof e=="string"}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function hr(e){return typeof e=="object"&&Array.isArray(e)}function gr(e){return e===!0||e===!1}function ws(e){return typeof e>"u"}function Ss(e){return ws(e)||e===null}function vr(e){return typeof e=="function"}function yr(e){return M(e)&&vr(e.then)}function br(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Tr(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(s,o){for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i)){let a=s[i],c=o[i],l=r(a,c,i,s,o);l!==void 0?s[i]=l:mr(c)&&mr(a)?s[i]=n(g({},a),c):Array.isArray(c)&&Array.isArray(a)?s[i]=[...a,...c]:s[i]=c}return s}return n(e,t)}function mr(e){return e&&typeof e=="object"&&e.constructor===Object}function kr(e,t){if(Array.isArray(e))return e.concat(t)}function we(e,t,r={}){let n=null,s,o,i,{leading:a=!1,trailing:c=!0}=r,l=()=>(i=e.apply(o,s),s=void 0,o=void 0,i),u=function(...m){s=m,o=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return u.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,l()},u}function As(e,t){return(...r)=>t(e,...r)}function Oe(e){return t=>As(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new Rs(`${s}`))}})}function ke(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Js(e){return new Promise(t=>Nr(e)(t))}function Nr(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Hs(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ee(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Vs(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ks(e[n],t[n])}function Ks(e,t){if(ce(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(vr(t)){try{if(e instanceof t)return}catch(r){}if(!Ss(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function O(){if(globalThis[kt])return globalThis[kt];let e=new Ce,t=new wt,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[kt]=r,r}var pr,Ts,ks,fr,ne,Is,St,le,Er,wr,Rs,Sr,Ir,Rr,Ar,_r,Se,Ne,It,j,xr,_s,Rt,xs,At,Ps,Cs,xe,Ns,Os,Fs,Pr,_t,Ds,Us,Ms,Cr,Q,A,Ls,Bs,Pe,Ee,z,Et,js,Tt,$s,X,Ce,wt,kt,E=f(()=>{"use strict";pr=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,ks=(e,t)=>{for(var r in t)pr(e,r,{get:t[r],enumerable:!0})},fr=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ts(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&pr(t,r,s),s};ne=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Is=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Is||{}),St=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},le=class extends St{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Er=class extends St{constructor(){super(...arguments),this.kind="USER_ERROR"}},wr=class extends Er{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Rs=class extends Er{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Sr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Ir=class extends le{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Rr=class extends le{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Ar=class extends le{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},_r=class extends le{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Se=class extends St{constructor(e,t,r,n,s){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Ne=class extends le{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},It=class extends le{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};j={log:ke("log"),warn:ke("warn"),info:ke("info"),error:ke("error"),debug:ke("debug")};Object.assign(globalThis,{logger:j});xr=Symbol.for("Jolibox.canIUseMap"),_s={};globalThis[xr]=_s;Rt={get config(){return globalThis[xr]}},xs=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(xs||{}),At=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(At||{}),Ps=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Ps||{}),Cs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),xe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ns=()=>xe.isiOS?"iOS":xe.isAndroid?"Android":xe.isMac?"Mac":xe.isFacebook?"Facebook":"PC",Os="device_id",Fs="advertising_id",Pr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Cs()),localStorage.getItem(e)),_t=()=>Pr(Os),Ds=()=>Pr(Fs),Us=e=>e.charAt(0).toUpperCase()+e.slice(1),Ms=()=>{var t;let e=new URLSearchParams(window.location.search);return Us((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Cr=e=>{let t="JoliboxWebSDK",r=Ns(),n=navigator.language,s=_t(),o=Ds();return`${t} (${Ms()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},A=(Q=class{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}},Q.Undefined=new Q(void 0),Q),Ls=class{constructor(){this._first=A.Undefined,this._last=A.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===A.Undefined}clear(){let e=this._first;for(;e!==A.Undefined;){let t=e.next;e.prev=A.Undefined,e.next=A.Undefined,e=t}this._first=A.Undefined,this._last=A.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new A(e);if(this._first===A.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==A.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==A.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==A.Undefined&&e.next!==A.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===A.Undefined&&e.next===A.Undefined?(this._first=A.Undefined,this._last=A.Undefined):e.next===A.Undefined?(this._last=this._last.prev,this._last.next=A.Undefined):e.prev===A.Undefined&&(this._first=this._first.next,this._first.prev=A.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==A.Undefined;)yield e.element,e=e.next}},Bs=0,Pe=class{constructor(e){this.value=e,this.id=Bs++}},Ee=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Pe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new Pe(t);this._listeners?this._listeners instanceof Pe?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(a=(i=this.options)==null?void 0:i.onDidFirstListener)==null||a.call(i,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof Pe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},z=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new Ee,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(g({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Ls,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},Et={};ks(Et,{None:()=>js,filter:()=>Hs,once:()=>Nr,toPromise:()=>Js});js=()=>{console.log("[Jolibox SDK] None Event")};Tt=Symbol.for("Jolibox.hostEmitter"),$s=()=>{let e=new z;return globalThis[Tt]||(globalThis[Tt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Tt]},X=$s();Ce=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ee,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Vs(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Ce=fr([br],Ce);wt=class{constructor(){this._onWillExecuteCommand=new Ee,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ee,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ce,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Es(3e4)),this._starActivation}executeCommand(e,...t){return y(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Et.toPromise(Et.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};wt=fr([br],wt);kt=Symbol.for("Jolibox.commands")});function D(e,t={}){xt.emit("ERROR_REPORT",{error:e,options:t})}var xt,de,V=f(()=>{"use strict";E();E();xt=new z,de=new z;D.debounce=we(D,50,{leading:!0})});function Fe(e,t){return`[${e}]:${t}`}var ue,Pt,se=f(()=>{"use strict";V();E();V();ue=(e,t)=>{var r,n;return new Se((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Pt=e=>new wr(e)});var Or,Fr,Dr,Ur=f(()=>{"use strict";Or=[],Fr=[],Dr=["env","createRequestTask","login"]});function Lr(e,t){Mr||(Ct=new me({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Nt=new me({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Ot=new me({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),t("onJoliboxEnterBackground",()=>{Ct.flush(),Nt.flush(),Ot.flush()}),Mr=!0);function r(s){var b,v;let{method:o,args:i,startTime:a,isForeground:c,errMsg:l=`${o}:fail no errMsg`,errNo:u=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:p,invokeCallback:T}=m,I=(v=(b=l.match(/\S:(\S+)\s?/))==null?void 0:b[1])!=null?v:"fail";Ct.report({status:I,method:n(o,i),errNo:`${u}`,errMsg:l,isForeground:c,duration:Date.now()-a}),a&&p&&T&&(Nt.report({status:I,method:o,isForeground:c,duration:Number((p-a).toFixed(3))}),Ot.report({status:I,method:o,isForeground:c,duration:Number((Date.now()-T).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o!=null&&o.method?`${s}-${o.method}`:s}return r}var qs,me,Mr,Ct,Nt,Ot,Ft=f(()=>{"use strict";E();qs=e=>e==="pv"?e:"default",me=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:s,tagNameOrder:o,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=s,this.tagNameOrder=o,this.metricName=i,this.type=qs(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,s,o,i)=>{let a=s.shift();if(a){let c=i[a];n[c]||(n[c]={}),r(n[c],s,o,i)}else n[o]||(n[o]=[]),n[o].push(i[o])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(s,o,i,a)=>{let c=o.shift();if(!c&&M(a))throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let l=[];if(M(a))l.push(...Object.keys(a));else if(ce(a)){if(o.length>0)throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new Ne(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(u=>{s[u]||(s[u]={});let m=M(a)?a[u]:a;r(s[u],[...o],i,m)})}else s[i]?s[i]++:s[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},Mr=!1});function jr(e,t){let r=0,n=!0,s=new Map,o=Lr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Dt.forEach(p=>y(this,[p],function*({method:l,args:u,resolve:m}){let T=yield a(l,u);m(T)})),Dt.length=0});let i=(l,u)=>{let m=s.get(Number(l));if(!m)return;let p=Te(u);m(p),s.delete(Number(l))},a=(l,u)=>{var N,fe;let m=Date.now(),p=`${n}`;r+=1;let T=new ne;if(s.set(r,T.resolve),!n&&Fr.includes(l))return new Promise(U=>{Dt.push({method:l,args:u,resolve:U})});let b=_(g({},{method:l,startTime:m,args:u,isForeground:p}),{invokeType:"js-bridge"}),v=!Gs&&Or.includes(l),k=ur(u,v),R=v?k:JSON.stringify(k),h;if(l.endsWith("Sync")||Dr.includes(l)?h=(N=e.call)==null?void 0:N.call(e,l,k,r):typeof R=="string"?h=e.invoke(l,R,r):h=(fe=e.call)==null?void 0:fe.call(e,l,R,r),h){try{typeof h=="string"&&(h=JSON.parse(h)),h=Te(h)}catch(U){j.error(U)}return s.delete(r),h.errorCode&&(h.errorCode=Fe(l,h.errorCode)),o(g(g({},b),h)),h}return l.endsWith("Sync")&&s.delete(r),T.promise.then(U=>(U.errorCode&&(U.errorCode=Fe(l,U.errorCode)),o(g(g({},b),U)),U))};return{invokeNative:a,applyNative:(l,u)=>{let m=a(l,u);return yr(m)?m.then(p=>Br(l,p)):Br(l,m)},invokeHandler:i}}function Br(e,t){if(!M(t)){j.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:s,errorCode:o}=a,i=ae(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Rr(r,n,s,o);return i}var Dt,Gs,Jr=f(()=>{"use strict";bt();E();se();Ur();Ft();Dt=[],Gs=!1});function Hr(e){let t=new z,r=new me({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,s,o){let i=Te(s),a;if(i.__extra){a=i.params;let{type:c,startTime:l}=i.__extra;r.report({type:c,event:n,duration:Date.now()-l})}else a=i;t.emit(n,a,o)}}}var $r=f(()=>{"use strict";E();bt();Ft()});function Ut(e){let{subscribeHandler:t,onNative:r,offNative:n}=Hr(e),{invokeNative:s,invokeHandler:o,applyNative:i}=jr(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var Vr=f(()=>{"use strict";Jr();$r()});var Kr=f(()=>{"use strict"});var qr=f(()=>{"use strict";Vr();Kr()});var oe,K,Gr,zr=f(()=>{"use strict";E();V();K={trigger(){},exit(){return!1},onReady(e){K.trigger=e},doExit(e){K.exit=e}},Gr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)D(new Ir("native env failed"));else{let{data:t}=JSON.parse(e);return t!=null?t:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(s="")=>{K.trigger(),e.onDocumentReady.postMessage({path:s})};oe={onDocumentReady:t,doExit:s=>{let o=K.exit();e.doExit.postMessage({uuid:s,shouldInterrupt:o})},invoke(s,o,i){e.invoke.postMessage({event:s,paramsString:o,callbackId:i})},call(s,o,i){let a=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(o),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:Gr};globalThis.joliboxJSCore=g({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{K.trigger(),e.onDocumentReady(JSON.stringify({path:s}))};oe={onDocumentReady:t,invoke(s,o,i){e.invoke(JSON.stringify({event:s,paramsString:o,callbackId:i}))},doExit:s=>{let o=K.exit();e.doExit(JSON.stringify({uuid:s,shouldInterrupt:o}))},call(s,o,i){let a=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(o),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:Gr};globalThis.joliboxJSCore=g({},n)}});function Mt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Lt=f(()=>{"use strict"});function Bt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([he]=e.ports,he.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},he.publish=function(t,r){let n=Mt(r,"messagePort");he.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},he.postMessage("msg:setup:ok"))}}var he,Wr=f(()=>{"use strict";Lt()});var De=f(()=>{"use strict";zr();Wr();Lt()});var Qr,zs,Xr,Yr,J,x,W,va,Ws,$=f(()=>{"use strict";qr();De();se();E();De();Qr=oe;if(!Qr)throw new Ar("No joliboxJScore is found, native bridge not found.");Bt();zs=g({},Qr),Xr=Ut(zs),{invokeHandler:Yr}=Xr,{applyNative:J,invokeNative:x,onNative:W,offNative:va,subscribeHandler:Ws}=Xr;globalThis.joliboxJSBridge={callHandler:Yr,invokeHandler:Yr,subscribeHandler:Ws}});var jt,Zr,en=f(()=>{"use strict";E();V();jt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(s){return{}}},Zr=e=>{var t;try{let s=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(s!=null&&s.length){let[o,i,a]=s;return{headerJson:jt(o),payloadJson:jt(i),signature:jt(a)}}else throw"joli_source is missing"}catch(r){return D(new Sr(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Ys,Ue,tn,Jt=f(()=>{"use strict";E();Ys="1.1.7",Ue=()=>Ys,tn=()=>{let e=Ue();return`${Cr(e)}`}});var Qs,rn,Ht,nn,L,Xs,w,q=f(()=>{"use strict";E();en();Jt();E();Qs={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:_t(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ue()},schema:window.location.href,platform:"h5"},Ht=(rn=globalThis.joliboxJSCore)==null?void 0:rn.env,L=Object.assign({},(nn=Ht==null?void 0:Ht())!=null?nn:Qs),Xs=()=>{var m,p,T,I,b,v,k,R;let{payloadJson:e,headerJson:t}=L.schema.length?Zr(L.schema):{},r=`${L.deviceInfo.did}-${new Date().getTime()}`,s=new URL(L.schema.length?L.schema:window.location.href).searchParams,o=(T=(p=(m=s.get("mpId"))!=null?m:s.get("appId"))!=null?p:s.get("gameId"))!=null?T:"",i=(b=(I=e==null?void 0:e.sessionId)!=null?I:s.get("sessionId"))!=null?b:r,a=!!((v=e==null?void 0:e.testAdsMode)!=null?v:s.get("testAdsMode")==="true"),c=(R=(k=e==null?void 0:e.joliboxEnv)!=null?k:s.get("joliboxEnv"))!=null?R:"production",l=c==="staging",u=t==null?void 0:t.channel;return{get testMode(){return l},get testAdsMode(){return a},get joliboxEnv(){return c},get joliSource(){var h;return(h=s.get("joliSource"))!=null?h:null},get mpId(){var h;return(h=o!=null?o:e==null?void 0:e.id)!=null?h:""},get mpVersion(){var h;return(h=t==null?void 0:t.ver)!=null?h:Ue()},get platform(){var h;return(h=L.platform)!=null?h:L.deviceInfo.platform},get deviceInfo(){return L.deviceInfo},get sdkInfo(){return L.sdkInfo},get hostInfo(){return L.hostInfo},get hostUserInfo(){return L.hostUserInfo},get sessionId(){var h,N;return(N=(h=L.clientSessionId)!=null?h:i)!=null?N:r},get channel(){return u},get webviewId(){var h;return(h=L.webviewId)!=null?h:-1},onEnvConfigChanged:h=>{Tr(L,h,kr)}}},w=Xs()});var $t,on,Zs,eo,sn,to,an=f(()=>{"use strict";E();V();q();E();$t=!1,on=(e,t)=>e==null?!1:t in e,Zs=e=>on(e,"kind"),eo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},sn=(e,t={},r)=>{var o,i,a;let n={user_id:(i=(o=w.hostUserInfo)==null?void 0:o.uid)!=null?i:"",device_id:(a=w.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:eo(e.name)},s=_(g({},n),{env:t.environment,isFromUser:r});r?de.emit("GLOBAL_USER_ERROR",e,s):de.emit("GLOBAL_ERROR",e,s)},to=e=>on(e,"kind")&&e.kind==="USER_ERROR";xt.on("ERROR_REPORT",({error:e,options:t})=>{if($t)return;$t=!0;let r=Zs(e)&&e.raw?e.raw:e;try{let n=to(e);sn(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new It(`${s}, origin error: ${r.message}`);j.error(o),sn(new It(o.message),{environment:t.environment},!1)}finally{$t=!1}})});var cn=f(()=>{"use strict";an();se();E();$();de.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};x("trackAsync",{event:"reportJsError",data:r})});de.on("GLOBAL_USER_ERROR",(e,t)=>{j.log("UserError",e,t)})});var Vt=f(()=>{"use strict"});function ln(e,t){let r=(n,s,o)=>{let i=_(g({tag:n},t),{extra:g({},s)});n=="globalJsError"?D(new _r(JSON.stringify(i))):e("systemLog",i,o)};return r.debounce=we(r,500,{leading:!0}),r}function dn(e){let t=(r,n,s)=>{var a;let o=(a=s&&JSON.stringify(s))!=null?a:0,i={speed_value_type:r,total_duration:n};o&&Object.assign(i,{extra:o}),e("joliboxSpeedAnalysis",i)};return t.debounce=we(t,500,{leading:!0}),t}var un=f(()=>{"use strict";E();E();V()});function mn(e,t){let r=ln(e,t),n=dn(r);return{track:r,trackPerformance:n}}var pn=f(()=>{"use strict";un()});var fn=f(()=>{"use strict";q();E();E()});var hn=f(()=>{"use strict";pn();Vt();fn()});var Me,gn=f(()=>{"use strict";Me=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,s,o=!1,i=0,a=()=>{if(!o)return;let T=Date.now(),I=T-r;I>=this.interval&&(this.visible&&(i+=I,t(i)),r=T),n=requestAnimationFrame(a)},c=()=>{u(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let T=Date.now();T-r>=this.interval&&(r=T)},this.interval)},l=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",T=>{o&&(console.log("visible",T),T?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,u(),m()}}}}});var Kt=f(()=>{"use strict"});function yn(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,u={duration:o-s,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:c.socketReused?1:0,request_from:i};(i==="public"&&vn<no||i==="inner")&&(u.joli_request_number=vn++,setTimeout(()=>{H("joliboxNetRequestResult",u)},500))}var vn,no,bn=f(()=>{"use strict";Kt();ie();vn=0,no=10});function Le(e,t,r){var c,l,u;let n=new Map,s=(c=r==null?void 0:r.baseUrl)!=null?c:"https://api.jolibox.com",o=(l=r==null?void 0:r.type)!=null?l:"public",i=(u=r==null?void 0:r.defaultHeaders)!=null?u:{};return W("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let T=m,{requestTaskId:b,state:v}=T,k=ae(T,["requestTaskId","state"]);p.resolve(k),n.delete(b)}else if(m.state==="fail"){let I=m,{requestTaskId:b,state:v}=I,k=ae(I,["requestTaskId","state"]);p.reject(k),n.delete(b)}else j.warn("onRequestTaskStateChange unknown event",m)}),X.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(T,...I)=>y(this,[T,...I],function*(m,p={}){let b=Date.now(),v=so(m,_(g({},p),{baseUrl:s})),{method:k="GET",responseType:R="text",dataType:h="json",timeout:N,enableCache:fe=!1,appendHostCookie:U=!0}=p,be=Object.assign({"content-type":"application/json"},i,p.header),re={url:v,method:k,header:be,enableCache:fe,responseType:R,appendHostCookie:U};if(k=="POST"||k=="PUT"){let G=io(p.data,be["content-type"]);re.data=G}N&&Object.assign(re,{timeout:N});let{data:{requestTaskId:vt}}=x(e,re);if(typeof vt!="string")throw ue({code:-1,msg:"requestTaskId is not a string"});let or=(G,Y)=>{yn("request",v,{state:G,startTime:b,endTime:Date.now(),params:re,response:Y,requestId:vt,requestFrom:o=="public"?"public":"inner"})},{resolve:ss,reject:os,promise:is}=new ne;n.set(vt,{resolve:ss,reject:os});try{let G=yield is;or("success",G);let{data:Y}=G;return h==="json"&&typeof Y=="string"&&(Y=oo(Y)),{url:v,timeout:N,method:k,response:_(g({},G),{data:Y})}}catch(G){let Y=G;if(M(Y)){let{errMsg:Re,prefetchDetail:as,isPrefetch:cs,errNo:ls}=Y;ce(Re)&&(or("fail",{errMsg:Re,isPrefetch:cs,prefetchDetail:as}),D(ue({code:-1,msg:Re},{errNo:ls,errMsg:Re})))}throw G}})}function oo(e){try{return JSON.parse(e.trim())}catch(t){return e}}function io(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var so,qt=f(()=>{"use strict";E();bn();Kt();$();V();se();so=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,s=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${s?`?${s}`:""}`:`${e}${s?`?${s}`:""}`}});var Gt,Tn,Z,Be=f(()=>{"use strict";Jt();qt();q();Gt={"x-user-agent":tn()};(Tn=w.hostUserInfo)!=null&&Tn.token&&(Gt["x-joli-token"]=w.hostUserInfo.token);w.joliSource&&(Gt["x-joli-source"]=w.joliSource);Z=Le("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:w.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Gt})});var je,kn=f(()=>{"use strict";q();gn();Be();$();je=class extends Me{constructor(t,r,n){super(r,n),this.gameId=w.mpId,this.sessionId=w.sessionId,this.track=t}reporter(t){return y(this,null,function*(){let{event:r,params:n}=t,s=[];s.push(Z("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:g({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(s)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield J("userTrackAsync",{event:r,params:g({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var Rn={};lr(Rn,{nativeTaskEmitter:()=>Ie,taskTracker:()=>B,track:()=>H,trackPerformance:()=>Sn});var ao,En,wn,H,Sn,In,Ie,B,ie=f(()=>{"use strict";cn();E();Vt();hn();q();kn();$();ao=(e,t,r)=>{var i,a;let n=t,s=M(n.extra)?n.extra:ce(n.extra)?JSON.parse(n.extra):{},o=_(g({},s),{mp_id:(i=n.mp_id)!=null?i:"",mp_version:(a=n.mp_version)!=null?a:""});x("trackAsync",{event:e,data:o,webviewId:r})},{track:H,trackPerformance:Sn}=mn(ao,{type:At.AppSDK,platform:"native",jssdk_version:(wn=(En=w.sdkInfo)==null?void 0:En.jssdkVersion)!=null?wn:"1.0.0",mp_id:w.mpId,mp_version:w.mpVersion}),In=O();In.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Sn(e,t,r)});In.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{H(e,t)});Ie=new z,B=new je(H,Ie)});function An(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let o=`
2
2
  html[data-jolibox-root] {
3
3
  height: 100%;
4
4
  margin: 0;
@@ -16,6 +16,6 @@ var Hn=Object.create;var at=Object.defineProperty;var Vn=Object.getOwnPropertyDe
16
16
  min-height: 100dvh;
17
17
  }
18
18
  }
19
- `;e.textContent=o;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{async function o(a){let u=a instanceof URL?a.href:a,l=new Promise((d,f)=>{let m=new XMLHttpRequest;m.open("GET",u),m.responseType="arraybuffer",m.addEventListener("load",()=>d(m.response)),m.addEventListener("error",f),m.send()});try{let d=await l;return new Response(d,{headers:new Headers([["Content-Type","application/wasm"]])}).clone()}catch(d){throw console.error("Failed to load wasm:",d),d}}let i=window.fetch;window.fetch=(a,u)=>{let l=a instanceof URL?a.href:a.toString();return l.endsWith(".wasm")?o(l):i(a,u)}},s=()=>{e?.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),s}var sn=p(()=>{"use strict"});var Ce,on=p(()=>{"use strict";Ce=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}}});var an,Pe,cn=p(()=>{"use strict";an="jolibox-sdk-ads-callbreak-timestamps",Pe=class{constructor(t,r){this.checkNetwork=t;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{try{let t=JSON.parse(window.localStorage.getItem(an)??"[]");Array.isArray(t)?this._callAdsTimestampsForTime=t:this._callAdsTimestampsForTime=[]}catch{this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let r=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:r,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&r-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let r=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:r,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&r-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let r=this.checkShouldBannedInitial();if(r)return r;let n=this.checkShouldBannedForSession(t);if(n)return n;let s=this.checkShouldBannedForTime(t);return s||"ALLOWED"};if(this.maxAllowedAdsForTime=r?.maxAllowedAdsForTime??8,this.bannedForTimeThreshold=r?.bannedForTimeThreshold??6e4,this.bannedReleaseTime=r?.bannedReleaseTime??6e4,this.maxAllowedAdsForSession=r?.maxAllowedAdsForSession??200,this.bannedForSessionThreshold=r?.bannedForSessionThreshold??6e5,this.initialThreshold=r?.initialThreshold??2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(an,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}}});var Ne,ln=p(()=>{"use strict";j();Ne=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}async init(){try{this.configs=await this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch{}}shouldBypassCallingInterstitial(){let t;if(!this.configs)this.init(),t=!this.firstRun;else{let r=v.channel??"",s=this.configs[r]?.interstitialRate??1;t=Math.random()<s}return this.firstRun=!1,t}}});var Oe,Fe,Ut=p(()=>{"use strict";on();cn();j();ln();g();Oe=new H,Fe=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>v.mpId;this.getTestAdsMode=()=>v.testAdsMode;this.asyncLoad=async()=>{let t="ca-pub-7171363994453626",r,n,s=window.encodeURIComponent(window.btoa(this.getGameId()??"")),o=this.getTestAdsMode()??!1;try{let i=await this.httpClient.get("/public/ads",{query:{objectId:s,testAdsMode:`${o}`}});t=i.data?.clientId,r=i.data?.channelId,n=i.data?.unitId}catch(i){console.error("Failed to fetch client info",i)}this.clientId=t,this.channelId=r,this.unitId=n};this.asyncInit=async t=>{if(typeof window>"u")return;await this.asyncLoad();let r="google-adsense",n=this.getTestAdsMode()??!1;if(!document.getElementById(r)&&this.clientId){let s=document.createElement("script");s.id=r,s.async=!0,s.crossOrigin="anonymous",s.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&s.setAttribute("data-adbreak-test","on"),this.channelId&&s.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(s),this.track("LoadAdsenseCompleted",null)}};this.push=(t={})=>{window.adsbygoogle.push(t)};this.adConfig=t=>{let{onReady:r,...n}=t;this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){t.adBreakDone?.({breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let r=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",r),t.adBreakDone?.({breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.track("PreventAdsCheating",{reason:r});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",r),t.adBreakDone?.({breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),this.track("PreventAdsCheating",{reason:r});return;default:break}let n=t.type,s=t.adBreakDone,o=a=>{this.adsActionDetection.adBreakIsShowing=!1,Oe.emit("isAdShowing",!1),this.track("CallAdBreakDone",{breakType:a.breakType,breakName:a.breakName??"",breakFormat:a.breakFormat,breakStatus:a.breakStatus}),s&&s(a)};if(t.adBreakDone=o,t.type==="reward"){let a=t.beforeReward,u=d=>()=>{this.track("CallShowAdFn",null),d()},l=d=>{a&&a(u(d))};t.beforeReward=l}let i;switch(n){case"preroll":i={type:n};break;case"start":case"pause":case"next":case"browse":case"reward":i={type:n,name:t.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,Oe.emit("isAdShowing",!0),this.track("CallAdBreak",i),this.push(t),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=async t=>{if(this.track("CallAdUnit",{adFormat:t.adFormat?.toString()??null,fullWidthResponsive:t.fullWidthResponsive??null}),this.clientId||await this.asyncLoad(),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:s,fullWidthResponsive:o,style:i}=t,a;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?a=document.querySelector(r):a=r,!a)throw new Error("targeting element not found");let u=n;if(u||(u=this.unitId),!u)throw new Error("slot is required");let l=typeof s=="object"&&Array.isArray(s)?s.join(", "):s,d=document.createElement("ins");if(d.className="adsbygoogle",d.id="jolibox-ads",d.style.display="block",d.setAttribute("data-ad-client",this.clientId),d.setAttribute("data-ad-slot",u),l&&d.setAttribute("data-ad-format",l),o&&d.setAttribute("data-full-width-responsive",o),i&&d.setAttribute("style",i),this.getTestAdsMode()??!1){let m=document.createElement("div");m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.width="100%",m.style.height="100%",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.backgroundColor="rgba(0, 0, 0, 0.5)",m.style.color="white",m.innerHTML="Test Ad",d.style.position="relative",a.appendChild(d),d.appendChild(m)}else a.appendChild(d),new MutationObserver(h=>{h.forEach(b=>{if(b.type==="attributes"&&b.attributeName==="data-ad-status"){let _=d.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:_??"null"})}})}).observe(d,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new Pe(n),this.adsActionDetection=new Ce(this.track),this.channelPolicy=new Ne(r)}init(t){this.track("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var un={};qt(un,{config:()=>$s});function Hs(){K.on("onDocumentReady",()=>{Z?.onDocumentReady(window.location.href),U("onDocumentReady",{start_timestamp:Ue,timestamp:Date.now()})})}function Vs(){V("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&v.onEnvConfigChanged({hostUserInfo:e}),K.emit("LifecycleEvent.onReady",{...v.hostUserInfo?v.hostUserInfo:{isLogin:!1}}),U("joliboxServiceReady",{start_timestamp:Ue,timestamp:Date.now()}),O.start(t)}),V("onBeforeExit",({uuid:e})=>{Z?.doExit(e)})}function $s(){Ue=Date.now(),Vs(),Hs(),dn=nn()}var dn,De,Ue,mn=p(()=>{"use strict";M();we();j();g();ee();sn();Ut();B.onReady(()=>{});B.doExit(()=>(U("onBeforeExit",{timestamp:Date.now()}),dn?.(),O.close(Date.now()-Ue),!!De));De=!1;Oe.on("isAdShowing",e=>{console.log("isAdShowing",e),De=e,Xt(De)&&E("updateContainerConfigSync",{displayCapsuleButton:!De,webviewId:v.webviewId})})});function pn(e){let t=ht.config[e];return t||(t={},ht.config[e]=t),(r,n)=>{if(t[r]){P.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var fn=p(()=>{"use strict";g()});function Mt(e){hn=e}function Me(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Me(t)):Object.keys(e).reduce((t,r)=>(t[r]=Me(e[r]),t),{})}function G(e){return typeof e=="number"}function Lt(e){let t=Bt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Bt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var hn,S,Le,Be,je,Je,ae,He,Ve,$e,Ke,qe,Ge,ze,We,Ye,Qe,Xe,Ze,jt=p(()=>{"use strict";hn=!1;S=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(hn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${Lt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Me(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Me(this._default)}optional(){return this._optional=!0,this}};Le=class extends S{validate(t){return this._optional&&t===void 0?!0:G(t)?G(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):G(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):G(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Be=class extends S{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},je=class extends S{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(G(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(G(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},Je=class extends S{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends S{validate(t){return!0}},He=class extends S{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ve=class extends S{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},$e=class extends S{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Ke=class extends S{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${Lt(t)}`)}return!0}},qe=class extends S{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(G(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(G(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(G(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let s=!0;if(r.forEach((o,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[i]=n.fallbackValue:s=!1)}),this._uniqueItems){let o=new Map;for(let i in r)o.has(r[i])?s=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[i])}] and ${this.path}[${i}] are identical)`):o.set(r[i],i)}return s}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},Ge=class extends S{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Bt(r)!=="object")return this.fail({expect:"object",actual:r});let s=r,o=this._value;o.errors=this.errors;let i=!0;for(let a in s){let u=s[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?o.path=`${this.path}.${a}`:o.path=`${this.path}["${a}"]`,!(u===void 0&&o._optional)){if(u===void 0&&o.hasDefault){s[a]=o.defaultValue;continue}o.validate(u)||(o.hasFallback?s[a]=o.fallbackValue:i=!1)}}return i}},ze=class extends S{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Bt(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,s=!0;for(let o in this._object){let i=n[o],a=this._object[o];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?a.path=`${this.path}.${o}`:a.path=`${this.path}["${o}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[o]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[o]=a.fallbackValue:s=!1)}}return s}},We=class extends S{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Lt(this.value),actual:r}):!0}},Ye=class extends S{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,s=this._items.length;for(let o=0;o<s;o++){let i=this._items[o];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
20
- or `);this.errors.push(o)}return n}},Qe=class extends S{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let s=t[n];if(s._optional||s.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,s)=>{if(n.path=`${this.path}[${s}]`,n.errors=this.errors,t[s]===void 0&&n.hasDefault){t[s]=n.defaultValue;return}n.validate(t[s])||(n.hasFallback?t[s]=n._fallback:r=!1)}),r}},Xe=class extends S{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},Ze=class extends S{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Jt(e,t,r="param"){if(e.errors=[],e.path=r,Mt(!0),!e.validate(t)){let n=e.errors.join(`
21
- `);throw e.errors.length=0,Mt(!1),new TypeError(n)}}var c,Ht=p(()=>{"use strict";jt();jt();c={object(e){return new ze(e)},array(e){return new qe(e)},tuple(...e){return new Qe(...e)},literal(e){return new We(e)},or(...e){return new Ye(...e)},symbol(){return new Je},record(e){return new Ge(e)},function(){return new $e},boolean(){return new Be},string(){return new je},number(){return new Le},undefined(){return new He},null(){return new Ve},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Xe},enum(...e){return new Ke(...e)},typedarray(e){return new Ze(e)}}});var et,gn,vn=p(()=>{"use strict";g();L();Ht();X();et=1,gn=e=>{function t(n,s){return(...o)=>{let i=Date.now(),a={method:n,trace_id:et};et+=1;let u="SUCCESS",l=`${n}:ok`,d=0;try{if(s.paramsSchema)try{Jt(s.paramsSchema,o,"params")}catch(b){throw bt(`${n}:fail ${b.message}`)}let f=s.implement(...o),m=f,h=`${n}:ok`;if(f&&"code"in f){let{code:b,data:_,message:F}=f;u=b,m=_,h=F}return{code:u,message:h,data:m}}catch(f){let m=f;d=m.code??m.errNo??2e3,u="FAILURE";let h=m.message??m.errMsg??`${f}`;return l=`${n}:${u} ${h.replace(/^\S+:(fail|cancel)\s?/,"")}`,A(new fe(l,d)),{code:u,message:l}}finally{let f=Date.now()-i;e("apiInvoked",{...a,duration:f,status:u})}}}function r(n,s){return async(...o)=>{let i=Qt(o)?o:[o],a=Date.now(),u={method:n,trace_id:et};et+=1;let l=`${n}:ok`,d="SUCCESS",f={code:d,message:l};try{if(s.paramsSchema)try{Jt(s.paramsSchema,i,"params")}catch(b){throw bt(b.message)}let h=await s.implement(...i);if(h&&"code"in h){let{code:b,data:_,message:F}=h;d=b,l=F,h=_}return Object.assign(f,{code:d,message:l,data:h}),f}catch(m){let h=m,b=h.code??h.errNo??2e3;d="FAILURE";let _=h.message??h.errMsg??`${m}`,F=`${n}:${d} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(f,{code:d,message:F}),A(new fe(F,b)),f}finally{let m=Date.now()-a;e("apiInvoked",{...u,duration:m,status:d})}}}return{createAPI:r,createSyncAPI:t}}});var w,R,y,z=p(()=>{"use strict";fn();ee();vn();Ht();({createAPI:w,createSyncAPI:R}=gn(U)),y=pn("native")});var yn,qs,Gs,zs,Ws,bn=p(()=>{"use strict";g();z();M();yn=I(),qs="env",Gs="getSystemInfoSync",zs=R(Gs,{implement:()=>{let e=E("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:t.hostInfo?.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),Ws=R(qs,{implement:()=>E("envSync")?.data??void 0});yn.registerCommand("API.getSystemInfoSync",zs);yn.registerCommand("API.env",Ws);y("env",{version:"1.0.0"});y("getSystemInfoSync",{version:"1.0.0"})});var kn=Gn(Tn=>{"use strict";g();z();L();M();ee();var Ys="exitGame",Qs="onReady",Xs="onJoliboxShow",Zs="onJoliboxHide",tt=I(),rt=Ee(A),eo=w(Ys,{paramsSchema:c.tuple(c.function()),implement:async e=>{rt(e).call(Tn),await D("exitAppAsync")}}),to=R(Xs,{paramsSchema:c.tuple(c.function()),implement(e){let t=rt(e);V("onJoliboxEnterForeground",()=>{t.call(this),he.emit("visible",!0)})}}),ro=R(Zs,{paramsSchema:c.tuple(c.function()),implement(e){let t=rt(e);V("onJoliboxEnterBackground",()=>{t.call(this),he.emit("visible",!1)})}}),no=R(Qs,{paramsSchema:c.tuple(c.function()),implement(e){let t=rt(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});tt.registerCommand("LifecycleSDK.exit",eo);tt.registerCommand("LifecycleSDK.onReady",no);tt.registerCommand("LifecycleSDK.onJoliboxShow",to);tt.registerCommand("LifecycleSDK.onJoliboxHide",ro);y("lifeCycle.exit",{version:"1.0.0"});y("lifeCycle.onReady",{version:"1.0.0"});y("lifeCycle.onJoliboxShow",{version:"1.0.0"});y("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function En(e){let t={};if(!C(e))return t;for(let[r,n]of Object.entries(e)){let s=r.toLocaleLowerCase();n?typeof n=="object"?t[s]=Object.prototype.toString.call(n):t[s]=String(n):t[s]=""}return t}function Sn(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function wn(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function In(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!C(r))return e;let[n,s=""]=e.split("?"),o=JSON.stringify({...JSON.parse(s),...r});return`${n}?${o}`}var Rn=p(()=>{"use strict";g()});var so,oo,Vt,$t,_n,io,ao,co,An=p(()=>{"use strict";X();Ft();z();Rn();g();L();so=15,oo=_e("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Vt=0,$t=[],_n=Ee(A),io=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},ao=e=>{let t=new Q,r=()=>{};return w("request",{paramsSchema:c.tuple(c.object({url:c.string(),method:c.string(),header:c.object(),data:c.object().optional(),query:c.object().optional(),dataType:c.string().default("json"),responseType:c.string().default("text"),enableCache:c.boolean().default(!1),appendHostCookie:c.boolean().default(!0),timeout:c.number().default(3e4),success:c.function(),fail:c.function()})),implement(s){let o=async()=>{let i=_n(s.fail);try{if(Vt+=1,t.state!=="pending")return;let{data:a,dataType:u,responseType:l,enableCache:d,appendHostCookie:f}=s,m=En(s.header),h=Sn(s.method),b=wn(s.timeout),_=In(s.url,h,a),F=_n(s.success),W=Object.assign({},s,{method:h,header:m,data:h==="GET"||h==="HEAD"?void 0:a,enableCache:d,query:s.query??{},dataType:u,responseType:l,appendHostCookie:f});b&&(W.timeout=b);let Y=oo(_,W);{let{response:k}=await Y,{code:x,data:le,message:it}=k;t.resolve({code:x??"SUCCESS",data:le,message:it??"request:ok"}),F({code:"SUCCESS",message:"request:ok",data:le})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Vt-=1,$t.shift()?.()}};return Vt>=so?(r=()=>{io($t,i=>i===o)},$t.push(o)):o(),t.promise}})(e),{abort(){t.reject(se({code:-1,msg:"request:fail abort"})),r()}}},co=I();co.registerCommand("HttpSDK.request",ao);y("request",{version:"1.0.0"})});function ho(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return fo.includes(t)?t:""}function go(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch{return""}}function vo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}var nt,lo,uo,mo,po,El,Sl,fo,xn=p(()=>{"use strict";z();M();g();Ae();j();nt=I(),lo=w("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await q(`/api/games/user-storage/${v.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:s}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:s?.value};try{let{data:{data:o,dataType:i}}=await D("getLocalStorageAsync",{key:e}),a=go(o,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch{return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}}});nt.registerCommand("StorageSDK.getItem",lo);y("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});uo=w("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=v.mpId,n=typeof t=="string"?t:String(t),{response:s}=await q(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:i}}=s,a=ho(t),u=vo(t,a);return await D("setLocalStorageAsync",{key:e,data:u,dataType:a}),o=="SUCCESS"?{code:o,message:i}:{code:o,message:`${i}. fallback to native`}}});nt.registerCommand("StorageSDK.setItem",uo);y("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});mo=w("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=v.mpId,{response:r}=await q(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:s}}=r;return await D("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:s}:{code:n,message:"[Jolibox SDK] remove item succ"}}});nt.registerCommand("StorageSDK.removeItem",mo);y("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});po=w("clearStorage",{async implement(){let e=v.mpId,{response:t}=await q(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});D("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});nt.registerCommand("StorageSDK.clear",po);y("storage.clear",{version:"1.0.0"});El=w("getStorageInfo",{async implement(){let{data:e}=await D("getStorageInfoAsync");return e}});y("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});Sl=R("getStorageInfoSync",{implement(){return E("getStorageInfoSync")}}),fo=["string","number","boolean","object",""]});var yo,bo,To,Kt,Cn=p(()=>{"use strict";g();M();z();yo=R("showKeyboard",{paramsSchema:c.tuple(c.object({defaultValue:c.string().optional().default(""),multiple:c.boolean().optional().default(!1),maxLength:c.unknown().optional().default(1e5)})),implement(e){let t=Math.floor(Number(e.maxLength)??1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),E("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});y("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});bo=R("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){E("updateKeyboardSync",e)}});y("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});To=R("hideKeyboard",{implement(){E("hideKeyboardSync")}});y("keyboard.hideKeyboard",{version:"1.0.0"});Kt=I();Kt.registerCommand("KeyboardSDK.showKeyboard",yo);Kt.registerCommand("KeyboardSDK.updateKeyboard",bo);Kt.registerCommand("KeyboardSDK.hideKeyboard",To)});var ce,ko,Eo,So,wo,Io,Ro,Pn=p(()=>{"use strict";g();z();ee();ce=I(),ko=w("levelFinished",{paramsSchema:c.tuple(c.string(),c.object({result:c.boolean(),duration:c.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,s=[];s.push(O.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(O.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(s)}}),Eo=w("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await O.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),So=w("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(O.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),wo=w("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await O.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Io=w("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await O.reportToNative({event:"HistoryUserScore",params:{score:e}})}),Ro=w("taskEvent",{paramsSchema:c.tuple(c.string(),c.object({tools:c.array(c.object({id:c.string(),name:c.string(),count:c.number(),description:c.string().optional(),price:c.object({amount:c.number(),unit:c.string()}).optional()})).optional(),awards:c.array(c.object({id:c.string(),name:c.string()})).optional()})),implement:async(e,t)=>{let r=[];r.push(O.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(O.reporter({event:"USE_GAME_ITEM"})),r.push(O.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",ko);ce.registerCommand("TaskTrackerSDK.taskFinished",Eo);ce.registerCommand("TaskTrackerSDK.levelUpgrade",So);ce.registerCommand("TaskTrackerSDK.historyUserLevel",wo);ce.registerCommand("TaskTrackerSDK.historyUserScore",Io);ce.registerCommand("TaskTrackerSDK.taskEvent",Ro);y("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});y("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});y("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});y("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});y("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});y("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var _o,Ao,Nn,On=p(()=>{"use strict";j();M();z();g();X();y("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});y("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});_o=w("login",{async implement(){let{data:{isLogin:e}}=await D("checkLoginAsync");if(e)return{isLogin:!0,token:v.hostUserInfo?.token};V("onLoginStateChange",({isLogin:i,token:a,uuid:u})=>{u==r&&s({isLogin:i,token:a})});let t=E("loginSync"),{data:{uuid:r}}=t;if(!r)throw se({code:-1,msg:"login failed"});let{promise:n,resolve:s}=new Q,o=await n;return v.onEnvConfigChanged({hostUserInfo:o}),K.emit("onLoginComplete",o),o}}),Ao=w("checkSession",{async implement(){let{data:{isLogin:e}}=await D("checkLoginAsync");return{isLogin:e}}}),Nn=I();Nn.registerCommand("API.login",_o);Nn.registerCommand("API.checkSession",Ao)});var st,xo,ot,Co,Po,No,Oo,Fn=p(()=>{"use strict";g();z();Ut();ee();Ae();M();st=I(),xo=()=>{let{data:e}=E("getNetworkStatusSync");return!!e?.isConnected},ot=new Fe(U,{get:(e,t)=>q(e,{method:"GET",responseType:"json",appendHostCookie:!0,...t}).then(r=>r.response.data)},xo),Co=R("adInit",{implement:e=>{ot.init(e)}}),Po=R("adConfig",{implement:e=>{ot.adConfig(e)}}),No=R("adBreak",{implement:e=>{ot.adBreak(e)}}),Oo=R("adUnit",{implement:e=>{ot.adUnit(e)}});st.registerCommand("AdsSDK.init",Co);st.registerCommand("AdsSDK.adConfig",Po);st.registerCommand("AdsSDK.adBreak",No);st.registerCommand("AdsSDK.adUnit",Oo);y("AdsSDK.init",{version:"1.0.0"});y("AdsSDK.adConfig",{version:"1.0.0"});y("AdsSDK.adBreak",{version:"1.0.0"});y("AdsSDK.adUnit",{version:"1.0.0"})});var Fo={};var Ql,Dn=p(()=>{"use strict";bn();Ql=Wn(kn());An();xn();Cn();Pn();On();Fn()});var Un=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[Un])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[Un]=!0;(async()=>{let[{config:e}]=await Promise.all([Promise.resolve().then(()=>(mn(),un)),Promise.resolve().then(()=>(Dn(),Fo)),Promise.resolve().then(()=>(ee(),rn))]);e()})();
19
+ `;e.textContent=o;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{function o(a){return y(this,null,function*(){let c=a instanceof URL?a.href:a,l=new Promise((u,m)=>{let p=new XMLHttpRequest;p.open("GET",c),p.responseType="arraybuffer",p.addEventListener("load",()=>u(p.response)),p.addEventListener("error",m),p.send()});try{let u=yield l;return new Response(u,{headers:new Headers([["Content-Type","application/wasm"]])}).clone()}catch(u){throw console.error("Failed to load wasm:",u),u}})}let i=window.fetch;window.fetch=(a,c)=>{let l=a instanceof URL?a.href:a.toString();return l.endsWith(".wasm")?o(l):i(a,c)}},s=()=>{e!=null&&e.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),s}var _n=f(()=>{"use strict"});var Je,xn=f(()=>{"use strict";Je=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}}});var Pn,He,Cn=f(()=>{"use strict";Pn="jolibox-sdk-ads-callbreak-timestamps",He=class{constructor(t,r){this.checkNetwork=t;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{var t;try{let r=JSON.parse((t=window.localStorage.getItem(Pn))!=null?t:"[]");Array.isArray(r)?this._callAdsTimestampsForTime=r:this._callAdsTimestampsForTime=[]}catch(r){this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let r=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:r,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&r-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let r=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:r,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&r-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let r=this.checkShouldBannedInitial();if(r)return r;let n=this.checkShouldBannedForSession(t);if(n)return n;let s=this.checkShouldBannedForTime(t);return s||"ALLOWED"};var n,s,o,i,a,c;if(this.maxAllowedAdsForTime=(n=r==null?void 0:r.maxAllowedAdsForTime)!=null?n:8,this.bannedForTimeThreshold=(s=r==null?void 0:r.bannedForTimeThreshold)!=null?s:6e4,this.bannedReleaseTime=(o=r==null?void 0:r.bannedReleaseTime)!=null?o:6e4,this.maxAllowedAdsForSession=(i=r==null?void 0:r.maxAllowedAdsForSession)!=null?i:200,this.bannedForSessionThreshold=(a=r==null?void 0:r.bannedForSessionThreshold)!=null?a:6e5,this.initialThreshold=(c=r==null?void 0:r.initialThreshold)!=null?c:2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(Pn,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}}});var $e,Nn=f(()=>{"use strict";q();$e=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return y(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let s=(r=w.channel)!=null?r:"",o=this.configs[s],i=(n=o==null?void 0:o.interstitialRate)!=null?n:1;t=Math.random()<i}return this.firstRun=!1,t}}});var ge,Ve,zt=f(()=>{"use strict";xn();Cn();q();Nn();E();ge=new z,Ve=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>w.mpId;this.getTestAdsMode=()=>w.testAdsMode;this.asyncLoad=()=>y(this,null,function*(){var i,a,c,l,u;let t="ca-pub-7171363994453626",r,n,s=window.encodeURIComponent(window.btoa((i=this.getGameId())!=null?i:"")),o=(a=this.getTestAdsMode())!=null?a:!1;try{let m=yield this.httpClient.get("/public/ads",{query:{objectId:s,testAdsMode:`${o}`}});t=(c=m.data)==null?void 0:c.clientId,r=(l=m.data)==null?void 0:l.channelId,n=(u=m.data)==null?void 0:u.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>y(this,null,function*(){var s;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(s=this.getTestAdsMode())!=null?s:!1;if(!document.getElementById(r)&&this.clientId){let o=document.createElement("script");o.id=r,o.async=!0,o.crossOrigin="anonymous",o.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&o.setAttribute("data-adbreak-test","on"),this.channelId&&o.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(o),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((n=>n.type==="preroll")(t)){ge.emit("isAdShowing",!0);let n=t.adBreakDone,s=o=>{ge.emit("isAdShowing",!1),n&&n(o)};return _(g({},t),{adBreakDone:s})}else{let n=t.beforeAd,s=t.afterAd,o=()=>{ge.emit("isAdShowing",!0),n&&n()},i=()=>{ge.emit("isAdShowing",!1),s&&s()};return _(g({},t),{beforeAd:o,afterAd:i})}};this.adConfig=t=>{let s=t,{onReady:r}=s,n=ae(s,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var c,l,u,m;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(c=t.adBreakDone)==null||c.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let r=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",r),(l=t.adBreakDone)==null||l.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.track("PreventAdsCheating",{reason:r});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",r),(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),this.track("PreventAdsCheating",{reason:r});return;default:break}let n=t.type,s=t.adBreakDone,o=p=>{var T;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:p.breakType,breakName:(T=p.breakName)!=null?T:"",breakFormat:p.breakFormat,breakStatus:p.breakStatus}),s&&s(p)};if(t.adBreakDone=o,t.type==="reward"){let p=t.beforeReward,T=b=>()=>{this.track("CallShowAdFn",null),b()},I=b=>{p&&p(T(b))};t.beforeReward=I}let i;switch(n){case"preroll":i={type:n};break;case"start":case"pause":case"next":case"browse":case"reward":i={type:n,name:(m=t.name)!=null?m:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",i);let a=this.wrapAdBreakParams(t);this.push(a),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>y(this,null,function*(){var p,T,I,b;if(this.track("CallAdUnit",{adFormat:(T=(p=t.adFormat)==null?void 0:p.toString())!=null?T:null,fullWidthResponsive:(I=t.fullWidthResponsive)!=null?I:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:s,fullWidthResponsive:o,style:i}=t,a;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?a=document.querySelector(r):a=r,!a)throw new Error("targeting element not found");let c=n;if(c||(c=this.unitId),!c)throw new Error("slot is required");let l=typeof s=="object"&&Array.isArray(s)?s.join(", "):s,u=document.createElement("ins");if(u.className="adsbygoogle",u.id="jolibox-ads",u.style.display="block",u.setAttribute("data-ad-client",this.clientId),u.setAttribute("data-ad-slot",c),l&&u.setAttribute("data-ad-format",l),o&&u.setAttribute("data-full-width-responsive",o),i&&u.setAttribute("style",i),(b=this.getTestAdsMode())!=null?b:!1){let v=document.createElement("div");v.style.position="absolute",v.style.top="0",v.style.left="0",v.style.width="100%",v.style.height="100%",v.style.display="flex",v.style.justifyContent="center",v.style.alignItems="center",v.style.backgroundColor="rgba(0, 0, 0, 0.5)",v.style.color="white",v.innerHTML="Test Ad",u.style.position="relative",a.appendChild(u),u.appendChild(v)}else a.appendChild(u),new MutationObserver(k=>{k.forEach(R=>{if(R.type==="attributes"&&R.attributeName==="data-ad-status"){let h=u.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:h!=null?h:"null"})}})}).observe(u,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new He(n),this.adsActionDetection=new Je(this.track),this.channelPolicy=new $e(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var On={};lr(On,{config:()=>mo});function co(){X.on("onDocumentReady",()=>{var e;(e=oe)==null||e.onDocumentReady(window.location.href),H("onDocumentReady",{start_timestamp:Ge,timestamp:Date.now()})})}function lo(e){B.start(e)}function uo(){W("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&w.onEnvConfigChanged({hostUserInfo:e}),X.emit("LifecycleEvent.onReady",g({},w.hostUserInfo?w.hostUserInfo:{isLogin:!1})),H("joliboxServiceReady",{start_timestamp:Ge,timestamp:Date.now()}),lo(t)}),W("onBeforeExit",({uuid:e})=>{var t;(t=oe)==null||t.doExit(e)})}function mo(){Ge=Date.now(),uo(),co(),Ke=An()}var Ke,qe,Ge,Fn=f(()=>{"use strict";$();De();q();E();ie();_n();zt();K.onReady(()=>{});K.doExit(()=>(H("onBeforeExit",{timestamp:Date.now()}),Ke==null||Ke(),B.close(Date.now()-Ge),!!qe));qe=!1;ge.on("isAdShowing",e=>{qe=e,gr(qe)&&x("updateContainerConfigSync",{displayCapsuleButton:!qe,webviewId:w.webviewId})})});function Dn(e){let t=Rt.config[e];return t||(t={},Rt.config[e]=t),(r,n)=>{if(t[r]){j.warn(`[can i use] ${r} already registered`);return}t[r]=g({},n)}}var Un=f(()=>{"use strict";E()});function Wt(e){Mn=e}function ze(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ze(t)):Object.keys(e).reduce((t,r)=>(t[r]=ze(e[r]),t),{})}function ee(e){return typeof e=="number"}function Yt(e){let t=Qt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Qt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Mn,P,We,Ye,Qe,Xe,ve,Ze,et,tt,rt,nt,st,ot,it,at,ct,lt,dt,Xt=f(()=>{"use strict";Mn=!1;P=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Mn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${Yt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ze(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ze(this._default)}optional(){return this._optional=!0,this}};We=class extends P{validate(t){return this._optional&&t===void 0?!0:ee(t)?ee(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ee(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ee(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Ye=class extends P{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Qe=class extends P{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ee(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ee(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},Xe=class extends P{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ve=class extends P{validate(t){return!0}},Ze=class extends P{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},et=class extends P{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},tt=class extends P{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},rt=class extends P{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${Yt(t)}`)}return!0}},nt=class extends P{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ee(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ee(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ee(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let s=!0;if(r.forEach((o,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[i]=n.fallbackValue:s=!1)}),this._uniqueItems){let o=new Map;for(let i in r)o.has(r[i])?s=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[i])}] and ${this.path}[${i}] are identical)`):o.set(r[i],i)}return s}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},st=class extends P{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(r)!=="object")return this.fail({expect:"object",actual:r});let s=r,o=this._value;o.errors=this.errors;let i=!0;for(let a in s){let c=s[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?o.path=`${this.path}.${a}`:o.path=`${this.path}["${a}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){s[a]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?s[a]=o.fallbackValue:i=!1)}}return i}},ot=class extends P{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,s=!0;for(let o in this._object){let i=n[o],a=this._object[o];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?a.path=`${this.path}.${o}`:a.path=`${this.path}["${o}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[o]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[o]=a.fallbackValue:s=!1)}}return s}},it=class extends P{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Yt(this.value),actual:r}):!0}},at=class extends P{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,s=this._items.length;for(let o=0;o<s;o++){let i=this._items[o];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
20
+ or `);this.errors.push(o)}return n}},ct=class extends P{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let s=t[n];if(s._optional||s.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,s)=>{if(n.path=`${this.path}[${s}]`,n.errors=this.errors,t[s]===void 0&&n.hasDefault){t[s]=n.defaultValue;return}n.validate(t[s])||(n.hasFallback?t[s]=n._fallback:r=!1)}),r}},lt=class extends P{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},dt=class extends P{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Zt(e,t,r="param"){if(e.errors=[],e.path=r,Wt(!0),!e.validate(t)){let n=e.errors.join(`
21
+ `);throw e.errors.length=0,Wt(!1),new TypeError(n)}}var d,er=f(()=>{"use strict";Xt();Xt();d={object(e){return new ot(e)},array(e){return new nt(e)},tuple(...e){return new ct(...e)},literal(e){return new it(e)},or(...e){return new at(...e)},symbol(){return new Xe},record(e){return new st(e)},function(){return new tt},boolean(){return new Ye},string(){return new Qe},number(){return new We},undefined(){return new Ze},null(){return new et},unknown(){return new ve},any(){return new ve},as(){return new ve},arraybuffer(){return new lt},enum(...e){return new rt(...e)},typedarray(e){return new dt(e)}}});var ut,Ln,Bn=f(()=>{"use strict";E();V();er();se();ut=1,Ln=e=>{function t(n,s){return(...o)=>{var m,p,T,I;let i=Date.now(),a={method:n,trace_id:ut};ut+=1;let c="SUCCESS",l=`${n}:ok`,u=0;try{if(s.paramsSchema)try{Zt(s.paramsSchema,o,"params")}catch(R){throw Pt(`${n}:fail ${R.message}`)}let b=s.implement(...o),v=b,k=`${n}:ok`;if(b&&"code"in b){let{code:R,data:h,message:N}=b;c=R,v=h,k=N}return{code:c,message:k,data:v}}catch(b){let v=b;u=(p=(m=v.code)!=null?m:v.errNo)!=null?p:2e3,c="FAILURE";let k=(I=(T=v.message)!=null?T:v.errMsg)!=null?I:`${b}`;return l=`${n}:${c} ${k.replace(/^\S+:(fail|cancel)\s?/,"")}`,D(new Se(l,u)),{code:c,message:l}}finally{let b=Date.now()-i;e("apiInvoked",_(g({},a),{duration:b,status:c}))}}}function r(n,s){return(...o)=>y(this,null,function*(){var p,T,I,b;let i=hr(o)?o:[o],a=Date.now(),c={method:n,trace_id:ut};ut+=1;let l=`${n}:ok`,u="SUCCESS",m={code:u,message:l};try{if(s.paramsSchema)try{Zt(s.paramsSchema,i,"params")}catch(R){throw Pt(R.message)}let k=yield s.implement(...i);if(k&&"code"in k){let{code:R,data:h,message:N}=k;u=R,l=N,k=h}return Object.assign(m,{code:u,message:l,data:k}),m}catch(v){let k=v,R=(T=(p=k.code)!=null?p:k.errNo)!=null?T:2e3;u="FAILURE";let h=(b=(I=k.message)!=null?I:k.errMsg)!=null?b:`${v}`,N=`${n}:${u} ${h.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:u,message:N}),D(new Se(N,R)),m}finally{let v=Date.now()-a;e("apiInvoked",_(g({},c),{duration:v,status:u}))}})}return{createAPI:r,createSyncAPI:t}}});var C,F,S,te=f(()=>{"use strict";Un();ie();Bn();er();({createAPI:C,createSyncAPI:F}=Ln(H)),S=Dn("native")});var jn,fo,ho,go,vo,Jn=f(()=>{"use strict";E();te();$();jn=O(),fo="env",ho="getSystemInfoSync",go=F(ho,{implement:()=>{var r;let e=x("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),vo=F(fo,{implement:()=>{var t;let e=x("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});jn.registerCommand("API.getSystemInfoSync",go);jn.registerCommand("API.env",vo);S("env",{version:"1.0.0"});S("getSystemInfoSync",{version:"1.0.0"})});var Hn=cr(tr=>{"use strict";E();te();V();$();ie();var yo="exitGame",bo="onReady",To="onJoliboxShow",ko="onJoliboxHide",mt=O(),pt=Oe(D),Eo=C(yo,{paramsSchema:d.tuple(d.function()),implement:e=>y(tr,null,function*(){pt(e).call(tr),yield J("exitAppAsync")})}),wo=F(To,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);W("onJoliboxEnterForeground",()=>{t.call(this),Ie.emit("visible",!0)})}}),So=F(ko,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);W("onJoliboxEnterBackground",()=>{t.call(this),Ie.emit("visible",!1)})}}),Io=F(bo,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);X.on("LifecycleEvent.onReady",r=>{t(r)})}});mt.registerCommand("LifecycleSDK.exit",Eo);mt.registerCommand("LifecycleSDK.onReady",Io);mt.registerCommand("LifecycleSDK.onJoliboxShow",wo);mt.registerCommand("LifecycleSDK.onJoliboxHide",So);S("lifeCycle.exit",{version:"1.0.0"});S("lifeCycle.onReady",{version:"1.0.0"});S("lifeCycle.onJoliboxShow",{version:"1.0.0"});S("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function $n(e){let t={};if(!M(e))return t;for(let[r,n]of Object.entries(e)){let s=r.toLocaleLowerCase();n?typeof n=="object"?t[s]=Object.prototype.toString.call(n):t[s]=String(n):t[s]=""}return t}function Vn(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function Kn(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function qn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!M(r))return e;let[n,s=""]=e.split("?"),o=JSON.stringify(g(g({},JSON.parse(s)),r));return`${n}?${o}`}var Gn=f(()=>{"use strict";E()});var Ro,Ao,rr,nr,zn,_o,xo,Po,Wn=f(()=>{"use strict";se();qt();te();Gn();E();V();Ro=15,Ao=Le("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),rr=0,nr=[],zn=Oe(D),_o=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},xo=e=>{let t=new ne,r=()=>{};return C("request",{paramsSchema:d.tuple(d.object({url:d.string(),method:d.string(),header:d.object(),data:d.object().optional(),query:d.object().optional(),dataType:d.string().default("json"),responseType:d.string().default("text"),enableCache:d.boolean().default(!1),appendHostCookie:d.boolean().default(!0),timeout:d.number().default(3e4),success:d.function(),fail:d.function()})),implement(s){let o=()=>y(this,null,function*(){var a,c;let i=zn(s.fail);try{if(rr+=1,t.state!=="pending")return;let{data:l,dataType:u,responseType:m,enableCache:p,appendHostCookie:T}=s,I=$n(s.header),b=Vn(s.method),v=Kn(s.timeout),k=qn(s.url,b,l),R=zn(s.success),h=Object.assign({},s,{method:b,header:I,data:b==="GET"||b==="HEAD"?void 0:l,enableCache:p,query:(a=s.query)!=null?a:{},dataType:u,responseType:m,appendHostCookie:T});v&&(h.timeout=v);let N=Ao(k,h);{let{response:fe}=yield N,{code:U,data:be,message:re}=fe;t.resolve({code:U!=null?U:"SUCCESS",data:be,message:re!=null?re:"request:ok"}),R({code:"SUCCESS",message:"request:ok",data:be})}}catch(l){t.reject(l),i({code:"FAILURE",message:"httpRequst: failed"})}finally{rr-=1,(c=nr.shift())==null||c()}});return rr>=Ro?(r=()=>{_o(nr,i=>i===o)},nr.push(o)):o(),t.promise}})(e),{abort(){t.reject(ue({code:-1,msg:"request:fail abort"})),r()}}},Po=O();Po.registerCommand("HttpSDK.request",xo);S("request",{version:"1.0.0"})});function Uo(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Do.includes(t)?t:""}function Mo(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function Lo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var ft,Co,No,Oo,Fo,cd,ld,Do,Yn=f(()=>{"use strict";te();$();E();Be();q();ft=O(),Co=C("getLocalStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let{response:t}=yield Z(`/api/games/user-storage/${w.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:s}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:s==null?void 0:s.value};try{let{data:{data:o,dataType:i}}=yield J("getLocalStorageAsync",{key:e}),a=Mo(o,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch(o){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});ft.registerCommand("StorageSDK.getItem",Co);S("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});No=C("setStorage",{paramsSchema:d.tuple(d.string(),d.or(d.string(),d.boolean(),d.number())),implement(e,t){return y(this,null,function*(){let r=w.mpId,n=typeof t=="string"?t:String(t),{response:s}=yield Z(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:i}}=s,a=Uo(t),c=Lo(t,a);return yield J("setLocalStorageAsync",{key:e,data:c,dataType:a}),o=="SUCCESS"?{code:o,message:i}:{code:o,message:`${i}. fallback to native`}})}});ft.registerCommand("StorageSDK.setItem",No);S("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Oo=C("removeStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let t=w.mpId,{response:r}=yield Z(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:s}}=r;return yield J("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:s}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ft.registerCommand("StorageSDK.removeItem",Oo);S("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Fo=C("clearStorage",{implement(){return y(this,null,function*(){let e=w.mpId,{response:t}=yield Z(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});J("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ft.registerCommand("StorageSDK.clear",Fo);S("storage.clear",{version:"1.0.0"});cd=C("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield J("getStorageInfoAsync");return e})}});S("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});ld=F("getStorageInfoSync",{implement(){return x("getStorageInfoSync")}}),Do=["string","number","boolean","object",""]});var Bo,jo,Jo,sr,Qn=f(()=>{"use strict";E();$();te();Bo=F("showKeyboard",{paramsSchema:d.tuple(d.object({defaultValue:d.string().optional().default(""),multiple:d.boolean().optional().default(!1),maxLength:d.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),x("showKeyboardSync",_(g({},e),{defaultValue:r,maxLength:t}))}});S("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});jo=F("updateKeyboard",{paramsSchema:d.tuple(d.object({value:d.string()})),implement(e){x("updateKeyboardSync",e)}});S("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Jo=F("hideKeyboard",{implement(){x("hideKeyboardSync")}});S("keyboard.hideKeyboard",{version:"1.0.0"});sr=O();sr.registerCommand("KeyboardSDK.showKeyboard",Bo);sr.registerCommand("KeyboardSDK.updateKeyboard",jo);sr.registerCommand("KeyboardSDK.hideKeyboard",Jo)});var Xn=cr(pe=>{"use strict";E();te();ie();var ye=O(),Ho=C("levelFinished",{paramsSchema:d.tuple(d.string(),d.object({result:d.boolean(),duration:d.number()})),implement:(e,t)=>y(pe,null,function*(){let{result:r,duration:n}=t,s=[];s.push(B.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(B.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(s)})}),$o=C("taskFinished",{paramsSchema:d.tuple(d.string(),d.object({duration:d.number()})),implement:(e,t)=>y(pe,null,function*(){let{duration:r}=t;return yield B.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Vo=C("levelUpgrade",{paramsSchema:d.tuple(d.string(),d.string()),implement:(e,t)=>y(pe,null,function*(){let r=[];r.push(B.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),Ko=C("onHistoryUserLevel",{paramsSchema:d.tuple(d.number()),implement:e=>y(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),qo=C("onHistoryUserScore",{paramsSchema:d.tuple(d.number()),implement:e=>y(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),Go=C("taskEvent",{paramsSchema:d.tuple(d.string(),d.object({tools:d.array(d.object({id:d.string(),name:d.string(),count:d.number(),description:d.string().optional(),price:d.object({amount:d.number(),unit:d.string()}).optional()})).optional(),awards:d.array(d.object({id:d.string(),name:d.string()})).optional()})),implement:(e,t)=>y(pe,null,function*(){var n,s;let r=[];r.push(B.reportToNative({event:"TaskEvent",params:g({taskId:e},t)})),(s=(n=t.tools)==null?void 0:n.length)!=null&&s&&(r.push(B.reporter({event:"USE_GAME_ITEM"})),r.push(B.reportToNative({event:"UseGameItem",params:g({taskId:e},t)}))),yield Promise.all(r)})});ye.registerCommand("TaskTrackerSDK.levelFinished",Ho);ye.registerCommand("TaskTrackerSDK.taskFinished",$o);ye.registerCommand("TaskTrackerSDK.levelUpgrade",Vo);ye.registerCommand("TaskTrackerSDK.historyUserLevel",Ko);ye.registerCommand("TaskTrackerSDK.historyUserScore",qo);ye.registerCommand("TaskTrackerSDK.taskEvent",Go);S("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});S("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});S("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});S("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});S("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});S("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var zo,Wo,Zn,es=f(()=>{"use strict";q();$();te();E();se();S("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});S("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});zo=C("login",{implement(){return y(this,null,function*(){var i;let{data:{isLogin:e}}=yield J("checkLoginAsync");if(e)return{isLogin:!0,token:(i=w.hostUserInfo)==null?void 0:i.token};W("onLoginStateChange",({isLogin:a,token:c,uuid:l})=>{l==r&&s({isLogin:a,token:c})});let t=x("loginSync"),{data:{uuid:r}}=t;if(!r)throw ue({code:-1,msg:"login failed"});let{promise:n,resolve:s}=new ne,o=yield n;return w.onEnvConfigChanged({hostUserInfo:o}),X.emit("onLoginComplete",o),o})}}),Wo=C("checkSession",{implement(){return y(this,null,function*(){let{data:{isLogin:e}}=yield J("checkLoginAsync");return{isLogin:e}})}}),Zn=O();Zn.registerCommand("API.login",zo);Zn.registerCommand("API.checkSession",Wo)});var ht,Yo,gt,Qo,Xo,Zo,ei,ts=f(()=>{"use strict";E();te();zt();ie();Be();$();ht=O(),Yo=()=>{let{data:e}=x("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},gt=new Ve(H,{get:(e,t)=>Z(e,g({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},Yo),Qo=F("adInit",{implement:e=>{gt.init(e)}}),Xo=F("adConfig",{implement:e=>{gt.adConfig(e)}}),Zo=F("adBreak",{implement:e=>{gt.adBreak(e)}}),ei=F("adUnit",{implement:e=>{gt.adUnit(e)}});ht.registerCommand("AdsSDK.init",Qo);ht.registerCommand("AdsSDK.adConfig",Xo);ht.registerCommand("AdsSDK.adBreak",Zo);ht.registerCommand("AdsSDK.adUnit",ei);S("AdsSDK.init",{version:"1.0.0"});S("AdsSDK.adConfig",{version:"1.0.0"});S("AdsSDK.adBreak",{version:"1.0.0"});S("AdsSDK.adUnit",{version:"1.0.0"})});var ti={};var $d,Gd,rs=f(()=>{"use strict";Jn();$d=dr(Hn());Wn();Yn();Qn();Gd=dr(Xn());es();ts()});var ns=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[ns])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[ns]=!0;y(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(Fn(),On)),Promise.resolve().then(()=>(rs(),ti)),Promise.resolve().then(()=>(ie(),Rn))]);e()});
package/esbuild.config.js CHANGED
@@ -44,6 +44,7 @@ function build(format) {
44
44
  entryPoints: ['src/index.native.ts', 'src/index.ts'],
45
45
  bundle: true,
46
46
  outdir: 'dist',
47
+ target: ['es2015', 'safari14'],
47
48
  format: format,
48
49
  minify: true,
49
50
  loader: {
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.7-beta.3 clean
3
+ > @jolibox/implement@1.1.7 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.7-beta.3 build:esm
7
+ > @jolibox/implement@1.1.7 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.7-beta.3",
4
+ "version": "1.1.7",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.1.7-beta.3",
10
- "@jolibox/types": "1.1.7-beta.3",
9
+ "@jolibox/common": "1.1.7",
10
+ "@jolibox/types": "1.1.7",
11
11
  "localforage": "1.10.0"
12
12
  },
13
13
  "devDependencies": {
@@ -374,6 +374,47 @@ export class JoliboxAdsImpl {
374
374
  window.adsbygoogle.push(params);
375
375
  };
376
376
 
377
+ /**
378
+ * Wrap adBreak params to track google adsense event and control adEventEmitter
379
+ * @param params IAdBreakParams
380
+ * @returns IAdBreakParams
381
+ */
382
+ private wrapAdBreakParams = (params: IAdBreakParams): IAdBreakParams => {
383
+ const isPreroll = (params: IAdBreakParams): params is IPrerollParams => {
384
+ return params.type === 'preroll';
385
+ };
386
+
387
+ if (isPreroll(params)) {
388
+ adEventEmitter.emit('isAdShowing', true);
389
+ const originAdBreakDone = params.adBreakDone;
390
+ const adBreakDone = (placementInfo: IPlacementInfo) => {
391
+ adEventEmitter.emit('isAdShowing', false);
392
+ if (originAdBreakDone) {
393
+ originAdBreakDone(placementInfo);
394
+ }
395
+ };
396
+ return { ...params, adBreakDone };
397
+ } else {
398
+ const originBeforeAd = params.beforeAd;
399
+ const originAfterAd = params.afterAd;
400
+
401
+ const beforeAd = () => {
402
+ adEventEmitter.emit('isAdShowing', true);
403
+ if (originBeforeAd) {
404
+ originBeforeAd();
405
+ }
406
+ };
407
+
408
+ const afterAd = () => {
409
+ adEventEmitter.emit('isAdShowing', false);
410
+ if (originAfterAd) {
411
+ originAfterAd();
412
+ }
413
+ };
414
+ return { ...params, beforeAd, afterAd };
415
+ }
416
+ };
417
+
377
418
  /**
378
419
  * The adConfig() call communicates the game's current configuration to the Ad Placement API. The Ad Placement API can use this to tune the way it preloads ads and to filter the kinds of ads it requests so they're suitable (eg. video ads that require sound).
379
420
  * @param params
@@ -477,7 +518,6 @@ export class JoliboxAdsImpl {
477
518
  const originAdBreakDone = params.adBreakDone;
478
519
  const adBreakDone = (placementInfo: IPlacementInfo) => {
479
520
  this.adsActionDetection.adBreakIsShowing = false;
480
- adEventEmitter.emit('isAdShowing', false);
481
521
  this.track('CallAdBreakDone', {
482
522
  breakType: placementInfo.breakType,
483
523
  breakName: placementInfo.breakName ?? '',
@@ -520,10 +560,12 @@ export class JoliboxAdsImpl {
520
560
  paramsToTrack = { type, name: params.name ?? '' };
521
561
  break;
522
562
  }
563
+
523
564
  this.adsActionDetection.adBreakIsShowing = true;
524
- adEventEmitter.emit('isAdShowing', true);
525
565
  this.track('CallAdBreak', paramsToTrack);
526
- this.push(params);
566
+
567
+ const wrappedParams = this.wrapAdBreakParams(params);
568
+ this.push(wrappedParams);
527
569
 
528
570
  // https://rsgce94md216.sg.larksuite.com/wiki/JGrAwRk7BiRJyekzJmKlbOawg7e?from=from_copylink
529
571
  if (window.JoliTesterBridge) {
package/src/h5/api/ads.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JoliboxAdsImpl } from '@/common/ads';
1
+ import { JoliboxAdsImpl, adEventEmitter } from '@/common/ads';
2
2
  import { track } from '../report';
3
3
  import { tracker as h5Tracker } from '../report/event-tracker';
4
4
  import { createCommands } from '@jolibox/common';
@@ -7,6 +7,10 @@ import JoliboxHttpClient from '../http';
7
7
  const commands = createCommands();
8
8
  const ads = new JoliboxAdsImpl(track, new JoliboxHttpClient(), () => h5Tracker.networkIsOk);
9
9
 
10
+ adEventEmitter.on('isAdShowing', (isAdShowing) => {
11
+ window.dispatchEvent(new CustomEvent('JOLIBOX_ADS_EVENT', { detail: { isAdShowing } }));
12
+ });
13
+
10
14
  commands.registerCommand('AdsSDK.init', (config) => {
11
15
  ads.init(config);
12
16
  });
@@ -33,7 +33,6 @@ export class H5EventTracker extends EventTracker {
33
33
  data: event,
34
34
  timeout: 5000
35
35
  });
36
- logger.info('Track', event);
37
36
  }
38
37
  }
39
38
 
@@ -34,7 +34,6 @@ export class H5TaskTracker extends TaskTracker {
34
34
  }
35
35
  }
36
36
  });
37
- logger.log('-----task tracker-----', event, params);
38
37
  }
39
38
  tracker(event: TrackEvent, info: Record<string, unknown> | null = null) {
40
39
  this.track(event, info);
@@ -26,7 +26,6 @@ RuntimeLoader.doExit(() => {
26
26
 
27
27
  let isAdShowing = false;
28
28
  adEventEmitter.on('isAdShowing', (isShowing) => {
29
- console.log('isAdShowing', isShowing);
30
29
  isAdShowing = isShowing;
31
30
  if (isBoolean(isAdShowing)) {
32
31
  invokeNative('updateContainerConfigSync', {
@@ -50,6 +49,10 @@ function addWebviewReadyListener() {
50
49
  });
51
50
  }
52
51
 
52
+ function handleTaskTracker(duration?: number) {
53
+ taskTracker.start(duration);
54
+ }
55
+
53
56
  function addGameServiceReadyListener() {
54
57
  onNative('onJoliboxServiceReady', ({ runtimeInfo, loadDuration }) => {
55
58
  runtimeInfo && context.onEnvConfigChanged({ hostUserInfo: runtimeInfo });
@@ -62,7 +65,7 @@ function addGameServiceReadyListener() {
62
65
  });
63
66
 
64
67
  // 任务上报
65
- taskTracker.start(loadDuration);
68
+ handleTaskTracker(loadDuration);
66
69
  });
67
70
 
68
71
  onNative('onBeforeExit', ({ uuid }) => {
@@ -62,7 +62,6 @@ export function createInvoke(jsCore: jsb.JSCore, onNative: On): Invokes {
62
62
  * Android resolveId 是 `string`
63
63
  * iOS 上待确认, IDE 上是 `number`
64
64
  */
65
- logger.info('----resolveId', resolveId, data);
66
65
  const resolve = resolveMap.get(Number(resolveId));
67
66
  if (!resolve) return;
68
67
  const response = unpack(data);
@@ -113,7 +112,6 @@ export function createInvoke(jsCore: jsb.JSCore, onNative: On): Invokes {
113
112
  response = jsCore.call?.(method, payload, resolveId);
114
113
  } else {
115
114
  if (typeof params === 'string') {
116
- console.log('-----params', method, resolveId);
117
115
  response = jsCore.invoke(method, params, resolveId);
118
116
  } else {
119
117
  response = jsCore.call?.(method, params, resolveId);