@jolibox/implement 1.1.4-beta.15 → 1.1.4-beta.16

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.
@@ -4,7 +4,7 @@
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": "2cbb46b82f30950b931917c13a1ea9e3a70bfebd",
7
+ "packages/implement/package.json": "555c85916345e750cfe8ad77358026c24e7d40bf",
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": "0ad2a6d868edbe7ad2f0788c2439b149bd40919a",
@@ -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": "9e564f73e29c50accd6a5b05fcecdfdde847473e",
33
+ "packages/implement/src/common/context/index.ts": "0ebeab79ecdfc183e22226bae266ed3a3452a0e5",
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",
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var io=Object.create;var Ir=Object.defineProperty;var so=Object.getOwnPropertyDescriptor;var ao=Object.getOwnPropertyNames;var co=Object.getPrototypeOf,lo=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 uo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of ao(t))!lo.call(e,l)&&l!==n&&Ir(e,l,{get:()=>t[l],enumerable:!(i=so(t,l))||i.enumerable});return e};var mo=(e,t,n)=>(n=e!=null?io(co(e)):{},fo(t||!e||!e.__esModule?Ir(n,"default",{value:e,enumerable:!0}):n,e));var en=uo((Zr,er)=>{(function(e){if(typeof Zr=="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 b(I,x){if(!d[I]){if(!l[I]){var m=typeof Ie=="function"&&Ie;if(!x&&m)return m(I,!0);if(E)return E(I,!0);var _=new Error("Cannot find module '"+I+"'");throw _.code="MODULE_NOT_FOUND",_}var C=d[I]={exports:{}};l[I][0].call(C.exports,function(N){var K=l[I][1][N];return b(K||N)},C,C.exports,i,l,d,h)}return d[I].exports}for(var E=typeof Ie=="function"&&Ie,A=0;A<h.length;A++)b(h[A]);return b}({1:[function(i,l,d){(function(h){"use strict";var b=h.MutationObserver||h.WebKitMutationObserver,E;if(b){var A=0,I=new b(N),x=h.document.createTextNode("");I.observe(x,{characterData:!0}),E=function(){x.data=A=++A%2}}else if(!h.setImmediate&&typeof h.MessageChannel<"u"){var m=new h.MessageChannel;m.port1.onmessage=N,E=function(){m.port2.postMessage(0)}}else"document"in h&&"onreadystatechange"in h.document.createElement("script")?E=function(){var V=h.document.createElement("script");V.onreadystatechange=function(){N(),V.onreadystatechange=null,V.parentNode.removeChild(V),V=null},h.document.documentElement.appendChild(V)}:E=function(){setTimeout(N,0)};var _,C=[];function N(){_=!0;for(var V,re,J=C.length;J;){for(re=C,C=[],V=-1;++V<J;)re[V]();J=C.length}_=!1}l.exports=K;function K(V){C.push(V)===1&&!_&&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 b(){}var E={},A=["REJECTED"],I=["FULFILLED"],x=["PENDING"];l.exports=m;function m(T){if(typeof T!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,T!==b&&K(this,T)}m.prototype.catch=function(T){return this.then(null,T)},m.prototype.then=function(T,D){if(typeof T!="function"&&this.state===I||typeof D!="function"&&this.state===A)return this;var P=new this.constructor(b);if(this.state!==x){var U=this.state===I?T:D;C(P,U,this.outcome)}else this.queue.push(new _(P,T,D));return P};function _(T,D,P){this.promise=T,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof P=="function"&&(this.onRejected=P,this.callRejected=this.otherCallRejected)}_.prototype.callFulfilled=function(T){E.resolve(this.promise,T)},_.prototype.otherCallFulfilled=function(T){C(this.promise,this.onFulfilled,T)},_.prototype.callRejected=function(T){E.reject(this.promise,T)},_.prototype.otherCallRejected=function(T){C(this.promise,this.onRejected,T)};function C(T,D,P){h(function(){var U;try{U=D(P)}catch(G){return E.reject(T,G)}U===T?E.reject(T,new TypeError("Cannot resolve promise with itself")):E.resolve(T,U)})}E.resolve=function(T,D){var P=V(N,D);if(P.status==="error")return E.reject(T,P.value);var U=P.value;if(U)K(T,U);else{T.state=I,T.outcome=D;for(var G=-1,W=T.queue.length;++G<W;)T.queue[G].callFulfilled(D)}return T},E.reject=function(T,D){T.state=A,T.outcome=D;for(var P=-1,U=T.queue.length;++P<U;)T.queue[P].callRejected(D);return T};function N(T){var D=T&&T.then;if(T&&(typeof T=="object"||typeof T=="function")&&typeof D=="function")return function(){D.apply(T,arguments)}}function K(T,D){var P=!1;function U(Y){P||(P=!0,E.reject(T,Y))}function G(Y){P||(P=!0,E.resolve(T,Y))}function W(){D(G,U)}var z=V(W);z.status==="error"&&U(z.value)}function V(T,D){var P={};try{P.value=T(D),P.status="success"}catch(U){P.status="error",P.value=U}return P}m.resolve=re;function re(T){return T instanceof this?T:E.resolve(new this(b),T)}m.reject=J;function J(T){var D=new this(b);return E.reject(D,T)}m.all=vt;function vt(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=T.length,U=!1;if(!P)return this.resolve([]);for(var G=new Array(P),W=0,z=-1,Y=new this(b);++z<P;)ne(T[z],z);return Y;function ne(_e,Ce){D.resolve(_e).then(yt,function(fe){U||(U=!0,E.reject(Y,fe))});function yt(fe){G[Ce]=fe,++W===P&&!U&&(U=!0,E.resolve(Y,G))}}}m.race=le;function le(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=T.length,U=!1;if(!P)return this.resolve([]);for(var G=-1,W=new this(b);++G<P;)z(T[G]);return W;function z(Y){D.resolve(Y).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 b(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function E(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var A=E();function I(){try{if(!A||!A.open)return!1;var r=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!r||s)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function x(r,s){r=r||[],s=s||{};try{return new Blob(r,s)}catch(a){if(a.name!=="TypeError")throw a;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,c=new o,u=0;u<r.length;u+=1)c.append(r[u]);return c.getBlob(s.type)}}typeof Promise>"u"&&i(3);var m=Promise;function _(r,s){s&&r.then(function(o){s(null,o)},function(o){s(o)})}function C(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={},vt=Object.prototype.toString,le="readonly",T="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),c=new Uint8Array(o),u=0;u<s;u++)c[u]=r.charCodeAt(u);return o}function P(r){return new m(function(s){var o=r.transaction(V,T),c=x([""]);o.objectStore(V).put(c,"key"),o.onabort=function(u){u.preventDefault(),u.stopPropagation(),s(!1)},o.oncomplete=function(){var u=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);s(a||!u||parseInt(u[1],10)>=43)}}).catch(function(){return!1})}function U(r){return typeof re=="boolean"?m.resolve(re):P(r).then(function(s){return re=s,re})}function G(r){var s=J[r.name],o={};o.promise=new m(function(c,u){o.resolve=c,o.reject=u}),s.deferredOperations.push(o),s.dbReady?s.dbReady=s.dbReady.then(function(){return o.promise}):s.dbReady=o.promise}function W(r){var s=J[r.name],o=s.deferredOperations.pop();if(o)return o.resolve(),o.promise}function z(r,s){var o=J[r.name],c=o.deferredOperations.pop();if(c)return c.reject(s),c.promise}function Y(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 Y(r,!1)}function _e(r){return Y(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 yt(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 sn(r){var s=this,o=s._initReady().then(function(){var c=J[s._dbInfo.name];if(c&&c.dbReady)return c.dbReady});return C(o,r,r),o}function an(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 z(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 an(r).then(function(){oe(r,s,o,c-1)})}).catch(o);o(a)}}function nr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function cn(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=sn);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 k=v[w];k!==s&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function ln(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 _(c,s),c}function un(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 k=w.value;rr(k)&&(k=fe(k));var O=r(k,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 _(c,s),c}function dn(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,vt.call(s)==="[object Blob]"?U(p.db).then(function(g){return g?s:yt(s)}):s}).then(function(g){oe(c._dbInfo,T,function(v,y){if(v)return f(v);try{var w=y.objectStore(c._dbInfo.storeName);g===null&&(g=void 0);var k=w.put(g,r);y.oncomplete=function(){g===void 0&&(g=null),a(g)},y.onabort=y.onerror=function(){var O=k.error?k.error:k.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return _(u,o),u}function fn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,T,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.delete(r);p.oncomplete=function(){u()},p.onerror=function(){a(v.error)},p.onabort=function(){var y=v.error?v.error:v.transaction.error;a(y)}}catch(y){a(y)}})}).catch(a)});return _(c,s),c}function mn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,T,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.clear();f.oncomplete=function(){c()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;u(v)}}catch(v){u(v)}})}).catch(u)});return _(o,r),o}function hn(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 _(o,r),o}function pn(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 _(c,s),c}function gn(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 _(o,r),o}function vn(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 k=y[w];k._dbInfo.db=null,k._dbInfo.version=g}var O=new m(function(F,$){var B=A.open(r.name,g);B.onerror=function(q){var Te=B.result;Te.close(),$(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 $=0;$<y.length;$++){var B=y[$];B._dbInfo.db=F,W(B._dbInfo)}}).catch(function(F){throw(z(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 k=new m(function(O,F){var $=A.deleteDatabase(r.name);$.onerror=function(){var B=$.result;B&&B.close(),F($.error)},$.onblocked=function(){console.warn('dropInstance blocked for database "'+r.name+'" until all open connections are closed')},$.onsuccess=function(){var B=$.result;B&&B.close(),O(B)}});return k.then(function(O){g.db=O;for(var F=0;F<v.length;F++){var $=v[F];W($._dbInfo)}}).catch(function(O){throw(z(r,O)||m.resolve()).catch(function(){}),O})})}return _(u,s),u}var yn={_driver:"asyncStorage",_initStorage:cn,_support:I(),iterate:un,getItem:ln,setItem:dn,removeItem:fn,clear:mn,length:hn,key:pn,keys:gn,dropInstance:vn};function bn(){return typeof openDatabase=="function"}var se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_n="~~local_forage_type~",or=/^~~local_forage_type~([^~]+)~/,Pe="__lfsc__:",bt=Pe.length,_t="arbf",Et="blob",ir="si08",sr="ui08",ar="uic8",cr="si16",lr="si32",ur="ur16",dr="ui32",fr="fl32",mr="fl64",hr=bt+_t.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 En(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+=_t):(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=_n+r.type+"~"+Tt(this.result);s(Pe+Et+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,bt)!==Pe)return JSON.parse(r);var s=r.substring(hr),o=r.substring(bt,hr),c;if(o===Et&&or.test(s)){var u=s.match(or);c=u[1],s=s.substring(u[0].length)}var a=gr(s);switch(o){case _t:return a;case Et: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 It={serialize:En,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 In(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=It,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 wn(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 _(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,k=0;k<w;k++){var O=y.item(k),F=O.value;if(F&&(F=f.serializer.deserialize(F)),F=r(F,O.key,k+1),F!==void 0){u(F);return}}u()},function(g,v){a(v)})})}).catch(a)});return _(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(k){ae(k,v,"INSERT OR REPLACE INTO "+v.storeName+" (key, value) VALUES (?, ?)",[r,y],function(){f(g)},function(O,F){p(F)})},function(k){if(k.code===k.QUOTA_ERR){if(c>0){f(yr.apply(u,[r,g,o,c-1]));return}p(k)}})})}).catch(p)});return _(a,o),a}function Sn(r,s,o){return yr.apply(this,[r,s,o,1])}function Rn(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 _(c,s),c}function xn(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 _(o,r),o}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,"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 _(o,r),o}function Cn(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 _(c,s),c}function Pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ae(f,a,"SELECT 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 _(o,r),o}function Dn(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 On(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(Dn(f))}).then(function(a){return new m(function(f,p){a.db.transaction(function(g){function v(O){return new m(function(F,$){g.executeSql("DROP TABLE IF EXISTS "+O,[],function(){F()},function(B,q){$(q)})})}for(var y=[],w=0,k=a.storeNames.length;w<k;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 Fn={_driver:"webSQLStorage",_initStorage:In,_support:bn(),iterate:An,getItem:wn,setItem:Sn,removeItem:Rn,clear:xn,length:kn,key:Cn,keys:Pn,dropInstance:On};function Nn(){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 Un(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Ln(){return!Un()||localStorage.length>0}function Bn(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=br(r,s._defaultConfig),Ln()?(s._dbInfo=o,o.serializer=It,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 _(o,r),o}function Mn(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 _(c,s),c}function Vn(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 _(c,s),c}function jn(r,s){var o=this,c=o.ready().then(function(){var u=o._dbInfo,a;try{a=localStorage.key(r)}catch{a=null}return a&&(a=a.substring(u.keyPrefix.length)),a});return _(c,s),c}function Kn(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 _(o,r),o}function Jn(r){var s=this,o=s.keys().then(function(c){return c.length});return _(o,r),o}function Gn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+r)});return _(c,s),c}function Hn(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 _(u,o),u}function Wn(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"),_(u,s),u}var zn={_driver:"localStorageWrapper",_initStorage:Bn,_support:Nn(),iterate:Vn,getItem:Mn,setItem:Hn,removeItem:Gn,clear:$n,length:Jn,key:jn,keys:Kn,dropInstance:Wn},Yn=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(Yn(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:yn,WEBSQL:Fn,LOCALSTORAGE:zn},Qn=[me.INDEXEDDB._driver,me.WEBSQL._driver,me.LOCALSTORAGE._driver],De=["dropInstance"],wt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(De),Xn={description:"",driver:Qn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Zn(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 eo=function(){function r(s){b(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({},Xn),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=wt.concat("_initStorage"),w=0,k=y.length;w<k;w++){var O=y[w],F=!qn(De,O);if((F||o[O])&&typeof o[O]!="function"){p(v);return}}var $=function(){for(var Te=function(no){return function(){var oo=new Error("Method "+no+" is not implemented by the current driver"),Tr=m.reject(oo);return _(Tr,arguments[arguments.length-1]),Tr}},St=0,ro=De.length;St<ro;St++){var Rt=De[St];o[Rt]||(o[Rt]=Te(Rt))}};$();var B=function(Te){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Er[g]=Te,f()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(B,p):B(!!o._support):B(!0)}catch(q){p(q)}});return C(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 C(a,c,u),a},r.prototype.getSerializer=function(o){var c=m.resolve(It);return C(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 C(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 k=0;function O(){for(;k<w.length;){var F=w[k];return k++,a._dbInfo=null,a._ready=null,a.getDriver(F).then(g).catch(O)}p();var $=new Error("No available storage method found.");return a._driverSet=m.reject($),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(k){a._driver=k._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}),C(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=wt.length;o<c;o++)Zn(this,wt[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),to=new eo;l.exports=to},{3:3}]},{},[4])(4)})});var Sr=Object.defineProperty,ho=Object.getOwnPropertyDescriptor,po=(e,t)=>{for(var n in t)Sr(e,n,{get:t[n],enumerable:!0})},Rr=(e,t,n,i)=>{for(var l=i>1?void 0:i?ho(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&&Sr(t,n,l),l};function go(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Dt(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 vo(e){return typeof e>"u"}function yo(e){return vo(e)||e===null}function bo(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 b=l[h],E=d[h],A=n(b,E,h,l,d);A!==void 0?l[h]=A:wr(E)&&wr(b)?l[h]=i({...b},E):Array.isArray(E)&&Array.isArray(b)?l[h]=[...b,...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 Se(e,t,n={}){let i=null,l,d,h,{leading:b=!1,trailing:E=!0}=n,A=()=>(h=e.apply(d,l),l=void 0,d=void 0,h),I=function(...x){l=x,d=this;let m=b&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,E&&!m&&A()},t),m)return A()};return I.cancel=()=>{i&&clearTimeout(i),i=null,l=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,A()},I}var _o=(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))(_o||{}),Ot=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}},Ft=class extends Ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Eo=class extends Ot{constructor(){super(...arguments),this.kind="USER_ERROR"}};var Nt=class extends Eo{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 Or=class extends Ft{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Fr=class extends Ft{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},Be=class extends Ot{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 Ft{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function To(e,t){return(...n)=>t(e,...n)}function Nr(e){return t=>To(t,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(l){e(new Nt(`${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 Ur=Symbol.for("Jolibox.canIUseMap"),Io={};globalThis[Ur]=Io;var Lt={get config(){return globalThis[Ur]}};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||{}),wo=(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))(wo||{}),Ar=["name","params"],Ao=["name","type","location","target","extra","timestamp","userId"],So=["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 Ro(e){let t=e.location?Ne(e.location,Ar):null,n=e.target?Ne(e.target,Ar):null;return Ne({...e,location:t,target:n},Ao)}function Bt(e){let t=e.events.map(i=>Ro(i)),n=Ne(e.device,So);return[e.protocolVersion,t,n,e.project]}var xo=()=>"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")},ko=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",Co="device_id",Po="advertising_id",Lr=e=>(localStorage.getItem(e)||localStorage.setItem(e,xo()),localStorage.getItem(e)),$t=()=>Lr(Co),Do=()=>Lr(Po),Oo=e=>e.charAt(0).toUpperCase()+e.slice(1),Fo=()=>{let e=new URLSearchParams(window.location.search);return Oo(e.get("utm_source")??"")||"JoliboxSDK"},Br=e=>{let t="JoliboxWebSDK",n=ko(),i=navigator.language,l=$t(),d=Do();return`${t} (${Fo()}${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}},No=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}},Uo=0,Fe=class{constructor(e){this.value=e,this.id=Uo++}},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}},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 Ae,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 No,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},Ct={};po(Ct,{None:()=>Lo,filter:()=>$o,once:()=>$r,toPromise:()=>Bo});var Lo=()=>{console.log("[Jolibox SDK] None Event")};function Bo(e){return new Promise(t=>$r(e)(t))}function $r(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 Ae(l);return d.event})((n,i=null)=>e(l=>t(l)&&n.call(i,l),null))}var xt=Symbol.for("Jolibox.hostEmitter"),Mo=()=>{let e=new pe;return globalThis[xt]||(globalThis[xt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[xt]},xe=Mo();function Vo(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(Dt(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(bo(t)){try{if(e instanceof t)return}catch{}if(!yo(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 l of e.metadata.args)n.push(l.constraint);let i=e.handler;e.handler=function(...l){return Vo(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 Pt=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=go(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,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}}};Pt=Rr([Cr],Pt);var kt=Symbol.for("Jolibox.commands");function Q(){if(globalThis[kt])return globalThis[kt];let e=new Le,t=new Pt,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[kt]=n,n}var Mt=new pe,ue=new pe;function ee(e,t={}){Mt.emit("ERROR_REPORT",{error:e,options:t})}ee.debounce=Se(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{}}},Mr=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 Or(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}};var Ko="1.1.4-beta.15",$e=()=>Ko,Vr=()=>{let e=$e();return`${Br(e)}`};var Jo={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:$t(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:$e()},schema:window.location.href,platform:"h5"},Go=globalThis.joliboxJSCore?.env,X=Object.assign({},Go?.()??Jo),Ho=()=>{let{payloadJson:e,headerJson:t}=X.schema.length?Mr(X.schema):{},n=`${X.deviceInfo.did}-${new Date().getTime()}`,i=new URLSearchParams(X.schema.length?X.schema:window.location.search),l=i.get("mpId")??i.get("appId")??i.get("gameId")??"",d=e?.sessionId??i.get("sessionId")??n,h=!!(e?.testAdsMode??i.get("testAdsMode")==="true"),b=e?.joliboxEnv??i.get("joliboxEnv")??"production",E=b==="staging",A=t?.channel;return{get testMode(){return E},get testAdsMode(){return h},get joliboxEnv(){return b},get mpId(){return l??e?.id??""},get mpVersion(){return t?.ver??$e()},get platform(){return X.platform},get deviceInfo(){return X.deviceInfo},get sdkInfo(){return X.sdkInfo},get hostInfo(){return X.hostInfo},get hostUserInfo(){return X.hostUserInfo},get sessionId(){return X.clientSessionId??d??n},get channel(){return A},onEnvConfigChanged:I=>{Pr(X,I,Dr)}}},R=Ho();var jt=!1,Kr=(e,t)=>e==null?!1:t in e,Wo=e=>Kr(e,"kind"),zo=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 i=e.priority??"P1",d={...{user_id:R.hostUserInfo?.uid??"",device_id:R.deviceInfo.did??"",timestamp:Date.now(),tag:zo(e.name)},env:t.environment,isFromUser:n};n?ue.emit("GLOBAL_USER_ERROR",e,d):ue.emit("GLOBAL_ERROR",e,d)},Yo=e=>Kr(e,"kind")&&e.kind==="USER_ERROR";Mt.on("ERROR_REPORT",({error:e,options:t})=>{if(jt)return;jt=!0;let n=Wo(e)&&e.raw?e.raw:e;try{let i=Yo(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 Nt(e);function Jr(e,t){let n=(i,l,d)=>{let h={tag:i,...t,extra:{...l}};i=="globalJsError"?ee(new Fr(JSON.stringify(h),"P0")):e("systemLog",h,d)};return n.debounce=Se(n,500,{leading:!0}),n}function Gr(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=Se(t,500,{leading:!0}),t}function Hr(e,t){let n=Jr(e,t),i=Gr(n);return{track:n,trackPerformance:i}}var Me=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.pushPastTracking=t=>{this.pastTrackings.push(t),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)}}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}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){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 b=this.deviceInfo,A={protocolVersion:"1.0.0",events:[{...t,location:l,target:d,extra:h,timestamp:Date.now(),userId:null}],device:b,project:n};try{i?this.doReport(Bt(A),i):this.doReport(Bt(A)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),H.log("[Jolibox SDK] report API error",I)}}};var Jt=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};AbortSignal.timeout??=Jt;var Ve=class{constructor(t){this.xua=Vr();this.getJoliSource=()=>new URLSearchParams(window.location.search).get("joliSource")??null;let n=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=t?.baseUrl??n}async get(t,{query:n,headers:i,timeout:l}){let h=new URLSearchParams(n).toString(),b=`${this.baseUrl}${t}${h?`?${h}`:""}`,E=this.xua,A=this.getJoliSource();return i=Object.assign({},i,E?{"x-user-agent":E}:{},A?{"x-joli-source":A}:{}),await(await fetch(b,{method:"GET",headers:i,credentials:"include",signal:Jt(l??3e4)})).json()}async post(t,{data:n,query:i,headers:l,timeout:d}){let b=new URLSearchParams(i).toString(),E=`${this.baseUrl}${t}${b?`?${b}`:""}`,A=this.xua,I=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},A?{"x-user-agent":A}:{},I?{"x-joli-source":I}:{});let x=await fetch(E,{method:"POST",headers:l,body:JSON.stringify(n),signal:Jt(d??3e4),credentials:"include"}),m=x.headers.get("content-type");if(m?.includes("application/octet-stream"))try{return x.blob()}catch{return await x.arrayBuffer()}if(m?.includes("multipart/form-data")||m?.includes("application/x-www-form-urlencoded"))try{return x.formData()}catch{return await x.text()}if(m?.includes("application/json"))try{return await x.json()}catch{return await x.text()}return x}async put(t,{data:n,query:i,headers:l}){try{let h=new URLSearchParams(i).toString(),b=`${this.baseUrl}${t}${h?`?${h}`:""}`,E=this.xua,A=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},E?{"x-user-agent":E}:{},A?{"x-joli-source":A}:{});let I=await fetch(b,{method:"PUT",headers:l,credentials:"include",body:JSON.stringify(n??{})});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);return await I.json()}catch(d){throw console.error("Error:",d),d}}};window.JoliboxHttpClient=Ve;var ce=Ve;var Gt=class extends Me{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,b=()=>{if(!d)return;let _=Date.now(),C=_-n;C>=this.interval&&(this.visible&&(h+=C,t(h)),n=_),i=requestAnimationFrame(b)},E=()=>{I(),n=Date.now(),l=window.setInterval(()=>{if(!d)return;let _=Date.now();_-n>=this.interval&&(n=_)},this.interval)},A=()=>{x(),n=Date.now(),i=requestAnimationFrame(b)},I=()=>{i&&(cancelAnimationFrame(i),i=0)},x=()=>{l&&(clearInterval(l),l=0)};this.eventEmitter.on("visible",_=>{d&&(console.log("visible",_),_?A():E())});let m=this.visible;return{start(){d||(d=!0,m?A():E())},stop(){d=!1,I(),x()}}}};var Ke=class extends je{constructor(n,i,l){super(i,l);this.httpClient=new 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 Wr=Q(),Qo={type:he.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:ve,trackPerformance:Xo}=Hr((...e)=>{let[,t]=e,n=t,l={...xr(n.extra)?n.extra:Dt(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)},Qo);Wr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{Xo(e,t)});Wr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{ve(e,t)});var Ht=new pe,te=new Ke(ve,Ht);function zr(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 Yr=!1;function Wt(e){Yr=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 M=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Yr)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 M{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 M{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},We=class extends M{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 M{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ye=class extends M{validate(t){return!0}},Ye=class extends M{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},qe=class extends M{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Qe=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Xe=class extends M{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 M{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 M{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 b in l){let E=l[b];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(b)?d.path=`${this.path}.${b}`:d.path=`${this.path}["${b}"]`,!(E===void 0&&d._optional)){if(E===void 0&&d.hasDefault){l[b]=d.defaultValue;continue}d.validate(E)||(d.hasFallback?l[b]=d.fallbackValue:h=!1)}}return h}},tt=class extends M{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],b=this._object[d];if(b.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?b.path=`${this.path}.${d}`:b.path=`${this.path}["${d}"]`,!(b._optional&&h===void 0)){if(h===void 0&&b.hasDefault){i[d]=b.defaultValue;continue}b.validate(h)||(b.hasFallback?i[d]=b.fallbackValue:l=!1)}}return l}},rt=class extends M{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 M{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(`
1
+ var io=Object.create;var Ir=Object.defineProperty;var so=Object.getOwnPropertyDescriptor;var ao=Object.getOwnPropertyNames;var co=Object.getPrototypeOf,lo=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 uo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of ao(t))!lo.call(e,l)&&l!==n&&Ir(e,l,{get:()=>t[l],enumerable:!(i=so(t,l))||i.enumerable});return e};var mo=(e,t,n)=>(n=e!=null?io(co(e)):{},fo(t||!e||!e.__esModule?Ir(n,"default",{value:e,enumerable:!0}):n,e));var en=uo((Zr,er)=>{(function(e){if(typeof Zr=="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 b(I,x){if(!d[I]){if(!l[I]){var m=typeof Ie=="function"&&Ie;if(!x&&m)return m(I,!0);if(_)return _(I,!0);var E=new Error("Cannot find module '"+I+"'");throw E.code="MODULE_NOT_FOUND",E}var C=d[I]={exports:{}};l[I][0].call(C.exports,function(N){var K=l[I][1][N];return b(K||N)},C,C.exports,i,l,d,h)}return d[I].exports}for(var _=typeof Ie=="function"&&Ie,A=0;A<h.length;A++)b(h[A]);return b}({1:[function(i,l,d){(function(h){"use strict";var b=h.MutationObserver||h.WebKitMutationObserver,_;if(b){var A=0,I=new b(N),x=h.document.createTextNode("");I.observe(x,{characterData:!0}),_=function(){x.data=A=++A%2}}else if(!h.setImmediate&&typeof h.MessageChannel<"u"){var m=new h.MessageChannel;m.port1.onmessage=N,_=function(){m.port2.postMessage(0)}}else"document"in h&&"onreadystatechange"in h.document.createElement("script")?_=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)}:_=function(){setTimeout(N,0)};var E,C=[];function N(){E=!0;for(var V,re,J=C.length;J;){for(re=C,C=[],V=-1;++V<J;)re[V]();J=C.length}E=!1}l.exports=K;function K(V){C.push(V)===1&&!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 b(){}var _={},A=["REJECTED"],I=["FULFILLED"],x=["PENDING"];l.exports=m;function m(T){if(typeof T!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,T!==b&&K(this,T)}m.prototype.catch=function(T){return this.then(null,T)},m.prototype.then=function(T,D){if(typeof T!="function"&&this.state===I||typeof D!="function"&&this.state===A)return this;var P=new this.constructor(b);if(this.state!==x){var U=this.state===I?T:D;C(P,U,this.outcome)}else this.queue.push(new E(P,T,D));return P};function E(T,D,P){this.promise=T,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof P=="function"&&(this.onRejected=P,this.callRejected=this.otherCallRejected)}E.prototype.callFulfilled=function(T){_.resolve(this.promise,T)},E.prototype.otherCallFulfilled=function(T){C(this.promise,this.onFulfilled,T)},E.prototype.callRejected=function(T){_.reject(this.promise,T)},E.prototype.otherCallRejected=function(T){C(this.promise,this.onRejected,T)};function C(T,D,P){h(function(){var U;try{U=D(P)}catch(G){return _.reject(T,G)}U===T?_.reject(T,new TypeError("Cannot resolve promise with itself")):_.resolve(T,U)})}_.resolve=function(T,D){var P=V(N,D);if(P.status==="error")return _.reject(T,P.value);var U=P.value;if(U)K(T,U);else{T.state=I,T.outcome=D;for(var G=-1,W=T.queue.length;++G<W;)T.queue[G].callFulfilled(D)}return T},_.reject=function(T,D){T.state=A,T.outcome=D;for(var P=-1,U=T.queue.length;++P<U;)T.queue[P].callRejected(D);return T};function N(T){var D=T&&T.then;if(T&&(typeof T=="object"||typeof T=="function")&&typeof D=="function")return function(){D.apply(T,arguments)}}function K(T,D){var P=!1;function U(Y){P||(P=!0,_.reject(T,Y))}function G(Y){P||(P=!0,_.resolve(T,Y))}function W(){D(G,U)}var z=V(W);z.status==="error"&&U(z.value)}function V(T,D){var P={};try{P.value=T(D),P.status="success"}catch(U){P.status="error",P.value=U}return P}m.resolve=re;function re(T){return T instanceof this?T:_.resolve(new this(b),T)}m.reject=J;function J(T){var D=new this(b);return _.reject(D,T)}m.all=vt;function vt(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=T.length,U=!1;if(!P)return this.resolve([]);for(var G=new Array(P),W=0,z=-1,Y=new this(b);++z<P;)ne(T[z],z);return Y;function ne(_e,Ce){D.resolve(_e).then(yt,function(fe){U||(U=!0,_.reject(Y,fe))});function yt(fe){G[Ce]=fe,++W===P&&!U&&(U=!0,_.resolve(Y,G))}}}m.race=le;function le(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=T.length,U=!1;if(!P)return this.resolve([]);for(var G=-1,W=new this(b);++G<P;)z(T[G]);return W;function z(Y){D.resolve(Y).then(function(ne){U||(U=!0,_.resolve(W,ne))},function(ne){U||(U=!0,_.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 b(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function _(){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=_();function I(){try{if(!A||!A.open)return!1;var r=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!r||s)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function x(r,s){r=r||[],s=s||{};try{return new Blob(r,s)}catch(a){if(a.name!=="TypeError")throw a;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,c=new o,u=0;u<r.length;u+=1)c.append(r[u]);return c.getBlob(s.type)}}typeof Promise>"u"&&i(3);var m=Promise;function E(r,s){s&&r.then(function(o){s(null,o)},function(o){s(o)})}function C(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={},vt=Object.prototype.toString,le="readonly",T="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),c=new Uint8Array(o),u=0;u<s;u++)c[u]=r.charCodeAt(u);return o}function P(r){return new m(function(s){var o=r.transaction(V,T),c=x([""]);o.objectStore(V).put(c,"key"),o.onabort=function(u){u.preventDefault(),u.stopPropagation(),s(!1)},o.oncomplete=function(){var u=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);s(a||!u||parseInt(u[1],10)>=43)}}).catch(function(){return!1})}function U(r){return typeof re=="boolean"?m.resolve(re):P(r).then(function(s){return re=s,re})}function G(r){var s=J[r.name],o={};o.promise=new m(function(c,u){o.resolve=c,o.reject=u}),s.deferredOperations.push(o),s.dbReady?s.dbReady=s.dbReady.then(function(){return o.promise}):s.dbReady=o.promise}function W(r){var s=J[r.name],o=s.deferredOperations.pop();if(o)return o.resolve(),o.promise}function z(r,s){var o=J[r.name],c=o.deferredOperations.pop();if(c)return c.reject(s),c.promise}function Y(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 Y(r,!1)}function _e(r){return Y(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 yt(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 sn(r){var s=this,o=s._initReady().then(function(){var c=J[s._dbInfo.name];if(c&&c.dbReady)return c.dbReady});return C(o,r,r),o}function an(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 z(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 an(r).then(function(){oe(r,s,o,c-1)})}).catch(o);o(a)}}function nr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function cn(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=sn);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 k=v[w];k!==s&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function ln(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 E(c,s),c}function un(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 k=w.value;rr(k)&&(k=fe(k));var O=r(k,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 E(c,s),c}function dn(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,vt.call(s)==="[object Blob]"?U(p.db).then(function(g){return g?s:yt(s)}):s}).then(function(g){oe(c._dbInfo,T,function(v,y){if(v)return f(v);try{var w=y.objectStore(c._dbInfo.storeName);g===null&&(g=void 0);var k=w.put(g,r);y.oncomplete=function(){g===void 0&&(g=null),a(g)},y.onabort=y.onerror=function(){var O=k.error?k.error:k.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return E(u,o),u}function fn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){oe(o._dbInfo,T,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.delete(r);p.oncomplete=function(){u()},p.onerror=function(){a(v.error)},p.onabort=function(){var y=v.error?v.error:v.transaction.error;a(y)}}catch(y){a(y)}})}).catch(a)});return E(c,s),c}function mn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){oe(s._dbInfo,T,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.clear();f.oncomplete=function(){c()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;u(v)}}catch(v){u(v)}})}).catch(u)});return E(o,r),o}function hn(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 E(o,r),o}function pn(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 E(c,s),c}function gn(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 E(o,r),o}function vn(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 k=y[w];k._dbInfo.db=null,k._dbInfo.version=g}var O=new m(function(F,$){var B=A.open(r.name,g);B.onerror=function(q){var Te=B.result;Te.close(),$(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 $=0;$<y.length;$++){var B=y[$];B._dbInfo.db=F,W(B._dbInfo)}}).catch(function(F){throw(z(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 k=new m(function(O,F){var $=A.deleteDatabase(r.name);$.onerror=function(){var B=$.result;B&&B.close(),F($.error)},$.onblocked=function(){console.warn('dropInstance blocked for database "'+r.name+'" until all open connections are closed')},$.onsuccess=function(){var B=$.result;B&&B.close(),O(B)}});return k.then(function(O){g.db=O;for(var F=0;F<v.length;F++){var $=v[F];W($._dbInfo)}}).catch(function(O){throw(z(r,O)||m.resolve()).catch(function(){}),O})})}return E(u,s),u}var yn={_driver:"asyncStorage",_initStorage:cn,_support:I(),iterate:un,getItem:ln,setItem:dn,removeItem:fn,clear:mn,length:hn,key:pn,keys:gn,dropInstance:vn};function bn(){return typeof openDatabase=="function"}var se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_n="~~local_forage_type~",or=/^~~local_forage_type~([^~]+)~/,Pe="__lfsc__:",bt=Pe.length,_t="arbf",Et="blob",ir="si08",sr="ui08",ar="uic8",cr="si16",lr="si32",ur="ur16",dr="ui32",fr="fl32",mr="fl64",hr=bt+_t.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 En(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+=_t):(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=_n+r.type+"~"+Tt(this.result);s(Pe+Et+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,bt)!==Pe)return JSON.parse(r);var s=r.substring(hr),o=r.substring(bt,hr),c;if(o===Et&&or.test(s)){var u=s.match(or);c=u[1],s=s.substring(u[0].length)}var a=gr(s);switch(o){case _t:return a;case Et: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 It={serialize:En,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 In(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=It,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 wn(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 E(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,k=0;k<w;k++){var O=y.item(k),F=O.value;if(F&&(F=f.serializer.deserialize(F)),F=r(F,O.key,k+1),F!==void 0){u(F);return}}u()},function(g,v){a(v)})})}).catch(a)});return E(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(k){ae(k,v,"INSERT OR REPLACE INTO "+v.storeName+" (key, value) VALUES (?, ?)",[r,y],function(){f(g)},function(O,F){p(F)})},function(k){if(k.code===k.QUOTA_ERR){if(c>0){f(yr.apply(u,[r,g,o,c-1]));return}p(k)}})})}).catch(p)});return E(a,o),a}function Sn(r,s,o){return yr.apply(this,[r,s,o,1])}function Rn(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 E(c,s),c}function xn(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 E(o,r),o}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,"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 E(o,r),o}function Cn(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 E(c,s),c}function Pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ae(f,a,"SELECT 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 E(o,r),o}function Dn(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 On(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(Dn(f))}).then(function(a){return new m(function(f,p){a.db.transaction(function(g){function v(O){return new m(function(F,$){g.executeSql("DROP TABLE IF EXISTS "+O,[],function(){F()},function(B,q){$(q)})})}for(var y=[],w=0,k=a.storeNames.length;w<k;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"),E(u,s),u}var Fn={_driver:"webSQLStorage",_initStorage:In,_support:bn(),iterate:An,getItem:wn,setItem:Sn,removeItem:Rn,clear:xn,length:kn,key:Cn,keys:Pn,dropInstance:On};function Nn(){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 Un(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Ln(){return!Un()||localStorage.length>0}function Bn(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=br(r,s._defaultConfig),Ln()?(s._dbInfo=o,o.serializer=It,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 E(o,r),o}function Mn(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 E(c,s),c}function Vn(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 E(c,s),c}function jn(r,s){var o=this,c=o.ready().then(function(){var u=o._dbInfo,a;try{a=localStorage.key(r)}catch{a=null}return a&&(a=a.substring(u.keyPrefix.length)),a});return E(c,s),c}function Kn(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 E(o,r),o}function Jn(r){var s=this,o=s.keys().then(function(c){return c.length});return E(o,r),o}function Gn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+r)});return E(c,s),c}function Hn(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 E(u,o),u}function Wn(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"),E(u,s),u}var zn={_driver:"localStorageWrapper",_initStorage:Bn,_support:Nn(),iterate:Vn,getItem:Mn,setItem:Hn,removeItem:Gn,clear:$n,length:Jn,key:jn,keys:Kn,dropInstance:Wn},Yn=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(Yn(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:yn,WEBSQL:Fn,LOCALSTORAGE:zn},Qn=[me.INDEXEDDB._driver,me.WEBSQL._driver,me.LOCALSTORAGE._driver],De=["dropInstance"],wt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(De),Xn={description:"",driver:Qn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Zn(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 eo=function(){function r(s){b(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({},Xn),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=wt.concat("_initStorage"),w=0,k=y.length;w<k;w++){var O=y[w],F=!qn(De,O);if((F||o[O])&&typeof o[O]!="function"){p(v);return}}var $=function(){for(var Te=function(no){return function(){var oo=new Error("Method "+no+" is not implemented by the current driver"),Tr=m.reject(oo);return E(Tr,arguments[arguments.length-1]),Tr}},St=0,ro=De.length;St<ro;St++){var Rt=De[St];o[Rt]||(o[Rt]=Te(Rt))}};$();var B=function(Te){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Er[g]=Te,f()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(B,p):B(!!o._support):B(!0)}catch(q){p(q)}});return C(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 C(a,c,u),a},r.prototype.getSerializer=function(o){var c=m.resolve(It);return C(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 C(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 k=0;function O(){for(;k<w.length;){var F=w[k];return k++,a._dbInfo=null,a._ready=null,a.getDriver(F).then(g).catch(O)}p();var $=new Error("No available storage method found.");return a._driverSet=m.reject($),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(k){a._driver=k._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}),C(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=wt.length;o<c;o++)Zn(this,wt[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),to=new eo;l.exports=to},{3:3}]},{},[4])(4)})});var Sr=Object.defineProperty,ho=Object.getOwnPropertyDescriptor,po=(e,t)=>{for(var n in t)Sr(e,n,{get:t[n],enumerable:!0})},Rr=(e,t,n,i)=>{for(var l=i>1?void 0:i?ho(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&&Sr(t,n,l),l};function go(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Dt(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 vo(e){return typeof e>"u"}function yo(e){return vo(e)||e===null}function bo(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 b=l[h],_=d[h],A=n(b,_,h,l,d);A!==void 0?l[h]=A:wr(_)&&wr(b)?l[h]=i({...b},_):Array.isArray(_)&&Array.isArray(b)?l[h]=[...b,..._]:l[h]=_}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 Se(e,t,n={}){let i=null,l,d,h,{leading:b=!1,trailing:_=!0}=n,A=()=>(h=e.apply(d,l),l=void 0,d=void 0,h),I=function(...x){l=x,d=this;let m=b&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,_&&!m&&A()},t),m)return A()};return I.cancel=()=>{i&&clearTimeout(i),i=null,l=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,A()},I}var _o=(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))(_o||{}),Ot=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}},Ft=class extends Ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Eo=class extends Ot{constructor(){super(...arguments),this.kind="USER_ERROR"}};var Nt=class extends Eo{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 Or=class extends Ft{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Fr=class extends Ft{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},Be=class extends Ot{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 Ft{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function To(e,t){return(...n)=>t(e,...n)}function Nr(e){return t=>To(t,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(l){e(new Nt(`${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 Ur=Symbol.for("Jolibox.canIUseMap"),Io={};globalThis[Ur]=Io;var Lt={get config(){return globalThis[Ur]}};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||{}),wo=(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))(wo||{}),Ar=["name","params"],Ao=["name","type","location","target","extra","timestamp","userId"],So=["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 Ro(e){let t=e.location?Ne(e.location,Ar):null,n=e.target?Ne(e.target,Ar):null;return Ne({...e,location:t,target:n},Ao)}function Bt(e){let t=e.events.map(i=>Ro(i)),n=Ne(e.device,So);return[e.protocolVersion,t,n,e.project]}var xo=()=>"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")},ko=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",Co="device_id",Po="advertising_id",Lr=e=>(localStorage.getItem(e)||localStorage.setItem(e,xo()),localStorage.getItem(e)),$t=()=>Lr(Co),Do=()=>Lr(Po),Oo=e=>e.charAt(0).toUpperCase()+e.slice(1),Fo=()=>{let e=new URLSearchParams(window.location.search);return Oo(e.get("utm_source")??"")||"JoliboxSDK"},Br=e=>{let t="JoliboxWebSDK",n=ko(),i=navigator.language,l=$t(),d=Do();return`${t} (${Fo()}${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}},No=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}},Uo=0,Fe=class{constructor(e){this.value=e,this.id=Uo++}},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}},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 Ae,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 No,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},Ct={};po(Ct,{None:()=>Lo,filter:()=>$o,once:()=>$r,toPromise:()=>Bo});var Lo=()=>{console.log("[Jolibox SDK] None Event")};function Bo(e){return new Promise(t=>$r(e)(t))}function $r(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 Ae(l);return d.event})((n,i=null)=>e(l=>t(l)&&n.call(i,l),null))}var xt=Symbol.for("Jolibox.hostEmitter"),Mo=()=>{let e=new pe;return globalThis[xt]||(globalThis[xt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[xt]},xe=Mo();function Vo(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(Dt(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(bo(t)){try{if(e instanceof t)return}catch{}if(!yo(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 l of e.metadata.args)n.push(l.constraint);let i=e.handler;e.handler=function(...l){return Vo(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 Pt=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=go(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,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}}};Pt=Rr([Cr],Pt);var kt=Symbol.for("Jolibox.commands");function Q(){if(globalThis[kt])return globalThis[kt];let e=new Le,t=new Pt,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[kt]=n,n}var Mt=new pe,ue=new pe;function ee(e,t={}){Mt.emit("ERROR_REPORT",{error:e,options:t})}ee.debounce=Se(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{}}},Mr=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 Or(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}};var Ko="1.1.4-beta.16",$e=()=>Ko,Vr=()=>{let e=$e();return`${Br(e)}`};var Jo={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:$t(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:$e()},schema:window.location.href,platform:"h5"},Go=globalThis.joliboxJSCore?.env,X=Object.assign({},Go?.()??Jo),Ho=()=>{let{payloadJson:e,headerJson:t}=X.schema.length?Mr(X.schema):{},n=`${X.deviceInfo.did}-${new Date().getTime()}`,l=new URL(X.schema.length?X.schema:window.location.href).searchParams,d=l.get("mpId")??l.get("appId")??l.get("gameId")??"",h=e?.sessionId??l.get("sessionId")??n,b=!!(e?.testAdsMode??l.get("testAdsMode")==="true"),_=e?.joliboxEnv??l.get("joliboxEnv")??"production",A=_==="staging",I=t?.channel;return{get testMode(){return A},get testAdsMode(){return b},get joliboxEnv(){return _},get mpId(){return d??e?.id??""},get mpVersion(){return t?.ver??$e()},get platform(){return X.platform},get deviceInfo(){return X.deviceInfo},get sdkInfo(){return X.sdkInfo},get hostInfo(){return X.hostInfo},get hostUserInfo(){return X.hostUserInfo},get sessionId(){return X.clientSessionId??h??n},get channel(){return I},onEnvConfigChanged:x=>{Pr(X,x,Dr)}}},R=Ho();var jt=!1,Kr=(e,t)=>e==null?!1:t in e,Wo=e=>Kr(e,"kind"),zo=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 i=e.priority??"P1",d={...{user_id:R.hostUserInfo?.uid??"",device_id:R.deviceInfo.did??"",timestamp:Date.now(),tag:zo(e.name)},env:t.environment,isFromUser:n};n?ue.emit("GLOBAL_USER_ERROR",e,d):ue.emit("GLOBAL_ERROR",e,d)},Yo=e=>Kr(e,"kind")&&e.kind==="USER_ERROR";Mt.on("ERROR_REPORT",({error:e,options:t})=>{if(jt)return;jt=!0;let n=Wo(e)&&e.raw?e.raw:e;try{let i=Yo(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 Nt(e);function Jr(e,t){let n=(i,l,d)=>{let h={tag:i,...t,extra:{...l}};i=="globalJsError"?ee(new Fr(JSON.stringify(h),"P0")):e("systemLog",h,d)};return n.debounce=Se(n,500,{leading:!0}),n}function Gr(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=Se(t,500,{leading:!0}),t}function Hr(e,t){let n=Jr(e,t),i=Gr(n);return{track:n,trackPerformance:i}}var Me=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.pushPastTracking=t=>{this.pastTrackings.push(t),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)}}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}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){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 b=this.deviceInfo,A={protocolVersion:"1.0.0",events:[{...t,location:l,target:d,extra:h,timestamp:Date.now(),userId:null}],device:b,project:n};try{i?this.doReport(Bt(A),i):this.doReport(Bt(A)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),H.log("[Jolibox SDK] report API error",I)}}};var Jt=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};AbortSignal.timeout??=Jt;var Ve=class{constructor(t){this.xua=Vr();this.getJoliSource=()=>new URLSearchParams(window.location.search).get("joliSource")??null;let n=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=t?.baseUrl??n}async get(t,{query:n,headers:i,timeout:l}){let h=new URLSearchParams(n).toString(),b=`${this.baseUrl}${t}${h?`?${h}`:""}`,_=this.xua,A=this.getJoliSource();return i=Object.assign({},i,_?{"x-user-agent":_}:{},A?{"x-joli-source":A}:{}),await(await fetch(b,{method:"GET",headers:i,credentials:"include",signal:Jt(l??3e4)})).json()}async post(t,{data:n,query:i,headers:l,timeout:d}){let b=new URLSearchParams(i).toString(),_=`${this.baseUrl}${t}${b?`?${b}`:""}`,A=this.xua,I=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},A?{"x-user-agent":A}:{},I?{"x-joli-source":I}:{});let x=await fetch(_,{method:"POST",headers:l,body:JSON.stringify(n),signal:Jt(d??3e4),credentials:"include"}),m=x.headers.get("content-type");if(m?.includes("application/octet-stream"))try{return x.blob()}catch{return await x.arrayBuffer()}if(m?.includes("multipart/form-data")||m?.includes("application/x-www-form-urlencoded"))try{return x.formData()}catch{return await x.text()}if(m?.includes("application/json"))try{return await x.json()}catch{return await x.text()}return x}async put(t,{data:n,query:i,headers:l}){try{let h=new URLSearchParams(i).toString(),b=`${this.baseUrl}${t}${h?`?${h}`:""}`,_=this.xua,A=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},A?{"x-joli-source":A}:{});let I=await fetch(b,{method:"PUT",headers:l,credentials:"include",body:JSON.stringify(n??{})});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);return await I.json()}catch(d){throw console.error("Error:",d),d}}};window.JoliboxHttpClient=Ve;var ce=Ve;var Gt=class extends Me{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,b=()=>{if(!d)return;let E=Date.now(),C=E-n;C>=this.interval&&(this.visible&&(h+=C,t(h)),n=E),i=requestAnimationFrame(b)},_=()=>{I(),n=Date.now(),l=window.setInterval(()=>{if(!d)return;let E=Date.now();E-n>=this.interval&&(n=E)},this.interval)},A=()=>{x(),n=Date.now(),i=requestAnimationFrame(b)},I=()=>{i&&(cancelAnimationFrame(i),i=0)},x=()=>{l&&(clearInterval(l),l=0)};this.eventEmitter.on("visible",E=>{d&&(console.log("visible",E),E?A():_())});let m=this.visible;return{start(){d||(d=!0,m?A():_())},stop(){d=!1,I(),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 Wr=Q(),Qo={type:he.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:ve,trackPerformance:Xo}=Hr((...e)=>{let[,t]=e,n=t,l={...xr(n.extra)?n.extra:Dt(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)},Qo);Wr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{Xo(e,t)});Wr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{ve(e,t)});var Ht=new pe,te=new Ke(ve,Ht);function zr(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 Yr=!1;function Wt(e){Yr=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 M=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Yr)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 M{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 M{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},We=class extends M{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 M{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ye=class extends M{validate(t){return!0}},Ye=class extends M{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},qe=class extends M{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Qe=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Xe=class extends M{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 M{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 M{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 b in l){let _=l[b];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(b)?d.path=`${this.path}.${b}`:d.path=`${this.path}["${b}"]`,!(_===void 0&&d._optional)){if(_===void 0&&d.hasDefault){l[b]=d.defaultValue;continue}d.validate(_)||(d.hasFallback?l[b]=d.fallbackValue:h=!1)}}return h}},tt=class extends M{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],b=this._object[d];if(b.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?b.path=`${this.path}.${d}`:b.path=`${this.path}["${d}"]`,!(b._optional&&h===void 0)){if(h===void 0&&b.hasDefault){i[d]=b.defaultValue;continue}b.validate(h)||(b.hasFallback?i[d]=b.fallbackValue:l=!1)}}return l}},rt=class extends M{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 M{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
2
  or `);this.errors.push(d)}return i}},ot=class extends M{constructor(...t){super(),this._items=t;let n=0,i=t.length-1;for(;i>=0;i--){let l=t[i];if(l._optional||l.hasDefault)n+=1;else break}this._minItems=t.length-n}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let n=!0;return this._items.forEach((i,l)=>{if(i.path=`${this.path}[${l}]`,i.errors=this.errors,t[l]===void 0&&i.hasDefault){t[l]=i.defaultValue;return}i.validate(t[l])||(i.hasFallback?t[l]=i._fallback:n=!1)}),n}},it=class extends M{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},st=class extends M{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}};var S={object(e){return new tt(e)},array(e){return new Ze(e)},tuple(...e){return new ot(...e)},literal(e){return new rt(e)},or(...e){return new nt(...e)},symbol(){return new ze},record(e){return new et(e)},function(){return new Qe},boolean(){return new He},string(){return new We},number(){return new Ge},undefined(){return new Ye},null(){return new qe},unknown(){return new ye},any(){return new ye},as(){return new ye},arraybuffer(){return new it},enum(...e){return new Xe(...e)},typedarray(e){return new st(e)}};function qt(e,t,n="param"){if(e.errors=[],e.path=n,Wt(!0),!e.validate(t)){let i=e.errors.join(`
3
- `);throw e.errors.length=0,Wt(!1),new TypeError(i)}}var at=1,qr=e=>{function t(i,l){return(...d)=>{let h=Date.now(),b={method:i,trace_id:at};at+=1;let E="SUCCESS",A=`${i}:ok`,I=0;try{if(l.paramsSchema)try{qt(l.paramsSchema,d,"params")}catch(C){throw Kt(`${i}:fail ${C.message}`)}let x=l.implement(...d),m=x,_=`${i}:ok`;if(x&&"code"in x){let{code:C,data:N,message:K}=x;E=C,m=N,_=K}return{code:E,message:_,data:m}}catch(x){let m=x;I=m.code??m.errNo??2e3,E="FAILURE";let _=m.message??m.errMsg??`${x}`;return A=`${i}:${E} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Be(A,I)),{code:E,message:A}}finally{let x=Date.now()-h;e("apiInvoked",{...b,duration:x,status:E})}}}function n(i,l){return async(...d)=>{let h=kr(d)?d:[d],b=Date.now(),E={method:i,trace_id:at};at+=1;let A=`${i}:ok`,I="SUCCESS",x={code:I,message:A};try{if(l.paramsSchema)try{qt(l.paramsSchema,h,"params")}catch(C){throw Kt(C.message)}let _=await l.implement(...h);if(_&&"code"in _){let{code:C,data:N,message:K}=_;I=C,A=K,_=N}return Object.assign(x,{code:I,message:A,data:_}),x}catch(m){let _=m,C=_.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,C)),x}finally{let m=Date.now()-b;e("apiInvoked",{...E,duration:m,status:I})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:de}=qr(ve),j=zr("h5");var Qr=Q(),ei="env",ti="getSystemInfoSync",ri=()=>{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},ni=de(ti,{implement:ri}),oi=de(ei,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Qr.registerCommand("API.env",oi);Qr.registerCommand("API.getSystemInfoSync",ni);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var ii="onJoliboxShow",si="onJoliboxHide",ai="onReady",Xt=Q(),Zt=Nr(ee),Qt=!0,ke=!0,ct=0,lt=Ht;function ci(){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 Xr(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",ci);window.addEventListener("focus",()=>Xr("focus"));window.addEventListener("blur",()=>Xr("blur"));var li=de(ii,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);lt.on("visible",n=>{n&&t()})}}),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);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Xt.registerCommand("LifecycleSDK.onReady",di);Xt.registerCommand("LifecycleSDK.onJoliboxShow",li);Xt.registerCommand("LifecycleSDK.onJoliboxHide",ui);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var tn=mo(en()),ut=Q(),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=tn.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},dt=new tr,fi=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.getItem(e)}});ut.registerCommand("StorageSDK.getItem",fi);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var mi=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",mi);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var hi=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.removeItem(e)}});ut.registerCommand("StorageSDK.removeItem",hi);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var pi=Z("clearStorage",{async implement(){return await dt.clear()}});ut.registerCommand("StorageSDK.clear",pi);j("storage.clear",{version:"1.0.0"});var be=Q(),gi=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})])}}),vi=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})}}),yi=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(e,t)=>await te.tracker("LevelUpgrade",{name:t,levelId:e})}),bi=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserLevel",{level:e})}),_i=Z("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserScore",{score:e})}),Ei=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",gi);be.registerCommand("TaskTrackerSDK.taskFinished",vi);be.registerCommand("TaskTrackerSDK.levelUpgrade",yi);be.registerCommand("TaskTrackerSDK.historyUserLevel",bi);be.registerCommand("TaskTrackerSDK.historyUserScore",_i);be.registerCommand("TaskTrackerSDK.taskEvent",Ei);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 rn="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(rn)??"[]");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(rn,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};var nn={ISXT6:{skipInterstitials:!0}};var ht=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"&&(nn[R.channel??""]?.skipInterstitials??!1)){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=b=>{this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:b.breakType,breakName:b.breakName??"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),l&&l(b)};if(t.adBreakDone=d,t.type==="reward"){let b=t.beforeReward,E=I=>()=>{this.track("CallShowAdFn",null),I()},A=I=>{b&&b(E(I))};t.beforeReward=A}let h;switch(i){case"preroll":h={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":h={type:i,name:t.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,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,b;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?b=document.querySelector(n):b=n,!b)throw new Error("targeting element not found");let E=i;if(E||(E=this.unitId),!E)throw new Error("slot is required");let A=typeof l=="object"&&Array.isArray(l)?l.join(", "):l,I=document.createElement("ins");if(I.className="adsbygoogle",I.id="jolibox-ads",I.style.display="block",I.setAttribute("data-ad-client",this.clientId),I.setAttribute("data-ad-slot",E),A&&I.setAttribute("data-ad-format",A),d&&I.setAttribute("data-full-width-responsive",d),h&&I.setAttribute("style",h),this.getTestAdsMode()??!1){let m=document.createElement("div");m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.width="100%",m.style.height="100%",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.backgroundColor="rgba(0, 0, 0, 0.5)",m.style.color="white",m.innerHTML="Test Ad",I.style.position="relative",b.appendChild(I),I.appendChild(m)}else b.appendChild(I),new MutationObserver(_=>{_.forEach(C=>{if(C.type==="attributes"&&C.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)}init(t){this.track("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};var pt=Q(),gt=new ht(ve,new ce,()=>ge.networkIsOk);pt.registerCommand("AdsSDK.init",e=>{gt.init(e)});pt.registerCommand("AdsSDK.adConfig",e=>{gt.adConfig(e)});pt.registerCommand("AdsSDK.adBreak",e=>{gt.adBreak(e)});pt.registerCommand("AdsSDK.adUnit",e=>{gt.adUnit(e)});function Ti(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),te.start(Date.now()-e)})}function on(){Ti()}on();
3
+ `);throw e.errors.length=0,Wt(!1),new TypeError(i)}}var at=1,qr=e=>{function t(i,l){return(...d)=>{let h=Date.now(),b={method:i,trace_id:at};at+=1;let _="SUCCESS",A=`${i}:ok`,I=0;try{if(l.paramsSchema)try{qt(l.paramsSchema,d,"params")}catch(C){throw Kt(`${i}:fail ${C.message}`)}let x=l.implement(...d),m=x,E=`${i}:ok`;if(x&&"code"in x){let{code:C,data:N,message:K}=x;_=C,m=N,E=K}return{code:_,message:E,data:m}}catch(x){let m=x;I=m.code??m.errNo??2e3,_="FAILURE";let E=m.message??m.errMsg??`${x}`;return A=`${i}:${_} ${E.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Be(A,I)),{code:_,message:A}}finally{let x=Date.now()-h;e("apiInvoked",{...b,duration:x,status:_})}}}function n(i,l){return async(...d)=>{let h=kr(d)?d:[d],b=Date.now(),_={method:i,trace_id:at};at+=1;let A=`${i}:ok`,I="SUCCESS",x={code:I,message:A};try{if(l.paramsSchema)try{qt(l.paramsSchema,h,"params")}catch(C){throw Kt(C.message)}let E=await l.implement(...h);if(E&&"code"in E){let{code:C,data:N,message:K}=E;I=C,A=K,E=N}return Object.assign(x,{code:I,message:A,data:E}),x}catch(m){let E=m,C=E.code??E.errNo??2e3;I="FAILURE";let N=E.message??E.errMsg??`${m}`,K=`${i}:${I} ${N.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:I,message:K}),ee(new Be(K,C)),x}finally{let m=Date.now()-b;e("apiInvoked",{..._,duration:m,status:I})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:de}=qr(ve),j=zr("h5");var Qr=Q(),ei="env",ti="getSystemInfoSync",ri=()=>{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},ni=de(ti,{implement:ri}),oi=de(ei,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Qr.registerCommand("API.env",oi);Qr.registerCommand("API.getSystemInfoSync",ni);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var ii="onJoliboxShow",si="onJoliboxHide",ai="onReady",Xt=Q(),Zt=Nr(ee),Qt=!0,ke=!0,ct=0,lt=Ht;function ci(){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 Xr(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",ci);window.addEventListener("focus",()=>Xr("focus"));window.addEventListener("blur",()=>Xr("blur"));var li=de(ii,{paramsSchema:S.tuple(S.function()),implement(e){let t=Zt(e);lt.on("visible",n=>{n&&t()})}}),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);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Xt.registerCommand("LifecycleSDK.onReady",di);Xt.registerCommand("LifecycleSDK.onJoliboxShow",li);Xt.registerCommand("LifecycleSDK.onJoliboxHide",ui);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var tn=mo(en()),ut=Q(),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=tn.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},dt=new tr,fi=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.getItem(e)}});ut.registerCommand("StorageSDK.getItem",fi);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var mi=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",mi);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var hi=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.removeItem(e)}});ut.registerCommand("StorageSDK.removeItem",hi);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var pi=Z("clearStorage",{async implement(){return await dt.clear()}});ut.registerCommand("StorageSDK.clear",pi);j("storage.clear",{version:"1.0.0"});var be=Q(),gi=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})])}}),vi=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})}}),yi=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(e,t)=>await te.tracker("LevelUpgrade",{name:t,levelId:e})}),bi=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserLevel",{level:e})}),_i=Z("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:async e=>await te.tracker("HistoryUserScore",{score:e})}),Ei=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",gi);be.registerCommand("TaskTrackerSDK.taskFinished",vi);be.registerCommand("TaskTrackerSDK.levelUpgrade",yi);be.registerCommand("TaskTrackerSDK.historyUserLevel",bi);be.registerCommand("TaskTrackerSDK.historyUserScore",_i);be.registerCommand("TaskTrackerSDK.taskEvent",Ei);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 rn="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(rn)??"[]");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(rn,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};var nn={ISXT6:{skipInterstitials:!0}};var ht=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"&&(nn[R.channel??""]?.skipInterstitials??!1)){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=b=>{this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:b.breakType,breakName:b.breakName??"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),l&&l(b)};if(t.adBreakDone=d,t.type==="reward"){let b=t.beforeReward,_=I=>()=>{this.track("CallShowAdFn",null),I()},A=I=>{b&&b(_(I))};t.beforeReward=A}let h;switch(i){case"preroll":h={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":h={type:i,name:t.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,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,b;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?b=document.querySelector(n):b=n,!b)throw new Error("targeting element not found");let _=i;if(_||(_=this.unitId),!_)throw new Error("slot is required");let A=typeof l=="object"&&Array.isArray(l)?l.join(", "):l,I=document.createElement("ins");if(I.className="adsbygoogle",I.id="jolibox-ads",I.style.display="block",I.setAttribute("data-ad-client",this.clientId),I.setAttribute("data-ad-slot",_),A&&I.setAttribute("data-ad-format",A),d&&I.setAttribute("data-full-width-responsive",d),h&&I.setAttribute("style",h),this.getTestAdsMode()??!1){let m=document.createElement("div");m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.width="100%",m.style.height="100%",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.backgroundColor="rgba(0, 0, 0, 0.5)",m.style.color="white",m.innerHTML="Test Ad",I.style.position="relative",b.appendChild(I),I.appendChild(m)}else b.appendChild(I),new MutationObserver(E=>{E.forEach(C=>{if(C.type==="attributes"&&C.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)}init(t){this.track("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};var pt=Q(),gt=new ht(ve,new ce,()=>ge.networkIsOk);pt.registerCommand("AdsSDK.init",e=>{gt.init(e)});pt.registerCommand("AdsSDK.adConfig",e=>{gt.adConfig(e)});pt.registerCommand("AdsSDK.adBreak",e=>{gt.adBreak(e)});pt.registerCommand("AdsSDK.adUnit",e=>{gt.adUnit(e)});function Ti(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),te.start(Date.now()-e)})}function on(){Ti()}on();
4
4
  /*! Bundled license information:
5
5
 
6
6
  localforage/dist/localforage.js:
@@ -1,3 +1,3 @@
1
- var gn=Object.create;var Jt=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var yn=Object.getOwnPropertyNames;var bn=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty;var h=(e,t)=>()=>(e&&(t=e(e=0)),t);var kn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var En=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yn(t))!Tn.call(e,s)&&s!==r&&Jt(e,s,{get:()=>t[s],enumerable:!(n=vn(t,s))||n.enumerable});return e};var Sn=(e,t,r)=>(r=e!=null?gn(bn(e)):{},En(t||!e||!e.__esModule?Jt(r,"default",{value:e,enumerable:!0}):r,e));function In(e){return!!e?.__nativeBuffers__}function de(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!In(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=wn(n.base64)),typeof s<"u"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function $t(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:_n(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var wn,_n,st=h(()=>{"use strict";wn=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};_n=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let s=0;s<n;s++)t+=String.fromCharCode(r[s]);return btoa(t)}});function xn(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 Pn(e){return typeof e>"u"}function Cn(e){return Pn(e)||e===null}function Gt(e){return typeof e=="function"}function zt(e){return P(e)&&Gt(e.then)}function Wt(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Yt(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],d=o[i],l=r(a,d,i,s,o);l!==void 0?s[i]=l:Ht(d)&&Ht(a)?s[i]=n({...a},d):Array.isArray(d)&&Array.isArray(a)?s[i]=[...a,...d]:s[i]=d}return s}return n(e,t)}function Ht(e){return e&&typeof e=="object"&&e.constructor===Object}function Qt(e,t){if(Array.isArray(e))return e.concat(t)}function pe(e,t,r={}){let n=null,s,o,i,{leading:a=!1,trailing:d=!0}=r,l=()=>(i=e.apply(o,s),s=void 0,o=void 0,i),u=function(...p){s=p,o=this;let m=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,d&&!m&&l()},t),m)return l()};return u.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,l()},u}function Fn(e,t){return(...r)=>t(e,...r)}function ke(e){return t=>Fn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new dt(`${s}`))}})}function ue(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function zn(e){return new Promise(t=>ir(e)(t))}function ir(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Wn(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new me(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Qn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xn(e[n],t[n])}function Xn(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Gt(t)){try{if(e instanceof t)return}catch{}if(!Cn(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[it])return globalThis[it];let e=new be,t=new ct,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[it]=r,r}var Vt,Rn,An,Kt,Y,Nn,lt,re,On,dt,Xt,Zt,er,tr,rr,fe,Te,ut,C,nr,Dn,mt,Un,pt,Mn,Ln,ge,Bn,jn,Jn,sr,ft,$n,Hn,Vn,or,T,Kn,qn,ve,me,Q,at,Gn,ot,Yn,V,be,ct,it,v=h(()=>{"use strict";Vt=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,An=(e,t)=>{for(var r in t)Vt(e,r,{get:t[r],enumerable:!0})},Kt=(e,t,r,n)=>{for(var s=n>1?void 0:n?Rn(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&&Vt(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))}})}};Nn=(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))(Nn||{}),lt=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 lt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},On=class extends lt{constructor(){super(...arguments),this.kind="USER_ERROR"}},dt=class extends On{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))}},Xt=class extends re{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Zt=class extends re{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},er=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}},tr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},rr=class extends re{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends lt{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}}},Te=class extends re{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},ut=class extends re{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};C={log:ue("log"),warn:ue("warn"),info:ue("info"),error:ue("error"),debug:ue("debug")};Object.assign(globalThis,{logger:C});nr=Symbol.for("Jolibox.canIUseMap"),Dn={};globalThis[nr]=Dn;mt={get config(){return globalThis[nr]}},Un=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Un||{}),pt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(pt||{}),Mn=(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))(Mn||{}),Ln=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ge={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")},Bn=()=>ge.isiOS?"iOS":ge.isAndroid?"Android":ge.isMac?"Mac":ge.isFacebook?"Facebook":"PC",jn="device_id",Jn="advertising_id",sr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Ln()),localStorage.getItem(e)),ft=()=>sr(jn),$n=()=>sr(Jn),Hn=e=>e.charAt(0).toUpperCase()+e.slice(1),Vn=()=>{let e=new URLSearchParams(window.location.search);return Hn(e.get("utm_source")??"")||"JoliboxSDK"},or=e=>{let t="JoliboxWebSDK",r=Bn(),n=navigator.language,s=ft(),o=$n();return`${t} (${Vn()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},T=class ye{static{this.Undefined=new ye(void 0)}constructor(t){this.element=t,this.next=ye.Undefined,this.prev=ye.Undefined}},Kn=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}},qn=0,ve=class{constructor(e){this.value=e,this.id=qn++}},me=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof ve&&(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 ve(e);this._listeners?this._listeners instanceof ve?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 ve?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 me,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Kn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},at={};An(at,{None:()=>Gn,filter:()=>Wn,once:()=>ir,toPromise:()=>zn});Gn=()=>{console.log("[Jolibox SDK] None Event")};ot=Symbol.for("Jolibox.hostEmitter"),Yn=()=>{let e=new Q;return globalThis[ot]||(globalThis[ot]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[ot]},V=Yn();be=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new me,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Qn(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}};be=Kt([Wt],be);ct=class{constructor(){this._onWillExecuteCommand=new me,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new me,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new be,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xn(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),at.toPromise(at.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}}};ct=Kt([Wt],ct);it=Symbol.for("Jolibox.commands")});function R(e,t={}){ht.emit("ERROR_REPORT",{error:e,options:t})}var ht,ne,M=h(()=>{"use strict";v();v();ht=new Q,ne=new Q;R.debounce=pe(R,50,{leading:!0})});function Ee(e,t){return`[${e}]:${t}`}var se,gt,X=h(()=>{"use strict";M();v();M();se=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),gt=e=>new dt(e)});var ar,cr,lr,dr=h(()=>{"use strict";ar=[],cr=[],lr=["env","createRequestTask","login"]});function mr(e,t){ur||(vt=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)}}),yt=new oe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),bt=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",()=>{vt.flush(),yt.flush(),bt.flush()}),ur=!0);function r(s){let{method:o,args:i,startTime:a,isForeground:d,errMsg:l=`${o}:fail no errMsg`,errNo:u=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:m,invokeCallback:f}=p,b=l.match(/\S:(\S+)\s?/)?.[1]??"fail";vt.report({status:b,method:n(o,i),errNo:`${u}`,errMsg:l,isForeground:d,duration:Date.now()-a}),a&&m&&f&&(yt.report({status:b,method:o,isForeground:d,duration:Number((m-a).toFixed(3))}),bt.report({status:b,method:o,isForeground:d,duration:Number((Date.now()-f).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o?.method?`${s}-${o.method}`:s}return r}var Zn,oe,ur,vt,yt,bt,Tt=h(()=>{"use strict";v();Zn=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=Zn(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 d=i[a];n[d]||(n[d]={}),r(n[d],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 d=o.shift();if(!d&&P(a))throw new Te(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(d){let l=[];if(P(a))l.push(...Object.keys(a));else if(te(a)){if(o.length>0)throw new Te(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new Te(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(u=>{s[u]||(s[u]={});let p=P(a)?a[u]:a;r(s[u],[...o],i,p)})}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={}}},ur=!1});function fr(e,t){let r=0,n=!0,s=new Map,o=mr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,kt.forEach(async({method:l,args:u,resolve:p})=>{let m=await a(l,u);p(m)}),kt.length=0});let i=(l,u)=>{C.info("----resolveId",l,u);let p=s.get(Number(l));if(!p)return;let m=de(u);p(m),s.delete(Number(l))},a=(l,u)=>{let p=Date.now(),m=`${n}`;r+=1;let f=new Y;if(s.set(r,f.resolve),!n&&cr.includes(l))return new Promise(x=>{kt.push({method:l,args:u,resolve:x})});let _={...{method:l,startTime:p,args:u,isForeground:m},invokeType:"js-bridge"},N=!es&&ar.includes(l),z=$t(u,N),W=N?z:JSON.stringify(z),k;if(l.endsWith("Sync")||lr.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=de(k)}catch(x){C.error(x)}return s.delete(r),k.errorCode&&(k.errorCode=Ee(l,k.errorCode)),o({..._,...k}),k}return l.endsWith("Sync")&&s.delete(r),f.promise.then(x=>(x.errorCode&&(x.errorCode=Ee(l,x.errorCode)),o({..._,...x}),x))};return{invokeNative:a,applyNative:(l,u)=>{let p=a(l,u);return zt(p)?p.then(m=>pr(l,m)):pr(l,p)},invokeHandler:i}}function pr(e,t){if(!P(t)){C.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 er(r,n,s,o);return i}var kt,es,hr=h(()=>{"use strict";st();v();X();dr();Tt();kt=[],es=!1});function gr(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=de(s),a;if(i.__extra){a=i.params;let{type:d,startTime:l}=i.__extra;r.report({type:d,event:n,duration:Date.now()-l})}else a=i;t.emit(n,a,o)}}}var vr=h(()=>{"use strict";v();st();Tt()});function Et(e){let{subscribeHandler:t,onNative:r,offNative:n}=gr(e),{invokeNative:s,invokeHandler:o,applyNative:i}=fr(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var yr=h(()=>{"use strict";hr();vr()});var br=h(()=>{"use strict"});var Tr=h(()=>{"use strict";yr();br()});var Z,L,kr,Er=h(()=>{"use strict";v();M();L={trigger(){},exit(){return!1},onReady(e){L.trigger=e},doExit(e){L.exit=e}},kr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)R(new Zt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(s="")=>{L.trigger(),e.onDocumentReady.postMessage({path:s})};Z={onDocumentReady:t,doExit:s=>{let o=L.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:kr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{L.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=L.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:kr};globalThis.joliboxJSCore={...n}}});function St(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var It=h(()=>{"use strict"});function wt(){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=St(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,Sr=h(()=>{"use strict";It()});var Se=h(()=>{"use strict";Er();Sr();It()});var wr,ts,_r,Ir,O,A,J,yi,rs,B=h(()=>{"use strict";Tr();Se();X();v();Se();wr=Z;if(!wr)throw new tr("No joliboxJScore is found, native bridge not found.");wt();ts={...wr},_r=Et(ts),{invokeHandler:Ir}=_r,{applyNative:O,invokeNative:A,onNative:J,offNative:yi,subscribeHandler:rs}=_r;globalThis.joliboxJSBridge={callHandler:Ir,invokeHandler:Ir,subscribeHandler:rs}});var _t,Rr,Ar=h(()=>{"use strict";v();M();_t=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{}}},Rr=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[s,o,i]=n;return{headerJson:_t(s),payloadJson:_t(o),signature:_t(i)}}else throw"joli_source is missing"}catch(t){return R(new Xt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var ns,Ie,xr,Rt=h(()=>{"use strict";v();ns="1.1.4-beta.15",Ie=()=>ns,xr=()=>{let e=Ie();return`${or(e)}`}});var ss,os,D,is,y,$=h(()=>{"use strict";v();Ar();Rt();v();ss={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ft(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ie()},schema:window.location.href,platform:"h5"},os=globalThis.joliboxJSCore?.env,D=Object.assign({},os?.()??ss),is=()=>{let{payloadJson:e,headerJson:t}=D.schema.length?Rr(D.schema):{},r=`${D.deviceInfo.did}-${new Date().getTime()}`,n=new URLSearchParams(D.schema.length?D.schema:window.location.search),s=n.get("mpId")??n.get("appId")??n.get("gameId")??"",o=e?.sessionId??n.get("sessionId")??r,i=!!(e?.testAdsMode??n.get("testAdsMode")==="true"),a=e?.joliboxEnv??n.get("joliboxEnv")??"production",d=a==="staging",l=t?.channel;return{get testMode(){return d},get testAdsMode(){return i},get joliboxEnv(){return a},get mpId(){return s??e?.id??""},get mpVersion(){return t?.ver??Ie()},get platform(){return D.platform},get deviceInfo(){return D.deviceInfo},get sdkInfo(){return D.sdkInfo},get hostInfo(){return D.hostInfo},get hostUserInfo(){return D.hostUserInfo},get sessionId(){return D.clientSessionId??o??r},get channel(){return l},onEnvConfigChanged:u=>{Yt(D,u,Qt)}}},y=is()});var At,Cr,as,cs,Pr,ls,Nr=h(()=>{"use strict";v();M();$();v();At=!1,Cr=(e,t)=>e==null?!1:t in e,as=e=>Cr(e,"kind"),cs=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Pr=(e,t={},r)=>{let n=e.priority??"P1",o={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:cs(e.name)},env:t.environment,isFromUser:r};r?ne.emit("GLOBAL_USER_ERROR",e,o):ne.emit("GLOBAL_ERROR",e,o)},ls=e=>Cr(e,"kind")&&e.kind==="USER_ERROR";ht.on("ERROR_REPORT",({error:e,options:t})=>{if(At)return;At=!0;let r=as(e)&&e.raw?e.raw:e;try{let n=ls(e);Pr(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new ut(`${s}, origin error: ${r.message}`);C.error(o),Pr(new ut(o.message),{environment:t.environment},!1)}finally{At=!1}})});var Or=h(()=>{"use strict";Nr();X();v();B();ne.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};A("trackAsync",{event:"reportJsError",data:r})});ne.on("GLOBAL_USER_ERROR",(e,t)=>{C.log("UserError",e,t)})});var xt=h(()=>{"use strict"});function Fr(e,t){let r=(n,s,o)=>{let i={tag:n,...t,extra:{...s}};n=="globalJsError"?R(new rr(JSON.stringify(i),"P0")):e("systemLog",i,o)};return r.debounce=pe(r,500,{leading:!0}),r}function Dr(e){let t=(r,n,s)=>{let o=(s&&JSON.stringify(s))??0,i={speed_value_type:r,total_duration:n};o&&Object.assign(i,{extra:o}),e("joliboxSpeedAnalysis",i)};return t.debounce=pe(t,500,{leading:!0}),t}var Ur=h(()=>{"use strict";v();v();M()});function Mr(e,t){let r=Fr(e,t),n=Dr(r);return{track:r,trackPerformance:n}}var Lr=h(()=>{"use strict";Ur()});var Br=h(()=>{"use strict";$();v();v()});var jr=h(()=>{"use strict";Lr();xt();Br()});var we,Jr=h(()=>{"use strict";we=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 f=Date.now(),b=f-r;b>=this.interval&&(this.visible&&(i+=b,t(i)),r=f),n=requestAnimationFrame(a)},d=()=>{u(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{p(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},p=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():d())});let m=this.visible;return{start(){o||(o=!0,m?l():d())},stop(){o=!1,u(),p()}}}}});var Pt=h(()=>{"use strict"});function Hr(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:d={}}=n,u={duration:o-s,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:d.socketReused?1:0,request_from:i};(i==="public"&&$r<us||i==="inner")&&(u.joli_request_number=$r++,setTimeout(()=>{U("joliboxNetRequestResult",u)},500))}var $r,us,Vr=h(()=>{"use strict";Pt();ee();$r=0,us=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 J("onRequestTaskStateChange",d=>{if(typeof d.requestTaskId!="string")return;let l=n.get(d.requestTaskId);if(l)if(d.state==="success"){let{requestTaskId:u,state:p,...m}=d;l.resolve(m),n.delete(u)}else if(d.state==="fail"){let{requestTaskId:u,state:p,...m}=d;l.reject(m),n.delete(u)}else C.warn("onRequestTaskStateChange unknown event",d)}),V.on("onLoginComplete",({isLogin:d,token:l})=>{d&&l&&(i["X-JOLI-TOKEN"]=l)}),async(d,l={})=>{let u=Date.now(),p=ms(d,{...l,baseUrl:s}),{method:m="GET",responseType:f="text",dataType:b="json",timeout:_,enableCache:N=!1,appendHostCookie:z=!0}=l,W=Object.assign({"content-type":"application/json"},i,l.header),k={url:p,method:m,header:W,enableCache:N,responseType:f,appendHostCookie:z};if(m=="POST"||m=="PUT"){let j=fs(l.data,W["content-type"]);k.data=j}_&&Object.assign(k,{timeout:_});let{data:{requestTaskId:x}}=A(e,k);if(typeof x!="string")throw se({code:-1,msg:"requestTaskId is not a string"});let le=(j,H)=>{Hr("request",p,{state:j,startTime:u,endTime:Date.now(),params:k,response:H,requestId:x,requestFrom:o=="public"?"public":"inner"})},{resolve:nt,reject:un,promise:mn}=new Y;n.set(x,{resolve:nt,reject:un});try{let j=await mn;le("success",j);let{data:H}=j;return b==="json"&&typeof H=="string"&&(H=ps(H)),{url:p,timeout:_,method:m,response:{...j,data:H}}}catch(j){let H=j;if(P(H)){let{errMsg:he,prefetchDetail:pn,isPrefetch:fn,errNo:hn}=H;te(he)&&(le("fail",{errMsg:he,isPrefetch:fn,prefetchDetail:pn}),R(se({code:-1,msg:he},{errNo:hn,errMsg:he})))}throw j}}}function ps(e){try{return JSON.parse(e.trim())}catch{return e}}function fs(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 ms,Ct=h(()=>{"use strict";v();Vr();Pt();B();M();X();ms=(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 K,Re=h(()=>{"use strict";Rt();Ct();$();K=_e("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":xr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ae,Kr=h(()=>{"use strict";$();Jr();Re();B();Ae=class extends we{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 O("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var hs,U,gs,qr,xe,F,ee=h(()=>{"use strict";Or();v();xt();jr();$();Kr();B();hs=(e,t,r)=>{let n=t,o={...P(n.extra)?n.extra:te(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};A("trackAsync",{event:e,data:o,webviewId:r})},{track:U,trackPerformance:gs}=Mr(hs,{type:pt.AppSDK,platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),qr=I();qr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{gs(e,t)});qr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{U(e,t)});xe=new Q,F=new Ae(U,xe)});function zr(e){let t=mt.config[e];return t||(t={},mt.config[e]=t),(r,n)=>{if(t[r]){C.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Wr=h(()=>{"use strict";v()});function Nt(e){Yr=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 Ot(e){let t=Ft(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Ft(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Yr,E,Ne,Oe,Fe,De,ae,Ue,Me,Le,Be,je,Je,$e,He,Ve,Ke,qe,Ge,Dt=h(()=>{"use strict";Yr=!1;E=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Yr)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 ${Ot(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}};Ne=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}},Oe=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Fe=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}},De=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}},Ue=class extends E{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends E{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Be=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 ${Ot(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}},Je=class extends E{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ft(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 d=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}"]`,!(d===void 0&&o._optional)){if(d===void 0&&o.hasDefault){s[a]=o.defaultValue;continue}o.validate(d)||(o.hasFallback?s[a]=o.fallbackValue:i=!1)}}return i}},$e=class extends E{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ft(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:Ot(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(`
1
+ var gn=Object.create;var Jt=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var yn=Object.getOwnPropertyNames;var bn=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty;var h=(e,t)=>()=>(e&&(t=e(e=0)),t);var kn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var En=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yn(t))!Tn.call(e,s)&&s!==r&&Jt(e,s,{get:()=>t[s],enumerable:!(n=vn(t,s))||n.enumerable});return e};var Sn=(e,t,r)=>(r=e!=null?gn(bn(e)):{},En(t||!e||!e.__esModule?Jt(r,"default",{value:e,enumerable:!0}):r,e));function In(e){return!!e?.__nativeBuffers__}function de(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!In(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=wn(n.base64)),typeof s<"u"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function $t(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:_n(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var wn,_n,st=h(()=>{"use strict";wn=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};_n=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let s=0;s<n;s++)t+=String.fromCharCode(r[s]);return btoa(t)}});function xn(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 Pn(e){return typeof e>"u"}function Cn(e){return Pn(e)||e===null}function Gt(e){return typeof e=="function"}function zt(e){return P(e)&&Gt(e.then)}function Wt(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Yt(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],d=o[i],l=r(a,d,i,s,o);l!==void 0?s[i]=l:Ht(d)&&Ht(a)?s[i]=n({...a},d):Array.isArray(d)&&Array.isArray(a)?s[i]=[...a,...d]:s[i]=d}return s}return n(e,t)}function Ht(e){return e&&typeof e=="object"&&e.constructor===Object}function Qt(e,t){if(Array.isArray(e))return e.concat(t)}function pe(e,t,r={}){let n=null,s,o,i,{leading:a=!1,trailing:d=!0}=r,l=()=>(i=e.apply(o,s),s=void 0,o=void 0,i),u=function(...p){s=p,o=this;let m=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,d&&!m&&l()},t),m)return l()};return u.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,l()},u}function Fn(e,t){return(...r)=>t(e,...r)}function ke(e){return t=>Fn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new dt(`${s}`))}})}function ue(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function zn(e){return new Promise(t=>ir(e)(t))}function ir(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Wn(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new me(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Qn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xn(e[n],t[n])}function Xn(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Gt(t)){try{if(e instanceof t)return}catch{}if(!Cn(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[it])return globalThis[it];let e=new be,t=new ct,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[it]=r,r}var Vt,Rn,An,Kt,Y,Nn,lt,re,On,dt,Xt,Zt,er,tr,rr,fe,Te,ut,C,nr,Dn,mt,Un,pt,Mn,Ln,ge,Bn,jn,Jn,sr,ft,$n,Hn,Vn,or,T,Kn,qn,ve,me,Q,at,Gn,ot,Yn,V,be,ct,it,v=h(()=>{"use strict";Vt=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,An=(e,t)=>{for(var r in t)Vt(e,r,{get:t[r],enumerable:!0})},Kt=(e,t,r,n)=>{for(var s=n>1?void 0:n?Rn(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&&Vt(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))}})}};Nn=(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))(Nn||{}),lt=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 lt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},On=class extends lt{constructor(){super(...arguments),this.kind="USER_ERROR"}},dt=class extends On{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))}},Xt=class extends re{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Zt=class extends re{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},er=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}},tr=class extends re{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},rr=class extends re{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends lt{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}}},Te=class extends re{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},ut=class extends re{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};C={log:ue("log"),warn:ue("warn"),info:ue("info"),error:ue("error"),debug:ue("debug")};Object.assign(globalThis,{logger:C});nr=Symbol.for("Jolibox.canIUseMap"),Dn={};globalThis[nr]=Dn;mt={get config(){return globalThis[nr]}},Un=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Un||{}),pt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(pt||{}),Mn=(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))(Mn||{}),Ln=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ge={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")},Bn=()=>ge.isiOS?"iOS":ge.isAndroid?"Android":ge.isMac?"Mac":ge.isFacebook?"Facebook":"PC",jn="device_id",Jn="advertising_id",sr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Ln()),localStorage.getItem(e)),ft=()=>sr(jn),$n=()=>sr(Jn),Hn=e=>e.charAt(0).toUpperCase()+e.slice(1),Vn=()=>{let e=new URLSearchParams(window.location.search);return Hn(e.get("utm_source")??"")||"JoliboxSDK"},or=e=>{let t="JoliboxWebSDK",r=Bn(),n=navigator.language,s=ft(),o=$n();return`${t} (${Vn()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},T=class ye{static{this.Undefined=new ye(void 0)}constructor(t){this.element=t,this.next=ye.Undefined,this.prev=ye.Undefined}},Kn=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}},qn=0,ve=class{constructor(e){this.value=e,this.id=qn++}},me=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof ve&&(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 ve(e);this._listeners?this._listeners instanceof ve?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 ve?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 me,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Kn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},at={};An(at,{None:()=>Gn,filter:()=>Wn,once:()=>ir,toPromise:()=>zn});Gn=()=>{console.log("[Jolibox SDK] None Event")};ot=Symbol.for("Jolibox.hostEmitter"),Yn=()=>{let e=new Q;return globalThis[ot]||(globalThis[ot]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[ot]},V=Yn();be=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new me,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Qn(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}};be=Kt([Wt],be);ct=class{constructor(){this._onWillExecuteCommand=new me,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new me,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new be,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xn(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),at.toPromise(at.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}}};ct=Kt([Wt],ct);it=Symbol.for("Jolibox.commands")});function R(e,t={}){ht.emit("ERROR_REPORT",{error:e,options:t})}var ht,ne,M=h(()=>{"use strict";v();v();ht=new Q,ne=new Q;R.debounce=pe(R,50,{leading:!0})});function Ee(e,t){return`[${e}]:${t}`}var se,gt,X=h(()=>{"use strict";M();v();M();se=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),gt=e=>new dt(e)});var ar,cr,lr,dr=h(()=>{"use strict";ar=[],cr=[],lr=["env","createRequestTask","login"]});function mr(e,t){ur||(vt=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)}}),yt=new oe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),bt=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",()=>{vt.flush(),yt.flush(),bt.flush()}),ur=!0);function r(s){let{method:o,args:i,startTime:a,isForeground:d,errMsg:l=`${o}:fail no errMsg`,errNo:u=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:m,invokeCallback:f}=p,b=l.match(/\S:(\S+)\s?/)?.[1]??"fail";vt.report({status:b,method:n(o,i),errNo:`${u}`,errMsg:l,isForeground:d,duration:Date.now()-a}),a&&m&&f&&(yt.report({status:b,method:o,isForeground:d,duration:Number((m-a).toFixed(3))}),bt.report({status:b,method:o,isForeground:d,duration:Number((Date.now()-f).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o?.method?`${s}-${o.method}`:s}return r}var Zn,oe,ur,vt,yt,bt,Tt=h(()=>{"use strict";v();Zn=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=Zn(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 d=i[a];n[d]||(n[d]={}),r(n[d],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 d=o.shift();if(!d&&P(a))throw new Te(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(d){let l=[];if(P(a))l.push(...Object.keys(a));else if(te(a)){if(o.length>0)throw new Te(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new Te(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(u=>{s[u]||(s[u]={});let p=P(a)?a[u]:a;r(s[u],[...o],i,p)})}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={}}},ur=!1});function fr(e,t){let r=0,n=!0,s=new Map,o=mr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,kt.forEach(async({method:l,args:u,resolve:p})=>{let m=await a(l,u);p(m)}),kt.length=0});let i=(l,u)=>{C.info("----resolveId",l,u);let p=s.get(Number(l));if(!p)return;let m=de(u);p(m),s.delete(Number(l))},a=(l,u)=>{let p=Date.now(),m=`${n}`;r+=1;let f=new Y;if(s.set(r,f.resolve),!n&&cr.includes(l))return new Promise(x=>{kt.push({method:l,args:u,resolve:x})});let _={...{method:l,startTime:p,args:u,isForeground:m},invokeType:"js-bridge"},N=!es&&ar.includes(l),z=$t(u,N),W=N?z:JSON.stringify(z),k;if(l.endsWith("Sync")||lr.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=de(k)}catch(x){C.error(x)}return s.delete(r),k.errorCode&&(k.errorCode=Ee(l,k.errorCode)),o({..._,...k}),k}return l.endsWith("Sync")&&s.delete(r),f.promise.then(x=>(x.errorCode&&(x.errorCode=Ee(l,x.errorCode)),o({..._,...x}),x))};return{invokeNative:a,applyNative:(l,u)=>{let p=a(l,u);return zt(p)?p.then(m=>pr(l,m)):pr(l,p)},invokeHandler:i}}function pr(e,t){if(!P(t)){C.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 er(r,n,s,o);return i}var kt,es,hr=h(()=>{"use strict";st();v();X();dr();Tt();kt=[],es=!1});function gr(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=de(s),a;if(i.__extra){a=i.params;let{type:d,startTime:l}=i.__extra;r.report({type:d,event:n,duration:Date.now()-l})}else a=i;t.emit(n,a,o)}}}var vr=h(()=>{"use strict";v();st();Tt()});function Et(e){let{subscribeHandler:t,onNative:r,offNative:n}=gr(e),{invokeNative:s,invokeHandler:o,applyNative:i}=fr(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var yr=h(()=>{"use strict";hr();vr()});var br=h(()=>{"use strict"});var Tr=h(()=>{"use strict";yr();br()});var Z,L,kr,Er=h(()=>{"use strict";v();M();L={trigger(){},exit(){return!1},onReady(e){L.trigger=e},doExit(e){L.exit=e}},kr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)R(new Zt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(s="")=>{L.trigger(),e.onDocumentReady.postMessage({path:s})};Z={onDocumentReady:t,doExit:s=>{let o=L.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:kr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{L.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=L.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:kr};globalThis.joliboxJSCore={...n}}});function St(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var It=h(()=>{"use strict"});function wt(){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=St(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,Sr=h(()=>{"use strict";It()});var Se=h(()=>{"use strict";Er();Sr();It()});var wr,ts,_r,Ir,O,A,J,yi,rs,B=h(()=>{"use strict";Tr();Se();X();v();Se();wr=Z;if(!wr)throw new tr("No joliboxJScore is found, native bridge not found.");wt();ts={...wr},_r=Et(ts),{invokeHandler:Ir}=_r,{applyNative:O,invokeNative:A,onNative:J,offNative:yi,subscribeHandler:rs}=_r;globalThis.joliboxJSBridge={callHandler:Ir,invokeHandler:Ir,subscribeHandler:rs}});var _t,Rr,Ar=h(()=>{"use strict";v();M();_t=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{}}},Rr=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[s,o,i]=n;return{headerJson:_t(s),payloadJson:_t(o),signature:_t(i)}}else throw"joli_source is missing"}catch(t){return R(new Xt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var ns,Ie,xr,Rt=h(()=>{"use strict";v();ns="1.1.4-beta.16",Ie=()=>ns,xr=()=>{let e=Ie();return`${or(e)}`}});var ss,os,D,is,y,$=h(()=>{"use strict";v();Ar();Rt();v();ss={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ft(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ie()},schema:window.location.href,platform:"h5"},os=globalThis.joliboxJSCore?.env,D=Object.assign({},os?.()??ss),is=()=>{let{payloadJson:e,headerJson:t}=D.schema.length?Rr(D.schema):{},r=`${D.deviceInfo.did}-${new Date().getTime()}`,s=new URL(D.schema.length?D.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"),d=e?.joliboxEnv??s.get("joliboxEnv")??"production",l=d==="staging",u=t?.channel;return{get testMode(){return l},get testAdsMode(){return a},get joliboxEnv(){return d},get mpId(){return o??e?.id??""},get mpVersion(){return t?.ver??Ie()},get platform(){return D.platform},get deviceInfo(){return D.deviceInfo},get sdkInfo(){return D.sdkInfo},get hostInfo(){return D.hostInfo},get hostUserInfo(){return D.hostUserInfo},get sessionId(){return D.clientSessionId??i??r},get channel(){return u},onEnvConfigChanged:p=>{Yt(D,p,Qt)}}},y=is()});var At,Cr,as,cs,Pr,ls,Nr=h(()=>{"use strict";v();M();$();v();At=!1,Cr=(e,t)=>e==null?!1:t in e,as=e=>Cr(e,"kind"),cs=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Pr=(e,t={},r)=>{let n=e.priority??"P1",o={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:cs(e.name)},env:t.environment,isFromUser:r};r?ne.emit("GLOBAL_USER_ERROR",e,o):ne.emit("GLOBAL_ERROR",e,o)},ls=e=>Cr(e,"kind")&&e.kind==="USER_ERROR";ht.on("ERROR_REPORT",({error:e,options:t})=>{if(At)return;At=!0;let r=as(e)&&e.raw?e.raw:e;try{let n=ls(e);Pr(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new ut(`${s}, origin error: ${r.message}`);C.error(o),Pr(new ut(o.message),{environment:t.environment},!1)}finally{At=!1}})});var Or=h(()=>{"use strict";Nr();X();v();B();ne.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};A("trackAsync",{event:"reportJsError",data:r})});ne.on("GLOBAL_USER_ERROR",(e,t)=>{C.log("UserError",e,t)})});var xt=h(()=>{"use strict"});function Fr(e,t){let r=(n,s,o)=>{let i={tag:n,...t,extra:{...s}};n=="globalJsError"?R(new rr(JSON.stringify(i),"P0")):e("systemLog",i,o)};return r.debounce=pe(r,500,{leading:!0}),r}function Dr(e){let t=(r,n,s)=>{let o=(s&&JSON.stringify(s))??0,i={speed_value_type:r,total_duration:n};o&&Object.assign(i,{extra:o}),e("joliboxSpeedAnalysis",i)};return t.debounce=pe(t,500,{leading:!0}),t}var Ur=h(()=>{"use strict";v();v();M()});function Mr(e,t){let r=Fr(e,t),n=Dr(r);return{track:r,trackPerformance:n}}var Lr=h(()=>{"use strict";Ur()});var Br=h(()=>{"use strict";$();v();v()});var jr=h(()=>{"use strict";Lr();xt();Br()});var we,Jr=h(()=>{"use strict";we=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 f=Date.now(),b=f-r;b>=this.interval&&(this.visible&&(i+=b,t(i)),r=f),n=requestAnimationFrame(a)},d=()=>{u(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{p(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},p=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():d())});let m=this.visible;return{start(){o||(o=!0,m?l():d())},stop(){o=!1,u(),p()}}}}});var Pt=h(()=>{"use strict"});function Hr(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:d={}}=n,u={duration:o-s,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:d.socketReused?1:0,request_from:i};(i==="public"&&$r<us||i==="inner")&&(u.joli_request_number=$r++,setTimeout(()=>{U("joliboxNetRequestResult",u)},500))}var $r,us,Vr=h(()=>{"use strict";Pt();ee();$r=0,us=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 J("onRequestTaskStateChange",d=>{if(typeof d.requestTaskId!="string")return;let l=n.get(d.requestTaskId);if(l)if(d.state==="success"){let{requestTaskId:u,state:p,...m}=d;l.resolve(m),n.delete(u)}else if(d.state==="fail"){let{requestTaskId:u,state:p,...m}=d;l.reject(m),n.delete(u)}else C.warn("onRequestTaskStateChange unknown event",d)}),V.on("onLoginComplete",({isLogin:d,token:l})=>{d&&l&&(i["X-JOLI-TOKEN"]=l)}),async(d,l={})=>{let u=Date.now(),p=ms(d,{...l,baseUrl:s}),{method:m="GET",responseType:f="text",dataType:b="json",timeout:_,enableCache:N=!1,appendHostCookie:z=!0}=l,W=Object.assign({"content-type":"application/json"},i,l.header),k={url:p,method:m,header:W,enableCache:N,responseType:f,appendHostCookie:z};if(m=="POST"||m=="PUT"){let j=fs(l.data,W["content-type"]);k.data=j}_&&Object.assign(k,{timeout:_});let{data:{requestTaskId:x}}=A(e,k);if(typeof x!="string")throw se({code:-1,msg:"requestTaskId is not a string"});let le=(j,H)=>{Hr("request",p,{state:j,startTime:u,endTime:Date.now(),params:k,response:H,requestId:x,requestFrom:o=="public"?"public":"inner"})},{resolve:nt,reject:un,promise:mn}=new Y;n.set(x,{resolve:nt,reject:un});try{let j=await mn;le("success",j);let{data:H}=j;return b==="json"&&typeof H=="string"&&(H=ps(H)),{url:p,timeout:_,method:m,response:{...j,data:H}}}catch(j){let H=j;if(P(H)){let{errMsg:he,prefetchDetail:pn,isPrefetch:fn,errNo:hn}=H;te(he)&&(le("fail",{errMsg:he,isPrefetch:fn,prefetchDetail:pn}),R(se({code:-1,msg:he},{errNo:hn,errMsg:he})))}throw j}}}function ps(e){try{return JSON.parse(e.trim())}catch{return e}}function fs(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 ms,Ct=h(()=>{"use strict";v();Vr();Pt();B();M();X();ms=(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 K,Re=h(()=>{"use strict";Rt();Ct();$();K=_e("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":xr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ae,Kr=h(()=>{"use strict";$();Jr();Re();B();Ae=class extends we{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 O("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var hs,U,gs,qr,xe,F,ee=h(()=>{"use strict";Or();v();xt();jr();$();Kr();B();hs=(e,t,r)=>{let n=t,o={...P(n.extra)?n.extra:te(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};A("trackAsync",{event:e,data:o,webviewId:r})},{track:U,trackPerformance:gs}=Mr(hs,{type:pt.AppSDK,platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),qr=I();qr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{gs(e,t)});qr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{U(e,t)});xe=new Q,F=new Ae(U,xe)});function zr(e){let t=mt.config[e];return t||(t={},mt.config[e]=t),(r,n)=>{if(t[r]){C.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Wr=h(()=>{"use strict";v()});function Nt(e){Yr=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 Ot(e){let t=Ft(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Ft(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Yr,E,Ne,Oe,Fe,De,ae,Ue,Me,Le,Be,je,Je,$e,He,Ve,Ke,qe,Ge,Dt=h(()=>{"use strict";Yr=!1;E=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Yr)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 ${Ot(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}};Ne=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}},Oe=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Fe=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}},De=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}},Ue=class extends E{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends E{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Be=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 ${Ot(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}},Je=class extends E{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ft(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 d=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}"]`,!(d===void 0&&o._optional)){if(d===void 0&&o.hasDefault){s[a]=o.defaultValue;continue}o.validate(d)||(o.hasFallback?s[a]=o.fallbackValue:i=!1)}}return i}},$e=class extends E{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ft(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:Ot(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
2
  or `);this.errors.push(o)}return n}},Ke=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}},qe=class extends E{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},Ge=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 Ut(e,t,r="param"){if(e.errors=[],e.path=r,Nt(!0),!e.validate(t)){let n=e.errors.join(`
3
3
  `);throw e.errors.length=0,Nt(!1),new TypeError(n)}}var c,Mt=h(()=>{"use strict";Dt();Dt();c={object(e){return new $e(e)},array(e){return new je(e)},tuple(...e){return new Ke(...e)},literal(e){return new He(e)},or(...e){return new Ve(...e)},symbol(){return new De},record(e){return new Je(e)},function(){return new Le},boolean(){return new Oe},string(){return new Fe},number(){return new Ne},undefined(){return new Ue},null(){return new Me},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new qe},enum(...e){return new Be(...e)},typedarray(e){return new Ge(e)}}});var ze,Qr,Xr=h(()=>{"use strict";v();M();Mt();X();ze=1,Qr=e=>{function t(n,s){return(...o)=>{let i=Date.now(),a={method:n,trace_id:ze};ze+=1;let d="SUCCESS",l=`${n}:ok`,u=0;try{if(s.paramsSchema)try{Ut(s.paramsSchema,o,"params")}catch(b){throw gt(`${n}:fail ${b.message}`)}let p=s.implement(...o),m=p,f=`${n}:ok`;if(p&&"code"in p){let{code:b,data:_,message:N}=p;d=b,m=_,f=N}return{code:d,message:f,data:m}}catch(p){let m=p;u=m.code??m.errNo??2e3,d="FAILURE";let f=m.message??m.errMsg??`${p}`;return l=`${n}:${d} ${f.replace(/^\S+:(fail|cancel)\s?/,"")}`,R(new fe(l,u)),{code:d,message:l}}finally{let p=Date.now()-i;e("apiInvoked",{...a,duration:p,status:d})}}}function r(n,s){return async(...o)=>{let i=qt(o)?o:[o],a=Date.now(),d={method:n,trace_id:ze};ze+=1;let l=`${n}:ok`,u="SUCCESS",p={code:u,message:l};try{if(s.paramsSchema)try{Ut(s.paramsSchema,i,"params")}catch(b){throw gt(b.message)}let f=await s.implement(...i);if(f&&"code"in f){let{code:b,data:_,message:N}=f;u=b,l=N,f=_}return Object.assign(p,{code:u,message:l,data:f}),p}catch(m){let f=m,b=f.code??f.errNo??2e3;u="FAILURE";let _=f.message??f.errMsg??`${m}`,N=`${n}:${u} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(p,{code:u,message:N}),R(new fe(N,b)),p}finally{let m=Date.now()-a;e("apiInvoked",{...d,duration:m,status:u})}}}return{createAPI:r,createSyncAPI:t}}});var S,w,g,G=h(()=>{"use strict";Wr();ee();Xr();Mt();({createAPI:S,createSyncAPI:w}=Qr(U)),g=zr("native")});var tn=kn(en=>{"use strict";v();G();M();B();ee();var Is="exitGame",ws="onReady",_s="onJoliboxShow",Rs="onJoliboxHide",We=I(),Ye=ke(R),As=S(Is,{paramsSchema:c.tuple(c.function()),implement:async e=>{Ye(e).call(en),await O("exitAppAsync")}}),xs=w(_s,{paramsSchema:c.tuple(c.function()),implement(e){let t=Ye(e);J("onJoliboxEnterForeground",()=>{t.call(this),xe.emit("visible",!0)})}}),Ps=w(Rs,{paramsSchema:c.tuple(c.function()),implement(e){let t=Ye(e);J("onJoliboxEnterBackground",()=>{t.call(this),xe.emit("visible",!1)})}}),Cs=w(ws,{paramsSchema:c.tuple(c.function()),implement(e){let t=Ye(e);V.on("LifecycleEvent.onReady",r=>{t(r)})}});We.registerCommand("LifecycleSDK.exit",As);We.registerCommand("LifecycleSDK.onReady",Cs);We.registerCommand("LifecycleSDK.onJoliboxShow",xs);We.registerCommand("LifecycleSDK.onJoliboxHide",Ps);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"})});B();Se();$();v();ee();L.onReady(()=>{});L.doExit(()=>(U("onBeforeExit",{timestamp:Date.now()}),F.close(Date.now()-Pe),!1));function vs(){V.on("onDocumentReady",()=>{Z?.onDocumentReady(window.location.href),U("onDocumentReady",{start_timestamp:Pe,timestamp:Date.now()})})}function ys(){J("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),V.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),U("joliboxServiceReady",{start_timestamp:Pe,timestamp:Date.now()}),F.start(t)}),J("onBeforeExit",({uuid:e})=>{Z?.doExit(e)})}var Pe;function Gr(){Pe=Date.now(),ys(),vs()}v();G();B();var Zr=I(),Ts="env",ks="getSystemInfoSync",Es=w(ks,{implement:()=>{let e=A("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}}}),Ss=w(Ts,{implement:()=>A("envSync")?.data??void 0});Zr.registerCommand("API.getSystemInfoSync",Es);Zr.registerCommand("API.env",Ss);g("env",{version:"1.0.0"});g("getSystemInfoSync",{version:"1.0.0"});var bl=Sn(tn());X();Ct();G();v();function rn(e){let t={};if(!P(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 nn(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 on(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!P(r))return e;let[n,s=""]=e.split("?"),o=JSON.stringify({...JSON.parse(s),...r});return`${n}?${o}`}v();M();var Ns=15,Os=_e("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Lt=0,Bt=[],an=ke(R),Fs=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},Ds=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=an(s.fail);try{if(Lt+=1,t.state!=="pending")return;let{data:a,dataType:d,responseType:l,enableCache:u,appendHostCookie:p}=s,m=rn(s.header),f=nn(s.method),b=sn(s.timeout),_=on(s.url,f,a),N=an(s.success),z=Object.assign({},s,{method:f,header:m,data:f==="GET"||f==="HEAD"?void 0:a,enableCache:u,query:s.query??{},dataType:d,responseType:l,appendHostCookie:p});b&&(z.timeout=b);let W=Os(_,z);{let{response:k}=await W,{code:x,data:le,message:nt}=k;t.resolve({code:x??"SUCCESS",data:le,message:nt??"request:ok"}),N({code:"SUCCESS",message:"request:ok",data:le})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Lt-=1,Bt.shift()?.()}};return Lt>=Ns?(r=()=>{Fs(Bt,i=>i===o)},Bt.push(o)):o(),t.promise}})(e),{abort(){t.reject(se({code:-1,msg:"request:fail abort"})),r()}}},Us=I();Us.registerCommand("HttpSDK.request",Ds);g("request",{version:"1.0.0"});G();B();v();Re();$();var Qe=I(),Ms=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 O("getLocalStorageAsync",{key:e}),a=Hs(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}}}});Qe.registerCommand("StorageSDK.getItem",Ms);g("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Ls=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=$s(t),d=Vs(t,a);return await O("setLocalStorageAsync",{key:e,data:d,dataType:a}),o=="SUCCESS"?{code:o,message:i}:{code:o,message:`${i}. fallback to native`}}});Qe.registerCommand("StorageSDK.setItem",Ls);g("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Bs=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 O("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:s}:{code:n,message:"[Jolibox SDK] remove item succ"}}});Qe.registerCommand("StorageSDK.removeItem",Bs);g("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var js=S("clearStorage",{async implement(){let e=y.mpId,{response:t}=await K(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});O("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});Qe.registerCommand("StorageSDK.clear",js);g("storage.clear",{version:"1.0.0"});var Mc=S("getStorageInfo",{async implement(){let{data:e}=await O("getStorageInfoAsync");return e}});g("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});var Lc=w("getStorageInfoSync",{implement(){return A("getStorageInfoSync")}}),Js=["string","number","boolean","object",""];function $s(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Js.includes(t)?t:""}function Hs(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""}}v();B();G();var Ks=w("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)),A("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"}});var qs=w("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){A("updateKeyboardSync",e)}});g("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});var Gs=w("hideKeyboard",{implement(){A("hideKeyboardSync")}});g("keyboard.hideKeyboard",{version:"1.0.0"});var jt=I();jt.registerCommand("KeyboardSDK.showKeyboard",Ks);jt.registerCommand("KeyboardSDK.updateKeyboard",qs);jt.registerCommand("KeyboardSDK.hideKeyboard",Gs);v();G();ee();var ce=I(),zs=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(F.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(F.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(s)}}),Ws=S("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await F.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),Ys=S("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(F.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),Qs=S("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await F.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Xs=S("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await F.reportToNative({event:"HistoryUserScore",params:{score:e}})}),Zs=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(F.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(F.reporter({event:"USE_GAME_ITEM"})),r.push(F.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",zs);ce.registerCommand("TaskTrackerSDK.taskFinished",Ws);ce.registerCommand("TaskTrackerSDK.levelUpgrade",Ys);ce.registerCommand("TaskTrackerSDK.historyUserLevel",Qs);ce.registerCommand("TaskTrackerSDK.historyUserScore",Xs);ce.registerCommand("TaskTrackerSDK.taskEvent",Zs);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"}}}});$();B();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"}});var eo=S("login",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};J("onLoginStateChange",({isLogin:i,token:a,uuid:d})=>{d==r&&s({isLogin:i,token:a})});let t=A("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}),V.emit("onLoginComplete",o),o}}),to=S("checkSession",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");return{isLogin:e}}}),cn=I();cn.registerCommand("API.login",eo);cn.registerCommand("API.checkSession",to);v();G();var Xe=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 ln="jolibox-sdk-ads-callbreak-timestamps",Ze=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(ln)??"[]");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(ln,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};$();var dn={ISXT6:{skipInterstitials:!0}};var 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"&&(dn[y.channel??""]?.skipInterstitials??!1)){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,d=u=>()=>{this.track("CallShowAdFn",null),u()},l=u=>{a&&a(d(u))};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 d=n;if(d||(d=this.unitId),!d)throw new Error("slot is required");let l=typeof s=="object"&&Array.isArray(s)?s.join(", "):s,u=document.createElement("ins");if(u.className="adsbygoogle",u.id="jolibox-ads",u.style.display="block",u.setAttribute("data-ad-client",this.clientId),u.setAttribute("data-ad-slot",d),l&&u.setAttribute("data-ad-format",l),o&&u.setAttribute("data-full-width-responsive",o),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(f=>{f.forEach(b=>{if(b.type==="attributes"&&b.attributeName==="data-ad-status"){let _=u.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:_??"null"})}})}).observe(u,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new Ze(n),this.adsActionDetection=new Xe(this.track)}init(t){this.track("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};ee();Re();var tt=I(),rt=new et(U,{get:(e,t)=>K(e,{method:"GET",responseType:"json",appendHostCookie:!0,...t}).then(r=>r.response.data)},()=>!0),ro=w("adInit",{implement:e=>{rt.init(e)}}),no=w("adConfig",{implement:e=>{rt.adConfig(e)}}),so=w("adBreak",{implement:e=>{rt.adBreak(e)}}),oo=w("adUnit",{implement:e=>{rt.adUnit(e)}});tt.registerCommand("AdsSDK.init",ro);tt.registerCommand("AdsSDK.adConfig",no);tt.registerCommand("AdsSDK.adBreak",so);tt.registerCommand("AdsSDK.adUnit",oo);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"});ee();Gr();
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.4-beta.15 clean
3
+ > @jolibox/implement@1.1.4-beta.16 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.4-beta.15 build:esm
7
+ > @jolibox/implement@1.1.4-beta.16 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.4-beta.15",
4
+ "version": "1.1.4-beta.16",
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.4-beta.15",
10
- "@jolibox/types": "1.1.4-beta.15",
9
+ "@jolibox/common": "1.1.4-beta.16",
10
+ "@jolibox/types": "1.1.4-beta.16",
11
11
  "localforage": "1.10.0"
12
12
  },
13
13
  "devDependencies": {
@@ -36,7 +36,8 @@ const env = Object.assign({}, nativeEnv?.() ?? defaultEnv);
36
36
  const wrapContext = () => {
37
37
  const { payloadJson, headerJson } = env.schema.length ? parseUrlQuery(env.schema) : {};
38
38
  const defaultSessionId = `${env.deviceInfo.did}-${new Date().getTime()}`;
39
- const urlParams = new URLSearchParams(env.schema.length ? env.schema : window.location.search);
39
+ const url = new URL(env.schema.length ? env.schema : window.location.href);
40
+ const urlParams = url.searchParams;
40
41
  const defaultGameID = urlParams.get('mpId') ?? urlParams.get('appId') ?? urlParams.get('gameId') ?? '';
41
42
  const sessionId = payloadJson?.sessionId ?? urlParams.get('sessionId') ?? defaultSessionId;
42
43
  const testAdsMode = !!(payloadJson?.testAdsMode ?? urlParams.get('testAdsMode') === 'true');