@jolibox/implement 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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": "876db4e384d8543b66a0b61d8f7b277a36dfb4e0",
|
|
7
|
-
"packages/implement/package.json": "
|
|
7
|
+
"packages/implement/package.json": "76dd4647bf60f8bc580dbef01048686d44f2fa10",
|
|
8
8
|
"packages/implement/src/common/ads/ads-action-detection.ts": "5a7b9f85d7eab9e744f8a9fc7638063f43baa214",
|
|
9
9
|
"packages/implement/src/common/ads/anti-cheating.test.ts": "e2ff3dc6760cfd28d0f8c15703d7fb20d43df583",
|
|
10
10
|
"packages/implement/src/common/ads/anti-cheating.ts": "a3ffb6a78e289e1c0ce45c7f7c0cee000e75e541",
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Nd=Object.create;var Oa=Object.defineProperty,Ud=Object.defineProperties,Bd=Object.getOwnPropertyDescriptor,Md=Object.getOwnPropertyDescriptors,Gd=Object.getOwnPropertyNames,jn=Object.getOwnPropertySymbols,os=Object.getPrototypeOf,ka=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,Jd=Reflect.get;var is=(t,e,n)=>e in t?Oa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,W=(t,e)=>{for(var n in e||(e={}))ka.call(e,n)&&is(t,n,e[n]);if(jn)for(var n of jn(e))ss.call(e,n)&&is(t,n,e[n]);return t},Ce=(t,e)=>Ud(t,Md(e));var ln=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ls=(t,e)=>{var n={};for(var r in t)ka.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&jn)for(var r of jn(t))e.indexOf(r)<0&&ss.call(t,r)&&(n[r]=t[r]);return n};var ne=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ta=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Fd=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Gd(e))!ka.call(t,a)&&a!==n&&Oa(t,a,{get:()=>e[a],enumerable:!(r=Bd(e,a))||r.enumerable});return t};var xa=(t,e,n)=>(n=t!=null?Nd(os(t)):{},Fd(e||!t||!t.__esModule?Oa(n,"default",{value:t,enumerable:!0}):n,t));var cs=(t,e,n)=>Jd(os(t),n,e);var S=(t,e,n)=>new Promise((r,a)=>{var i=l=>{try{s(n.next(l))}catch(d){a(d)}},o=l=>{try{s(n.throw(l))}catch(d){a(d)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,o);s((n=n.apply(t,e)).next())});function zd(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}function Ja(t){return typeof t=="string"}function vs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}function gs(t){return typeof t=="object"&&Array.isArray(t)}function Xd(t){return typeof t=="undefined"}function Yd(t){return Xd(t)||t===null}function Qd(t){return typeof t=="function"}function _s(t){let e=t,n=null,r=function(...a){return n||(n=new e(...a)),n};return r.prototype=e.prototype,r}function ys(t,e,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function r(a,i){for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let s=a[o],l=i[o],d=n(s,l,o,a,i);d!==void 0?a[o]=d:fs(l)&&fs(s)?a[o]=r(Ga({},s),l):Array.isArray(l)&&Array.isArray(s)?a[o]=[...s,...l]:a[o]=l}return a}return r(t,e)}function fs(t){return t&&typeof t=="object"&&t.constructor===Object}function ws(t,e){if(Array.isArray(t))return t.concat(e)}function fn(t,e,n={}){let r=null,a,i,o,{leading:s=!1,trailing:l=!0}=n,d=()=>(o=t.apply(i,a),a=void 0,i=void 0,o),_=function(...f){a=f,i=this;let p=s&&!r;if(r&&clearTimeout(r),r=setTimeout(()=>{r=null,l&&!p&&d()},e),p)return d()};return _.cancel=()=>{r&&clearTimeout(r),r=null,a=i=void 0},_.flush=()=>{if(r)return clearTimeout(r),r=null,d()},_}function tf(t,e){return(...n)=>e(t,...n)}function As(t){return e=>tf(e,function(n,...r){if(typeof n=="function")try{return n.apply(this,r)}catch(a){t(new ef(`${a}`))}})}function cn(t){return(...e)=>{var n,r;((r=(n=globalThis.VConsole)==null?void 0:n[t])!=null?r:globalThis.console[t])(...e)}}function qn(t,e){return e.map(n=>{if(n==="params"&&t[n]){let r=t[n];return Object.keys(r).reduce((a,i)=>(a[i]=String(r[i]),a),{})}return t[n]})}function lf(t){let e=t.location?qn(t.location,ms):null,n=t.target?qn(t.target,ms):null;return qn(Kd(Ga({},t),{location:e,target:n}),of)}function Va(t){let e=t.events.map(r=>lf(r)),n=qn(t.device,sf);return[t.protocolVersion,e,n,t.project]}function cf(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let t=Object.getOwnPropertyDescriptor(window,"localStorage");if(t&&t.get){let r=t.get.call(window);return window.__joliboxLocalStorage__=r,r}if(t=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),t&&t.get)return t.get.call(window);let e=Window.prototype,n=Object.getOwnPropertyDescriptor(e,"localStorage");if(n&&n.get){let r=n.get.call(window);return window.__joliboxLocalStorage__=r,r}return localStorage}catch(t){return console.warn("Failed to get original localStorage, fallback to default implementation",t),localStorage}}function Wa(t,e,n){let r=window.location.hostname,a=r.split("."),i=n?e:t;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r))return`${i}.jolibox.com`;if(a.length>=2){let o=a.slice(-2).join(".");if(o==="jolibox.com"||o==="pico-game.com"||o==="joyslite.com")return`${i}.${o}`}return`${i}.jolibox.com`}function Rs(t){return Wa("app","stg-app",t)}function Gt(t){return`https://${Wa("api","stg-api",t)}`}function vf(t){return Wa("collect","stg-collect",t)}function Os(t){return`https://${vf(t)}`}function wf(t){return new Promise(e=>ks(t)(e))}function ks(t){return(e,n=null)=>{let r=!1;return t(a=>{if(!r)return r=!0,e.call(n,a)},null)}}function bf(t,e){return(n=>{let r,a={onWillAddFirstListener(){r=n(i.fire,i)}},i=new dn(a);return i.event})((n,r=null)=>t(a=>e(a)&&n.call(r,a),null))}function If(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++)Af(t[r],e[r])}function Af(t,e){if(Ja(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(Qd(e)){try{if(t instanceof e)return}catch(n){}if(!Yd(t)&&t.constructor===e||e.length===1&&e.call(void 0,t)===!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 Sf(){return typeof globalThis!="undefined"?globalThis[Ts]:void 0}function Cf(t){typeof globalThis!="undefined"&&(globalThis[Ts]=t)}function we(t=!1){let e=Sf();if(!t&&e)return e;let n=new Vn,r=new Ba,a={registerCommand(i,o,s){n.registerCommand({id:i,handler:o,metadata:s})},executeCommand(i,...o){return r.executeCommand(i,...o)},excuteCommandSync(i,...o){return r.executeCommandThowErr(i,...o)}};return Cf(a),a}var Ma,Hd,jd,qd,us,Vd,$d,ds,Ga,Kd,Wd,ps,bt,Zd,Fa,Ha,bs,Es,ef,Is,$n,Kn,ja,Ne,Da,nf,qa,hs,rf,Et,Mt,af,ms,of,sf,je,Bt,uf,Re,df,ff,hf,Ss,$a,Ka,mf,pf,Cs,It,La,ie,gf,_f,un,dn,$e,Ua,yf,Pa,Ef,pt,Vn,Ba,Ts,q=ne(()=>{"use strict";Ma=Object.defineProperty,Hd=Object.defineProperties,jd=Object.getOwnPropertyDescriptor,qd=Object.getOwnPropertyDescriptors,us=Object.getOwnPropertySymbols,Vd=Object.prototype.hasOwnProperty,$d=Object.prototype.propertyIsEnumerable,ds=(t,e,n)=>e in t?Ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ga=(t,e)=>{for(var n in e||(e={}))Vd.call(e,n)&&ds(t,n,e[n]);if(us)for(var n of us(e))$d.call(e,n)&&ds(t,n,e[n]);return t},Kd=(t,e)=>Hd(t,qd(e)),Wd=(t,e)=>{for(var n in e)Ma(t,n,{get:e[n],enumerable:!0})},ps=(t,e,n,r)=>{for(var a=r>1?void 0:r?jd(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(a=(r?o(e,n,a):o(a))||a);return r&&a&&Ma(e,n,a),a},bt=(t,e,n)=>new Promise((r,a)=>{var i=l=>{try{s(n.next(l))}catch(d){a(d)}},o=l=>{try{s(n.throw(l))}catch(d){a(d)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,o);s((n=n.apply(t,e)).next())});if(typeof window!="undefined"&&!window.AbortController){let t=function(){this.signal=new e};t.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let n=new Event("abort");this.signal.dispatchEvent(n)};let e=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(e.prototype,"aborted",{get:function(){return this._aborted}}),e.prototype.addEventListener=function(n,r){this._eventListeners[n]||(this._eventListeners[n]=[]),this._eventListeners[n].push(r)},e.prototype.removeEventListener=function(n,r){if(!this._eventListeners[n])return;let a=this._eventListeners[n].indexOf(r);a!==-1&&this._eventListeners[n].splice(a,1)},e.prototype.dispatchEvent=function(n){if(this._eventListeners[n.type])for(let r of this._eventListeners[n.type])r.call(this,n)},window.AbortController=t,window.AbortSignal=e}Zd=(t=>(t[t.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",t[t.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",t[t.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",t[t.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",t[t.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",t[t.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",t[t.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",t[t.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",t))(Zd||{}),Fa=class extends Error{constructor(t){if(typeof t=="string"){super(t),this.priority="P1";return}super(t.message),this.priority="P1",this.stack=t.stack,this.raw=t}},Ha=class extends Fa{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},bs=class extends Fa{constructor(){super(...arguments),this.kind="USER_ERROR"}},Es=class extends bs{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},ef=class extends bs{constructor(t,e,n){super(t),this.message=t,this.errNo=e,this.name="USER_CUSTOM_ERROR",this.errMsg=t,n&&(this.extra=Object.assign({},this.extra,n))}},Is=class extends Ha{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},$n=class extends Ha{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Kn=class extends Fa{constructor(t,e,n,r,a){super(t),this.message=t,this.code=e,this.kind="API_ERROR",this.name="API_ERROR",n&&(this.errorType=n),r!==void 0&&(this.stack=r),a&&(this.priority=a)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},ja=class extends Ha{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Ne={log:cn("log"),warn:cn("warn"),info:cn("info"),error:cn("error"),debug:cn("debug")};Object.assign(globalThis,{logger:Ne});Da=Symbol.for("Jolibox.canIUseMap"),nf={};globalThis[Da]||(globalThis[Da]=nf);qa={get config(){return globalThis[Da]}},hs=Symbol.for("Jolibox.canIUseMap.native"),rf={};globalThis[hs]||(globalThis[hs]=rf);Et=(t=>(t[t.Other=0]="Other",t[t.Route=1]="Route",t[t.Click=2]="Click",t[t.View=3]="View",t[t.Expose=4]="Expose",t[t.Swipe=5]="Swipe",t[t.Input=6]="Input",t[t.Select=7]="Select",t[t.SwitchOn=8]="SwitchOn",t[t.SwitchOff=9]="SwitchOff",t[t.Submit=10]="Submit",t[t.Scroll=11]="Scroll",t[t.Hide=12]="Hide",t[t.System=1e3]="System",t[t.ErrorTrace=1001]="ErrorTrace",t[t.UserDefined=1002]="UserDefined",t))(Et||{}),Mt=(t=>(t.MiniGame="mini-game",t.MiniDrama="mini-drama",t.App="app",t.WebSDK="web-sdk",t.AppSDK="app-sdk",t))(Mt||{}),af=(t=>(t[t.App=0]="App",t[t.H5=1]="H5",t[t.Weapp=2]="Weapp",t[t.Alipay=3]="Alipay",t[t.Gcash=4]="Gcash",t[t.Dana=5]="Dana",t[t.Umma=6]="Umma",t[t.WebSDK=1e3]="WebSDK",t[t.AppSDK=1001]="AppSDK",t[t.Other=9999]="Other",t))(af||{}),ms=["name","params"],of=["name","type","location","target","extra","timestamp","userId"],sf=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];je=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)});cf();Bt=typeof window=="undefined",uf=()=>!Bt&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Re={isiOS:!Bt&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let t=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3]||"0",10)]},isAndroid:!Bt&&navigator.userAgent.includes("Android"),isMac:!Bt&&navigator.userAgent.includes("Mac"),isFacebook:!Bt&&navigator.userAgent.includes("FB_IAB"),isPC:!Bt&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},df=()=>Re.isiOS?"iOS":Re.isAndroid?"Android":Re.isMac?"Mac":Re.isFacebook?"Facebook":"PC",ff="device_id",hf="advertising_id",Ss=t=>(window.__joliboxLocalStorage__.getItem(t)||window.__joliboxLocalStorage__.setItem(t,je()),window.__joliboxLocalStorage__.getItem(t)),$a=()=>new URLSearchParams(window.location.search).get("deviceId")||Ss(ff),Ka=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ss(hf),mf=t=>t.charAt(0).toUpperCase()+t.slice(1),pf=()=>{var t;let e=new URLSearchParams(window.location.search);return mf((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Cs=t=>{if(uf())return window.navigator.userAgent;let e="JoliboxWebSDK",n=df(),r=navigator.language,a=$a(),i=Ka();return`${e} (${pf()}${n}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${a} adid/${i} version/${t||""}`};It=class{constructor(t,e={}){this.requestAdapter=t,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=Ga({duration:10*60*1e3,timeout:3e3,keyGenerator:(n,r)=>n,consistencyChecker:()=>!0},e)}request(t,e){return bt(this,null,function*(){let n=this.config.keyGenerator(t,e),r=this.pendingRequests.get(n);if(r)return console.log(`[RequestCacheService] Reusing pending request for ${t}`),r;let a=this.requestInternal(t,e),i=this.createTimeoutPromise(),o=Promise.race([a,i]).catch(s=>bt(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(n);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${t}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}throw s}));this.pendingRequests.set(n,o),a.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${t}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${t}:`,s)});try{return yield o}finally{this.pendingRequests.delete(n)}})}requestInternal(t,e){return bt(this,null,function*(){var n,r,a,i;let o=this.config.keyGenerator(t,e),s=++this.requestSequence,l=this.getValidCachedData(o);if(console.log("[RequestCacheService] requestInternal start",t,"cached:",l),l){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let f=yield this.requestAdapter.execute(t,e),p=this.requestAdapter.extractRealTimeData(f),h=(r=(n=this.requestAdapter).extractCacheableData)==null?void 0:r.call(n,f);return h&&!this.config.consistencyChecker(l,h)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${t}`),this.setCachedDataWithSequence(o,h,s),f):this.requestAdapter.mergeData(l,p)}catch(f){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${t}:`,f),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}return console.log(`[RequestCacheService] use cache for ${t}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${t} (sequence: ${s})`);let d=yield this.requestAdapter.execute(t,e),_=(i=(a=this.requestAdapter).extractCacheableData)==null?void 0:i.call(a,d);return _&&this.setCachedDataWithSequence(o,_,s),d})}createTimeoutPromise(){return new Promise((t,e)=>{setTimeout(()=>{e(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(t){let e=this.cache.get(t);return e?Date.now()>e.expiresAt?(this.cache.delete(t),null):e.data:null}setCachedDataWithSequence(t,e,n,r){let a=this.cache.get(t);if(a&&a.sequence>n){console.log(`[RequestCacheService] Ignoring stale cache update for ${t} (current: ${a.sequence}, incoming: ${n})`);return}let i=Date.now();this.cache.set(t,{data:JSON.parse(JSON.stringify(e)),timestamp:i,expiresAt:i+this.config.duration,key:t,sequence:n,metadata:r}),this.cacheSequences.set(t,n),console.log(`[RequestCacheService] Updated cache for ${t} with sequence ${n}`)}refreshCache(t,e){return bt(this,null,function*(){let n=this.config.keyGenerator(t,e);return this.cache.delete(n),this.request(t,e)})}forceRequest(t,e){return bt(this,null,function*(){var n,r;let a=this.config.keyGenerator(t,e),i=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${t} (sequence: ${i})`);let o=yield this.requestAdapter.execute(t,e),s=(r=(n=this.requestAdapter).extractCacheableData)==null?void 0:r.call(n,o);return s&&(this.setCachedDataWithSequence(a,s,i),console.log(`[RequestCacheService] Force updated cache for ${t}`)),o})}warmupCache(t,e){return bt(this,null,function*(){let n=this.config.keyGenerator(t,e);if(this.pendingRequests.has(n)){console.log(`[RequestCacheService] Skipping warmup for ${t} - request in progress`);return}if(this.hasValidCache(n)){console.log(`[RequestCacheService] Skipping warmup for ${t} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${t}`),yield this.forceRequest(t,e)}catch(r){console.warn(`[RequestCacheService] Cache warmup failed for ${t}:`,r)}})}clearCache(t){t?(this.cache.delete(t),this.cacheSequences.delete(t),this.pendingRequests.delete(t),console.log(`[RequestCacheService] Cleared cache for ${t}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let t=Date.now();for(let[e,n]of this.cache)t>n.expiresAt&&(this.cache.delete(e),this.cacheSequences.delete(e));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let t=Date.now(),e=0,n=0;for(let r of this.cache.values())t>r.expiresAt?n++:e++;return{cacheCount:this.cache.size,validCount:e,expiredCount:n,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(t){let e=this.cache.get(t);return e?Date.now()<=e.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(t){return this.pendingRequests.has(t)}getCacheSequence(t){return this.cacheSequences.get(t)}},La=class Na{constructor(e){this.element=e,this.next=Na.Undefined,this.prev=Na.Undefined}};La.Undefined=new La(void 0);ie=La,gf=class{constructor(){this._first=ie.Undefined,this._last=ie.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ie.Undefined}clear(){let t=this._first;for(;t!==ie.Undefined;){let e=t.next;t.prev=ie.Undefined,t.next=ie.Undefined,t=e}this._first=ie.Undefined,this._last=ie.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let n=new ie(t);if(this._first===ie.Undefined)this._first=n,this._last=n;else if(e){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==ie.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==ie.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==ie.Undefined&&t.next!==ie.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===ie.Undefined&&t.next===ie.Undefined?(this._first=ie.Undefined,this._last=ie.Undefined):t.next===ie.Undefined?(this._last=this._last.prev,this._last.next=ie.Undefined):t.prev===ie.Undefined&&(this._first=this._first.next,this._first.prev=ie.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==ie.Undefined;)yield t.element,t=t.next}},_f=0,un=class{constructor(t){this.value=t,this.id=_f++}},dn=class{constructor(t){this.options=t,this._size=0}dispose(t){var e,n;this._disposed||(this._disposed=!0,this._listeners&&(t?(this._listeners instanceof un&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(r=>(r==null?void 0:r.value)===t)):(this._listeners=void 0,this._size=0)),(n=(e=this.options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e))}get event(){var t;return(t=this._event)!=null||(this._event=(e,n)=>{var r,a,i,o,s,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};n&&(e=e.bind(n));let d=new un(e);return this._listeners?this._listeners instanceof un?this._listeners=[this._listeners,d]:this._listeners.push(d):((a=(r=this.options)==null?void 0:r.onWillAddFirstListener)==null||a.call(r,this),this._listeners=d,(o=(i=this.options)==null?void 0:i.onDidFirstListener)==null||o.call(i,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var _,f,p,h;if(!this._disposed){if(this._listeners instanceof un)this._listeners.id===d.id&&(this._listeners=void 0,this._size=0,(f=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||f.call(_));else if(this._listeners){let b=this._listeners.indexOf(d);b>=0&&(this._listeners.splice(b,1),this._size--,this._size===0&&((h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p)))}}}}),this._event}_deliver(t,e){var n;if(!t)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){t.value(e);return}try{t.value(e)}catch(a){r(a)}}fire(t){this._listeners&&(this._listeners instanceof un?this._deliver(this._listeners,t):this._listeners.forEach(e=>this._deliver(e,t)))}hasListeners(){return this._size>0}},$e=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(t,e,n=!0){var r;let a=(r=this.listeners.get(t))!=null?r:new dn,i=l=>e(...l.args),o=a.event(i);this.listerHandlerMap.set(e,{handler:i,dispose:o}),this.listeners.set(t,a);let s=this.cachedEventQueue.get(t);if(s&&n)for(let l of s)e(...l.args)}flushCachedEvent(t){t?this.cachedEventQueue.delete(t):this.cachedEventQueue.clear()}off(t,e){let n=this.listerHandlerMap.get(e);n&&(n.dispose(),this.listerHandlerMap.delete(e))}emit(t,...e){let n=this.listeners.get(t),r=this.cachedEventQueue.get(t);r||(r=new gf,this.cachedEventQueue.set(t,r)),r.push({args:e}),n&&n.fire({event:t,args:e})}once(t,e){let n=(...r)=>{e(...r),this.off(t,n)};this.on(t,n,!1)}},Ua={};Wd(Ua,{None:()=>yf,filter:()=>bf,once:()=>ks,toPromise:()=>wf});yf=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Pa=Symbol.for("Jolibox.hostEmitter"),Ef=()=>{let t=new $e;return globalThis[Pa]||(globalThis[Pa]={on:t.on.bind(t),off:t.off.bind(t),emit:t.emit.bind(t),once:t.once.bind(t)}),globalThis[Pa]},pt=Ef();Vn=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new dn,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(t){if(!t)throw new Error("invalid command");if(t.metadata&&Array.isArray(t.metadata.args)){let n=[];for(let a of t.metadata.args)n.push(a.constraint);let r=t.handler;t.handler=function(...a){return If(a,n),r(...a)}}let{id:e}=t;this._commands.get(e)&&console.info(`[Jolibox SDK] duplicated command is registered ${e}`),this._commands.set(e,t),this._onDidRegisterCommand.fire(e)}getCommand(t){return this._commands.get(t)}getCommands(){let t=new Map;for(let e of this._commands.keys()){let n=this.getCommand(e);n&&t.set(e,n)}return t}};Vn=ps([_s],Vn);Ba=class{constructor(){this._onWillExecuteCommand=new dn,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new dn,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Vn,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=zd(3e4)),this._starActivation}executeCommand(t,...e){return bt(this,null,function*(){return this.registry.getCommand(t)?this._tryExecuteCommand(t,e):(yield Promise.all([Promise.race([this._activateStar(),Ua.toPromise(Ua.filter(this.registry.onDidRegisterCommand,n=>n===t))])]),this._tryExecuteCommand(t,e))})}executeCommandThowErr(t,...e){if(!this.registry.getCommand(t))throw new Error(`command '${t}' not found`);let n=this.registry.getCommand(t);this._onWillExecuteCommand.fire({commandId:t,args:e});let r=this.invokeFunction(n.handler,...e);return this._onDidExecuteCommand.fire({commandId:t,args:e}),r}_tryExecuteCommand(t,e){let n=this.registry.getCommand(t);if(!n)return Promise.reject(new Error(`command '${t}' not found`));try{this._onWillExecuteCommand.fire({commandId:t,args:e});let r=this.invokeFunction(n.handler,...e);return this._onDidExecuteCommand.fire({commandId:t,args:e}),Promise.resolve(r)}catch(r){return Promise.reject(r)}}invokeFunction(t,...e){let n=!1;try{return t(...e)}finally{n=!0}}};Ba=ps([_s],Ba);Ts=Symbol.for("Jolibox.commands")});function Ue(t,e={}){za.emit("ERROR_REPORT",{error:t,options:e})}var za,At,et=ne(()=>{"use strict";q();q();za=new $e,At=new $e;Ue.debounce=fn(Ue,50,{leading:!0})});var Xa,Rf,xs,Ps,Ds=ne(()=>{"use strict";q();et();Xa=t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),r=atob(e+n);try{return JSON.parse(r)}catch(a){return{}}},Rf=t=>{let e=JSON.stringify(t);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},xs=t=>{var e;try{let a=(e=new URL(t).searchParams.get("joliSource"))==null?void 0:e.split(".");if(a!=null&&a.length){let[i,o,s]=a;return{headerJson:Xa(i),payloadJson:Xa(o),signature:Xa(s)}}else throw"joli_source is missing"}catch(n){return Ue(new Is(`${t} not a valid schema: ${n}`)),{headerJson:{},payloadJson:{},signature:{}}}},Ps=(t,e)=>{let n=e.split(".");if(n&&n.length===3){let r=n[0],a=Rf(t),i=n[2];return`${r}.${a}.${i}`}return e}});var Of,Wn,Ls,Ya=ne(()=>{"use strict";q();Of="1.3.3",Wn=()=>Of,Ls=()=>{let t=Wn();return`${Cs(t)}`}});function Za(t,e){return(document==null?void 0:document.head.querySelector(`meta[name="${t}"][content="${e}"]`))!==null}var kf,Ns,Qa,Us,oe,Tf,L,fe=ne(()=>{"use strict";q();Ds();Ya();q();kf={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:$a(),adId:Ka(),pixelRatio:window.devicePixelRatio||1,platform:Re.isAndroid?"android":Re.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Wn()},schema:window.location.href,platform:Re.isAndroid?"android":Re.isiOS?"ios":"h5"},Qa=(Ns=globalThis.joliboxJSCore)==null?void 0:Ns.env,oe=Object.assign({},(Us=Qa==null?void 0:Qa())!=null?Us:kf);Tf=()=>{var E,C,w,O,k,M,B,I,D,J,j;let{payloadJson:t,headerJson:e,signature:n}=oe.schema.length?xs(oe.schema):{},r=`${oe.deviceInfo.did}-${new Date().getTime()}`,i=new URL(oe.schema.length?oe.schema:window.location.href).searchParams,o=(w=(C=(E=i.get("mpId"))!=null?E:i.get("appId"))!=null?C:i.get("gameId"))!=null?w:"",s=(M=(k=(O=oe.clientSessionId)!=null?O:t==null?void 0:t.sessionId)!=null?k:i.get("sessionId"))!=null?M:r,l=!!((I=(B=t==null?void 0:t.testAdsMode)!=null?B:t==null?void 0:t.__testAdsMode)!=null?I:i.get("testAdsMode")==="true"),d=(j=(J=(D=t==null?void 0:t.joliboxEnv)!=null?D:t==null?void 0:t.__joliboxEnv)!=null?J:i.get("joliboxEnv"))!=null?j:"production",_=d==="staging",f=e==null?void 0:e.channel,h=new URL(window.location.href).searchParams,b=t==null?void 0:t.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return _},get testAdsMode(){return l},get joliboxEnv(){return d},get joliSource(){var N,G;return(G=(N=h.get("joliSource"))!=null?N:i.get("joliSource"))!=null?G:null},get mpId(){var N;return(N=o!=null?o:t==null?void 0:t.id)!=null?N:""},get mpVersion(){var N;return(N=e==null?void 0:e.ver)!=null?N:Wn()},get mpType(){var N,G;return(G=(N=e==null?void 0:e.__mpType)!=null?N:t==null?void 0:t.__mpType)!=null?G:"game"},get platform(){var N;return((N=oe.platform)!=null?N:oe.deviceInfo.platform).toLowerCase()},get deviceInfo(){return oe.deviceInfo},get sdkInfo(){return oe.sdkInfo},get hostInfo(){return oe.hostInfo},get hostUserInfo(){return oe.hostUserInfo},get sessionId(){var N,G;return(G=(N=oe.clientSessionId)!=null?N:s)!=null?G:r},get channel(){return f},get webviewId(){var N;return(N=oe.webviewId)!=null?N:-1},get shouldInterupt(){return b},get from(){return t==null?void 0:t.__from},get baseApiHost(){return Rs(_)},get adId(){var N;return(N=oe.deviceInfo.adId)!=null?N:oe.deviceInfo.did},get language(){return oe.deviceInfo.lang},get sdkEnvironment(){return Za("dlightek","jolibox")?"dlightek":i.get("huaweiQuick")==="true"?"huaweiQuick":Za("gamedistribution","jolibox")?"gamedistribution":Za("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var X,Z,He;let N=(X=oe.deviceInfo.pixelRatio)!=null?X:1,G=(Z=oe.deviceInfo.statusBarHeight)!=null?Z:t==null?void 0:t.__androidStatusBarHeight,F=(He=oe.deviceInfo.navigationBarHeight)!=null?He:t==null?void 0:t.__androidNavigationBarHeight;return{statusBarHeight:G!==void 0?G/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,G;return(G=(N=oe.abValues)==null?void 0:N.split(","))!=null?G:[]},get mpInfo(){var N;return(N=oe.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{ys(oe,N,ws)},encodeJoliSourceQuery:N=>{var G,F;return e&&n?Ps(W(W({},t),N),(G=i.get("joliSource"))!=null?G:""):(F=i.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{b=!1}}},L=Tf()});var ei,Ms,xf,Pf,Bs,Df,Gs=ne(()=>{"use strict";q();et();fe();q();ei=!1,Ms=(t,e)=>t==null?!1:e in t,xf=t=>Ms(t,"kind"),Pf=t=>{let e=t.toLowerCase().split("_");return e[0]+e.slice(1).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Bs=(t,e={},n)=>{var i,o,s;let r={user_id:(o=(i=L.hostUserInfo)==null?void 0:i.uid)!=null?o:"",device_id:(s=L.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:Pf(t.name)},a=Ce(W({},r),{env:e.environment,isFromUser:n});n?At.emit("GLOBAL_USER_ERROR",t,a):At.emit("GLOBAL_ERROR",t,a)},Df=t=>Ms(t,"kind")&&t.kind==="USER_ERROR";za.on("ERROR_REPORT",({error:t,options:e})=>{if(ei)return;ei=!0;let n=xf(t)&&t.raw?t.raw:t;try{let r=Df(t);Bs(t,e,r)}catch(r){let a=r instanceof Error?r.message:String(r),i=new ja(`${a}, origin error: ${n.message}`);Ne.error(i),Bs(new ja(i.message),{environment:e.environment},!1)}finally{ei=!1}})});var ti,ni=ne(()=>{"use strict";et();q();et();ti=t=>new Es(t)});function Js(t,e){let n=(r,a,i)=>{let d=a!=null?a:{},{eventType:o}=d,s=ls(d,["eventType"]),l=Ce(W({tag:r,eventType:i!=null?i:o!=null?o:Et.Other},e),{extra:W({},s)});r=="globalJsError"?Ue(new $n(JSON.stringify(l))):t("systemLog",l,L.webviewId)};return n.debounce=fn(n,500,{leading:!0}),n}function Fs(t){let e=(n,r,a)=>{var s;let i=(s=a&&JSON.stringify(a))!=null?s:0,o={speed_value_type:n,total_duration:r};i&&Object.assign(o,{extra:i}),t("joliboxSpeedAnalysis",o)};return e.debounce=fn(e,500,{leading:!0}),e}var Hs=ne(()=>{"use strict";q();q();et();fe()});function js(t,e){let n=Js(t,e),r=Fs(n);return{track:n,trackPerformance:r}}var qs=ne(()=>{"use strict";Hs()});var ri=ne(()=>{"use strict"});var zn,Vs=ne(()=>{"use strict";fe();q();q();zn=class{constructor(e){this.apiHost=e;this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return S(this,null,function*(){let n=`${this.apiHost}/api/fe-configs/js-sdk/samples-config`,r=yield(yield fetch(n)).json();this.samplesConfig=r})}checkIsSampled(e){if(!this.samplesConfig)return!1;let{samples:n}=this.samplesConfig;for(let[r,a]of Object.entries(n))if(a.includes(e.name))return Math.floor(Math.random()*101)<parseFloat(r);return!1}getDevice(){var r,a,i,o,s;let{nativeSDKVersion:e,jssdkVersion:n}=L.sdkInfo;return{platform:1e3,os:L.deviceInfo.platform,appVersion:(r=e!=null?e:n)!=null?r:"1.0.0",appId:(i=(a=L.hostInfo)==null?void 0:a.aid)!=null?i:"1",model:(o=L.deviceInfo.model)!=null?o:"UnknownModel",brand:(s=L.deviceInfo.brand)!=null?s:"UnknownBrand",uuid:L.deviceInfo.did,jsSdkVersion:n,extra:{}}}getLocation(){let e=new URLSearchParams(window.location.search),n={};return e.forEach((r,a)=>{n[a]=r}),{name:"GamePage",params:n}}trackEvent(e,n,r){return S(this,null,function*(){if(this.checkIsSampled(e))return;let a=e.location?e.location:yield this.getLocation(),i=e.target||null,o=e.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let s=this.deviceInfo,d={protocolVersion:"1.0.0",events:[Ce(W({},e),{location:a,target:i,extra:o,timestamp:Date.now(),userId:null})],device:s,project:n};try{r?yield this.doReport(Va(d),r):yield this.doReport(Va(d))}catch(_){Ne.log("[Jolibox SDK] report API error",_)}})}}});var ai=ne(()=>{"use strict";qs();ri();Vs()});var ii,$s,tt,Xn,qe,Jt=ne(()=>{"use strict";Ya();fe();q();ii=t=>{let e=new AbortController;return setTimeout(()=>e.abort(),t),e.signal};($s=AbortSignal.timeout)!=null||(AbortSignal.timeout=ii);tt=class t{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20;this.getNetworkStatus=()=>this.networkRequests.length===0?!0:this.networkRequests.filter(r=>r).length/this.networkRequests.length>=.6}static getInstance(){return t._instance||(t._instance=new t),t._instance}create(e){let n=new Xn(e);return t.getInstance().httpClients.add(n),n}recordNetworkRequest(e){this.networkRequests.push(e),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}},Xn=class{constructor(e){this.xua=Ls();this.getJoliSource=()=>L.joliSource;var r;let n=Gt(L.testMode);this.baseUrl=(r=e==null?void 0:e.baseUrl)!=null?r:n}get(e,n){return S(this,null,function*(){try{let{query:r,timeout:a}=n!=null?n:{},{headers:i}=n!=null?n:{},o=r?new URLSearchParams(r):null,s=o==null?void 0:o.toString(),l=`${this.baseUrl}${e}${s?`?${s}`:""}`,d=this.xua,_=this.getJoliSource();i=Object.assign({},i!=null?i:{},d?{"x-user-agent":d}:{},_?{"x-joli-source":_}:{});let f=yield fetch(l,{method:"GET",headers:i,credentials:"include",signal:ii(a!=null?a:3e4)});return tt.getInstance().recordNetworkRequest(!0),yield f.json()}catch(r){throw tt.getInstance().recordNetworkRequest(!1),r}})}post(e,n){return S(this,null,function*(){try{let{data:r,query:a,timeout:i}=n!=null?n:{},{headers:o}=n!=null?n:{},s=a?new URLSearchParams(a):null,l=s==null?void 0:s.toString(),d=`${this.baseUrl}${e}${l?`?${l}`:""}`,_=this.xua,f=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},f?{"x-joli-source":f}:{},{"x-os-type":Re.isAndroid?"ANDROID":Re.isiOS?"IOS":"PC"},{"x-runtime-type":"WEB"});let p=yield fetch(d,{method:"POST",headers:o,body:JSON.stringify(r),signal:ii(i!=null?i:3e4),credentials:"include"});tt.getInstance().recordNetworkRequest(!0);let h=p.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return p.blob()}catch(b){return yield p.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return p.formData()}catch(b){return yield p.text()}if(h!=null&&h.includes("application/json"))try{return yield p.json()}catch(b){return yield p.text()}return p}catch(r){throw tt.getInstance().recordNetworkRequest(!1),r}})}put(e,n){return S(this,null,function*(){try{let{data:r,query:a,timeout:i}=n!=null?n:{},{headers:o}=n!=null?n:{},s=a?new URLSearchParams(a):null,l=s==null?void 0:s.toString(),d=`${this.baseUrl}${e}${l?`?${l}`:""}`,_=this.xua,f=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},f?{"x-joli-source":f}:{});let p=yield fetch(d,{method:"PUT",headers:o,credentials:"include",body:JSON.stringify(r!=null?r:{})});if(!p.ok)throw tt.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${p.status}`);return tt.getInstance().recordNetworkRequest(!0),yield p.json()}catch(r){throw console.error("Error:",r),r}})}};window.JoliboxHttpClient=Xn;qe=tt.getInstance()});var oi,Yn,si=ne(()=>{"use strict";fe();ai();Jt();q();oi=class extends zn{constructor(){super(...arguments);this.httpClient=qe.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var n;return Os((n=L.testMode)!=null?n:!1)}doReport(n){this.httpClient.post("/report",{data:n,timeout:5e3}).catch(r=>{console.info("report error",r)})}},Yn=new oi(Gt(L.testMode))});var Lf,Ks=ne(()=>{"use strict";Gs();q();ni();q();si();fe();Lf=(t,e)=>{var a,i,o;let n={message:e.message,stack:(a=e.stack)!=null?a:"",errorType:e.name,source:0},r={name:t,type:Et.ErrorTrace,location:null,target:null,extra:n,timestamp:Date.now(),userId:(o=(i=L.hostUserInfo)==null?void 0:i.uid)!=null?o:null};Yn.trackEvent(r,Mt.WebSDK)};At.on("GLOBAL_ERROR",(t,e)=>{Lf(e.tag,t)});At.on("GLOBAL_USER_ERROR",(t,e)=>{Ne.log("UserError",t,e)})});var Qn,Ws=ne(()=>{"use strict";Qn=class{constructor(e,n){this.eventEmitter=e;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(e,n)=>{window.parent&&window.parent.postMessage({type:e,data:n},"*")};this.playGame=e=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:e}}),this.tracker("PlayGame",{duration:e}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:e}))};this.timer=this.createRAFTimer(e=>{this.playGame(e)});this.interval=n!=null?n:5*1e3,e.on("visible",r=>{this.visible=r})}start(e){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:e!=null?e:0}}),this.tracker("OpenGame",{duration:e!=null?e:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:e!=null?e:0}),this.timer.start()}close(e){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:e}}),this.tracker("CloseGame",{duration:e}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:e}),this.timer.stop()}createRAFTimer(e){let n=Date.now(),r,a,i=!1,o=0,s=()=>{if(!i)return;let h=Date.now(),b=h-n;b>=this.interval&&(this.visible&&(o+=Math.min(b,this.interval+1e3),e(o)),n=h),r=requestAnimationFrame(s)},l=()=>{_(),n=Date.now(),a=window.setInterval(()=>{if(!i)return;let h=Date.now();h-n>=this.interval&&(n=h)},this.interval)},d=()=>{f(),n=Date.now(),r=requestAnimationFrame(s)},_=()=>{r&&(cancelAnimationFrame(r),r=0)},f=()=>{a&&(clearInterval(a),a=0)};this.eventEmitter.on("visible",h=>{i&&(console.log("visible",h),h?d():l())});let p=this.visible;return{start(){i||(i=!0,p?d():l())},stop(){i=!1,_(),f()}}}}});var zs,Xs=ne(()=>{"use strict";zs=`-----BEGIN PUBLIC KEY-----
|
|
1
|
+
var Nd=Object.create;var Oa=Object.defineProperty,Ud=Object.defineProperties,Bd=Object.getOwnPropertyDescriptor,Md=Object.getOwnPropertyDescriptors,Gd=Object.getOwnPropertyNames,jn=Object.getOwnPropertySymbols,os=Object.getPrototypeOf,ka=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,Jd=Reflect.get;var is=(t,e,n)=>e in t?Oa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,W=(t,e)=>{for(var n in e||(e={}))ka.call(e,n)&&is(t,n,e[n]);if(jn)for(var n of jn(e))ss.call(e,n)&&is(t,n,e[n]);return t},Ce=(t,e)=>Ud(t,Md(e));var ln=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ls=(t,e)=>{var n={};for(var r in t)ka.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&jn)for(var r of jn(t))e.indexOf(r)<0&&ss.call(t,r)&&(n[r]=t[r]);return n};var ne=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ta=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Fd=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Gd(e))!ka.call(t,a)&&a!==n&&Oa(t,a,{get:()=>e[a],enumerable:!(r=Bd(e,a))||r.enumerable});return t};var xa=(t,e,n)=>(n=t!=null?Nd(os(t)):{},Fd(e||!t||!t.__esModule?Oa(n,"default",{value:t,enumerable:!0}):n,t));var cs=(t,e,n)=>Jd(os(t),n,e);var S=(t,e,n)=>new Promise((r,a)=>{var i=l=>{try{s(n.next(l))}catch(d){a(d)}},o=l=>{try{s(n.throw(l))}catch(d){a(d)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,o);s((n=n.apply(t,e)).next())});function zd(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}function Ja(t){return typeof t=="string"}function vs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}function gs(t){return typeof t=="object"&&Array.isArray(t)}function Xd(t){return typeof t=="undefined"}function Yd(t){return Xd(t)||t===null}function Qd(t){return typeof t=="function"}function _s(t){let e=t,n=null,r=function(...a){return n||(n=new e(...a)),n};return r.prototype=e.prototype,r}function ys(t,e,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function r(a,i){for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let s=a[o],l=i[o],d=n(s,l,o,a,i);d!==void 0?a[o]=d:fs(l)&&fs(s)?a[o]=r(Ga({},s),l):Array.isArray(l)&&Array.isArray(s)?a[o]=[...s,...l]:a[o]=l}return a}return r(t,e)}function fs(t){return t&&typeof t=="object"&&t.constructor===Object}function ws(t,e){if(Array.isArray(t))return t.concat(e)}function fn(t,e,n={}){let r=null,a,i,o,{leading:s=!1,trailing:l=!0}=n,d=()=>(o=t.apply(i,a),a=void 0,i=void 0,o),_=function(...f){a=f,i=this;let p=s&&!r;if(r&&clearTimeout(r),r=setTimeout(()=>{r=null,l&&!p&&d()},e),p)return d()};return _.cancel=()=>{r&&clearTimeout(r),r=null,a=i=void 0},_.flush=()=>{if(r)return clearTimeout(r),r=null,d()},_}function tf(t,e){return(...n)=>e(t,...n)}function As(t){return e=>tf(e,function(n,...r){if(typeof n=="function")try{return n.apply(this,r)}catch(a){t(new ef(`${a}`))}})}function cn(t){return(...e)=>{var n,r;((r=(n=globalThis.VConsole)==null?void 0:n[t])!=null?r:globalThis.console[t])(...e)}}function qn(t,e){return e.map(n=>{if(n==="params"&&t[n]){let r=t[n];return Object.keys(r).reduce((a,i)=>(a[i]=String(r[i]),a),{})}return t[n]})}function lf(t){let e=t.location?qn(t.location,ms):null,n=t.target?qn(t.target,ms):null;return qn(Kd(Ga({},t),{location:e,target:n}),of)}function Va(t){let e=t.events.map(r=>lf(r)),n=qn(t.device,sf);return[t.protocolVersion,e,n,t.project]}function cf(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let t=Object.getOwnPropertyDescriptor(window,"localStorage");if(t&&t.get){let r=t.get.call(window);return window.__joliboxLocalStorage__=r,r}if(t=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),t&&t.get)return t.get.call(window);let e=Window.prototype,n=Object.getOwnPropertyDescriptor(e,"localStorage");if(n&&n.get){let r=n.get.call(window);return window.__joliboxLocalStorage__=r,r}return localStorage}catch(t){return console.warn("Failed to get original localStorage, fallback to default implementation",t),localStorage}}function Wa(t,e,n){let r=window.location.hostname,a=r.split("."),i=n?e:t;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r))return`${i}.jolibox.com`;if(a.length>=2){let o=a.slice(-2).join(".");if(o==="jolibox.com"||o==="pico-game.com"||o==="joyslite.com"||o==="mporia.com"||o==="pingplus.ai")return`${i}.${o}`}return`${i}.jolibox.com`}function Rs(t){return Wa("app","stg-app",t)}function Gt(t){return`https://${Wa("api","stg-api",t)}`}function vf(t){return Wa("collect","stg-collect",t)}function Os(t){return`https://${vf(t)}`}function wf(t){return new Promise(e=>ks(t)(e))}function ks(t){return(e,n=null)=>{let r=!1;return t(a=>{if(!r)return r=!0,e.call(n,a)},null)}}function bf(t,e){return(n=>{let r,a={onWillAddFirstListener(){r=n(i.fire,i)}},i=new dn(a);return i.event})((n,r=null)=>t(a=>e(a)&&n.call(r,a),null))}function If(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++)Af(t[r],e[r])}function Af(t,e){if(Ja(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(Qd(e)){try{if(t instanceof e)return}catch(n){}if(!Yd(t)&&t.constructor===e||e.length===1&&e.call(void 0,t)===!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 Sf(){return typeof globalThis!="undefined"?globalThis[Ts]:void 0}function Cf(t){typeof globalThis!="undefined"&&(globalThis[Ts]=t)}function we(t=!1){let e=Sf();if(!t&&e)return e;let n=new Vn,r=new Ba,a={registerCommand(i,o,s){n.registerCommand({id:i,handler:o,metadata:s})},executeCommand(i,...o){return r.executeCommand(i,...o)},excuteCommandSync(i,...o){return r.executeCommandThowErr(i,...o)}};return Cf(a),a}var Ma,Hd,jd,qd,us,Vd,$d,ds,Ga,Kd,Wd,ps,bt,Zd,Fa,Ha,bs,Es,ef,Is,$n,Kn,ja,Ne,Da,nf,qa,hs,rf,Et,Mt,af,ms,of,sf,je,Bt,uf,Re,df,ff,hf,Ss,$a,Ka,mf,pf,Cs,It,La,ie,gf,_f,un,dn,$e,Ua,yf,Pa,Ef,pt,Vn,Ba,Ts,q=ne(()=>{"use strict";Ma=Object.defineProperty,Hd=Object.defineProperties,jd=Object.getOwnPropertyDescriptor,qd=Object.getOwnPropertyDescriptors,us=Object.getOwnPropertySymbols,Vd=Object.prototype.hasOwnProperty,$d=Object.prototype.propertyIsEnumerable,ds=(t,e,n)=>e in t?Ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ga=(t,e)=>{for(var n in e||(e={}))Vd.call(e,n)&&ds(t,n,e[n]);if(us)for(var n of us(e))$d.call(e,n)&&ds(t,n,e[n]);return t},Kd=(t,e)=>Hd(t,qd(e)),Wd=(t,e)=>{for(var n in e)Ma(t,n,{get:e[n],enumerable:!0})},ps=(t,e,n,r)=>{for(var a=r>1?void 0:r?jd(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(a=(r?o(e,n,a):o(a))||a);return r&&a&&Ma(e,n,a),a},bt=(t,e,n)=>new Promise((r,a)=>{var i=l=>{try{s(n.next(l))}catch(d){a(d)}},o=l=>{try{s(n.throw(l))}catch(d){a(d)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,o);s((n=n.apply(t,e)).next())});if(typeof window!="undefined"&&!window.AbortController){let t=function(){this.signal=new e};t.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let n=new Event("abort");this.signal.dispatchEvent(n)};let e=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(e.prototype,"aborted",{get:function(){return this._aborted}}),e.prototype.addEventListener=function(n,r){this._eventListeners[n]||(this._eventListeners[n]=[]),this._eventListeners[n].push(r)},e.prototype.removeEventListener=function(n,r){if(!this._eventListeners[n])return;let a=this._eventListeners[n].indexOf(r);a!==-1&&this._eventListeners[n].splice(a,1)},e.prototype.dispatchEvent=function(n){if(this._eventListeners[n.type])for(let r of this._eventListeners[n.type])r.call(this,n)},window.AbortController=t,window.AbortSignal=e}Zd=(t=>(t[t.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",t[t.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",t[t.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",t[t.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",t[t.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",t[t.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",t[t.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",t[t.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",t))(Zd||{}),Fa=class extends Error{constructor(t){if(typeof t=="string"){super(t),this.priority="P1";return}super(t.message),this.priority="P1",this.stack=t.stack,this.raw=t}},Ha=class extends Fa{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},bs=class extends Fa{constructor(){super(...arguments),this.kind="USER_ERROR"}},Es=class extends bs{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},ef=class extends bs{constructor(t,e,n){super(t),this.message=t,this.errNo=e,this.name="USER_CUSTOM_ERROR",this.errMsg=t,n&&(this.extra=Object.assign({},this.extra,n))}},Is=class extends Ha{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},$n=class extends Ha{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Kn=class extends Fa{constructor(t,e,n,r,a){super(t),this.message=t,this.code=e,this.kind="API_ERROR",this.name="API_ERROR",n&&(this.errorType=n),r!==void 0&&(this.stack=r),a&&(this.priority=a)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},ja=class extends Ha{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Ne={log:cn("log"),warn:cn("warn"),info:cn("info"),error:cn("error"),debug:cn("debug")};Object.assign(globalThis,{logger:Ne});Da=Symbol.for("Jolibox.canIUseMap"),nf={};globalThis[Da]||(globalThis[Da]=nf);qa={get config(){return globalThis[Da]}},hs=Symbol.for("Jolibox.canIUseMap.native"),rf={};globalThis[hs]||(globalThis[hs]=rf);Et=(t=>(t[t.Other=0]="Other",t[t.Route=1]="Route",t[t.Click=2]="Click",t[t.View=3]="View",t[t.Expose=4]="Expose",t[t.Swipe=5]="Swipe",t[t.Input=6]="Input",t[t.Select=7]="Select",t[t.SwitchOn=8]="SwitchOn",t[t.SwitchOff=9]="SwitchOff",t[t.Submit=10]="Submit",t[t.Scroll=11]="Scroll",t[t.Hide=12]="Hide",t[t.System=1e3]="System",t[t.ErrorTrace=1001]="ErrorTrace",t[t.UserDefined=1002]="UserDefined",t))(Et||{}),Mt=(t=>(t.MiniGame="mini-game",t.MiniDrama="mini-drama",t.App="app",t.WebSDK="web-sdk",t.AppSDK="app-sdk",t))(Mt||{}),af=(t=>(t[t.App=0]="App",t[t.H5=1]="H5",t[t.Weapp=2]="Weapp",t[t.Alipay=3]="Alipay",t[t.Gcash=4]="Gcash",t[t.Dana=5]="Dana",t[t.Umma=6]="Umma",t[t.WebSDK=1e3]="WebSDK",t[t.AppSDK=1001]="AppSDK",t[t.Other=9999]="Other",t))(af||{}),ms=["name","params"],of=["name","type","location","target","extra","timestamp","userId"],sf=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];je=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)});cf();Bt=typeof window=="undefined",uf=()=>!Bt&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Re={isiOS:!Bt&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let t=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3]||"0",10)]},isAndroid:!Bt&&navigator.userAgent.includes("Android"),isMac:!Bt&&navigator.userAgent.includes("Mac"),isFacebook:!Bt&&navigator.userAgent.includes("FB_IAB"),isPC:!Bt&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},df=()=>Re.isiOS?"iOS":Re.isAndroid?"Android":Re.isMac?"Mac":Re.isFacebook?"Facebook":"PC",ff="device_id",hf="advertising_id",Ss=t=>(window.__joliboxLocalStorage__.getItem(t)||window.__joliboxLocalStorage__.setItem(t,je()),window.__joliboxLocalStorage__.getItem(t)),$a=()=>new URLSearchParams(window.location.search).get("deviceId")||Ss(ff),Ka=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ss(hf),mf=t=>t.charAt(0).toUpperCase()+t.slice(1),pf=()=>{var t;let e=new URLSearchParams(window.location.search);return mf((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Cs=t=>{if(uf())return window.navigator.userAgent;let e="JoliboxWebSDK",n=df(),r=navigator.language,a=$a(),i=Ka();return`${e} (${pf()}${n}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${a} adid/${i} version/${t||""}`};It=class{constructor(t,e={}){this.requestAdapter=t,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=Ga({duration:10*60*1e3,timeout:3e3,keyGenerator:(n,r)=>n,consistencyChecker:()=>!0},e)}request(t,e){return bt(this,null,function*(){let n=this.config.keyGenerator(t,e),r=this.pendingRequests.get(n);if(r)return console.log(`[RequestCacheService] Reusing pending request for ${t}`),r;let a=this.requestInternal(t,e),i=this.createTimeoutPromise(),o=Promise.race([a,i]).catch(s=>bt(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(n);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${t}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}throw s}));this.pendingRequests.set(n,o),a.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${t}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${t}:`,s)});try{return yield o}finally{this.pendingRequests.delete(n)}})}requestInternal(t,e){return bt(this,null,function*(){var n,r,a,i;let o=this.config.keyGenerator(t,e),s=++this.requestSequence,l=this.getValidCachedData(o);if(console.log("[RequestCacheService] requestInternal start",t,"cached:",l),l){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let f=yield this.requestAdapter.execute(t,e),p=this.requestAdapter.extractRealTimeData(f),h=(r=(n=this.requestAdapter).extractCacheableData)==null?void 0:r.call(n,f);return h&&!this.config.consistencyChecker(l,h)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${t}`),this.setCachedDataWithSequence(o,h,s),f):this.requestAdapter.mergeData(l,p)}catch(f){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${t}:`,f),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}return console.log(`[RequestCacheService] use cache for ${t}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${t} (sequence: ${s})`);let d=yield this.requestAdapter.execute(t,e),_=(i=(a=this.requestAdapter).extractCacheableData)==null?void 0:i.call(a,d);return _&&this.setCachedDataWithSequence(o,_,s),d})}createTimeoutPromise(){return new Promise((t,e)=>{setTimeout(()=>{e(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(t){let e=this.cache.get(t);return e?Date.now()>e.expiresAt?(this.cache.delete(t),null):e.data:null}setCachedDataWithSequence(t,e,n,r){let a=this.cache.get(t);if(a&&a.sequence>n){console.log(`[RequestCacheService] Ignoring stale cache update for ${t} (current: ${a.sequence}, incoming: ${n})`);return}let i=Date.now();this.cache.set(t,{data:JSON.parse(JSON.stringify(e)),timestamp:i,expiresAt:i+this.config.duration,key:t,sequence:n,metadata:r}),this.cacheSequences.set(t,n),console.log(`[RequestCacheService] Updated cache for ${t} with sequence ${n}`)}refreshCache(t,e){return bt(this,null,function*(){let n=this.config.keyGenerator(t,e);return this.cache.delete(n),this.request(t,e)})}forceRequest(t,e){return bt(this,null,function*(){var n,r;let a=this.config.keyGenerator(t,e),i=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${t} (sequence: ${i})`);let o=yield this.requestAdapter.execute(t,e),s=(r=(n=this.requestAdapter).extractCacheableData)==null?void 0:r.call(n,o);return s&&(this.setCachedDataWithSequence(a,s,i),console.log(`[RequestCacheService] Force updated cache for ${t}`)),o})}warmupCache(t,e){return bt(this,null,function*(){let n=this.config.keyGenerator(t,e);if(this.pendingRequests.has(n)){console.log(`[RequestCacheService] Skipping warmup for ${t} - request in progress`);return}if(this.hasValidCache(n)){console.log(`[RequestCacheService] Skipping warmup for ${t} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${t}`),yield this.forceRequest(t,e)}catch(r){console.warn(`[RequestCacheService] Cache warmup failed for ${t}:`,r)}})}clearCache(t){t?(this.cache.delete(t),this.cacheSequences.delete(t),this.pendingRequests.delete(t),console.log(`[RequestCacheService] Cleared cache for ${t}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let t=Date.now();for(let[e,n]of this.cache)t>n.expiresAt&&(this.cache.delete(e),this.cacheSequences.delete(e));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let t=Date.now(),e=0,n=0;for(let r of this.cache.values())t>r.expiresAt?n++:e++;return{cacheCount:this.cache.size,validCount:e,expiredCount:n,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(t){let e=this.cache.get(t);return e?Date.now()<=e.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(t){return this.pendingRequests.has(t)}getCacheSequence(t){return this.cacheSequences.get(t)}},La=class Na{constructor(e){this.element=e,this.next=Na.Undefined,this.prev=Na.Undefined}};La.Undefined=new La(void 0);ie=La,gf=class{constructor(){this._first=ie.Undefined,this._last=ie.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ie.Undefined}clear(){let t=this._first;for(;t!==ie.Undefined;){let e=t.next;t.prev=ie.Undefined,t.next=ie.Undefined,t=e}this._first=ie.Undefined,this._last=ie.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let n=new ie(t);if(this._first===ie.Undefined)this._first=n,this._last=n;else if(e){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==ie.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==ie.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==ie.Undefined&&t.next!==ie.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===ie.Undefined&&t.next===ie.Undefined?(this._first=ie.Undefined,this._last=ie.Undefined):t.next===ie.Undefined?(this._last=this._last.prev,this._last.next=ie.Undefined):t.prev===ie.Undefined&&(this._first=this._first.next,this._first.prev=ie.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==ie.Undefined;)yield t.element,t=t.next}},_f=0,un=class{constructor(t){this.value=t,this.id=_f++}},dn=class{constructor(t){this.options=t,this._size=0}dispose(t){var e,n;this._disposed||(this._disposed=!0,this._listeners&&(t?(this._listeners instanceof un&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(r=>(r==null?void 0:r.value)===t)):(this._listeners=void 0,this._size=0)),(n=(e=this.options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e))}get event(){var t;return(t=this._event)!=null||(this._event=(e,n)=>{var r,a,i,o,s,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};n&&(e=e.bind(n));let d=new un(e);return this._listeners?this._listeners instanceof un?this._listeners=[this._listeners,d]:this._listeners.push(d):((a=(r=this.options)==null?void 0:r.onWillAddFirstListener)==null||a.call(r,this),this._listeners=d,(o=(i=this.options)==null?void 0:i.onDidFirstListener)==null||o.call(i,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var _,f,p,h;if(!this._disposed){if(this._listeners instanceof un)this._listeners.id===d.id&&(this._listeners=void 0,this._size=0,(f=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||f.call(_));else if(this._listeners){let b=this._listeners.indexOf(d);b>=0&&(this._listeners.splice(b,1),this._size--,this._size===0&&((h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p)))}}}}),this._event}_deliver(t,e){var n;if(!t)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){t.value(e);return}try{t.value(e)}catch(a){r(a)}}fire(t){this._listeners&&(this._listeners instanceof un?this._deliver(this._listeners,t):this._listeners.forEach(e=>this._deliver(e,t)))}hasListeners(){return this._size>0}},$e=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(t,e,n=!0){var r;let a=(r=this.listeners.get(t))!=null?r:new dn,i=l=>e(...l.args),o=a.event(i);this.listerHandlerMap.set(e,{handler:i,dispose:o}),this.listeners.set(t,a);let s=this.cachedEventQueue.get(t);if(s&&n)for(let l of s)e(...l.args)}flushCachedEvent(t){t?this.cachedEventQueue.delete(t):this.cachedEventQueue.clear()}off(t,e){let n=this.listerHandlerMap.get(e);n&&(n.dispose(),this.listerHandlerMap.delete(e))}emit(t,...e){let n=this.listeners.get(t),r=this.cachedEventQueue.get(t);r||(r=new gf,this.cachedEventQueue.set(t,r)),r.push({args:e}),n&&n.fire({event:t,args:e})}once(t,e){let n=(...r)=>{e(...r),this.off(t,n)};this.on(t,n,!1)}},Ua={};Wd(Ua,{None:()=>yf,filter:()=>bf,once:()=>ks,toPromise:()=>wf});yf=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Pa=Symbol.for("Jolibox.hostEmitter"),Ef=()=>{let t=new $e;return globalThis[Pa]||(globalThis[Pa]={on:t.on.bind(t),off:t.off.bind(t),emit:t.emit.bind(t),once:t.once.bind(t)}),globalThis[Pa]},pt=Ef();Vn=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new dn,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(t){if(!t)throw new Error("invalid command");if(t.metadata&&Array.isArray(t.metadata.args)){let n=[];for(let a of t.metadata.args)n.push(a.constraint);let r=t.handler;t.handler=function(...a){return If(a,n),r(...a)}}let{id:e}=t;this._commands.get(e)&&console.info(`[Jolibox SDK] duplicated command is registered ${e}`),this._commands.set(e,t),this._onDidRegisterCommand.fire(e)}getCommand(t){return this._commands.get(t)}getCommands(){let t=new Map;for(let e of this._commands.keys()){let n=this.getCommand(e);n&&t.set(e,n)}return t}};Vn=ps([_s],Vn);Ba=class{constructor(){this._onWillExecuteCommand=new dn,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new dn,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Vn,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=zd(3e4)),this._starActivation}executeCommand(t,...e){return bt(this,null,function*(){return this.registry.getCommand(t)?this._tryExecuteCommand(t,e):(yield Promise.all([Promise.race([this._activateStar(),Ua.toPromise(Ua.filter(this.registry.onDidRegisterCommand,n=>n===t))])]),this._tryExecuteCommand(t,e))})}executeCommandThowErr(t,...e){if(!this.registry.getCommand(t))throw new Error(`command '${t}' not found`);let n=this.registry.getCommand(t);this._onWillExecuteCommand.fire({commandId:t,args:e});let r=this.invokeFunction(n.handler,...e);return this._onDidExecuteCommand.fire({commandId:t,args:e}),r}_tryExecuteCommand(t,e){let n=this.registry.getCommand(t);if(!n)return Promise.reject(new Error(`command '${t}' not found`));try{this._onWillExecuteCommand.fire({commandId:t,args:e});let r=this.invokeFunction(n.handler,...e);return this._onDidExecuteCommand.fire({commandId:t,args:e}),Promise.resolve(r)}catch(r){return Promise.reject(r)}}invokeFunction(t,...e){let n=!1;try{return t(...e)}finally{n=!0}}};Ba=ps([_s],Ba);Ts=Symbol.for("Jolibox.commands")});function Ue(t,e={}){za.emit("ERROR_REPORT",{error:t,options:e})}var za,At,et=ne(()=>{"use strict";q();q();za=new $e,At=new $e;Ue.debounce=fn(Ue,50,{leading:!0})});var Xa,Rf,xs,Ps,Ds=ne(()=>{"use strict";q();et();Xa=t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),r=atob(e+n);try{return JSON.parse(r)}catch(a){return{}}},Rf=t=>{let e=JSON.stringify(t);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},xs=t=>{var e;try{let a=(e=new URL(t).searchParams.get("joliSource"))==null?void 0:e.split(".");if(a!=null&&a.length){let[i,o,s]=a;return{headerJson:Xa(i),payloadJson:Xa(o),signature:Xa(s)}}else throw"joli_source is missing"}catch(n){return Ue(new Is(`${t} not a valid schema: ${n}`)),{headerJson:{},payloadJson:{},signature:{}}}},Ps=(t,e)=>{let n=e.split(".");if(n&&n.length===3){let r=n[0],a=Rf(t),i=n[2];return`${r}.${a}.${i}`}return e}});var Of,Wn,Ls,Ya=ne(()=>{"use strict";q();Of="1.3.4",Wn=()=>Of,Ls=()=>{let t=Wn();return`${Cs(t)}`}});function Za(t,e){return(document==null?void 0:document.head.querySelector(`meta[name="${t}"][content="${e}"]`))!==null}var kf,Ns,Qa,Us,oe,Tf,L,fe=ne(()=>{"use strict";q();Ds();Ya();q();kf={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:$a(),adId:Ka(),pixelRatio:window.devicePixelRatio||1,platform:Re.isAndroid?"android":Re.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Wn()},schema:window.location.href,platform:Re.isAndroid?"android":Re.isiOS?"ios":"h5"},Qa=(Ns=globalThis.joliboxJSCore)==null?void 0:Ns.env,oe=Object.assign({},(Us=Qa==null?void 0:Qa())!=null?Us:kf);Tf=()=>{var E,C,w,O,k,M,B,I,D,J,j;let{payloadJson:t,headerJson:e,signature:n}=oe.schema.length?xs(oe.schema):{},r=`${oe.deviceInfo.did}-${new Date().getTime()}`,i=new URL(oe.schema.length?oe.schema:window.location.href).searchParams,o=(w=(C=(E=i.get("mpId"))!=null?E:i.get("appId"))!=null?C:i.get("gameId"))!=null?w:"",s=(M=(k=(O=oe.clientSessionId)!=null?O:t==null?void 0:t.sessionId)!=null?k:i.get("sessionId"))!=null?M:r,l=!!((I=(B=t==null?void 0:t.testAdsMode)!=null?B:t==null?void 0:t.__testAdsMode)!=null?I:i.get("testAdsMode")==="true"),d=(j=(J=(D=t==null?void 0:t.joliboxEnv)!=null?D:t==null?void 0:t.__joliboxEnv)!=null?J:i.get("joliboxEnv"))!=null?j:"production",_=d==="staging",f=e==null?void 0:e.channel,h=new URL(window.location.href).searchParams,b=t==null?void 0:t.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return _},get testAdsMode(){return l},get joliboxEnv(){return d},get joliSource(){var N,G;return(G=(N=h.get("joliSource"))!=null?N:i.get("joliSource"))!=null?G:null},get mpId(){var N;return(N=o!=null?o:t==null?void 0:t.id)!=null?N:""},get mpVersion(){var N;return(N=e==null?void 0:e.ver)!=null?N:Wn()},get mpType(){var N,G;return(G=(N=e==null?void 0:e.__mpType)!=null?N:t==null?void 0:t.__mpType)!=null?G:"game"},get platform(){var N;return((N=oe.platform)!=null?N:oe.deviceInfo.platform).toLowerCase()},get deviceInfo(){return oe.deviceInfo},get sdkInfo(){return oe.sdkInfo},get hostInfo(){return oe.hostInfo},get hostUserInfo(){return oe.hostUserInfo},get sessionId(){var N,G;return(G=(N=oe.clientSessionId)!=null?N:s)!=null?G:r},get channel(){return f},get webviewId(){var N;return(N=oe.webviewId)!=null?N:-1},get shouldInterupt(){return b},get from(){return t==null?void 0:t.__from},get baseApiHost(){return Rs(_)},get adId(){var N;return(N=oe.deviceInfo.adId)!=null?N:oe.deviceInfo.did},get language(){return oe.deviceInfo.lang},get sdkEnvironment(){return Za("dlightek","jolibox")?"dlightek":i.get("huaweiQuick")==="true"?"huaweiQuick":Za("gamedistribution","jolibox")?"gamedistribution":Za("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var X,Z,He;let N=(X=oe.deviceInfo.pixelRatio)!=null?X:1,G=(Z=oe.deviceInfo.statusBarHeight)!=null?Z:t==null?void 0:t.__androidStatusBarHeight,F=(He=oe.deviceInfo.navigationBarHeight)!=null?He:t==null?void 0:t.__androidNavigationBarHeight;return{statusBarHeight:G!==void 0?G/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,G;return(G=(N=oe.abValues)==null?void 0:N.split(","))!=null?G:[]},get mpInfo(){var N;return(N=oe.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{ys(oe,N,ws)},encodeJoliSourceQuery:N=>{var G,F;return e&&n?Ps(W(W({},t),N),(G=i.get("joliSource"))!=null?G:""):(F=i.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{b=!1}}},L=Tf()});var ei,Ms,xf,Pf,Bs,Df,Gs=ne(()=>{"use strict";q();et();fe();q();ei=!1,Ms=(t,e)=>t==null?!1:e in t,xf=t=>Ms(t,"kind"),Pf=t=>{let e=t.toLowerCase().split("_");return e[0]+e.slice(1).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Bs=(t,e={},n)=>{var i,o,s;let r={user_id:(o=(i=L.hostUserInfo)==null?void 0:i.uid)!=null?o:"",device_id:(s=L.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:Pf(t.name)},a=Ce(W({},r),{env:e.environment,isFromUser:n});n?At.emit("GLOBAL_USER_ERROR",t,a):At.emit("GLOBAL_ERROR",t,a)},Df=t=>Ms(t,"kind")&&t.kind==="USER_ERROR";za.on("ERROR_REPORT",({error:t,options:e})=>{if(ei)return;ei=!0;let n=xf(t)&&t.raw?t.raw:t;try{let r=Df(t);Bs(t,e,r)}catch(r){let a=r instanceof Error?r.message:String(r),i=new ja(`${a}, origin error: ${n.message}`);Ne.error(i),Bs(new ja(i.message),{environment:e.environment},!1)}finally{ei=!1}})});var ti,ni=ne(()=>{"use strict";et();q();et();ti=t=>new Es(t)});function Js(t,e){let n=(r,a,i)=>{let d=a!=null?a:{},{eventType:o}=d,s=ls(d,["eventType"]),l=Ce(W({tag:r,eventType:i!=null?i:o!=null?o:Et.Other},e),{extra:W({},s)});r=="globalJsError"?Ue(new $n(JSON.stringify(l))):t("systemLog",l,L.webviewId)};return n.debounce=fn(n,500,{leading:!0}),n}function Fs(t){let e=(n,r,a)=>{var s;let i=(s=a&&JSON.stringify(a))!=null?s:0,o={speed_value_type:n,total_duration:r};i&&Object.assign(o,{extra:i}),t("joliboxSpeedAnalysis",o)};return e.debounce=fn(e,500,{leading:!0}),e}var Hs=ne(()=>{"use strict";q();q();et();fe()});function js(t,e){let n=Js(t,e),r=Fs(n);return{track:n,trackPerformance:r}}var qs=ne(()=>{"use strict";Hs()});var ri=ne(()=>{"use strict"});var zn,Vs=ne(()=>{"use strict";fe();q();q();zn=class{constructor(e){this.apiHost=e;this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return S(this,null,function*(){let n=`${this.apiHost}/api/fe-configs/js-sdk/samples-config`,r=yield(yield fetch(n)).json();this.samplesConfig=r})}checkIsSampled(e){if(!this.samplesConfig)return!1;let{samples:n}=this.samplesConfig;for(let[r,a]of Object.entries(n))if(a.includes(e.name))return Math.floor(Math.random()*101)<parseFloat(r);return!1}getDevice(){var r,a,i,o,s;let{nativeSDKVersion:e,jssdkVersion:n}=L.sdkInfo;return{platform:1e3,os:L.deviceInfo.platform,appVersion:(r=e!=null?e:n)!=null?r:"1.0.0",appId:(i=(a=L.hostInfo)==null?void 0:a.aid)!=null?i:"1",model:(o=L.deviceInfo.model)!=null?o:"UnknownModel",brand:(s=L.deviceInfo.brand)!=null?s:"UnknownBrand",uuid:L.deviceInfo.did,jsSdkVersion:n,extra:{}}}getLocation(){let e=new URLSearchParams(window.location.search),n={};return e.forEach((r,a)=>{n[a]=r}),{name:"GamePage",params:n}}trackEvent(e,n,r){return S(this,null,function*(){if(this.checkIsSampled(e))return;let a=e.location?e.location:yield this.getLocation(),i=e.target||null,o=e.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let s=this.deviceInfo,d={protocolVersion:"1.0.0",events:[Ce(W({},e),{location:a,target:i,extra:o,timestamp:Date.now(),userId:null})],device:s,project:n};try{r?yield this.doReport(Va(d),r):yield this.doReport(Va(d))}catch(_){Ne.log("[Jolibox SDK] report API error",_)}})}}});var ai=ne(()=>{"use strict";qs();ri();Vs()});var ii,$s,tt,Xn,qe,Jt=ne(()=>{"use strict";Ya();fe();q();ii=t=>{let e=new AbortController;return setTimeout(()=>e.abort(),t),e.signal};($s=AbortSignal.timeout)!=null||(AbortSignal.timeout=ii);tt=class t{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20;this.getNetworkStatus=()=>this.networkRequests.length===0?!0:this.networkRequests.filter(r=>r).length/this.networkRequests.length>=.6}static getInstance(){return t._instance||(t._instance=new t),t._instance}create(e){let n=new Xn(e);return t.getInstance().httpClients.add(n),n}recordNetworkRequest(e){this.networkRequests.push(e),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}},Xn=class{constructor(e){this.xua=Ls();this.getJoliSource=()=>L.joliSource;var r;let n=Gt(L.testMode);this.baseUrl=(r=e==null?void 0:e.baseUrl)!=null?r:n}get(e,n){return S(this,null,function*(){try{let{query:r,timeout:a}=n!=null?n:{},{headers:i}=n!=null?n:{},o=r?new URLSearchParams(r):null,s=o==null?void 0:o.toString(),l=`${this.baseUrl}${e}${s?`?${s}`:""}`,d=this.xua,_=this.getJoliSource();i=Object.assign({},i!=null?i:{},d?{"x-user-agent":d}:{},_?{"x-joli-source":_}:{});let f=yield fetch(l,{method:"GET",headers:i,credentials:"include",signal:ii(a!=null?a:3e4)});return tt.getInstance().recordNetworkRequest(!0),yield f.json()}catch(r){throw tt.getInstance().recordNetworkRequest(!1),r}})}post(e,n){return S(this,null,function*(){try{let{data:r,query:a,timeout:i}=n!=null?n:{},{headers:o}=n!=null?n:{},s=a?new URLSearchParams(a):null,l=s==null?void 0:s.toString(),d=`${this.baseUrl}${e}${l?`?${l}`:""}`,_=this.xua,f=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},f?{"x-joli-source":f}:{},{"x-os-type":Re.isAndroid?"ANDROID":Re.isiOS?"IOS":"PC"},{"x-runtime-type":"WEB"});let p=yield fetch(d,{method:"POST",headers:o,body:JSON.stringify(r),signal:ii(i!=null?i:3e4),credentials:"include"});tt.getInstance().recordNetworkRequest(!0);let h=p.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return p.blob()}catch(b){return yield p.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return p.formData()}catch(b){return yield p.text()}if(h!=null&&h.includes("application/json"))try{return yield p.json()}catch(b){return yield p.text()}return p}catch(r){throw tt.getInstance().recordNetworkRequest(!1),r}})}put(e,n){return S(this,null,function*(){try{let{data:r,query:a,timeout:i}=n!=null?n:{},{headers:o}=n!=null?n:{},s=a?new URLSearchParams(a):null,l=s==null?void 0:s.toString(),d=`${this.baseUrl}${e}${l?`?${l}`:""}`,_=this.xua,f=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},f?{"x-joli-source":f}:{});let p=yield fetch(d,{method:"PUT",headers:o,credentials:"include",body:JSON.stringify(r!=null?r:{})});if(!p.ok)throw tt.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${p.status}`);return tt.getInstance().recordNetworkRequest(!0),yield p.json()}catch(r){throw console.error("Error:",r),r}})}};window.JoliboxHttpClient=Xn;qe=tt.getInstance()});var oi,Yn,si=ne(()=>{"use strict";fe();ai();Jt();q();oi=class extends zn{constructor(){super(...arguments);this.httpClient=qe.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var n;return Os((n=L.testMode)!=null?n:!1)}doReport(n){this.httpClient.post("/report",{data:n,timeout:5e3}).catch(r=>{console.info("report error",r)})}},Yn=new oi(Gt(L.testMode))});var Lf,Ks=ne(()=>{"use strict";Gs();q();ni();q();si();fe();Lf=(t,e)=>{var a,i,o;let n={message:e.message,stack:(a=e.stack)!=null?a:"",errorType:e.name,source:0},r={name:t,type:Et.ErrorTrace,location:null,target:null,extra:n,timestamp:Date.now(),userId:(o=(i=L.hostUserInfo)==null?void 0:i.uid)!=null?o:null};Yn.trackEvent(r,Mt.WebSDK)};At.on("GLOBAL_ERROR",(t,e)=>{Lf(e.tag,t)});At.on("GLOBAL_USER_ERROR",(t,e)=>{Ne.log("UserError",t,e)})});var Qn,Ws=ne(()=>{"use strict";Qn=class{constructor(e,n){this.eventEmitter=e;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(e,n)=>{window.parent&&window.parent.postMessage({type:e,data:n},"*")};this.playGame=e=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:e}}),this.tracker("PlayGame",{duration:e}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:e}))};this.timer=this.createRAFTimer(e=>{this.playGame(e)});this.interval=n!=null?n:5*1e3,e.on("visible",r=>{this.visible=r})}start(e){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:e!=null?e:0}}),this.tracker("OpenGame",{duration:e!=null?e:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:e!=null?e:0}),this.timer.start()}close(e){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:e}}),this.tracker("CloseGame",{duration:e}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:e}),this.timer.stop()}createRAFTimer(e){let n=Date.now(),r,a,i=!1,o=0,s=()=>{if(!i)return;let h=Date.now(),b=h-n;b>=this.interval&&(this.visible&&(o+=Math.min(b,this.interval+1e3),e(o)),n=h),r=requestAnimationFrame(s)},l=()=>{_(),n=Date.now(),a=window.setInterval(()=>{if(!i)return;let h=Date.now();h-n>=this.interval&&(n=h)},this.interval)},d=()=>{f(),n=Date.now(),r=requestAnimationFrame(s)},_=()=>{r&&(cancelAnimationFrame(r),r=0)},f=()=>{a&&(clearInterval(a),a=0)};this.eventEmitter.on("visible",h=>{i&&(console.log("visible",h),h?d():l())});let p=this.visible;return{start(){i||(i=!0,p?d():l())},stop(){i=!1,_(),f()}}}}});var zs,Xs=ne(()=>{"use strict";zs=`-----BEGIN PUBLIC KEY-----
|
|
2
2
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs29BUZPZdQwNDEYtXufp
|
|
3
3
|
IGF40RBoddFzoD2ixl6PjyKWFXF8kxGS++HNtLspxhLvWoE12IZvrP7+whSpgHcy
|
|
4
4
|
4ryuW86mOdHnP9iyeK69GosHz3lVhQjF9UdhJDXB7P/zdj3VlVzZIj0yL+YvZjO0
|
package/dist/index.native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var iT=Object.create;var ca=Object.defineProperty,oT=Object.defineProperties,aT=Object.getOwnPropertyDescriptor,sT=Object.getOwnPropertyDescriptors,cT=Object.getOwnPropertyNames,sa=Object.getOwnPropertySymbols,lT=Object.getPrototypeOf,fl=Object.prototype.hasOwnProperty,Jm=Object.prototype.propertyIsEnumerable;var Bm=(e,t,r)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))fl.call(t,r)&&Bm(e,r,t[r]);if(sa)for(var r of sa(t))Jm.call(t,r)&&Bm(e,r,t[r]);return e},j=(e,t)=>oT(e,sT(t));var Ye=(e,t)=>{var r={};for(var n in e)fl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&sa)for(var n of sa(e))t.indexOf(n)<0&&Jm.call(e,n)&&(r[n]=e[n]);return r};var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Hm=(e,t)=>{for(var r in t)ca(e,r,{get:t[r],enumerable:!0})},uT=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cT(t))!fl.call(e,i)&&i!==r&&ca(e,i,{get:()=>t[i],enumerable:!(n=aT(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?iT(lT(e)):{},uT(t||!e||!e.__esModule?ca(r,"default",{value:e,enumerable:!0}):r,e));var y=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});function gT(e){return!!(e!=null&&e.__nativeBuffers__)}function _l(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!gT(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 i;n.value?i=n.value:n.base64&&(i=vT(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function bT(e={},t=!1){let r=e,n=[];for(let[i,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let a=t?{value:o,key:i}:{base64:yT(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function IT(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function nh(e){return typeof e=="string"}function Dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vm(e){return typeof e=="number"&&!isNaN(e)}function kT(e){return typeof e=="undefined"}function CT(e){return kT(e)||e===null}function ih(e){return typeof e=="function"}function AT(e){return Dn(e)&&ih(e.then)}function oh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Pi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function DT(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}function FT(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function HT(e){return new Promise(t=>ah(e)(t))}function ah(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function $T(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Oi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function WT(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)zT(e[n],t[n])}function zT(e,t){if(nh(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(ih(t)){try{if(e instanceof t)return}catch(r){}if(!CT(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 Jt(e,t){if(Sl.config[e]){ma.warn(`[can i use] ${e} already registered`);return}Sl.config[e]=ur({},t)}function Km(e,t){return`[${e}]:${t}`}function tR(e,t){Ym||(gl=new ua({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),vl=new ua({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),yl=new ua({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{gl.flush(),vl.flush(),yl.flush()}),Ym=!0);function r(i){var o,a;let{method:s,args:c,startTime:l,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:m,invokeCallback:g}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";gl.report({status:b,method:n(s,c),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-l}),l&&m&&g&&(vl.report({status:b,method:s,isForeground:d,duration:Number((m-l).toFixed(3))}),yl.report({status:b,method:s,isForeground:d,duration:Number((Date.now()-g).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function oR(e,t){let r=0,n=!0,i=iR.resolveMap,o=tR(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,bl.forEach(c=>pa(this,[c],function*({method:l,args:d,resolve:u}){let p=yield s(l,d);u(p)})),bl.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let u=_l(l);d(u),i.delete(Number(c))},s=(c,l)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new ET;if(i.set(r,m.resolve),!n&&QT.includes(c))return new Promise(x=>{bl.push({method:c,args:l,resolve:x})});let g=mT(ur({},{method:c,startTime:p,args:l,isForeground:f}),{invokeType:"js-bridge"}),b=!rR&&YT.includes(c),v=bT(l,b),w=b?v:JSON.stringify(v),S;if(c.endsWith("Sync")||XT.includes(c)?S=(d=e.call)==null?void 0:d.call(e,c,v,r):typeof w=="string"?S=e.invoke(c,w,r):S=(u=e.call)==null?void 0:u.call(e,c,w,r),S){try{typeof S=="string"&&(S=JSON.parse(S)),S=_l(S)}catch(x){ma.error(x)}return i.delete(r),S.errorCode&&(S.errorCode=Km(c,S.errorCode)),o(ur(ur({},g),S)),S}return c.endsWith("Sync")&&i.delete(r),m.promise.then(x=>(x.errorCode&&(x.errorCode=Km(c,x.errorCode)),o(ur(ur({},g),x)),x))};return{invokeNative:s,applyNative:(c,l)=>{let d=s(c,l);return AT(d)?d.then(u=>Qm(c,u)):Qm(c,d)},invokeHandler:a}}function Qm(e,t){if(!Dn(t)){ma.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=hT(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new RT(n,i,o,a);return s}function aR(e){if(globalThis[la])return globalThis[la];let t=new kl,r=new kl,n=new ua({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[la]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,o,a){let s=_l(o),c;if(s.__extra){c=s.params;let{type:l,startTime:d}=s.__extra;n.report({type:l,event:i,duration:Date.now()-d})}else c=s;if(i===ch){c.forEach(l=>{let[d,u]=l;try{r.emit(d.slice(Ri.length),u,a)}catch(p){}});return}if(i.startsWith(Ri)){r.emit(i.slice(Ri.length),c,a);return}t.emit(i,c,a)}},globalThis[la]}function sR(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Ri}${o}`,a,d);return}n||(n=Promise.resolve().then(()=>{t.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(ch,d,p)}catch(p){}}),n=void 0,t.clear()}));let l=t.get(s);l||(l=[],t.set(s,l)),l.push([`${Ri}${o}`,a])},emitNative:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(o,a,d),console.log("emitNative",o,a,d);return}i||(i=Promise.resolve().then(()=>{r.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(ZT,d,p)}catch(p){}}),i=void 0,r.clear()}));let l=r.get(s);l||(l=[],r.set(s,l)),l.push([o,a])}}}function cR(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=aR(e),{invokeNative:a,invokeHandler:s,applyNative:c}=oR(e,r),{publish:l,emitNative:d}=sR(e);return{invokeHandler:s,subscribeHandler:t,applyNative:c,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:l,subscribe:i,unsubscribe:o}}function lh(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var dT,pT,fT,da,Zm,eh,$m,ur,mT,hT,pa,vT,yT,th,_T,wT,rh,ST,ET,xT,PT,fa,TT,RT,OT,ml,ma,Wm,NT,wl,LT,Sl,qT,MT,UT,Nn,jT,c9,Il,fe,GT,BT,Ti,Oi,kl,Cl,JT,hl,VT,l9,Al,zm,u9,sh,KT,Ri,YT,QT,XT,ch,ZT,eR,ua,Ym,gl,vl,yl,bl,rR,xl,nR,iR,la,Pl,At,uh,dh,lR,ph,Xm,me,U,Ne,d9,uR,fh,Tl,p9,f9,ue=P(()=>{"use strict";dT=Object.defineProperty,pT=Object.defineProperties,fT=Object.getOwnPropertyDescriptors,da=Object.getOwnPropertySymbols,Zm=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,$m=(e,t,r)=>t in e?dT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ur=(e,t)=>{for(var r in t||(t={}))Zm.call(t,r)&&$m(e,r,t[r]);if(da)for(var r of da(t))eh.call(t,r)&&$m(e,r,t[r]);return e},mT=(e,t)=>pT(e,fT(t)),hT=(e,t)=>{var r={};for(var n in e)Zm.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&da)for(var n of da(e))t.indexOf(n)<0&&eh.call(e,n)&&(r[n]=e[n]);return r},pa=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});vT=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};yT=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};th=Object.defineProperty,_T=Object.getOwnPropertyDescriptor,wT=(e,t)=>{for(var r in t)th(e,r,{get:t[r],enumerable:!0})},rh=(e,t,r,n)=>{for(var i=n>1?void 0:n?_T(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&th(t,r,i),i},ST=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}ET=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))}})}};xT=(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))(xT||{}),PT=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},fa=class extends PT{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},TT=class extends fa{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},RT=class extends fa{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},OT=class extends fa{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},ml=class extends fa{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};ma={log:Pi("log"),warn:Pi("warn"),info:Pi("info"),error:Pi("error"),debug:Pi("debug")};Object.assign(globalThis,{logger:ma});Wm=Symbol.for("Jolibox.canIUseMap"),NT={};globalThis[Wm]||(globalThis[Wm]=NT);wl=Symbol.for("Jolibox.canIUseMap.native"),LT={};globalThis[wl]||(globalThis[wl]=LT);Sl={get config(){return globalThis[wl]}},qT=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(qT||{}),MT=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(MT||{}),UT=(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))(UT||{});FT();Nn=typeof window=="undefined",jT=()=>!Nn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),c9={isiOS:!Nn&&(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:!Nn&&navigator.userAgent.includes("Android"),isMac:!Nn&&navigator.userAgent.includes("Mac"),isFacebook:!Nn&&navigator.userAgent.includes("FB_IAB"),isPC:!Nn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Il=class El{constructor(t){this.element=t,this.next=El.Undefined,this.prev=El.Undefined}};Il.Undefined=new Il(void 0);fe=Il,GT=class{constructor(){this._first=fe.Undefined,this._last=fe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===fe.Undefined}clear(){let e=this._first;for(;e!==fe.Undefined;){let t=e.next;e.prev=fe.Undefined,e.next=fe.Undefined,e=t}this._first=fe.Undefined,this._last=fe.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new fe(e);if(this._first===fe.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==fe.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==fe.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==fe.Undefined&&e.next!==fe.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===fe.Undefined&&e.next===fe.Undefined?(this._first=fe.Undefined,this._last=fe.Undefined):e.next===fe.Undefined?(this._last=this._last.prev,this._last.next=fe.Undefined):e.prev===fe.Undefined&&(this._first=this._first.next,this._first.prev=fe.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==fe.Undefined;)yield e.element,e=e.next}},BT=0,Ti=class{constructor(e){this.value=e,this.id=BT++}},Oi=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Ti&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Ti(t);return this._listeners?this._listeners instanceof Ti?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Ti)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Ti?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},kl=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Oi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new GT,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Cl={};wT(Cl,{None:()=>JT,filter:()=>$T,once:()=>ah,toPromise:()=>HT});JT=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});hl=Symbol.for("Jolibox.hostEmitter"),VT=()=>{let e=new kl;return globalThis[hl]||(globalThis[hl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[hl]},l9=VT();Al=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Oi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return WT(i,r),n(...i)}}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}};Al=rh([oh],Al);zm=class{constructor(){this._onWillExecuteCommand=new Oi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Oi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Al,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=IT(3e4)),this._starActivation}executeCommand(e,...t){return ST(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Cl.toPromise(Cl.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}}};zm=rh([oh],zm);u9=Symbol.for("Jolibox.commands");Jt("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Jt("requestProductDetailsAsync",{version:102e4});Jt("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Jt("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Jt("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Jt("userTrackAsync",{version:1e6});Jt("openMiniapp",{version:1050100});Jt("requestCoinDetailsSync",{version:1070100});Jt("requestCoinDetailsAsync",{version:1070100});Jt("sendServerEventAsync",{version:1070100});sh=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let c=Sl.config[a];if(!c)return!1;let l=(o=t==null?void 0:t())!=null?o:"",d=c.version;if(c.platforms&&l in c.platforms){let p=c.platforms[l];if(p===!1)return!1;typeof p=="number"&&(d=p)}if(typeof d!="number")return!1;let u=e();return typeof u!="number"||u<d?!1:s.length===0?!0:n(c,s,u)||n(c.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=DT(i,o);if(!s)return!1;if(Dn(s)){let c=s.version;return Vm(c)?typeof a=="number"&&a>=c:!0}return Vm(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};KT=()=>jT(),Ri="custom_event_",YT=[],QT=[],XT=["env","createRequestTask","login"],ch="__batch_event__",ZT="__native_batch_event__",eR=e=>e==="pv"?e:"default",ua=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:i,metricName:o,type:a}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=i,this.metricName=o,this.type=eR(a)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){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(e){let t=(r,n,i,o)=>{let a=n.shift();if(a){let s=o[a];r[s]||(r[s]={}),t(r[s],n,i,o)}else r[i]||(r[i]=[]),r[i].push(o[i])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,i,o,a)=>{let s=i.shift();if(!s&&Dn(a))throw new ml(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let c=[];if(Dn(a))c.push(...Object.keys(a));else if(nh(a)){if(i.length>0)throw new ml(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);c.push(a)}else throw new ml(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);c.forEach(l=>{n[l]||(n[l]={});let d=Dn(a)?a[l]:a;t(n[l],[...i],o,d)})}else n[o]?n[o]++:n[o]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Ym=!1;bl=[],rR=!1,xl=Symbol.for("Jolibox.invokeResolverInstance"),nR=new Map;globalThis[xl]||(globalThis[xl]=nR);iR={get resolveMap(){return globalThis[xl]}};la=Symbol.for("Jolibox.subscribeInstance");At={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){At.trigger=e},onDoExit(e){At.exit=e},onDoBackPress(e){At.backPress=e}},uh=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new TT("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{At.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>pa(void 0,null,function*(){let o=yield At.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});Pl={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=lh(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(s),webviewIds:a}))},call(i,o,a){let s=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(o),callbackId:a}));if(s)return JSON.parse(s)}};let n={onDocumentReady:t,env:uh,doExit:r};globalThis.joliboxJSCore=ur({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{At.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>pa(void 0,null,function*(){let a=yield At.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});Pl={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let c=lh(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(c),webviewIds:s}))},call(o,a,s){let c=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(c)return JSON.parse(c)},doBackPress(o){return pa(this,null,function*(){let a=yield At.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:uh,doExit:n};globalThis.joliboxJSCore=ur({},i)}dh=Pl;if(!dh&&KT())throw new OT("No joliboxJScore is found, native bridge not found.");lR=ur({},dh),ph=cR(lR),{invokeHandler:Xm}=ph,{applyNative:me,invokeNative:U,onNative:Ne,offNative:d9,subscribeHandler:uR,publish:fh,emitNative:Tl,subscribe:p9,unsubscribe:f9}=ph;globalThis.joliboxJSBridge={callHandler:Xm,invokeHandler:Xm,subscribeHandler:uR}});function hR(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ga(e){return new Promise(t=>setTimeout(t,e))}function Mi(e){return typeof e=="string"}function rn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _h(e){return typeof e=="object"&&Array.isArray(e)}function va(e){return typeof e=="number"&&!isNaN(e)}function Dr(e){return e===!0||e===!1}function wh(e){return typeof e=="undefined"}function Ui(e){return wh(e)||e===null}function gR(e){return typeof e=="function"}function Sh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Ih(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],c=o[a],l=r(s,c,a,i,o);l!==void 0?i[a]=l:gh(c)&&gh(s)?i[a]=n(yh({},s),c):Array.isArray(c)&&Array.isArray(s)?i[a]=[...s,...c]:i[a]=c}return i}return n(e,t)}function gh(e){return e&&typeof e=="object"&&e.constructor===Object}function Eh(e,t){if(Array.isArray(e))return e.concat(t)}function Fi(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:c=!0}=r,l=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),d=function(...u){i=u,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function yR(e,t){return(...r)=>t(e,...r)}function Ln(e){return t=>yR(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Ht(`${i}`))}})}function Ni(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Ph(e,t,r){let n=0;if(e!==t){let i=e.split("."),o=t.split("."),a=Math.max(i.length,o.length);for(let s=0;s<a;s++){let c=parseInt(i[s],10)||0,l=parseInt(o[s],10)||0;if(c>l){n=1;break}else if(c<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}function Jl(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function ER(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com")return`${o}.${a}`}return`${o}.jolibox.com`}function Hl(e){return ER("app","stg-app",e)}function Mn(e){return`https://${Hl(e)}`}function xR(e){return new Promise(t=>Nh(e)(t))}function Nh(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function PR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new qi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function RR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)OR(e[n],t[n])}function OR(e,t){if(Mi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(gR(t)){try{if(e instanceof t)return}catch(r){}if(!Ui(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 NR(){return typeof globalThis!="undefined"?globalThis[Dh]:void 0}function DR(e){typeof globalThis!="undefined"&&(globalThis[Dh]=e)}function V(e=!1){let t=NR();if(!e&&t)return t;let r=new ha,n=new ql,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return DR(i),i}var Ml,dR,mh,pR,fR,hh,yh,mR,bh,tn,lt,vR,Ul,ji,Fl,kh,Ht,ya,Ch,ba,Ah,xh,Gi,jl,$t,Ol,bR,Gl,vh,_R,$,Bl,wR,qn,Di,Bi,SR,IR,Th,Rh,Oh,Dt,Nl,he,kR,CR,Li,qi,Vt,Ll,AR,Rl,TR,be,ha,ql,Dh,O=P(()=>{"use strict";Ml=Object.defineProperty,dR=Object.getOwnPropertyDescriptor,mh=Object.getOwnPropertySymbols,pR=Object.prototype.hasOwnProperty,fR=Object.prototype.propertyIsEnumerable,hh=(e,t,r)=>t in e?Ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yh=(e,t)=>{for(var r in t||(t={}))pR.call(t,r)&&hh(e,r,t[r]);if(mh)for(var r of mh(t))fR.call(t,r)&&hh(e,r,t[r]);return e},mR=(e,t)=>{for(var r in t)Ml(e,r,{get:t[r],enumerable:!0})},bh=(e,t,r,n)=>{for(var i=n>1?void 0:n?dR(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Ml(t,r,i),i},tn=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}lt=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))}})}};vR=(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))(vR||{}),Ul=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}},ji=class extends Ul{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Fl=class extends Ul{constructor(){super(...arguments),this.kind="USER_ERROR"}},kh=class extends Fl{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ht=class extends Fl{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))}},ya=class extends Fl{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_PAYMENT_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ch=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},ba=class extends ji{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="INTERNAL_PAYMENT_ERROR",this.priority="P0",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ah=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},xh=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Gi=class extends Ul{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},jl=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};$t={log:Ni("log"),warn:Ni("warn"),info:Ni("info"),error:Ni("error"),debug:Ni("debug")};Object.assign(globalThis,{logger:$t});Ol=Symbol.for("Jolibox.canIUseMap"),bR={};globalThis[Ol]||(globalThis[Ol]=bR);Gl={get config(){return globalThis[Ol]}},vh=Symbol.for("Jolibox.canIUseMap.native"),_R={};globalThis[vh]||(globalThis[vh]=_R);$=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))($||{}),Bl=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Bl||{}),wR=(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))(wR||{}),qn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});Jl();Di=typeof window=="undefined",Bi={isiOS:!Di&&(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:!Di&&navigator.userAgent.includes("Android"),isMac:!Di&&navigator.userAgent.includes("Mac"),isFacebook:!Di&&navigator.userAgent.includes("FB_IAB"),isPC:!Di&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},SR="device_id",IR="advertising_id",Th=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,qn()),window.__joliboxLocalStorage__.getItem(e)),Rh=()=>new URLSearchParams(window.location.search).get("deviceId")||Th(SR),Oh=()=>new URLSearchParams(window.location.search).get("advertisingId")||Th(IR);Dt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=yh({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return tn(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>tn(this,null,function*(){if(s.message.includes("timeout")){let c=this.getValidCachedData(r);if(c)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return tn(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,c=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",c),c){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(u),f=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return f&&!this.config.consistencyChecker(c,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(c,p)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let l=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,l);return d&&this.setCachedDataWithSequence(a,d,s),l})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return tn(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return tn(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return tn(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},Nl=class Dl{constructor(t){this.element=t,this.next=Dl.Undefined,this.prev=Dl.Undefined}};Nl.Undefined=new Nl(void 0);he=Nl,kR=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new he(e);if(this._first===he.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},CR=0,Li=class{constructor(e){this.value=e,this.id=CR++}},qi=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Li&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Li(t);return this._listeners?this._listeners instanceof Li?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Li)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Li?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Vt=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new qi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new kR,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Ll={};mR(Ll,{None:()=>AR,filter:()=>PR,once:()=>Nh,toPromise:()=>xR});AR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Rl=Symbol.for("Jolibox.hostEmitter"),TR=()=>{let e=new Vt;return globalThis[Rl]||(globalThis[Rl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Rl]},be=TR();ha=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new qi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return RR(i,r),n(...i)}}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}};ha=bh([Sh],ha);ql=class{constructor(){this._onWillExecuteCommand=new qi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new qi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new ha,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=hR(3e4)),this._starActivation}executeCommand(e,...t){return tn(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Ll.toPromise(Ll.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}}};ql=bh([Sh],ql);Dh=Symbol.for("Jolibox.commands")});function Ie(e,t={}){$l.emit("ERROR_REPORT",{error:e,options:t})}var $l,nn,gt=P(()=>{"use strict";O();O();$l=new Vt,nn=new Vt;Ie.debounce=Fi(Ie,50,{leading:!0})});var Vl,LR,Lh,qh,Mh=P(()=>{"use strict";O();gt();Vl=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(i){return{}}},LR=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Lh=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:Vl(o),payloadJson:Vl(a),signature:Vl(s)}}else throw"joli_source is missing"}catch(r){return Ie(new Ch(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},qh=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=LR(e),o=r[2];return`${n}.${i}.${o}`}return t}});var qR,Wl,Uh=P(()=>{"use strict";O();qR="1.3.3",Wl=()=>qR});function Kl(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var MR,Fh,zl,jh,ge,UR,I,J=P(()=>{"use strict";O();Mh();Uh();O();MR={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Rh(),adId:Oh(),pixelRatio:window.devicePixelRatio||1,platform:Bi.isAndroid?"android":Bi.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Wl()},schema:window.location.href,platform:Bi.isAndroid?"android":Bi.isiOS?"ios":"h5"},zl=(Fh=globalThis.joliboxJSCore)==null?void 0:Fh.env,ge=Object.assign({},(jh=zl==null?void 0:zl())!=null?jh:MR);UR=()=>{var g,b,v,w,S,x,A,C,k,B,le;let{payloadJson:e,headerJson:t,signature:r}=ge.schema.length?Lh(ge.schema):{},n=`${ge.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ge.schema.length?ge.schema:window.location.href).searchParams,a=(v=(b=(g=o.get("mpId"))!=null?g:o.get("appId"))!=null?b:o.get("gameId"))!=null?v:"",s=(x=(S=(w=ge.clientSessionId)!=null?w:e==null?void 0:e.sessionId)!=null?S:o.get("sessionId"))!=null?x:n,c=!!((C=(A=e==null?void 0:e.testAdsMode)!=null?A:e==null?void 0:e.__testAdsMode)!=null?C:o.get("testAdsMode")==="true"),l=(le=(B=(k=e==null?void 0:e.joliboxEnv)!=null?k:e==null?void 0:e.__joliboxEnv)!=null?B:o.get("joliboxEnv"))!=null?le:"production",d=l==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,m=e==null?void 0:e.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var N,R;return(R=(N=f.get("joliSource"))!=null?N:o.get("joliSource"))!=null?R:null},get mpId(){var N;return(N=a!=null?a:e==null?void 0:e.id)!=null?N:""},get mpVersion(){var N;return(N=t==null?void 0:t.ver)!=null?N:Wl()},get mpType(){var N,R;return(R=(N=t==null?void 0:t.__mpType)!=null?N:e==null?void 0:e.__mpType)!=null?R:"game"},get platform(){var N;return((N=ge.platform)!=null?N:ge.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ge.deviceInfo},get sdkInfo(){return ge.sdkInfo},get hostInfo(){return ge.hostInfo},get hostUserInfo(){return ge.hostUserInfo},get sessionId(){var N,R;return(R=(N=ge.clientSessionId)!=null?N:s)!=null?R:n},get channel(){return u},get webviewId(){var N;return(N=ge.webviewId)!=null?N:-1},get shouldInterupt(){return m},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Hl(d)},get adId(){var N;return(N=ge.deviceInfo.adId)!=null?N:ge.deviceInfo.did},get language(){return ge.deviceInfo.lang},get sdkEnvironment(){return Kl("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Kl("gamedistribution","jolibox")?"gamedistribution":Kl("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var ee,ie,lr;let N=(ee=ge.deviceInfo.pixelRatio)!=null?ee:1,R=(ie=ge.deviceInfo.statusBarHeight)!=null?ie:e==null?void 0:e.__androidStatusBarHeight,F=(lr=ge.deviceInfo.navigationBarHeight)!=null?lr:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:R!==void 0?R/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,R;return(R=(N=ge.abValues)==null?void 0:N.split(","))!=null?R:[]},get mpInfo(){var N;return(N=ge.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{Ih(ge,N,Eh)},encodeJoliSourceQuery:N=>{var R,F;return t&&r?qh(T(T({},e),N),(R=o.get("joliSource"))!=null?R:""):(F=o.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{m=!1}}},I=UR()});var Yl,Bh,FR,jR,Gh,GR,Jh=P(()=>{"use strict";O();gt();J();O();Yl=!1,Bh=(e,t)=>e==null?!1:t in e,FR=e=>Bh(e,"kind"),jR=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Gh=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=I.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:jR(e.name)},i=j(T({},n),{env:t.environment,isFromUser:r});r?nn.emit("GLOBAL_USER_ERROR",e,i):nn.emit("GLOBAL_ERROR",e,i)},GR=e=>Bh(e,"kind")&&e.kind==="USER_ERROR";$l.on("ERROR_REPORT",({error:e,options:t})=>{if(Yl)return;Yl=!0;let r=FR(e)&&e.raw?e.raw:e;try{let n=GR(e);Gh(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new jl(`${i}, origin error: ${r.message}`);$t.error(o),Gh(new jl(o.message),{environment:t.environment},!1)}finally{Yl=!1}})});var Qe,Ql,Lr=P(()=>{"use strict";gt();O();gt();Qe=(e,t)=>{var r,n;return new Gi((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Ql=e=>new kh(e)});var Hh=P(()=>{"use strict";Jh();Lr();O();ue();nn.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};U("trackAsync",{event:"reportJsError",data:r})});nn.on("GLOBAL_USER_ERROR",(e,t)=>{$t.log("UserError",e,t)})});var Xl=P(()=>{"use strict"});function $h(e,t){let r=(n,i,o)=>{let l=i!=null?i:{},{eventType:a}=l,s=Ye(l,["eventType"]),c=j(T({tag:n,eventType:o!=null?o:a!=null?a:$.Other},t),{extra:T({},s)});n=="globalJsError"?Ie(new xh(JSON.stringify(c))):e("systemLog",c,I.webviewId)};return r.debounce=Fi(r,500,{leading:!0}),r}function Vh(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=Fi(t,500,{leading:!0}),t}var Wh=P(()=>{"use strict";O();O();gt();J()});function zh(e,t){let r=$h(e,t),n=Vh(r);return{track:r,trackPerformance:n}}var Kh=P(()=>{"use strict";Wh()});var Yh=P(()=>{"use strict";J();O();O()});var Qh=P(()=>{"use strict";Kh();Xl();Yh()});var _a,Xh=P(()=>{"use strict";_a=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},c=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),u()}}}}});function wa(e,t,r){var c,l,d;let n=new Map,i=(c=r==null?void 0:r.baseUrl)!=null?c:Mn(I.testMode),o=(l=r==null?void 0:r.type)!=null?l:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return Ne("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:g,state:b}=f,v=Ye(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(v):p.reject(v),n.delete(g)}else if(u.state==="fail"){let m=u,{requestTaskId:g,state:b}=m,v=Ye(m,["requestTaskId","state"]);p.reject(v),n.delete(g)}else $t.warn("onRequestTaskStateChange unknown event",u)}),be.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>y(this,[f,...m],function*(u,p={}){let g=Date.now(),b=BR(u,j(T({},p),{baseUrl:i})),{method:v="GET",responseType:w="text",dataType:S="json",timeout:x,enableCache:A=!1,appendHostCookie:C=!0}=p,k=Object.assign({"content-type":"application/json"},a,p.header),B={url:b,method:v,header:k,enableCache:A,responseType:w,appendHostCookie:C};if(v=="POST"||v=="PUT"){let ee=HR(p.data,k["content-type"]);B.data=ee}x&&Object.assign(B,{timeout:x});let{data:{requestTaskId:le}}=U(e,B);if(typeof le!="string")throw Qe({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:R,promise:F}=new lt;n.set(le,{resolve:N,reject:R});try{let ee=yield F,{data:ie}=ee;return S==="json"&&typeof ie=="string"&&(ie=JR(ie)),{url:b,timeout:x,method:v,response:j(T({},ee),{data:ie})}}catch(ee){let ie=ee;if(rn(ie)){let{errMsg:lr,prefetchDetail:o9,isPrefetch:a9,errNo:nT}=ie;Mi(lr)&&Ie(Qe({code:-1,msg:lr},{errNo:nT,errMsg:lr}))}throw ee}})}function JR(e){try{return JSON.parse(e.trim())}catch(t){return e}}function HR(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 BR,Zl=P(()=>{"use strict";O();ue();gt();Lr();J();BR=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,i=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${i?`?${i}`:""}`:`${e}${i?`?${i}`:""}`}});var eu,Zh,re,vt=P(()=>{"use strict";Zl();J();O();eu={};(Zh=I.hostUserInfo)!=null&&Zh.token&&(eu["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(eu["x-joli-source"]=I.joliSource);re=wa("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Mn(I.testMode),defaultHeaders:eu})});function eg(e){let t=Gl.config[e];return t||(t={},Gl.config[e]=t),(r,n)=>{if(t[r]){$t.warn(`[can i use] ${r} already registered`);return}t[r]=T({},n)}}var tg=P(()=>{"use strict";O()});function tu(e){rg=e}function Sa(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Sa(t)):Object.keys(e).reduce((t,r)=>(t[r]=Sa(e[r]),t),{})}function dr(e){return typeof e=="number"}function ru(e){let t=nu(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function nu(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var rg,Ce,Ia,Ea,ka,Ca,Un,Aa,xa,Pa,Ta,Ra,Oa,Na,Da,La,qa,Ma,Ua,iu=P(()=>{"use strict";rg=!1;Ce=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(rg)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 ${ru(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Sa(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Sa(this._default)}optional(){return this._optional=!0,this}};Ia=class extends Ce{validate(t){return this._optional&&t===void 0?!0:dr(t)?dr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):dr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):dr(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}},Ea=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ka=class extends Ce{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(dr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(dr(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}},Ca=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Un=class extends Ce{validate(t){return!0}},Aa=class extends Ce{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},xa=class extends Ce{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Pa=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Ta=class extends Ce{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 ${ru(t)}`)}return!0}},Ra=class extends Ce{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(dr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(dr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(dr(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 i=!0;if(r.forEach((o,a)=>{if(n.path=`${this.path}[${a}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[a]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[a]=n.fallbackValue:i=!1)}),this._uniqueItems){let o=new Map;for(let a in r)o.has(r[a])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[a])}] and ${this.path}[${a}] are identical)`):o.set(r[a],a)}return i}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}},Oa=class extends Ce{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(nu(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,o=this._value;o.errors=this.errors;let a=!0;for(let s in i){let c=i[s];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?o.path=`${this.path}.${s}`:o.path=`${this.path}["${s}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},Na=class extends Ce{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(nu(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let o in this._object){let a=n[o],s=this._object[o];if(s.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?s.path=`${this.path}.${o}`:s.path=`${this.path}["${o}"]`,!(s._optional&&a===void 0)){if(a===void 0&&s.hasDefault){n[o]=s.defaultValue;continue}s.validate(a)||(s.hasFallback?n[o]=s.fallbackValue:i=!1)}}return i}},Da=class extends Ce{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:ru(this.value),actual:r}):!0}},La=class extends Ce{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let o=0;o<i;o++){let a=this._items[o];if(a.errors=[],a.path=this.path,!a.validate(t))r.push(a.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
|
|
1
|
+
var iT=Object.create;var ca=Object.defineProperty,oT=Object.defineProperties,aT=Object.getOwnPropertyDescriptor,sT=Object.getOwnPropertyDescriptors,cT=Object.getOwnPropertyNames,sa=Object.getOwnPropertySymbols,lT=Object.getPrototypeOf,fl=Object.prototype.hasOwnProperty,Jm=Object.prototype.propertyIsEnumerable;var Bm=(e,t,r)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))fl.call(t,r)&&Bm(e,r,t[r]);if(sa)for(var r of sa(t))Jm.call(t,r)&&Bm(e,r,t[r]);return e},j=(e,t)=>oT(e,sT(t));var Ye=(e,t)=>{var r={};for(var n in e)fl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&sa)for(var n of sa(e))t.indexOf(n)<0&&Jm.call(e,n)&&(r[n]=e[n]);return r};var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Hm=(e,t)=>{for(var r in t)ca(e,r,{get:t[r],enumerable:!0})},uT=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cT(t))!fl.call(e,i)&&i!==r&&ca(e,i,{get:()=>t[i],enumerable:!(n=aT(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?iT(lT(e)):{},uT(t||!e||!e.__esModule?ca(r,"default",{value:e,enumerable:!0}):r,e));var y=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});function gT(e){return!!(e!=null&&e.__nativeBuffers__)}function _l(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!gT(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 i;n.value?i=n.value:n.base64&&(i=vT(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function bT(e={},t=!1){let r=e,n=[];for(let[i,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let a=t?{value:o,key:i}:{base64:yT(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function IT(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function nh(e){return typeof e=="string"}function Dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vm(e){return typeof e=="number"&&!isNaN(e)}function kT(e){return typeof e=="undefined"}function CT(e){return kT(e)||e===null}function ih(e){return typeof e=="function"}function AT(e){return Dn(e)&&ih(e.then)}function oh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Pi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function DT(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}function FT(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function HT(e){return new Promise(t=>ah(e)(t))}function ah(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function $T(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Oi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function WT(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)zT(e[n],t[n])}function zT(e,t){if(nh(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(ih(t)){try{if(e instanceof t)return}catch(r){}if(!CT(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 Jt(e,t){if(Sl.config[e]){ma.warn(`[can i use] ${e} already registered`);return}Sl.config[e]=ur({},t)}function Km(e,t){return`[${e}]:${t}`}function tR(e,t){Ym||(gl=new ua({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),vl=new ua({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),yl=new ua({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{gl.flush(),vl.flush(),yl.flush()}),Ym=!0);function r(i){var o,a;let{method:s,args:c,startTime:l,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:m,invokeCallback:g}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";gl.report({status:b,method:n(s,c),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-l}),l&&m&&g&&(vl.report({status:b,method:s,isForeground:d,duration:Number((m-l).toFixed(3))}),yl.report({status:b,method:s,isForeground:d,duration:Number((Date.now()-g).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function oR(e,t){let r=0,n=!0,i=iR.resolveMap,o=tR(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,bl.forEach(c=>pa(this,[c],function*({method:l,args:d,resolve:u}){let p=yield s(l,d);u(p)})),bl.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let u=_l(l);d(u),i.delete(Number(c))},s=(c,l)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new ET;if(i.set(r,m.resolve),!n&&QT.includes(c))return new Promise(x=>{bl.push({method:c,args:l,resolve:x})});let g=mT(ur({},{method:c,startTime:p,args:l,isForeground:f}),{invokeType:"js-bridge"}),b=!rR&&YT.includes(c),v=bT(l,b),w=b?v:JSON.stringify(v),S;if(c.endsWith("Sync")||XT.includes(c)?S=(d=e.call)==null?void 0:d.call(e,c,v,r):typeof w=="string"?S=e.invoke(c,w,r):S=(u=e.call)==null?void 0:u.call(e,c,w,r),S){try{typeof S=="string"&&(S=JSON.parse(S)),S=_l(S)}catch(x){ma.error(x)}return i.delete(r),S.errorCode&&(S.errorCode=Km(c,S.errorCode)),o(ur(ur({},g),S)),S}return c.endsWith("Sync")&&i.delete(r),m.promise.then(x=>(x.errorCode&&(x.errorCode=Km(c,x.errorCode)),o(ur(ur({},g),x)),x))};return{invokeNative:s,applyNative:(c,l)=>{let d=s(c,l);return AT(d)?d.then(u=>Qm(c,u)):Qm(c,d)},invokeHandler:a}}function Qm(e,t){if(!Dn(t)){ma.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=hT(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new RT(n,i,o,a);return s}function aR(e){if(globalThis[la])return globalThis[la];let t=new kl,r=new kl,n=new ua({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[la]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,o,a){let s=_l(o),c;if(s.__extra){c=s.params;let{type:l,startTime:d}=s.__extra;n.report({type:l,event:i,duration:Date.now()-d})}else c=s;if(i===ch){c.forEach(l=>{let[d,u]=l;try{r.emit(d.slice(Ri.length),u,a)}catch(p){}});return}if(i.startsWith(Ri)){r.emit(i.slice(Ri.length),c,a);return}t.emit(i,c,a)}},globalThis[la]}function sR(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Ri}${o}`,a,d);return}n||(n=Promise.resolve().then(()=>{t.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(ch,d,p)}catch(p){}}),n=void 0,t.clear()}));let l=t.get(s);l||(l=[],t.set(s,l)),l.push([`${Ri}${o}`,a])},emitNative:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(o,a,d),console.log("emitNative",o,a,d);return}i||(i=Promise.resolve().then(()=>{r.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(ZT,d,p)}catch(p){}}),i=void 0,r.clear()}));let l=r.get(s);l||(l=[],r.set(s,l)),l.push([o,a])}}}function cR(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=aR(e),{invokeNative:a,invokeHandler:s,applyNative:c}=oR(e,r),{publish:l,emitNative:d}=sR(e);return{invokeHandler:s,subscribeHandler:t,applyNative:c,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:l,subscribe:i,unsubscribe:o}}function lh(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var dT,pT,fT,da,Zm,eh,$m,ur,mT,hT,pa,vT,yT,th,_T,wT,rh,ST,ET,xT,PT,fa,TT,RT,OT,ml,ma,Wm,NT,wl,LT,Sl,qT,MT,UT,Nn,jT,c9,Il,fe,GT,BT,Ti,Oi,kl,Cl,JT,hl,VT,l9,Al,zm,u9,sh,KT,Ri,YT,QT,XT,ch,ZT,eR,ua,Ym,gl,vl,yl,bl,rR,xl,nR,iR,la,Pl,At,uh,dh,lR,ph,Xm,me,U,Ne,d9,uR,fh,Tl,p9,f9,ue=P(()=>{"use strict";dT=Object.defineProperty,pT=Object.defineProperties,fT=Object.getOwnPropertyDescriptors,da=Object.getOwnPropertySymbols,Zm=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,$m=(e,t,r)=>t in e?dT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ur=(e,t)=>{for(var r in t||(t={}))Zm.call(t,r)&&$m(e,r,t[r]);if(da)for(var r of da(t))eh.call(t,r)&&$m(e,r,t[r]);return e},mT=(e,t)=>pT(e,fT(t)),hT=(e,t)=>{var r={};for(var n in e)Zm.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&da)for(var n of da(e))t.indexOf(n)<0&&eh.call(e,n)&&(r[n]=e[n]);return r},pa=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});vT=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};yT=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};th=Object.defineProperty,_T=Object.getOwnPropertyDescriptor,wT=(e,t)=>{for(var r in t)th(e,r,{get:t[r],enumerable:!0})},rh=(e,t,r,n)=>{for(var i=n>1?void 0:n?_T(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&th(t,r,i),i},ST=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}ET=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))}})}};xT=(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))(xT||{}),PT=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},fa=class extends PT{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},TT=class extends fa{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},RT=class extends fa{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},OT=class extends fa{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},ml=class extends fa{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};ma={log:Pi("log"),warn:Pi("warn"),info:Pi("info"),error:Pi("error"),debug:Pi("debug")};Object.assign(globalThis,{logger:ma});Wm=Symbol.for("Jolibox.canIUseMap"),NT={};globalThis[Wm]||(globalThis[Wm]=NT);wl=Symbol.for("Jolibox.canIUseMap.native"),LT={};globalThis[wl]||(globalThis[wl]=LT);Sl={get config(){return globalThis[wl]}},qT=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(qT||{}),MT=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(MT||{}),UT=(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))(UT||{});FT();Nn=typeof window=="undefined",jT=()=>!Nn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),c9={isiOS:!Nn&&(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:!Nn&&navigator.userAgent.includes("Android"),isMac:!Nn&&navigator.userAgent.includes("Mac"),isFacebook:!Nn&&navigator.userAgent.includes("FB_IAB"),isPC:!Nn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Il=class El{constructor(t){this.element=t,this.next=El.Undefined,this.prev=El.Undefined}};Il.Undefined=new Il(void 0);fe=Il,GT=class{constructor(){this._first=fe.Undefined,this._last=fe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===fe.Undefined}clear(){let e=this._first;for(;e!==fe.Undefined;){let t=e.next;e.prev=fe.Undefined,e.next=fe.Undefined,e=t}this._first=fe.Undefined,this._last=fe.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new fe(e);if(this._first===fe.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==fe.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==fe.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==fe.Undefined&&e.next!==fe.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===fe.Undefined&&e.next===fe.Undefined?(this._first=fe.Undefined,this._last=fe.Undefined):e.next===fe.Undefined?(this._last=this._last.prev,this._last.next=fe.Undefined):e.prev===fe.Undefined&&(this._first=this._first.next,this._first.prev=fe.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==fe.Undefined;)yield e.element,e=e.next}},BT=0,Ti=class{constructor(e){this.value=e,this.id=BT++}},Oi=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Ti&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Ti(t);return this._listeners?this._listeners instanceof Ti?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Ti)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Ti?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},kl=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Oi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new GT,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Cl={};wT(Cl,{None:()=>JT,filter:()=>$T,once:()=>ah,toPromise:()=>HT});JT=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});hl=Symbol.for("Jolibox.hostEmitter"),VT=()=>{let e=new kl;return globalThis[hl]||(globalThis[hl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[hl]},l9=VT();Al=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Oi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return WT(i,r),n(...i)}}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}};Al=rh([oh],Al);zm=class{constructor(){this._onWillExecuteCommand=new Oi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Oi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Al,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=IT(3e4)),this._starActivation}executeCommand(e,...t){return ST(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Cl.toPromise(Cl.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}}};zm=rh([oh],zm);u9=Symbol.for("Jolibox.commands");Jt("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Jt("requestProductDetailsAsync",{version:102e4});Jt("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Jt("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Jt("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Jt("userTrackAsync",{version:1e6});Jt("openMiniapp",{version:1050100});Jt("requestCoinDetailsSync",{version:1070100});Jt("requestCoinDetailsAsync",{version:1070100});Jt("sendServerEventAsync",{version:1070100});sh=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let c=Sl.config[a];if(!c)return!1;let l=(o=t==null?void 0:t())!=null?o:"",d=c.version;if(c.platforms&&l in c.platforms){let p=c.platforms[l];if(p===!1)return!1;typeof p=="number"&&(d=p)}if(typeof d!="number")return!1;let u=e();return typeof u!="number"||u<d?!1:s.length===0?!0:n(c,s,u)||n(c.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=DT(i,o);if(!s)return!1;if(Dn(s)){let c=s.version;return Vm(c)?typeof a=="number"&&a>=c:!0}return Vm(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};KT=()=>jT(),Ri="custom_event_",YT=[],QT=[],XT=["env","createRequestTask","login"],ch="__batch_event__",ZT="__native_batch_event__",eR=e=>e==="pv"?e:"default",ua=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:i,metricName:o,type:a}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=i,this.metricName=o,this.type=eR(a)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){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(e){let t=(r,n,i,o)=>{let a=n.shift();if(a){let s=o[a];r[s]||(r[s]={}),t(r[s],n,i,o)}else r[i]||(r[i]=[]),r[i].push(o[i])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,i,o,a)=>{let s=i.shift();if(!s&&Dn(a))throw new ml(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let c=[];if(Dn(a))c.push(...Object.keys(a));else if(nh(a)){if(i.length>0)throw new ml(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);c.push(a)}else throw new ml(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);c.forEach(l=>{n[l]||(n[l]={});let d=Dn(a)?a[l]:a;t(n[l],[...i],o,d)})}else n[o]?n[o]++:n[o]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Ym=!1;bl=[],rR=!1,xl=Symbol.for("Jolibox.invokeResolverInstance"),nR=new Map;globalThis[xl]||(globalThis[xl]=nR);iR={get resolveMap(){return globalThis[xl]}};la=Symbol.for("Jolibox.subscribeInstance");At={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){At.trigger=e},onDoExit(e){At.exit=e},onDoBackPress(e){At.backPress=e}},uh=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new TT("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{At.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>pa(void 0,null,function*(){let o=yield At.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});Pl={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=lh(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(s),webviewIds:a}))},call(i,o,a){let s=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(o),callbackId:a}));if(s)return JSON.parse(s)}};let n={onDocumentReady:t,env:uh,doExit:r};globalThis.joliboxJSCore=ur({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{At.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>pa(void 0,null,function*(){let a=yield At.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});Pl={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let c=lh(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(c),webviewIds:s}))},call(o,a,s){let c=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(c)return JSON.parse(c)},doBackPress(o){return pa(this,null,function*(){let a=yield At.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:uh,doExit:n};globalThis.joliboxJSCore=ur({},i)}dh=Pl;if(!dh&&KT())throw new OT("No joliboxJScore is found, native bridge not found.");lR=ur({},dh),ph=cR(lR),{invokeHandler:Xm}=ph,{applyNative:me,invokeNative:U,onNative:Ne,offNative:d9,subscribeHandler:uR,publish:fh,emitNative:Tl,subscribe:p9,unsubscribe:f9}=ph;globalThis.joliboxJSBridge={callHandler:Xm,invokeHandler:Xm,subscribeHandler:uR}});function hR(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ga(e){return new Promise(t=>setTimeout(t,e))}function Mi(e){return typeof e=="string"}function rn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _h(e){return typeof e=="object"&&Array.isArray(e)}function va(e){return typeof e=="number"&&!isNaN(e)}function Dr(e){return e===!0||e===!1}function wh(e){return typeof e=="undefined"}function Ui(e){return wh(e)||e===null}function gR(e){return typeof e=="function"}function Sh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Ih(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],c=o[a],l=r(s,c,a,i,o);l!==void 0?i[a]=l:gh(c)&&gh(s)?i[a]=n(yh({},s),c):Array.isArray(c)&&Array.isArray(s)?i[a]=[...s,...c]:i[a]=c}return i}return n(e,t)}function gh(e){return e&&typeof e=="object"&&e.constructor===Object}function Eh(e,t){if(Array.isArray(e))return e.concat(t)}function Fi(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:c=!0}=r,l=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),d=function(...u){i=u,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function yR(e,t){return(...r)=>t(e,...r)}function Ln(e){return t=>yR(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Ht(`${i}`))}})}function Ni(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Ph(e,t,r){let n=0;if(e!==t){let i=e.split("."),o=t.split("."),a=Math.max(i.length,o.length);for(let s=0;s<a;s++){let c=parseInt(i[s],10)||0,l=parseInt(o[s],10)||0;if(c>l){n=1;break}else if(c<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}function Jl(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function ER(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function Hl(e){return ER("app","stg-app",e)}function Mn(e){return`https://${Hl(e)}`}function xR(e){return new Promise(t=>Nh(e)(t))}function Nh(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function PR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new qi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function RR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)OR(e[n],t[n])}function OR(e,t){if(Mi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(gR(t)){try{if(e instanceof t)return}catch(r){}if(!Ui(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 NR(){return typeof globalThis!="undefined"?globalThis[Dh]:void 0}function DR(e){typeof globalThis!="undefined"&&(globalThis[Dh]=e)}function V(e=!1){let t=NR();if(!e&&t)return t;let r=new ha,n=new ql,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return DR(i),i}var Ml,dR,mh,pR,fR,hh,yh,mR,bh,tn,lt,vR,Ul,ji,Fl,kh,Ht,ya,Ch,ba,Ah,xh,Gi,jl,$t,Ol,bR,Gl,vh,_R,$,Bl,wR,qn,Di,Bi,SR,IR,Th,Rh,Oh,Dt,Nl,he,kR,CR,Li,qi,Vt,Ll,AR,Rl,TR,be,ha,ql,Dh,O=P(()=>{"use strict";Ml=Object.defineProperty,dR=Object.getOwnPropertyDescriptor,mh=Object.getOwnPropertySymbols,pR=Object.prototype.hasOwnProperty,fR=Object.prototype.propertyIsEnumerable,hh=(e,t,r)=>t in e?Ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yh=(e,t)=>{for(var r in t||(t={}))pR.call(t,r)&&hh(e,r,t[r]);if(mh)for(var r of mh(t))fR.call(t,r)&&hh(e,r,t[r]);return e},mR=(e,t)=>{for(var r in t)Ml(e,r,{get:t[r],enumerable:!0})},bh=(e,t,r,n)=>{for(var i=n>1?void 0:n?dR(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Ml(t,r,i),i},tn=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}lt=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))}})}};vR=(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))(vR||{}),Ul=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}},ji=class extends Ul{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Fl=class extends Ul{constructor(){super(...arguments),this.kind="USER_ERROR"}},kh=class extends Fl{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ht=class extends Fl{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))}},ya=class extends Fl{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_PAYMENT_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ch=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},ba=class extends ji{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="INTERNAL_PAYMENT_ERROR",this.priority="P0",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ah=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},xh=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Gi=class extends Ul{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},jl=class extends ji{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};$t={log:Ni("log"),warn:Ni("warn"),info:Ni("info"),error:Ni("error"),debug:Ni("debug")};Object.assign(globalThis,{logger:$t});Ol=Symbol.for("Jolibox.canIUseMap"),bR={};globalThis[Ol]||(globalThis[Ol]=bR);Gl={get config(){return globalThis[Ol]}},vh=Symbol.for("Jolibox.canIUseMap.native"),_R={};globalThis[vh]||(globalThis[vh]=_R);$=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))($||{}),Bl=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Bl||{}),wR=(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))(wR||{}),qn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});Jl();Di=typeof window=="undefined",Bi={isiOS:!Di&&(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:!Di&&navigator.userAgent.includes("Android"),isMac:!Di&&navigator.userAgent.includes("Mac"),isFacebook:!Di&&navigator.userAgent.includes("FB_IAB"),isPC:!Di&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},SR="device_id",IR="advertising_id",Th=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,qn()),window.__joliboxLocalStorage__.getItem(e)),Rh=()=>new URLSearchParams(window.location.search).get("deviceId")||Th(SR),Oh=()=>new URLSearchParams(window.location.search).get("advertisingId")||Th(IR);Dt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=yh({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return tn(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>tn(this,null,function*(){if(s.message.includes("timeout")){let c=this.getValidCachedData(r);if(c)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return tn(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,c=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",c),c){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(u),f=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return f&&!this.config.consistencyChecker(c,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(c,p)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let l=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,l);return d&&this.setCachedDataWithSequence(a,d,s),l})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return tn(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return tn(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return tn(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},Nl=class Dl{constructor(t){this.element=t,this.next=Dl.Undefined,this.prev=Dl.Undefined}};Nl.Undefined=new Nl(void 0);he=Nl,kR=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new he(e);if(this._first===he.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},CR=0,Li=class{constructor(e){this.value=e,this.id=CR++}},qi=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Li&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Li(t);return this._listeners?this._listeners instanceof Li?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Li)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Li?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Vt=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new qi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new kR,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Ll={};mR(Ll,{None:()=>AR,filter:()=>PR,once:()=>Nh,toPromise:()=>xR});AR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Rl=Symbol.for("Jolibox.hostEmitter"),TR=()=>{let e=new Vt;return globalThis[Rl]||(globalThis[Rl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Rl]},be=TR();ha=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new qi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return RR(i,r),n(...i)}}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}};ha=bh([Sh],ha);ql=class{constructor(){this._onWillExecuteCommand=new qi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new qi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new ha,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=hR(3e4)),this._starActivation}executeCommand(e,...t){return tn(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Ll.toPromise(Ll.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}}};ql=bh([Sh],ql);Dh=Symbol.for("Jolibox.commands")});function Ie(e,t={}){$l.emit("ERROR_REPORT",{error:e,options:t})}var $l,nn,gt=P(()=>{"use strict";O();O();$l=new Vt,nn=new Vt;Ie.debounce=Fi(Ie,50,{leading:!0})});var Vl,LR,Lh,qh,Mh=P(()=>{"use strict";O();gt();Vl=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(i){return{}}},LR=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Lh=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:Vl(o),payloadJson:Vl(a),signature:Vl(s)}}else throw"joli_source is missing"}catch(r){return Ie(new Ch(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},qh=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=LR(e),o=r[2];return`${n}.${i}.${o}`}return t}});var qR,Wl,Uh=P(()=>{"use strict";O();qR="1.3.4",Wl=()=>qR});function Kl(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var MR,Fh,zl,jh,ge,UR,I,J=P(()=>{"use strict";O();Mh();Uh();O();MR={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Rh(),adId:Oh(),pixelRatio:window.devicePixelRatio||1,platform:Bi.isAndroid?"android":Bi.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Wl()},schema:window.location.href,platform:Bi.isAndroid?"android":Bi.isiOS?"ios":"h5"},zl=(Fh=globalThis.joliboxJSCore)==null?void 0:Fh.env,ge=Object.assign({},(jh=zl==null?void 0:zl())!=null?jh:MR);UR=()=>{var g,b,v,w,S,x,A,C,k,B,le;let{payloadJson:e,headerJson:t,signature:r}=ge.schema.length?Lh(ge.schema):{},n=`${ge.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ge.schema.length?ge.schema:window.location.href).searchParams,a=(v=(b=(g=o.get("mpId"))!=null?g:o.get("appId"))!=null?b:o.get("gameId"))!=null?v:"",s=(x=(S=(w=ge.clientSessionId)!=null?w:e==null?void 0:e.sessionId)!=null?S:o.get("sessionId"))!=null?x:n,c=!!((C=(A=e==null?void 0:e.testAdsMode)!=null?A:e==null?void 0:e.__testAdsMode)!=null?C:o.get("testAdsMode")==="true"),l=(le=(B=(k=e==null?void 0:e.joliboxEnv)!=null?k:e==null?void 0:e.__joliboxEnv)!=null?B:o.get("joliboxEnv"))!=null?le:"production",d=l==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,m=e==null?void 0:e.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var N,R;return(R=(N=f.get("joliSource"))!=null?N:o.get("joliSource"))!=null?R:null},get mpId(){var N;return(N=a!=null?a:e==null?void 0:e.id)!=null?N:""},get mpVersion(){var N;return(N=t==null?void 0:t.ver)!=null?N:Wl()},get mpType(){var N,R;return(R=(N=t==null?void 0:t.__mpType)!=null?N:e==null?void 0:e.__mpType)!=null?R:"game"},get platform(){var N;return((N=ge.platform)!=null?N:ge.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ge.deviceInfo},get sdkInfo(){return ge.sdkInfo},get hostInfo(){return ge.hostInfo},get hostUserInfo(){return ge.hostUserInfo},get sessionId(){var N,R;return(R=(N=ge.clientSessionId)!=null?N:s)!=null?R:n},get channel(){return u},get webviewId(){var N;return(N=ge.webviewId)!=null?N:-1},get shouldInterupt(){return m},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Hl(d)},get adId(){var N;return(N=ge.deviceInfo.adId)!=null?N:ge.deviceInfo.did},get language(){return ge.deviceInfo.lang},get sdkEnvironment(){return Kl("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Kl("gamedistribution","jolibox")?"gamedistribution":Kl("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var ee,ie,lr;let N=(ee=ge.deviceInfo.pixelRatio)!=null?ee:1,R=(ie=ge.deviceInfo.statusBarHeight)!=null?ie:e==null?void 0:e.__androidStatusBarHeight,F=(lr=ge.deviceInfo.navigationBarHeight)!=null?lr:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:R!==void 0?R/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,R;return(R=(N=ge.abValues)==null?void 0:N.split(","))!=null?R:[]},get mpInfo(){var N;return(N=ge.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{Ih(ge,N,Eh)},encodeJoliSourceQuery:N=>{var R,F;return t&&r?qh(T(T({},e),N),(R=o.get("joliSource"))!=null?R:""):(F=o.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{m=!1}}},I=UR()});var Yl,Bh,FR,jR,Gh,GR,Jh=P(()=>{"use strict";O();gt();J();O();Yl=!1,Bh=(e,t)=>e==null?!1:t in e,FR=e=>Bh(e,"kind"),jR=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Gh=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=I.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:jR(e.name)},i=j(T({},n),{env:t.environment,isFromUser:r});r?nn.emit("GLOBAL_USER_ERROR",e,i):nn.emit("GLOBAL_ERROR",e,i)},GR=e=>Bh(e,"kind")&&e.kind==="USER_ERROR";$l.on("ERROR_REPORT",({error:e,options:t})=>{if(Yl)return;Yl=!0;let r=FR(e)&&e.raw?e.raw:e;try{let n=GR(e);Gh(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new jl(`${i}, origin error: ${r.message}`);$t.error(o),Gh(new jl(o.message),{environment:t.environment},!1)}finally{Yl=!1}})});var Qe,Ql,Lr=P(()=>{"use strict";gt();O();gt();Qe=(e,t)=>{var r,n;return new Gi((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Ql=e=>new kh(e)});var Hh=P(()=>{"use strict";Jh();Lr();O();ue();nn.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};U("trackAsync",{event:"reportJsError",data:r})});nn.on("GLOBAL_USER_ERROR",(e,t)=>{$t.log("UserError",e,t)})});var Xl=P(()=>{"use strict"});function $h(e,t){let r=(n,i,o)=>{let l=i!=null?i:{},{eventType:a}=l,s=Ye(l,["eventType"]),c=j(T({tag:n,eventType:o!=null?o:a!=null?a:$.Other},t),{extra:T({},s)});n=="globalJsError"?Ie(new xh(JSON.stringify(c))):e("systemLog",c,I.webviewId)};return r.debounce=Fi(r,500,{leading:!0}),r}function Vh(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=Fi(t,500,{leading:!0}),t}var Wh=P(()=>{"use strict";O();O();gt();J()});function zh(e,t){let r=$h(e,t),n=Vh(r);return{track:r,trackPerformance:n}}var Kh=P(()=>{"use strict";Wh()});var Yh=P(()=>{"use strict";J();O();O()});var Qh=P(()=>{"use strict";Kh();Xl();Yh()});var _a,Xh=P(()=>{"use strict";_a=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},c=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),u()}}}}});function wa(e,t,r){var c,l,d;let n=new Map,i=(c=r==null?void 0:r.baseUrl)!=null?c:Mn(I.testMode),o=(l=r==null?void 0:r.type)!=null?l:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return Ne("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:g,state:b}=f,v=Ye(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(v):p.reject(v),n.delete(g)}else if(u.state==="fail"){let m=u,{requestTaskId:g,state:b}=m,v=Ye(m,["requestTaskId","state"]);p.reject(v),n.delete(g)}else $t.warn("onRequestTaskStateChange unknown event",u)}),be.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>y(this,[f,...m],function*(u,p={}){let g=Date.now(),b=BR(u,j(T({},p),{baseUrl:i})),{method:v="GET",responseType:w="text",dataType:S="json",timeout:x,enableCache:A=!1,appendHostCookie:C=!0}=p,k=Object.assign({"content-type":"application/json"},a,p.header),B={url:b,method:v,header:k,enableCache:A,responseType:w,appendHostCookie:C};if(v=="POST"||v=="PUT"){let ee=HR(p.data,k["content-type"]);B.data=ee}x&&Object.assign(B,{timeout:x});let{data:{requestTaskId:le}}=U(e,B);if(typeof le!="string")throw Qe({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:R,promise:F}=new lt;n.set(le,{resolve:N,reject:R});try{let ee=yield F,{data:ie}=ee;return S==="json"&&typeof ie=="string"&&(ie=JR(ie)),{url:b,timeout:x,method:v,response:j(T({},ee),{data:ie})}}catch(ee){let ie=ee;if(rn(ie)){let{errMsg:lr,prefetchDetail:o9,isPrefetch:a9,errNo:nT}=ie;Mi(lr)&&Ie(Qe({code:-1,msg:lr},{errNo:nT,errMsg:lr}))}throw ee}})}function JR(e){try{return JSON.parse(e.trim())}catch(t){return e}}function HR(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 BR,Zl=P(()=>{"use strict";O();ue();gt();Lr();J();BR=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,i=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${i?`?${i}`:""}`:`${e}${i?`?${i}`:""}`}});var eu,Zh,re,vt=P(()=>{"use strict";Zl();J();O();eu={};(Zh=I.hostUserInfo)!=null&&Zh.token&&(eu["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(eu["x-joli-source"]=I.joliSource);re=wa("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Mn(I.testMode),defaultHeaders:eu})});function eg(e){let t=Gl.config[e];return t||(t={},Gl.config[e]=t),(r,n)=>{if(t[r]){$t.warn(`[can i use] ${r} already registered`);return}t[r]=T({},n)}}var tg=P(()=>{"use strict";O()});function tu(e){rg=e}function Sa(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Sa(t)):Object.keys(e).reduce((t,r)=>(t[r]=Sa(e[r]),t),{})}function dr(e){return typeof e=="number"}function ru(e){let t=nu(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function nu(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var rg,Ce,Ia,Ea,ka,Ca,Un,Aa,xa,Pa,Ta,Ra,Oa,Na,Da,La,qa,Ma,Ua,iu=P(()=>{"use strict";rg=!1;Ce=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(rg)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 ${ru(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Sa(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Sa(this._default)}optional(){return this._optional=!0,this}};Ia=class extends Ce{validate(t){return this._optional&&t===void 0?!0:dr(t)?dr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):dr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):dr(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}},Ea=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ka=class extends Ce{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(dr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(dr(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}},Ca=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Un=class extends Ce{validate(t){return!0}},Aa=class extends Ce{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},xa=class extends Ce{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Pa=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Ta=class extends Ce{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 ${ru(t)}`)}return!0}},Ra=class extends Ce{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(dr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(dr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(dr(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 i=!0;if(r.forEach((o,a)=>{if(n.path=`${this.path}[${a}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[a]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[a]=n.fallbackValue:i=!1)}),this._uniqueItems){let o=new Map;for(let a in r)o.has(r[a])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[a])}] and ${this.path}[${a}] are identical)`):o.set(r[a],a)}return i}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}},Oa=class extends Ce{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(nu(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,o=this._value;o.errors=this.errors;let a=!0;for(let s in i){let c=i[s];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?o.path=`${this.path}.${s}`:o.path=`${this.path}["${s}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},Na=class extends Ce{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(nu(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let o in this._object){let a=n[o],s=this._object[o];if(s.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?s.path=`${this.path}.${o}`:s.path=`${this.path}["${o}"]`,!(s._optional&&a===void 0)){if(a===void 0&&s.hasDefault){n[o]=s.defaultValue;continue}s.validate(a)||(s.hasFallback?n[o]=s.fallbackValue:i=!1)}}return i}},Da=class extends Ce{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:ru(this.value),actual:r}):!0}},La=class extends Ce{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let o=0;o<i;o++){let a=this._items[o];if(a.errors=[],a.path=this.path,!a.validate(t))r.push(a.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
|
|
2
2
|
or `);this.errors.push(o)}return n}},qa=class extends Ce{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let i=t[n];if(i._optional||i.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,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,t[i]===void 0&&n.hasDefault){t[i]=n.defaultValue;return}n.validate(t[i])||(n.hasFallback?t[i]=n._fallback:r=!1)}),r}},Ma=class extends Ce{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},Ua=class extends Ce{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 ou(e,t,r="param"){if(e.errors=[],e.path=r,tu(!0),!e.validate(t)){let n=e.errors.join(`
|
|
3
3
|
`);throw e.errors.length=0,tu(!1),new TypeError(n)}}var E,au=P(()=>{"use strict";iu();iu();E={object(e){return new Na(e)},array(e){return new Ra(e)},tuple(...e){return new qa(...e)},literal(e){return new Da(e)},or(...e){return new La(...e)},symbol(){return new Ca},record(e){return new Oa(e)},function(){return new Pa},boolean(){return new Ea},string(){return new ka},number(){return new Ia},undefined(){return new Aa},null(){return new xa},unknown(){return new Un},any(){return new Un},as(){return new Un},arraybuffer(){return new Ma},enum(...e){return new Ta(...e)},typedarray(e){return new Ua(e)}}});var Fa,ng,ig=P(()=>{"use strict";O();gt();au();Lr();Fa=1,ng=e=>{function t(n,i){return(...o)=>{var u,p,f,m;let a=Date.now(),s={method:n,trace_id:Fa};Fa+=1;let c="SUCCESS",l=`${n}:ok`,d=0;try{if(i.paramsSchema)try{ou(i.paramsSchema,o,"params")}catch(w){throw Ql(`${n}:fail ${w.message}`)}let g=i.implement(...o),b=g,v=`${n}:ok`;if(g&&"code"in g){let{code:w,data:S,message:x}=g;c=w,b=S,v=x}return{code:c,message:v,data:b}}catch(g){let b=g;d=(p=(u=b.code)!=null?u:b.errNo)!=null?p:2e3,c="FAILURE";let v=(m=(f=b.message)!=null?f:b.errMsg)!=null?m:`${g}`;return l=`${n}:${c} ${v.replace(/^\S+:(fail|cancel)\s?/,"")}`,Ie(new Gi(l,d)),{code:c,message:l}}finally{let g=Date.now()-a}}}function r(n,i){return(...o)=>y(this,null,function*(){var p,f,m,g;let a=_h(o)?o:[o],s=Date.now(),c={method:n,trace_id:Fa};Fa+=1;let l=`${n}:ok`,d="SUCCESS",u={code:d,message:l};try{if(i.paramsSchema)try{ou(i.paramsSchema,a,"params")}catch(w){throw Ql(w.message)}let v=yield i.implement(...a);if(v&&"code"in v){let{code:w,data:S,message:x}=v;d=w,l=x,v=S}return Object.assign(u,{code:d,message:l,data:v}),u}catch(b){let v=b,w=(f=(p=v.code)!=null?p:v.errNo)!=null?f:2e3;d="FAILURE";let S=(g=(m=v.message)!=null?m:v.errMsg)!=null?g:`${b}`,x=`${n}:${d} ${S.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:x}),Ie(new Gi(x,w)),u}finally{let b=Date.now()-s}})}return{createAPI:r,createSyncAPI:t}}});var Fe,su=P(()=>{"use strict";J();ue();({canIUseNative:Fe}=sh(()=>I.sdkInfo.nativeSDKVersionCode,()=>I.platform))});function cu(e){if(typeof e!="number"||e<=0)return"0.0.0";let t=e.toString(),r=0,n=0,i=0;return t.length>=1&&(r=parseInt(t.substring(0,1),10)),t.length>=3&&(n=parseInt(t.substring(1,3),10)),t.length>=5&&(i=parseInt(t.substring(3,5),10)),`${r}.${n}.${i}`}var og=P(()=>{"use strict"});var oe,z,M,Be=P(()=>{"use strict";tg();xt();ig();au();su();og();({createAPI:oe,createSyncAPI:z}=ng(G)),M=eg("native")});function ag(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return t==="array"&&(t="object"),YR.includes(t)?t:""}function sg(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function cg(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var ja,VR,WR,zR,KR,Gz,Bz,YR,qr,yt,Ji=P(()=>{"use strict";Be();ue();O();vt();J();ja=V(),VR=oe("getLocalStorage",{paramsSchema:E.tuple(E.string()),implement(e){return y(this,null,function*(){let{response:t}=yield re(`/api/games/user-storage/${I.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:i}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:i==null?void 0:i.value};try{let{data:{data:o,dataType:a}}=yield me("getLocalStorageAsync",{key:e}),s=sg(o,a);return{code:r,message:`${n}. fallback to native`,data:s}}catch(o){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});ja.registerCommand("StorageSDK.getItem",VR);M("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});WR=oe("setStorage",{paramsSchema:E.tuple(E.string(),E.or(E.string(),E.boolean(),E.number())),implement(e,t){return y(this,null,function*(){let r=I.mpId,n=typeof t=="string"?t:String(t),{response:i}=yield re(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:a}}=i,s=ag(t),c=cg(t,s);return yield me("setLocalStorageAsync",{key:e,data:c,dataType:s}),o=="SUCCESS"?{code:o,message:a}:{code:o,message:`${a}. fallback to native`}})}});ja.registerCommand("StorageSDK.setItem",WR);M("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});zR=oe("removeStorage",{paramsSchema:E.tuple(E.string()),implement(e){return y(this,null,function*(){let t=I.mpId,{response:r}=yield re(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:i}}=r;return yield me("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:i}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ja.registerCommand("StorageSDK.removeItem",zR);M("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});KR=oe("clearStorage",{implement(){return y(this,null,function*(){let e=I.mpId,{response:t}=yield re(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});me("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ja.registerCommand("StorageSDK.clear",KR);M("storage.clear",{version:"1.0.0"});Gz=oe("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield me("getStorageInfoAsync");return e})}});M("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});Bz=z("getStorageInfoSync",{implement(){return U("getStorageInfoSync")}}),YR=["string","number","boolean","object",""];qr=oe("getGlobalStorage",{paramsSchema:E.tuple(E.string()),implement(e){return y(this,null,function*(){try{let{data:{data:t,dataType:r}}=yield me("getGlobalStorageAsync",{key:e});return{code:"SUCCESS",message:"success",data:sg(t,r)}}catch(t){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get global storage failed",data:null}}})}}),yt=oe("setGlobalStorage",{paramsSchema:E.tuple(E.string(),E.or(E.string(),E.boolean(),E.number(),E.array())),implement(e,t){return y(this,null,function*(){try{let r=ag(t),n=cg(t,r);return yield me("setGlobalStorageAsync",{key:e,data:n,dataType:r}),{code:"SUCCESS",message:"success"}}catch(r){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] set global storage failed"}}})}})});var lg,Ga,ug=P(()=>{"use strict";J();Xh();O();vt();ue();Ji();su();lg="REPORT_FIRST_OPEN_GAME",Ga=class extends _a{constructor(t,r,n){super(r,n),this.gameId=I.mpId,this.sessionId=I.sessionId,this.track=t,this.taskUrl=Mn(I.testMode)+"/api/base/app-event"}reporter(t){return y(this,null,function*(){let{event:r,params:n,extraParams:i}=t,o={eventType:r,gameInfo:T({gameId:this.gameId,sessionId:this.sessionId},n)};i&&Object.assign(o,i),yield this.createTask(o)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield me("userTrackAsync",{event:r,params:T({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}start(t){super.start(t),this.tryReportOpenGamePlus()}tryReportOpenGamePlus(){qr(lg).then(t=>{Dr(t.data)&&t.data&&this.tracker("OpenGame_2Plus"),yt(lg,!0)})}createTask(t){return Fe("sendServerEventAsync")?me("sendServerEventAsync",{payload:t}):I.platform==="android"?re("/api/base/app-event",{method:"POST",data:t}):me("trackAppEventAsync",{url:this.taskUrl,body:JSON.stringify(t)})}}});var hg={};Hm(hg,{nativeTaskEmitter:()=>Hi,taskTracker:()=>Lt,track:()=>G,trackPerformance:()=>fg});var QR,dg,pg,G,fg,mg,Hi,Lt,xt=P(()=>{"use strict";Hh();O();Xl();Qh();J();ug();ue();QR=(e,t,r)=>{var l,d,u,p,f,m,g;let n=t,i=rn(n.extra)?n.extra:Mi(n.extra)?JSON.parse(n.extra):{},{mpName:o,mpVersion:a}=(l=I.mpInfo)!=null?l:{},s=T(T(j(T({},i),{mp_id:(d=n.mp_id)!=null?d:"",mp_version:(u=n.mp_version)!=null?u:"",session_id:I.sessionId,user_id:(f=(p=I.hostUserInfo)==null?void 0:p.uid)!=null?f:""}),o?{mp_name:o}:{}),a?{mp_info_version:a}:{}),c=(m=n.eventType)!=null?m:$.Other;U("trackAsync",{event:(g=t.tag)!=null?g:e,data:s,webviewId:r,eventType:c})},{track:G,trackPerformance:fg}=zh(QR,{type:Bl.AppSDK,platform:"native",jssdk_version:(pg=(dg=I.sdkInfo)==null?void 0:dg.jssdkVersion)!=null?pg:"1.0.0",mp_id:I.mpId,mp_version:I.mpVersion}),mg=V();mg.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{fg(e,t,r)});mg.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{G(e,t)});Hi=new Vt,Lt=new Ga(G,Hi)});function gg(){let e=null,t=null,r=window.fetch,n=()=>{t=document.createElement("meta"),t.setAttribute("name","viewport"),t.setAttribute("content","viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"),t.setAttribute("data-jolibox-sdk","viewport-meta"),e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
|
|
4
4
|
html[data-jolibox-root] {
|
package/implement.build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:esm && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/implement@1.3.
|
|
3
|
+
> @jolibox/implement@1.3.4 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.3.
|
|
7
|
+
> @jolibox/implement@1.3.4 build:esm
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.4",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@jolibox/common": "1.3.
|
|
10
|
-
"@jolibox/types": "1.3.
|
|
11
|
-
"@jolibox/native-bridge": "1.3.
|
|
12
|
-
"@jolibox/ads": "1.3.
|
|
9
|
+
"@jolibox/common": "1.3.4",
|
|
10
|
+
"@jolibox/types": "1.3.4",
|
|
11
|
+
"@jolibox/native-bridge": "1.3.4",
|
|
12
|
+
"@jolibox/ads": "1.3.4",
|
|
13
13
|
"localforage": "1.10.0",
|
|
14
|
-
"@jolibox/ui": "1.3.
|
|
14
|
+
"@jolibox/ui": "1.3.4",
|
|
15
15
|
"web-vitals": "4.2.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|