@jolibox/implement 1.1.7-beta.2 → 1.1.7-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +7 -7
- package/dist/common/ads/index.d.ts +10 -0
- package/dist/common/context/index.d.ts +1 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.js +3 -3
- package/dist/index.native.js +4 -4
- package/implement.build.log +2 -2
- package/package.json +3 -3
- package/src/common/ads/index.ts +49 -1
- package/src/common/context/index.ts +3 -0
- package/src/index.native.ts +5 -3
- package/src/index.ts +0 -15
- package/src/native/bootstrap/index.ts +19 -3
- package/src/native/types/native-method-map.d.ts +7 -0
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"packages/implement/.eslintrc.js": "7a3d2747dc887655ca9e2d3ff621f7dfd98500b9",
|
|
5
5
|
"packages/implement/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
|
|
6
6
|
"packages/implement/esbuild.config.js": "889e44fb2f426aae078b59a42fcfb9c2f28ebd89",
|
|
7
|
-
"packages/implement/package.json": "
|
|
7
|
+
"packages/implement/package.json": "39ef05a2e6a2104dbbd7f7e822561837aa2580dc",
|
|
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": "
|
|
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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"packages/implement/src/common/api-factory/validator/index.ts": "204e86b97c854647d177805e3180d4cfd542b0f8",
|
|
31
31
|
"packages/implement/src/common/api-factory/validator/validate.ts": "5fee8175a9a05a69fe709c7e7899e5372d81efb1",
|
|
32
32
|
"packages/implement/src/common/can-i-use.ts": "9a28562870d92b82ce42ec656c8e9d868dd87528",
|
|
33
|
-
"packages/implement/src/common/context/index.ts": "
|
|
33
|
+
"packages/implement/src/common/context/index.ts": "7778627e11c1b9e80b7763937c5eaeb9a7cf8b6d",
|
|
34
34
|
"packages/implement/src/common/context/types.ts": "244ff65de52dcbce2457ffee427f5fa102987825",
|
|
35
35
|
"packages/implement/src/common/context/url-parse.ts": "567bb6ee4124e0320431bd3c30fcae9759c99fa9",
|
|
36
36
|
"packages/implement/src/common/http/index.ts": "5087185d80e1e239262f849b3015eb9b810e2945",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"packages/implement/src/h5/report/event-tracker.ts": "eb52379559e584a5b3f7a5241a3555b667b18c8c",
|
|
62
62
|
"packages/implement/src/h5/report/index.ts": "7154000726a72f477183d069eea5de87d12ceb7d",
|
|
63
63
|
"packages/implement/src/h5/report/task-tracker.ts": "184708c10b610b305f4f87af1639d9005486218e",
|
|
64
|
-
"packages/implement/src/index.native.ts": "
|
|
65
|
-
"packages/implement/src/index.ts": "
|
|
64
|
+
"packages/implement/src/index.native.ts": "96cc46c8919ba2333600e9c3ee100f47c511a79a",
|
|
65
|
+
"packages/implement/src/index.ts": "d0ca7b5312b0a258ae8887e725440c70190442f7",
|
|
66
66
|
"packages/implement/src/native/api/ads.ts": "bec8c772e1f881dc49030082e48b32af0c7db0fb",
|
|
67
67
|
"packages/implement/src/native/api/base.ts": "c4c4d04519cdbc3a08226c620f6314ee3b151435",
|
|
68
68
|
"packages/implement/src/native/api/get-system-info.ts": "d0132211c53425eed4811721ac5d577781b118a7",
|
|
@@ -74,7 +74,7 @@
|
|
|
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": "
|
|
77
|
+
"packages/implement/src/native/bootstrap/index.ts": "31d2b3d4c6ba91c7e585e15db7a7ad2f290772b4",
|
|
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",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"packages/implement/src/native/report/index.ts": "b30ccb9ef8e9124cbf156c6bdc3751465721383a",
|
|
98
98
|
"packages/implement/src/native/report/task-tracker.ts": "09f8bc1dd157fe9a2159c261278bd2a92930cee3",
|
|
99
99
|
"packages/implement/src/native/types/global.d.ts": "065076bbecdd9a0ffe7a71c19475356a6f816cee",
|
|
100
|
-
"packages/implement/src/native/types/native-method-map.d.ts": "
|
|
100
|
+
"packages/implement/src/native/types/native-method-map.d.ts": "4f852c0331eaabb90849a652de3ea75905d98324",
|
|
101
101
|
"packages/implement/src/native/types/native-method.d.ts": "e4e22c921a5b54d4e10fe5ca18158d691fbfe3e7",
|
|
102
102
|
"packages/implement/src/utils/index.ts": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
|
|
103
103
|
"packages/implement/tsconfig.json": "b150f4b2ef4eb9d98f92135d481fe530eb7145b5"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Track } from '../report';
|
|
2
|
+
import { EventEmitter } from '@jolibox/common';
|
|
2
3
|
declare global {
|
|
3
4
|
interface Window {
|
|
4
5
|
adsbygoogle: Array<unknown>;
|
|
@@ -196,6 +197,9 @@ interface HttpClient {
|
|
|
196
197
|
query?: Record<string, string>;
|
|
197
198
|
}): Promise<T>;
|
|
198
199
|
}
|
|
200
|
+
export declare const adEventEmitter: EventEmitter<{
|
|
201
|
+
isAdShowing: [boolean];
|
|
202
|
+
}, "isAdShowing">;
|
|
199
203
|
/**
|
|
200
204
|
* Jolibox Ads SDK
|
|
201
205
|
*/
|
|
@@ -235,6 +239,12 @@ export declare class JoliboxAdsImpl {
|
|
|
235
239
|
* @param params
|
|
236
240
|
*/
|
|
237
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;
|
|
238
248
|
/**
|
|
239
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).
|
|
240
250
|
* @param params
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var so=Object.create;var Tr=Object.defineProperty;var ao=Object.getOwnPropertyDescriptor;var co=Object.getOwnPropertyNames;var lo=Object.getPrototypeOf,uo=Object.prototype.hasOwnProperty;var Te=(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 fo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var mo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of co(t))!uo.call(e,l)&&l!==n&&Tr(e,l,{get:()=>t[l],enumerable:!(i=ao(t,l))||i.enumerable});return e};var ho=(e,t,n)=>(n=e!=null?so(lo(e)):{},mo(t||!e||!e.__esModule?Tr(n,"default",{value:e,enumerable:!0}):n,e));var rn=fo((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 _(T,x){if(!d[T]){if(!l[T]){var m=typeof Te=="function"&&Te;if(!x&&m)return m(T,!0);if(E)return E(T,!0);var b=new Error("Cannot find module '"+T+"'");throw b.code="MODULE_NOT_FOUND",b}var k=d[T]={exports:{}};l[T][0].call(k.exports,function(N){var K=l[T][1][N];return _(K||N)},k,k.exports,i,l,d,h)}return d[T].exports}for(var E=typeof Te=="function"&&Te,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,T=new _(N),x=h.document.createTextNode("");T.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"],T=["FULFILLED"],x=["PENDING"];l.exports=m;function m(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,I!==_&&K(this,I)}m.prototype.catch=function(I){return this.then(null,I)},m.prototype.then=function(I,D){if(typeof I!="function"&&this.state===T||typeof D!="function"&&this.state===A)return this;var P=new this.constructor(_);if(this.state!==x){var U=this.state===T?I:D;k(P,U,this.outcome)}else this.queue.push(new b(P,I,D));return P};function b(I,D,P){this.promise=I,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof P=="function"&&(this.onRejected=P,this.callRejected=this.otherCallRejected)}b.prototype.callFulfilled=function(I){E.resolve(this.promise,I)},b.prototype.otherCallFulfilled=function(I){k(this.promise,this.onFulfilled,I)},b.prototype.callRejected=function(I){E.reject(this.promise,I)},b.prototype.otherCallRejected=function(I){k(this.promise,this.onRejected,I)};function k(I,D,P){h(function(){var U;try{U=D(P)}catch(G){return E.reject(I,G)}U===I?E.reject(I,new TypeError("Cannot resolve promise with itself")):E.resolve(I,U)})}E.resolve=function(I,D){var P=V(N,D);if(P.status==="error")return E.reject(I,P.value);var U=P.value;if(U)K(I,U);else{I.state=T,I.outcome=D;for(var G=-1,W=I.queue.length;++G<W;)I.queue[G].callFulfilled(D)}return I},E.reject=function(I,D){I.state=A,I.outcome=D;for(var P=-1,U=I.queue.length;++P<U;)I.queue[P].callRejected(D);return I};function N(I){var D=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof D=="function")return function(){D.apply(I,arguments)}}function K(I,D){var P=!1;function U(q){P||(P=!0,E.reject(I,q))}function G(q){P||(P=!0,E.resolve(I,q))}function W(){D(G,U)}var Y=V(W);Y.status==="error"&&U(Y.value)}function V(I,D){var P={};try{P.value=I(D),P.status="success"}catch(U){P.status="error",P.value=U}return P}m.resolve=re;function re(I){return I instanceof this?I:E.resolve(new this(_),I)}m.reject=J;function J(I){var D=new this(_);return E.reject(D,I)}m.all=yt;function yt(I){var D=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=I.length,U=!1;if(!P)return this.resolve([]);for(var G=new Array(P),W=0,Y=-1,q=new this(_);++Y<P;)ne(I[Y],Y);return q;function ne(_e,Ce){D.resolve(_e).then(bt,function(fe){U||(U=!0,E.reject(q,fe))});function bt(fe){G[Ce]=fe,++W===P&&!U&&(U=!0,E.resolve(q,G))}}}m.race=le;function le(I){var D=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=I.length,U=!1;if(!P)return this.resolve([]);for(var G=-1,W=new this(_);++G<P;)Y(I[G]);return W;function Y(q){D.resolve(q).then(function(ne){U||(U=!0,E.resolve(W,ne))},function(ne){U||(U=!0,E.reject(W,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 T(){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,le="readonly",I="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,I),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 W(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),W(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 fe(r){var s=D(atob(r.data));return x([s],{type:r.type})}function rr(r){return r&&r.__local_forage_encoded_blob}function an(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 cn(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 cn(r).then(function(){oe(r,s,o,c-1)})}).catch(o);o(a)}}function nr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function ln(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=an);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 un(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,le,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=fe(y)),u(y)},v.onerror=function(){a(v.error)}}catch(y){a(y)}})}).catch(a)});return b(c,s),c}function dn(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,le,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=fe(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 fn(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,I,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 mn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,I,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 hn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,I,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 pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,le,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 gn(r,s){var o=this,c=new m(function(u,a){if(r<0){u(null);return}o.ready().then(function(){oe(o._dbInfo,le,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 vn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,le,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 yn(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 Ie=B.result;Ie.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,W(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];W(M._dbInfo)}}).catch(function(O){throw(Y(r,O)||m.resolve()).catch(function(){}),O})})}return b(u,s),u}var bn={_driver:"asyncStorage",_initStorage:ln,_support:T(),iterate:dn,getItem:un,setItem:fn,removeItem:mn,clear:hn,length:pn,key:gn,keys:vn,dropInstance:yn};function _n(){return typeof openDatabase=="function"}var se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",En="~~local_forage_type~",or=/^~~local_forage_type~([^~]+)~/,Pe="__lfsc__:",_t=Pe.length,Et="arbf",It="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 Tt(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+Tt(c))}else if(o==="[object Blob]"){var a=new FileReader;a.onload=function(){var f=En+r.type+"~"+Tt(this.result);s(Pe+It+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 Tn(r){if(r.substring(0,_t)!==Pe)return JSON.parse(r);var s=r.substring(hr),o=r.substring(_t,hr),c;if(o===It&&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 It: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:Tn,stringToBuffer:gr,bufferToString:Tt};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 wn(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 Sn(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 An(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 Rn(r,s,o){return yr.apply(this,[r,s,o,1])}function xn(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 kn(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 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,"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 Pn(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 Dn(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 On(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 Fn(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(On(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 Nn={_driver:"webSQLStorage",_initStorage:wn,_support:_n(),iterate:An,getItem:Sn,setItem:Rn,removeItem:xn,clear:kn,length:Cn,key:Pn,keys:Dn,dropInstance:Fn};function Un(){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 Ln(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Bn(){return!Ln()||localStorage.length>0}function Mn(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=br(r,s._defaultConfig),Bn()?(s._dbInfo=o,o.serializer=wt,m.resolve()):m.reject()}function $n(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 Vn(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 jn(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 Kn(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 Jn(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 Gn(r){var s=this,o=s.keys().then(function(c){return c.length});return b(o,r),o}function Hn(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 Wn(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 zn(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 Yn={_driver:"localStorageWrapper",_initStorage:Mn,_support:Un(),iterate:jn,getItem:Vn,setItem:Wn,removeItem:Hn,clear:$n,length:Gn,key:Kn,keys:Jn,dropInstance:zn},qn=function(s,o){return s===o||typeof s=="number"&&typeof o=="number"&&isNaN(s)&&isNaN(o)},Qn=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={},me={INDEXEDDB:bn,WEBSQL:Nn,LOCALSTORAGE:Yn},Xn=[me.INDEXEDDB._driver,me.WEBSQL._driver,me.LOCALSTORAGE._driver],De=["dropInstance"],St=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(De),Zn={description:"",driver:Xn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function eo(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 to=function(){function r(s){_(this,r);for(var o in me)if(me.hasOwnProperty(o)){var c=me[o],u=c._driver;this[o]=u,Ee[u]||this.defineDriver(c)}this._defaultConfig=At({},Zn),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=!Qn(De,O);if((F||o[O])&&typeof o[O]!="function"){p(v);return}}var M=function(){for(var Ie=function(oo){return function(){var io=new Error("Method "+oo+" is not implemented by the current driver"),Ir=m.reject(io);return b(Ir,arguments[arguments.length-1]),Ir}},Rt=0,no=De.length;Rt<no;Rt++){var xt=De[Rt];o[xt]||(o[xt]=Ie(xt))}};M();var B=function(Ie){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Er[g]=Ie,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++)eo(this,St[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),ro=new to;l.exports=ro},{3:3}]},{},[4])(4)})});var Ar=Object.defineProperty,po=Object.getOwnPropertyDescriptor,go=(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?po(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 vo(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 yo(e){return typeof e>"u"}function bo(e){return yo(e)||e===null}function _o(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),T=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 T.cancel=()=>{i&&clearTimeout(i),i=null,l=d=void 0},T.flush=()=>{if(i)return clearTimeout(i),i=null,A()},T}var Eo=(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))(Eo||{}),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 To(e,t){return(...n)=>t(e,...n)}function Lr(e){return t=>To(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"),wo={};globalThis[Br]=wo;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||{}),he=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(he||{}),So=(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))(So||{}),Sr=["name","params"],Ao=["name","type","location","target","extra","timestamp","userId"],Ro=["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 xo(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},Ao)}function Bt(e){let t=e.events.map(i=>xo(i)),n=Ne(e.device,Ro);return[e.protocolVersion,t,n,e.project]}var ko=()=>"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")},Co=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",Po="device_id",Do="advertising_id",Mr=e=>(localStorage.getItem(e)||localStorage.setItem(e,ko()),localStorage.getItem(e)),Mt=()=>Mr(Po),Oo=()=>Mr(Do),Fo=e=>e.charAt(0).toUpperCase()+e.slice(1),No=()=>{let e=new URLSearchParams(window.location.search);return Fo(e.get("utm_source")??"")||"JoliboxSDK"},$r=e=>{let t="JoliboxWebSDK",n=Co(),i=navigator.language,l=Mt(),d=Oo();return`${t} (${No()}${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}},Uo=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}},Lo=0,Fe=class{constructor(e){this.value=e,this.id=Lo++}},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}},pe=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 Uo,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},Pt={};go(Pt,{None:()=>Bo,filter:()=>$o,once:()=>Vr,toPromise:()=>Mo});var Bo=()=>{console.log("[Jolibox SDK] None Event")};function Mo(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 $o(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"),Vo=()=>{let e=new pe;return globalThis[kt]||(globalThis[kt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[kt]},xe=Vo();function jo(e,t){let n=Math.min(e.length,t.length);for(let i=0;i<n;i++)Ko(e[i],t[i])}function Ko(e,t){if(Ot(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(_o(t)){try{if(e instanceof t)return}catch{}if(!bo(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 jo(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=vo(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 pe,ue=new pe;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 Jo="1.1.7-beta.2",Me=()=>Jo,Kr=()=>{let e=Me();return`${$r(e)}`};var Go={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"},Ho=globalThis.joliboxJSCore?.env,z=Object.assign({},Ho?.()??Go),Wo=()=>{let{payloadJson:e,headerJson:t}=z.schema.length?jr(z.schema):{},n=`${z.deviceInfo.did}-${new Date().getTime()}`,l=new URL(z.schema.length?z.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",T=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 z.platform??z.deviceInfo.platform},get deviceInfo(){return z.deviceInfo},get sdkInfo(){return z.sdkInfo},get hostInfo(){return z.hostInfo},get hostUserInfo(){return z.hostUserInfo},get sessionId(){return z.clientSessionId??h??n},get channel(){return T},onEnvConfigChanged:x=>{Pr(z,x,Dr)}}},R=Wo();var jt=!1,Gr=(e,t)=>e==null?!1:t in e,zo=e=>Gr(e,"kind"),Yo=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:Yo(e.name)},env:t.environment,isFromUser:n};n?ue.emit("GLOBAL_USER_ERROR",e,l):ue.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=zo(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(T){this.pushPastTracking(!1),H.log("[Jolibox SDK] report API error",T)}}};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,T=this.getJoliSource();return d=Object.assign({},d??{},A?{"x-user-agent":A}:{},T?{"x-joli-source":T}:{}),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}`:""}`,T=this.xua,x=this.getJoliSource();h=Object.assign({},h??{},{"Content-Type":"application/json"},T?{"x-user-agent":T}:{},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}`:""}`,T=this.xua,x=this.getJoliSource();h=Object.assign({},h??{},{"Content-Type":"application/json"},T?{"x-user-agent":T}:{},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 ce=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 ce({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 Qo=(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,he.WebSDK)};ue.on("GLOBAL_ERROR",(e,t)=>{Qo(t.tag,e)});ue.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=()=>{T(),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(_)},T=()=>{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,T(),x()}}}};var Ke=class extends je{constructor(n,i,l){super(i,l);this.httpClient=new ce;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(),Xo={type:he.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:ve,trackPerformance:Zo}=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,he.WebSDK)},Xo);Yr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:n})=>{Zo(e,t,n)});Yr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{ve(e,t)});var Ht=new pe,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
|
|
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`,T=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;T=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,T)),{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`,T="SUCCESS",x={code:T,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;T=k,A=K,b=N}return Object.assign(x,{code:T,message:A,data:b}),x}catch(m){let b=m,k=b.code??b.errNo??2e3;T="FAILURE";let N=b.message??b.errMsg??`${m}`,K=`${i}:${T} ${N.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:T,message:K}),ee(new Be(K,k)),x}finally{let m=Date.now()-_;e("apiInvoked",{...E,duration:m,status:T})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:de}=Xr(ve),j=qr("h5");var Zr=X(),ti="env",ri="getSystemInfoSync",ni=()=>{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},oi=de(ri,{implement:ni}),ii=de(ti,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Zr.registerCommand("API.env",ii);Zr.registerCommand("API.getSystemInfoSync",oi);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var si="onJoliboxShow",ai="onJoliboxHide",ci="onReady",Xt=X(),Zt=Lr(ee),Qt=!0,ke=!0,ct=0,lt=Ht;function li(){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",li);window.addEventListener("focus",()=>en("focus"));window.addEventListener("blur",()=>en("blur"));var ui=de(si,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);lt.on("visible",n=>{n&&t()})}}),di=de(ai,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);lt.on("visible",n=>{!n&&t()})}}),fi=de(ci,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Xt.registerCommand("LifecycleSDK.onReady",fi);Xt.registerCommand("LifecycleSDK.onJoliboxShow",ui);Xt.registerCommand("LifecycleSDK.onJoliboxHide",di);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var nn=ho(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 ce({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,mi=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.getItem(e)}});ut.registerCommand("StorageSDK.getItem",mi);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var hi=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",hi);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var pi=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.removeItem(e)}});ut.registerCommand("StorageSDK.removeItem",pi);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var gi=Z("clearStorage",{async implement(){return await dt.clear()}});ut.registerCommand("StorageSDK.clear",gi);j("storage.clear",{version:"1.0.0"});var be=X(),vi=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})])}}),yi=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})}}),bi=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(e,t)=>await te.tracker("LevelUpgrade",{name:t,levelId:e})}),_i=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserLevel",{level:e})}),Ei=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",vi);be.registerCommand("TaskTrackerSDK.taskFinished",yi);be.registerCommand("TaskTrackerSDK.levelUpgrade",bi);be.registerCommand("TaskTrackerSDK.historyUserLevel",_i);be.registerCommand("TaskTrackerSDK.historyUserScore",Ei);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 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,this.track("CallAdBreakDone",{breakType:_.breakType,breakName:_.breakName??"",breakFormat:_.breakFormat,breakStatus:_.breakStatus}),l&&l(_)};if(t.adBreakDone=d,t.type==="reward"){let _=t.beforeReward,E=T=>()=>{this.track("CallShowAdFn",null),T()},A=T=>{_&&_(E(T))};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,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,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",E),A&&T.setAttribute("data-ad-format",A),d&&T.setAttribute("data-full-width-responsive",d),h&&T.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",T.style.position="relative",_.appendChild(T),T.appendChild(m)}else _.appendChild(T),new MutationObserver(b=>{b.forEach(k=>{if(k.type==="attributes"&&k.attributeName==="data-ad-status"){let N=T.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:N??"null"})}})}).observe(T,{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 ce,()=>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 Ti(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),te.start(Date.now()-e)})}function sn(){Ti()}var wi=Symbol("__JOLIBOX_SDK_INITIALIZED__");(()=>{if(window[wi]){console.warn("JoliboxSDK already initialized, skipping...");return}})();sn();
|
|
1
|
+
var ao=Object.create;var wr=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 c of lo(t))!fo.call(e,c)&&c!==n&&wr(e,c,{get:()=>t[c],enumerable:!(i=co(t,c))||i.enumerable});return e};var po=(e,t,n)=>(n=e!=null?ao(uo(e)):{},ho(t||!e||!e.__esModule?wr(n,"default",{value:e,enumerable:!0}):n,e));var nn=mo((rn,tr)=>{(function(e){if(typeof rn=="object"&&typeof tr<"u")tr.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(c,d,h){function T(I,x){if(!d[I]){if(!c[I]){var m=typeof Ie=="function"&&Ie;if(!x&&m)return m(I,!0);if(b)return b(I,!0);var _=new Error("Cannot find module '"+I+"'");throw _.code="MODULE_NOT_FOUND",_}var k=d[I]={exports:{}};c[I][0].call(k.exports,function(N){var K=c[I][1][N];return T(K||N)},k,k.exports,i,c,d,h)}return d[I].exports}for(var b=typeof Ie=="function"&&Ie,S=0;S<h.length;S++)T(h[S]);return T}({1:[function(i,c,d){(function(h){"use strict";var T=h.MutationObserver||h.WebKitMutationObserver,b;if(T){var S=0,I=new T(N),x=h.document.createTextNode("");I.observe(x,{characterData:!0}),b=function(){x.data=S=++S%2}}else if(!h.setImmediate&&typeof h.MessageChannel<"u"){var m=new h.MessageChannel;m.port1.onmessage=N,b=function(){m.port2.postMessage(0)}}else"document"in h&&"onreadystatechange"in h.document.createElement("script")?b=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)}:b=function(){setTimeout(N,0)};var _,k=[];function N(){_=!0;for(var V,re,J=k.length;J;){for(re=k,k=[],V=-1;++V<J;)re[V]();J=k.length}_=!1}c.exports=K;function K(V){k.push(V)===1&&!_&&b()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,c,d){"use strict";var h=i(1);function T(){}var b={},S=["REJECTED"],I=["FULFILLED"],x=["PENDING"];c.exports=m;function m(E){if(typeof E!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,E!==T&&K(this,E)}m.prototype.catch=function(E){return this.then(null,E)},m.prototype.then=function(E,D){if(typeof E!="function"&&this.state===I||typeof D!="function"&&this.state===S)return this;var P=new this.constructor(T);if(this.state!==x){var U=this.state===I?E:D;k(P,U,this.outcome)}else this.queue.push(new _(P,E,D));return P};function _(E,D,P){this.promise=E,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof P=="function"&&(this.onRejected=P,this.callRejected=this.otherCallRejected)}_.prototype.callFulfilled=function(E){b.resolve(this.promise,E)},_.prototype.otherCallFulfilled=function(E){k(this.promise,this.onFulfilled,E)},_.prototype.callRejected=function(E){b.reject(this.promise,E)},_.prototype.otherCallRejected=function(E){k(this.promise,this.onRejected,E)};function k(E,D,P){h(function(){var U;try{U=D(P)}catch(G){return b.reject(E,G)}U===E?b.reject(E,new TypeError("Cannot resolve promise with itself")):b.resolve(E,U)})}b.resolve=function(E,D){var P=V(N,D);if(P.status==="error")return b.reject(E,P.value);var U=P.value;if(U)K(E,U);else{E.state=I,E.outcome=D;for(var G=-1,z=E.queue.length;++G<z;)E.queue[G].callFulfilled(D)}return E},b.reject=function(E,D){E.state=S,E.outcome=D;for(var P=-1,U=E.queue.length;++P<U;)E.queue[P].callRejected(D);return E};function N(E){var D=E&&E.then;if(E&&(typeof E=="object"||typeof E=="function")&&typeof D=="function")return function(){D.apply(E,arguments)}}function K(E,D){var P=!1;function U(q){P||(P=!0,b.reject(E,q))}function G(q){P||(P=!0,b.resolve(E,q))}function z(){D(G,U)}var Y=V(z);Y.status==="error"&&U(Y.value)}function V(E,D){var P={};try{P.value=E(D),P.status="success"}catch(U){P.status="error",P.value=U}return P}m.resolve=re;function re(E){return E instanceof this?E:b.resolve(new this(T),E)}m.reject=J;function J(E){var D=new this(T);return b.reject(D,E)}m.all=bt;function bt(E){var D=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=E.length,U=!1;if(!P)return this.resolve([]);for(var G=new Array(P),z=0,Y=-1,q=new this(T);++Y<P;)ne(E[Y],Y);return q;function ne(_e,Ce){D.resolve(_e).then(_t,function(me){U||(U=!0,b.reject(q,me))});function _t(me){G[Ce]=me,++z===P&&!U&&(U=!0,b.resolve(q,G))}}}m.race=ue;function ue(E){var D=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=E.length,U=!1;if(!P)return this.resolve([]);for(var G=-1,z=new this(T);++G<P;)Y(E[G]);return z;function Y(q){D.resolve(q).then(function(ne){U||(U=!0,b.resolve(z,ne))},function(ne){U||(U=!0,b.reject(z,ne))})}}},{1:1}],3:[function(i,c,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,c,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 T(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function b(){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 S=b();function I(){try{if(!S||!S.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,l=new o,u=0;u<r.length;u+=1)l.append(r[u]);return l.getBlob(s.type)}}typeof Promise>"u"&&i(3);var m=Promise;function _(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={},bt=Object.prototype.toString,ue="readonly",E="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),l=new Uint8Array(o),u=0;u<s;u++)l[u]=r.charCodeAt(u);return o}function P(r){return new m(function(s){var o=r.transaction(V,E),l=x([""]);o.objectStore(V).put(l,"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(l,u){o.resolve=l,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],l=o.deferredOperations.pop();if(l)return l.reject(s),l.promise}function q(r,s){return new m(function(o,l){if(J[r.name]=J[r.name]||or(),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=S.open.apply(S,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(),l(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),l=r.version<r.db.version,u=r.version>r.db.version;if(l&&(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 _t(r){return new m(function(s,o){var l=new FileReader;l.onerror=o,l.onloadend=function(u){var a=btoa(u.target.result||"");s({__local_forage_encoded_blob:!0,data:a,type:r.type})},l.readAsBinaryString(r)})}function me(r){var s=D(atob(r.data));return x([s],{type:r.type})}function nr(r){return r&&r.__local_forage_encoded_blob}function cn(r){var s=this,o=s._initReady().then(function(){var l=J[s._dbInfo.name];if(l&&l.dbReady)return l.dbReady});return k(o,r,r),o}function ln(r){G(r);for(var s=J[r.name],o=s.forages,l=0;l<o.length;l++){var u=o[l];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,l){l===void 0&&(l=1);try{var u=r.db.transaction(r.storeName,s);o(null,u)}catch(a){if(l>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,l-1)})}).catch(o);o(a)}}function or(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function un(r){var s=this,o={db:null};if(r)for(var l in r)o[l]=r[l];var u=J[o.name];u||(u=or(),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 l=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),nr(y)&&(y=me(y)),u(y)},v.onerror=function(){a(v.error)}}catch(y){a(y)}})}).catch(a)});return _(l,s),l}function fn(r,s){var o=this,l=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;nr(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 _(l,s),l}function mn(r,s,o){var l=this;r=N(r);var u=new m(function(a,f){var p;l.ready().then(function(){return p=l._dbInfo,bt.call(s)==="[object Blob]"?U(p.db).then(function(g){return g?s:_t(s)}):s}).then(function(g){oe(l._dbInfo,E,function(v,y){if(v)return f(v);try{var w=y.objectStore(l._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 _(u,o),u}function hn(r,s){var o=this;r=N(r);var l=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,E,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 _(l,s),l}function pn(r){var s=this,o=new m(function(l,u){s.ready().then(function(){oe(s._dbInfo,E,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.clear();f.oncomplete=function(){l()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;u(v)}}catch(v){u(v)}})}).catch(u)});return _(o,r),o}function gn(r){var s=this,o=new m(function(l,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(){l(g.result)},g.onerror=function(){u(g.error)}}catch(v){u(v)}})}).catch(u)});return _(o,r),o}function vn(r,s){var o=this,l=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 _(l,s),l}function yn(r){var s=this,o=new m(function(l,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){l(v);return}v.push(y.key),y.continue()},g.onerror=function(){u(g.error)}}catch(y){u(y)}})}).catch(u)});return _(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 l=this,u;if(!r.name)u=m.reject("Invalid arguments");else{var a=r.name===o.name&&l._dbInfo.db,f=a?m.resolve(l._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=S.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=S.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 _(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~",ir=/^~~local_forage_type~([^~]+)~/,Pe="__lfsc__:",Et=Pe.length,Tt="arbf",It="blob",sr="si08",ar="ui08",cr="uic8",lr="si16",ur="si32",dr="ur16",fr="ui32",mr="fl32",hr="fl64",pr=Et+Tt.length,gr=Object.prototype.toString;function vr(r){var s=r.length*.75,o=r.length,l,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(l=0;l<o;l+=4)a=se.indexOf(r[l]),f=se.indexOf(r[l+1]),p=se.indexOf(r[l+2]),g=se.indexOf(r[l+3]),y[u++]=a<<2|f>>4,y[u++]=(f&15)<<4|p>>2,y[u++]=(p&3)<<6|g&63;return v}function wt(r){var s=new Uint8Array(r),o="",l;for(l=0;l<s.length;l+=3)o+=se[s[l]>>2],o+=se[(s[l]&3)<<4|s[l+1]>>4],o+=se[(s[l+1]&15)<<2|s[l+2]>>6],o+=se[s[l+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=gr.call(r)),r&&(o==="[object ArrayBuffer]"||r.buffer&&gr.call(r.buffer)==="[object ArrayBuffer]")){var l,u=Pe;r instanceof ArrayBuffer?(l=r,u+=Tt):(l=r.buffer,o==="[object Int8Array]"?u+=sr:o==="[object Uint8Array]"?u+=ar:o==="[object Uint8ClampedArray]"?u+=cr:o==="[object Int16Array]"?u+=lr:o==="[object Uint16Array]"?u+=dr:o==="[object Int32Array]"?u+=ur:o==="[object Uint32Array]"?u+=fr:o==="[object Float32Array]"?u+=mr:o==="[object Float64Array]"?u+=hr:s(new Error("Failed to get type for BinaryArray"))),s(u+wt(l))}else if(o==="[object Blob]"){var a=new FileReader;a.onload=function(){var f=Tn+r.type+"~"+wt(this.result);s(Pe+It+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,Et)!==Pe)return JSON.parse(r);var s=r.substring(pr),o=r.substring(Et,pr),l;if(o===It&&ir.test(s)){var u=s.match(ir);l=u[1],s=s.substring(u[0].length)}var a=vr(s);switch(o){case Tt:return a;case It:return x([a],{type:l});case sr:return new Int8Array(a);case ar:return new Uint8Array(a);case cr:return new Uint8ClampedArray(a);case lr:return new Int16Array(a);case dr:return new Uint16Array(a);case ur:return new Int32Array(a);case fr:return new Uint32Array(a);case mr:return new Float32Array(a);case hr:return new Float64Array(a);default:throw new Error("Unkown type: "+o)}}var At={serialize:In,deserialize:wn,stringToBuffer:vr,bufferToString:wt};function yr(r,s,o,l){r.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,l)}function An(r){var s=this,o={db:null};if(r)for(var l in r)o[l]=typeof r[l]!="string"?r[l].toString():r[l];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){yr(p,o,function(){s._dbInfo=o,a()},function(g,v){f(v)})},f)});return o.serializer=At,u}function ae(r,s,o,l,u,a){r.executeSql(o,l,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):yr(g,s,function(){g.executeSql(o,l,u,a)},a)},a):a(f,p)},a)}function Sn(r,s){var o=this;r=N(r);var l=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 _(l,s),l}function Rn(r,s){var o=this,l=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 _(l,s),l}function br(r,s,o,l){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(l>0){f(br.apply(u,[r,g,o,l-1]));return}p(C)}})})}).catch(p)});return _(a,o),a}function xn(r,s,o){return br.apply(this,[r,s,o,1])}function kn(r,s){var o=this;r=N(r);var l=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 _(l,s),l}function Cn(r){var s=this,o=new m(function(l,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ae(f,a,"DELETE FROM "+a.storeName,[],function(){l()},function(p,g){u(g)})})}).catch(u)});return _(o,r),o}function Pn(r){var s=this,o=new m(function(l,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;l(v)},function(p,g){u(g)})})}).catch(u)});return _(o,r),o}function Dn(r,s){var o=this,l=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 _(l,s),l}function On(r){var s=this,o=new m(function(l,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);l(v)},function(p,g){u(g)})})}).catch(u)});return _(o,r),o}function Fn(r){return new m(function(s,o){r.transaction(function(l){l.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(l){o(l)})})}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 l=this,u;return r.name?u=new m(function(a){var f;r.name===o.name?f=l._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"),_(u,s),u}var Un={_driver:"webSQLStorage",_initStorage:An,_support:En(),iterate:Rn,getItem:Sn,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 _r(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 l in r)o[l]=r[l];return o.keyPrefix=_r(r,s._defaultConfig),Mn()?(s._dbInfo=o,o.serializer=At,m.resolve()):m.reject()}function Vn(r){var s=this,o=s.ready().then(function(){for(var l=s._dbInfo.keyPrefix,u=localStorage.length-1;u>=0;u--){var a=localStorage.key(u);a.indexOf(l)===0&&localStorage.removeItem(a)}});return _(o,r),o}function jn(r,s){var o=this;r=N(r);var l=o.ready().then(function(){var u=o._dbInfo,a=localStorage.getItem(u.keyPrefix+r);return a&&(a=u.serializer.deserialize(a)),a});return _(l,s),l}function Kn(r,s){var o=this,l=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 _(l,s),l}function Jn(r,s){var o=this,l=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 _(l,s),l}function Gn(r){var s=this,o=s.ready().then(function(){for(var l=s._dbInfo,u=localStorage.length,a=[],f=0;f<u;f++){var p=localStorage.key(f);p.indexOf(l.keyPrefix)===0&&a.push(p.substring(l.keyPrefix.length))}return a});return _(o,r),o}function Hn(r){var s=this,o=s.keys().then(function(l){return l.length});return _(o,r),o}function Wn(r,s){var o=this;r=N(r);var l=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+r)});return _(l,s),l}function zn(r,s,o){var l=this;r=N(r);var u=l.ready().then(function(){s===void 0&&(s=null);var a=s;return new m(function(f,p){var g=l._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 _(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 l=this,u;return r.name?u=new m(function(a){r.storeName?a(_r(r,l._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"),_(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 l=s.length,u=0;u<l;){if(Qn(s[u],o))return!0;u++}return!1},Er=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"},Ee={},Tr={},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 Rt(){for(var r=1;r<arguments.length;r++){var s=arguments[r];if(s)for(var o in s)s.hasOwnProperty(o)&&(Er(s[o])?arguments[0][o]=s[o].slice():arguments[0][o]=s[o])}return arguments[0]}var ro=function(){function r(s){T(this,r);for(var o in he)if(he.hasOwnProperty(o)){var l=he[o],u=l._driver;this[o]=u,Ee[u]||this.defineDriver(l)}this._defaultConfig=Rt({},eo),this._config=Rt({},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 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},r.prototype.defineDriver=function(o,l,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"),Ir=m.reject(so);return _(Ir,arguments[arguments.length-1]),Ir}},xt=0,oo=De.length;xt<oo;xt++){var kt=De[xt];o[kt]||(o[kt]=Te(kt))}};M();var B=function(Te){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Tr[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,l,u),a},r.prototype.driver=function(){return this._driver||null},r.prototype.getDriver=function(o,l,u){var a=Ee[o]?m.resolve(Ee[o]):m.reject(new Error("Driver not found."));return k(a,l,u),a},r.prototype.getSerializer=function(o){var l=m.resolve(At);return k(l,o),l},r.prototype.ready=function(o){var l=this,u=l._driverSet.then(function(){return l._ready===null&&(l._ready=l._initDriver()),l._ready});return k(u,o,o),u},r.prototype.setDriver=function(o,l,u){var a=this;Er(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,l,u),this._driverSet},r.prototype.supports=function(o){return!!Tr[o]},r.prototype._extend=function(o){Rt(this,o)},r.prototype._getSupportedDrivers=function(o){for(var l=[],u=0,a=o.length;u<a;u++){var f=o[u];this.supports(f)&&l.push(f)}return l},r.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,l=St.length;o<l;o++)to(this,St[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),no=new ro;c.exports=no},{3:3}]},{},[4])(4)})});var Rr=Object.defineProperty,go=Object.getOwnPropertyDescriptor,vo=(e,t)=>{for(var n in t)Rr(e,n,{get:t[n],enumerable:!0})},xr=(e,t,n,i)=>{for(var c=i>1?void 0:i?go(t,n):t,d=e.length-1,h;d>=0;d--)(h=e[d])&&(c=(i?h(t,n,c):h(c))||c);return i&&c&&Rr(t,n,c),c};function yo(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ft(e){return typeof e=="string"}function kr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Cr(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 Pr(e){let t=e,n=null,i=function(...c){return n||(n=new t(...c)),n};return i.prototype=t.prototype,i}function Dr(e,t,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function i(c,d){for(let h in d)if(Object.prototype.hasOwnProperty.call(d,h)){let T=c[h],b=d[h],S=n(T,b,h,c,d);S!==void 0?c[h]=S:Ar(b)&&Ar(T)?c[h]=i({...T},b):Array.isArray(b)&&Array.isArray(T)?c[h]=[...T,...b]:c[h]=b}return c}return i(e,t)}function Ar(e){return e&&typeof e=="object"&&e.constructor===Object}function Or(e,t){if(Array.isArray(e))return e.concat(t)}function Se(e,t,n={}){let i=null,c,d,h,{leading:T=!1,trailing:b=!0}=n,S=()=>(h=e.apply(d,c),c=void 0,d=void 0,h),I=function(...x){c=x,d=this;let m=T&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,b&&!m&&S()},t),m)return S()};return I.cancel=()=>{i&&clearTimeout(i),i=null,c=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,S()},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||{}),Nt=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}},Ut=class extends Nt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Fr=class extends Nt{constructor(){super(...arguments),this.kind="USER_ERROR"}},Nr=class extends Fr{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}};var Io=class extends Fr{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 Ur=class extends Ut{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Lr=class extends Ut{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Be=class extends Nt{constructor(e,t,n,i,c){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),c&&(this.priority=c)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};var Lt=class extends Ut{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function wo(e,t){return(...n)=>t(e,...n)}function Br(e){return t=>wo(t,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(c){e(new Io(`${c}`))}})}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 Mr=Symbol.for("Jolibox.canIUseMap"),Ao={};globalThis[Mr]=Ao;var Bt={get config(){return globalThis[Mr]}};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||{}),So=(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))(So||{}),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((c,d)=>(c[d]=String(i[d]),c),{})}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 Mt(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",$r=e=>(localStorage.getItem(e)||localStorage.setItem(e,Co()),localStorage.getItem(e)),$t=()=>$r(Do),Fo=()=>$r(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"},Vr=e=>{let t="JoliboxWebSDK",n=Po(),i=navigator.language,c=$t(),d=Fo();return`${t} (${Uo()}${n}; UnknownModel; UnknownSystemVersion; ${i}) uuid/${c} 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 c=this._last;this._last=n,n.prev=c,c.next=n}else{let c=this._first;this._first=n,n.next=c,c.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++}},Ae=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 Ae,i=d=>t(...d.args);this.listerHandlerMap.set(t,i),n.event(i),this.listeners.set(e,n);let c=this.cachedEventQueue.get(e);if(c)for(;c.size>0;)n.fire({event:e,...c.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})}}},Dt={};vo(Dt,{None:()=>Mo,filter:()=>Vo,once:()=>jr,toPromise:()=>$o});var Mo=()=>{console.log("[Jolibox SDK] None Event")};function $o(e){return new Promise(t=>jr(e)(t))}function jr(e){return(t,n=null)=>{let i=!1;return e(c=>{if(!i)return i=!0,t.call(n,c)},null)}}function Vo(e,t){return(n=>{let i,c={onWillAddFirstListener(){i=n(d.fire,d)}},d=new Ae(c);return d.event})((n,i=null)=>e(c=>t(c)&&n.call(i,c),null))}var Ct=Symbol.for("Jolibox.hostEmitter"),jo=()=>{let e=new ce;return globalThis[Ct]||(globalThis[Ct]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Ct]},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(Ft(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 Ae,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 c of e.metadata.args)n.push(c.constraint);let i=e.handler;e.handler=function(...c){return Ko(c,n),i(...c)}}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=xr([Pr],Le);var Ot=class{constructor(){this._onWillExecuteCommand=new Ae,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ae,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(),Dt.toPromise(Dt.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}}};Ot=xr([Pr],Ot);var Pt=Symbol.for("Jolibox.commands");function X(){if(globalThis[Pt])return globalThis[Pt];let e=new Le,t=new Ot,n={registerCommand(i,c,d){e.registerCommand({id:i,handler:c,metadata:d})},executeCommand(i,...c){return t.executeCommand(i,...c)},excuteCommandSync(i,...c){return t.executeCommandThowErr(i,...c)}};return globalThis[Pt]=n,n}var Vt=new ce,de=new ce;function ee(e,t={}){Vt.emit("ERROR_REPORT",{error:e,options:t})}ee.debounce=Se(ee,50,{leading:!0});var jt=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{}}},Kr=e=>{try{let i=new URL(e).searchParams.get("joliSource")?.split(".");if(i?.length){let[c,d,h]=i;return{headerJson:jt(c),payloadJson:jt(d),signature:jt(h)}}else throw"joli_source is missing"}catch(t){return ee(new Ur(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}};var Go="1.1.7-beta.4",Me=()=>Go,Jr=()=>{let e=Me();return`${Vr(e)}`};var Ho={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:$t(),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?Kr(W.schema):{},n=`${W.deviceInfo.did}-${new Date().getTime()}`,c=new URL(W.schema.length?W.schema:window.location.href).searchParams,d=c.get("mpId")??c.get("appId")??c.get("gameId")??"",h=e?.sessionId??c.get("sessionId")??n,T=!!(e?.testAdsMode??c.get("testAdsMode")==="true"),b=e?.joliboxEnv??c.get("joliboxEnv")??"production",S=b==="staging",I=t?.channel;return{get testMode(){return S},get testAdsMode(){return T},get joliboxEnv(){return b},get joliSource(){return c.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=>{Dr(W,x,Or)}}},R=zo();var Kt=!1,Hr=(e,t)=>e==null?!1:t in e,Yo=e=>Hr(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("")},Gr=(e,t={},n)=>{let c={...{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,c):de.emit("GLOBAL_ERROR",e,c)},Qo=e=>Hr(e,"kind")&&e.kind==="USER_ERROR";Vt.on("ERROR_REPORT",({error:e,options:t})=>{if(Kt)return;Kt=!0;let n=Yo(e)&&e.raw?e.raw:e;try{let i=Qo(e);Gr(e,t,i)}catch(i){let c=i instanceof Error?i.message:String(i),d=new Lt(`${c}, origin error: ${n.message}`);H.error(d),Gr(new Lt(d.message),{environment:t.environment},!1)}finally{Kt=!1}});var Jt=e=>new Nr(e);function Wr(e,t){let n=(i,c,d)=>{let h={tag:i,...t,extra:{...c}};i=="globalJsError"?ee(new Lr(JSON.stringify(h))):e("systemLog",h,d)};return n.debounce=Se(n,500,{leading:!0}),n}function zr(e){let t=(n,i,c)=>{let d=(c&&JSON.stringify(c))??0,h={speed_value_type:n,total_duration:i};d&&Object.assign(h,{extra:d}),e("joliboxSpeedAnalysis",h)};return t.debounce=Se(t,500,{leading:!0}),t}function Yr(e,t){let n=Wr(e,t),i=zr(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,c]of Object.entries(n))if(c.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,c)=>{n[c]=i}),{name:"GamePage",params:n}}async trackEvent(t,n,i){if(this.checkIsSampled(t))return;let c=t.location?t.location:await this.getLocation(),d=t.target||null,h=t.extra||null;this.deviceInfo||(this.deviceInfo=await this.getDevice());let T=this.deviceInfo,S={protocolVersion:"1.0.0",events:[{...t,location:c,target:d,extra:h,timestamp:Date.now(),userId:null}],device:T,project:n};try{i?this.doReport(Mt(S),i):this.doReport(Mt(S)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),H.log("[Jolibox SDK] report API error",I)}}};var Gt=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};AbortSignal.timeout??=Gt;var Ve=class{constructor(t){this.xua=Jr();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:c}=n??{},{headers:d}=n??{},T=(i?new URLSearchParams(i):null)?.toString(),b=`${this.baseUrl}${t}${T?`?${T}`:""}`,S=this.xua,I=this.getJoliSource();return d=Object.assign({},d??{},S?{"x-user-agent":S}:{},I?{"x-joli-source":I}:{}),await(await fetch(b,{method:"GET",headers:d,credentials:"include",signal:Gt(c??3e4)})).json()}async post(t,n){let{data:i,query:c,timeout:d}=n??{},{headers:h}=n??{},b=(c?new URLSearchParams(c):null)?.toString(),S=`${this.baseUrl}${t}${b?`?${b}`:""}`,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(S,{method:"POST",headers:h,body:JSON.stringify(i),signal:Gt(d??3e4),credentials:"include"}),_=m.headers.get("content-type");if(_?.includes("application/octet-stream"))try{return m.blob()}catch{return await m.arrayBuffer()}if(_?.includes("multipart/form-data")||_?.includes("application/x-www-form-urlencoded"))try{return m.formData()}catch{return await m.text()}if(_?.includes("application/json"))try{return await m.json()}catch{return await m.text()}return m}async put(t,n){try{let{data:i,query:c,timeout:d}=n??{},{headers:h}=n??{},b=(c?new URLSearchParams(c):null)?.toString(),S=`${this.baseUrl}${t}${b?`?${b}`:""}`,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(S,{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 Ht=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 Ht;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,c,d=!1,h=0,T=()=>{if(!d)return;let _=Date.now(),k=_-n;k>=this.interval&&(this.visible&&(h+=k,t(h)),n=_),i=requestAnimationFrame(T)},b=()=>{I(),n=Date.now(),c=window.setInterval(()=>{if(!d)return;let _=Date.now();_-n>=this.interval&&(n=_)},this.interval)},S=()=>{x(),n=Date.now(),i=requestAnimationFrame(T)},I=()=>{i&&(cancelAnimationFrame(i),i=0)},x=()=>{c&&(clearInterval(c),c=0)};this.eventEmitter.on("visible",_=>{d&&(console.log("visible",_),_?S():b())});let m=this.visible;return{start(){d||(d=!0,m?S():b())},stop(){d=!1,I(),x()}}}};var Ke=class extends je{constructor(n,i,c){super(i,c);this.httpClient=new le;this.gameId=R.mpId,this.sessionId=R.sessionId,this.track=n}async reporter(n){let{event:i,params:c}=n;await this.httpClient.post("/api/base/app-event",{data:{eventType:i,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...c}}}),H.log("-----task tracker-----",i,c)}tracker(n,i=null){this.track(n,i)}};var qr=X(),Zo={type:pe.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:ve,trackPerformance:ei}=Yr((...e)=>{let[,t]=e,n=t,c={...kr(n.extra)?n.extra:Ft(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:c,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ge.trackEvent(d,pe.WebSDK)},Zo);qr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:n})=>{ei(e,t,n)});qr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{ve(e,t)});var Wt=new ce,te=new Ke(ve,Wt);function Qr(e){let t=Bt.config[e];return t||(t={},Bt.config[e]=t),(n,i)=>{if(t[n]){H.warn(`[can i use] ${n} already registered`);return}t[n]={...i}}}var Xr=!1;function zt(e){Xr=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(Xr)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 ${Yt(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 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 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 ${Yt(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 c=!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:c=!1)}),this._uniqueItems){let d=new Map;for(let h in n)d.has(n[h])?c=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 c}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(qt(n)!=="object")return this.fail({expect:"object",actual:n});let c=n,d=this._value;d.errors=this.errors;let h=!0;for(let T in c){let b=c[T];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(T)?d.path=`${this.path}.${T}`:d.path=`${this.path}["${T}"]`,!(b===void 0&&d._optional)){if(b===void 0&&d.hasDefault){c[T]=d.defaultValue;continue}d.validate(b)||(d.hasFallback?c[T]=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(qt(n)!=="object")return this.fail({expect:"object",actual:n});let i=n,c=!0;for(let d in this._object){let h=i[d],T=this._object[d];if(T.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?T.path=`${this.path}.${d}`:T.path=`${this.path}["${d}"]`,!(T._optional&&h===void 0)){if(h===void 0&&T.hasDefault){i[d]=T.defaultValue;continue}T.validate(h)||(T.hasFallback?i[d]=T.fallbackValue:c=!1)}}return c}},rt=class extends ${constructor(n){super();this.value=n}validate(n){return n===void 0&&this._optional?!0:n!==this.value?this.fail({expect:Yt(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,c=this._items.length;for(let d=0;d<c;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 c=t[i];if(c._optional||c.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,c)=>{if(i.path=`${this.path}[${c}]`,i.errors=this.errors,t[c]===void 0&&i.hasDefault){t[c]=i.defaultValue;return}i.validate(t[c])||(i.hasFallback?t[c]=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 A={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,zt(!0),!e.validate(t)){let i=e.errors.join(`
|
|
3
|
+
`);throw e.errors.length=0,zt(!1),new TypeError(i)}}var at=1,Zr=e=>{function t(i,c){return(...d)=>{let h=Date.now(),T={method:i,trace_id:at};at+=1;let b="SUCCESS",S=`${i}:ok`,I=0;try{if(c.paramsSchema)try{Qt(c.paramsSchema,d,"params")}catch(k){throw Jt(`${i}:fail ${k.message}`)}let x=c.implement(...d),m=x,_=`${i}:ok`;if(x&&"code"in x){let{code:k,data:N,message:K}=x;b=k,m=N,_=K}return{code:b,message:_,data:m}}catch(x){let m=x;I=m.code??m.errNo??2e3,b="FAILURE";let _=m.message??m.errMsg??`${x}`;return S=`${i}:${b} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Be(S,I)),{code:b,message:S}}finally{let x=Date.now()-h;e("apiInvoked",{...T,duration:x,status:b})}}}function n(i,c){return async(...d)=>{let h=Cr(d)?d:[d],T=Date.now(),b={method:i,trace_id:at};at+=1;let S=`${i}:ok`,I="SUCCESS",x={code:I,message:S};try{if(c.paramsSchema)try{Qt(c.paramsSchema,h,"params")}catch(k){throw Jt(k.message)}let _=await c.implement(...h);if(_&&"code"in _){let{code:k,data:N,message:K}=_;I=k,S=K,_=N}return Object.assign(x,{code:I,message:S,data:_}),x}catch(m){let _=m,k=_.code??_.errNo??2e3;I="FAILURE";let N=_.message??_.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()-T;e("apiInvoked",{...b,duration:m,status:I})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:fe}=Zr(ve),j=Qr("h5");var en=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})});en.registerCommand("API.env",si);en.registerCommand("API.getSystemInfoSync",ii);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var ai="onJoliboxShow",ci="onJoliboxHide",li="onReady",Zt=X(),er=Br(ee),Xt=!0,ke=!0,ct=0,lt=Wt;function ui(){let e=Date.now();if(e-ct<100)return;ct=e;let t=document.visibilityState==="visible";t!==Xt&&(Xt=t,lt.emit("visible",Xt))}function tn(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",()=>tn("focus"));window.addEventListener("blur",()=>tn("blur"));var di=fe(ai,{paramsSchema:A.tuple(A.function()),implement(e){let t=er(e);lt.on("visible",n=>{n&&t()})}}),fi=fe(ci,{paramsSchema:A.tuple(A.function()),implement(e){let t=er(e);lt.on("visible",n=>{!n&&t()})}}),mi=fe(li,{paramsSchema:A.tuple(A.function()),implement(e){let t=er(e);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Zt.registerCommand("LifecycleSDK.onReady",mi);Zt.registerCommand("LifecycleSDK.onJoliboxShow",di);Zt.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 on=po(nn()),ut=X(),rr=class{constructor(){this.getGameId=()=>R.mpId;this.getItem=async t=>{let{code:n,data:i,message:c}=await this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),d=i?.value,h=c;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:c,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:c,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=on.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},dt=new rr,hi=Z("getLocalStorage",{paramsSchema:A.tuple(A.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:A.tuple(A.string(),A.or(A.string(),A.boolean(),A.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:A.tuple(A.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:A.tuple(A.string(),A.object({result:A.boolean(),duration:A.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:A.tuple(A.string(),A.object({duration:A.number()})),implement:async(e,t)=>{let{duration:n}=t;await te.tracker("TaskFinished",{duration:n,taskId:e})}}),_i=Z("levelUpgrade",{paramsSchema:A.tuple(A.string(),A.string()),implement:async(e,t)=>await te.tracker("LevelUpgrade",{name:t,levelId:e})}),Ei=Z("onHistoryUserLevel",{paramsSchema:A.tuple(A.number()),implement:async e=>await te.tracker("HistoryUserLevel",{level:e})}),Ti=Z("onHistoryUserScore",{paramsSchema:A.tuple(A.number()),implement:async e=>await te.tracker("HistoryUserScore",{score:e})}),Ii=Z("taskEvent",{paramsSchema:A.tuple(A.string(),A.object({tools:A.array(A.object({id:A.string(),name:A.string(),count:A.number(),description:A.string().optional(),price:A.object({amount:A.number(),unit:A.string()}).optional()})).optional(),awards:A.array(A.object({id:A.string(),name:A.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 sn="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(sn)??"[]");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 c=this.checkShouldBannedForTime(t);return c||"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(sn,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??"",c=this.configs[n]?.interstitialRate??1;t=Math.random()<c}return this.firstRun=!1,t}};var pt=new ce,gt=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,c=window.encodeURIComponent(window.btoa(this.getGameId()??"")),d=this.getTestAdsMode()??!1;try{let h=await this.httpClient.get("/public/ads",{query:{objectId:c,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 c=document.createElement("script");c.id=n,c.async=!0,c.crossOrigin="anonymous",c.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,i&&c.setAttribute("data-adbreak-test","on"),this.channelId&&c.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(c),this.track("LoadAdsenseCompleted",null)}};this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((i=>i.type==="preroll")(t)){pt.emit("isAdShowing",!0);let i=t.adBreakDone;return{...t,adBreakDone:d=>{pt.emit("isAdShowing",!1),i&&i(d)}}}else{let i=t.beforeAd,c=t.afterAd;return{...t,beforeAd:()=>{pt.emit("isAdShowing",!0),i&&i()},afterAd:()=>{pt.emit("isAdShowing",!1),c&&c()}}}};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,c=t.adBreakDone,d=b=>{this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:b.breakType,breakName:b.breakName??"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),c&&c(b)};if(t.adBreakDone=d,t.type==="reward"){let b=t.beforeReward,S=x=>()=>{this.track("CallShowAdFn",null),x()},I=x=>{b&&b(S(x))};t.beforeReward=I}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,this.track("CallAdBreak",h);let T=this.wrapAdBreakParams(t);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:c,fullWidthResponsive:d,style:h}=t,T;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?T=document.querySelector(n):T=n,!T)throw new Error("targeting element not found");let b=i;if(b||(b=this.unitId),!b)throw new Error("slot is required");let S=typeof c=="object"&&Array.isArray(c)?c.join(", "):c,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",b),S&&I.setAttribute("data-ad-format",S),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",T.appendChild(I),I.appendChild(m)}else T.appendChild(I),new MutationObserver(_=>{_.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 vt=X(),yt=new gt(ve,new le,()=>ge.networkIsOk);vt.registerCommand("AdsSDK.init",e=>{yt.init(e)});vt.registerCommand("AdsSDK.adConfig",e=>{yt.adConfig(e)});vt.registerCommand("AdsSDK.adBreak",e=>{yt.adBreak(e)});vt.registerCommand("AdsSDK.adUnit",e=>{yt.adUnit(e)});function wi(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),te.start(Date.now()-e)})}function an(){wi()}an();
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
localforage/dist/localforage.js:
|
package/dist/index.native.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
var jn=Object.create;var ot=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Hn=Object.getPrototypeOf,Vn=Object.prototype.hasOwnProperty;var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var $n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vt=(e,t)=>{for(var r in t)ot(e,r,{get:t[r],enumerable:!0})},Kn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Jn(t))!Vn.call(e,s)&&s!==r&&ot(e,s,{get:()=>t[s],enumerable:!(n=Bn(t,s))||n.enumerable});return e};var qn=(e,t,r)=>(r=e!=null?jn(Hn(e)):{},Kn(t||!e||!e.__esModule?ot(r,"default",{value:e,enumerable:!0}):r,e));function Wn(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 Gt(e){return typeof e=="object"&&Array.isArray(e)}function Yn(e){return typeof e>"u"}function Qn(e){return Yn(e)||e===null}function zt(e){return typeof e=="function"}function Wt(e){return C(e)&&zt(e.then)}function Yt(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Qt(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:$t(u)&&$t(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 $t(e){return e&&typeof e=="object"&&e.constructor===Object}function Xt(e,t){if(Array.isArray(e))return e.concat(t)}function me(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 es(e,t){return(...r)=>t(e,...r)}function Ee(e){return t=>es(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new Zn(`${s}`))}})}function de(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function fs(e){return new Promise(t=>lr(e)(t))}function lr(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 ue(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++)ys(e[n],t[n])}function ys(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(!Qn(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[at])return globalThis[at];let e=new Te,t=new lt,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[at]=r,r}var Kt,Gn,zn,qt,Y,Xn,dt,re,Zt,er,Zn,tr,rr,nr,sr,or,pe,ke,ut,P,ir,ts,mt,rs,pt,ns,ss,ve,os,is,as,ar,ft,cs,ls,ds,cr,T,us,ms,ye,ue,Q,ct,ps,it,gs,$,Te,lt,at,v=p(()=>{"use strict";Kt=Object.defineProperty,Gn=Object.getOwnPropertyDescriptor,zn=(e,t)=>{for(var r in t)Kt(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,n)=>{for(var s=n>1?void 0:n?Gn(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&&Kt(t,r,s),s};Y=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))}})}};Xn=(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))(Xn||{}),dt=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 dt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Zt=class extends dt{constructor(){super(...arguments),this.kind="USER_ERROR"}},er=class extends Zt{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Zn=class extends Zt{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))}},tr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},rr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},nr=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}},sr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},or=class extends re{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},pe=class extends dt{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"}},ut=class extends re{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};P={log:de("log"),warn:de("warn"),info:de("info"),error:de("error"),debug:de("debug")};Object.assign(globalThis,{logger:P});ir=Symbol.for("Jolibox.canIUseMap"),ts={};globalThis[ir]=ts;mt={get config(){return globalThis[ir]}},rs=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(rs||{}),pt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(pt||{}),ns=(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))(ns||{}),ss=()=>"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")},os=()=>ve.isiOS?"iOS":ve.isAndroid?"Android":ve.isMac?"Mac":ve.isFacebook?"Facebook":"PC",is="device_id",as="advertising_id",ar=e=>(localStorage.getItem(e)||localStorage.setItem(e,ss()),localStorage.getItem(e)),ft=()=>ar(is),cs=()=>ar(as),ls=e=>e.charAt(0).toUpperCase()+e.slice(1),ds=()=>{let e=new URLSearchParams(window.location.search);return ls(e.get("utm_source")??"")||"JoliboxSDK"},cr=e=>{let t="JoliboxWebSDK",r=os(),n=navigator.language,s=ft(),o=cs();return`${t} (${ds()}${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}},us=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}},ms=0,ye=class{constructor(e){this.value=e,this.id=ms++}},ue=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}},Q=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new ue,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 us,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},ct={};zn(ct,{None:()=>ps,filter:()=>hs,once:()=>lr,toPromise:()=>fs});ps=()=>{console.log("[Jolibox SDK] None Event")};it=Symbol.for("Jolibox.hostEmitter"),gs=()=>{let e=new Q;return globalThis[it]||(globalThis[it]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[it]},$=gs();Te=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new ue,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}};Te=qt([Yt],Te);lt=class{constructor(){this._onWillExecuteCommand=new ue,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new ue,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Te,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Wn(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),ct.toPromise(ct.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}}};lt=qt([Yt],lt);at=Symbol.for("Jolibox.commands")});function dr(e){let t=mt.config[e];return t||(t={},mt.config[e]=t),(r,n)=>{if(t[r]){P.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var ur=p(()=>{"use strict";v()});function A(e,t={}){ht.emit("ERROR_REPORT",{error:e,options:t})}var ht,ne,L=p(()=>{"use strict";v();v();ht=new Q,ne=new Q;A.debounce=me(A,50,{leading:!0})});var gt,mr,pr=p(()=>{"use strict";v();L();gt=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{}}},mr=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[s,o,i]=n;return{headerJson:gt(s),payloadJson:gt(o),signature:gt(i)}}else throw"joli_source is missing"}catch(t){return A(new tr(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var bs,Se,fr,vt=p(()=>{"use strict";v();bs="1.1.7-beta.2",Se=()=>bs,fr=()=>{let e=Se();return`${cr(e)}`}});var Ts,ks,F,Es,y,j=p(()=>{"use strict";v();pr();vt();v();Ts={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ft(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Se()},schema:window.location.href,platform:"h5"},ks=globalThis.joliboxJSCore?.env,F=Object.assign({},ks?.()??Ts),Es=()=>{let{payloadJson:e,headerJson:t}=F.schema.length?mr(F.schema):{},r=`${F.deviceInfo.did}-${new Date().getTime()}`,s=new URL(F.schema.length?F.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??Se()},get platform(){return F.platform??F.deviceInfo.platform},get deviceInfo(){return F.deviceInfo},get sdkInfo(){return F.sdkInfo},get hostInfo(){return F.hostInfo},get hostUserInfo(){return F.hostUserInfo},get sessionId(){return F.clientSessionId??i??r},get channel(){return d},onEnvConfigChanged:f=>{Qt(F,f,Xt)}}},y=Es()});var yt,gr,Ss,ws,hr,Is,vr=p(()=>{"use strict";v();L();j();v();yt=!1,gr=(e,t)=>e==null?!1:t in e,Ss=e=>gr(e,"kind"),ws=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},hr=(e,t={},r)=>{let s={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:ws(e.name)},env:t.environment,isFromUser:r};r?ne.emit("GLOBAL_USER_ERROR",e,s):ne.emit("GLOBAL_ERROR",e,s)},Is=e=>gr(e,"kind")&&e.kind==="USER_ERROR";ht.on("ERROR_REPORT",({error:e,options:t})=>{if(yt)return;yt=!0;let r=Ss(e)&&e.raw?e.raw:e;try{let n=Is(e);hr(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new ut(`${s}, origin error: ${r.message}`);P.error(o),hr(new ut(o.message),{environment:t.environment},!1)}finally{yt=!1}})});function we(e,t){return`[${e}]:${t}`}var se,bt,X=p(()=>{"use strict";L();v();L();se=(e,t)=>new pe(t?.errMsg??e.msg??"",e.code,e.type),bt=e=>new er(e)});function Rs(e){return!!e?.__nativeBuffers__}function fe(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!Rs(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=_s(n.base64)),typeof s<"u"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function yr(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:As(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var _s,As,Tt=p(()=>{"use strict";_s=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};As=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)}});var br,Tr,kr,Er=p(()=>{"use strict";br=[],Tr=[],kr=["env","createRequestTask","login"]});function wr(e,t){Sr||(kt=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)}}),Et=new oe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),St=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",()=>{kt.flush(),Et.flush(),St.flush()}),Sr=!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";kt.report({status:b,method:n(o,i),errNo:`${d}`,errMsg:l,isForeground:u,duration:Date.now()-a}),a&&m&&h&&(Et.report({status:b,method:o,isForeground:u,duration:Number((m-a).toFixed(3))}),St.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 xs,oe,Sr,kt,Et,St,wt=p(()=>{"use strict";v();xs=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=xs(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={}}},Sr=!1});function Rr(e,t){let r=0,n=!0,s=new Map,o=wr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,It.forEach(async({method:l,args:d,resolve:f})=>{let m=await a(l,d);f(m)}),It.length=0});let i=(l,d)=>{P.info("----resolveId",l,d);let f=s.get(Number(l));if(!f)return;let m=fe(d);f(m),s.delete(Number(l))},a=(l,d)=>{let f=Date.now(),m=`${n}`;r+=1;let h=new Y;if(s.set(r,h.resolve),!n&&Tr.includes(l))return new Promise(x=>{It.push({method:l,args:d,resolve:x})});let _={...{method:l,startTime:f,args:d,isForeground:m},invokeType:"js-bridge"},O=!Cs&&br.includes(l),z=yr(d,O),W=O?z:JSON.stringify(z),k;if(l.endsWith("Sync")||kr.includes(l)?k=e.call?.(l,z,r):typeof W=="string"?(console.log("-----params",l,r),k=e.invoke(l,W,r)):k=e.call?.(l,W,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=fe(k)}catch(x){P.error(x)}return s.delete(r),k.errorCode&&(k.errorCode=we(l,k.errorCode)),o({..._,...k}),k}return l.endsWith("Sync")&&s.delete(r),h.promise.then(x=>(x.errorCode&&(x.errorCode=we(l,x.errorCode)),o({..._,...x}),x))};return{invokeNative:a,applyNative:(l,d)=>{let f=a(l,d);return Wt(f)?f.then(m=>Ir(l,m)):Ir(l,f)},invokeHandler:i}}function Ir(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 nr(r,n,s,o);return i}var It,Cs,_r=p(()=>{"use strict";Tt();v();X();Er();wt();It=[],Cs=!1});function Ar(e){let t=new Q,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=fe(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 xr=p(()=>{"use strict";v();Tt();wt()});function Rt(e){let{subscribeHandler:t,onNative:r,offNative:n}=Ar(e),{invokeNative:s,invokeHandler:o,applyNative:i}=Rr(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var Cr=p(()=>{"use strict";_r();xr()});var Pr=p(()=>{"use strict"});var Nr=p(()=>{"use strict";Cr();Pr()});var Z,B,Or,Fr=p(()=>{"use strict";v();L();B={trigger(){},exit(){return!1},onReady(e){B.trigger=e},doExit(e){B.exit=e}},Or=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)A(new rr("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:Or};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:Or};globalThis.joliboxJSCore={...n}}});function _t(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var At=p(()=>{"use strict"});function xt(){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=_t(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,Dr=p(()=>{"use strict";At()});var Ie=p(()=>{"use strict";Fr();Dr();At()});var Mr,Ps,Lr,Ur,D,w,H,la,Ns,M=p(()=>{"use strict";Nr();Ie();X();v();Ie();Mr=Z;if(!Mr)throw new sr("No joliboxJScore is found, native bridge not found.");xt();Ps={...Mr},Lr=Rt(Ps),{invokeHandler:Ur}=Lr,{applyNative:D,invokeNative:w,onNative:H,offNative:la,subscribeHandler:Ns}=Lr;globalThis.joliboxJSBridge={callHandler:Ur,invokeHandler:Ur,subscribeHandler:Ns}});var jr=p(()=>{"use strict";vr();X();v();M();ne.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};w("trackAsync",{event:"reportJsError",data:r})});ne.on("GLOBAL_USER_ERROR",(e,t)=>{P.log("UserError",e,t)})});var Ct=p(()=>{"use strict"});function Br(e,t){let r=(n,s,o)=>{let i={tag:n,...t,extra:{...s}};n=="globalJsError"?A(new or(JSON.stringify(i))):e("systemLog",i,o)};return r.debounce=me(r,500,{leading:!0}),r}function Jr(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=me(t,500,{leading:!0}),t}var Hr=p(()=>{"use strict";v();v();L()});function Vr(e,t){let r=Br(e,t),n=Jr(r);return{track:r,trackPerformance:n}}var $r=p(()=>{"use strict";Hr()});var Kr=p(()=>{"use strict";j();v();v()});var qr=p(()=>{"use strict";$r();Ct();Kr()});var Re,Gr=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 Pt=p(()=>{"use strict"});function Wr(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"&&zr<Fs||i==="inner")&&(d.joli_request_number=zr++,setTimeout(()=>{U("joliboxNetRequestResult",d)},500))}var zr,Fs,Yr=p(()=>{"use strict";Pt();ee();zr=0,Fs=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 H("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)}),$.on("onLoginComplete",({isLogin:u,token:l})=>{u&&l&&(i["X-JOLI-TOKEN"]=l)}),async(u,l={})=>{let d=Date.now(),f=Ds(u,{...l,baseUrl:s}),{method:m="GET",responseType:h="text",dataType:b="json",timeout:_,enableCache:O=!1,appendHostCookie:z=!0}=l,W=Object.assign({"content-type":"application/json"},i,l.header),k={url:f,method:m,header:W,enableCache:O,responseType:h,appendHostCookie:z};if(m=="POST"||m=="PUT"){let J=Ms(l.data,W["content-type"]);k.data=J}_&&Object.assign(k,{timeout:_});let{data:{requestTaskId:x}}=w(e,k);if(typeof x!="string")throw se({code:-1,msg:"requestTaskId is not a string"});let le=(J,V)=>{Wr("request",f,{state:J,startTime:d,endTime:Date.now(),params:k,response:V,requestId:x,requestFrom:o=="public"?"public":"inner"})},{resolve:st,reject:Fn,promise:Dn}=new Y;n.set(x,{resolve:st,reject:Fn});try{let J=await Dn;le("success",J);let{data:V}=J;return b==="json"&&typeof V=="string"&&(V=Us(V)),{url:f,timeout:_,method:m,response:{...J,data:V}}}catch(J){let V=J;if(C(V)){let{errMsg:ge,prefetchDetail:Un,isPrefetch:Mn,errNo:Ln}=V;te(ge)&&(le("fail",{errMsg:ge,isPrefetch:Mn,prefetchDetail:Un}),A(se({code:-1,msg:ge},{errNo:Ln,errMsg:ge})))}throw J}}}function Us(e){try{return JSON.parse(e.trim())}catch{return e}}function Ms(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 Ds,Nt=p(()=>{"use strict";v();Yr();Pt();M();L();X();Ds=(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 Ot,K,Ae=p(()=>{"use strict";vt();Nt();j();Ot={"x-user-agent":fr()};y.hostUserInfo?.token&&(Ot["x-joli-token"]=y.hostUserInfo.token);y.joliSource&&(Ot["x-joli-source"]=y.joliSource);K=_e("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Ot})});var xe,Qr=p(()=>{"use strict";j();Gr();Ae();M();xe=class extends Re{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,s=[];s.push(K("/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 en={};Vt(en,{nativeTaskEmitter:()=>he,taskTracker:()=>N,track:()=>U,trackPerformance:()=>Xr});var Ls,U,Xr,Zr,he,N,ee=p(()=>{"use strict";jr();v();Ct();qr();j();Qr();M();Ls=(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??""};w("trackAsync",{event:e,data:o,webviewId:r})},{track:U,trackPerformance:Xr}=Vr(Ls,{type:pt.AppSDK,platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),Zr=I();Zr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Xr(e,t,r)});Zr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{U(e,t)});he=new Q,N=new xe(U,he)});function Ft(e){tn=e}function Ce(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ce(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ce(e[r]),t),{})}function q(e){return typeof e=="number"}function Dt(e){let t=Ut(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Ut(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var tn,E,Pe,Ne,Oe,Fe,ae,De,Ue,Me,Le,je,Be,Je,He,Ve,$e,Ke,qe,Mt=p(()=>{"use strict";tn=!1;E=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(tn)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 ${Dt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ce(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ce(this._default)}optional(){return this._optional=!0,this}};Pe=class extends E{validate(t){return this._optional&&t===void 0?!0:q(t)?q(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):q(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):q(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}},Ne=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Oe=class extends E{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(q(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(q(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}},Fe=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends E{validate(t){return!0}},De=class extends E{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ue=class extends E{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Me=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Le=class extends E{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 ${Dt(t)}`)}return!0}},je=class extends E{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(q(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(q(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(q(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}},Be=class extends E{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ut(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}},Je=class extends E{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ut(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}},He=class extends E{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Dt(this.value),actual:r}):!0}},Ve=class extends E{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(`
|
|
2
|
-
or `);this.errors.push(o)}return n}},$e=class extends E{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}},Ke=class extends E{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},qe=class extends E{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 Lt(e,t,r="param"){if(e.errors=[],e.path=r,Ft(!0),!e.validate(t)){let n=e.errors.join(`
|
|
3
|
-
`);throw e.errors.length=0,Ft(!1),new TypeError(n)}}var c,jt=p(()=>{"use strict";Mt();Mt();c={object(e){return new Je(e)},array(e){return new je(e)},tuple(...e){return new $e(...e)},literal(e){return new He(e)},or(...e){return new Ve(...e)},symbol(){return new Fe},record(e){return new Be(e)},function(){return new Me},boolean(){return new Ne},string(){return new Oe},number(){return new Pe},undefined(){return new De},null(){return new Ue},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Ke},enum(...e){return new Le(...e)},typedarray(e){return new qe(e)}}});var Ge,rn,nn=p(()=>{"use strict";v();L();jt();X();Ge=1,rn=e=>{function t(n,s){return(...o)=>{let i=Date.now(),a={method:n,trace_id:Ge};Ge+=1;let u="SUCCESS",l=`${n}:ok`,d=0;try{if(s.paramsSchema)try{Lt(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:O}=f;u=b,m=_,h=O}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 pe(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=Gt(o)?o:[o],a=Date.now(),u={method:n,trace_id:Ge};Ge+=1;let l=`${n}:ok`,d="SUCCESS",f={code:d,message:l};try{if(s.paramsSchema)try{Lt(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:O}=h;d=b,l=O,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}`,O=`${n}:${d} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(f,{code:d,message:O}),A(new pe(O,b)),f}finally{let m=Date.now()-a;e("apiInvoked",{...u,duration:m,status:d})}}}return{createAPI:r,createSyncAPI:t}}});var S,R,g,G=p(()=>{"use strict";ur();ee();nn();jt();({createAPI:S,createSyncAPI:R}=rn(U)),g=dr("native")});var sn,Bs,Js,Hs,Vs,on=p(()=>{"use strict";v();G();M();sn=I(),Bs="env",Js="getSystemInfoSync",Hs=R(Js,{implement:()=>{let e=w("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}}}),Vs=R(Bs,{implement:()=>w("envSync")?.data??void 0});sn.registerCommand("API.getSystemInfoSync",Hs);sn.registerCommand("API.env",Vs);g("env",{version:"1.0.0"});g("getSystemInfoSync",{version:"1.0.0"})});var cn=$n(an=>{"use strict";v();G();L();M();ee();var $s="exitGame",Ks="onReady",qs="onJoliboxShow",Gs="onJoliboxHide",ze=I(),We=Ee(A),zs=S($s,{paramsSchema:c.tuple(c.function()),implement:async e=>{We(e).call(an),await D("exitAppAsync")}}),Ws=R(qs,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);H("onJoliboxEnterForeground",()=>{t.call(this),he.emit("visible",!0)})}}),Ys=R(Gs,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);H("onJoliboxEnterBackground",()=>{t.call(this),he.emit("visible",!1)})}}),Qs=R(Ks,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);$.on("LifecycleEvent.onReady",r=>{t(r)})}});ze.registerCommand("LifecycleSDK.exit",zs);ze.registerCommand("LifecycleSDK.onReady",Qs);ze.registerCommand("LifecycleSDK.onJoliboxShow",Ws);ze.registerCommand("LifecycleSDK.onJoliboxHide",Ys);g("lifeCycle.exit",{version:"1.0.0"});g("lifeCycle.onReady",{version:"1.0.0"});g("lifeCycle.onJoliboxShow",{version:"1.0.0"});g("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function ln(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 dn(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 un(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function mn(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 pn=p(()=>{"use strict";v()});var Xs,Zs,Bt,Jt,fn,eo,to,ro,hn=p(()=>{"use strict";X();Nt();G();pn();v();L();Xs=15,Zs=_e("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Bt=0,Jt=[],fn=Ee(A),eo=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},to=e=>{let t=new Y,r=()=>{};return S("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=fn(s.fail);try{if(Bt+=1,t.state!=="pending")return;let{data:a,dataType:u,responseType:l,enableCache:d,appendHostCookie:f}=s,m=ln(s.header),h=dn(s.method),b=un(s.timeout),_=mn(s.url,h,a),O=fn(s.success),z=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&&(z.timeout=b);let W=Zs(_,z);{let{response:k}=await W,{code:x,data:le,message:st}=k;t.resolve({code:x??"SUCCESS",data:le,message:st??"request:ok"}),O({code:"SUCCESS",message:"request:ok",data:le})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Bt-=1,Jt.shift()?.()}};return Bt>=Xs?(r=()=>{eo(Jt,i=>i===o)},Jt.push(o)):o(),t.promise}})(e),{abort(){t.reject(se({code:-1,msg:"request:fail abort"})),r()}}},ro=I();ro.registerCommand("HttpSDK.request",to);g("request",{version:"1.0.0"})});function co(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return ao.includes(t)?t:""}function lo(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 uo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}var Ye,no,so,oo,io,tl,rl,ao,gn=p(()=>{"use strict";G();M();v();Ae();j();Ye=I(),no=S("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await K(`/api/games/user-storage/${y.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=lo(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}}}});Ye.registerCommand("StorageSDK.getItem",no);g("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});so=S("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:s}=await K(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:i}}=s,a=co(t),u=uo(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`}}});Ye.registerCommand("StorageSDK.setItem",so);g("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});oo=S("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=y.mpId,{response:r}=await K(`/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"}}});Ye.registerCommand("StorageSDK.removeItem",oo);g("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});io=S("clearStorage",{async implement(){let e=y.mpId,{response:t}=await K(`/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`}}});Ye.registerCommand("StorageSDK.clear",io);g("storage.clear",{version:"1.0.0"});tl=S("getStorageInfo",{async implement(){let{data:e}=await D("getStorageInfoAsync");return e}});g("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});rl=R("getStorageInfoSync",{implement(){return w("getStorageInfoSync")}}),ao=["string","number","boolean","object",""]});var mo,po,fo,Ht,vn=p(()=>{"use strict";v();M();G();mo=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)),w("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});g("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"}});po=R("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){w("updateKeyboardSync",e)}});g("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});fo=R("hideKeyboard",{implement(){w("hideKeyboardSync")}});g("keyboard.hideKeyboard",{version:"1.0.0"});Ht=I();Ht.registerCommand("KeyboardSDK.showKeyboard",mo);Ht.registerCommand("KeyboardSDK.updateKeyboard",po);Ht.registerCommand("KeyboardSDK.hideKeyboard",fo)});var ce,ho,go,vo,yo,bo,To,yn=p(()=>{"use strict";v();G();ee();ce=I(),ho=S("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(N.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(N.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(s)}}),go=S("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await N.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),vo=S("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(N.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),yo=S("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await N.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),bo=S("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await N.reportToNative({event:"HistoryUserScore",params:{score:e}})}),To=S("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(N.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(N.reporter({event:"USE_GAME_ITEM"})),r.push(N.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",ho);ce.registerCommand("TaskTrackerSDK.taskFinished",go);ce.registerCommand("TaskTrackerSDK.levelUpgrade",vo);ce.registerCommand("TaskTrackerSDK.historyUserLevel",yo);ce.registerCommand("TaskTrackerSDK.historyUserScore",bo);ce.registerCommand("TaskTrackerSDK.taskEvent",To);g("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});g("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});g("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});g("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 ko,Eo,bn,Tn=p(()=>{"use strict";j();M();G();v();X();g("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"}});g("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});ko=S("login",{async implement(){let{data:{isLogin:e}}=await D("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};H("onLoginStateChange",({isLogin:i,token:a,uuid:u})=>{u==r&&s({isLogin:i,token:a})});let t=w("loginSync"),{data:{uuid:r}}=t;if(!r)throw se({code:-1,msg:"login failed"});let{promise:n,resolve:s}=new Y,o=await n;return y.onEnvConfigChanged({hostUserInfo:o}),$.emit("onLoginComplete",o),o}}),Eo=S("checkSession",{async implement(){let{data:{isLogin:e}}=await D("checkLoginAsync");return{isLogin:e}}}),bn=I();bn.registerCommand("API.login",ko);bn.registerCommand("API.checkSession",Eo)});var Qe,kn=p(()=>{"use strict";Qe=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 En,Xe,Sn=p(()=>{"use strict";En="jolibox-sdk-ads-callbreak-timestamps",Xe=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(En)??"[]");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(En,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}}});var Ze,wn=p(()=>{"use strict";j();Ze=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=y.channel??"",s=this.configs[r]?.interstitialRate??1;t=Math.random()<s}return this.firstRun=!1,t}}});var et,In=p(()=>{"use strict";kn();Sn();j();wn();et=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>y.mpId;this.getTestAdsMode=()=>y.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,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,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 Xe(n),this.adsActionDetection=new Qe(this.track),this.channelPolicy=new Ze(r)}init(t){this.track("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var tt,So,rt,wo,Io,Ro,_o,Rn=p(()=>{"use strict";v();G();In();ee();Ae();M();tt=I(),So=()=>{let{data:e}=w("getNetworkStatusSync");return!!e?.isConnected},rt=new et(U,{get:(e,t)=>K(e,{method:"GET",responseType:"json",appendHostCookie:!0,...t}).then(r=>r.response.data)},So),wo=R("adInit",{implement:e=>{rt.init(e)}}),Io=R("adConfig",{implement:e=>{rt.adConfig(e)}}),Ro=R("adBreak",{implement:e=>{rt.adBreak(e)}}),_o=R("adUnit",{implement:e=>{rt.adUnit(e)}});tt.registerCommand("AdsSDK.init",wo);tt.registerCommand("AdsSDK.adConfig",Io);tt.registerCommand("AdsSDK.adBreak",Ro);tt.registerCommand("AdsSDK.adUnit",_o);g("AdsSDK.init",{version:"1.0.0"});g("AdsSDK.adConfig",{version:"1.0.0"});g("AdsSDK.adBreak",{version:"1.0.0"});g("AdsSDK.adUnit",{version:"1.0.0"})});var Ao={};var jl,_n=p(()=>{"use strict";on();jl=qn(cn());hn();gn();vn();yn();Tn();Rn()});function An(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let o=`
|
|
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 o of $n(t))!qn.call(e,o)&&o!==r&&at(e,o,{get:()=>t[o],enumerable:!(n=Vn(t,o))||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 ue(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 o;n.value?o=n.value:n.base64&&(o=Qn(n.base64)),typeof o<"u"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Gt(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:Xn(s),key:o};n.push(i),delete r[o]}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 o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};Xn=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function to(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function P(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 ro(e){return typeof e>"u"}function no(e){return ro(e)||e===null}function Zt(e){return typeof e=="function"}function er(e){return P(e)&&Zt(e.then)}function tr(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),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(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],c=s[i],d=r(a,c,i,o,s);d!==void 0?o[i]=d:zt(c)&&zt(a)?o[i]=n({...a},c):Array.isArray(c)&&Array.isArray(a)?o[i]=[...a,...c]:o[i]=c}return o}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 fe(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:c=!0}=r,d=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),u=function(...f){o=f,s=this;let m=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!m&&d()},t),m)return d()};return u.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,d()},u}function io(e,t){return(...r)=>t(e,...r)}function we(e){return t=>io(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new so(`${o}`))}})}function me(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function ko(e){return new Promise(t=>fr(e)(t))}function fr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Eo(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new pe(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function So(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Io(e[n],t[n])}function Io(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(!no(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 ke,t=new mt,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[dt]=r,r}var Wt,Zn,eo,Yt,Q,oo,pt,re,or,sr,so,ir,ar,cr,lr,dr,he,Ee,ft,C,ur,ao,ht,co,gt,lo,uo,ye,mo,po,fo,mr,vt,ho,go,vo,pr,T,yo,bo,be,pe,H,ut,To,lt,wo,K,ke,mt,dt,g=p(()=>{"use strict";Wt=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,eo=(e,t)=>{for(var r in t)Wt(e,r,{get:t[r],enumerable:!0})},Yt=(e,t,r,n)=>{for(var o=n>1?void 0:n?Zn(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Wt(t,r,o),o};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))}})}};oo=(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))(oo||{}),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"}},or=class extends pt{constructor(){super(...arguments),this.kind="USER_ERROR"}},sr=class extends or{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},so=class extends or{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"}},he=class extends pt{constructor(e,t,r,n,o){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),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Ee=class extends re{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},ft=class extends re{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};C={log:me("log"),warn:me("warn"),info:me("info"),error:me("error"),debug:me("debug")};Object.assign(globalThis,{logger:C});ur=Symbol.for("Jolibox.canIUseMap"),ao={};globalThis[ur]=ao;ht={get config(){return globalThis[ur]}},co=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(co||{}),gt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(gt||{}),lo=(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))(lo||{}),uo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ye={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")},mo=()=>ye.isiOS?"iOS":ye.isAndroid?"Android":ye.isMac?"Mac":ye.isFacebook?"Facebook":"PC",po="device_id",fo="advertising_id",mr=e=>(localStorage.getItem(e)||localStorage.setItem(e,uo()),localStorage.getItem(e)),vt=()=>mr(po),ho=()=>mr(fo),go=e=>e.charAt(0).toUpperCase()+e.slice(1),vo=()=>{let e=new URLSearchParams(window.location.search);return go(e.get("utm_source")??"")||"JoliboxSDK"},pr=e=>{let t="JoliboxWebSDK",r=mo(),n=navigator.language,o=vt(),s=ho();return`${t} (${vo()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},T=class Te{static{this.Undefined=new Te(void 0)}constructor(t){this.element=t,this.next=Te.Undefined,this.prev=Te.Undefined}},yo=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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}},bo=0,be=class{constructor(e){this.value=e,this.id=bo++}},pe=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof be&&(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 be(e);this._listeners?this._listeners instanceof be?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 be?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 pe,n=s=>t(...s.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire({event:e,...o.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 yo,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},ut={};eo(ut,{None:()=>To,filter:()=>Eo,once:()=>fr,toPromise:()=>ko});To=()=>{console.log("[Jolibox SDK] None Event")};lt=Symbol.for("Jolibox.hostEmitter"),wo=()=>{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=wo();ke=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new pe,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return So(o,r),n(...o)}}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}};ke=Yt([tr],ke);mt=class{constructor(){this._onWillExecuteCommand=new pe,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new pe,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new ke,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=to(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 _(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;_.debounce=fe(_,50,{leading:!0})});function Se(e,t){return`[${e}]:${t}`}var oe,bt,X=p(()=>{"use strict";L();g();L();oe=(e,t)=>new he(t?.errMsg??e.msg??"",e.code,e.type),bt=e=>new sr(e)});var hr,gr,vr,yr=p(()=>{"use strict";hr=[],gr=[],vr=["env","createRequestTask","login"]});function Tr(e,t){br||(Tt=new se({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),kt=new se({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),Et=new se({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{Tt.flush(),kt.flush(),Et.flush()}),br=!0);function r(o){let{method:s,args:i,startTime:a,isForeground:c,errMsg:d=`${s}:fail no errMsg`,errNo:u=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:m,invokeCallback:h}=f,b=d.match(/\S:(\S+)\s?/)?.[1]??"fail";Tt.report({status:b,method:n(s,i),errNo:`${u}`,errMsg:d,isForeground:c,duration:Date.now()-a}),a&&m&&h&&(kt.report({status:b,method:s,isForeground:c,duration:Number((m-a).toFixed(3))}),Et.report({status:b,method:s,isForeground:c,duration:Number((Date.now()-h).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s?.method?`${o}-${s.method}`:o}return r}var Ao,se,br,Tt,kt,Et,wt=p(()=>{"use strict";g();Ao=e=>e==="pv"?e:"default",se=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=Ao(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,o,s,i)=>{let a=o.shift();if(a){let c=i[a];n[c]||(n[c]={}),r(n[c],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let c=s.shift();if(!c&&P(a))throw new Ee(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let d=[];if(P(a))d.push(...Object.keys(a));else if(te(a)){if(s.length>0)throw new Ee(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);d.push(a)}else throw new Ee(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);d.forEach(u=>{o[u]||(o[u]={});let f=P(a)?a[u]:a;r(o[u],[...s],i,f)})}else o[i]?o[i]++:o[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,o=new Map,s=Tr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,St.forEach(async({method:d,args:u,resolve:f})=>{let m=await a(d,u);f(m)}),St.length=0});let i=(d,u)=>{C.info("----resolveId",d,u);let f=o.get(Number(d));if(!f)return;let m=ue(u);f(m),o.delete(Number(d))},a=(d,u)=>{let f=Date.now(),m=`${n}`;r+=1;let h=new Q;if(o.set(r,h.resolve),!n&&gr.includes(d))return new Promise(x=>{St.push({method:d,args:u,resolve:x})});let R={...{method:d,startTime:f,args:u,isForeground:m},invokeType:"js-bridge"},F=!Ro&&hr.includes(d),W=Gt(u,F),Y=F?W:JSON.stringify(W),k;if(d.endsWith("Sync")||vr.includes(d)?k=e.call?.(d,W,r):typeof Y=="string"?(console.log("-----params",d,r),k=e.invoke(d,Y,r)):k=e.call?.(d,Y,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=ue(k)}catch(x){C.error(x)}return o.delete(r),k.errorCode&&(k.errorCode=Se(d,k.errorCode)),s({...R,...k}),k}return d.endsWith("Sync")&&o.delete(r),h.promise.then(x=>(x.errorCode&&(x.errorCode=Se(d,x.errorCode)),s({...R,...x}),x))};return{invokeNative:a,applyNative:(d,u)=>{let f=a(d,u);return er(f)?f.then(m=>kr(d,m)):kr(d,f)},invokeHandler:i}}function kr(e,t){if(!P(t)){C.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:o,errorCode:s,...i}=t;if(r&&r!==`${e}:ok`)throw new cr(r,n,o,s);return i}var St,Ro,wr=p(()=>{"use strict";ct();g();X();yr();wt();St=[],Ro=!1});function Sr(e){let t=new H,r=new se({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,o,s){let i=ue(o),a;if(i.__extra){a=i.params;let{type:c,startTime:d}=i.__extra;r.report({type:c,event:n,duration:Date.now()-d})}else a=i;t.emit(n,a,s)}}}var Ir=p(()=>{"use strict";g();ct();wt()});function It(e){let{subscribeHandler:t,onNative:r,offNative:n}=Sr(e),{invokeNative:o,invokeHandler:s,applyNative:i}=Er(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var Ar=p(()=>{"use strict";wr();Ir()});var Rr=p(()=>{"use strict"});var _r=p(()=>{"use strict";Ar();Rr()});var Z,B,xr,Pr=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)_(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=(o="")=>{B.trigger(),e.onDocumentReady.postMessage({path:o})};Z={onDocumentReady:t,doExit:o=>{let s=B.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})},invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),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=(o="")=>{B.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};Z={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=B.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:xr};globalThis.joliboxJSCore={...n}}});function At(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Rt=p(()=>{"use strict"});function _t(){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=At(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,Cr=p(()=>{"use strict";Rt()});var Ie=p(()=>{"use strict";Pr();Cr();Rt()});var Or,_o,Fr,Nr,D,E,V,Gi,xo,M=p(()=>{"use strict";_r();Ie();X();g();Ie();Or=Z;if(!Or)throw new lr("No joliboxJScore is found, native bridge not found.");_t();_o={...Or},Fr=It(_o),{invokeHandler:Nr}=Fr,{applyNative:D,invokeNative:E,onNative:V,offNative:Gi,subscribeHandler:xo}=Fr;globalThis.joliboxJSBridge={callHandler:Nr,invokeHandler:Nr,subscribeHandler:xo}});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[o,s,i]=n;return{headerJson:xt(o),payloadJson:xt(s),signature:xt(i)}}else throw"joli_source is missing"}catch(t){return _(new ir(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Po,Ae,Mr,Pt=p(()=>{"use strict";g();Po="1.1.7-beta.4",Ae=()=>Po,Mr=()=>{let e=Ae();return`${pr(e)}`}});var Co,No,N,Oo,v,j=p(()=>{"use strict";g();Ur();Pt();g();Co={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:vt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ae()},schema:window.location.href,platform:"h5"},No=globalThis.joliboxJSCore?.env,N=Object.assign({},No?.()??Co),Oo=()=>{let{payloadJson:e,headerJson:t}=N.schema.length?Dr(N.schema):{},r=`${N.deviceInfo.did}-${new Date().getTime()}`,o=new URL(N.schema.length?N.schema:window.location.href).searchParams,s=o.get("mpId")??o.get("appId")??o.get("gameId")??"",i=e?.sessionId??o.get("sessionId")??r,a=!!(e?.testAdsMode??o.get("testAdsMode")==="true"),c=e?.joliboxEnv??o.get("joliboxEnv")??"production",d=c==="staging",u=t?.channel;return{get testMode(){return d},get testAdsMode(){return a},get joliboxEnv(){return c},get joliSource(){return o.get("joliSource")??null},get mpId(){return s??e?.id??""},get mpVersion(){return t?.ver??Ae()},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 u},get webviewId(){return N.webviewId??-1},onEnvConfigChanged:f=>{rr(N,f,nr)}}},v=Oo()});var Ct,Br,Fo,Do,Lr,Uo,jr=p(()=>{"use strict";g();L();j();g();Ct=!1,Br=(e,t)=>e==null?!1:t in e,Fo=e=>Br(e,"kind"),Do=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 o={...{user_id:v.hostUserInfo?.uid??"",device_id:v.deviceInfo.did??"",timestamp:Date.now(),tag:Do(e.name)},env:t.environment,isFromUser:r};r?ne.emit("GLOBAL_USER_ERROR",e,o):ne.emit("GLOBAL_ERROR",e,o)},Uo=e=>Br(e,"kind")&&e.kind==="USER_ERROR";yt.on("ERROR_REPORT",({error:e,options:t})=>{if(Ct)return;Ct=!0;let r=Fo(e)&&e.raw?e.raw:e;try{let n=Uo(e);Lr(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new ft(`${o}, origin error: ${r.message}`);C.error(s),Lr(new ft(s.message),{environment:t.environment},!1)}finally{Ct=!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)=>{C.log("UserError",e,t)})});var Nt=p(()=>{"use strict"});function Hr(e,t){let r=(n,o,s)=>{let i={tag:n,...t,extra:{...o}};n=="globalJsError"?_(new dr(JSON.stringify(i))):e("systemLog",i,s)};return r.debounce=fe(r,500,{leading:!0}),r}function Vr(e){let t=(r,n,o)=>{let s=(o&&JSON.stringify(o))??0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=fe(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,o,s=!1,i=0,a=()=>{if(!s)return;let h=Date.now(),b=h-r;b>=this.interval&&(this.visible&&(i+=b,t(i)),r=h),n=requestAnimationFrame(a)},c=()=>{u(),r=Date.now(),o=window.setInterval(()=>{if(!s)return;let h=Date.now();h-r>=this.interval&&(r=h)},this.interval)},d=()=>{f(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},f=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",h=>{s&&(console.log("visible",h),h?d():c())});let m=this.visible;return{start(){s||(s=!0,m?d():c())},stop(){s=!1,u(),f()}}}}});var Ot=p(()=>{"use strict"});function Qr(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,u={duration:s-o,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"&&Yr<Lo||i==="inner")&&(u.joli_request_number=Yr++,setTimeout(()=>{U("joliboxNetRequestResult",u)},500))}var Yr,Lo,Xr=p(()=>{"use strict";Ot();ee();Yr=0,Lo=10});function _e(e,t,r){let n=new Map,o=r?.baseUrl??"https://api.jolibox.com",s=r?.type??"public",i=r?.defaultHeaders??{};return V("onRequestTaskStateChange",c=>{if(typeof c.requestTaskId!="string")return;let d=n.get(c.requestTaskId);if(d)if(c.state==="success"){let{requestTaskId:u,state:f,...m}=c;d.resolve(m),n.delete(u)}else if(c.state==="fail"){let{requestTaskId:u,state:f,...m}=c;d.reject(m),n.delete(u)}else C.warn("onRequestTaskStateChange unknown event",c)}),K.on("onLoginComplete",({isLogin:c,token:d})=>{c&&d&&(i["X-JOLI-TOKEN"]=d)}),async(c,d={})=>{let u=Date.now(),f=Bo(c,{...d,baseUrl:o}),{method:m="GET",responseType:h="text",dataType:b="json",timeout:R,enableCache:F=!1,appendHostCookie:W=!0}=d,Y=Object.assign({"content-type":"application/json"},i,d.header),k={url:f,method:m,header:Y,enableCache:F,responseType:h,appendHostCookie:W};if(m=="POST"||m=="PUT"){let J=Jo(d.data,Y["content-type"]);k.data=J}R&&Object.assign(k,{timeout:R});let{data:{requestTaskId:x}}=E(e,k);if(typeof x!="string")throw oe({code:-1,msg:"requestTaskId is not a string"});let de=(J,$)=>{Qr("request",f,{state:J,startTime:u,endTime:Date.now(),params:k,response:$,requestId:x,requestFrom:s=="public"?"public":"inner"})},{resolve:it,reject:Mn,promise:Ln}=new Q;n.set(x,{resolve:it,reject:Mn});try{let J=await Ln;de("success",J);let{data:$}=J;return b==="json"&&typeof $=="string"&&($=jo($)),{url:f,timeout:R,method:m,response:{...J,data:$}}}catch(J){let $=J;if(P($)){let{errMsg:ve,prefetchDetail:Bn,isPrefetch:jn,errNo:Jn}=$;te(ve)&&(de("fail",{errMsg:ve,isPrefetch:jn,prefetchDetail:Bn}),_(oe({code:-1,msg:ve},{errNo:Jn,errMsg:ve})))}throw J}}}function jo(e){try{return JSON.parse(e.trim())}catch{return e}}function Jo(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 Bo,Ft=p(()=>{"use strict";g();Xr();Ot();M();L();X();Bo=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,o=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var Dt,q,xe=p(()=>{"use strict";Pt();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 Pe,Zr=p(()=>{"use strict";j();Wr();xe();M();Pe=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,o=[];o.push(q("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(o)}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:()=>ge,taskTracker:()=>O,track:()=>U,trackPerformance:()=>en});var Ho,U,en,tn,ge,O,ee=p(()=>{"use strict";Jr();g();Nt();zr();j();Zr();M();Ho=(e,t,r)=>{let n=t,s={...P(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:s,webviewId:r})},{track:U,trackPerformance:en}=Kr(Ho,{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)});ge=new H,O=new Pe(U,ge)});function nn(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
|
|
4
2
|
html[data-jolibox-root] {
|
|
5
3
|
height: 100%;
|
|
6
4
|
margin: 0;
|
|
@@ -18,4 +16,6 @@ or `);this.errors.push(o)}return n}},$e=class extends E{constructor(...t){super(
|
|
|
18
16
|
min-height: 100dvh;
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
`;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 xn=p(()=>{"use strict"});var Pn={};Vt(Pn,{config:()=>Po});function xo(){$.on("onDocumentReady",()=>{Z?.onDocumentReady(window.location.href),U("onDocumentReady",{start_timestamp:nt,timestamp:Date.now()})})}function Co(){H("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),$.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),U("joliboxServiceReady",{start_timestamp:nt,timestamp:Date.now()}),N.start(t)}),H("onBeforeExit",({uuid:e})=>{Z?.doExit(e)})}function Po(){nt=Date.now(),Co(),xo(),Cn=An()}var Cn,nt,Nn=p(()=>{"use strict";M();Ie();j();v();ee();xn();B.onReady(()=>{});B.doExit(()=>(U("onBeforeExit",{timestamp:Date.now()}),Cn?.(),N.close(Date.now()-nt),!1))});var On=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[On])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[On]=!0;(async()=>{await Promise.all([Promise.resolve().then(()=>(_n(),Ao)),Promise.resolve().then(()=>(ee(),en))]);let{config:e}=await Promise.resolve().then(()=>(Nn(),Pn));e()})();
|
|
19
|
+
`;e.textContent=s;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{async function s(a){let c=a instanceof URL?a.href:a,d=new Promise((u,f)=>{let m=new XMLHttpRequest;m.open("GET",c),m.responseType="arraybuffer",m.addEventListener("load",()=>u(m.response)),m.addEventListener("error",f),m.send()});try{let u=await d;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 d=a instanceof URL?a.href:a.toString();return d.endsWith(".wasm")?s(d):i(a,c)}},o=()=>{e?.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),o}var on=p(()=>{"use strict"});var Ce,sn=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,Ne,cn=p(()=>{"use strict";an="jolibox-sdk-ads-callbreak-timestamps",Ne=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 o=this.checkShouldBannedForTime(t);return o||"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 Oe,ln=p(()=>{"use strict";j();Oe=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??"",o=this.configs[r]?.interstitialRate??1;t=Math.random()<o}return this.firstRun=!1,t}}});var ae,Fe,Ut=p(()=>{"use strict";sn();cn();j();ln();g();ae=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,o=window.encodeURIComponent(window.btoa(this.getGameId()??"")),s=this.getTestAdsMode()??!1;try{let i=await this.httpClient.get("/public/ads",{query:{objectId:o,testAdsMode:`${s}`}});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 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)){ae.emit("isAdShowing",!0);let n=t.adBreakDone;return{...t,adBreakDone:s=>{ae.emit("isAdShowing",!1),n&&n(s)}}}else{let n=t.beforeAd,o=t.afterAd;return{...t,beforeAd:()=>{ae.emit("isAdShowing",!0),n&&n()},afterAd:()=>{ae.emit("isAdShowing",!1),o&&o()}}}};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,o=t.adBreakDone,s=c=>{this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:c.breakType,breakName:c.breakName??"",breakFormat:c.breakFormat,breakStatus:c.breakStatus}),o&&o(c)};if(t.adBreakDone=s,t.type==="reward"){let c=t.beforeReward,d=f=>()=>{this.track("CallShowAdFn",null),f()},u=f=>{c&&c(d(f))};t.beforeReward=u}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,this.track("CallAdBreak",i);let a=this.wrapAdBreakParams(t);this.push(a),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:o,fullWidthResponsive:s,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 d=typeof o=="object"&&Array.isArray(o)?o.join(", "):o,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),d&&u.setAttribute("data-ad-format",d),s&&u.setAttribute("data-full-width-responsive",s),i&&u.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",u.style.position="relative",a.appendChild(u),u.appendChild(m)}else a.appendChild(u),new MutationObserver(h=>{h.forEach(b=>{if(b.type==="attributes"&&b.attributeName==="data-ad-status"){let R=u.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:R??"null"})}})}).observe(u,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new Ne(n),this.adsActionDetection=new Ce(this.track),this.channelPolicy=new Oe(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:()=>Ko});function Vo(){K.on("onDocumentReady",()=>{Z?.onDocumentReady(window.location.href),U("onDocumentReady",{start_timestamp:Ue,timestamp:Date.now()})})}function $o(){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 Ko(){Ue=Date.now(),$o(),Vo(),dn=nn()}var dn,De,Ue,mn=p(()=>{"use strict";M();Ie();j();g();ee();on();Ut();B.onReady(()=>{});B.doExit(()=>(U("onBeforeExit",{timestamp:Date.now()}),dn?.(),O.close(Date.now()-Ue),!!De));De=!1;ae.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]){C.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,w,Le,Be,je,Je,ce,He,Ve,$e,Ke,qe,Ge,ze,We,Ye,Qe,Xe,Ze,jt=p(()=>{"use strict";hn=!1;w=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 w{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 w{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},je=class extends w{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 w{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ce=class extends w{validate(t){return!0}},He=class extends w{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ve=class extends w{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},$e=class extends w{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Ke=class extends w{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 w{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 o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}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 w{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 o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let c=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(c===void 0&&s._optional)){if(c===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(c)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},ze=class extends w{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,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},We=class extends w{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 w{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
|
|
20
|
+
or `);this.errors.push(s)}return n}},Qe=class extends w{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let o=t[n];if(o._optional||o.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,o)=>{if(n.path=`${this.path}[${o}]`,n.errors=this.errors,t[o]===void 0&&n.hasDefault){t[o]=n.defaultValue;return}n.validate(t[o])||(n.hasFallback?t[o]=n._fallback:r=!1)}),r}},Xe=class extends w{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},Ze=class extends w{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 l,Ht=p(()=>{"use strict";jt();jt();l={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 ce},any(){return new ce},as(){return new ce},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,o){return(...s)=>{let i=Date.now(),a={method:n,trace_id:et};et+=1;let c="SUCCESS",d=`${n}:ok`,u=0;try{if(o.paramsSchema)try{Jt(o.paramsSchema,s,"params")}catch(b){throw bt(`${n}:fail ${b.message}`)}let f=o.implement(...s),m=f,h=`${n}:ok`;if(f&&"code"in f){let{code:b,data:R,message:F}=f;c=b,m=R,h=F}return{code:c,message:h,data:m}}catch(f){let m=f;u=m.code??m.errNo??2e3,c="FAILURE";let h=m.message??m.errMsg??`${f}`;return d=`${n}:${c} ${h.replace(/^\S+:(fail|cancel)\s?/,"")}`,_(new he(d,u)),{code:c,message:d}}finally{let f=Date.now()-i;e("apiInvoked",{...a,duration:f,status:c})}}}function r(n,o){return async(...s)=>{let i=Qt(s)?s:[s],a=Date.now(),c={method:n,trace_id:et};et+=1;let d=`${n}:ok`,u="SUCCESS",f={code:u,message:d};try{if(o.paramsSchema)try{Jt(o.paramsSchema,i,"params")}catch(b){throw bt(b.message)}let h=await o.implement(...i);if(h&&"code"in h){let{code:b,data:R,message:F}=h;u=b,d=F,h=R}return Object.assign(f,{code:u,message:d,data:h}),f}catch(m){let h=m,b=h.code??h.errNo??2e3;u="FAILURE";let R=h.message??h.errMsg??`${m}`,F=`${n}:${u} ${R.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(f,{code:u,message:F}),_(new he(F,b)),f}finally{let m=Date.now()-a;e("apiInvoked",{...c,duration:m,status:u})}}}return{createAPI:r,createSyncAPI:t}}});var S,A,y,z=p(()=>{"use strict";fn();ee();vn();Ht();({createAPI:S,createSyncAPI:A}=gn(U)),y=pn("native")});var yn,Go,zo,Wo,Yo,bn=p(()=>{"use strict";g();z();M();yn=I(),Go="env",zo="getSystemInfoSync",Wo=A(zo,{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}}}),Yo=A(Go,{implement:()=>E("envSync")?.data??void 0});yn.registerCommand("API.getSystemInfoSync",Wo);yn.registerCommand("API.env",Yo);y("env",{version:"1.0.0"});y("getSystemInfoSync",{version:"1.0.0"})});var kn=Gn(Tn=>{"use strict";g();z();L();M();ee();var Qo="exitGame",Xo="onReady",Zo="onJoliboxShow",es="onJoliboxHide",tt=I(),rt=we(_),ts=S(Qo,{paramsSchema:l.tuple(l.function()),implement:async e=>{rt(e).call(Tn),await D("exitAppAsync")}}),rs=A(Zo,{paramsSchema:l.tuple(l.function()),implement(e){let t=rt(e);V("onJoliboxEnterForeground",()=>{t.call(this),ge.emit("visible",!0)})}}),ns=A(es,{paramsSchema:l.tuple(l.function()),implement(e){let t=rt(e);V("onJoliboxEnterBackground",()=>{t.call(this),ge.emit("visible",!1)})}}),os=A(Xo,{paramsSchema:l.tuple(l.function()),implement(e){let t=rt(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});tt.registerCommand("LifecycleSDK.exit",ts);tt.registerCommand("LifecycleSDK.onReady",os);tt.registerCommand("LifecycleSDK.onJoliboxShow",rs);tt.registerCommand("LifecycleSDK.onJoliboxHide",ns);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(!P(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function wn(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 Sn(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)||!P(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify({...JSON.parse(o),...r});return`${n}?${s}`}var An=p(()=>{"use strict";g()});var ss,is,Vt,$t,Rn,as,cs,ls,_n=p(()=>{"use strict";X();Ft();z();An();g();L();ss=15,is=_e("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Vt=0,$t=[],Rn=we(_),as=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},cs=e=>{let t=new Q,r=()=>{};return S("request",{paramsSchema:l.tuple(l.object({url:l.string(),method:l.string(),header:l.object(),data:l.object().optional(),query:l.object().optional(),dataType:l.string().default("json"),responseType:l.string().default("text"),enableCache:l.boolean().default(!1),appendHostCookie:l.boolean().default(!0),timeout:l.number().default(3e4),success:l.function(),fail:l.function()})),implement(o){let s=async()=>{let i=Rn(o.fail);try{if(Vt+=1,t.state!=="pending")return;let{data:a,dataType:c,responseType:d,enableCache:u,appendHostCookie:f}=o,m=En(o.header),h=wn(o.method),b=Sn(o.timeout),R=In(o.url,h,a),F=Rn(o.success),W=Object.assign({},o,{method:h,header:m,data:h==="GET"||h==="HEAD"?void 0:a,enableCache:u,query:o.query??{},dataType:c,responseType:d,appendHostCookie:f});b&&(W.timeout=b);let Y=is(R,W);{let{response:k}=await Y,{code:x,data:de,message:it}=k;t.resolve({code:x??"SUCCESS",data:de,message:it??"request:ok"}),F({code:"SUCCESS",message:"request:ok",data:de})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Vt-=1,$t.shift()?.()}};return Vt>=ss?(r=()=>{as($t,i=>i===s)},$t.push(s)):s(),t.promise}})(e),{abort(){t.reject(oe({code:-1,msg:"request:fail abort"})),r()}}},ls=I();ls.registerCommand("HttpSDK.request",cs);y("request",{version:"1.0.0"})});function hs(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return fs.includes(t)?t:""}function gs(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 vs(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,ds,us,ms,ps,El,wl,fs,xn=p(()=>{"use strict";z();M();g();xe();j();nt=I(),ds=S("getLocalStorage",{paramsSchema:l.tuple(l.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:o}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:o?.value};try{let{data:{data:s,dataType:i}}=await D("getLocalStorageAsync",{key:e}),a=gs(s,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",ds);y("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});us=S("setStorage",{paramsSchema:l.tuple(l.string(),l.or(l.string(),l.boolean(),l.number())),async implement(e,t){let r=v.mpId,n=typeof t=="string"?t:String(t),{response:o}=await q(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=hs(t),c=vs(t,a);return await D("setLocalStorageAsync",{key:e,data:c,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}}});nt.registerCommand("StorageSDK.setItem",us);y("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});ms=S("removeStorage",{paramsSchema:l.tuple(l.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:o}}=r;return await D("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}}});nt.registerCommand("StorageSDK.removeItem",ms);y("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});ps=S("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",ps);y("storage.clear",{version:"1.0.0"});El=S("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"}});wl=A("getStorageInfoSync",{implement(){return E("getStorageInfoSync")}}),fs=["string","number","boolean","object",""]});var ys,bs,Ts,Kt,Pn=p(()=>{"use strict";g();M();z();ys=A("showKeyboard",{paramsSchema:l.tuple(l.object({defaultValue:l.string().optional().default(""),multiple:l.boolean().optional().default(!1),maxLength:l.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"}});bs=A("updateKeyboard",{paramsSchema:l.tuple(l.object({value:l.string()})),implement(e){E("updateKeyboardSync",e)}});y("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Ts=A("hideKeyboard",{implement(){E("hideKeyboardSync")}});y("keyboard.hideKeyboard",{version:"1.0.0"});Kt=I();Kt.registerCommand("KeyboardSDK.showKeyboard",ys);Kt.registerCommand("KeyboardSDK.updateKeyboard",bs);Kt.registerCommand("KeyboardSDK.hideKeyboard",Ts)});var le,ks,Es,ws,Ss,Is,As,Cn=p(()=>{"use strict";g();z();ee();le=I(),ks=S("levelFinished",{paramsSchema:l.tuple(l.string(),l.object({result:l.boolean(),duration:l.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,o=[];o.push(O.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(O.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(o)}}),Es=S("taskFinished",{paramsSchema:l.tuple(l.string(),l.object({duration:l.number()})),implement:async(e,t)=>{let{duration:r}=t;return await O.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),ws=S("levelUpgrade",{paramsSchema:l.tuple(l.string(),l.string()),implement:async(e,t)=>{let r=[];r.push(O.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),Ss=S("onHistoryUserLevel",{paramsSchema:l.tuple(l.number()),implement:async e=>await O.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Is=S("onHistoryUserScore",{paramsSchema:l.tuple(l.number()),implement:async e=>await O.reportToNative({event:"HistoryUserScore",params:{score:e}})}),As=S("taskEvent",{paramsSchema:l.tuple(l.string(),l.object({tools:l.array(l.object({id:l.string(),name:l.string(),count:l.number(),description:l.string().optional(),price:l.object({amount:l.number(),unit:l.string()}).optional()})).optional(),awards:l.array(l.object({id:l.string(),name:l.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)}});le.registerCommand("TaskTrackerSDK.levelFinished",ks);le.registerCommand("TaskTrackerSDK.taskFinished",Es);le.registerCommand("TaskTrackerSDK.levelUpgrade",ws);le.registerCommand("TaskTrackerSDK.historyUserLevel",Ss);le.registerCommand("TaskTrackerSDK.historyUserScore",Is);le.registerCommand("TaskTrackerSDK.taskEvent",As);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 Rs,_s,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"}});Rs=S("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:c})=>{c==r&&o({isLogin:i,token:a})});let t=E("loginSync"),{data:{uuid:r}}=t;if(!r)throw oe({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new Q,s=await n;return v.onEnvConfigChanged({hostUserInfo:s}),K.emit("onLoginComplete",s),s}}),_s=S("checkSession",{async implement(){let{data:{isLogin:e}}=await D("checkLoginAsync");return{isLogin:e}}}),Nn=I();Nn.registerCommand("API.login",Rs);Nn.registerCommand("API.checkSession",_s)});var ot,xs,st,Ps,Cs,Ns,Os,Fn=p(()=>{"use strict";g();z();Ut();ee();xe();M();ot=I(),xs=()=>{let{data:e}=E("getNetworkStatusSync");return!!e?.isConnected},st=new Fe(U,{get:(e,t)=>q(e,{method:"GET",responseType:"json",appendHostCookie:!0,...t}).then(r=>r.response.data)},xs),Ps=A("adInit",{implement:e=>{st.init(e)}}),Cs=A("adConfig",{implement:e=>{st.adConfig(e)}}),Ns=A("adBreak",{implement:e=>{st.adBreak(e)}}),Os=A("adUnit",{implement:e=>{st.adUnit(e)}});ot.registerCommand("AdsSDK.init",Ps);ot.registerCommand("AdsSDK.adConfig",Cs);ot.registerCommand("AdsSDK.adBreak",Ns);ot.registerCommand("AdsSDK.adUnit",Os);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 Fs={};var Ql,Dn=p(()=>{"use strict";bn();Ql=Wn(kn());_n();xn();Pn();Cn();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(),Fs)),Promise.resolve().then(()=>(ee(),rn))]);e()})();
|
package/implement.build.log
CHANGED
|
@@ -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
|
+
> @jolibox/implement@1.1.7-beta.4 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.7-beta.
|
|
7
|
+
> @jolibox/implement@1.1.7-beta.4 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.
|
|
4
|
+
"version": "1.1.7-beta.4",
|
|
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.
|
|
10
|
-
"@jolibox/types": "1.1.7-beta.
|
|
9
|
+
"@jolibox/common": "1.1.7-beta.4",
|
|
10
|
+
"@jolibox/types": "1.1.7-beta.4",
|
|
11
11
|
"localforage": "1.10.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
package/src/common/ads/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AdsAntiCheating } from './anti-cheating';
|
|
|
3
3
|
import { Track } from '../report';
|
|
4
4
|
import { context } from '../context';
|
|
5
5
|
import { ChannelPolicy } from './channel-policy';
|
|
6
|
+
import { EventEmitter } from '@jolibox/common';
|
|
6
7
|
|
|
7
8
|
declare global {
|
|
8
9
|
interface Window {
|
|
@@ -257,6 +258,9 @@ interface HttpClient {
|
|
|
257
258
|
get<T>(url: string, options?: { query?: Record<string, string> }): Promise<T>;
|
|
258
259
|
}
|
|
259
260
|
|
|
261
|
+
export const adEventEmitter = new EventEmitter<{
|
|
262
|
+
isAdShowing: [boolean];
|
|
263
|
+
}>();
|
|
260
264
|
/**
|
|
261
265
|
* Jolibox Ads SDK
|
|
262
266
|
*/
|
|
@@ -370,6 +374,47 @@ export class JoliboxAdsImpl {
|
|
|
370
374
|
window.adsbygoogle.push(params);
|
|
371
375
|
};
|
|
372
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
|
+
|
|
373
418
|
/**
|
|
374
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).
|
|
375
420
|
* @param params
|
|
@@ -515,9 +560,12 @@ export class JoliboxAdsImpl {
|
|
|
515
560
|
paramsToTrack = { type, name: params.name ?? '' };
|
|
516
561
|
break;
|
|
517
562
|
}
|
|
563
|
+
|
|
518
564
|
this.adsActionDetection.adBreakIsShowing = true;
|
|
519
565
|
this.track('CallAdBreak', paramsToTrack);
|
|
520
|
-
|
|
566
|
+
|
|
567
|
+
const wrappedParams = this.wrapAdBreakParams(params);
|
|
568
|
+
this.push(wrappedParams);
|
|
521
569
|
|
|
522
570
|
// https://rsgce94md216.sg.larksuite.com/wiki/JGrAwRk7BiRJyekzJmKlbOawg7e?from=from_copylink
|
|
523
571
|
if (window.JoliTesterBridge) {
|
|
@@ -85,6 +85,9 @@ const wrapContext = () => {
|
|
|
85
85
|
get channel(): string | undefined {
|
|
86
86
|
return channel;
|
|
87
87
|
},
|
|
88
|
+
get webviewId(): number {
|
|
89
|
+
return env.webviewId ?? -1;
|
|
90
|
+
},
|
|
88
91
|
onEnvConfigChanged: (newConfig: Partial<Env>) => {
|
|
89
92
|
mergeWith(env, newConfig, mergeArray);
|
|
90
93
|
}
|
package/src/index.native.ts
CHANGED
|
@@ -20,9 +20,11 @@ if (window[JOLIBOX_IMPLEMENT_INIT]) {
|
|
|
20
20
|
window[JOLIBOX_IMPLEMENT_INIT] = true;
|
|
21
21
|
|
|
22
22
|
(async () => {
|
|
23
|
-
await Promise.all([
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const [{ config }] = await Promise.all([
|
|
24
|
+
import('./native/bootstrap'),
|
|
25
|
+
import('./native/api'),
|
|
26
|
+
import('./native/report')
|
|
27
|
+
]);
|
|
26
28
|
|
|
27
29
|
config();
|
|
28
30
|
})();
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
//TODO(DX): H5 entrance
|
|
2
2
|
// internal modules
|
|
3
3
|
//TODO: entrance for native
|
|
4
|
-
const SDK_INITIALIZED = Symbol('__JOLIBOX_SDK_INITIALIZED__');
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
[SDK_INITIALIZED]?: boolean; // 添加初始化标记
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// check if already initialized
|
|
12
|
-
(() => {
|
|
13
|
-
if (window[SDK_INITIALIZED]) {
|
|
14
|
-
console.warn('JoliboxSDK already initialized, skipping...');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
})();
|
|
18
|
-
|
|
19
4
|
import './h5/report';
|
|
20
5
|
//global apis
|
|
21
6
|
import './h5/api';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { onNative, RuntimeLoader } from './bridge';
|
|
1
|
+
import { invokeNative, onNative, RuntimeLoader } from './bridge';
|
|
2
2
|
import { joliboxJSCore } from '../js-core';
|
|
3
3
|
import { context } from '@/common/context';
|
|
4
|
-
import { hostEmitter } from '@jolibox/common';
|
|
4
|
+
import { hostEmitter, isBoolean } from '@jolibox/common';
|
|
5
5
|
import { taskTracker, track } from '../report';
|
|
6
6
|
import { initializeNativeEnv } from './init-env';
|
|
7
|
+
import { adEventEmitter } from '@/common/ads';
|
|
7
8
|
|
|
8
9
|
let cleanStyles: () => void;
|
|
9
10
|
RuntimeLoader.onReady(() => {
|
|
@@ -17,7 +18,22 @@ RuntimeLoader.doExit(() => {
|
|
|
17
18
|
});
|
|
18
19
|
cleanStyles?.();
|
|
19
20
|
taskTracker.close(Date.now() - start_timestamp);
|
|
20
|
-
|
|
21
|
+
if (isAdShowing) {
|
|
22
|
+
return true; // Forbid exit on watching ads
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
let isAdShowing = false;
|
|
28
|
+
adEventEmitter.on('isAdShowing', (isShowing) => {
|
|
29
|
+
console.log('isAdShowing', isShowing);
|
|
30
|
+
isAdShowing = isShowing;
|
|
31
|
+
if (isBoolean(isAdShowing)) {
|
|
32
|
+
invokeNative('updateContainerConfigSync', {
|
|
33
|
+
displayCapsuleButton: !isAdShowing,
|
|
34
|
+
webviewId: context.webviewId
|
|
35
|
+
});
|
|
36
|
+
}
|
|
21
37
|
});
|
|
22
38
|
|
|
23
39
|
/**
|
|
@@ -248,6 +248,13 @@ declare global {
|
|
|
248
248
|
networkType: 'wifi' | '4g' | '5g' | '3g' | '2g' | 'unknown';
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
|
+
|
|
252
|
+
updateContainerConfigSync: (params: { displayCapsuleButton: boolean; webviewId?: number }) => {
|
|
253
|
+
/** 错误消息 */
|
|
254
|
+
errMsg: string;
|
|
255
|
+
/** 错误码 */
|
|
256
|
+
errNo?: number;
|
|
257
|
+
};
|
|
251
258
|
}
|
|
252
259
|
|
|
253
260
|
interface NativeEventMap {
|