@jolibox/implement 1.3.5-beta.2 → 1.3.5-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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": "edf044c001e6b6ed1a96c5b283563410b777d272",
7
+ "packages/implement/package.json": "ea59a854244228f2dfc02dfcf4d82edd380d82e6",
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 Hf=Object.create;var Wi=Object.defineProperty,qf=Object.defineProperties,Vf=Object.getOwnPropertyDescriptor,$f=Object.getOwnPropertyDescriptors,Kf=Object.getOwnPropertyNames,nn=Object.getOwnPropertySymbols,Ks=Object.getPrototypeOf,zi=Object.prototype.hasOwnProperty,Ws=Object.prototype.propertyIsEnumerable,Wf=Reflect.get;var $s=(e,t,r)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,z=(e,t)=>{for(var r in t||(t={}))zi.call(t,r)&&$s(e,r,t[r]);if(nn)for(var r of nn(t))Ws.call(t,r)&&$s(e,r,t[r]);return e},Re=(e,t)=>qf(e,$f(t));var gr=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var zs=(e,t)=>{var r={};for(var n in e)zi.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&nn)for(var n of nn(e))t.indexOf(n)<0&&Ws.call(e,n)&&(r[n]=e[n]);return r};var re=(e,t)=>()=>(e&&(t=e(e=0)),t);var Yi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var zf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Kf(t))!zi.call(e,i)&&i!==r&&Wi(e,i,{get:()=>t[i],enumerable:!(n=Vf(t,i))||n.enumerable});return e};var Xi=(e,t,r)=>(r=e!=null?Hf(Ks(e)):{},zf(t||!e||!e.__esModule?Wi(r,"default",{value:e,enumerable:!0}):r,e));var Ys=(e,t,r)=>Wf(Ks(e),r,t);var A=(e,t,r)=>new Promise((n,i)=>{var a=l=>{try{s(r.next(l))}catch(c){i(c)}},o=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,o);s((r=r.apply(e,t)).next())});function nh(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function oa(e){return typeof e=="string"}function nl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function il(e){return typeof e=="object"&&Array.isArray(e)}function ih(e){return typeof e=="undefined"}function ah(e){return ih(e)||e===null}function oh(e){return typeof e=="function"}function al(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function ol(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,a){for(let o in a)if(Object.prototype.hasOwnProperty.call(a,o)){let s=i[o],l=a[o],c=r(s,l,o,i,a);c!==void 0?i[o]=c:Zs(l)&&Zs(s)?i[o]=n(aa({},s),l):Array.isArray(l)&&Array.isArray(s)?i[o]=[...s,...l]:i[o]=l}return i}return n(e,t)}function Zs(e){return e&&typeof e=="object"&&e.constructor===Object}function sl(e,t){if(Array.isArray(e))return e.concat(t)}function wr(e,t,r={}){let n=null,i,a,o,{leading:s=!1,trailing:l=!0}=r,c=()=>(o=e.apply(a,i),i=void 0,a=void 0,o),p=function(...u){i=u,a=this;let m=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!m&&c()},t),m)return c()};return p.cancel=()=>{n&&clearTimeout(n),n=null,i=a=void 0},p.flush=()=>{if(n)return clearTimeout(n),n=null,c()},p}function ch(e,t){return(...r)=>t(e,...r)}function ul(e){return t=>ch(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new lh(`${i}`))}})}function _r(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function an(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((i,a)=>(i[a]=String(n[a]),i),{})}return e[r]})}function ph(e){let t=e.location?an(e.location,tl):null,r=e.target?an(e.target,tl):null;return an(th(aa({},e),{location:t,target:r}),hh)}function ua(e){let t=e.events.map(n=>ph(n)),r=an(e.device,mh);return[e.protocolVersion,t,r,e.project]}function vh(){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 ma(e,t,r){let n=window.location.hostname,i=n.split("."),a=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${a}.jolibox.com`;if(i.length>=2){let o=i.slice(-2).join(".");if(o==="jolibox.com"||o==="pico-game.com"||o==="joyslite.com"||o==="mporia.com"||o==="pingplus.ai")return`${a}.${o}`}return`${a}.jolibox.com`}function ml(e){return ma("app","stg-app",e)}function Kt(e){return`https://${ma("api","stg-api",e)}`}function Ih(e){return ma("collect","stg-collect",e)}function pl(e){return`https://${Ih(e)}`}function Rh(e){return new Promise(t=>vl(e)(t))}function vl(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function Oh(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(a.fire,a)}},a=new br(i);return a.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function Th(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)xh(e[n],t[n])}function xh(e,t){if(oa(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(oh(t)){try{if(e instanceof t)return}catch(r){}if(!ah(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 Ph(){return typeof globalThis!="undefined"?globalThis[gl]:void 0}function Nh(e){typeof globalThis!="undefined"&&(globalThis[gl]=e)}function we(e=!1){let t=Ph();if(!e&&t)return t;let r=new on,n=new na,i={registerCommand(a,o,s){r.registerCommand({id:a,handler:o,metadata:s})},executeCommand(a,...o){return n.executeCommand(a,...o)},excuteCommandSync(a,...o){return n.executeCommandThowErr(a,...o)}};return Nh(i),i}var ia,Yf,Xf,Qf,Xs,Zf,eh,Qs,aa,th,rh,rl,Ot,sh,sa,la,ll,cl,lh,dl,sn,ln,ca,Be,Zi,dh,da,el,uh,kt,$t,fh,tl,hh,mh,$e,Vt,gh,Oe,_h,yh,bh,fl,fa,ha,wh,Eh,hl,Tt,ea,ae,Ah,Sh,yr,br,ze,ra,Ch,Qi,kh,bt,on,na,gl,q=re(()=>{"use strict";ia=Object.defineProperty,Yf=Object.defineProperties,Xf=Object.getOwnPropertyDescriptor,Qf=Object.getOwnPropertyDescriptors,Xs=Object.getOwnPropertySymbols,Zf=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,Qs=(e,t,r)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,aa=(e,t)=>{for(var r in t||(t={}))Zf.call(t,r)&&Qs(e,r,t[r]);if(Xs)for(var r of Xs(t))eh.call(t,r)&&Qs(e,r,t[r]);return e},th=(e,t)=>Yf(e,Qf(t)),rh=(e,t)=>{for(var r in t)ia(e,r,{get:t[r],enumerable:!0})},rl=(e,t,r,n)=>{for(var i=n>1?void 0:n?Xf(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,r,i):o(i))||i);return n&&i&&ia(t,r,i),i},Ot=(e,t,r)=>new Promise((n,i)=>{var a=l=>{try{s(r.next(l))}catch(c){i(c)}},o=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,o);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}sh=(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))(sh||{}),sa=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}},la=class extends sa{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},ll=class extends sa{constructor(){super(...arguments),this.kind="USER_ERROR"}},cl=class extends ll{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},lh=class extends ll{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))}},dl=class extends la{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},sn=class extends la{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},ln=class extends sa{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}}},ca=class extends la{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Be={log:_r("log"),warn:_r("warn"),info:_r("info"),error:_r("error"),debug:_r("debug")};Object.assign(globalThis,{logger:Be});Zi=Symbol.for("Jolibox.canIUseMap"),dh={};globalThis[Zi]||(globalThis[Zi]=dh);da={get config(){return globalThis[Zi]}},el=Symbol.for("Jolibox.canIUseMap.native"),uh={};globalThis[el]||(globalThis[el]=uh);kt=(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))(kt||{}),$t=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))($t||{}),fh=(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))(fh||{}),tl=["name","params"],hh=["name","type","location","target","extra","timestamp","userId"],mh=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];$e=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});vh();Vt=typeof window=="undefined",gh=()=>!Vt&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Oe={isiOS:!Vt&&(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:!Vt&&navigator.userAgent.includes("Android"),isMac:!Vt&&navigator.userAgent.includes("Mac"),isFacebook:!Vt&&navigator.userAgent.includes("FB_IAB"),isPC:!Vt&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},_h=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",yh="device_id",bh="advertising_id",fl=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,$e()),window.__joliboxLocalStorage__.getItem(e)),fa=()=>new URLSearchParams(window.location.search).get("deviceId")||fl(yh),ha=()=>new URLSearchParams(window.location.search).get("advertisingId")||fl(bh),wh=e=>e.charAt(0).toUpperCase()+e.slice(1),Eh=()=>{var e;let t=new URLSearchParams(window.location.search);return wh((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},hl=e=>{if(gh())return window.navigator.userAgent;let t="JoliboxWebSDK",r=_h(),n=navigator.language,i=fa(),a=ha();return`${t} (${Eh()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${a} version/${e||""}`};Tt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=aa({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return Ot(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),a=this.createTimeoutPromise(),o=Promise.race([i,a]).catch(s=>Ot(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(r);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}throw s}));this.pendingRequests.set(r,o),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 o}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return Ot(this,null,function*(){var r,n,i,a;let o=this.config.keyGenerator(e,t),s=++this.requestSequence,l=this.getValidCachedData(o);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",l),l){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),m=this.requestAdapter.extractRealTimeData(u),h=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return h&&!this.config.consistencyChecker(l,h)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(o,h,s),u):this.requestAdapter.mergeData(l,m)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let c=yield this.requestAdapter.execute(e,t),p=(a=(i=this.requestAdapter).extractCacheableData)==null?void 0:a.call(i,c);return p&&this.setCachedDataWithSequence(o,p,s),c})}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 a=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:a,expiresAt:a+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 Ot(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return Ot(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),a=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${a})`);let o=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,o);return s&&(this.setCachedDataWithSequence(i,s,a),console.log(`[RequestCacheService] Force updated cache for ${e}`)),o})}warmupCache(e,t){return Ot(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)}},ea=class ta{constructor(t){this.element=t,this.next=ta.Undefined,this.prev=ta.Undefined}};ea.Undefined=new ea(void 0);ae=ea,Ah=class{constructor(){this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ae.Undefined}clear(){let e=this._first;for(;e!==ae.Undefined;){let t=e.next;e.prev=ae.Undefined,e.next=ae.Undefined,e=t}this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new ae(e);if(this._first===ae.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!==ae.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ae.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ae.Undefined&&e.next!==ae.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ae.Undefined&&e.next===ae.Undefined?(this._first=ae.Undefined,this._last=ae.Undefined):e.next===ae.Undefined?(this._last=this._last.prev,this._last.next=ae.Undefined):e.prev===ae.Undefined&&(this._first=this._first.next,this._first.prev=ae.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ae.Undefined;)yield e.element,e=e.next}},Sh=0,yr=class{constructor(e){this.value=e,this.id=Sh++}},br=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 yr&&(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,a,o,s,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new yr(t);return this._listeners?this._listeners instanceof yr?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(o=(a=this.options)==null?void 0:a.onDidFirstListener)==null||o.call(a,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var p,u,m,h;if(!this._disposed){if(this._listeners instanceof yr)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(u=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||u.call(p));else if(this._listeners){let w=this._listeners.indexOf(c);w>=0&&(this._listeners.splice(w,1),this._size--,this._size===0&&((h=(m=this.options)==null?void 0:m.onDidRemoveLastListener)==null||h.call(m)))}}}}),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 yr?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ze=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 br,a=l=>t(...l.args),o=i.event(a);this.listerHandlerMap.set(t,{handler:a,dispose:o}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let l of s)t(...l.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 Ah,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)}},ra={};rh(ra,{None:()=>Ch,filter:()=>Oh,once:()=>vl,toPromise:()=>Rh});Ch=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Qi=Symbol.for("Jolibox.hostEmitter"),kh=()=>{let e=new ze;return globalThis[Qi]||(globalThis[Qi]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Qi]},bt=kh();on=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new br,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 Th(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}};on=rl([al],on);na=class{constructor(){this._onWillExecuteCommand=new br,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new br,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new on,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=nh(3e4)),this._starActivation}executeCommand(e,...t){return Ot(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ra.toPromise(ra.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}}};na=rl([al],na);gl=Symbol.for("Jolibox.commands")});function Me(e,t={}){pa.emit("ERROR_REPORT",{error:e,options:t})}var pa,xt,rt=re(()=>{"use strict";q();q();pa=new ze,xt=new ze;Me.debounce=wr(Me,50,{leading:!0})});var va,Dh,_l,yl,bl=re(()=>{"use strict";q();rt();va=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{}}},Dh=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},_l=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[a,o,s]=i;return{headerJson:va(a),payloadJson:va(o),signature:va(s)}}else throw"joli_source is missing"}catch(r){return Me(new dl(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},yl=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=Dh(e),a=r[2];return`${n}.${i}.${a}`}return t}});var Lh,cn,wl,ga=re(()=>{"use strict";q();Lh="1.3.5-beta.2",cn=()=>Lh,wl=()=>{let e=cn();return`${hl(e)}`}});function ya(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var Uh,El,_a,Il,oe,Bh,L,he=re(()=>{"use strict";q();bl();ga();q();Uh={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:fa(),adId:ha(),pixelRatio:window.devicePixelRatio||1,platform:Oe.isAndroid?"android":Oe.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:cn()},schema:window.location.href,platform:Oe.isAndroid?"android":Oe.isiOS?"ios":"h5"},_a=(El=globalThis.joliboxJSCore)==null?void 0:El.env,oe=Object.assign({},(Il=_a==null?void 0:_a())!=null?Il:Uh);Bh=()=>{var E,I,b,R,k,D,J,S,N,F,H;let{payloadJson:e,headerJson:t,signature:r}=oe.schema.length?_l(oe.schema):{},n=`${oe.deviceInfo.did}-${new Date().getTime()}`,a=new URL(oe.schema.length?oe.schema:window.location.href).searchParams,o=(b=(I=(E=a.get("mpId"))!=null?E:a.get("appId"))!=null?I:a.get("gameId"))!=null?b:"",s=(D=(k=(R=oe.clientSessionId)!=null?R:e==null?void 0:e.sessionId)!=null?k:a.get("sessionId"))!=null?D:n,l=!!((S=(J=e==null?void 0:e.testAdsMode)!=null?J:e==null?void 0:e.__testAdsMode)!=null?S:a.get("testAdsMode")==="true"),c=(H=(F=(N=e==null?void 0:e.joliboxEnv)!=null?N:e==null?void 0:e.__joliboxEnv)!=null?F:a.get("joliboxEnv"))!=null?H:"production",p=c==="staging",u=t==null?void 0:t.channel,h=new URL(window.location.href).searchParams,w=e==null?void 0:e.__shouldInterupt;return{get startTime(){var U;return(U=performance.timeOrigin)!=null?U:performance.timing.navigationStart},get testMode(){return p},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var U,M;return(M=(U=h.get("joliSource"))!=null?U:a.get("joliSource"))!=null?M:null},get mpId(){var U;return(U=o!=null?o:e==null?void 0:e.id)!=null?U:""},get mpVersion(){var U;return(U=t==null?void 0:t.ver)!=null?U:cn()},get mpType(){var U,M;return(M=(U=t==null?void 0:t.__mpType)!=null?U:e==null?void 0:e.__mpType)!=null?M:"game"},get platform(){var U;return((U=oe.platform)!=null?U: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 U,M;return(M=(U=oe.clientSessionId)!=null?U:s)!=null?M:n},get channel(){return u},get webviewId(){var U;return(U=oe.webviewId)!=null?U:-1},get shouldInterupt(){return w},get from(){return e==null?void 0:e.__from},get baseApiHost(){return ml(p)},get adId(){var U;return(U=oe.deviceInfo.adId)!=null?U:oe.deviceInfo.did},get language(){return oe.deviceInfo.lang},get sdkEnvironment(){return ya("dlightek","jolibox")?"dlightek":a.get("huaweiQuick")==="true"?"huaweiQuick":ya("gamedistribution","jolibox")?"gamedistribution":ya("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var K,Y,Ue;let U=(K=oe.deviceInfo.pixelRatio)!=null?K:1,M=(Y=oe.deviceInfo.statusBarHeight)!=null?Y:e==null?void 0:e.__androidStatusBarHeight,G=(Ue=oe.deviceInfo.navigationBarHeight)!=null?Ue:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:M!==void 0?M/U:20,navigationBarHeight:G!==void 0?G/U:10}},get abTests(){var U,M;return(M=(U=oe.abValues)==null?void 0:U.split(","))!=null?M:[]},get mpInfo(){var U;return(U=oe.mpInfo)!=null?U:{mpName:"unknown"}},onEnvConfigChanged:U=>{ol(oe,U,sl)},encodeJoliSourceQuery:U=>{var M,G;return t&&r?yl(z(z({},e),U),(M=a.get("joliSource"))!=null?M:""):(G=a.get("joliSource"))!=null?G:""},setDoExitDirectly:()=>{w=!1}}},L=Bh()});var ba,Sl,Mh,Gh,Al,Jh,Cl=re(()=>{"use strict";q();rt();he();q();ba=!1,Sl=(e,t)=>e==null?!1:t in e,Mh=e=>Sl(e,"kind"),Gh=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Al=(e,t={},r)=>{var a,o,s;let n={user_id:(o=(a=L.hostUserInfo)==null?void 0:a.uid)!=null?o:"",device_id:(s=L.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:Gh(e.name)},i=Re(z({},n),{env:t.environment,isFromUser:r});r?xt.emit("GLOBAL_USER_ERROR",e,i):xt.emit("GLOBAL_ERROR",e,i)},Jh=e=>Sl(e,"kind")&&e.kind==="USER_ERROR";pa.on("ERROR_REPORT",({error:e,options:t})=>{if(ba)return;ba=!0;let r=Mh(e)&&e.raw?e.raw:e;try{let n=Jh(e);Al(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),a=new ca(`${i}, origin error: ${r.message}`);Be.error(a),Al(new ca(a.message),{environment:t.environment},!1)}finally{ba=!1}})});var wa,Ea=re(()=>{"use strict";rt();q();rt();wa=e=>new cl(e)});function Rl(e,t){let r=(n,i,a)=>{let c=i!=null?i:{},{eventType:o}=c,s=zs(c,["eventType"]),l=Re(z({tag:n,eventType:a!=null?a:o!=null?o:kt.Other},t),{extra:z({},s)});n=="globalJsError"?Me(new sn(JSON.stringify(l))):e("systemLog",l,L.webviewId)};return r.debounce=wr(r,500,{leading:!0}),r}function Ol(e){let t=(r,n,i)=>{var s;let a=(s=i&&JSON.stringify(i))!=null?s:0,o={speed_value_type:r,total_duration:n};a&&Object.assign(o,{extra:a}),e("joliboxSpeedAnalysis",o)};return t.debounce=wr(t,500,{leading:!0}),t}var kl=re(()=>{"use strict";q();q();rt();he()});function Tl(e,t){let r=Rl(e,t),n=Ol(r);return{track:r,trackPerformance:n}}var xl=re(()=>{"use strict";kl()});var Ia=re(()=>{"use strict"});var dn,Pl=re(()=>{"use strict";he();q();q();dn=class{constructor(t){this.apiHost=t;this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return A(this,null,function*(){let r=`${this.apiHost}/api/fe-configs/js-sdk/samples-config`,n=yield(yield fetch(r)).json();this.samplesConfig=n})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[n,i]of Object.entries(r))if(i.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(n);return!1}getDevice(){var n,i,a,o,s;let{nativeSDKVersion:t,jssdkVersion:r}=L.sdkInfo;return{platform:1e3,os:L.deviceInfo.platform,appVersion:(n=t!=null?t:r)!=null?n:"1.0.0",appId:(a=(i=L.hostInfo)==null?void 0:i.aid)!=null?a:"1",model:(o=L.deviceInfo.model)!=null?o:"UnknownModel",brand:(s=L.deviceInfo.brand)!=null?s:"UnknownBrand",uuid:L.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:"GamePage",params:r}}trackEvent(t,r,n){return A(this,null,function*(){if(this.checkIsSampled(t))return;let i=t.location?t.location:yield this.getLocation(),a=t.target||null,o=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let s=this.deviceInfo,c={protocolVersion:"1.0.0",events:[Re(z({},t),{location:i,target:a,extra:o,timestamp:Date.now(),userId:null})],device:s,project:r};try{n?yield this.doReport(ua(c),n):yield this.doReport(ua(c))}catch(p){Be.log("[Jolibox SDK] report API error",p)}})}}});var Aa=re(()=>{"use strict";xl();Ia();Pl()});var Sa,Nl,nt,un,Ke,Wt=re(()=>{"use strict";ga();he();q();Sa=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(Nl=AbortSignal.timeout)!=null||(AbortSignal.timeout=Sa);nt=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20;this.getNetworkStatus=()=>this.networkRequests.length===0?!0:this.networkRequests.filter(n=>n).length/this.networkRequests.length>=.6}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new un(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}},un=class{constructor(t){this.xua=wl();this.getJoliSource=()=>L.joliSource;var n;let r=Kt(L.testMode);this.baseUrl=(n=t==null?void 0:t.baseUrl)!=null?n:r}get(t,r){return A(this,null,function*(){try{let{query:n,timeout:i}=r!=null?r:{},{headers:a}=r!=null?r:{},o=n?new URLSearchParams(n):null,s=o==null?void 0:o.toString(),l=`${this.baseUrl}${t}${s?`?${s}`:""}`,c=this.xua,p=this.getJoliSource();a=Object.assign({},a!=null?a:{},c?{"x-user-agent":c}:{},p?{"x-joli-source":p}:{});let u=yield fetch(l,{method:"GET",headers:a,credentials:"include",signal:Sa(i!=null?i:3e4)});return nt.getInstance().recordNetworkRequest(!0),yield u.json()}catch(n){throw nt.getInstance().recordNetworkRequest(!1),n}})}post(t,r){return A(this,null,function*(){try{let{data:n,query:i,timeout:a}=r!=null?r:{},{headers:o}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,p=this.xua,u=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},p?{"x-user-agent":p}:{},u?{"x-joli-source":u}:{},{"x-os-type":Oe.isAndroid?"ANDROID":Oe.isiOS?"IOS":"PC"},{"x-runtime-type":"WEB"});let m=yield fetch(c,{method:"POST",headers:o,body:JSON.stringify(n),signal:Sa(a!=null?a:3e4),credentials:"include"});nt.getInstance().recordNetworkRequest(!0);let h=m.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return m.blob()}catch(w){return yield m.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return m.formData()}catch(w){return yield m.text()}if(h!=null&&h.includes("application/json"))try{return yield m.json()}catch(w){return yield m.text()}return m}catch(n){throw nt.getInstance().recordNetworkRequest(!1),n}})}put(t,r){return A(this,null,function*(){try{let{data:n,query:i,timeout:a}=r!=null?r:{},{headers:o}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,p=this.xua,u=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},p?{"x-user-agent":p}:{},u?{"x-joli-source":u}:{});let m=yield fetch(c,{method:"PUT",headers:o,credentials:"include",body:JSON.stringify(n!=null?n:{})});if(!m.ok)throw nt.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${m.status}`);return nt.getInstance().recordNetworkRequest(!0),yield m.json()}catch(n){throw console.error("Error:",n),n}})}};window.JoliboxHttpClient=un;Ke=nt.getInstance()});var Ca,fn,Ra=re(()=>{"use strict";he();Aa();Wt();q();Ca=class extends dn{constructor(){super(...arguments);this.httpClient=Ke.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var r;return pl((r=L.testMode)!=null?r:!1)}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(n=>{console.info("report error",n)})}},fn=new Ca(Kt(L.testMode))});var Fh,Dl=re(()=>{"use strict";Cl();q();Ea();q();Ra();he();Fh=(e,t)=>{var i,a,o;let r={message:t.message,stack:(i=t.stack)!=null?i:"",errorType:t.name,source:0},n={name:e,type:kt.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(o=(a=L.hostUserInfo)==null?void 0:a.uid)!=null?o:null};fn.trackEvent(n,$t.WebSDK)};xt.on("GLOBAL_ERROR",(e,t)=>{Fh(t.tag,e)});xt.on("GLOBAL_USER_ERROR",(e,t)=>{Be.log("UserError",e,t)})});var hn,Ll=re(()=>{"use strict";hn=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,a=!1,o=0,s=()=>{if(!a)return;let h=Date.now(),w=h-r;w>=this.interval&&(this.visible&&(o+=Math.min(w,this.interval+1e3),t(o)),r=h),n=requestAnimationFrame(s)},l=()=>{p(),r=Date.now(),i=window.setInterval(()=>{if(!a)return;let h=Date.now();h-r>=this.interval&&(r=h)},this.interval)},c=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},p=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",h=>{a&&(console.log("visible",h),h?c():l())});let m=this.visible;return{start(){a||(a=!0,m?c():l())},stop(){a=!1,p(),u()}}}}});var Ul,Bl=re(()=>{"use strict";Ul=`-----BEGIN PUBLIC KEY-----
1
+ var Hf=Object.create;var Wi=Object.defineProperty,qf=Object.defineProperties,Vf=Object.getOwnPropertyDescriptor,$f=Object.getOwnPropertyDescriptors,Kf=Object.getOwnPropertyNames,nn=Object.getOwnPropertySymbols,Ks=Object.getPrototypeOf,zi=Object.prototype.hasOwnProperty,Ws=Object.prototype.propertyIsEnumerable,Wf=Reflect.get;var $s=(e,t,r)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,z=(e,t)=>{for(var r in t||(t={}))zi.call(t,r)&&$s(e,r,t[r]);if(nn)for(var r of nn(t))Ws.call(t,r)&&$s(e,r,t[r]);return e},Re=(e,t)=>qf(e,$f(t));var gr=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var zs=(e,t)=>{var r={};for(var n in e)zi.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&nn)for(var n of nn(e))t.indexOf(n)<0&&Ws.call(e,n)&&(r[n]=e[n]);return r};var re=(e,t)=>()=>(e&&(t=e(e=0)),t);var Yi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var zf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Kf(t))!zi.call(e,i)&&i!==r&&Wi(e,i,{get:()=>t[i],enumerable:!(n=Vf(t,i))||n.enumerable});return e};var Xi=(e,t,r)=>(r=e!=null?Hf(Ks(e)):{},zf(t||!e||!e.__esModule?Wi(r,"default",{value:e,enumerable:!0}):r,e));var Ys=(e,t,r)=>Wf(Ks(e),r,t);var A=(e,t,r)=>new Promise((n,i)=>{var a=l=>{try{s(r.next(l))}catch(c){i(c)}},o=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,o);s((r=r.apply(e,t)).next())});function nh(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function oa(e){return typeof e=="string"}function nl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function il(e){return typeof e=="object"&&Array.isArray(e)}function ih(e){return typeof e=="undefined"}function ah(e){return ih(e)||e===null}function oh(e){return typeof e=="function"}function al(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function ol(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,a){for(let o in a)if(Object.prototype.hasOwnProperty.call(a,o)){let s=i[o],l=a[o],c=r(s,l,o,i,a);c!==void 0?i[o]=c:Zs(l)&&Zs(s)?i[o]=n(aa({},s),l):Array.isArray(l)&&Array.isArray(s)?i[o]=[...s,...l]:i[o]=l}return i}return n(e,t)}function Zs(e){return e&&typeof e=="object"&&e.constructor===Object}function sl(e,t){if(Array.isArray(e))return e.concat(t)}function wr(e,t,r={}){let n=null,i,a,o,{leading:s=!1,trailing:l=!0}=r,c=()=>(o=e.apply(a,i),i=void 0,a=void 0,o),p=function(...u){i=u,a=this;let m=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!m&&c()},t),m)return c()};return p.cancel=()=>{n&&clearTimeout(n),n=null,i=a=void 0},p.flush=()=>{if(n)return clearTimeout(n),n=null,c()},p}function ch(e,t){return(...r)=>t(e,...r)}function ul(e){return t=>ch(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new lh(`${i}`))}})}function _r(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function an(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((i,a)=>(i[a]=String(n[a]),i),{})}return e[r]})}function ph(e){let t=e.location?an(e.location,tl):null,r=e.target?an(e.target,tl):null;return an(th(aa({},e),{location:t,target:r}),hh)}function ua(e){let t=e.events.map(n=>ph(n)),r=an(e.device,mh);return[e.protocolVersion,t,r,e.project]}function vh(){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 ma(e,t,r){let n=window.location.hostname,i=n.split("."),a=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${a}.jolibox.com`;if(i.length>=2){let o=i.slice(-2).join(".");if(o==="jolibox.com"||o==="pico-game.com"||o==="joyslite.com"||o==="mporia.com"||o==="pingplus.ai")return`${a}.${o}`}return`${a}.jolibox.com`}function ml(e){return ma("app","stg-app",e)}function Kt(e){return`https://${ma("api","stg-api",e)}`}function Ih(e){return ma("collect","stg-collect",e)}function pl(e){return`https://${Ih(e)}`}function Rh(e){return new Promise(t=>vl(e)(t))}function vl(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function Oh(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(a.fire,a)}},a=new br(i);return a.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function Th(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)xh(e[n],t[n])}function xh(e,t){if(oa(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(oh(t)){try{if(e instanceof t)return}catch(r){}if(!ah(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 Ph(){return typeof globalThis!="undefined"?globalThis[gl]:void 0}function Nh(e){typeof globalThis!="undefined"&&(globalThis[gl]=e)}function we(e=!1){let t=Ph();if(!e&&t)return t;let r=new on,n=new na,i={registerCommand(a,o,s){r.registerCommand({id:a,handler:o,metadata:s})},executeCommand(a,...o){return n.executeCommand(a,...o)},excuteCommandSync(a,...o){return n.executeCommandThowErr(a,...o)}};return Nh(i),i}var ia,Yf,Xf,Qf,Xs,Zf,eh,Qs,aa,th,rh,rl,Ot,sh,sa,la,ll,cl,lh,dl,sn,ln,ca,Be,Zi,dh,da,el,uh,kt,$t,fh,tl,hh,mh,$e,Vt,gh,Oe,_h,yh,bh,fl,fa,ha,wh,Eh,hl,Tt,ea,ae,Ah,Sh,yr,br,ze,ra,Ch,Qi,kh,bt,on,na,gl,q=re(()=>{"use strict";ia=Object.defineProperty,Yf=Object.defineProperties,Xf=Object.getOwnPropertyDescriptor,Qf=Object.getOwnPropertyDescriptors,Xs=Object.getOwnPropertySymbols,Zf=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,Qs=(e,t,r)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,aa=(e,t)=>{for(var r in t||(t={}))Zf.call(t,r)&&Qs(e,r,t[r]);if(Xs)for(var r of Xs(t))eh.call(t,r)&&Qs(e,r,t[r]);return e},th=(e,t)=>Yf(e,Qf(t)),rh=(e,t)=>{for(var r in t)ia(e,r,{get:t[r],enumerable:!0})},rl=(e,t,r,n)=>{for(var i=n>1?void 0:n?Xf(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,r,i):o(i))||i);return n&&i&&ia(t,r,i),i},Ot=(e,t,r)=>new Promise((n,i)=>{var a=l=>{try{s(r.next(l))}catch(c){i(c)}},o=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,o);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}sh=(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))(sh||{}),sa=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}},la=class extends sa{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},ll=class extends sa{constructor(){super(...arguments),this.kind="USER_ERROR"}},cl=class extends ll{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},lh=class extends ll{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))}},dl=class extends la{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},sn=class extends la{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},ln=class extends sa{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}}},ca=class extends la{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Be={log:_r("log"),warn:_r("warn"),info:_r("info"),error:_r("error"),debug:_r("debug")};Object.assign(globalThis,{logger:Be});Zi=Symbol.for("Jolibox.canIUseMap"),dh={};globalThis[Zi]||(globalThis[Zi]=dh);da={get config(){return globalThis[Zi]}},el=Symbol.for("Jolibox.canIUseMap.native"),uh={};globalThis[el]||(globalThis[el]=uh);kt=(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))(kt||{}),$t=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))($t||{}),fh=(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))(fh||{}),tl=["name","params"],hh=["name","type","location","target","extra","timestamp","userId"],mh=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];$e=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});vh();Vt=typeof window=="undefined",gh=()=>!Vt&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Oe={isiOS:!Vt&&(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:!Vt&&navigator.userAgent.includes("Android"),isMac:!Vt&&navigator.userAgent.includes("Mac"),isFacebook:!Vt&&navigator.userAgent.includes("FB_IAB"),isPC:!Vt&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},_h=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",yh="device_id",bh="advertising_id",fl=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,$e()),window.__joliboxLocalStorage__.getItem(e)),fa=()=>new URLSearchParams(window.location.search).get("deviceId")||fl(yh),ha=()=>new URLSearchParams(window.location.search).get("advertisingId")||fl(bh),wh=e=>e.charAt(0).toUpperCase()+e.slice(1),Eh=()=>{var e;let t=new URLSearchParams(window.location.search);return wh((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},hl=e=>{if(gh())return window.navigator.userAgent;let t="JoliboxWebSDK",r=_h(),n=navigator.language,i=fa(),a=ha();return`${t} (${Eh()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${a} version/${e||""}`};Tt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=aa({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return Ot(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),a=this.createTimeoutPromise(),o=Promise.race([i,a]).catch(s=>Ot(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(r);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}throw s}));this.pendingRequests.set(r,o),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 o}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return Ot(this,null,function*(){var r,n,i,a;let o=this.config.keyGenerator(e,t),s=++this.requestSequence,l=this.getValidCachedData(o);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",l),l){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),m=this.requestAdapter.extractRealTimeData(u),h=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return h&&!this.config.consistencyChecker(l,h)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(o,h,s),u):this.requestAdapter.mergeData(l,m)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let c=yield this.requestAdapter.execute(e,t),p=(a=(i=this.requestAdapter).extractCacheableData)==null?void 0:a.call(i,c);return p&&this.setCachedDataWithSequence(o,p,s),c})}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 a=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:a,expiresAt:a+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 Ot(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return Ot(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),a=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${a})`);let o=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,o);return s&&(this.setCachedDataWithSequence(i,s,a),console.log(`[RequestCacheService] Force updated cache for ${e}`)),o})}warmupCache(e,t){return Ot(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)}},ea=class ta{constructor(t){this.element=t,this.next=ta.Undefined,this.prev=ta.Undefined}};ea.Undefined=new ea(void 0);ae=ea,Ah=class{constructor(){this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ae.Undefined}clear(){let e=this._first;for(;e!==ae.Undefined;){let t=e.next;e.prev=ae.Undefined,e.next=ae.Undefined,e=t}this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new ae(e);if(this._first===ae.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!==ae.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ae.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ae.Undefined&&e.next!==ae.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ae.Undefined&&e.next===ae.Undefined?(this._first=ae.Undefined,this._last=ae.Undefined):e.next===ae.Undefined?(this._last=this._last.prev,this._last.next=ae.Undefined):e.prev===ae.Undefined&&(this._first=this._first.next,this._first.prev=ae.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ae.Undefined;)yield e.element,e=e.next}},Sh=0,yr=class{constructor(e){this.value=e,this.id=Sh++}},br=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 yr&&(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,a,o,s,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new yr(t);return this._listeners?this._listeners instanceof yr?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(o=(a=this.options)==null?void 0:a.onDidFirstListener)==null||o.call(a,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var p,u,m,h;if(!this._disposed){if(this._listeners instanceof yr)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(u=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||u.call(p));else if(this._listeners){let w=this._listeners.indexOf(c);w>=0&&(this._listeners.splice(w,1),this._size--,this._size===0&&((h=(m=this.options)==null?void 0:m.onDidRemoveLastListener)==null||h.call(m)))}}}}),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 yr?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ze=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 br,a=l=>t(...l.args),o=i.event(a);this.listerHandlerMap.set(t,{handler:a,dispose:o}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let l of s)t(...l.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 Ah,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)}},ra={};rh(ra,{None:()=>Ch,filter:()=>Oh,once:()=>vl,toPromise:()=>Rh});Ch=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Qi=Symbol.for("Jolibox.hostEmitter"),kh=()=>{let e=new ze;return globalThis[Qi]||(globalThis[Qi]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Qi]},bt=kh();on=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new br,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 Th(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}};on=rl([al],on);na=class{constructor(){this._onWillExecuteCommand=new br,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new br,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new on,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=nh(3e4)),this._starActivation}executeCommand(e,...t){return Ot(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ra.toPromise(ra.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}}};na=rl([al],na);gl=Symbol.for("Jolibox.commands")});function Me(e,t={}){pa.emit("ERROR_REPORT",{error:e,options:t})}var pa,xt,rt=re(()=>{"use strict";q();q();pa=new ze,xt=new ze;Me.debounce=wr(Me,50,{leading:!0})});var va,Dh,_l,yl,bl=re(()=>{"use strict";q();rt();va=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{}}},Dh=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},_l=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[a,o,s]=i;return{headerJson:va(a),payloadJson:va(o),signature:va(s)}}else throw"joli_source is missing"}catch(r){return Me(new dl(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},yl=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=Dh(e),a=r[2];return`${n}.${i}.${a}`}return t}});var Lh,cn,wl,ga=re(()=>{"use strict";q();Lh="1.3.5-beta.3",cn=()=>Lh,wl=()=>{let e=cn();return`${hl(e)}`}});function ya(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var Uh,El,_a,Il,oe,Bh,L,he=re(()=>{"use strict";q();bl();ga();q();Uh={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:fa(),adId:ha(),pixelRatio:window.devicePixelRatio||1,platform:Oe.isAndroid?"android":Oe.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:cn()},schema:window.location.href,platform:Oe.isAndroid?"android":Oe.isiOS?"ios":"h5"},_a=(El=globalThis.joliboxJSCore)==null?void 0:El.env,oe=Object.assign({},(Il=_a==null?void 0:_a())!=null?Il:Uh);Bh=()=>{var E,I,b,R,k,D,J,S,N,F,H;let{payloadJson:e,headerJson:t,signature:r}=oe.schema.length?_l(oe.schema):{},n=`${oe.deviceInfo.did}-${new Date().getTime()}`,a=new URL(oe.schema.length?oe.schema:window.location.href).searchParams,o=(b=(I=(E=a.get("mpId"))!=null?E:a.get("appId"))!=null?I:a.get("gameId"))!=null?b:"",s=(D=(k=(R=oe.clientSessionId)!=null?R:e==null?void 0:e.sessionId)!=null?k:a.get("sessionId"))!=null?D:n,l=!!((S=(J=e==null?void 0:e.testAdsMode)!=null?J:e==null?void 0:e.__testAdsMode)!=null?S:a.get("testAdsMode")==="true"),c=(H=(F=(N=e==null?void 0:e.joliboxEnv)!=null?N:e==null?void 0:e.__joliboxEnv)!=null?F:a.get("joliboxEnv"))!=null?H:"production",p=c==="staging",u=t==null?void 0:t.channel,h=new URL(window.location.href).searchParams,w=e==null?void 0:e.__shouldInterupt;return{get startTime(){var U;return(U=performance.timeOrigin)!=null?U:performance.timing.navigationStart},get testMode(){return p},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var U,M;return(M=(U=h.get("joliSource"))!=null?U:a.get("joliSource"))!=null?M:null},get mpId(){var U;return(U=o!=null?o:e==null?void 0:e.id)!=null?U:""},get mpVersion(){var U;return(U=t==null?void 0:t.ver)!=null?U:cn()},get mpType(){var U,M;return(M=(U=t==null?void 0:t.__mpType)!=null?U:e==null?void 0:e.__mpType)!=null?M:"game"},get platform(){var U;return((U=oe.platform)!=null?U: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 U,M;return(M=(U=oe.clientSessionId)!=null?U:s)!=null?M:n},get channel(){return u},get webviewId(){var U;return(U=oe.webviewId)!=null?U:-1},get shouldInterupt(){return w},get from(){return e==null?void 0:e.__from},get baseApiHost(){return ml(p)},get adId(){var U;return(U=oe.deviceInfo.adId)!=null?U:oe.deviceInfo.did},get language(){return oe.deviceInfo.lang},get sdkEnvironment(){return ya("dlightek","jolibox")?"dlightek":a.get("huaweiQuick")==="true"?"huaweiQuick":ya("gamedistribution","jolibox")?"gamedistribution":ya("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var K,Y,Ue;let U=(K=oe.deviceInfo.pixelRatio)!=null?K:1,M=(Y=oe.deviceInfo.statusBarHeight)!=null?Y:e==null?void 0:e.__androidStatusBarHeight,G=(Ue=oe.deviceInfo.navigationBarHeight)!=null?Ue:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:M!==void 0?M/U:20,navigationBarHeight:G!==void 0?G/U:10}},get abTests(){var U,M;return(M=(U=oe.abValues)==null?void 0:U.split(","))!=null?M:[]},get mpInfo(){var U;return(U=oe.mpInfo)!=null?U:{mpName:"unknown"}},onEnvConfigChanged:U=>{ol(oe,U,sl)},encodeJoliSourceQuery:U=>{var M,G;return t&&r?yl(z(z({},e),U),(M=a.get("joliSource"))!=null?M:""):(G=a.get("joliSource"))!=null?G:""},setDoExitDirectly:()=>{w=!1}}},L=Bh()});var ba,Sl,Mh,Gh,Al,Jh,Cl=re(()=>{"use strict";q();rt();he();q();ba=!1,Sl=(e,t)=>e==null?!1:t in e,Mh=e=>Sl(e,"kind"),Gh=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Al=(e,t={},r)=>{var a,o,s;let n={user_id:(o=(a=L.hostUserInfo)==null?void 0:a.uid)!=null?o:"",device_id:(s=L.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:Gh(e.name)},i=Re(z({},n),{env:t.environment,isFromUser:r});r?xt.emit("GLOBAL_USER_ERROR",e,i):xt.emit("GLOBAL_ERROR",e,i)},Jh=e=>Sl(e,"kind")&&e.kind==="USER_ERROR";pa.on("ERROR_REPORT",({error:e,options:t})=>{if(ba)return;ba=!0;let r=Mh(e)&&e.raw?e.raw:e;try{let n=Jh(e);Al(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),a=new ca(`${i}, origin error: ${r.message}`);Be.error(a),Al(new ca(a.message),{environment:t.environment},!1)}finally{ba=!1}})});var wa,Ea=re(()=>{"use strict";rt();q();rt();wa=e=>new cl(e)});function Rl(e,t){let r=(n,i,a)=>{let c=i!=null?i:{},{eventType:o}=c,s=zs(c,["eventType"]),l=Re(z({tag:n,eventType:a!=null?a:o!=null?o:kt.Other},t),{extra:z({},s)});n=="globalJsError"?Me(new sn(JSON.stringify(l))):e("systemLog",l,L.webviewId)};return r.debounce=wr(r,500,{leading:!0}),r}function Ol(e){let t=(r,n,i)=>{var s;let a=(s=i&&JSON.stringify(i))!=null?s:0,o={speed_value_type:r,total_duration:n};a&&Object.assign(o,{extra:a}),e("joliboxSpeedAnalysis",o)};return t.debounce=wr(t,500,{leading:!0}),t}var kl=re(()=>{"use strict";q();q();rt();he()});function Tl(e,t){let r=Rl(e,t),n=Ol(r);return{track:r,trackPerformance:n}}var xl=re(()=>{"use strict";kl()});var Ia=re(()=>{"use strict"});var dn,Pl=re(()=>{"use strict";he();q();q();dn=class{constructor(t){this.apiHost=t;this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return A(this,null,function*(){let r=`${this.apiHost}/api/fe-configs/js-sdk/samples-config`,n=yield(yield fetch(r)).json();this.samplesConfig=n})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[n,i]of Object.entries(r))if(i.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(n);return!1}getDevice(){var n,i,a,o,s;let{nativeSDKVersion:t,jssdkVersion:r}=L.sdkInfo;return{platform:1e3,os:L.deviceInfo.platform,appVersion:(n=t!=null?t:r)!=null?n:"1.0.0",appId:(a=(i=L.hostInfo)==null?void 0:i.aid)!=null?a:"1",model:(o=L.deviceInfo.model)!=null?o:"UnknownModel",brand:(s=L.deviceInfo.brand)!=null?s:"UnknownBrand",uuid:L.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:"GamePage",params:r}}trackEvent(t,r,n){return A(this,null,function*(){if(this.checkIsSampled(t))return;let i=t.location?t.location:yield this.getLocation(),a=t.target||null,o=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let s=this.deviceInfo,c={protocolVersion:"1.0.0",events:[Re(z({},t),{location:i,target:a,extra:o,timestamp:Date.now(),userId:null})],device:s,project:r};try{n?yield this.doReport(ua(c),n):yield this.doReport(ua(c))}catch(p){Be.log("[Jolibox SDK] report API error",p)}})}}});var Aa=re(()=>{"use strict";xl();Ia();Pl()});var Sa,Nl,nt,un,Ke,Wt=re(()=>{"use strict";ga();he();q();Sa=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(Nl=AbortSignal.timeout)!=null||(AbortSignal.timeout=Sa);nt=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20;this.getNetworkStatus=()=>this.networkRequests.length===0?!0:this.networkRequests.filter(n=>n).length/this.networkRequests.length>=.6}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new un(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}},un=class{constructor(t){this.xua=wl();this.getJoliSource=()=>L.joliSource;var n;let r=Kt(L.testMode);this.baseUrl=(n=t==null?void 0:t.baseUrl)!=null?n:r}get(t,r){return A(this,null,function*(){try{let{query:n,timeout:i}=r!=null?r:{},{headers:a}=r!=null?r:{},o=n?new URLSearchParams(n):null,s=o==null?void 0:o.toString(),l=`${this.baseUrl}${t}${s?`?${s}`:""}`,c=this.xua,p=this.getJoliSource();a=Object.assign({},a!=null?a:{},c?{"x-user-agent":c}:{},p?{"x-joli-source":p}:{});let u=yield fetch(l,{method:"GET",headers:a,credentials:"include",signal:Sa(i!=null?i:3e4)});return nt.getInstance().recordNetworkRequest(!0),yield u.json()}catch(n){throw nt.getInstance().recordNetworkRequest(!1),n}})}post(t,r){return A(this,null,function*(){try{let{data:n,query:i,timeout:a}=r!=null?r:{},{headers:o}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,p=this.xua,u=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},p?{"x-user-agent":p}:{},u?{"x-joli-source":u}:{},{"x-os-type":Oe.isAndroid?"ANDROID":Oe.isiOS?"IOS":"PC"},{"x-runtime-type":"WEB"});let m=yield fetch(c,{method:"POST",headers:o,body:JSON.stringify(n),signal:Sa(a!=null?a:3e4),credentials:"include"});nt.getInstance().recordNetworkRequest(!0);let h=m.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return m.blob()}catch(w){return yield m.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return m.formData()}catch(w){return yield m.text()}if(h!=null&&h.includes("application/json"))try{return yield m.json()}catch(w){return yield m.text()}return m}catch(n){throw nt.getInstance().recordNetworkRequest(!1),n}})}put(t,r){return A(this,null,function*(){try{let{data:n,query:i,timeout:a}=r!=null?r:{},{headers:o}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,p=this.xua,u=this.getJoliSource();o=Object.assign({},o!=null?o:{},{"Content-Type":"application/json"},p?{"x-user-agent":p}:{},u?{"x-joli-source":u}:{});let m=yield fetch(c,{method:"PUT",headers:o,credentials:"include",body:JSON.stringify(n!=null?n:{})});if(!m.ok)throw nt.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${m.status}`);return nt.getInstance().recordNetworkRequest(!0),yield m.json()}catch(n){throw console.error("Error:",n),n}})}};window.JoliboxHttpClient=un;Ke=nt.getInstance()});var Ca,fn,Ra=re(()=>{"use strict";he();Aa();Wt();q();Ca=class extends dn{constructor(){super(...arguments);this.httpClient=Ke.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var r;return pl((r=L.testMode)!=null?r:!1)}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(n=>{console.info("report error",n)})}},fn=new Ca(Kt(L.testMode))});var Fh,Dl=re(()=>{"use strict";Cl();q();Ea();q();Ra();he();Fh=(e,t)=>{var i,a,o;let r={message:t.message,stack:(i=t.stack)!=null?i:"",errorType:t.name,source:0},n={name:e,type:kt.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(o=(a=L.hostUserInfo)==null?void 0:a.uid)!=null?o:null};fn.trackEvent(n,$t.WebSDK)};xt.on("GLOBAL_ERROR",(e,t)=>{Fh(t.tag,e)});xt.on("GLOBAL_USER_ERROR",(e,t)=>{Be.log("UserError",e,t)})});var hn,Ll=re(()=>{"use strict";hn=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,a=!1,o=0,s=()=>{if(!a)return;let h=Date.now(),w=h-r;w>=this.interval&&(this.visible&&(o+=Math.min(w,this.interval+1e3),t(o)),r=h),n=requestAnimationFrame(s)},l=()=>{p(),r=Date.now(),i=window.setInterval(()=>{if(!a)return;let h=Date.now();h-r>=this.interval&&(r=h)},this.interval)},c=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},p=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",h=>{a&&(console.log("visible",h),h?c():l())});let m=this.visible;return{start(){a||(a=!0,m?c():l())},stop(){a=!1,p(),u()}}}}});var Ul,Bl=re(()=>{"use strict";Ul=`-----BEGIN PUBLIC KEY-----
2
2
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs29BUZPZdQwNDEYtXufp
3
3
  IGF40RBoddFzoD2ixl6PjyKWFXF8kxGS++HNtLspxhLvWoE12IZvrP7+whSpgHcy
4
4
  4ryuW86mOdHnP9iyeK69GosHz3lVhQjF9UdhJDXB7P/zdj3VlVzZIj0yL+YvZjO0
@@ -1,4 +1,4 @@
1
- var UR=Object.create;var Ea=Object.defineProperty,MR=Object.defineProperties,FR=Object.getOwnPropertyDescriptor,jR=Object.getOwnPropertyDescriptors,BR=Object.getOwnPropertyNames,Ia=Object.getOwnPropertySymbols,GR=Object.getPrototypeOf,Bc=Object.prototype.hasOwnProperty,Bm=Object.prototype.propertyIsEnumerable;var jm=(e,t,r)=>t in e?Ea(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))Bc.call(t,r)&&jm(e,r,t[r]);if(Ia)for(var r of Ia(t))Bm.call(t,r)&&jm(e,r,t[r]);return e},B=(e,t)=>MR(e,jR(t));var Qe=(e,t)=>{var r={};for(var n in e)Bc.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ia)for(var n of Ia(e))t.indexOf(n)<0&&Bm.call(e,n)&&(r[n]=e[n]);return r};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Gm=(e,t)=>{for(var r in t)Ea(e,r,{get:t[r],enumerable:!0})},JR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of BR(t))!Bc.call(e,i)&&i!==r&&Ea(e,i,{get:()=>t[i],enumerable:!(n=FR(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?UR(GR(e)):{},JR(t||!e||!e.__esModule?Ea(r,"default",{value:e,enumerable:!0}):r,e));var v=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((r=r.apply(e,t)).next())});function KR(e){return!!(e!=null&&e.__nativeBuffers__)}function zc(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!KR(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=YR(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function XR(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:QR(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function rO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function tg(e){return typeof e=="string"}function jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Hm(e){return typeof e=="number"&&!isNaN(e)}function iO(e){return typeof e=="undefined"}function oO(e){return iO(e)||e===null}function rg(e){return typeof e=="function"}function aO(e){return jn(e)&&rg(e.then)}function ng(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function ji(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function fO(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 yO(){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 IO(e){return new Promise(t=>ig(e)(t))}function ig(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function EO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ji(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function kO(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)CO(e[n],t[n])}function CO(e,t){if(tg(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(rg(t)){try{if(e instanceof t)return}catch(r){}if(!oO(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 Pt(e,t){if(Yc.config[e]){Ta.warn(`[can i use] ${e} already registered`);return}Yc.config[e]=pr({},t)}function Wm(e,t){return`[${e}]:${t}`}function DO(e,t){zm||(Hc=new ka({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),$c=new ka({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Vc=new ka({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Hc.flush(),$c.flush(),Vc.flush()}),zm=!0);function r(i){var o,a;let{method:s,args:l,startTime:c,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:h,invokeCallback:g}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Hc.report({status:b,method:n(s,l),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-c}),c&&h&&g&&($c.report({status:b,method:s,isForeground:d,duration:Number((h-c).toFixed(3))}),Vc.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 MO(e,t){let r=0,n=!0,i=UO.resolveMap,o=DO(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Wc.forEach(l=>xa(this,[l],function*({method:c,args:d,resolve:u}){let p=yield s(c,d);u(p)})),Wc.length=0});let a=(l,c)=>{let d=i.get(Number(l));if(!d)return;let u=zc(c);d(u),i.delete(Number(l))},s=(l,c)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let h=new nO;if(i.set(r,h.resolve),!n&&TO.includes(l))return new Promise(E=>{Wc.push({method:l,args:c,resolve:E})});let g=WR(pr({},{method:l,startTime:p,args:c,isForeground:f}),{invokeType:"js-bridge"}),b=!LO&&PO.includes(l),y=XR(c,b),_=b?y:JSON.stringify(y),S;if(l.endsWith("Sync")||RO.includes(l)?S=(d=e.call)==null?void 0:d.call(e,l,y,r):typeof _=="string"?S=e.invoke(l,_,r):S=(u=e.call)==null?void 0:u.call(e,l,_,r),S){try{typeof S=="string"&&(S=JSON.parse(S)),S=zc(S)}catch(E){Ta.error(E)}return i.delete(r),S.errorCode&&(S.errorCode=Wm(l,S.errorCode)),o(pr(pr({},g),S)),S}return l.endsWith("Sync")&&i.delete(r),h.promise.then(E=>(E.errorCode&&(E.errorCode=Wm(l,E.errorCode)),o(pr(pr({},g),E)),E))};return{invokeNative:s,applyNative:(l,c)=>{let d=s(l,c);return aO(d)?d.then(u=>Km(l,u)):Km(l,d)},invokeHandler:a}}function Km(e,t){if(!jn(t)){Ta.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=zR(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new uO(n,i,o,a);return s}function FO(e){if(globalThis[Aa])return globalThis[Aa];let t=new Zc,r=new Zc,n=new ka({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[Aa]={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=zc(o),l;if(s.__extra){l=s.params;let{type:c,startTime:d}=s.__extra;n.report({type:c,event:i,duration:Date.now()-d})}else l=s;if(i===ag){l.forEach(c=>{let[d,u]=c;try{r.emit(d.slice(Gi.length),u,a)}catch(p){}});return}if(i.startsWith(Gi)){r.emit(i.slice(Gi.length),l,a);return}t.emit(i,l,a)}},globalThis[Aa]}function jO(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,l)=>{if(l){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Gi}${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(ag,d,p)}catch(p){}}),n=void 0,t.clear()}));let c=t.get(s);c||(c=[],t.set(s,c)),c.push([`${Gi}${o}`,a])},emitNative:(o,a,s,l)=>{if(l){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(OO,d,p)}catch(p){}}),i=void 0,r.clear()}));let c=r.get(s);c||(c=[],r.set(s,c)),c.push([o,a])}}}function BO(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=FO(e),{invokeNative:a,invokeHandler:s,applyNative:l}=MO(e,r),{publish:c,emitNative:d}=jO(e);return{invokeHandler:s,subscribeHandler:t,applyNative:l,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:c,subscribe:i,unsubscribe:o}}function sg(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var HR,$R,VR,Ca,Qm,Xm,Jm,pr,WR,zR,xa,YR,QR,Zm,ZR,eO,eg,tO,nO,sO,lO,Pa,cO,uO,dO,Gc,Ta,$m,pO,Kc,hO,Yc,mO,gO,vO,Fn,bO,n6,Qc,fe,_O,wO,Bi,Ji,Zc,eu,SO,Jc,AO,i6,tu,Vm,o6,og,xO,Gi,PO,TO,RO,ag,OO,NO,ka,zm,Hc,$c,Vc,Wc,LO,ru,qO,UO,Aa,nu,xt,lg,cg,GO,ug,Ym,he,F,De,a6,JO,dg,iu,s6,l6,ue=x(()=>{"use strict";HR=Object.defineProperty,$R=Object.defineProperties,VR=Object.getOwnPropertyDescriptors,Ca=Object.getOwnPropertySymbols,Qm=Object.prototype.hasOwnProperty,Xm=Object.prototype.propertyIsEnumerable,Jm=(e,t,r)=>t in e?HR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pr=(e,t)=>{for(var r in t||(t={}))Qm.call(t,r)&&Jm(e,r,t[r]);if(Ca)for(var r of Ca(t))Xm.call(t,r)&&Jm(e,r,t[r]);return e},WR=(e,t)=>$R(e,VR(t)),zR=(e,t)=>{var r={};for(var n in e)Qm.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ca)for(var n of Ca(e))t.indexOf(n)<0&&Xm.call(e,n)&&(r[n]=e[n]);return r},xa=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((r=r.apply(e,t)).next())});YR=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};QR=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)};Zm=Object.defineProperty,ZR=Object.getOwnPropertyDescriptor,eO=(e,t)=>{for(var r in t)Zm(e,r,{get:t[r],enumerable:!0})},eg=(e,t,r,n)=>{for(var i=n>1?void 0:n?ZR(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&&Zm(t,r,i),i},tO=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.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}nO=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))}})}};sO=(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))(sO||{}),lO=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}},Pa=class extends lO{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},cO=class extends Pa{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},uO=class extends Pa{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},dO=class extends Pa{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Gc=class extends Pa{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Ta={log:ji("log"),warn:ji("warn"),info:ji("info"),error:ji("error"),debug:ji("debug")};Object.assign(globalThis,{logger:Ta});$m=Symbol.for("Jolibox.canIUseMap"),pO={};globalThis[$m]||(globalThis[$m]=pO);Kc=Symbol.for("Jolibox.canIUseMap.native"),hO={};globalThis[Kc]||(globalThis[Kc]=hO);Yc={get config(){return globalThis[Kc]}},mO=(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))(mO||{}),gO=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(gO||{}),vO=(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))(vO||{});yO();Fn=typeof window=="undefined",bO=()=>!Fn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),n6={isiOS:!Fn&&(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:!Fn&&navigator.userAgent.includes("Android"),isMac:!Fn&&navigator.userAgent.includes("Mac"),isFacebook:!Fn&&navigator.userAgent.includes("FB_IAB"),isPC:!Fn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Qc=class Xc{constructor(t){this.element=t,this.next=Xc.Undefined,this.prev=Xc.Undefined}};Qc.Undefined=new Qc(void 0);fe=Qc,_O=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}},wO=0,Bi=class{constructor(e){this.value=e,this.id=wO++}},Ji=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 Bi&&(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,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new Bi(t);return this._listeners?this._listeners instanceof Bi?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Bi)this._listeners.id===c.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 h=this._listeners.indexOf(c);h>=0&&(this._listeners.splice(h,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 Bi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Zc=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 Ji,o=l=>t(...l.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 l of s)t(...l.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 _O,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)}},eu={};eO(eu,{None:()=>SO,filter:()=>EO,once:()=>ig,toPromise:()=>IO});SO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Jc=Symbol.for("Jolibox.hostEmitter"),AO=()=>{let e=new Zc;return globalThis[Jc]||(globalThis[Jc]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Jc]},i6=AO();tu=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ji,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 kO(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}};tu=eg([ng],tu);Vm=class{constructor(){this._onWillExecuteCommand=new Ji,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ji,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new tu,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=rO(3e4)),this._starActivation}executeCommand(e,...t){return tO(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),eu.toPromise(eu.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}}};Vm=eg([ng],Vm);o6=Symbol.for("Jolibox.commands");Pt("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Pt("requestProductDetailsAsync",{version:102e4});Pt("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Pt("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Pt("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Pt("userTrackAsync",{version:1e6});Pt("openMiniapp",{version:1050100});Pt("requestCoinDetailsSync",{version:1070100});Pt("requestCoinDetailsAsync",{version:1070100});Pt("sendServerEventAsync",{version:1070100});Pt("loadAdsAsync",{version:1070200});Pt("showAdAsync",{version:1070200});og=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let l=Yc.config[a];if(!l)return!1;let c=(o=t==null?void 0:t())!=null?o:"",d=l.version;if(l.platforms&&c in l.platforms){let p=l.platforms[c];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(l,s,u)||n(l.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=fO(i,o);if(!s)return!1;if(jn(s)){let l=s.version;return Hm(l)?typeof a=="number"&&a>=l:!0}return Hm(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};xO=()=>bO(),Gi="custom_event_",PO=[],TO=[],RO=["env","createRequestTask","login"],ag="__batch_event__",OO="__native_batch_event__",NO=e=>e==="pv"?e:"default",ka=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=NO(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&&jn(a))throw new Gc(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let l=[];if(jn(a))l.push(...Object.keys(a));else if(tg(a)){if(i.length>0)throw new Gc(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);l.push(a)}else throw new Gc(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);l.forEach(c=>{n[c]||(n[c]={});let d=jn(a)?a[c]:a;t(n[c],[...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={}}},zm=!1;Wc=[],LO=!1,ru=Symbol.for("Jolibox.invokeResolverInstance"),qO=new Map;globalThis[ru]||(globalThis[ru]=qO);UO={get resolveMap(){return globalThis[ru]}};Aa=Symbol.for("Jolibox.subscribeInstance");xt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){xt.trigger=e},onDoExit(e){xt.exit=e},onDoBackPress(e){xt.backPress=e}},lg=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new cO("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="")=>{xt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>xa(void 0,null,function*(){let o=yield xt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});nu={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=sg(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:lg,doExit:r};globalThis.joliboxJSCore=pr({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{xt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>xa(void 0,null,function*(){let a=yield xt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});nu={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let l=sg(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(l),webviewIds:s}))},call(o,a,s){let l=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(l)return JSON.parse(l)},doBackPress(o){return xa(this,null,function*(){let a=yield xt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:lg,doExit:n};globalThis.joliboxJSCore=pr({},i)}cg=nu;if(!cg&&xO())throw new dO("No joliboxJScore is found, native bridge not found.");GO=pr({},cg),ug=BO(GO),{invokeHandler:Ym}=ug,{applyNative:he,invokeNative:F,onNative:De,offNative:a6,subscribeHandler:JO,publish:dg,emitNative:iu,subscribe:s6,unsubscribe:l6}=ug;globalThis.joliboxJSBridge={callHandler:Ym,invokeHandler:Ym,subscribeHandler:JO}});function zO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Oa(e){return new Promise(t=>setTimeout(t,e))}function zi(e){return typeof e=="string"}function cn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yg(e){return typeof e=="object"&&Array.isArray(e)}function Na(e){return typeof e=="number"&&!isNaN(e)}function Fr(e){return e===!0||e===!1}function bg(e){return typeof e=="undefined"}function Ki(e){return bg(e)||e===null}function KO(e){return typeof e=="function"}function _g(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function wg(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],l=o[a],c=r(s,l,a,i,o);c!==void 0?i[a]=c:hg(l)&&hg(s)?i[a]=n(gg({},s),l):Array.isArray(l)&&Array.isArray(s)?i[a]=[...s,...l]:i[a]=l}return i}return n(e,t)}function hg(e){return e&&typeof e=="object"&&e.constructor===Object}function Sg(e,t){if(Array.isArray(e))return e.concat(t)}function Yi(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:l=!0}=r,c=()=>(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,l&&!p&&c()},t),p)return c()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,c()},d}function QO(e,t){return(...r)=>t(e,...r)}function Bn(e){return t=>QO(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Wt(`${i}`))}})}function Hi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Cg(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 l=parseInt(i[s],10)||0,c=parseInt(o[s],10)||0;if(l>c){n=1;break}else if(l<c){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 vu(){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 n1(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 yu(e){return n1("app","stg-app",e)}function Jn(e){return`https://${yu(e)}`}function s1(e){return new Promise(t=>Rg(e)(t))}function Rg(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function l1(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Wi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function u1(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)d1(e[n],t[n])}function d1(e,t){if(zi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(KO(t)){try{if(e instanceof t)return}catch(r){}if(!Ki(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 p1(){return typeof globalThis!="undefined"?globalThis[Og]:void 0}function f1(e){typeof globalThis!="undefined"&&(globalThis[Og]=e)}function W(e=!1){let t=p1();if(!e&&t)return t;let r=new Ra,n=new uu,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 f1(i),i}var du,HO,pg,$O,VO,fg,gg,WO,vg,ln,ut,YO,pu,Qi,fu,Ig,Wt,Da,Eg,La,Ag,kg,Xi,hu,zt,au,XO,mu,mg,ZO,V,gu,e1,Gn,$i,Zi,t1,r1,xg,Pg,Tg,Mt,su,me,i1,o1,Vi,Wi,Kt,cu,a1,ou,c1,_e,Ra,uu,Og,O=x(()=>{"use strict";du=Object.defineProperty,HO=Object.getOwnPropertyDescriptor,pg=Object.getOwnPropertySymbols,$O=Object.prototype.hasOwnProperty,VO=Object.prototype.propertyIsEnumerable,fg=(e,t,r)=>t in e?du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gg=(e,t)=>{for(var r in t||(t={}))$O.call(t,r)&&fg(e,r,t[r]);if(pg)for(var r of pg(t))VO.call(t,r)&&fg(e,r,t[r]);return e},WO=(e,t)=>{for(var r in t)du(e,r,{get:t[r],enumerable:!0})},vg=(e,t,r,n)=>{for(var i=n>1?void 0:n?HO(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&&du(t,r,i),i},ln=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.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}ut=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))}})}};YO=(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))(YO||{}),pu=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}},Qi=class extends pu{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},fu=class extends pu{constructor(){super(...arguments),this.kind="USER_ERROR"}},Ig=class extends fu{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Wt=class extends fu{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))}},Da=class extends fu{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))}},Eg=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},La=class extends Qi{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))}},Ag=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},kg=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Xi=class extends pu{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}}},hu=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};zt={log:Hi("log"),warn:Hi("warn"),info:Hi("info"),error:Hi("error"),debug:Hi("debug")};Object.assign(globalThis,{logger:zt});au=Symbol.for("Jolibox.canIUseMap"),XO={};globalThis[au]||(globalThis[au]=XO);mu={get config(){return globalThis[au]}},mg=Symbol.for("Jolibox.canIUseMap.native"),ZO={};globalThis[mg]||(globalThis[mg]=ZO);V=(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))(V||{}),gu=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(gu||{}),e1=(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))(e1||{}),Gn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});vu();$i=typeof window=="undefined",Zi={isiOS:!$i&&(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:!$i&&navigator.userAgent.includes("Android"),isMac:!$i&&navigator.userAgent.includes("Mac"),isFacebook:!$i&&navigator.userAgent.includes("FB_IAB"),isPC:!$i&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},t1="device_id",r1="advertising_id",xg=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Gn()),window.__joliboxLocalStorage__.getItem(e)),Pg=()=>new URLSearchParams(window.location.search).get("deviceId")||xg(t1),Tg=()=>new URLSearchParams(window.location.search).get("advertisingId")||xg(r1);Mt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=gg({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return ln(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=>ln(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(r);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}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 ln(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,l=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",l),l){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(l,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(l,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(l):l}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let c=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,c);return d&&this.setCachedDataWithSequence(a,d,s),c})}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 ln(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return ln(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 ln(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)}},su=class lu{constructor(t){this.element=t,this.next=lu.Undefined,this.prev=lu.Undefined}};su.Undefined=new su(void 0);me=su,i1=class{constructor(){this._first=me.Undefined,this._last=me.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===me.Undefined}clear(){let e=this._first;for(;e!==me.Undefined;){let t=e.next;e.prev=me.Undefined,e.next=me.Undefined,e=t}this._first=me.Undefined,this._last=me.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new me(e);if(this._first===me.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!==me.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==me.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==me.Undefined&&e.next!==me.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===me.Undefined&&e.next===me.Undefined?(this._first=me.Undefined,this._last=me.Undefined):e.next===me.Undefined?(this._last=this._last.prev,this._last.next=me.Undefined):e.prev===me.Undefined&&(this._first=this._first.next,this._first.prev=me.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==me.Undefined;)yield e.element,e=e.next}},o1=0,Vi=class{constructor(e){this.value=e,this.id=o1++}},Wi=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 Vi&&(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,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new Vi(t);return this._listeners?this._listeners instanceof Vi?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Vi)this._listeners.id===c.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 h=this._listeners.indexOf(c);h>=0&&(this._listeners.splice(h,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 Vi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Kt=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 Wi,o=l=>t(...l.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 l of s)t(...l.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 i1,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)}},cu={};WO(cu,{None:()=>a1,filter:()=>l1,once:()=>Rg,toPromise:()=>s1});a1=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});ou=Symbol.for("Jolibox.hostEmitter"),c1=()=>{let e=new Kt;return globalThis[ou]||(globalThis[ou]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[ou]},_e=c1();Ra=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Wi,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 u1(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}};Ra=vg([_g],Ra);uu=class{constructor(){this._onWillExecuteCommand=new Wi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Wi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ra,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=zO(3e4)),this._starActivation}executeCommand(e,...t){return ln(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),cu.toPromise(cu.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}}};uu=vg([_g],uu);Og=Symbol.for("Jolibox.commands")});function Ee(e,t={}){bu.emit("ERROR_REPORT",{error:e,options:t})}var bu,un,vt=x(()=>{"use strict";O();O();bu=new Kt,un=new Kt;Ee.debounce=Yi(Ee,50,{leading:!0})});var _u,h1,Ng,Dg,Lg=x(()=>{"use strict";O();vt();_u=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{}}},h1=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Ng=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:_u(o),payloadJson:_u(a),signature:_u(s)}}else throw"joli_source is missing"}catch(r){return Ee(new Eg(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},Dg=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=h1(e),o=r[2];return`${n}.${i}.${o}`}return t}});var m1,wu,qg=x(()=>{"use strict";O();m1="1.3.5-beta.2",wu=()=>m1});function Iu(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var g1,Ug,Su,Mg,ge,v1,I,J=x(()=>{"use strict";O();Lg();qg();O();g1={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Pg(),adId:Tg(),pixelRatio:window.devicePixelRatio||1,platform:Zi.isAndroid?"android":Zi.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:wu()},schema:window.location.href,platform:Zi.isAndroid?"android":Zi.isiOS?"ios":"h5"},Su=(Ug=globalThis.joliboxJSCore)==null?void 0:Ug.env,ge=Object.assign({},(Mg=Su==null?void 0:Su())!=null?Mg:g1);v1=()=>{var g,b,y,_,S,E,P,C,k,G,ce;let{payloadJson:e,headerJson:t,signature:r}=ge.schema.length?Ng(ge.schema):{},n=`${ge.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ge.schema.length?ge.schema:window.location.href).searchParams,a=(y=(b=(g=o.get("mpId"))!=null?g:o.get("appId"))!=null?b:o.get("gameId"))!=null?y:"",s=(E=(S=(_=ge.clientSessionId)!=null?_:e==null?void 0:e.sessionId)!=null?S:o.get("sessionId"))!=null?E:n,l=!!((C=(P=e==null?void 0:e.testAdsMode)!=null?P:e==null?void 0:e.__testAdsMode)!=null?C:o.get("testAdsMode")==="true"),c=(ce=(G=(k=e==null?void 0:e.joliboxEnv)!=null?k:e==null?void 0:e.__joliboxEnv)!=null?G:o.get("joliboxEnv"))!=null?ce:"production",d=c==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,h=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 l},get joliboxEnv(){return c},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:wu()},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 h},get from(){return e==null?void 0:e.__from},get baseApiHost(){return yu(d)},get adId(){var N;return(N=ge.deviceInfo.adId)!=null?N:ge.deviceInfo.did},get language(){return ge.deviceInfo.lang},get sdkEnvironment(){return Iu("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Iu("gamedistribution","jolibox")?"gamedistribution":Iu("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var H,te,Ut;let N=(H=ge.deviceInfo.pixelRatio)!=null?H:1,R=(te=ge.deviceInfo.statusBarHeight)!=null?te:e==null?void 0:e.__androidStatusBarHeight,U=(Ut=ge.deviceInfo.navigationBarHeight)!=null?Ut:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:R!==void 0?R/N:20,navigationBarHeight:U!==void 0?U/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=>{wg(ge,N,Sg)},encodeJoliSourceQuery:N=>{var R,U;return t&&r?Dg(T(T({},e),N),(R=o.get("joliSource"))!=null?R:""):(U=o.get("joliSource"))!=null?U:""},setDoExitDirectly:()=>{h=!1}}},I=v1()});var Eu,jg,y1,b1,Fg,_1,Bg=x(()=>{"use strict";O();vt();J();O();Eu=!1,jg=(e,t)=>e==null?!1:t in e,y1=e=>jg(e,"kind"),b1=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Fg=(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:b1(e.name)},i=B(T({},n),{env:t.environment,isFromUser:r});r?un.emit("GLOBAL_USER_ERROR",e,i):un.emit("GLOBAL_ERROR",e,i)},_1=e=>jg(e,"kind")&&e.kind==="USER_ERROR";bu.on("ERROR_REPORT",({error:e,options:t})=>{if(Eu)return;Eu=!0;let r=y1(e)&&e.raw?e.raw:e;try{let n=_1(e);Fg(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new hu(`${i}, origin error: ${r.message}`);zt.error(o),Fg(new hu(o.message),{environment:t.environment},!1)}finally{Eu=!1}})});var Xe,Au,jr=x(()=>{"use strict";vt();O();vt();Xe=(e,t)=>{var r,n;return new Xi((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Au=e=>new Ig(e)});var Gg=x(()=>{"use strict";Bg();jr();O();ue();un.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};F("trackAsync",{event:"reportJsError",data:r})});un.on("GLOBAL_USER_ERROR",(e,t)=>{zt.log("UserError",e,t)})});var ku=x(()=>{"use strict"});function Jg(e,t){let r=(n,i,o)=>{let c=i!=null?i:{},{eventType:a}=c,s=Qe(c,["eventType"]),l=B(T({tag:n,eventType:o!=null?o:a!=null?a:V.Other},t),{extra:T({},s)});n=="globalJsError"?Ee(new kg(JSON.stringify(l))):e("systemLog",l,I.webviewId)};return r.debounce=Yi(r,500,{leading:!0}),r}function Hg(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=Yi(t,500,{leading:!0}),t}var $g=x(()=>{"use strict";O();O();vt();J()});function Vg(e,t){let r=Jg(e,t),n=Hg(r);return{track:r,trackPerformance:n}}var Wg=x(()=>{"use strict";$g()});var zg=x(()=>{"use strict";J();O();O()});var Kg=x(()=>{"use strict";Wg();ku();zg()});var qa,Yg=x(()=>{"use strict";qa=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(),h=f-r;h>=this.interval&&(this.visible&&(a+=Math.min(h,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},l=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},c=()=>{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?c():l())});let p=this.visible;return{start(){o||(o=!0,p?c():l())},stop(){o=!1,d(),u()}}}}});function Ua(e,t,r){var l,c,d;let n=new Map,i=(l=r==null?void 0:r.baseUrl)!=null?l:Jn(I.testMode),o=(c=r==null?void 0:r.type)!=null?c:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return De("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,y=Qe(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(y):p.reject(y),n.delete(g)}else if(u.state==="fail"){let h=u,{requestTaskId:g,state:b}=h,y=Qe(h,["requestTaskId","state"]);p.reject(y),n.delete(g)}else zt.warn("onRequestTaskStateChange unknown event",u)}),_e.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...h)=>v(this,[f,...h],function*(u,p={}){let g=Date.now(),b=w1(u,B(T({},p),{baseUrl:i})),{method:y="GET",responseType:_="text",dataType:S="json",timeout:E,enableCache:P=!1,appendHostCookie:C=!0}=p,k=Object.assign({"content-type":"application/json"},a,p.header),G={url:b,method:y,header:k,enableCache:P,responseType:_,appendHostCookie:C};if(y=="POST"||y=="PUT"){let H=I1(p.data,k["content-type"]);G.data=H}E&&Object.assign(G,{timeout:E});let{data:{requestTaskId:ce}}=F(e,G);if(typeof ce!="string")throw Xe({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:R,promise:U}=new ut;n.set(ce,{resolve:N,reject:R});try{let H=yield U,{data:te}=H;return S==="json"&&typeof te=="string"&&(te=S1(te)),{url:b,timeout:E,method:y,response:B(T({},H),{data:te})}}catch(H){let te=H;if(cn(te)){let{errMsg:Ut,prefetchDetail:Fc,isPrefetch:jc,errNo:qR}=te;zi(Ut)&&Ee(Xe({code:-1,msg:Ut},{errNo:qR,errMsg:Ut}))}throw H}})}function S1(e){try{return JSON.parse(e.trim())}catch(t){return e}}function I1(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 w1,Cu=x(()=>{"use strict";O();ue();vt();jr();J();w1=(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 xu,Qg,ne,yt=x(()=>{"use strict";Cu();J();O();xu={};(Qg=I.hostUserInfo)!=null&&Qg.token&&(xu["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(xu["x-joli-source"]=I.joliSource);ne=Ua("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Jn(I.testMode),defaultHeaders:xu})});function Xg(e){let t=mu.config[e];return t||(t={},mu.config[e]=t),(r,n)=>{if(t[r]){zt.warn(`[can i use] ${r} already registered`);return}t[r]=T({},n)}}var Zg=x(()=>{"use strict";O()});function Pu(e){ev=e}function Ma(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ma(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ma(e[r]),t),{})}function fr(e){return typeof e=="number"}function Tu(e){let t=Ru(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Ru(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var ev,Ce,Fa,ja,Ba,Ga,Hn,Ja,Ha,$a,Va,Wa,za,Ka,Ya,Qa,Xa,Za,es,Ou=x(()=>{"use strict";ev=!1;Ce=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(ev)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 ${Tu(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ma(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ma(this._default)}optional(){return this._optional=!0,this}};Fa=class extends Ce{validate(t){return this._optional&&t===void 0?!0:fr(t)?fr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):fr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):fr(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}},ja=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Ba=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(fr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(fr(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}},Ga=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Hn=class extends Ce{validate(t){return!0}},Ja=class extends Ce{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ha=class extends Ce{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},$a=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Va=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 ${Tu(t)}`)}return!0}},Wa=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(fr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(fr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(fr(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}},za=class extends Ce{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ru(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 l=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}"]`,!(l===void 0&&o._optional)){if(l===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(l)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},Ka=class extends Ce{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ru(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}},Ya=class extends Ce{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Tu(this.value),actual:r}):!0}},Qa=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 UR=Object.create;var Ea=Object.defineProperty,MR=Object.defineProperties,FR=Object.getOwnPropertyDescriptor,jR=Object.getOwnPropertyDescriptors,BR=Object.getOwnPropertyNames,Ia=Object.getOwnPropertySymbols,GR=Object.getPrototypeOf,Bc=Object.prototype.hasOwnProperty,Bm=Object.prototype.propertyIsEnumerable;var jm=(e,t,r)=>t in e?Ea(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))Bc.call(t,r)&&jm(e,r,t[r]);if(Ia)for(var r of Ia(t))Bm.call(t,r)&&jm(e,r,t[r]);return e},B=(e,t)=>MR(e,jR(t));var Qe=(e,t)=>{var r={};for(var n in e)Bc.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ia)for(var n of Ia(e))t.indexOf(n)<0&&Bm.call(e,n)&&(r[n]=e[n]);return r};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Gm=(e,t)=>{for(var r in t)Ea(e,r,{get:t[r],enumerable:!0})},JR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of BR(t))!Bc.call(e,i)&&i!==r&&Ea(e,i,{get:()=>t[i],enumerable:!(n=FR(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?UR(GR(e)):{},JR(t||!e||!e.__esModule?Ea(r,"default",{value:e,enumerable:!0}):r,e));var v=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((r=r.apply(e,t)).next())});function KR(e){return!!(e!=null&&e.__nativeBuffers__)}function zc(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!KR(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=YR(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function XR(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:QR(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function rO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function tg(e){return typeof e=="string"}function jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Hm(e){return typeof e=="number"&&!isNaN(e)}function iO(e){return typeof e=="undefined"}function oO(e){return iO(e)||e===null}function rg(e){return typeof e=="function"}function aO(e){return jn(e)&&rg(e.then)}function ng(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function ji(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function fO(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 yO(){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 IO(e){return new Promise(t=>ig(e)(t))}function ig(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function EO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ji(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function kO(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)CO(e[n],t[n])}function CO(e,t){if(tg(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(rg(t)){try{if(e instanceof t)return}catch(r){}if(!oO(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 Pt(e,t){if(Yc.config[e]){Ta.warn(`[can i use] ${e} already registered`);return}Yc.config[e]=pr({},t)}function Wm(e,t){return`[${e}]:${t}`}function DO(e,t){zm||(Hc=new ka({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),$c=new ka({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Vc=new ka({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Hc.flush(),$c.flush(),Vc.flush()}),zm=!0);function r(i){var o,a;let{method:s,args:l,startTime:c,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:h,invokeCallback:g}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Hc.report({status:b,method:n(s,l),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-c}),c&&h&&g&&($c.report({status:b,method:s,isForeground:d,duration:Number((h-c).toFixed(3))}),Vc.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 MO(e,t){let r=0,n=!0,i=UO.resolveMap,o=DO(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Wc.forEach(l=>xa(this,[l],function*({method:c,args:d,resolve:u}){let p=yield s(c,d);u(p)})),Wc.length=0});let a=(l,c)=>{let d=i.get(Number(l));if(!d)return;let u=zc(c);d(u),i.delete(Number(l))},s=(l,c)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let h=new nO;if(i.set(r,h.resolve),!n&&TO.includes(l))return new Promise(E=>{Wc.push({method:l,args:c,resolve:E})});let g=WR(pr({},{method:l,startTime:p,args:c,isForeground:f}),{invokeType:"js-bridge"}),b=!LO&&PO.includes(l),y=XR(c,b),_=b?y:JSON.stringify(y),S;if(l.endsWith("Sync")||RO.includes(l)?S=(d=e.call)==null?void 0:d.call(e,l,y,r):typeof _=="string"?S=e.invoke(l,_,r):S=(u=e.call)==null?void 0:u.call(e,l,_,r),S){try{typeof S=="string"&&(S=JSON.parse(S)),S=zc(S)}catch(E){Ta.error(E)}return i.delete(r),S.errorCode&&(S.errorCode=Wm(l,S.errorCode)),o(pr(pr({},g),S)),S}return l.endsWith("Sync")&&i.delete(r),h.promise.then(E=>(E.errorCode&&(E.errorCode=Wm(l,E.errorCode)),o(pr(pr({},g),E)),E))};return{invokeNative:s,applyNative:(l,c)=>{let d=s(l,c);return aO(d)?d.then(u=>Km(l,u)):Km(l,d)},invokeHandler:a}}function Km(e,t){if(!jn(t)){Ta.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=zR(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new uO(n,i,o,a);return s}function FO(e){if(globalThis[Aa])return globalThis[Aa];let t=new Zc,r=new Zc,n=new ka({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[Aa]={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=zc(o),l;if(s.__extra){l=s.params;let{type:c,startTime:d}=s.__extra;n.report({type:c,event:i,duration:Date.now()-d})}else l=s;if(i===ag){l.forEach(c=>{let[d,u]=c;try{r.emit(d.slice(Gi.length),u,a)}catch(p){}});return}if(i.startsWith(Gi)){r.emit(i.slice(Gi.length),l,a);return}t.emit(i,l,a)}},globalThis[Aa]}function jO(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,l)=>{if(l){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Gi}${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(ag,d,p)}catch(p){}}),n=void 0,t.clear()}));let c=t.get(s);c||(c=[],t.set(s,c)),c.push([`${Gi}${o}`,a])},emitNative:(o,a,s,l)=>{if(l){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(OO,d,p)}catch(p){}}),i=void 0,r.clear()}));let c=r.get(s);c||(c=[],r.set(s,c)),c.push([o,a])}}}function BO(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=FO(e),{invokeNative:a,invokeHandler:s,applyNative:l}=MO(e,r),{publish:c,emitNative:d}=jO(e);return{invokeHandler:s,subscribeHandler:t,applyNative:l,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:c,subscribe:i,unsubscribe:o}}function sg(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var HR,$R,VR,Ca,Qm,Xm,Jm,pr,WR,zR,xa,YR,QR,Zm,ZR,eO,eg,tO,nO,sO,lO,Pa,cO,uO,dO,Gc,Ta,$m,pO,Kc,hO,Yc,mO,gO,vO,Fn,bO,n6,Qc,fe,_O,wO,Bi,Ji,Zc,eu,SO,Jc,AO,i6,tu,Vm,o6,og,xO,Gi,PO,TO,RO,ag,OO,NO,ka,zm,Hc,$c,Vc,Wc,LO,ru,qO,UO,Aa,nu,xt,lg,cg,GO,ug,Ym,he,F,De,a6,JO,dg,iu,s6,l6,ue=x(()=>{"use strict";HR=Object.defineProperty,$R=Object.defineProperties,VR=Object.getOwnPropertyDescriptors,Ca=Object.getOwnPropertySymbols,Qm=Object.prototype.hasOwnProperty,Xm=Object.prototype.propertyIsEnumerable,Jm=(e,t,r)=>t in e?HR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pr=(e,t)=>{for(var r in t||(t={}))Qm.call(t,r)&&Jm(e,r,t[r]);if(Ca)for(var r of Ca(t))Xm.call(t,r)&&Jm(e,r,t[r]);return e},WR=(e,t)=>$R(e,VR(t)),zR=(e,t)=>{var r={};for(var n in e)Qm.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ca)for(var n of Ca(e))t.indexOf(n)<0&&Xm.call(e,n)&&(r[n]=e[n]);return r},xa=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((r=r.apply(e,t)).next())});YR=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};QR=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)};Zm=Object.defineProperty,ZR=Object.getOwnPropertyDescriptor,eO=(e,t)=>{for(var r in t)Zm(e,r,{get:t[r],enumerable:!0})},eg=(e,t,r,n)=>{for(var i=n>1?void 0:n?ZR(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&&Zm(t,r,i),i},tO=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.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}nO=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))}})}};sO=(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))(sO||{}),lO=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}},Pa=class extends lO{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},cO=class extends Pa{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},uO=class extends Pa{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},dO=class extends Pa{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Gc=class extends Pa{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Ta={log:ji("log"),warn:ji("warn"),info:ji("info"),error:ji("error"),debug:ji("debug")};Object.assign(globalThis,{logger:Ta});$m=Symbol.for("Jolibox.canIUseMap"),pO={};globalThis[$m]||(globalThis[$m]=pO);Kc=Symbol.for("Jolibox.canIUseMap.native"),hO={};globalThis[Kc]||(globalThis[Kc]=hO);Yc={get config(){return globalThis[Kc]}},mO=(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))(mO||{}),gO=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(gO||{}),vO=(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))(vO||{});yO();Fn=typeof window=="undefined",bO=()=>!Fn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),n6={isiOS:!Fn&&(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:!Fn&&navigator.userAgent.includes("Android"),isMac:!Fn&&navigator.userAgent.includes("Mac"),isFacebook:!Fn&&navigator.userAgent.includes("FB_IAB"),isPC:!Fn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Qc=class Xc{constructor(t){this.element=t,this.next=Xc.Undefined,this.prev=Xc.Undefined}};Qc.Undefined=new Qc(void 0);fe=Qc,_O=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}},wO=0,Bi=class{constructor(e){this.value=e,this.id=wO++}},Ji=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 Bi&&(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,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new Bi(t);return this._listeners?this._listeners instanceof Bi?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Bi)this._listeners.id===c.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 h=this._listeners.indexOf(c);h>=0&&(this._listeners.splice(h,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 Bi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Zc=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 Ji,o=l=>t(...l.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 l of s)t(...l.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 _O,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)}},eu={};eO(eu,{None:()=>SO,filter:()=>EO,once:()=>ig,toPromise:()=>IO});SO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Jc=Symbol.for("Jolibox.hostEmitter"),AO=()=>{let e=new Zc;return globalThis[Jc]||(globalThis[Jc]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Jc]},i6=AO();tu=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ji,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 kO(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}};tu=eg([ng],tu);Vm=class{constructor(){this._onWillExecuteCommand=new Ji,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ji,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new tu,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=rO(3e4)),this._starActivation}executeCommand(e,...t){return tO(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),eu.toPromise(eu.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}}};Vm=eg([ng],Vm);o6=Symbol.for("Jolibox.commands");Pt("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Pt("requestProductDetailsAsync",{version:102e4});Pt("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Pt("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Pt("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Pt("userTrackAsync",{version:1e6});Pt("openMiniapp",{version:1050100});Pt("requestCoinDetailsSync",{version:1070100});Pt("requestCoinDetailsAsync",{version:1070100});Pt("sendServerEventAsync",{version:1070100});Pt("loadAdsAsync",{version:1070200});Pt("showAdAsync",{version:1070200});og=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let l=Yc.config[a];if(!l)return!1;let c=(o=t==null?void 0:t())!=null?o:"",d=l.version;if(l.platforms&&c in l.platforms){let p=l.platforms[c];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(l,s,u)||n(l.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=fO(i,o);if(!s)return!1;if(jn(s)){let l=s.version;return Hm(l)?typeof a=="number"&&a>=l:!0}return Hm(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};xO=()=>bO(),Gi="custom_event_",PO=[],TO=[],RO=["env","createRequestTask","login"],ag="__batch_event__",OO="__native_batch_event__",NO=e=>e==="pv"?e:"default",ka=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=NO(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&&jn(a))throw new Gc(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let l=[];if(jn(a))l.push(...Object.keys(a));else if(tg(a)){if(i.length>0)throw new Gc(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);l.push(a)}else throw new Gc(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);l.forEach(c=>{n[c]||(n[c]={});let d=jn(a)?a[c]:a;t(n[c],[...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={}}},zm=!1;Wc=[],LO=!1,ru=Symbol.for("Jolibox.invokeResolverInstance"),qO=new Map;globalThis[ru]||(globalThis[ru]=qO);UO={get resolveMap(){return globalThis[ru]}};Aa=Symbol.for("Jolibox.subscribeInstance");xt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){xt.trigger=e},onDoExit(e){xt.exit=e},onDoBackPress(e){xt.backPress=e}},lg=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new cO("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="")=>{xt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>xa(void 0,null,function*(){let o=yield xt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});nu={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=sg(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:lg,doExit:r};globalThis.joliboxJSCore=pr({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{xt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>xa(void 0,null,function*(){let a=yield xt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});nu={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let l=sg(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(l),webviewIds:s}))},call(o,a,s){let l=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(l)return JSON.parse(l)},doBackPress(o){return xa(this,null,function*(){let a=yield xt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:lg,doExit:n};globalThis.joliboxJSCore=pr({},i)}cg=nu;if(!cg&&xO())throw new dO("No joliboxJScore is found, native bridge not found.");GO=pr({},cg),ug=BO(GO),{invokeHandler:Ym}=ug,{applyNative:he,invokeNative:F,onNative:De,offNative:a6,subscribeHandler:JO,publish:dg,emitNative:iu,subscribe:s6,unsubscribe:l6}=ug;globalThis.joliboxJSBridge={callHandler:Ym,invokeHandler:Ym,subscribeHandler:JO}});function zO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Oa(e){return new Promise(t=>setTimeout(t,e))}function zi(e){return typeof e=="string"}function cn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yg(e){return typeof e=="object"&&Array.isArray(e)}function Na(e){return typeof e=="number"&&!isNaN(e)}function Fr(e){return e===!0||e===!1}function bg(e){return typeof e=="undefined"}function Ki(e){return bg(e)||e===null}function KO(e){return typeof e=="function"}function _g(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function wg(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],l=o[a],c=r(s,l,a,i,o);c!==void 0?i[a]=c:hg(l)&&hg(s)?i[a]=n(gg({},s),l):Array.isArray(l)&&Array.isArray(s)?i[a]=[...s,...l]:i[a]=l}return i}return n(e,t)}function hg(e){return e&&typeof e=="object"&&e.constructor===Object}function Sg(e,t){if(Array.isArray(e))return e.concat(t)}function Yi(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:l=!0}=r,c=()=>(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,l&&!p&&c()},t),p)return c()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,c()},d}function QO(e,t){return(...r)=>t(e,...r)}function Bn(e){return t=>QO(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Wt(`${i}`))}})}function Hi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Cg(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 l=parseInt(i[s],10)||0,c=parseInt(o[s],10)||0;if(l>c){n=1;break}else if(l<c){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 vu(){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 n1(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 yu(e){return n1("app","stg-app",e)}function Jn(e){return`https://${yu(e)}`}function s1(e){return new Promise(t=>Rg(e)(t))}function Rg(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function l1(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Wi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function u1(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)d1(e[n],t[n])}function d1(e,t){if(zi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(KO(t)){try{if(e instanceof t)return}catch(r){}if(!Ki(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 p1(){return typeof globalThis!="undefined"?globalThis[Og]:void 0}function f1(e){typeof globalThis!="undefined"&&(globalThis[Og]=e)}function W(e=!1){let t=p1();if(!e&&t)return t;let r=new Ra,n=new uu,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 f1(i),i}var du,HO,pg,$O,VO,fg,gg,WO,vg,ln,ut,YO,pu,Qi,fu,Ig,Wt,Da,Eg,La,Ag,kg,Xi,hu,zt,au,XO,mu,mg,ZO,V,gu,e1,Gn,$i,Zi,t1,r1,xg,Pg,Tg,Mt,su,me,i1,o1,Vi,Wi,Kt,cu,a1,ou,c1,_e,Ra,uu,Og,O=x(()=>{"use strict";du=Object.defineProperty,HO=Object.getOwnPropertyDescriptor,pg=Object.getOwnPropertySymbols,$O=Object.prototype.hasOwnProperty,VO=Object.prototype.propertyIsEnumerable,fg=(e,t,r)=>t in e?du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gg=(e,t)=>{for(var r in t||(t={}))$O.call(t,r)&&fg(e,r,t[r]);if(pg)for(var r of pg(t))VO.call(t,r)&&fg(e,r,t[r]);return e},WO=(e,t)=>{for(var r in t)du(e,r,{get:t[r],enumerable:!0})},vg=(e,t,r,n)=>{for(var i=n>1?void 0:n?HO(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&&du(t,r,i),i},ln=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.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}ut=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))}})}};YO=(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))(YO||{}),pu=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}},Qi=class extends pu{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},fu=class extends pu{constructor(){super(...arguments),this.kind="USER_ERROR"}},Ig=class extends fu{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Wt=class extends fu{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))}},Da=class extends fu{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))}},Eg=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},La=class extends Qi{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))}},Ag=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},kg=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Xi=class extends pu{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}}},hu=class extends Qi{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};zt={log:Hi("log"),warn:Hi("warn"),info:Hi("info"),error:Hi("error"),debug:Hi("debug")};Object.assign(globalThis,{logger:zt});au=Symbol.for("Jolibox.canIUseMap"),XO={};globalThis[au]||(globalThis[au]=XO);mu={get config(){return globalThis[au]}},mg=Symbol.for("Jolibox.canIUseMap.native"),ZO={};globalThis[mg]||(globalThis[mg]=ZO);V=(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))(V||{}),gu=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(gu||{}),e1=(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))(e1||{}),Gn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});vu();$i=typeof window=="undefined",Zi={isiOS:!$i&&(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:!$i&&navigator.userAgent.includes("Android"),isMac:!$i&&navigator.userAgent.includes("Mac"),isFacebook:!$i&&navigator.userAgent.includes("FB_IAB"),isPC:!$i&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},t1="device_id",r1="advertising_id",xg=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Gn()),window.__joliboxLocalStorage__.getItem(e)),Pg=()=>new URLSearchParams(window.location.search).get("deviceId")||xg(t1),Tg=()=>new URLSearchParams(window.location.search).get("advertisingId")||xg(r1);Mt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=gg({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return ln(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=>ln(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(r);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}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 ln(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,l=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",l),l){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(l,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(l,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(l):l}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let c=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,c);return d&&this.setCachedDataWithSequence(a,d,s),c})}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 ln(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return ln(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 ln(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)}},su=class lu{constructor(t){this.element=t,this.next=lu.Undefined,this.prev=lu.Undefined}};su.Undefined=new su(void 0);me=su,i1=class{constructor(){this._first=me.Undefined,this._last=me.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===me.Undefined}clear(){let e=this._first;for(;e!==me.Undefined;){let t=e.next;e.prev=me.Undefined,e.next=me.Undefined,e=t}this._first=me.Undefined,this._last=me.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new me(e);if(this._first===me.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!==me.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==me.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==me.Undefined&&e.next!==me.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===me.Undefined&&e.next===me.Undefined?(this._first=me.Undefined,this._last=me.Undefined):e.next===me.Undefined?(this._last=this._last.prev,this._last.next=me.Undefined):e.prev===me.Undefined&&(this._first=this._first.next,this._first.prev=me.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==me.Undefined;)yield e.element,e=e.next}},o1=0,Vi=class{constructor(e){this.value=e,this.id=o1++}},Wi=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 Vi&&(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,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new Vi(t);return this._listeners?this._listeners instanceof Vi?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Vi)this._listeners.id===c.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 h=this._listeners.indexOf(c);h>=0&&(this._listeners.splice(h,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 Vi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Kt=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 Wi,o=l=>t(...l.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 l of s)t(...l.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 i1,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)}},cu={};WO(cu,{None:()=>a1,filter:()=>l1,once:()=>Rg,toPromise:()=>s1});a1=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});ou=Symbol.for("Jolibox.hostEmitter"),c1=()=>{let e=new Kt;return globalThis[ou]||(globalThis[ou]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[ou]},_e=c1();Ra=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Wi,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 u1(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}};Ra=vg([_g],Ra);uu=class{constructor(){this._onWillExecuteCommand=new Wi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Wi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ra,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=zO(3e4)),this._starActivation}executeCommand(e,...t){return ln(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),cu.toPromise(cu.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}}};uu=vg([_g],uu);Og=Symbol.for("Jolibox.commands")});function Ee(e,t={}){bu.emit("ERROR_REPORT",{error:e,options:t})}var bu,un,vt=x(()=>{"use strict";O();O();bu=new Kt,un=new Kt;Ee.debounce=Yi(Ee,50,{leading:!0})});var _u,h1,Ng,Dg,Lg=x(()=>{"use strict";O();vt();_u=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{}}},h1=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Ng=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:_u(o),payloadJson:_u(a),signature:_u(s)}}else throw"joli_source is missing"}catch(r){return Ee(new Eg(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},Dg=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=h1(e),o=r[2];return`${n}.${i}.${o}`}return t}});var m1,wu,qg=x(()=>{"use strict";O();m1="1.3.5-beta.3",wu=()=>m1});function Iu(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var g1,Ug,Su,Mg,ge,v1,I,J=x(()=>{"use strict";O();Lg();qg();O();g1={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Pg(),adId:Tg(),pixelRatio:window.devicePixelRatio||1,platform:Zi.isAndroid?"android":Zi.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:wu()},schema:window.location.href,platform:Zi.isAndroid?"android":Zi.isiOS?"ios":"h5"},Su=(Ug=globalThis.joliboxJSCore)==null?void 0:Ug.env,ge=Object.assign({},(Mg=Su==null?void 0:Su())!=null?Mg:g1);v1=()=>{var g,b,y,_,S,E,P,C,k,G,ce;let{payloadJson:e,headerJson:t,signature:r}=ge.schema.length?Ng(ge.schema):{},n=`${ge.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ge.schema.length?ge.schema:window.location.href).searchParams,a=(y=(b=(g=o.get("mpId"))!=null?g:o.get("appId"))!=null?b:o.get("gameId"))!=null?y:"",s=(E=(S=(_=ge.clientSessionId)!=null?_:e==null?void 0:e.sessionId)!=null?S:o.get("sessionId"))!=null?E:n,l=!!((C=(P=e==null?void 0:e.testAdsMode)!=null?P:e==null?void 0:e.__testAdsMode)!=null?C:o.get("testAdsMode")==="true"),c=(ce=(G=(k=e==null?void 0:e.joliboxEnv)!=null?k:e==null?void 0:e.__joliboxEnv)!=null?G:o.get("joliboxEnv"))!=null?ce:"production",d=c==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,h=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 l},get joliboxEnv(){return c},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:wu()},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 h},get from(){return e==null?void 0:e.__from},get baseApiHost(){return yu(d)},get adId(){var N;return(N=ge.deviceInfo.adId)!=null?N:ge.deviceInfo.did},get language(){return ge.deviceInfo.lang},get sdkEnvironment(){return Iu("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Iu("gamedistribution","jolibox")?"gamedistribution":Iu("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var H,te,Ut;let N=(H=ge.deviceInfo.pixelRatio)!=null?H:1,R=(te=ge.deviceInfo.statusBarHeight)!=null?te:e==null?void 0:e.__androidStatusBarHeight,U=(Ut=ge.deviceInfo.navigationBarHeight)!=null?Ut:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:R!==void 0?R/N:20,navigationBarHeight:U!==void 0?U/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=>{wg(ge,N,Sg)},encodeJoliSourceQuery:N=>{var R,U;return t&&r?Dg(T(T({},e),N),(R=o.get("joliSource"))!=null?R:""):(U=o.get("joliSource"))!=null?U:""},setDoExitDirectly:()=>{h=!1}}},I=v1()});var Eu,jg,y1,b1,Fg,_1,Bg=x(()=>{"use strict";O();vt();J();O();Eu=!1,jg=(e,t)=>e==null?!1:t in e,y1=e=>jg(e,"kind"),b1=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Fg=(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:b1(e.name)},i=B(T({},n),{env:t.environment,isFromUser:r});r?un.emit("GLOBAL_USER_ERROR",e,i):un.emit("GLOBAL_ERROR",e,i)},_1=e=>jg(e,"kind")&&e.kind==="USER_ERROR";bu.on("ERROR_REPORT",({error:e,options:t})=>{if(Eu)return;Eu=!0;let r=y1(e)&&e.raw?e.raw:e;try{let n=_1(e);Fg(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new hu(`${i}, origin error: ${r.message}`);zt.error(o),Fg(new hu(o.message),{environment:t.environment},!1)}finally{Eu=!1}})});var Xe,Au,jr=x(()=>{"use strict";vt();O();vt();Xe=(e,t)=>{var r,n;return new Xi((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Au=e=>new Ig(e)});var Gg=x(()=>{"use strict";Bg();jr();O();ue();un.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};F("trackAsync",{event:"reportJsError",data:r})});un.on("GLOBAL_USER_ERROR",(e,t)=>{zt.log("UserError",e,t)})});var ku=x(()=>{"use strict"});function Jg(e,t){let r=(n,i,o)=>{let c=i!=null?i:{},{eventType:a}=c,s=Qe(c,["eventType"]),l=B(T({tag:n,eventType:o!=null?o:a!=null?a:V.Other},t),{extra:T({},s)});n=="globalJsError"?Ee(new kg(JSON.stringify(l))):e("systemLog",l,I.webviewId)};return r.debounce=Yi(r,500,{leading:!0}),r}function Hg(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=Yi(t,500,{leading:!0}),t}var $g=x(()=>{"use strict";O();O();vt();J()});function Vg(e,t){let r=Jg(e,t),n=Hg(r);return{track:r,trackPerformance:n}}var Wg=x(()=>{"use strict";$g()});var zg=x(()=>{"use strict";J();O();O()});var Kg=x(()=>{"use strict";Wg();ku();zg()});var qa,Yg=x(()=>{"use strict";qa=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(),h=f-r;h>=this.interval&&(this.visible&&(a+=Math.min(h,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},l=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},c=()=>{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?c():l())});let p=this.visible;return{start(){o||(o=!0,p?c():l())},stop(){o=!1,d(),u()}}}}});function Ua(e,t,r){var l,c,d;let n=new Map,i=(l=r==null?void 0:r.baseUrl)!=null?l:Jn(I.testMode),o=(c=r==null?void 0:r.type)!=null?c:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return De("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,y=Qe(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(y):p.reject(y),n.delete(g)}else if(u.state==="fail"){let h=u,{requestTaskId:g,state:b}=h,y=Qe(h,["requestTaskId","state"]);p.reject(y),n.delete(g)}else zt.warn("onRequestTaskStateChange unknown event",u)}),_e.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...h)=>v(this,[f,...h],function*(u,p={}){let g=Date.now(),b=w1(u,B(T({},p),{baseUrl:i})),{method:y="GET",responseType:_="text",dataType:S="json",timeout:E,enableCache:P=!1,appendHostCookie:C=!0}=p,k=Object.assign({"content-type":"application/json"},a,p.header),G={url:b,method:y,header:k,enableCache:P,responseType:_,appendHostCookie:C};if(y=="POST"||y=="PUT"){let H=I1(p.data,k["content-type"]);G.data=H}E&&Object.assign(G,{timeout:E});let{data:{requestTaskId:ce}}=F(e,G);if(typeof ce!="string")throw Xe({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:R,promise:U}=new ut;n.set(ce,{resolve:N,reject:R});try{let H=yield U,{data:te}=H;return S==="json"&&typeof te=="string"&&(te=S1(te)),{url:b,timeout:E,method:y,response:B(T({},H),{data:te})}}catch(H){let te=H;if(cn(te)){let{errMsg:Ut,prefetchDetail:Fc,isPrefetch:jc,errNo:qR}=te;zi(Ut)&&Ee(Xe({code:-1,msg:Ut},{errNo:qR,errMsg:Ut}))}throw H}})}function S1(e){try{return JSON.parse(e.trim())}catch(t){return e}}function I1(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 w1,Cu=x(()=>{"use strict";O();ue();vt();jr();J();w1=(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 xu,Qg,ne,yt=x(()=>{"use strict";Cu();J();O();xu={};(Qg=I.hostUserInfo)!=null&&Qg.token&&(xu["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(xu["x-joli-source"]=I.joliSource);ne=Ua("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Jn(I.testMode),defaultHeaders:xu})});function Xg(e){let t=mu.config[e];return t||(t={},mu.config[e]=t),(r,n)=>{if(t[r]){zt.warn(`[can i use] ${r} already registered`);return}t[r]=T({},n)}}var Zg=x(()=>{"use strict";O()});function Pu(e){ev=e}function Ma(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ma(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ma(e[r]),t),{})}function fr(e){return typeof e=="number"}function Tu(e){let t=Ru(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Ru(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var ev,Ce,Fa,ja,Ba,Ga,Hn,Ja,Ha,$a,Va,Wa,za,Ka,Ya,Qa,Xa,Za,es,Ou=x(()=>{"use strict";ev=!1;Ce=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(ev)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 ${Tu(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ma(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ma(this._default)}optional(){return this._optional=!0,this}};Fa=class extends Ce{validate(t){return this._optional&&t===void 0?!0:fr(t)?fr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):fr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):fr(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}},ja=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Ba=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(fr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(fr(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}},Ga=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Hn=class extends Ce{validate(t){return!0}},Ja=class extends Ce{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ha=class extends Ce{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},$a=class extends Ce{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Va=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 ${Tu(t)}`)}return!0}},Wa=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(fr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(fr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(fr(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}},za=class extends Ce{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ru(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 l=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}"]`,!(l===void 0&&o._optional)){if(l===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(l)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},Ka=class extends Ce{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Ru(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}},Ya=class extends Ce{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Tu(this.value),actual:r}):!0}},Qa=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}},Xa=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}},Za=class extends Ce{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},es=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 Nu(e,t,r="param"){if(e.errors=[],e.path=r,Pu(!0),!e.validate(t)){let n=e.errors.join(`
3
3
  `);throw e.errors.length=0,Pu(!1),new TypeError(n)}}var A,Du=x(()=>{"use strict";Ou();Ou();A={object(e){return new Ka(e)},array(e){return new Wa(e)},tuple(...e){return new Xa(...e)},literal(e){return new Ya(e)},or(...e){return new Qa(...e)},symbol(){return new Ga},record(e){return new za(e)},function(){return new $a},boolean(){return new ja},string(){return new Ba},number(){return new Fa},undefined(){return new Ja},null(){return new Ha},unknown(){return new Hn},any(){return new Hn},as(){return new Hn},arraybuffer(){return new Za},enum(...e){return new Va(...e)},typedarray(e){return new es(e)}}});var ts,tv,rv=x(()=>{"use strict";O();vt();Du();jr();ts=1,tv=e=>{function t(n,i){return(...o)=>{var u,p,f,h;let a=Date.now(),s={method:n,trace_id:ts};ts+=1;let l="SUCCESS",c=`${n}:ok`,d=0;try{if(i.paramsSchema)try{Nu(i.paramsSchema,o,"params")}catch(_){throw Au(`${n}:fail ${_.message}`)}let g=i.implement(...o),b=g,y=`${n}:ok`;if(g&&"code"in g){let{code:_,data:S,message:E}=g;l=_,b=S,y=E}return{code:l,message:y,data:b}}catch(g){let b=g;d=(p=(u=b.code)!=null?u:b.errNo)!=null?p:2e3,l="FAILURE";let y=(h=(f=b.message)!=null?f:b.errMsg)!=null?h:`${g}`;return c=`${n}:${l} ${y.replace(/^\S+:(fail|cancel)\s?/,"")}`,Ee(new Xi(c,d)),{code:l,message:c}}finally{let g=Date.now()-a}}}function r(n,i){return(...o)=>v(this,null,function*(){var p,f,h,g;let a=yg(o)?o:[o],s=Date.now(),l={method:n,trace_id:ts};ts+=1;let c=`${n}:ok`,d="SUCCESS",u={code:d,message:c};try{if(i.paramsSchema)try{Nu(i.paramsSchema,a,"params")}catch(_){throw Au(_.message)}let y=yield i.implement(...a);if(y&&"code"in y){let{code:_,data:S,message:E}=y;d=_,c=E,y=S}return Object.assign(u,{code:d,message:c,data:y}),u}catch(b){let y=b,_=(f=(p=y.code)!=null?p:y.errNo)!=null?f:2e3;d="FAILURE";let S=(g=(h=y.message)!=null?h:y.errMsg)!=null?g:`${b}`,E=`${n}:${d} ${S.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:E}),Ee(new Xi(E,_)),u}finally{let b=Date.now()-s}})}return{createAPI:r,createSyncAPI:t}}});var je,Lu=x(()=>{"use strict";J();ue();({canIUseNative:je}=og(()=>I.sdkInfo.nativeSDKVersionCode,()=>I.platform))});function qu(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 nv=x(()=>{"use strict"});var oe,K,M,Je=x(()=>{"use strict";Zg();Tt();rv();Du();Lu();nv();({createAPI:oe,createSyncAPI:K}=tv(j)),M=Xg("native")});function iv(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return t==="array"&&(t="object"),P1.includes(t)?t:""}function ov(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 av(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 rs,A1,k1,C1,x1,q8,U8,P1,Br,bt,eo=x(()=>{"use strict";Je();ue();O();yt();J();rs=W(),A1=oe("getLocalStorage",{paramsSchema:A.tuple(A.string()),implement(e){return v(this,null,function*(){let{response:t}=yield ne(`/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 he("getLocalStorageAsync",{key:e}),s=ov(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}}})}});rs.registerCommand("StorageSDK.getItem",A1);M("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});k1=oe("setStorage",{paramsSchema:A.tuple(A.string(),A.or(A.string(),A.boolean(),A.number())),implement(e,t){return v(this,null,function*(){let r=I.mpId,n=typeof t=="string"?t:String(t),{response:i}=yield ne(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:a}}=i,s=iv(t),l=av(t,s);return yield he("setLocalStorageAsync",{key:e,data:l,dataType:s}),o=="SUCCESS"?{code:o,message:a}:{code:o,message:`${a}. fallback to native`}})}});rs.registerCommand("StorageSDK.setItem",k1);M("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});C1=oe("removeStorage",{paramsSchema:A.tuple(A.string()),implement(e){return v(this,null,function*(){let t=I.mpId,{response:r}=yield ne(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:i}}=r;return yield he("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:i}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});rs.registerCommand("StorageSDK.removeItem",C1);M("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});x1=oe("clearStorage",{implement(){return v(this,null,function*(){let e=I.mpId,{response:t}=yield ne(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});he("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});rs.registerCommand("StorageSDK.clear",x1);M("storage.clear",{version:"1.0.0"});q8=oe("getStorageInfo",{implement(){return v(this,null,function*(){let{data:e}=yield he("getStorageInfoAsync");return e})}});M("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});U8=K("getStorageInfoSync",{implement(){return F("getStorageInfoSync")}}),P1=["string","number","boolean","object",""];Br=oe("getGlobalStorage",{paramsSchema:A.tuple(A.string()),implement(e){return v(this,null,function*(){try{let{data:{data:t,dataType:r}}=yield he("getGlobalStorageAsync",{key:e});return{code:"SUCCESS",message:"success",data:ov(t,r)}}catch(t){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get global storage failed",data:null}}})}}),bt=oe("setGlobalStorage",{paramsSchema:A.tuple(A.string(),A.or(A.string(),A.boolean(),A.number(),A.array())),implement(e,t){return v(this,null,function*(){try{let r=iv(t),n=av(t,r);return yield he("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 sv,ns,lv=x(()=>{"use strict";J();Yg();O();yt();ue();eo();Lu();sv="REPORT_FIRST_OPEN_GAME",ns=class extends qa{constructor(t,r,n){super(r,n),this.gameId=I.mpId,this.sessionId=I.sessionId,this.track=t,this.taskUrl=Jn(I.testMode)+"/api/base/app-event"}reporter(t){return v(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 v(this,null,function*(){let{event:r,params:n}=t;yield he("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(){Br(sv).then(t=>{Fr(t.data)&&t.data&&this.tracker("OpenGame_2Plus"),bt(sv,!0)})}createTask(t){return je("sendServerEventAsync")?he("sendServerEventAsync",{payload:t}):I.platform==="android"?ne("/api/base/app-event",{method:"POST",data:t}):he("trackAppEventAsync",{url:this.taskUrl,body:JSON.stringify(t)})}}});var fv={};Gm(fv,{nativeTaskEmitter:()=>to,taskTracker:()=>Ft,track:()=>j,trackPerformance:()=>dv});var T1,cv,uv,j,dv,pv,to,Ft,Tt=x(()=>{"use strict";Gg();O();ku();Kg();J();lv();ue();T1=(e,t,r)=>{var c,d,u,p,f,h,g;let n=t,i=cn(n.extra)?n.extra:zi(n.extra)?JSON.parse(n.extra):{},{mpName:o,mpVersion:a}=(c=I.mpInfo)!=null?c:{},s=T(T(B(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}:{}),l=(h=n.eventType)!=null?h:V.Other;F("trackAsync",{event:(g=t.tag)!=null?g:e,data:s,webviewId:r,eventType:l})},{track:j,trackPerformance:dv}=Vg(T1,{type:gu.AppSDK,platform:"native",jssdk_version:(uv=(cv=I.sdkInfo)==null?void 0:cv.jssdkVersion)!=null?uv:"1.0.0",mp_id:I.mpId,mp_version:I.mpVersion}),pv=W();pv.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{dv(e,t,r)});pv.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{j(e,t)});to=new Kt,Ft=new ns(j,to)});function hv(){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] {
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.3.5-beta.2 clean
3
+ > @jolibox/implement@1.3.5-beta.3 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.3.5-beta.2 build:esm
7
+ > @jolibox/implement@1.3.5-beta.3 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.5-beta.2",
4
+ "version": "1.3.5-beta.3",
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.5-beta.2",
10
- "@jolibox/types": "1.3.5-beta.2",
11
- "@jolibox/native-bridge": "1.3.5-beta.2",
12
- "@jolibox/ads": "1.3.5-beta.2",
9
+ "@jolibox/common": "1.3.5-beta.3",
10
+ "@jolibox/types": "1.3.5-beta.3",
11
+ "@jolibox/native-bridge": "1.3.5-beta.3",
12
+ "@jolibox/ads": "1.3.5-beta.3",
13
13
  "localforage": "1.10.0",
14
- "@jolibox/ui": "1.3.5-beta.2",
14
+ "@jolibox/ui": "1.3.5-beta.3",
15
15
  "web-vitals": "4.2.4"
16
16
  },
17
17
  "devDependencies": {