@jolibox/implement 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var gT=Object.create;var Go=Object.defineProperty,vT=Object.defineProperties,yT=Object.getOwnPropertyDescriptor,_T=Object.getOwnPropertyDescriptors,bT=Object.getOwnPropertyNames,jo=Object.getOwnPropertySymbols,wT=Object.getPrototypeOf,Jl=Object.prototype.hasOwnProperty,dh=Object.prototype.propertyIsEnumerable;var uh=(e,t,r)=>t in e?Go(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,x=(e,t)=>{for(var r in t||(t={}))Jl.call(t,r)&&uh(e,r,t[r]);if(jo)for(var r of jo(t))dh.call(t,r)&&uh(e,r,t[r]);return e},F=(e,t)=>vT(e,_T(t));var Be=(e,t)=>{var r={};for(var n in e)Jl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&jo)for(var n of jo(e))t.indexOf(n)<0&&dh.call(e,n)&&(r[n]=e[n]);return r};var C=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ph=(e,t)=>{for(var r in t)Go(e,r,{get:t[r],enumerable:!0})},IT=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bT(t))!Jl.call(e,i)&&i!==r&&Go(e,i,{get:()=>t[i],enumerable:!(n=yT(t,i))||n.enumerable});return e};var ie=(e,t,r)=>(r=e!=null?gT(wT(e)):{},IT(t||!e||!e.__esModule?Go(r,"default",{value:e,enumerable:!0}):r,e));var _=(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 xT(e){return!!(e!=null&&e.__nativeBuffers__)}function Yl(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!xT(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=TT(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function RT(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:OT(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function LT(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function kh(e){return typeof e=="string"}function fn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function hh(e){return typeof e=="number"&&!isNaN(e)}function MT(e){return typeof e=="undefined"}function UT(e){return MT(e)||e===null}function Ch(e){return typeof e=="function"}function FT(e){return fn(e)&&Ch(e.then)}function Ah(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function ai(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function VT(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 QT(){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 rO(e){return new Promise(t=>xh(e)(t))}function xh(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function nO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new ci(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function oO(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)aO(e[n],t[n])}function aO(e,t){if(kh(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ch(t)){try{if(e instanceof t)return}catch(r){}if(!UT(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 oc(e,t){if(Xl.config[e]){Wo.warn(`[can i use] ${e} already registered`);return}Xl.config[e]=Yt({},t)}function vh(e,t){return`[${e}]:${t}`}function fO(e,t){yh||(Vl=new Jo({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Wl=new Jo({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),zl=new Jo({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Vl.flush(),Wl.flush(),zl.flush()}),yh=!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:m,invokeCallback:v}=f,y=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Vl.report({status:y,method:n(s,l),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-c}),c&&m&&v&&(Wl.report({status:y,method:s,isForeground:d,duration:Number((m-c).toFixed(3))}),zl.report({status:y,method:s,isForeground:d,duration:Number((Date.now()-v).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function vO(e,t){let r=0,n=!0,i=gO.resolveMap,o=fO(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Kl.forEach(l=>$o(this,[l],function*({method:c,args:d,resolve:u}){let p=yield s(c,d);u(p)})),Kl.length=0});let a=(l,c)=>{let d=i.get(Number(l));if(!d)return;let u=Yl(c);d(u),i.delete(Number(l))},s=(l,c)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new qT;if(i.set(r,m.resolve),!n&&cO.includes(l))return new Promise(A=>{Kl.push({method:l,args:c,resolve:A})});let v=CT(Yt({},{method:l,startTime:p,args:c,isForeground:f}),{invokeType:"js-bridge"}),y=!hO&&lO.includes(l),g=RT(c,y),w=y?g:JSON.stringify(g),S;if(l.endsWith("Sync")||uO.includes(l)?S=(d=e.call)==null?void 0:d.call(e,l,g,r):typeof w=="string"?S=e.invoke(l,w,r):S=(u=e.call)==null?void 0:u.call(e,l,w,r),S){try{typeof S=="string"&&(S=JSON.parse(S)),S=Yl(S)}catch(A){Wo.error(A)}return i.delete(r),S.errorCode&&(S.errorCode=vh(l,S.errorCode)),o(Yt(Yt({},v),S)),S}return l.endsWith("Sync")&&i.delete(r),m.promise.then(A=>(A.errorCode&&(A.errorCode=vh(l,A.errorCode)),o(Yt(Yt({},v),A)),A))};return{invokeNative:s,applyNative:(l,c)=>{let d=s(l,c);return FT(d)?d.then(u=>_h(l,u)):_h(l,d)},invokeHandler:a}}function _h(e,t){if(!fn(t)){Wo.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=AT(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new JT(n,i,o,a);return s}function yO(e){if(globalThis[Bo])return globalThis[Bo];let t=new tc,r=new tc,n=new Jo({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[Bo]={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=Yl(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===Oh){l.forEach(c=>{let[d,u]=c;try{r.emit(d.slice(li.length),u,a)}catch(p){}});return}if(i.startsWith(li)){r.emit(i.slice(li.length),l,a);return}t.emit(i,l,a)}},globalThis[Bo]}function _O(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(`${li}${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(Oh,d,p)}catch(p){}}),n=void 0,t.clear()}));let c=t.get(s);c||(c=[],t.set(s,c)),c.push([`${li}${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(dO,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}=yO(e),{invokeNative:a,invokeHandler:s,applyNative:l}=vO(e,r),{publish:c,emitNative:d}=_O(e);return{invokeHandler:s,subscribeHandler:t,applyNative:l,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:c,subscribe:i,unsubscribe:o}}function Rh(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var ET,ST,kT,Ho,wh,Ih,fh,Yt,CT,AT,$o,TT,OT,Eh,PT,NT,Sh,DT,qT,jT,GT,Vo,BT,JT,HT,Hl,Wo,mh,$T,Ql,WT,Xl,zT,KT,YT,pn,XT,V$,Zl,se,ZT,eO,si,ci,tc,rc,tO,$l,iO,W$,nc,gh,z$,Th,sO,li,lO,cO,uO,Oh,dO,pO,Jo,yh,Vl,Wl,zl,Kl,hO,ic,mO,gO,Bo,ac,mt,Ph,Nh,wO,Dh,bh,_e,j,rt,K$,IO,Lh,sc,Y$,Q$,be=C(()=>{"use strict";ET=Object.defineProperty,ST=Object.defineProperties,kT=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertySymbols,wh=Object.prototype.hasOwnProperty,Ih=Object.prototype.propertyIsEnumerable,fh=(e,t,r)=>t in e?ET(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yt=(e,t)=>{for(var r in t||(t={}))wh.call(t,r)&&fh(e,r,t[r]);if(Ho)for(var r of Ho(t))Ih.call(t,r)&&fh(e,r,t[r]);return e},CT=(e,t)=>ST(e,kT(t)),AT=(e,t)=>{var r={};for(var n in e)wh.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ho)for(var n of Ho(e))t.indexOf(n)<0&&Ih.call(e,n)&&(r[n]=e[n]);return r},$o=(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())});TT=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};OT=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)};Eh=Object.defineProperty,PT=Object.getOwnPropertyDescriptor,NT=(e,t)=>{for(var r in t)Eh(e,r,{get:t[r],enumerable:!0})},Sh=(e,t,r,n)=>{for(var i=n>1?void 0:n?PT(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&&Eh(t,r,i),i},DT=(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}qT=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))}})}};jT=(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))(jT||{}),GT=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}},Vo=class extends GT{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},BT=class extends Vo{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},JT=class extends Vo{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},HT=class extends Vo{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Hl=class extends Vo{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Wo={log:ai("log"),warn:ai("warn"),info:ai("info"),error:ai("error"),debug:ai("debug")};Object.assign(globalThis,{logger:Wo});mh=Symbol.for("Jolibox.canIUseMap"),$T={};globalThis[mh]||(globalThis[mh]=$T);Ql=Symbol.for("Jolibox.canIUseMap.native"),WT={};globalThis[Ql]||(globalThis[Ql]=WT);Xl={get config(){return globalThis[Ql]}},zT=(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))(zT||{}),KT=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(KT||{}),YT=(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))(YT||{});QT();pn=typeof window=="undefined",XT=()=>!pn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),V$={isiOS:!pn&&(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:!pn&&navigator.userAgent.includes("Android"),isMac:!pn&&navigator.userAgent.includes("Mac"),isFacebook:!pn&&navigator.userAgent.includes("FB_IAB"),isPC:!pn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Zl=class ec{constructor(t){this.element=t,this.next=ec.Undefined,this.prev=ec.Undefined}};Zl.Undefined=new Zl(void 0);se=Zl,ZT=class{constructor(){this._first=se.Undefined,this._last=se.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===se.Undefined}clear(){let e=this._first;for(;e!==se.Undefined;){let t=e.next;e.prev=se.Undefined,e.next=se.Undefined,e=t}this._first=se.Undefined,this._last=se.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new se(e);if(this._first===se.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!==se.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==se.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==se.Undefined&&e.next!==se.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===se.Undefined&&e.next===se.Undefined?(this._first=se.Undefined,this._last=se.Undefined):e.next===se.Undefined?(this._last=this._last.prev,this._last.next=se.Undefined):e.prev===se.Undefined&&(this._first=this._first.next,this._first.prev=se.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==se.Undefined;)yield e.element,e=e.next}},eO=0,si=class{constructor(e){this.value=e,this.id=eO++}},ci=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 si&&(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 si(t);return this._listeners?this._listeners instanceof si?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 si)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 m=this._listeners.indexOf(c);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof si?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},tc=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 ci,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 ZT,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)}},rc={};NT(rc,{None:()=>tO,filter:()=>nO,once:()=>xh,toPromise:()=>rO});tO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});$l=Symbol.for("Jolibox.hostEmitter"),iO=()=>{let e=new tc;return globalThis[$l]||(globalThis[$l]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[$l]},W$=iO();nc=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new ci,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 oO(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}};nc=Sh([Ah],nc);gh=class{constructor(){this._onWillExecuteCommand=new ci,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new ci,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new nc,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=LT(3e4)),this._starActivation}executeCommand(e,...t){return DT(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),rc.toPromise(rc.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}}};gh=Sh([Ah],gh);z$=Symbol.for("Jolibox.commands");oc("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});oc("requestProductDetailsAsync",{version:102e4});oc("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Th=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let l=Xl.config[a];if(!l)return!1;let c=(o=t==null?void 0:t())!=null?o:"";if(l.platforms&&!l.platforms.includes(c))return!1;let d=l.version;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=VT(i,o);if(!s)return!1;if(fn(s)){let l=s.version;return hh(l)?typeof a=="number"&&a>=l:!0}return hh(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};sO=()=>XT(),li="custom_event_",lO=[],cO=[],uO=["env","createRequestTask","login"],Oh="__batch_event__",dO="__native_batch_event__",pO=e=>e==="pv"?e:"default",Jo=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=pO(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&&fn(a))throw new Hl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let l=[];if(fn(a))l.push(...Object.keys(a));else if(kh(a)){if(i.length>0)throw new Hl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);l.push(a)}else throw new Hl(`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=fn(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={}}},yh=!1;Kl=[],hO=!1,ic=Symbol.for("Jolibox.invokeResolverInstance"),mO=new Map;globalThis[ic]||(globalThis[ic]=mO);gO={get resolveMap(){return globalThis[ic]}};Bo=Symbol.for("Jolibox.subscribeInstance");mt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){mt.trigger=e},onDoExit(e){mt.exit=e},onDoBackPress(e){mt.backPress=e}},Ph=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new BT("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="")=>{mt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>$o(void 0,null,function*(){let o=yield mt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});ac={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=Rh(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:Ph,doExit:r};globalThis.joliboxJSCore=Yt({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{mt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>$o(void 0,null,function*(){let a=yield mt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});ac={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let l=Rh(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 $o(this,null,function*(){let a=yield mt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:Ph,doExit:n};globalThis.joliboxJSCore=Yt({},i)}Nh=ac;if(!Nh&&sO())throw new HT("No joliboxJScore is found, native bridge not found.");wO=Yt({},Nh),Dh=bO(wO),{invokeHandler:bh}=Dh,{applyNative:_e,invokeNative:j,onNative:rt,offNative:K$,subscribeHandler:IO,publish:Lh,emitNative:sc,subscribe:Y$,unsubscribe:Q$}=Dh;globalThis.joliboxJSBridge={callHandler:bh,invokeHandler:bh,subscribeHandler:IO}});function AO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Bh(e){return new Promise(t=>setTimeout(t,e))}function hi(e){return typeof e=="string"}function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Jh(e){return typeof e=="object"&&Array.isArray(e)}function Hh(e){return typeof e=="number"&&!isNaN(e)}function Sr(e){return e===!0||e===!1}function $h(e){return typeof e=="undefined"}function mc(e){return $h(e)||e===null}function xO(e){return typeof e=="function"}function Vh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Wh(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:Uh(l)&&Uh(s)?i[a]=n(jh({},s),l):Array.isArray(l)&&Array.isArray(s)?i[a]=[...s,...l]:i[a]=l}return i}return n(e,t)}function Uh(e){return e&&typeof e=="object"&&e.constructor===Object}function zh(e,t){if(Array.isArray(e))return e.concat(t)}function mi(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 OO(e,t){return(...r)=>t(e,...r)}function Ko(e){return t=>OO(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Pt(`${i}`))}})}function ui(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function tm(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 wc(){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 qO(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com")return`${o}.${a}`}return`${o}.jolibox.com`}function Ic(e){return qO("app","stg-app",e)}function mn(e){return`https://${Ic(e)}`}function jO(e){return new Promise(t=>om(e)(t))}function om(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function GO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new fi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function JO(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)HO(e[n],t[n])}function HO(e,t){if(hi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(xO(t)){try{if(e instanceof t)return}catch(r){}if(!mc(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function $O(){return typeof globalThis!="undefined"?globalThis[am]:void 0}function VO(e){typeof globalThis!="undefined"&&(globalThis[am]=e)}function Y(e=!1){let t=$O();if(!e&&t)return t;let r=new zo,n=new fc,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 VO(i),i}var hc,EO,qh,SO,kO,Mh,jh,CO,Gh,Hr,Rt,TO,gc,gi,vc,Kh,Pt,Yh,Qh,Xh,Zh,em,yi,yc,Nt,cc,RO,_c,Fh,PO,J,bc,NO,hn,di,_i,DO,LO,rm,nm,im,Qt,uc,le,MO,UO,pi,fi,Dt,pc,FO,lc,BO,te,zo,fc,am,P=C(()=>{"use strict";hc=Object.defineProperty,EO=Object.getOwnPropertyDescriptor,qh=Object.getOwnPropertySymbols,SO=Object.prototype.hasOwnProperty,kO=Object.prototype.propertyIsEnumerable,Mh=(e,t,r)=>t in e?hc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jh=(e,t)=>{for(var r in t||(t={}))SO.call(t,r)&&Mh(e,r,t[r]);if(qh)for(var r of qh(t))kO.call(t,r)&&Mh(e,r,t[r]);return e},CO=(e,t)=>{for(var r in t)hc(e,r,{get:t[r],enumerable:!0})},Gh=(e,t,r,n)=>{for(var i=n>1?void 0:n?EO(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&&hc(t,r,i),i},Hr=(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}Rt=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))}})}};TO=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(TO||{}),gc=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}},gi=class extends gc{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},vc=class extends gc{constructor(){super(...arguments),this.kind="USER_ERROR"}},Kh=class extends vc{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Pt=class extends vc{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))}},Yh=class extends vc{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))}},Qh=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Xh=class extends gi{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))}},Zh=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},em=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},yi=class extends gc{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}}},yc=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Nt={log:ui("log"),warn:ui("warn"),info:ui("info"),error:ui("error"),debug:ui("debug")};Object.assign(globalThis,{logger:Nt});cc=Symbol.for("Jolibox.canIUseMap"),RO={};globalThis[cc]||(globalThis[cc]=RO);_c={get config(){return globalThis[cc]}},Fh=Symbol.for("Jolibox.canIUseMap.native"),PO={};globalThis[Fh]||(globalThis[Fh]=PO);J=(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))(J||{}),bc=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(bc||{}),NO=(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))(NO||{}),hn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});wc();di=typeof window=="undefined",_i={isiOS:!di&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!di&&navigator.userAgent.includes("Android"),isMac:!di&&navigator.userAgent.includes("Mac"),isFacebook:!di&&navigator.userAgent.includes("FB_IAB"),isPC:!di&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},DO="device_id",LO="advertising_id",rm=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,hn()),window.__joliboxLocalStorage__.getItem(e)),nm=()=>new URLSearchParams(window.location.search).get("deviceId")||rm(DO),im=()=>new URLSearchParams(window.location.search).get("advertisingId")||rm(LO);Qt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=jh({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return Hr(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=>Hr(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 Hr(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 Hr(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return Hr(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 Hr(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)}},uc=class dc{constructor(t){this.element=t,this.next=dc.Undefined,this.prev=dc.Undefined}};uc.Undefined=new uc(void 0);le=uc,MO=class{constructor(){this._first=le.Undefined,this._last=le.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===le.Undefined}clear(){let e=this._first;for(;e!==le.Undefined;){let t=e.next;e.prev=le.Undefined,e.next=le.Undefined,e=t}this._first=le.Undefined,this._last=le.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new le(e);if(this._first===le.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!==le.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==le.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==le.Undefined&&e.next!==le.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===le.Undefined&&e.next===le.Undefined?(this._first=le.Undefined,this._last=le.Undefined):e.next===le.Undefined?(this._last=this._last.prev,this._last.next=le.Undefined):e.prev===le.Undefined&&(this._first=this._first.next,this._first.prev=le.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==le.Undefined;)yield e.element,e=e.next}},UO=0,pi=class{constructor(e){this.value=e,this.id=UO++}},fi=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 pi&&(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 pi(t);return this._listeners?this._listeners instanceof pi?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 pi)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 m=this._listeners.indexOf(c);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof pi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Dt=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 fi,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 MO,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)}},pc={};CO(pc,{None:()=>FO,filter:()=>GO,once:()=>om,toPromise:()=>jO});FO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});lc=Symbol.for("Jolibox.hostEmitter"),BO=()=>{let e=new Dt;return globalThis[lc]||(globalThis[lc]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[lc]},te=BO();zo=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new fi,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 JO(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}};zo=Gh([Vh],zo);fc=class{constructor(){this._onWillExecuteCommand=new fi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new fi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new zo,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=AO(3e4)),this._starActivation}executeCommand(e,...t){return Hr(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),pc.toPromise(pc.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}}};fc=Gh([Vh],fc);am=Symbol.for("Jolibox.commands")});function Ae(e,t={}){Ec.emit("ERROR_REPORT",{error:e,options:t})}var Ec,Vr,gt=C(()=>{"use strict";P();P();Ec=new Dt,Vr=new Dt;Ae.debounce=mi(Ae,50,{leading:!0})});var Sc,WO,sm,lm,cm=C(()=>{"use strict";P();gt();Sc=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{}}},WO=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},sm=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:Sc(o),payloadJson:Sc(a),signature:Sc(s)}}else throw"joli_source is missing"}catch(r){return Ae(new Qh(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},lm=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=WO(e),o=r[2];return`${n}.${i}.${o}`}return t}});var zO,kc,um=C(()=>{"use strict";P();zO="1.2.6",kc=()=>zO});function Ac(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var KO,dm,Cc,pm,ce,YO,E,B=C(()=>{"use strict";P();cm();um();P();KO={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:nm(),adId:im(),pixelRatio:window.devicePixelRatio||1,platform:_i.isAndroid?"android":_i.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:kc()},schema:window.location.href,platform:_i.isAndroid?"android":_i.isiOS?"ios":"h5"},Cc=(dm=globalThis.joliboxJSCore)==null?void 0:dm.env,ce=Object.assign({},(pm=Cc==null?void 0:Cc())!=null?pm:KO);YO=()=>{var f,m,v,y,g,w,S,A,R,T,k;let{payloadJson:e,headerJson:t,signature:r}=ce.schema.length?sm(ce.schema):{},n=`${ce.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ce.schema.length?ce.schema:window.location.href).searchParams,a=(v=(m=(f=o.get("mpId"))!=null?f:o.get("appId"))!=null?m:o.get("gameId"))!=null?v:"",s=(w=(g=(y=ce.clientSessionId)!=null?y:e==null?void 0:e.sessionId)!=null?g:o.get("sessionId"))!=null?w:n,l=!!((A=(S=e==null?void 0:e.testAdsMode)!=null?S:e==null?void 0:e.__testAdsMode)!=null?A:o.get("testAdsMode")==="true"),c=(k=(T=(R=e==null?void 0:e.joliboxEnv)!=null?R:e==null?void 0:e.__joliboxEnv)!=null?T:o.get("joliboxEnv"))!=null?k:"production",d=c==="staging",u=t==null?void 0:t.channel,p=e==null?void 0:e.__shouldInterupt;return{get startTime(){var O;return(O=performance.timeOrigin)!=null?O:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var O;return(O=o.get("joliSource"))!=null?O:null},get mpId(){var O;return(O=a!=null?a:e==null?void 0:e.id)!=null?O:""},get mpVersion(){var O;return(O=t==null?void 0:t.ver)!=null?O:kc()},get mpType(){var O,G;return(G=(O=t==null?void 0:t.__mpType)!=null?O:e==null?void 0:e.__mpType)!=null?G:"game"},get platform(){var O;return((O=ce.platform)!=null?O:ce.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ce.deviceInfo},get sdkInfo(){return ce.sdkInfo},get hostInfo(){return ce.hostInfo},get hostUserInfo(){return ce.hostUserInfo},get sessionId(){var O,G;return(G=(O=ce.clientSessionId)!=null?O:s)!=null?G:n},get channel(){return u},get webviewId(){var O;return(O=ce.webviewId)!=null?O:-1},get shouldInterupt(){return p},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Ic(d)},get adId(){var O;return(O=ce.deviceInfo.adId)!=null?O:ce.deviceInfo.did},get language(){return ce.deviceInfo.lang},get sdkEnvironment(){return Ac("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Ac("gamedistribution","jolibox")?"gamedistribution":Ac("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var M,Pe,Ne;let O=(M=ce.deviceInfo.pixelRatio)!=null?M:1,G=(Pe=ce.deviceInfo.statusBarHeight)!=null?Pe:e==null?void 0:e.__androidStatusBarHeight,Ye=(Ne=ce.deviceInfo.navigationBarHeight)!=null?Ne:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:G!==void 0?G/O:20,navigationBarHeight:Ye!==void 0?Ye/O:10}},get abTests(){var O,G;return(G=(O=ce.abValues)==null?void 0:O.split(","))!=null?G:[]},get mpInfo(){var O;return(O=ce.mpInfo)!=null?O:{mpName:"unknown"}},onEnvConfigChanged:O=>{Wh(ce,O,zh)},encodeJoliSourceQuery:O=>{var G,Ye;return t&&r?lm(x(x({},e),O),(G=o.get("joliSource"))!=null?G:""):(Ye=o.get("joliSource"))!=null?Ye:""},setDoExitDirectly:()=>{p=!1}}},E=YO()});var xc,hm,QO,XO,fm,ZO,mm=C(()=>{"use strict";P();gt();B();P();xc=!1,hm=(e,t)=>e==null?!1:t in e,QO=e=>hm(e,"kind"),XO=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},fm=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=E.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=E.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:XO(e.name)},i=F(x({},n),{env:t.environment,isFromUser:r});r?Vr.emit("GLOBAL_USER_ERROR",e,i):Vr.emit("GLOBAL_ERROR",e,i)},ZO=e=>hm(e,"kind")&&e.kind==="USER_ERROR";Ec.on("ERROR_REPORT",({error:e,options:t})=>{if(xc)return;xc=!0;let r=QO(e)&&e.raw?e.raw:e;try{let n=ZO(e);fm(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new yc(`${i}, origin error: ${r.message}`);Nt.error(o),fm(new yc(o.message),{environment:t.environment},!1)}finally{xc=!1}})});var Lt,Tc,Wr=C(()=>{"use strict";gt();P();gt();Lt=(e,t)=>{var r,n;return new yi((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Tc=e=>new Kh(e)});var gm=C(()=>{"use strict";mm();Wr();P();be();Vr.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};j("trackAsync",{event:"reportJsError",data:r})});Vr.on("GLOBAL_USER_ERROR",(e,t)=>{Nt.log("UserError",e,t)})});var Oc=C(()=>{"use strict"});function vm(e,t){let r=(n,i,o)=>{let c=i!=null?i:{},{eventType:a}=c,s=Be(c,["eventType"]),l=F(x({tag:n,eventType:o!=null?o:a!=null?a:J.Other},t),{extra:x({},s)});n=="globalJsError"?Ae(new em(JSON.stringify(l))):e("systemLog",l,E.webviewId)};return r.debounce=mi(r,500,{leading:!0}),r}function ym(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=mi(t,500,{leading:!0}),t}var _m=C(()=>{"use strict";P();P();gt();B()});function bm(e,t){let r=vm(e,t),n=ym(r);return{track:r,trackPerformance:n}}var wm=C(()=>{"use strict";_m()});var Im=C(()=>{"use strict";B();P();P()});var Em=C(()=>{"use strict";wm();Oc();Im()});var Yo,Sm=C(()=>{"use strict";Yo=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},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 Qo(e,t,r){var l,c,d;let n=new Map,i=(l=r==null?void 0:r.baseUrl)!=null?l:mn(E.testMode),o=(c=r==null?void 0:r.type)!=null?c:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return rt("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:v,state:y}=f,g=Be(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(g):p.reject(g),n.delete(v)}else if(u.state==="fail"){let m=u,{requestTaskId:v,state:y}=m,g=Be(m,["requestTaskId","state"]);p.reject(g),n.delete(v)}else Nt.warn("onRequestTaskStateChange unknown event",u)}),te.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>_(this,[f,...m],function*(u,p={}){let v=Date.now(),y=eR(u,F(x({},p),{baseUrl:i})),{method:g="GET",responseType:w="text",dataType:S="json",timeout:A,enableCache:R=!1,appendHostCookie:T=!0}=p,k=Object.assign({"content-type":"application/json"},a,p.header),O={url:y,method:g,header:k,enableCache:R,responseType:w,appendHostCookie:T};if(g=="POST"||g=="PUT"){let Ne=rR(p.data,k["content-type"]);O.data=Ne}A&&Object.assign(O,{timeout:A});let{data:{requestTaskId:G}}=j(e,O);if(typeof G!="string")throw Lt({code:-1,msg:"requestTaskId is not a string"});let{resolve:Ye,reject:M,promise:Pe}=new Rt;n.set(G,{resolve:Ye,reject:M});try{let Ne=yield Pe,{data:Jr}=Ne;return S==="json"&&typeof Jr=="string"&&(Jr=tR(Jr)),{url:y,timeout:A,method:g,response:F(x({},Ne),{data:Jr})}}catch(Ne){let Jr=Ne;if($r(Jr)){let{errMsg:Bl,prefetchDetail:J$,isPrefetch:H$,errNo:mT}=Jr;hi(Bl)&&Ae(Lt({code:-1,msg:Bl},{errNo:mT,errMsg:Bl}))}throw Ne}})}function tR(e){try{return JSON.parse(e.trim())}catch(t){return e}}function rR(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 eR,Rc=C(()=>{"use strict";P();be();gt();Wr();B();eR=(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 Pc,km,re,vt=C(()=>{"use strict";Rc();B();P();Pc={};(km=E.hostUserInfo)!=null&&km.token&&(Pc["x-joli-token"]=E.hostUserInfo.token);E.joliSource&&(Pc["x-joli-source"]=E.joliSource);re=Qo("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:mn(E.testMode),defaultHeaders:Pc})});function Cm(e){let t=_c.config[e];return t||(t={},_c.config[e]=t),(r,n)=>{if(t[r]){Nt.warn(`[can i use] ${r} already registered`);return}t[r]=x({},n)}}var Am=C(()=>{"use strict";P()});function Nc(e){xm=e}function Xo(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Xo(t)):Object.keys(e).reduce((t,r)=>(t[r]=Xo(e[r]),t),{})}function Xt(e){return typeof e=="number"}function Dc(e){let t=Lc(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Lc(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var xm,we,Zo,ea,ta,ra,gn,na,ia,oa,aa,sa,la,ca,ua,da,pa,fa,ha,qc=C(()=>{"use strict";xm=!1;we=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(xm)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 ${Dc(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Xo(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Xo(this._default)}optional(){return this._optional=!0,this}};Zo=class extends we{validate(t){return this._optional&&t===void 0?!0:Xt(t)?Xt(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):Xt(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):Xt(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},ea=class extends we{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ta=class extends we{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(Xt(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(Xt(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}},ra=class extends we{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},gn=class extends we{validate(t){return!0}},na=class extends we{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},ia=class extends we{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},oa=class extends we{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},aa=class extends we{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 ${Dc(t)}`)}return!0}},sa=class extends we{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(Xt(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(Xt(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(Xt(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}},la=class extends we{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Lc(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}},ca=class extends we{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Lc(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}},ua=class extends we{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Dc(this.value),actual:r}):!0}},da=class extends we{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 gT=Object.create;var Go=Object.defineProperty,vT=Object.defineProperties,yT=Object.getOwnPropertyDescriptor,_T=Object.getOwnPropertyDescriptors,bT=Object.getOwnPropertyNames,jo=Object.getOwnPropertySymbols,wT=Object.getPrototypeOf,Jl=Object.prototype.hasOwnProperty,dh=Object.prototype.propertyIsEnumerable;var uh=(e,t,r)=>t in e?Go(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,x=(e,t)=>{for(var r in t||(t={}))Jl.call(t,r)&&uh(e,r,t[r]);if(jo)for(var r of jo(t))dh.call(t,r)&&uh(e,r,t[r]);return e},F=(e,t)=>vT(e,_T(t));var Be=(e,t)=>{var r={};for(var n in e)Jl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&jo)for(var n of jo(e))t.indexOf(n)<0&&dh.call(e,n)&&(r[n]=e[n]);return r};var C=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ph=(e,t)=>{for(var r in t)Go(e,r,{get:t[r],enumerable:!0})},IT=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bT(t))!Jl.call(e,i)&&i!==r&&Go(e,i,{get:()=>t[i],enumerable:!(n=yT(t,i))||n.enumerable});return e};var ie=(e,t,r)=>(r=e!=null?gT(wT(e)):{},IT(t||!e||!e.__esModule?Go(r,"default",{value:e,enumerable:!0}):r,e));var _=(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 xT(e){return!!(e!=null&&e.__nativeBuffers__)}function Yl(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!xT(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=TT(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function RT(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:OT(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function LT(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function kh(e){return typeof e=="string"}function fn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function hh(e){return typeof e=="number"&&!isNaN(e)}function MT(e){return typeof e=="undefined"}function UT(e){return MT(e)||e===null}function Ch(e){return typeof e=="function"}function FT(e){return fn(e)&&Ch(e.then)}function Ah(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function ai(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function VT(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 QT(){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 rO(e){return new Promise(t=>xh(e)(t))}function xh(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function nO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new ci(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function oO(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)aO(e[n],t[n])}function aO(e,t){if(kh(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ch(t)){try{if(e instanceof t)return}catch(r){}if(!UT(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 oc(e,t){if(Xl.config[e]){Wo.warn(`[can i use] ${e} already registered`);return}Xl.config[e]=Yt({},t)}function vh(e,t){return`[${e}]:${t}`}function fO(e,t){yh||(Vl=new Jo({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Wl=new Jo({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),zl=new Jo({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Vl.flush(),Wl.flush(),zl.flush()}),yh=!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:m,invokeCallback:v}=f,y=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Vl.report({status:y,method:n(s,l),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-c}),c&&m&&v&&(Wl.report({status:y,method:s,isForeground:d,duration:Number((m-c).toFixed(3))}),zl.report({status:y,method:s,isForeground:d,duration:Number((Date.now()-v).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function vO(e,t){let r=0,n=!0,i=gO.resolveMap,o=fO(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Kl.forEach(l=>$o(this,[l],function*({method:c,args:d,resolve:u}){let p=yield s(c,d);u(p)})),Kl.length=0});let a=(l,c)=>{let d=i.get(Number(l));if(!d)return;let u=Yl(c);d(u),i.delete(Number(l))},s=(l,c)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new qT;if(i.set(r,m.resolve),!n&&cO.includes(l))return new Promise(A=>{Kl.push({method:l,args:c,resolve:A})});let v=CT(Yt({},{method:l,startTime:p,args:c,isForeground:f}),{invokeType:"js-bridge"}),y=!hO&&lO.includes(l),g=RT(c,y),w=y?g:JSON.stringify(g),S;if(l.endsWith("Sync")||uO.includes(l)?S=(d=e.call)==null?void 0:d.call(e,l,g,r):typeof w=="string"?S=e.invoke(l,w,r):S=(u=e.call)==null?void 0:u.call(e,l,w,r),S){try{typeof S=="string"&&(S=JSON.parse(S)),S=Yl(S)}catch(A){Wo.error(A)}return i.delete(r),S.errorCode&&(S.errorCode=vh(l,S.errorCode)),o(Yt(Yt({},v),S)),S}return l.endsWith("Sync")&&i.delete(r),m.promise.then(A=>(A.errorCode&&(A.errorCode=vh(l,A.errorCode)),o(Yt(Yt({},v),A)),A))};return{invokeNative:s,applyNative:(l,c)=>{let d=s(l,c);return FT(d)?d.then(u=>_h(l,u)):_h(l,d)},invokeHandler:a}}function _h(e,t){if(!fn(t)){Wo.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=AT(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new JT(n,i,o,a);return s}function yO(e){if(globalThis[Bo])return globalThis[Bo];let t=new tc,r=new tc,n=new Jo({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[Bo]={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=Yl(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===Oh){l.forEach(c=>{let[d,u]=c;try{r.emit(d.slice(li.length),u,a)}catch(p){}});return}if(i.startsWith(li)){r.emit(i.slice(li.length),l,a);return}t.emit(i,l,a)}},globalThis[Bo]}function _O(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(`${li}${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(Oh,d,p)}catch(p){}}),n=void 0,t.clear()}));let c=t.get(s);c||(c=[],t.set(s,c)),c.push([`${li}${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(dO,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}=yO(e),{invokeNative:a,invokeHandler:s,applyNative:l}=vO(e,r),{publish:c,emitNative:d}=_O(e);return{invokeHandler:s,subscribeHandler:t,applyNative:l,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:c,subscribe:i,unsubscribe:o}}function Rh(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var ET,ST,kT,Ho,wh,Ih,fh,Yt,CT,AT,$o,TT,OT,Eh,PT,NT,Sh,DT,qT,jT,GT,Vo,BT,JT,HT,Hl,Wo,mh,$T,Ql,WT,Xl,zT,KT,YT,pn,XT,V$,Zl,se,ZT,eO,si,ci,tc,rc,tO,$l,iO,W$,nc,gh,z$,Th,sO,li,lO,cO,uO,Oh,dO,pO,Jo,yh,Vl,Wl,zl,Kl,hO,ic,mO,gO,Bo,ac,mt,Ph,Nh,wO,Dh,bh,_e,j,rt,K$,IO,Lh,sc,Y$,Q$,be=C(()=>{"use strict";ET=Object.defineProperty,ST=Object.defineProperties,kT=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertySymbols,wh=Object.prototype.hasOwnProperty,Ih=Object.prototype.propertyIsEnumerable,fh=(e,t,r)=>t in e?ET(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yt=(e,t)=>{for(var r in t||(t={}))wh.call(t,r)&&fh(e,r,t[r]);if(Ho)for(var r of Ho(t))Ih.call(t,r)&&fh(e,r,t[r]);return e},CT=(e,t)=>ST(e,kT(t)),AT=(e,t)=>{var r={};for(var n in e)wh.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ho)for(var n of Ho(e))t.indexOf(n)<0&&Ih.call(e,n)&&(r[n]=e[n]);return r},$o=(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())});TT=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};OT=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)};Eh=Object.defineProperty,PT=Object.getOwnPropertyDescriptor,NT=(e,t)=>{for(var r in t)Eh(e,r,{get:t[r],enumerable:!0})},Sh=(e,t,r,n)=>{for(var i=n>1?void 0:n?PT(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&&Eh(t,r,i),i},DT=(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}qT=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))}})}};jT=(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))(jT||{}),GT=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}},Vo=class extends GT{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},BT=class extends Vo{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},JT=class extends Vo{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},HT=class extends Vo{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Hl=class extends Vo{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Wo={log:ai("log"),warn:ai("warn"),info:ai("info"),error:ai("error"),debug:ai("debug")};Object.assign(globalThis,{logger:Wo});mh=Symbol.for("Jolibox.canIUseMap"),$T={};globalThis[mh]||(globalThis[mh]=$T);Ql=Symbol.for("Jolibox.canIUseMap.native"),WT={};globalThis[Ql]||(globalThis[Ql]=WT);Xl={get config(){return globalThis[Ql]}},zT=(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))(zT||{}),KT=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(KT||{}),YT=(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))(YT||{});QT();pn=typeof window=="undefined",XT=()=>!pn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),V$={isiOS:!pn&&(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:!pn&&navigator.userAgent.includes("Android"),isMac:!pn&&navigator.userAgent.includes("Mac"),isFacebook:!pn&&navigator.userAgent.includes("FB_IAB"),isPC:!pn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Zl=class ec{constructor(t){this.element=t,this.next=ec.Undefined,this.prev=ec.Undefined}};Zl.Undefined=new Zl(void 0);se=Zl,ZT=class{constructor(){this._first=se.Undefined,this._last=se.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===se.Undefined}clear(){let e=this._first;for(;e!==se.Undefined;){let t=e.next;e.prev=se.Undefined,e.next=se.Undefined,e=t}this._first=se.Undefined,this._last=se.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new se(e);if(this._first===se.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!==se.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==se.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==se.Undefined&&e.next!==se.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===se.Undefined&&e.next===se.Undefined?(this._first=se.Undefined,this._last=se.Undefined):e.next===se.Undefined?(this._last=this._last.prev,this._last.next=se.Undefined):e.prev===se.Undefined&&(this._first=this._first.next,this._first.prev=se.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==se.Undefined;)yield e.element,e=e.next}},eO=0,si=class{constructor(e){this.value=e,this.id=eO++}},ci=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 si&&(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 si(t);return this._listeners?this._listeners instanceof si?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 si)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 m=this._listeners.indexOf(c);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof si?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},tc=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 ci,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 ZT,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)}},rc={};NT(rc,{None:()=>tO,filter:()=>nO,once:()=>xh,toPromise:()=>rO});tO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});$l=Symbol.for("Jolibox.hostEmitter"),iO=()=>{let e=new tc;return globalThis[$l]||(globalThis[$l]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[$l]},W$=iO();nc=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new ci,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 oO(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}};nc=Sh([Ah],nc);gh=class{constructor(){this._onWillExecuteCommand=new ci,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new ci,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new nc,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=LT(3e4)),this._starActivation}executeCommand(e,...t){return DT(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),rc.toPromise(rc.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}}};gh=Sh([Ah],gh);z$=Symbol.for("Jolibox.commands");oc("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});oc("requestProductDetailsAsync",{version:102e4});oc("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Th=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let l=Xl.config[a];if(!l)return!1;let c=(o=t==null?void 0:t())!=null?o:"";if(l.platforms&&!l.platforms.includes(c))return!1;let d=l.version;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=VT(i,o);if(!s)return!1;if(fn(s)){let l=s.version;return hh(l)?typeof a=="number"&&a>=l:!0}return hh(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};sO=()=>XT(),li="custom_event_",lO=[],cO=[],uO=["env","createRequestTask","login"],Oh="__batch_event__",dO="__native_batch_event__",pO=e=>e==="pv"?e:"default",Jo=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=pO(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&&fn(a))throw new Hl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let l=[];if(fn(a))l.push(...Object.keys(a));else if(kh(a)){if(i.length>0)throw new Hl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);l.push(a)}else throw new Hl(`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=fn(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={}}},yh=!1;Kl=[],hO=!1,ic=Symbol.for("Jolibox.invokeResolverInstance"),mO=new Map;globalThis[ic]||(globalThis[ic]=mO);gO={get resolveMap(){return globalThis[ic]}};Bo=Symbol.for("Jolibox.subscribeInstance");mt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){mt.trigger=e},onDoExit(e){mt.exit=e},onDoBackPress(e){mt.backPress=e}},Ph=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new BT("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="")=>{mt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>$o(void 0,null,function*(){let o=yield mt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});ac={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=Rh(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:Ph,doExit:r};globalThis.joliboxJSCore=Yt({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{mt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>$o(void 0,null,function*(){let a=yield mt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});ac={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let l=Rh(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 $o(this,null,function*(){let a=yield mt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:Ph,doExit:n};globalThis.joliboxJSCore=Yt({},i)}Nh=ac;if(!Nh&&sO())throw new HT("No joliboxJScore is found, native bridge not found.");wO=Yt({},Nh),Dh=bO(wO),{invokeHandler:bh}=Dh,{applyNative:_e,invokeNative:j,onNative:rt,offNative:K$,subscribeHandler:IO,publish:Lh,emitNative:sc,subscribe:Y$,unsubscribe:Q$}=Dh;globalThis.joliboxJSBridge={callHandler:bh,invokeHandler:bh,subscribeHandler:IO}});function AO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Bh(e){return new Promise(t=>setTimeout(t,e))}function hi(e){return typeof e=="string"}function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Jh(e){return typeof e=="object"&&Array.isArray(e)}function Hh(e){return typeof e=="number"&&!isNaN(e)}function Sr(e){return e===!0||e===!1}function $h(e){return typeof e=="undefined"}function mc(e){return $h(e)||e===null}function xO(e){return typeof e=="function"}function Vh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Wh(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:Uh(l)&&Uh(s)?i[a]=n(jh({},s),l):Array.isArray(l)&&Array.isArray(s)?i[a]=[...s,...l]:i[a]=l}return i}return n(e,t)}function Uh(e){return e&&typeof e=="object"&&e.constructor===Object}function zh(e,t){if(Array.isArray(e))return e.concat(t)}function mi(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 OO(e,t){return(...r)=>t(e,...r)}function Ko(e){return t=>OO(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Pt(`${i}`))}})}function ui(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function tm(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 wc(){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 qO(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com")return`${o}.${a}`}return`${o}.jolibox.com`}function Ic(e){return qO("app","stg-app",e)}function mn(e){return`https://${Ic(e)}`}function jO(e){return new Promise(t=>om(e)(t))}function om(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function GO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new fi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function JO(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)HO(e[n],t[n])}function HO(e,t){if(hi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(xO(t)){try{if(e instanceof t)return}catch(r){}if(!mc(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function $O(){return typeof globalThis!="undefined"?globalThis[am]:void 0}function VO(e){typeof globalThis!="undefined"&&(globalThis[am]=e)}function Y(e=!1){let t=$O();if(!e&&t)return t;let r=new zo,n=new fc,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 VO(i),i}var hc,EO,qh,SO,kO,Mh,jh,CO,Gh,Hr,Rt,TO,gc,gi,vc,Kh,Pt,Yh,Qh,Xh,Zh,em,yi,yc,Nt,cc,RO,_c,Fh,PO,J,bc,NO,hn,di,_i,DO,LO,rm,nm,im,Qt,uc,le,MO,UO,pi,fi,Dt,pc,FO,lc,BO,te,zo,fc,am,P=C(()=>{"use strict";hc=Object.defineProperty,EO=Object.getOwnPropertyDescriptor,qh=Object.getOwnPropertySymbols,SO=Object.prototype.hasOwnProperty,kO=Object.prototype.propertyIsEnumerable,Mh=(e,t,r)=>t in e?hc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jh=(e,t)=>{for(var r in t||(t={}))SO.call(t,r)&&Mh(e,r,t[r]);if(qh)for(var r of qh(t))kO.call(t,r)&&Mh(e,r,t[r]);return e},CO=(e,t)=>{for(var r in t)hc(e,r,{get:t[r],enumerable:!0})},Gh=(e,t,r,n)=>{for(var i=n>1?void 0:n?EO(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&&hc(t,r,i),i},Hr=(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}Rt=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))}})}};TO=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(TO||{}),gc=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}},gi=class extends gc{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},vc=class extends gc{constructor(){super(...arguments),this.kind="USER_ERROR"}},Kh=class extends vc{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Pt=class extends vc{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))}},Yh=class extends vc{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))}},Qh=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Xh=class extends gi{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))}},Zh=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},em=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},yi=class extends gc{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}}},yc=class extends gi{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Nt={log:ui("log"),warn:ui("warn"),info:ui("info"),error:ui("error"),debug:ui("debug")};Object.assign(globalThis,{logger:Nt});cc=Symbol.for("Jolibox.canIUseMap"),RO={};globalThis[cc]||(globalThis[cc]=RO);_c={get config(){return globalThis[cc]}},Fh=Symbol.for("Jolibox.canIUseMap.native"),PO={};globalThis[Fh]||(globalThis[Fh]=PO);J=(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))(J||{}),bc=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(bc||{}),NO=(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))(NO||{}),hn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});wc();di=typeof window=="undefined",_i={isiOS:!di&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!di&&navigator.userAgent.includes("Android"),isMac:!di&&navigator.userAgent.includes("Mac"),isFacebook:!di&&navigator.userAgent.includes("FB_IAB"),isPC:!di&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},DO="device_id",LO="advertising_id",rm=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,hn()),window.__joliboxLocalStorage__.getItem(e)),nm=()=>new URLSearchParams(window.location.search).get("deviceId")||rm(DO),im=()=>new URLSearchParams(window.location.search).get("advertisingId")||rm(LO);Qt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=jh({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return Hr(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=>Hr(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 Hr(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 Hr(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return Hr(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 Hr(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)}},uc=class dc{constructor(t){this.element=t,this.next=dc.Undefined,this.prev=dc.Undefined}};uc.Undefined=new uc(void 0);le=uc,MO=class{constructor(){this._first=le.Undefined,this._last=le.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===le.Undefined}clear(){let e=this._first;for(;e!==le.Undefined;){let t=e.next;e.prev=le.Undefined,e.next=le.Undefined,e=t}this._first=le.Undefined,this._last=le.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new le(e);if(this._first===le.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!==le.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==le.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==le.Undefined&&e.next!==le.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===le.Undefined&&e.next===le.Undefined?(this._first=le.Undefined,this._last=le.Undefined):e.next===le.Undefined?(this._last=this._last.prev,this._last.next=le.Undefined):e.prev===le.Undefined&&(this._first=this._first.next,this._first.prev=le.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==le.Undefined;)yield e.element,e=e.next}},UO=0,pi=class{constructor(e){this.value=e,this.id=UO++}},fi=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 pi&&(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 pi(t);return this._listeners?this._listeners instanceof pi?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 pi)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 m=this._listeners.indexOf(c);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof pi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Dt=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 fi,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 MO,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)}},pc={};CO(pc,{None:()=>FO,filter:()=>GO,once:()=>om,toPromise:()=>jO});FO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});lc=Symbol.for("Jolibox.hostEmitter"),BO=()=>{let e=new Dt;return globalThis[lc]||(globalThis[lc]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[lc]},te=BO();zo=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new fi,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 JO(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}};zo=Gh([Vh],zo);fc=class{constructor(){this._onWillExecuteCommand=new fi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new fi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new zo,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=AO(3e4)),this._starActivation}executeCommand(e,...t){return Hr(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),pc.toPromise(pc.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}}};fc=Gh([Vh],fc);am=Symbol.for("Jolibox.commands")});function Ae(e,t={}){Ec.emit("ERROR_REPORT",{error:e,options:t})}var Ec,Vr,gt=C(()=>{"use strict";P();P();Ec=new Dt,Vr=new Dt;Ae.debounce=mi(Ae,50,{leading:!0})});var Sc,WO,sm,lm,cm=C(()=>{"use strict";P();gt();Sc=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{}}},WO=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},sm=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:Sc(o),payloadJson:Sc(a),signature:Sc(s)}}else throw"joli_source is missing"}catch(r){return Ae(new Qh(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},lm=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=WO(e),o=r[2];return`${n}.${i}.${o}`}return t}});var zO,kc,um=C(()=>{"use strict";P();zO="1.2.7",kc=()=>zO});function Ac(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var KO,dm,Cc,pm,ce,YO,E,B=C(()=>{"use strict";P();cm();um();P();KO={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:nm(),adId:im(),pixelRatio:window.devicePixelRatio||1,platform:_i.isAndroid?"android":_i.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:kc()},schema:window.location.href,platform:_i.isAndroid?"android":_i.isiOS?"ios":"h5"},Cc=(dm=globalThis.joliboxJSCore)==null?void 0:dm.env,ce=Object.assign({},(pm=Cc==null?void 0:Cc())!=null?pm:KO);YO=()=>{var f,m,v,y,g,w,S,A,R,T,k;let{payloadJson:e,headerJson:t,signature:r}=ce.schema.length?sm(ce.schema):{},n=`${ce.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ce.schema.length?ce.schema:window.location.href).searchParams,a=(v=(m=(f=o.get("mpId"))!=null?f:o.get("appId"))!=null?m:o.get("gameId"))!=null?v:"",s=(w=(g=(y=ce.clientSessionId)!=null?y:e==null?void 0:e.sessionId)!=null?g:o.get("sessionId"))!=null?w:n,l=!!((A=(S=e==null?void 0:e.testAdsMode)!=null?S:e==null?void 0:e.__testAdsMode)!=null?A:o.get("testAdsMode")==="true"),c=(k=(T=(R=e==null?void 0:e.joliboxEnv)!=null?R:e==null?void 0:e.__joliboxEnv)!=null?T:o.get("joliboxEnv"))!=null?k:"production",d=c==="staging",u=t==null?void 0:t.channel,p=e==null?void 0:e.__shouldInterupt;return{get startTime(){var O;return(O=performance.timeOrigin)!=null?O:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var O;return(O=o.get("joliSource"))!=null?O:null},get mpId(){var O;return(O=a!=null?a:e==null?void 0:e.id)!=null?O:""},get mpVersion(){var O;return(O=t==null?void 0:t.ver)!=null?O:kc()},get mpType(){var O,G;return(G=(O=t==null?void 0:t.__mpType)!=null?O:e==null?void 0:e.__mpType)!=null?G:"game"},get platform(){var O;return((O=ce.platform)!=null?O:ce.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ce.deviceInfo},get sdkInfo(){return ce.sdkInfo},get hostInfo(){return ce.hostInfo},get hostUserInfo(){return ce.hostUserInfo},get sessionId(){var O,G;return(G=(O=ce.clientSessionId)!=null?O:s)!=null?G:n},get channel(){return u},get webviewId(){var O;return(O=ce.webviewId)!=null?O:-1},get shouldInterupt(){return p},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Ic(d)},get adId(){var O;return(O=ce.deviceInfo.adId)!=null?O:ce.deviceInfo.did},get language(){return ce.deviceInfo.lang},get sdkEnvironment(){return Ac("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Ac("gamedistribution","jolibox")?"gamedistribution":Ac("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var M,Pe,Ne;let O=(M=ce.deviceInfo.pixelRatio)!=null?M:1,G=(Pe=ce.deviceInfo.statusBarHeight)!=null?Pe:e==null?void 0:e.__androidStatusBarHeight,Ye=(Ne=ce.deviceInfo.navigationBarHeight)!=null?Ne:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:G!==void 0?G/O:20,navigationBarHeight:Ye!==void 0?Ye/O:10}},get abTests(){var O,G;return(G=(O=ce.abValues)==null?void 0:O.split(","))!=null?G:[]},get mpInfo(){var O;return(O=ce.mpInfo)!=null?O:{mpName:"unknown"}},onEnvConfigChanged:O=>{Wh(ce,O,zh)},encodeJoliSourceQuery:O=>{var G,Ye;return t&&r?lm(x(x({},e),O),(G=o.get("joliSource"))!=null?G:""):(Ye=o.get("joliSource"))!=null?Ye:""},setDoExitDirectly:()=>{p=!1}}},E=YO()});var xc,hm,QO,XO,fm,ZO,mm=C(()=>{"use strict";P();gt();B();P();xc=!1,hm=(e,t)=>e==null?!1:t in e,QO=e=>hm(e,"kind"),XO=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},fm=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=E.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=E.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:XO(e.name)},i=F(x({},n),{env:t.environment,isFromUser:r});r?Vr.emit("GLOBAL_USER_ERROR",e,i):Vr.emit("GLOBAL_ERROR",e,i)},ZO=e=>hm(e,"kind")&&e.kind==="USER_ERROR";Ec.on("ERROR_REPORT",({error:e,options:t})=>{if(xc)return;xc=!0;let r=QO(e)&&e.raw?e.raw:e;try{let n=ZO(e);fm(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new yc(`${i}, origin error: ${r.message}`);Nt.error(o),fm(new yc(o.message),{environment:t.environment},!1)}finally{xc=!1}})});var Lt,Tc,Wr=C(()=>{"use strict";gt();P();gt();Lt=(e,t)=>{var r,n;return new yi((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Tc=e=>new Kh(e)});var gm=C(()=>{"use strict";mm();Wr();P();be();Vr.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};j("trackAsync",{event:"reportJsError",data:r})});Vr.on("GLOBAL_USER_ERROR",(e,t)=>{Nt.log("UserError",e,t)})});var Oc=C(()=>{"use strict"});function vm(e,t){let r=(n,i,o)=>{let c=i!=null?i:{},{eventType:a}=c,s=Be(c,["eventType"]),l=F(x({tag:n,eventType:o!=null?o:a!=null?a:J.Other},t),{extra:x({},s)});n=="globalJsError"?Ae(new em(JSON.stringify(l))):e("systemLog",l,E.webviewId)};return r.debounce=mi(r,500,{leading:!0}),r}function ym(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=mi(t,500,{leading:!0}),t}var _m=C(()=>{"use strict";P();P();gt();B()});function bm(e,t){let r=vm(e,t),n=ym(r);return{track:r,trackPerformance:n}}var wm=C(()=>{"use strict";_m()});var Im=C(()=>{"use strict";B();P();P()});var Em=C(()=>{"use strict";wm();Oc();Im()});var Yo,Sm=C(()=>{"use strict";Yo=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},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 Qo(e,t,r){var l,c,d;let n=new Map,i=(l=r==null?void 0:r.baseUrl)!=null?l:mn(E.testMode),o=(c=r==null?void 0:r.type)!=null?c:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return rt("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:v,state:y}=f,g=Be(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(g):p.reject(g),n.delete(v)}else if(u.state==="fail"){let m=u,{requestTaskId:v,state:y}=m,g=Be(m,["requestTaskId","state"]);p.reject(g),n.delete(v)}else Nt.warn("onRequestTaskStateChange unknown event",u)}),te.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>_(this,[f,...m],function*(u,p={}){let v=Date.now(),y=eR(u,F(x({},p),{baseUrl:i})),{method:g="GET",responseType:w="text",dataType:S="json",timeout:A,enableCache:R=!1,appendHostCookie:T=!0}=p,k=Object.assign({"content-type":"application/json"},a,p.header),O={url:y,method:g,header:k,enableCache:R,responseType:w,appendHostCookie:T};if(g=="POST"||g=="PUT"){let Ne=rR(p.data,k["content-type"]);O.data=Ne}A&&Object.assign(O,{timeout:A});let{data:{requestTaskId:G}}=j(e,O);if(typeof G!="string")throw Lt({code:-1,msg:"requestTaskId is not a string"});let{resolve:Ye,reject:M,promise:Pe}=new Rt;n.set(G,{resolve:Ye,reject:M});try{let Ne=yield Pe,{data:Jr}=Ne;return S==="json"&&typeof Jr=="string"&&(Jr=tR(Jr)),{url:y,timeout:A,method:g,response:F(x({},Ne),{data:Jr})}}catch(Ne){let Jr=Ne;if($r(Jr)){let{errMsg:Bl,prefetchDetail:J$,isPrefetch:H$,errNo:mT}=Jr;hi(Bl)&&Ae(Lt({code:-1,msg:Bl},{errNo:mT,errMsg:Bl}))}throw Ne}})}function tR(e){try{return JSON.parse(e.trim())}catch(t){return e}}function rR(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 eR,Rc=C(()=>{"use strict";P();be();gt();Wr();B();eR=(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 Pc,km,re,vt=C(()=>{"use strict";Rc();B();P();Pc={};(km=E.hostUserInfo)!=null&&km.token&&(Pc["x-joli-token"]=E.hostUserInfo.token);E.joliSource&&(Pc["x-joli-source"]=E.joliSource);re=Qo("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:mn(E.testMode),defaultHeaders:Pc})});function Cm(e){let t=_c.config[e];return t||(t={},_c.config[e]=t),(r,n)=>{if(t[r]){Nt.warn(`[can i use] ${r} already registered`);return}t[r]=x({},n)}}var Am=C(()=>{"use strict";P()});function Nc(e){xm=e}function Xo(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Xo(t)):Object.keys(e).reduce((t,r)=>(t[r]=Xo(e[r]),t),{})}function Xt(e){return typeof e=="number"}function Dc(e){let t=Lc(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Lc(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var xm,we,Zo,ea,ta,ra,gn,na,ia,oa,aa,sa,la,ca,ua,da,pa,fa,ha,qc=C(()=>{"use strict";xm=!1;we=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(xm)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 ${Dc(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Xo(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Xo(this._default)}optional(){return this._optional=!0,this}};Zo=class extends we{validate(t){return this._optional&&t===void 0?!0:Xt(t)?Xt(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):Xt(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):Xt(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},ea=class extends we{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ta=class extends we{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(Xt(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(Xt(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}},ra=class extends we{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},gn=class extends we{validate(t){return!0}},na=class extends we{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},ia=class extends we{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},oa=class extends we{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},aa=class extends we{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 ${Dc(t)}`)}return!0}},sa=class extends we{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(Xt(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(Xt(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(Xt(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}},la=class extends we{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Lc(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}},ca=class extends we{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Lc(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}},ua=class extends we{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Dc(this.value),actual:r}):!0}},da=class extends we{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}},pa=class extends we{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}},fa=class extends we{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},ha=class extends we{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 Mc(e,t,r="param"){if(e.errors=[],e.path=r,Nc(!0),!e.validate(t)){let n=e.errors.join(`
3
3
  `);throw e.errors.length=0,Nc(!1),new TypeError(n)}}var I,Uc=C(()=>{"use strict";qc();qc();I={object(e){return new ca(e)},array(e){return new sa(e)},tuple(...e){return new pa(...e)},literal(e){return new ua(e)},or(...e){return new da(...e)},symbol(){return new ra},record(e){return new la(e)},function(){return new oa},boolean(){return new ea},string(){return new ta},number(){return new Zo},undefined(){return new na},null(){return new ia},unknown(){return new gn},any(){return new gn},as(){return new gn},arraybuffer(){return new fa},enum(...e){return new aa(...e)},typedarray(e){return new ha(e)}}});var ma,Tm,Om=C(()=>{"use strict";P();gt();Uc();Wr();ma=1,Tm=e=>{function t(n,i){return(...o)=>{var u,p,f,m;let a=Date.now(),s={method:n,trace_id:ma};ma+=1;let l="SUCCESS",c=`${n}:ok`,d=0;try{if(i.paramsSchema)try{Mc(i.paramsSchema,o,"params")}catch(w){throw Tc(`${n}:fail ${w.message}`)}let v=i.implement(...o),y=v,g=`${n}:ok`;if(v&&"code"in v){let{code:w,data:S,message:A}=v;l=w,y=S,g=A}return{code:l,message:g,data:y}}catch(v){let y=v;d=(p=(u=y.code)!=null?u:y.errNo)!=null?p:2e3,l="FAILURE";let g=(m=(f=y.message)!=null?f:y.errMsg)!=null?m:`${v}`;return c=`${n}:${l} ${g.replace(/^\S+:(fail|cancel)\s?/,"")}`,Ae(new yi(c,d)),{code:l,message:c}}finally{let v=Date.now()-a}}}function r(n,i){return(...o)=>_(this,null,function*(){var p,f,m,v;let a=Jh(o)?o:[o],s=Date.now(),l={method:n,trace_id:ma};ma+=1;let c=`${n}:ok`,d="SUCCESS",u={code:d,message:c};try{if(i.paramsSchema)try{Mc(i.paramsSchema,a,"params")}catch(w){throw Tc(w.message)}let g=yield i.implement(...a);if(g&&"code"in g){let{code:w,data:S,message:A}=g;d=w,c=A,g=S}return Object.assign(u,{code:d,message:c,data:g}),u}catch(y){let g=y,w=(f=(p=g.code)!=null?p:g.errNo)!=null?f:2e3;d="FAILURE";let S=(v=(m=g.message)!=null?m:g.errMsg)!=null?v:`${y}`,A=`${n}:${d} ${S.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:A}),Ae(new yi(A,w)),u}finally{let y=Date.now()-s}})}return{createAPI:r,createSyncAPI:t}}});function Fc(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 Rm=C(()=>{"use strict"});var ue,H,L,Pm,Qe=C(()=>{"use strict";Am();yt();Om();Uc();be();B();Rm();({createAPI:ue,createSyncAPI:H}=Tm(U)),L=Cm("native"),{canIUseNative:Pm}=Th(()=>E.sdkInfo.nativeSDKVersionCode,()=>E.platform)});function Nm(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return t==="array"&&(t="object"),lR.includes(t)?t:""}function Dm(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 Lm(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 ga,iR,oR,aR,sR,EW,SW,lR,bi,va,ya=C(()=>{"use strict";Qe();be();P();vt();B();ga=Y(),iR=ue("getLocalStorage",{paramsSchema:I.tuple(I.string()),implement(e){return _(this,null,function*(){let{response:t}=yield re(`/api/games/user-storage/${E.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 _e("getLocalStorageAsync",{key:e}),s=Dm(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}}})}});ga.registerCommand("StorageSDK.getItem",iR);L("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});oR=ue("setStorage",{paramsSchema:I.tuple(I.string(),I.or(I.string(),I.boolean(),I.number())),implement(e,t){return _(this,null,function*(){let r=E.mpId,n=typeof t=="string"?t:String(t),{response:i}=yield re(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:a}}=i,s=Nm(t),l=Lm(t,s);return yield _e("setLocalStorageAsync",{key:e,data:l,dataType:s}),o=="SUCCESS"?{code:o,message:a}:{code:o,message:`${a}. fallback to native`}})}});ga.registerCommand("StorageSDK.setItem",oR);L("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});aR=ue("removeStorage",{paramsSchema:I.tuple(I.string()),implement(e){return _(this,null,function*(){let t=E.mpId,{response:r}=yield re(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:i}}=r;return yield _e("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:i}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ga.registerCommand("StorageSDK.removeItem",aR);L("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});sR=ue("clearStorage",{implement(){return _(this,null,function*(){let e=E.mpId,{response:t}=yield re(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});_e("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ga.registerCommand("StorageSDK.clear",sR);L("storage.clear",{version:"1.0.0"});EW=ue("getStorageInfo",{implement(){return _(this,null,function*(){let{data:e}=yield _e("getStorageInfoAsync");return e})}});L("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});SW=H("getStorageInfoSync",{implement(){return j("getStorageInfoSync")}}),lR=["string","number","boolean","object",""];bi=ue("getGlobalStorage",{paramsSchema:I.tuple(I.string()),implement(e){return _(this,null,function*(){try{let{data:{data:t,dataType:r}}=yield _e("getGlobalStorageAsync",{key:e});return{code:"SUCCESS",message:"success",data:Dm(t,r)}}catch(t){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get global storage failed",data:null}}})}}),va=ue("setGlobalStorage",{paramsSchema:I.tuple(I.string(),I.or(I.string(),I.boolean(),I.number(),I.array())),implement(e,t){return _(this,null,function*(){try{let r=Nm(t),n=Lm(t,r);return yield _e("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 qm,_a,Mm=C(()=>{"use strict";B();Sm();P();vt();be();ya();qm="REPORT_FIRST_OPEN_GAME",_a=class extends Yo{constructor(t,r,n){super(r,n),this.gameId=E.mpId,this.sessionId=E.sessionId,this.track=t,this.taskUrl=mn(E.testMode)+"/api/base/app-event"}reporter(t){return _(this,null,function*(){let{event:r,params:n,extraParams:i}=t,o={eventType:r,gameInfo:x({gameId:this.gameId,sessionId:this.sessionId},n)};i&&Object.assign(o,i),yield E.platform==="android"?re("/api/base/app-event",{method:"POST",data:o}):_e("trackAppEventAsync",{url:this.taskUrl,body:JSON.stringify(o)})})}reportToNative(t){return _(this,null,function*(){let{event:r,params:n}=t;yield _e("userTrackAsync",{event:r,params:x({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}start(t){super.start(t),this.tryReportOpenGamePlus()}tryReportOpenGamePlus(){bi(qm).then(t=>{Sr(t.data)&&t.data&&this.tracker("OpenGame_2Plus"),va(qm,!0)})}}});var Bm={};ph(Bm,{nativeTaskEmitter:()=>wi,taskTracker:()=>Et,track:()=>U,trackPerformance:()=>jm});var cR,Um,Fm,U,jm,Gm,wi,Et,yt=C(()=>{"use strict";gm();P();Oc();Em();B();Mm();be();cR=(e,t,r)=>{var c,d,u,p,f,m,v;let n=t,i=$r(n.extra)?n.extra:hi(n.extra)?JSON.parse(n.extra):{},{mpName:o,mpVersion:a}=(c=E.mpInfo)!=null?c:{},s=x(x(F(x({},i),{mp_id:(d=n.mp_id)!=null?d:"",mp_version:(u=n.mp_version)!=null?u:"",session_id:E.sessionId,user_id:(f=(p=E.hostUserInfo)==null?void 0:p.uid)!=null?f:""}),o?{mp_name:o}:{}),a?{mp_info_version:a}:{}),l=(m=n.eventType)!=null?m:J.Other;j("trackAsync",{event:(v=t.tag)!=null?v:e,data:s,webviewId:r,eventType:l})},{track:U,trackPerformance:jm}=bm(cR,{type:bc.AppSDK,platform:"native",jssdk_version:(Fm=(Um=E.sdkInfo)==null?void 0:Um.jssdkVersion)!=null?Fm:"1.0.0",mp_id:E.mpId,mp_version:E.mpVersion}),Gm=Y();Gm.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{jm(e,t,r)});Gm.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{U(e,t)});wi=new Dt,Et=new _a(U,wi)});function Jm(){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] {
@@ -828,4 +828,4 @@ If multiple caches share the same key they might "fight" for each other's style
828
828
  cursor: pointer;
829
829
  }
830
830
  }
831
- `});function Ox(){let e=new Map,t,r;return{registerRewardHandler(i,o){e.set(i,o)},handleReward(i,...o){return _(this,null,function*(){return yield i.reduce((s,l)=>_(this,null,function*(){let c=yield s;if(c===!0)return!0;Tx&&console.log(`handleReward ${l}`);let d=e.get(l),u=d?yield d(...o):c;return Tx&&console.log(`handleReward ${l} ${u}`),u}),Promise.resolve(!1))})},registerRewardsFetcher(i){return _(this,null,function*(){t=(...o)=>_(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),["ADS"]}})})},registerRewardFrequencyConfigFetcher(i){return _(this,null,function*(){r=(...o)=>_(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),{joliCoinUseAndCharge:pr,loginGuide:fr}}})})},getRewardsTypes(...i){return _(this,null,function*(){return t?yield t(...i):["ADS"]})},getRewardFrequencyConfig(...i){return _(this,null,function*(){return r?yield r(...i):{joliCoinUseAndCharge:pr,loginGuide:fr}})}}}var Tx,Rx=C(()=>{"use strict";B();Ue();Tx=E.testMode});var Lf,qf,Nl,Px=C(()=>{"use strict";P();Lf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"POST",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){var r,n,i;return{unlockOptions:((r=t.data)==null?void 0:r.unlockOptions)||[],joliCoin:(n=t.extra)==null?void 0:n.joliCoin,joliGem:((i=t.extra)==null?void 0:i.joliGem)||{balance:0,enableAutoDeduct:!1}}}mergeData(t,r){return{code:"SUCCESS",message:"success",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin,joliGem:t.joliGem}}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin,joliGem:t.joliGem}}}},qf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){let r=t.data;return x({joliCoinUseAndCharge:r==null?void 0:r.joliCoinUseAndCharge,loginGuide:r==null?void 0:r.loginGuide},r)}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:t}}},Nl=class{constructor(t){this.unlockOptionsService=new Qt(new Lf(t),{duration:30*60*1e3,timeout:1e3,keyGenerator:r=>r,consistencyChecker:(r,n)=>r.unlockOptions.length!==n.unlockOptions.length?!1:r.unlockOptions.every((i,o)=>{var s,l;let a=n.unlockOptions[o];return i.type===a.type&&((s=i.joliGemChoice)==null?void 0:s.joliGemQuantity)===((l=a.joliGemChoice)==null?void 0:l.joliGemQuantity)})}),this.globalConfigService=new Qt(new qf(t),{duration:60*60*1e3,timeout:1e3,keyGenerator:r=>r})}getUnlockOptions(){return _(this,arguments,function*(t={}){return yield this.unlockOptionsService.request("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}getGlobalConfig(){return _(this,null,function*(){return yield this.globalConfigService.request("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}refreshUnlockOptions(){return _(this,arguments,function*(t={}){return yield this.unlockOptionsService.forceRequest("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}refreshGlobalConfig(){return _(this,null,function*(){return yield this.globalConfigService.forceRequest("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}warmupCache(){return _(this,null,function*(){yield Promise.all([this.unlockOptionsService.warmupCache("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",method:"POST"}),this.globalConfigService.warmupCache("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})])})}clearAllCache(){this.unlockOptionsService.clearCache(),this.globalConfigService.clearCache()}getCacheStats(){return{unlockOptions:this.unlockOptionsService.getCacheStats(),globalConfig:this.globalConfigService.getCacheStats()}}clearExpiredCache(){this.unlockOptionsService.clearExpiredCache(),this.globalConfigService.clearExpiredCache()}}});function Uf(e){return Mf||(Mf=new Nl(e)),Mf}var g$,v$,Mf,Ff,jf,Gf,Bf=C(()=>{"use strict";Px();Ue();P();g$=()=>(e,t)=>{let r={SUBSCRIPTION:4,JOLI_GEM:3,JOLI_GEM_ONLY:3,JOLI_COIN:2,JOLI_COIN_ONLY:2,ADS:1};return r[t]-r[e]},v$=e=>{if(!e.length)return["ADS"];if(e.includes("JOLI_GEM")){if(e.length===1)return["JOLI_GEM_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_GEM_ONLY"]}if(e.includes("JOLI_COIN")){if(e.length===1)return["JOLI_COIN_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_COIN_ONLY"]}return e.sort(g$())},Mf=null;Ff=e=>{e.registerRewardsFetcher(t=>_(void 0,null,function*(){var i,o,a,s,l;let r=["ADS"],n=Uf(t);try{let c=yield n.getUnlockOptions({});if(c.code!=="SUCCESS")return r;q.emit(rl,{options:((i=c.data)==null?void 0:i.unlockOptions)||[],userJoliCoin:((o=c.extra)==null?void 0:o.joliCoin)||{balance:0,enableAutoDeduct:!1},userGem:((a=c.extra)==null?void 0:a.joliGem)||{balance:0,enableAutoDeduct:!1}});let d=((l=(s=c.data)==null?void 0:s.unlockOptions)==null?void 0:l.map(u=>u.type))||Array.from(r);return v$(d)}catch(c){return console.error("getRewardOptions error (cached):",c),r}}))},jf=e=>{e.registerRewardFrequencyConfigFetcher(t=>_(void 0,null,function*(){var n,i,o,a;let r=Uf(t);try{let s=yield r.getGlobalConfig();return q.emit(ur,{joliCoinUseAndCharge:((n=s.data)==null?void 0:n.joliCoinUseAndCharge)||pr,loginGuide:((i=s.data)==null?void 0:i.loginGuide)||fr}),s.data&&te.emit("onGlobalConfigChanged",{globalConfig:s.data}),{joliCoinUseAndCharge:((o=s.data)==null?void 0:o.joliCoinUseAndCharge)||pr,loginGuide:((a=s.data)==null?void 0:a.loginGuide)||fr}}catch(s){return console.error("getGlobalConfig error (cached):",s),q.emit(ur,{joliCoinUseAndCharge:pr,loginGuide:fr}),te.emit("onGlobalConfigChanged",{globalConfig:{joliCoinUseAndCharge:pr,loginGuide:fr}}),{joliCoinUseAndCharge:pr,loginGuide:fr}}}))},Gf=e=>_(void 0,null,function*(){yield Uf(e).warmupCache(),console.log("Reward cache warmed up")})});var Jf=C(()=>{"use strict";Bf();Bf()});var Nx,Dx=C(()=>{"use strict";Nx=e=>t=>_(void 0,null,function*(){try{console.log("trigger @jolibox/ads reward",t),yield e.adBreak(t)}catch(r){console.error("-----createAdsRewardHandler error-----",r)}return!0})});var Ge,_r=C(()=>{"use strict";Ue();hr();Ue();Ge=et(q,rl)});var Dl,Hf=C(()=>{"use strict";Dl={JOLI_COIN:{balanceEndpoint:"/api/joli-coin/balance",balanceDetailEndpoint:"/api/joli-coin/balance-detail",unlockEndpoint:"/api/joli-coin/unlock",unlockType:"JOLI_COIN"},GEM:{balanceEndpoint:"/api/joli-gem/balance",balanceDetailEndpoint:"/api/joli-gem/balance-detail",unlockEndpoint:"/api/joli-gem/unlock",unlockType:"GEM"}}});var It,Br=C(()=>{"use strict";P();It=Y()});function Lx(e){return $f||($f=new Wf(e)),$f}var Vf,Wf,$f,zf,Po,No=C(()=>{"use strict";P();Vf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},Wf=class{constructor(t){this.balanceService=new Qt(new Vf(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getBalance(t="JOLI_COIN"){return _(this,null,function*(){return(yield this.balanceService.request("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}refreshBalance(t="JOLI_COIN"){return _(this,null,function*(){return(yield this.balanceService.forceRequest("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}warmupBalance(t="JOLI_COIN"){return _(this,null,function*(){yield this.balanceService.warmupCache("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})})}clearBalanceCache(){this.balanceService.clearCache()}getBalanceCacheStats(){return this.balanceService.getCacheStats()}clearExpiredCache(){this.balanceService.clearExpiredCache()}},$f=null;zf=(e,t="JOLI_COIN")=>_(void 0,null,function*(){return yield Lx(e).getBalance(t)}),Po=(e,t="JOLI_COIN")=>_(void 0,null,function*(){let n=yield Lx(e).refreshBalance(t);return console.log(`Balance cache refreshed for type: ${t}`),n})});var qx=C(()=>{"use strict";No()});function Xf(e){return Kf||(Kf=new Qf(e)),Kf}var Yf,Qf,Kf,Zf,Do,Ll,Lo=C(()=>{"use strict";P();Yf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},Qf=class{constructor(t){this.gemBalanceService=new Qt(new Yf(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getGemBalance(t="GEM"){return _(this,null,function*(){return(yield this.gemBalanceService.request("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}refreshGemBalance(t="GEM"){return _(this,null,function*(){return(yield this.gemBalanceService.forceRequest("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}warmupGemBalance(t="GEM"){return _(this,null,function*(){yield this.gemBalanceService.warmupCache("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})})}clearGemBalanceCache(){this.gemBalanceService.clearCache()}getGemBalanceCacheStats(){return this.gemBalanceService.getCacheStats()}clearExpiredCache(){this.gemBalanceService.clearExpiredCache()}},Kf=null;Zf=(e,t="GEM")=>_(void 0,null,function*(){return yield Xf(e).getGemBalance(t)}),Do=(e,t="GEM")=>_(void 0,null,function*(){let n=yield Xf(e).refreshGemBalance(t);return console.log(`Gem balance cache refreshed for type: ${t}`),n}),Ll=(e,t="GEM")=>_(void 0,null,function*(){yield Xf(e).warmupGemBalance(t),console.log(`Gem balance cache warmed up for type: ${t}`)})});var Mx=C(()=>{"use strict";Lo()});var oi,ql=C(()=>{"use strict";qx();Mx();oi={JOLI_COIN:{fetchBalance:zf,getQuantity:e=>{var t,r,n;return(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(i=>i.type==="JOLI_COIN"))==null?void 0:r.joliCoinChoices[0].joliCoinQuantity)!=null?n:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userJoliCoin)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userJoliCoin",isEnough:(e,t)=>{var r,n;return(n=(r=e==null?void 0:e.options)==null?void 0:r.some(i=>i.type==="JOLI_COIN"&&i.joliCoinChoices.some(o=>{var a;return o.joliCoinQuantity<=((a=t==null?void 0:t.balance)!=null?a:0)})))!=null?n:!1}},JOLI_GEM:{fetchBalance:Zf,getQuantity:e=>{var t,r,n,i;return(i=(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(o=>o.type==="JOLI_GEM"))==null?void 0:r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userGem)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userGem",isEnough:(e,t)=>{var n,i,o;let r=e==null?void 0:e.options.find(a=>a.type==="JOLI_GEM");return r?((i=(n=r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0)<=((o=t==null?void 0:t.balance)!=null?o:0):!1}}}});var qo,br,eh=C(()=>{"use strict";Br();_r();hr();Ue();Ue();ql();qo=(e,t,r)=>{let{showUnlockWithCurrencyModal:n}=r;It.registerCommand(`Rewards.${e}.useJolicoin`,()=>_(void 0,null,function*(){let i=yield Ge.getData(),o=oi[t],a=o.getCurrentUser(i),s=o.getQuantity(i),l=!!(a!=null&&a.enableAutoDeduct);return console.log("-----unlockOptions usemodal-----",i,l,s),(yield n({enableAutoDeduct:l,userCurrency:a,quantity:s,currency:t}))!=="CONFIRM"?{result:"FAILED"}:{result:"SUCCESS"}}))},br=(e,t)=>r=>_(void 0,null,function*(){let n=et(q,sn);return q.emit(il,e,{enableAutoDeduct:r.enableAutoDeduct,userCurrency:r.userCurrency,quantity:r.quantity,currency:r.currency,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).useModalResult})});var Mo,wr,Ux=C(()=>{"use strict";Br();_r();Ue();hr();Ue();ql();Lo();No();Mo=(e,t,r)=>{let{httpClient:n,initiateAndAwaitPayment:i}=r;It.registerCommand(`Rewards.${e}.usePayment`,()=>_(void 0,null,function*(){var p;let o=yield Ge.getData(),a=oi[t],s=yield a.fetchBalance(n),l=a.getQuantity(o),c=a.getCurrentUser(o),d=a.createUpdatedUser((p=s==null?void 0:s.balance)!=null?p:0,c.enableAutoDeduct),u=a.getUpdateKey();if(Ge.updateData({[u]:d}),console.log("-----unlockOptions payment-----",o,d,l,t),!a.isEnough(o,d)){let f=yield i({userCurrency:d,currencyQuantity:l,currency:t});return t==="JOLI_GEM"?Do(n):Po(n),{result:f==="SUCCESS"?"SUCCESS":"FAILED"}}return{result:"CONTINUE"}}))},wr=(e,t)=>r=>_(void 0,null,function*(){let n=et(q,xt);return q.emit(nl,e,{userCurrency:r.userCurrency,quantity:r.currencyQuantity,currency:r.currency,enableAutoDeduct:r.userCurrency.enableAutoDeduct,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).paymentResult})});var th,Ir,Fx=C(()=>{"use strict";B();Br();hr();Ue();Ue();P();_r();ql();th=(e,t,r)=>{let{showUnloginModal:n,httpClient:i}=r;It.registerCommand(`Rewards.${e}.useUnloginModal`,()=>_(void 0,null,function*(){var s,l,c;let o=(s=E.hostUserInfo)==null?void 0:s.isLogin,a=yield Ge.getData();if(console.log("-----isLogin-----",!!o),!o){let d=yield n(t);if(console.log("-----unloginModalResult-----",d),d.result=="FAILED"||d.result=="CANCEL")return{result:"FAILED"};let{isFirstLogin:u,claimedRewardValue:p}=(l=d.rewards)!=null?l:{};if(d.result=="SUCCESS"){u&&p&&(yield Bh(3e3));let f=oi[t],m=yield f.fetchBalance(i),v=f.getQuantity(a),y=f.getCurrentUser(a),g=f.createUpdatedUser((c=m==null?void 0:m.balance)!=null?c:0,y.enableAutoDeduct),w=f.getUpdateKey();if(Ge.updateData({[w]:g}),g.balance>=v)return{result:"SUCCESS"}}}return{result:"CONTINUE"}}))},Ir=(e,t)=>r=>_(void 0,null,function*(){let n=et(q,dr);return q.emit(ol,e,{confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText,currency:r}),yield n.getFreshData()})});var dn=C(()=>{"use strict";eh();Ux();Fx()});var _$,Ml,rh=C(()=>{"use strict";B();P();Hf();dn();Br();No();_$=(e,t,r,{handlers:{handleUnlockSuccess:n,handleUnlockFailed:i,unlockOptionsHandler:o,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:s,showUnloginModal:l}})=>{Mo(e,"JOLI_COIN",{httpClient:t,initiateAndAwaitPayment:a}),qo(e,"JOLI_COIN",{showUnlockWithCurrencyModal:s});let c=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return d=>_(void 0,null,function*(){var u,p,f;try{let m=!0;for(let g of c){let w=yield It.executeCommand(g);if(m=m&&w.result!=="FAILED",w.result!=="CONTINUE")break}if(!m)return i==null||i(d),!1;let v=Dl[r],y=yield t.post(v.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${hn()}-${E.mpType}-${Date.now()}`,gameInfo:{gameId:E.mpId}}});if(console.log("-----unlockWithCurrency request result-----",y),y.code=="SUCCESS"){try{(p=d.adBreakDone)==null||p.call(d,{breakType:d.type,breakName:"name"in d&&(u=d.name)!=null?u:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in d&&((f=d.adViewed)==null||f.call(d)),Po(t)}catch(g){console.error("-----unlockWithJolicoin adBreakDone error-----",g)}return n==null||n({quantity:y.data.quantity,balance:y.data.balance}),!0}return i==null||i(d),!1}catch(m){if(console.info("JolicoinRewardHandler error:",m),m instanceof Error&&m.message=="CANCEL")throw m;return i==null||i(d),!1}finally{o.clearCache()}})},Ml=(e,t,r)=>_$(e,t,"JOLI_COIN",r)});var jx,Gx=C(()=>{"use strict";_r();rh();dn();jx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=()=>{r==null||r()},i=br("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),o=wr("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),a=Ir("ADS-JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Ml("ADS-JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var Bx,Jx=C(()=>{"use strict";rh();_r();dn();Bx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=l=>{var c;r==null||r(),(c=l.adBreakDone)==null||c.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},i=br("JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),o=wr("JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),a=Ir("JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Ml("JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var Ul,nh=C(()=>{"use strict";B();P();Hf();dn();eh();Br();Lo();Ul=(e,t,{handlers:{handleUnlockSuccess:r,handleUnlockFailed:n,unlockOptionsHandler:i,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:a,showUnloginModal:s}})=>{th(e,"JOLI_GEM",{httpClient:t,showUnloginModal:s}),Mo(e,"JOLI_GEM",{httpClient:t,initiateAndAwaitPayment:o}),qo(e,"JOLI_GEM",{showUnlockWithCurrencyModal:a});let l=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return c=>_(void 0,null,function*(){var d,u,p;try{let f=!0;for(let y of l){let g=yield It.executeCommand(y);if(f=f&&g.result!=="FAILED",g.result!=="CONTINUE")break}if(!f)return n==null||n(c),!1;let m=Dl.GEM,v=yield t.post(m.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${hn()}-${E.mpType}-${Date.now()}`,gameInfo:{gameId:E.mpId}}});if(console.log("-----unlockWithGem request result-----",v),v.code=="SUCCESS"){try{(u=c.adBreakDone)==null||u.call(c,{breakType:c.type,breakName:"name"in c&&(d=c.name)!=null?d:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in c&&((p=c.adViewed)==null||p.call(c)),Do(t)}catch(y){console.error("-----unlockWithGem adBreakDone error-----",y)}return r==null||r({quantity:v.data.quantity,balance:v.data.balance}),!0}return n==null||n(c),!1}catch(f){if(console.info("GemRewardHandler error:",f),f instanceof Error&&f.message=="CANCEL")throw f;return n==null||n(c),!1}finally{i.clearCache()}})}});var Hx,$x=C(()=>{"use strict";_r();nh();dn();Hx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=()=>{r==null||r()},i=br("ADS-JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),o=wr("ADS-JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),a=Ir("ADS-JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Ul("ADS-JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var Vx,Wx=C(()=>{"use strict";nh();_r();dn();Vx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=l=>{var c;r==null||r(),(c=l.adBreakDone)==null||c.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},i=br("JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),o=wr("JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),a=Ir("JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Ul("JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var ih=C(()=>{"use strict";Br();hr();Ue();Ue()});var zx=C(()=>{"use strict";ih()});var Kx=C(()=>{"use strict";Br();zx();B()});var Yx=C(()=>{"use strict";_r();Kx();ih()});var Ot,Qx=C(()=>{"use strict";Rx();Jf();Dx();Gx();Jx();$x();Wx();Yx();No();Lo();Ot=Ox();Ff(Ot);jf(Ot)});var Fl,b$,Er,w$,Uo,Xx,Zx,I$,E$,oh,S$,k$,eT=C(()=>{"use strict";P();Qe();cr();kA();xx();yt();B();vt();be();Qx();jc();Jf();Fl=Y(),b$=()=>{let{data:e}=j("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},Er={get:(e,t)=>re(e,x({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t)=>re(e,x({method:"POST",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},w$={httpClient:Er,checkNetwork:b$,track:U,eventEmitter:ba,getWindowInfo:()=>({width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,statusBarHeight:30}),handleLinkClicked:e=>{window.open(e,"_blank")},getContextInfo:()=>{var e,t,r,n,i,o,a,s,l;return{hostAppId:(t=(e=E.hostInfo)==null?void 0:e.aid)!=null?t:"1",deviceId:(r=E.deviceInfo.did)!=null?r:"",adId:(n=E.deviceInfo.adId)!=null?n:"",sessionId:(i=E.sessionId)!=null?i:"",userId:(a=(o=E.hostUserInfo)==null?void 0:o.uid)!=null?a:"",objectType:"GAME",objectId:E.mpId,testAdsMode:E.testAdsMode,channel:(s=E.joliSource)!=null?s:"",deviceBrand:E.deviceInfo.brand,deviceModel:E.deviceInfo.model,osType:E.platform==="android"?"ANDROID":E.platform==="ios"?"IOS":"PC",runtimeType:"APP",platform:1e3,joliSource:(l=E.joliSource)!=null?l:""}}},Uo=new xl(w$);Ot.getRewardFrequencyConfig(Er).then(e=>{console.log("getRewardFrequencyConfig",e)});Ot.registerRewardHandler("ADS",Nx(Uo));Ot.registerRewardHandler("JOLI_COIN",jx(Er,{onUnlockSuccess:e=>{Xx(e),U("jolicoin_unlock_success",{quantity:e.quantity})},onUnlockFailed:()=>{console.log("onUnlockFailed")}}));Ot.registerRewardHandler("JOLI_COIN_ONLY",Bx(Er,{onUnlockSuccess:e=>{Xx(e),U("jolicoin_unlock_success",{quantity:e.quantity,isOnly:!0})},onUnlockFailed:()=>{console.log("onUnlockFailed")}}));Ot.registerRewardHandler("JOLI_GEM",Hx(Er,{onUnlockSuccess:e=>{Zx(e),U("gem_unlock_success",{quantity:e.quantity})}}));Ot.registerRewardHandler("JOLI_GEM_ONLY",Vx(Er,{onUnlockSuccess:e=>{Zx(e),U("gem_unlock_success",{quantity:e.quantity,isOnly:!0})}}));Xx=e=>{let{quantity:t}=e,r=`{slot-coin} ${t} {slot-i18n-jolicoin.coinUsed}`;Ur(r,{customStyle:{mark:{marginRight:"8px"},base:{with:"auto"}},i18nParams:{text:"Jolicoin Used"}})};Gf(Er);Ll(Er);Zx=e=>{let{quantity:t}=e,r=`{slot-correct} ${t*-1} {slot-gem}`;Ur(r,{customStyle:{mark:{marginRight:"8px"},base:{"font-size":"25px","font-weight":"700","line-height":"18px"},span:{width:"auto",minWidth:"fit-content",maxWidth:"60px",textAlign:"center",padding:"0 2px",lineHeight:"25px"},gem:{transform:"translateY(-2px)",width:"28px",height:"28px"}}})},I$=H("adInit",{implement:e=>{Uo.init(e)}}),E$=H("adConfig",{implement:e=>{Uo.adConfig(e)}}),oh=!1,S$=H("adBreak",{implement:e=>{if(e.type==="reward"){if(oh)return;oh=!0,Ot.getRewardsTypes(Er).then(t=>{Ot.handleReward(t,e).catch(r=>{var n;console.info("handleReward failed in native",r),(n=e.adBreakDone)==null||n.call(e,{breakType:e.type,breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}).finally(()=>{oh=!1})})}else Uo.adBreak(e)}}),k$=H("adUnit",{implement:e=>{Uo.adUnit(e)}});Fl.registerCommand("AdsSDK.init",I$);Fl.registerCommand("AdsSDK.adConfig",E$);Fl.registerCommand("AdsSDK.adBreak",S$);Fl.registerCommand("AdsSDK.adUnit",k$);L("AdsSDK.init",{version:"1.0.0"});L("AdsSDK.adConfig",{version:"1.0.0"});L("AdsSDK.adBreak",{version:"1.0.0"});L("AdsSDK.adUnit",{version:"1.0.0"})});var Fo,C$,A$,x$,T$,O$,tT=C(()=>{"use strict";P();be();Qe();B();Fo=Y(),C$=H("openSchemaSync",{paramsSchema:I.tuple(I.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${E.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=j("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Pt(r.errMsg,r.errNo)}}),A$=H("openPageSync",{paramsSchema:I.tuple(I.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=j("openPageSync",{url:e});if(t!==0||!n)throw new Pt(r,t);return{webviewId:n.webviewId}}}),x$=H("closePageSync",{paramsSchema:I.tuple(I.number()),implement:e=>{let{errNo:t,errMsg:r}=j("closePageSync",{webviewId:e});if(t!==0)throw new Pt(r,t)}}),T$=H("interceptSystemExitSync",{paramsSchema:I.tuple(I.boolean()),implement:e=>{te.emit("onInterceptSystemExit",{intercept:e}),te.emit("onInterceptBackPress",{intercept:e})}}),O$=H("navigateToNativePage",{paramsSchema:I.tuple(I.enum("openHistory","openDiscover","openDiscover","openGame","openDrama","openTopup","openFeed","openRewards"),I.object()),implement:(e,t)=>{j("callHostMethodAsync",{method:e,params:x({},t)})}});Fo.registerCommand("RouterSDK.openSchema",C$);Fo.registerCommand("RouterSDK.openPage",A$);Fo.registerCommand("RouterSDK.closePage",x$);Fo.registerCommand("RouterSDK.interceptSystemExit",T$);Fo.registerCommand("RouterSDK.navigateToNativePage",O$);L("router.openSchema",{version:"1.1.10"});L("router.openPage",{version:"1.1.10"});L("router.closePage",{version:"1.1.10"});L("router.interceptSystemExit",{version:"1.1.18"});L("router.navigateToNativePage",{version:"1.1.19"})});function N$(e){sc("cpLoadProgressEvent",{progress:e},E.webviewId,!0)}var nT,R$,jl,ah,rT,P$,D$,iT=C(()=>{"use strict";P();Qe();be();B();yt();nT=Y(),R$=H("onLoadFinished",{implement:()=>{sc("cpLoadFinishEvent",{},E.webviewId,!0),U("loadFinished",{duration:performance.now()})}}),jl=null,ah=!1,rT=0,P$=200;D$=H("onLoadProgress",{paramsSchema:I.tuple(I.number()),implement:e=>{jl=e,ah||(ah=!0,requestAnimationFrame(function t(){let r=Date.now();r-rT>=P$?(jl!==null&&(N$(jl),rT=r,jl=null),ah=!1):requestAnimationFrame(t)}))}});nT.registerCommand("RuntimeSDK.loadFinishedEvent",R$);nT.registerCommand("RuntimeSDK.loadProgressEvent",D$)});var L$,q$,M$,oT=C(()=>{"use strict";P();Qe();B();L$=Y(),q$="isNativeSupport",M$=H(q$,{paramsSchema:I.tuple(I.object({version:I.string()})),implement:e=>{let t=E.sdkInfo.nativeSDKVersionCode,{version:r}=e;return r?{code:"SUCCESS",data:tm(Fc(t!=null?t:0),r,">=")}:{code:"FAILURE",message:"[Jolibox SDK] api or versionCode is required",data:!1}}});L$.registerCommand("API.isNativeSupport",M$);L("isNativeSupport",{version:"1.1.46"})});var cT=h(lh=>{"use strict";Qe();be();P();P();B();var aT=Y(),Gl=[],sh=!1,sT=e=>{var n;let t=E.platform,r=(n=E.sdkInfo.nativeSDKVersionCode)!=null?n:0;return e.reduce((i,o)=>{if(typeof o=="string")i.push(o);else{let{method:a,platforms:s,nativeVersionCode:l}=o,c=!0;s&&!s.includes(t)&&(c=!1),l&&l>r&&(c=!1),c&&i.push(a)}return i},[])};te.on("onGlobalConfigChanged",e=>{var t,r;Gl=sT((r=(t=e.globalConfig)==null?void 0:t.supportedHostMethods)!=null?r:[]),sh=!0});var lT=()=>new Promise(e=>{if(sh)e(Gl);else{let t=r=>{var n;Gl=sT((n=r.globalConfig.supportedHostMethods)!=null?n:[]),sh=!0,te.off("onGlobalConfigChanged",t),e(Gl)};te.on("onGlobalConfigChanged",t)}}),U$=ue("callHostMethod",{paramsSchema:I.tuple(I.object({method:I.string(),params:I.object().optional().default({})})),implement:r=>_(lh,[r],function*({method:e,params:t}){if(!(yield lT()).includes(e))throw new Pt("Method not supported",10001);let{errNo:i,errMsg:o,data:a}=yield j("callHostMethodAsync",{method:e,params:x({},t)});if(i!==0)throw new Pt(o,i);let c=a,{callHostMethodId:s}=c,l=Be(c,["callHostMethodId"]);return x({},l)})});aT.registerCommand("API.callHostMethod",U$);L("callHostMethod",{version:"1.1.49"});var F$=ue("userTrackAsync",{paramsSchema:I.tuple(I.object({event:I.string(),eventType:I.number(),params:I.object().optional().default({})})),implement:n=>_(lh,[n],function*({event:e,eventType:t,params:r}){if(!(yield lT()).includes("userTrackAsync"))throw new Pt("Method not supported",10001);let{errNo:o,errMsg:a}=yield j("trackAsync",{event:e,eventType:t,data:x({},r),webviewId:E.webviewId});if(o!==0)throw new Pt(a,o)})});aT.registerCommand("API.track",F$);L("track",{version:"1.1.53"})});var pT=h(ch=>{"use strict";P();Qe();tf();Wr();var uT=Y(),dT=ul(),j$=ue("purchaseGem",{paramsSchema:I.tuple(I.object({productId:I.string()})),implement:e=>_(ch,null,function*(){var r,n;let t=yield dT.purchase(e.productId);if(t.code!=="SUCCESS"||!((r=t.data)!=null&&r.totalAmount))throw Lt({code:-1,msg:"[JoliboxSDK]: purchase gem failed: "+t.message});return{totalAmount:(n=t.data)==null?void 0:n.totalAmount}})}),G$=ue("getGemProducts",{paramsSchema:I.tuple(),implement:()=>_(ch,null,function*(){var t,r;let e=(r=(t=yield dT.getProductsInfo())==null?void 0:t.paymentChoices)!=null?r:[];return console.info("choices",e),{products:e.map(n=>{var i;return{productId:n.productId,totalAmountStr:(i=n.totalAmountStr)!=null?i:"",quantity:n.quantity}})}})});uT.registerCommand("PaymentSDK.purchaseGem",j$);uT.registerCommand("PaymentSDK.getGemProducts",G$);L("payment.purchaseGem",{version:"1.2.3"});L("payment.getGemProducts",{version:"1.2.3"})});var B$={};var nie,sie,fie,hie,fT=C(()=>{"use strict";DC();nie=ie(LC());BC();ya();JC();sie=ie(HC());Zs();eT();tT();iT();oT();fie=ie(cT()),hie=ie(pT())});var hT=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[hT])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[hT]=!0;_(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(PC(),RC)),Promise.resolve().then(()=>(fT(),B$)),Promise.resolve().then(()=>(yt(),Bm))]);e()});
831
+ `});function Ox(){let e=new Map,t,r;return{registerRewardHandler(i,o){e.set(i,o)},handleReward(i,...o){return _(this,null,function*(){return yield i.reduce((s,l)=>_(this,null,function*(){let c=yield s;if(c===!0)return!0;Tx&&console.log(`handleReward ${l}`);let d=e.get(l),u=d?yield d(...o):c;return Tx&&console.log(`handleReward ${l} ${u}`),u}),Promise.resolve(!1))})},registerRewardsFetcher(i){return _(this,null,function*(){t=(...o)=>_(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),["ADS"]}})})},registerRewardFrequencyConfigFetcher(i){return _(this,null,function*(){r=(...o)=>_(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),{joliCoinUseAndCharge:pr,loginGuide:fr}}})})},getRewardsTypes(...i){return _(this,null,function*(){return t?yield t(...i):["ADS"]})},getRewardFrequencyConfig(...i){return _(this,null,function*(){return r?yield r(...i):{joliCoinUseAndCharge:pr,loginGuide:fr}})}}}var Tx,Rx=C(()=>{"use strict";B();Ue();Tx=E.testMode});var Lf,qf,Nl,Px=C(()=>{"use strict";P();Lf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"POST",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){var r,n,i;return{unlockOptions:((r=t.data)==null?void 0:r.unlockOptions)||[],joliCoin:((n=t.extra)==null?void 0:n.joliCoin)||{balance:0,enableAutoDeduct:!1},joliGem:((i=t.extra)==null?void 0:i.joliGem)||{balance:0,enableAutoDeduct:!1}}}mergeData(t,r){return{code:"SUCCESS",message:"success",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin||{balance:0,enableAutoDeduct:!1},joliGem:t.joliGem||{balance:0,enableAutoDeduct:!1}}}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin,joliGem:t.joliGem}}}},qf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){let r=t.data;return x({joliCoinUseAndCharge:r==null?void 0:r.joliCoinUseAndCharge,loginGuide:r==null?void 0:r.loginGuide},r)}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:t}}},Nl=class{constructor(t){this.unlockOptionsService=new Qt(new Lf(t),{duration:30*60*1e3,timeout:1e3,keyGenerator:r=>r,consistencyChecker:(r,n)=>r.unlockOptions.length!==n.unlockOptions.length?!1:r.unlockOptions.every((i,o)=>{var s,l;let a=n.unlockOptions[o];return i.type===a.type&&((s=i.joliGemChoice)==null?void 0:s.joliGemQuantity)===((l=a.joliGemChoice)==null?void 0:l.joliGemQuantity)})}),this.globalConfigService=new Qt(new qf(t),{duration:60*60*1e3,timeout:1e3,keyGenerator:r=>r})}getUnlockOptions(){return _(this,arguments,function*(t={}){return yield this.unlockOptionsService.request("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}getGlobalConfig(){return _(this,null,function*(){return yield this.globalConfigService.request("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}refreshUnlockOptions(){return _(this,arguments,function*(t={}){return yield this.unlockOptionsService.forceRequest("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}refreshGlobalConfig(){return _(this,null,function*(){return yield this.globalConfigService.forceRequest("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}warmupCache(){return _(this,null,function*(){yield Promise.all([this.unlockOptionsService.warmupCache("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",method:"POST"}),this.globalConfigService.warmupCache("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})])})}clearAllCache(){this.unlockOptionsService.clearCache(),this.globalConfigService.clearCache()}getCacheStats(){return{unlockOptions:this.unlockOptionsService.getCacheStats(),globalConfig:this.globalConfigService.getCacheStats()}}clearExpiredCache(){this.unlockOptionsService.clearExpiredCache(),this.globalConfigService.clearExpiredCache()}}});function Uf(e){return Mf||(Mf=new Nl(e)),Mf}var g$,v$,Mf,Ff,jf,Gf,Bf=C(()=>{"use strict";Px();Ue();P();g$=()=>(e,t)=>{let r={SUBSCRIPTION:4,JOLI_GEM:3,JOLI_GEM_ONLY:3,JOLI_COIN:2,JOLI_COIN_ONLY:2,ADS:1};return r[t]-r[e]},v$=e=>{if(!e.length)return["ADS"];if(e.includes("JOLI_GEM")){if(e.length===1)return["JOLI_GEM_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_GEM_ONLY"]}if(e.includes("JOLI_COIN")){if(e.length===1)return["JOLI_COIN_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_COIN_ONLY"]}return e.sort(g$())},Mf=null;Ff=e=>{e.registerRewardsFetcher(t=>_(void 0,null,function*(){var i,o,a,s,l;let r=["ADS"],n=Uf(t);try{let c=yield n.getUnlockOptions({});if(c.code!=="SUCCESS")return r;q.emit(rl,{options:((i=c.data)==null?void 0:i.unlockOptions)||[],userJoliCoin:((o=c.extra)==null?void 0:o.joliCoin)||{balance:0,enableAutoDeduct:!1},userGem:((a=c.extra)==null?void 0:a.joliGem)||{balance:0,enableAutoDeduct:!1}});let d=((l=(s=c.data)==null?void 0:s.unlockOptions)==null?void 0:l.map(u=>u.type))||Array.from(r);return v$(d)}catch(c){return console.error("getRewardOptions error (cached):",c),r}}))},jf=e=>{e.registerRewardFrequencyConfigFetcher(t=>_(void 0,null,function*(){var n,i,o,a;let r=Uf(t);try{let s=yield r.getGlobalConfig();return q.emit(ur,{joliCoinUseAndCharge:((n=s.data)==null?void 0:n.joliCoinUseAndCharge)||pr,loginGuide:((i=s.data)==null?void 0:i.loginGuide)||fr}),s.data&&te.emit("onGlobalConfigChanged",{globalConfig:s.data}),{joliCoinUseAndCharge:((o=s.data)==null?void 0:o.joliCoinUseAndCharge)||pr,loginGuide:((a=s.data)==null?void 0:a.loginGuide)||fr}}catch(s){return console.error("getGlobalConfig error (cached):",s),q.emit(ur,{joliCoinUseAndCharge:pr,loginGuide:fr}),te.emit("onGlobalConfigChanged",{globalConfig:{joliCoinUseAndCharge:pr,loginGuide:fr}}),{joliCoinUseAndCharge:pr,loginGuide:fr}}}))},Gf=e=>_(void 0,null,function*(){yield Uf(e).warmupCache(),console.log("Reward cache warmed up")})});var Jf=C(()=>{"use strict";Bf();Bf()});var Nx,Dx=C(()=>{"use strict";Nx=e=>t=>_(void 0,null,function*(){try{console.log("trigger @jolibox/ads reward",t),yield e.adBreak(t)}catch(r){console.error("-----createAdsRewardHandler error-----",r)}return!0})});var Ge,_r=C(()=>{"use strict";Ue();hr();Ue();Ge=et(q,rl)});var Dl,Hf=C(()=>{"use strict";Dl={JOLI_COIN:{balanceEndpoint:"/api/joli-coin/balance",balanceDetailEndpoint:"/api/joli-coin/balance-detail",unlockEndpoint:"/api/joli-coin/unlock",unlockType:"JOLI_COIN"},GEM:{balanceEndpoint:"/api/joli-gem/balance",balanceDetailEndpoint:"/api/joli-gem/balance-detail",unlockEndpoint:"/api/joli-gem/unlock",unlockType:"GEM"}}});var It,Br=C(()=>{"use strict";P();It=Y()});function Lx(e){return $f||($f=new Wf(e)),$f}var Vf,Wf,$f,zf,Po,No=C(()=>{"use strict";P();Vf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},Wf=class{constructor(t){this.balanceService=new Qt(new Vf(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getBalance(t="JOLI_COIN"){return _(this,null,function*(){return(yield this.balanceService.request("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}refreshBalance(t="JOLI_COIN"){return _(this,null,function*(){return(yield this.balanceService.forceRequest("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}warmupBalance(t="JOLI_COIN"){return _(this,null,function*(){yield this.balanceService.warmupCache("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})})}clearBalanceCache(){this.balanceService.clearCache()}getBalanceCacheStats(){return this.balanceService.getCacheStats()}clearExpiredCache(){this.balanceService.clearExpiredCache()}},$f=null;zf=(e,t="JOLI_COIN")=>_(void 0,null,function*(){return yield Lx(e).getBalance(t)}),Po=(e,t="JOLI_COIN")=>_(void 0,null,function*(){let n=yield Lx(e).refreshBalance(t);return console.log(`Balance cache refreshed for type: ${t}`),n})});var qx=C(()=>{"use strict";No()});function Xf(e){return Kf||(Kf=new Qf(e)),Kf}var Yf,Qf,Kf,Zf,Do,Ll,Lo=C(()=>{"use strict";P();Yf=class{constructor(t){this.httpClient=t}execute(t,r){return _(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},Qf=class{constructor(t){this.gemBalanceService=new Qt(new Yf(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getGemBalance(t="GEM"){return _(this,null,function*(){return(yield this.gemBalanceService.request("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}refreshGemBalance(t="GEM"){return _(this,null,function*(){return(yield this.gemBalanceService.forceRequest("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}warmupGemBalance(t="GEM"){return _(this,null,function*(){yield this.gemBalanceService.warmupCache("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})})}clearGemBalanceCache(){this.gemBalanceService.clearCache()}getGemBalanceCacheStats(){return this.gemBalanceService.getCacheStats()}clearExpiredCache(){this.gemBalanceService.clearExpiredCache()}},Kf=null;Zf=(e,t="GEM")=>_(void 0,null,function*(){return yield Xf(e).getGemBalance(t)}),Do=(e,t="GEM")=>_(void 0,null,function*(){let n=yield Xf(e).refreshGemBalance(t);return console.log(`Gem balance cache refreshed for type: ${t}`),n}),Ll=(e,t="GEM")=>_(void 0,null,function*(){yield Xf(e).warmupGemBalance(t),console.log(`Gem balance cache warmed up for type: ${t}`)})});var Mx=C(()=>{"use strict";Lo()});var oi,ql=C(()=>{"use strict";qx();Mx();oi={JOLI_COIN:{fetchBalance:zf,getQuantity:e=>{var t,r,n;return(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(i=>i.type==="JOLI_COIN"))==null?void 0:r.joliCoinChoices[0].joliCoinQuantity)!=null?n:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userJoliCoin)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userJoliCoin",isEnough:(e,t)=>{var r,n;return(n=(r=e==null?void 0:e.options)==null?void 0:r.some(i=>i.type==="JOLI_COIN"&&i.joliCoinChoices.some(o=>{var a;return o.joliCoinQuantity<=((a=t==null?void 0:t.balance)!=null?a:0)})))!=null?n:!1}},JOLI_GEM:{fetchBalance:Zf,getQuantity:e=>{var t,r,n,i;return(i=(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(o=>o.type==="JOLI_GEM"))==null?void 0:r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userGem)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userGem",isEnough:(e,t)=>{var n,i,o;let r=e==null?void 0:e.options.find(a=>a.type==="JOLI_GEM");return r?((i=(n=r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0)<=((o=t==null?void 0:t.balance)!=null?o:0):!1}}}});var qo,br,eh=C(()=>{"use strict";Br();_r();hr();Ue();Ue();ql();qo=(e,t,r)=>{let{showUnlockWithCurrencyModal:n}=r;It.registerCommand(`Rewards.${e}.useJolicoin`,()=>_(void 0,null,function*(){let i=yield Ge.getData(),o=oi[t],a=o.getCurrentUser(i),s=o.getQuantity(i),l=!!(a!=null&&a.enableAutoDeduct);return console.log("-----unlockOptions usemodal-----",i,l,s),(yield n({enableAutoDeduct:l,userCurrency:a,quantity:s,currency:t}))!=="CONFIRM"?{result:"FAILED"}:{result:"SUCCESS"}}))},br=(e,t)=>r=>_(void 0,null,function*(){let n=et(q,sn);return q.emit(il,e,{enableAutoDeduct:r.enableAutoDeduct,userCurrency:r.userCurrency,quantity:r.quantity,currency:r.currency,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).useModalResult})});var Mo,wr,Ux=C(()=>{"use strict";Br();_r();Ue();hr();Ue();ql();Lo();No();Mo=(e,t,r)=>{let{httpClient:n,initiateAndAwaitPayment:i}=r;It.registerCommand(`Rewards.${e}.usePayment`,()=>_(void 0,null,function*(){var p;let o=yield Ge.getData(),a=oi[t],s=yield a.fetchBalance(n),l=a.getQuantity(o),c=a.getCurrentUser(o),d=a.createUpdatedUser((p=s==null?void 0:s.balance)!=null?p:0,c.enableAutoDeduct),u=a.getUpdateKey();if(Ge.updateData({[u]:d}),console.log("-----unlockOptions payment-----",o,d,l,t),!a.isEnough(o,d)){let f=yield i({userCurrency:d,currencyQuantity:l,currency:t});return t==="JOLI_GEM"?Do(n):Po(n),{result:f==="SUCCESS"?"SUCCESS":"FAILED"}}return{result:"CONTINUE"}}))},wr=(e,t)=>r=>_(void 0,null,function*(){let n=et(q,xt);return q.emit(nl,e,{userCurrency:r.userCurrency,quantity:r.currencyQuantity,currency:r.currency,enableAutoDeduct:r.userCurrency.enableAutoDeduct,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).paymentResult})});var th,Ir,Fx=C(()=>{"use strict";B();Br();hr();Ue();Ue();P();_r();ql();th=(e,t,r)=>{let{showUnloginModal:n,httpClient:i}=r;It.registerCommand(`Rewards.${e}.useUnloginModal`,()=>_(void 0,null,function*(){var s,l,c;let o=(s=E.hostUserInfo)==null?void 0:s.isLogin,a=yield Ge.getData();if(console.log("-----isLogin-----",!!o),!o){let d=yield n(t);if(console.log("-----unloginModalResult-----",d),d.result=="FAILED"||d.result=="CANCEL")return{result:"FAILED"};let{isFirstLogin:u,claimedRewardValue:p}=(l=d.rewards)!=null?l:{};if(d.result=="SUCCESS"){u&&p&&(yield Bh(3e3));let f=oi[t],m=yield f.fetchBalance(i),v=f.getQuantity(a),y=f.getCurrentUser(a),g=f.createUpdatedUser((c=m==null?void 0:m.balance)!=null?c:0,y.enableAutoDeduct),w=f.getUpdateKey();if(Ge.updateData({[w]:g}),g.balance>=v)return{result:"SUCCESS"}}}return{result:"CONTINUE"}}))},Ir=(e,t)=>r=>_(void 0,null,function*(){let n=et(q,dr);return q.emit(ol,e,{confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText,currency:r}),yield n.getFreshData()})});var dn=C(()=>{"use strict";eh();Ux();Fx()});var _$,Ml,rh=C(()=>{"use strict";B();P();Hf();dn();Br();No();_$=(e,t,r,{handlers:{handleUnlockSuccess:n,handleUnlockFailed:i,unlockOptionsHandler:o,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:s,showUnloginModal:l}})=>{Mo(e,"JOLI_COIN",{httpClient:t,initiateAndAwaitPayment:a}),qo(e,"JOLI_COIN",{showUnlockWithCurrencyModal:s});let c=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return d=>_(void 0,null,function*(){var u,p,f;try{let m=!0;for(let g of c){let w=yield It.executeCommand(g);if(m=m&&w.result!=="FAILED",w.result!=="CONTINUE")break}if(!m)return i==null||i(d),!1;let v=Dl[r],y=yield t.post(v.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${hn()}-${E.mpType}-${Date.now()}`,gameInfo:{gameId:E.mpId}}});if(console.log("-----unlockWithCurrency request result-----",y),y.code=="SUCCESS"){try{(p=d.adBreakDone)==null||p.call(d,{breakType:d.type,breakName:"name"in d&&(u=d.name)!=null?u:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in d&&((f=d.adViewed)==null||f.call(d)),Po(t)}catch(g){console.error("-----unlockWithJolicoin adBreakDone error-----",g)}return n==null||n({quantity:y.data.quantity,balance:y.data.balance}),!0}return i==null||i(d),!1}catch(m){if(console.info("JolicoinRewardHandler error:",m),m instanceof Error&&m.message=="CANCEL")throw m;return i==null||i(d),!1}finally{o.clearCache()}})},Ml=(e,t,r)=>_$(e,t,"JOLI_COIN",r)});var jx,Gx=C(()=>{"use strict";_r();rh();dn();jx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=()=>{r==null||r()},i=br("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),o=wr("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),a=Ir("ADS-JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Ml("ADS-JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var Bx,Jx=C(()=>{"use strict";rh();_r();dn();Bx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=l=>{var c;r==null||r(),(c=l.adBreakDone)==null||c.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},i=br("JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),o=wr("JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),a=Ir("JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Ml("JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var Ul,nh=C(()=>{"use strict";B();P();Hf();dn();eh();Br();Lo();Ul=(e,t,{handlers:{handleUnlockSuccess:r,handleUnlockFailed:n,unlockOptionsHandler:i,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:a,showUnloginModal:s}})=>{th(e,"JOLI_GEM",{httpClient:t,showUnloginModal:s}),Mo(e,"JOLI_GEM",{httpClient:t,initiateAndAwaitPayment:o}),qo(e,"JOLI_GEM",{showUnlockWithCurrencyModal:a});let l=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return c=>_(void 0,null,function*(){var d,u,p;try{let f=!0;for(let y of l){let g=yield It.executeCommand(y);if(f=f&&g.result!=="FAILED",g.result!=="CONTINUE")break}if(!f)return n==null||n(c),!1;let m=Dl.GEM,v=yield t.post(m.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${hn()}-${E.mpType}-${Date.now()}`,gameInfo:{gameId:E.mpId}}});if(console.log("-----unlockWithGem request result-----",v),v.code=="SUCCESS"){try{(u=c.adBreakDone)==null||u.call(c,{breakType:c.type,breakName:"name"in c&&(d=c.name)!=null?d:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in c&&((p=c.adViewed)==null||p.call(c)),Do(t)}catch(y){console.error("-----unlockWithGem adBreakDone error-----",y)}return r==null||r({quantity:v.data.quantity,balance:v.data.balance}),!0}return n==null||n(c),!1}catch(f){if(console.info("GemRewardHandler error:",f),f instanceof Error&&f.message=="CANCEL")throw f;return n==null||n(c),!1}finally{i.clearCache()}})}});var Hx,$x=C(()=>{"use strict";_r();nh();dn();Hx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=()=>{r==null||r()},i=br("ADS-JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),o=wr("ADS-JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),a=Ir("ADS-JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Ul("ADS-JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var Vx,Wx=C(()=>{"use strict";nh();_r();dn();Vx=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=l=>{var c;r==null||r(),(c=l.adBreakDone)==null||c.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},i=br("JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),o=wr("JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),a=Ir("JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Ul("JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:n,unlockOptionsHandler:Ge,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:i,showUnloginModal:a}})}});var ih=C(()=>{"use strict";Br();hr();Ue();Ue()});var zx=C(()=>{"use strict";ih()});var Kx=C(()=>{"use strict";Br();zx();B()});var Yx=C(()=>{"use strict";_r();Kx();ih()});var Ot,Qx=C(()=>{"use strict";Rx();Jf();Dx();Gx();Jx();$x();Wx();Yx();No();Lo();Ot=Ox();Ff(Ot);jf(Ot)});var Fl,b$,Er,w$,Uo,Xx,Zx,I$,E$,oh,S$,k$,eT=C(()=>{"use strict";P();Qe();cr();kA();xx();yt();B();vt();be();Qx();jc();Jf();Fl=Y(),b$=()=>{let{data:e}=j("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},Er={get:(e,t)=>re(e,x({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t)=>re(e,x({method:"POST",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},w$={httpClient:Er,checkNetwork:b$,track:U,eventEmitter:ba,getWindowInfo:()=>({width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,statusBarHeight:30}),handleLinkClicked:e=>{window.open(e,"_blank")},getContextInfo:()=>{var e,t,r,n,i,o,a,s,l;return{hostAppId:(t=(e=E.hostInfo)==null?void 0:e.aid)!=null?t:"1",deviceId:(r=E.deviceInfo.did)!=null?r:"",adId:(n=E.deviceInfo.adId)!=null?n:"",sessionId:(i=E.sessionId)!=null?i:"",userId:(a=(o=E.hostUserInfo)==null?void 0:o.uid)!=null?a:"",objectType:"GAME",objectId:E.mpId,testAdsMode:E.testAdsMode,channel:(s=E.joliSource)!=null?s:"",deviceBrand:E.deviceInfo.brand,deviceModel:E.deviceInfo.model,osType:E.platform==="android"?"ANDROID":E.platform==="ios"?"IOS":"PC",runtimeType:"APP",platform:1e3,joliSource:(l=E.joliSource)!=null?l:""}}},Uo=new xl(w$);Ot.getRewardFrequencyConfig(Er).then(e=>{console.log("getRewardFrequencyConfig",e)});Ot.registerRewardHandler("ADS",Nx(Uo));Ot.registerRewardHandler("JOLI_COIN",jx(Er,{onUnlockSuccess:e=>{Xx(e),U("jolicoin_unlock_success",{quantity:e.quantity})},onUnlockFailed:()=>{console.log("onUnlockFailed")}}));Ot.registerRewardHandler("JOLI_COIN_ONLY",Bx(Er,{onUnlockSuccess:e=>{Xx(e),U("jolicoin_unlock_success",{quantity:e.quantity,isOnly:!0})},onUnlockFailed:()=>{console.log("onUnlockFailed")}}));Ot.registerRewardHandler("JOLI_GEM",Hx(Er,{onUnlockSuccess:e=>{Zx(e),U("gem_unlock_success",{quantity:e.quantity})}}));Ot.registerRewardHandler("JOLI_GEM_ONLY",Vx(Er,{onUnlockSuccess:e=>{Zx(e),U("gem_unlock_success",{quantity:e.quantity,isOnly:!0})}}));Xx=e=>{let{quantity:t}=e,r=`{slot-coin} ${t} {slot-i18n-jolicoin.coinUsed}`;Ur(r,{customStyle:{mark:{marginRight:"8px"},base:{with:"auto"}},i18nParams:{text:"Jolicoin Used"}})};Gf(Er);Ll(Er);Zx=e=>{let{quantity:t}=e,r=`{slot-correct} ${t*-1} {slot-gem}`;Ur(r,{customStyle:{mark:{marginRight:"8px"},base:{"font-size":"25px","font-weight":"700","line-height":"18px"},span:{width:"auto",minWidth:"fit-content",maxWidth:"60px",textAlign:"center",padding:"0 2px",lineHeight:"25px"},gem:{transform:"translateY(-2px)",width:"28px",height:"28px"}}})},I$=H("adInit",{implement:e=>{Uo.init(e)}}),E$=H("adConfig",{implement:e=>{Uo.adConfig(e)}}),oh=!1,S$=H("adBreak",{implement:e=>{if(e.type==="reward"){if(oh)return;oh=!0,Ot.getRewardsTypes(Er).then(t=>{Ot.handleReward(t,e).catch(r=>{var n;console.info("handleReward failed in native",r),(n=e.adBreakDone)==null||n.call(e,{breakType:e.type,breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}).finally(()=>{oh=!1})})}else Uo.adBreak(e)}}),k$=H("adUnit",{implement:e=>{Uo.adUnit(e)}});Fl.registerCommand("AdsSDK.init",I$);Fl.registerCommand("AdsSDK.adConfig",E$);Fl.registerCommand("AdsSDK.adBreak",S$);Fl.registerCommand("AdsSDK.adUnit",k$);L("AdsSDK.init",{version:"1.0.0"});L("AdsSDK.adConfig",{version:"1.0.0"});L("AdsSDK.adBreak",{version:"1.0.0"});L("AdsSDK.adUnit",{version:"1.0.0"})});var Fo,C$,A$,x$,T$,O$,tT=C(()=>{"use strict";P();be();Qe();B();Fo=Y(),C$=H("openSchemaSync",{paramsSchema:I.tuple(I.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${E.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=j("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Pt(r.errMsg,r.errNo)}}),A$=H("openPageSync",{paramsSchema:I.tuple(I.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=j("openPageSync",{url:e});if(t!==0||!n)throw new Pt(r,t);return{webviewId:n.webviewId}}}),x$=H("closePageSync",{paramsSchema:I.tuple(I.number()),implement:e=>{let{errNo:t,errMsg:r}=j("closePageSync",{webviewId:e});if(t!==0)throw new Pt(r,t)}}),T$=H("interceptSystemExitSync",{paramsSchema:I.tuple(I.boolean()),implement:e=>{te.emit("onInterceptSystemExit",{intercept:e}),te.emit("onInterceptBackPress",{intercept:e})}}),O$=H("navigateToNativePage",{paramsSchema:I.tuple(I.enum("openHistory","openDiscover","openDiscover","openGame","openDrama","openTopup","openFeed","openRewards"),I.object()),implement:(e,t)=>{j("callHostMethodAsync",{method:e,params:x({},t)})}});Fo.registerCommand("RouterSDK.openSchema",C$);Fo.registerCommand("RouterSDK.openPage",A$);Fo.registerCommand("RouterSDK.closePage",x$);Fo.registerCommand("RouterSDK.interceptSystemExit",T$);Fo.registerCommand("RouterSDK.navigateToNativePage",O$);L("router.openSchema",{version:"1.1.10"});L("router.openPage",{version:"1.1.10"});L("router.closePage",{version:"1.1.10"});L("router.interceptSystemExit",{version:"1.1.18"});L("router.navigateToNativePage",{version:"1.1.19"})});function N$(e){sc("cpLoadProgressEvent",{progress:e},E.webviewId,!0)}var nT,R$,jl,ah,rT,P$,D$,iT=C(()=>{"use strict";P();Qe();be();B();yt();nT=Y(),R$=H("onLoadFinished",{implement:()=>{sc("cpLoadFinishEvent",{},E.webviewId,!0),U("loadFinished",{duration:performance.now()})}}),jl=null,ah=!1,rT=0,P$=200;D$=H("onLoadProgress",{paramsSchema:I.tuple(I.number()),implement:e=>{jl=e,ah||(ah=!0,requestAnimationFrame(function t(){let r=Date.now();r-rT>=P$?(jl!==null&&(N$(jl),rT=r,jl=null),ah=!1):requestAnimationFrame(t)}))}});nT.registerCommand("RuntimeSDK.loadFinishedEvent",R$);nT.registerCommand("RuntimeSDK.loadProgressEvent",D$)});var L$,q$,M$,oT=C(()=>{"use strict";P();Qe();B();L$=Y(),q$="isNativeSupport",M$=H(q$,{paramsSchema:I.tuple(I.object({version:I.string()})),implement:e=>{let t=E.sdkInfo.nativeSDKVersionCode,{version:r}=e;return r?{code:"SUCCESS",data:tm(Fc(t!=null?t:0),r,">=")}:{code:"FAILURE",message:"[Jolibox SDK] api or versionCode is required",data:!1}}});L$.registerCommand("API.isNativeSupport",M$);L("isNativeSupport",{version:"1.1.46"})});var cT=h(lh=>{"use strict";Qe();be();P();P();B();var aT=Y(),Gl=[],sh=!1,sT=e=>{var n;let t=E.platform,r=(n=E.sdkInfo.nativeSDKVersionCode)!=null?n:0;return e.reduce((i,o)=>{if(typeof o=="string")i.push(o);else{let{method:a,platforms:s,nativeVersionCode:l}=o,c=!0;s&&!s.includes(t)&&(c=!1),l&&l>r&&(c=!1),c&&i.push(a)}return i},[])};te.on("onGlobalConfigChanged",e=>{var t,r;Gl=sT((r=(t=e.globalConfig)==null?void 0:t.supportedHostMethods)!=null?r:[]),sh=!0});var lT=()=>new Promise(e=>{if(sh)e(Gl);else{let t=r=>{var n;Gl=sT((n=r.globalConfig.supportedHostMethods)!=null?n:[]),sh=!0,te.off("onGlobalConfigChanged",t),e(Gl)};te.on("onGlobalConfigChanged",t)}}),U$=ue("callHostMethod",{paramsSchema:I.tuple(I.object({method:I.string(),params:I.object().optional().default({})})),implement:r=>_(lh,[r],function*({method:e,params:t}){if(!(yield lT()).includes(e))throw new Pt("Method not supported",10001);let{errNo:i,errMsg:o,data:a}=yield j("callHostMethodAsync",{method:e,params:x({},t)});if(i!==0)throw new Pt(o,i);let c=a,{callHostMethodId:s}=c,l=Be(c,["callHostMethodId"]);return x({},l)})});aT.registerCommand("API.callHostMethod",U$);L("callHostMethod",{version:"1.1.49"});var F$=ue("userTrackAsync",{paramsSchema:I.tuple(I.object({event:I.string(),eventType:I.number(),params:I.object().optional().default({})})),implement:n=>_(lh,[n],function*({event:e,eventType:t,params:r}){if(!(yield lT()).includes("userTrackAsync"))throw new Pt("Method not supported",10001);let{errNo:o,errMsg:a}=yield j("trackAsync",{event:e,eventType:t,data:x({},r),webviewId:E.webviewId});if(o!==0)throw new Pt(a,o)})});aT.registerCommand("API.track",F$);L("track",{version:"1.1.53"})});var pT=h(ch=>{"use strict";P();Qe();tf();Wr();var uT=Y(),dT=ul(),j$=ue("purchaseGem",{paramsSchema:I.tuple(I.object({productId:I.string()})),implement:e=>_(ch,null,function*(){var r,n;let t=yield dT.purchase(e.productId);if(t.code!=="SUCCESS"||!((r=t.data)!=null&&r.totalAmount))throw Lt({code:-1,msg:"[JoliboxSDK]: purchase gem failed: "+t.message});return{totalAmount:(n=t.data)==null?void 0:n.totalAmount}})}),G$=ue("getGemProducts",{paramsSchema:I.tuple(),implement:()=>_(ch,null,function*(){var t,r;let e=(r=(t=yield dT.getProductsInfo())==null?void 0:t.paymentChoices)!=null?r:[];return console.info("choices",e),{products:e.map(n=>{var i;return{productId:n.productId,totalAmountStr:(i=n.totalAmountStr)!=null?i:"",quantity:n.quantity}})}})});uT.registerCommand("PaymentSDK.purchaseGem",j$);uT.registerCommand("PaymentSDK.getGemProducts",G$);L("payment.purchaseGem",{version:"1.2.3"});L("payment.getGemProducts",{version:"1.2.3"})});var B$={};var nie,sie,fie,hie,fT=C(()=>{"use strict";DC();nie=ie(LC());BC();ya();JC();sie=ie(HC());Zs();eT();tT();iT();oT();fie=ie(cT()),hie=ie(pT())});var hT=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[hT])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[hT]=!0;_(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(PC(),RC)),Promise.resolve().then(()=>(fT(),B$)),Promise.resolve().then(()=>(yt(),Bm))]);e()});
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.2.6 clean
3
+ > @jolibox/implement@1.2.7 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.2.6 build:esm
7
+ > @jolibox/implement@1.2.7 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.2.6",
4
+ "version": "1.2.7",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.2.6",
10
- "@jolibox/types": "1.2.6",
11
- "@jolibox/native-bridge": "1.2.6",
12
- "@jolibox/ads": "1.2.6",
9
+ "@jolibox/common": "1.2.7",
10
+ "@jolibox/types": "1.2.7",
11
+ "@jolibox/native-bridge": "1.2.7",
12
+ "@jolibox/ads": "1.2.7",
13
13
  "localforage": "1.10.0",
14
14
  "@jolibox/ui": "1.0.0",
15
15
  "web-vitals": "4.2.4"
@@ -50,7 +50,7 @@ class RewardRequestAdapter
50
50
  extractCacheableData(response: IJolicoinRewardOption): UnlockOptionsCacheData {
51
51
  return {
52
52
  unlockOptions: response.data?.unlockOptions || [],
53
- joliCoin: response.extra?.joliCoin,
53
+ joliCoin: response.extra?.joliCoin || { balance: 0, enableAutoDeduct: false },
54
54
  joliGem: response.extra?.joliGem || { balance: 0, enableAutoDeduct: false }
55
55
  };
56
56
  }
@@ -65,8 +65,8 @@ class RewardRequestAdapter
65
65
  unlockOptions: cached.unlockOptions
66
66
  },
67
67
  extra: {
68
- joliCoin: cached.joliCoin,
69
- joliGem: cached.joliGem
68
+ joliCoin: cached.joliCoin || { balance: 0, enableAutoDeduct: false },
69
+ joliGem: cached.joliGem || { balance: 0, enableAutoDeduct: false }
70
70
  }
71
71
  };
72
72
  }