@jolibox/sdk 1.1.18-beta.5 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
7
- "packages/sdk/package.json": "b65e23c4777c8ceb35e4fccbb12b806852d0004a",
7
+ "packages/sdk/package.json": "f32c4af67dcc643f5a20eb10ecae4a709d6cbeed",
8
8
  "packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
9
9
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
10
10
  "packages/sdk/src/api/can-i-use.ts": "4fd7efe21419d39e535584d7ab8e6a3c4e186877",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertyNames,he=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))_e.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))mt.call(t,r)&&ge(e,r,t[r]);return e},U=(e,t)=>it(e,ct(t));var dt=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!_e.call(e,o)&&o!==r&&D(e,o,{get:()=>t[o],enumerable:!(n=at(t,o))||n.enumerable});return e};var pt=e=>ut(D({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var fr={};dt(fr,{JoliboxSDK:()=>H});module.exports=pt(fr);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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}var Y=Object.defineProperty,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,ye=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&ye(e,r,t[r]);if(Ee)for(var r of Ee(t))Et.call(t,r)&&ye(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),bt=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,n)=>{for(var o=n>1?void 0:n?ht(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Y(t,r,o),o},St=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}function xt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rt(e){return typeof e=="undefined"}function wt(e){return Rt(e)||e===null}function It(e){return typeof e=="function"}function xe(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Tt=(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))(Tt||{}),ee=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Re=class extends ee{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var we=class extends Re{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Re{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Lt});var W=Symbol.for("Jolibox.canIUseMap"),Dt={};globalThis[W]||(globalThis[W]=Dt);var Ie={get config(){return globalThis[W]}};function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<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}}var re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),At=(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))(At||{}),ve=["name","params"],Ut=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function kt(e){let t=e.location?k(e.location,ve):null,r=e.target?k(e.target,ve):null;return k(vt(yt({},e),{location:t,target:r}),Ut)}function Te(e){let t=e.events.map(n=>kt(n)),r=k(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Pt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){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}}oe();var Ct=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Kt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Mt="device_id",jt="advertising_id",Le=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),Nt=()=>new URLSearchParams(window.location.search).get("deviceId")||Le(Mt),Jt=()=>Le(jt),Ft=e=>e.charAt(0).toUpperCase()+e.slice(1),Bt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ft((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},De=e=>{if(Ct())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Kt(),n=navigator.language,o=Nt(),s=Jt();return`${t} (${Bt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},z=class q{constructor(t){this.element=t,this.next=q.Undefined,this.prev=q.Undefined}};z.Undefined=new z(void 0);var d=z,Vt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},$t=0,S=class{constructor(e){this.value=e,this.id=$t++}},x=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 S&&(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,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new S(t);return this._listeners?this._listeners instanceof S?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,pe;if(!this._disposed){if(this._listeners instanceof S)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let fe=this._listeners.indexOf(c);fe>=0&&(this._listeners.splice(fe,1),this._size--,this._size===0&&((pe=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||pe.call(E)))}}}}),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(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof S?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},se=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)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 Vt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},Q={};bt(Q,{None:()=>Ht,filter:()=>Wt,once:()=>Ae,toPromise:()=>Gt});var Ht=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Ae(e)(t))}function Ae(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Wt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var G=Symbol.for("Jolibox.hostEmitter"),zt=()=>{let e=new se;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},C=zt();function qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Qt(e[n],t[n])}function Qt(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(It(t)){try{if(e instanceof t)return}catch(r){}if(!wt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return qt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};P=be([xe],P);var X=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xt(3e4)),this._starActivation}executeCommand(e,...t){return St(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Q.toPromise(Q.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}}};X=be([xe],X);var Ue=Symbol.for("Jolibox.commands");function Xt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function Yt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Xt();if(e)return e;let t=new P,r=new X,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Yt(n),n}var K=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function er(){return{platform:1e3,os:"h5",appVersion:"1.1.18-beta.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.18-beta.5",extra:{}}}var Oe={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},tr=()=>{var t;let e=(t=Oe[window.location.host])!=null?t:Oe.default;return K?e.test:e.prod},rr=tr(),Pe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Pe);var nr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},or=nr(),sr=e=>m(void 0,null,function*(){try{let r=`${rr}/report`,n=De("1.1.18-beta.5"),o=or,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Pe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=er(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Te(o);yield sr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>C.emit("onDocumentReady",w.startTime));var ir=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=ir(),Ce=h(),ie=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof ee?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},ae=ie;window.addEventListener("unhandledrejection",ie.bind(void 0));window.addEventListener("error",ie.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ce(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Ke=h(),M=(e,t)=>{Ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Ne="jolibox-sdk-loadermeta",je,L=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Ne))!=null?je:"{}"),le=Date.now(),Me=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ar(){return m(this,null,function*(){let t=`${K?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(A({},L),{timestamp:le});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=U(A({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=U(A({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ne,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Me(le,c)&&I(i)==t&&T(i,r)>=0&&(n=me(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new we(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();M("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Me(le,u)&&I(c)==t&&T(c,r)>=0&&(o=de(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ar()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Fe=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){ae(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();M("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),ae(new R(`module load failed ${o}`))}}};var cr="1.1.18-beta.5",j=cr,$e=I(j),He=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),lr=He?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,me=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,mr=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=mr(j)?$e:j,Be=me(Ge),Ve=de(Ge);function dr(){He?Fe(lr,{bootstrapUrl:Be,implementUrl:Ve})():Je({bootstrapUrl:Be,implementUrl:Ve,currentMajorVersion:$e,currentVersion:j})()}dr();var We=h();function ze(){return We.excuteCommandSync("API.getSystemInfoSync")}function qe(){return We.excuteCommandSync("API.env")}function Qe(e,t){var r;return(r=Ie.config[e])==null?void 0:r[t]}function Xe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ze="1.1.18-beta.5";function _(e){var l,i;let r=(i=(l=qe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Qe(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||te(Ze,a,"<")?!1:o.length===0?!0:Ye(s,o)||Ye(s.properties,o)}function Ye(e,t){if(!e)return!1;let r=Xe(e,t);return r?Se(r)?!0:Z(r)?te(Ze,r,">="):!1:!1}var et=h();function tt(){return m(this,null,function*(){return _("login")?yield et.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function rt(){return m(this,null,function*(){return _("checkSession")?yield et.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function nt(e){return m(this,null,function*(){return _("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ot=(e,t)=>{C.on(e,t)};var ue=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},st=window.JoliboxRuntime||ue;var p=class{constructor(){this.commands=h();this._emitter=new se}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",N=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(pr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var F=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var $=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.18-beta.5";this.runtime=new st;this.ads=new F;this.lifecycle=new N;this.storage=new J;this.keyboard=new B;this.task=new V;this.router=new $;this.getSystemInfoSync=ze.bind(this);this.canIUse=_.bind(this);this.login=tt.bind(this);this.checkSession=rt.bind(this);this.request=nt.bind(this);this.on=ot.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var H=g;window.JoliboxSDK=H;
1
+ "use strict";var D=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertyNames,he=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))_e.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))mt.call(t,r)&&ge(e,r,t[r]);return e},U=(e,t)=>it(e,ct(t));var dt=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!_e.call(e,o)&&o!==r&&D(e,o,{get:()=>t[o],enumerable:!(n=at(t,o))||n.enumerable});return e};var pt=e=>ut(D({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var fr={};dt(fr,{JoliboxSDK:()=>H});module.exports=pt(fr);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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}var Y=Object.defineProperty,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,ye=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&ye(e,r,t[r]);if(Ee)for(var r of Ee(t))Et.call(t,r)&&ye(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),St=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},Se=(e,t,r,n)=>{for(var o=n>1?void 0:n?ht(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Y(t,r,o),o},bt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}function xt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rt(e){return typeof e=="undefined"}function wt(e){return Rt(e)||e===null}function It(e){return typeof e=="function"}function xe(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Tt=(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))(Tt||{}),ee=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Re=class extends ee{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var we=class extends Re{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Re{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Lt});var W=Symbol.for("Jolibox.canIUseMap"),Dt={};globalThis[W]||(globalThis[W]=Dt);var Ie={get config(){return globalThis[W]}};function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<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}}var re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),At=(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))(At||{}),ve=["name","params"],Ut=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function kt(e){let t=e.location?k(e.location,ve):null,r=e.target?k(e.target,ve):null;return k(vt(yt({},e),{location:t,target:r}),Ut)}function Te(e){let t=e.events.map(n=>kt(n)),r=k(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Pt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){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}}oe();var Ct=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Kt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Mt="device_id",jt="advertising_id",Le=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),Nt=()=>new URLSearchParams(window.location.search).get("deviceId")||Le(Mt),Jt=()=>Le(jt),Ft=e=>e.charAt(0).toUpperCase()+e.slice(1),Bt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ft((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},De=e=>{if(Ct())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Kt(),n=navigator.language,o=Nt(),s=Jt();return`${t} (${Bt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},z=class q{constructor(t){this.element=t,this.next=q.Undefined,this.prev=q.Undefined}};z.Undefined=new z(void 0);var d=z,Vt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},$t=0,b=class{constructor(e){this.value=e,this.id=$t++}},x=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 b&&(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,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,pe;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let fe=this._listeners.indexOf(c);fe>=0&&(this._listeners.splice(fe,1),this._size--,this._size===0&&((pe=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||pe.call(E)))}}}}),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(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},se=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)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 Vt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},Q={};St(Q,{None:()=>Ht,filter:()=>Wt,once:()=>Ae,toPromise:()=>Gt});var Ht=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Ae(e)(t))}function Ae(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Wt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var G=Symbol.for("Jolibox.hostEmitter"),zt=()=>{let e=new se;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},C=zt();function qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Qt(e[n],t[n])}function Qt(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(It(t)){try{if(e instanceof t)return}catch(r){}if(!wt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return qt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};P=Se([xe],P);var X=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xt(3e4)),this._starActivation}executeCommand(e,...t){return bt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Q.toPromise(Q.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}}};X=Se([xe],X);var Ue=Symbol.for("Jolibox.commands");function Xt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function Yt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Xt();if(e)return e;let t=new P,r=new X,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Yt(n),n}var K=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function er(){return{platform:1e3,os:"h5",appVersion:"1.1.18",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.18",extra:{}}}var Oe={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},tr=()=>{var t;let e=(t=Oe[window.location.host])!=null?t:Oe.default;return K?e.test:e.prod},rr=tr(),Pe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Pe);var nr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},or=nr(),sr=e=>m(void 0,null,function*(){try{let r=`${rr}/report`,n=De("1.1.18"),o=or,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Pe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=er(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Te(o);yield sr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>C.emit("onDocumentReady",w.startTime));var ir=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=ir(),Ce=h(),ie=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof ee?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},ae=ie;window.addEventListener("unhandledrejection",ie.bind(void 0));window.addEventListener("error",ie.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ce(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Ke=h(),M=(e,t)=>{Ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Ne="jolibox-sdk-loadermeta",je,L=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Ne))!=null?je:"{}"),le=Date.now(),Me=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ar(){return m(this,null,function*(){let t=`${K?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(A({},L),{timestamp:le});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=U(A({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=U(A({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ne,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Me(le,c)&&I(i)==t&&T(i,r)>=0&&(n=me(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new we(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();M("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Me(le,u)&&I(c)==t&&T(c,r)>=0&&(o=de(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ar()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Fe=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){ae(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();M("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),ae(new R(`module load failed ${o}`))}}};var cr="1.1.18",j=cr,$e=I(j),He=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),lr=He?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,me=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,mr=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=mr(j)?$e:j,Be=me(Ge),Ve=de(Ge);function dr(){He?Fe(lr,{bootstrapUrl:Be,implementUrl:Ve})():Je({bootstrapUrl:Be,implementUrl:Ve,currentMajorVersion:$e,currentVersion:j})()}dr();var We=h();function ze(){return We.excuteCommandSync("API.getSystemInfoSync")}function qe(){return We.excuteCommandSync("API.env")}function Qe(e,t){var r;return(r=Ie.config[e])==null?void 0:r[t]}function Xe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ze="1.1.18";function _(e){var l,i;let r=(i=(l=qe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Qe(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||te(Ze,a,"<")?!1:o.length===0?!0:Ye(s,o)||Ye(s.properties,o)}function Ye(e,t){if(!e)return!1;let r=Xe(e,t);return r?be(r)?!0:Z(r)?te(Ze,r,">="):!1:!1}var et=h();function tt(){return m(this,null,function*(){return _("login")?yield et.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function rt(){return m(this,null,function*(){return _("checkSession")?yield et.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function nt(e){return m(this,null,function*(){return _("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ot=(e,t)=>{C.on(e,t)};var ue=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},st=window.JoliboxRuntime||ue;var p=class{constructor(){this.commands=h();this._emitter=new se}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",N=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(pr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var F=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var $=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.18";this.runtime=new st;this.ads=new F;this.lifecycle=new N;this.storage=new J;this.keyboard=new B;this.task=new V;this.router=new $;this.getSystemInfoSync=ze.bind(this);this.canIUse=_.bind(this);this.login=tt.bind(this);this.checkSession=rt.bind(this);this.request=nt.bind(this);this.on=ot.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var H=g;window.JoliboxSDK=H;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))ct.call(t,r)&&he(e,r,t[r]);return e},A=(e,t)=>st(e,it(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}var Q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))pt.call(t,r)&&_e(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Q(t,r,o),o},_t=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}function Et(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function bt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var St=(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))(St||{}),Y=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}},Se=class extends Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var xe=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var xt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:xt});var H=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[H]||(globalThis[H]=Rt);var Re={get config(){return globalThis[H]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<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}}var ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),wt=(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))(wt||{}),Ee=["name","params"],It=["name","type","location","target","extra","timestamp","userId"],Tt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Lt(e){let t=e.location?O(e.location,Ee):null,r=e.target?O(e.target,Ee):null;return O(ht(ft({},e),{location:t,target:r}),It)}function we(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);return[e.protocolVersion,t,r,e.project]}var Dt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function re(){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}}re();var At=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),U={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ut=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ot="device_id",kt="advertising_id",Ie=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),Pt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ie(Ot),Ct=()=>Ie(kt),Kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Mt=()=>{var e;let t=new URLSearchParams(window.location.search);return Kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Te=e=>{if(At())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ut(),n=navigator.language,o=Pt(),s=Ct();return`${t} (${Mt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};G.Undefined=new G(void 0);var d=G,jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Nt=0,S=class{constructor(e){this.value=e,this.id=Nt++}},x=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 S&&(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,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new S(t);return this._listeners?this._listeners instanceof S?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof S)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),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(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof S?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)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 jt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},z={};gt(z,{None:()=>Jt,filter:()=>Bt,once:()=>Le,toPromise:()=>Ft});var Jt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ft(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Bt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Vt=()=>{let e=new ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ht(e[n],t[n])}function Ht(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(bt(t)){try{if(e instanceof t)return}catch(r){}if(!vt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return $t(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=ye([be],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.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}}};q=ye([be],q);var De=Symbol.for("Jolibox.commands");function Gt(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Gt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Wt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function qt(){return{platform:1e3,os:"h5",appVersion:"1.1.18-beta.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.18-beta.5",extra:{}}}var Ae={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Yt(),er=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Te("1.1.18-beta.5"),o=Zt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=we(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=tr(),ke=h(),oe=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof Y?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ie=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Pe=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Me="jolibox-sdk-loadermeta",Ke,L=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ae=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function rr(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Me,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ce(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new xe(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),rr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Ne=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var nr="1.1.18-beta.5",M=nr,Be=I(M),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),or=Ve?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(M)?Be:M,Je=ce($e),Fe=le($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}ir();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.config[e])==null?void 0:r[t]}function qe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Xe="1.1.18-beta.5";function _(e){var l,i;let r=(i=(l=We().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=ze(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Z(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ve(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ye=h();function Ze(){return m(this,null,function*(){return _("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return _("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=h();function tt(e){return m(this,null,function*(){return _("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};var me=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},nt=window.JoliboxRuntime||me;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(cr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var N=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.18-beta.5";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var de=g;window.JoliboxSDK=de;export{de as JoliboxSDK};
1
+ var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))ct.call(t,r)&&he(e,r,t[r]);return e},A=(e,t)=>st(e,it(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}var Q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))pt.call(t,r)&&_e(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Q(t,r,o),o},_t=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}function Et(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function St(e){return typeof e=="function"}function Se(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var bt=(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))(bt||{}),Y=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}},be=class extends Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var xe=class extends be{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends be{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var xt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:xt});var H=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[H]||(globalThis[H]=Rt);var Re={get config(){return globalThis[H]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<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}}var ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),wt=(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))(wt||{}),Ee=["name","params"],It=["name","type","location","target","extra","timestamp","userId"],Tt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Lt(e){let t=e.location?O(e.location,Ee):null,r=e.target?O(e.target,Ee):null;return O(ht(ft({},e),{location:t,target:r}),It)}function we(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);return[e.protocolVersion,t,r,e.project]}var Dt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function re(){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}}re();var At=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),U={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ut=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ot="device_id",kt="advertising_id",Ie=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),Pt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ie(Ot),Ct=()=>Ie(kt),Kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Mt=()=>{var e;let t=new URLSearchParams(window.location.search);return Kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Te=e=>{if(At())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ut(),n=navigator.language,o=Pt(),s=Ct();return`${t} (${Mt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};G.Undefined=new G(void 0);var d=G,jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Nt=0,b=class{constructor(e){this.value=e,this.id=Nt++}},x=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 b&&(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,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),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(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)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 jt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},z={};gt(z,{None:()=>Jt,filter:()=>Bt,once:()=>Le,toPromise:()=>Ft});var Jt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ft(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Bt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Vt=()=>{let e=new ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ht(e[n],t[n])}function Ht(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(St(t)){try{if(e instanceof t)return}catch(r){}if(!vt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return $t(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=ye([Se],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.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}}};q=ye([Se],q);var De=Symbol.for("Jolibox.commands");function Gt(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Gt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Wt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function qt(){return{platform:1e3,os:"h5",appVersion:"1.1.18",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.18",extra:{}}}var Ae={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Yt(),er=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Te("1.1.18"),o=Zt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=we(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=tr(),ke=h(),oe=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof Y?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ie=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Pe=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Me="jolibox-sdk-loadermeta",Ke,L=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ae=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function rr(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Me,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ce(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new xe(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),rr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Ne=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var nr="1.1.18",M=nr,Be=I(M),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),or=Ve?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(M)?Be:M,Je=ce($e),Fe=le($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}ir();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.config[e])==null?void 0:r[t]}function qe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Xe="1.1.18";function _(e){var l,i;let r=(i=(l=We().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=ze(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Z(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ve(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ye=h();function Ze(){return m(this,null,function*(){return _("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return _("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=h();function tt(e){return m(this,null,function*(){return _("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};var me=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},nt=window.JoliboxRuntime||me;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(cr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var N=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.18";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var de=g;window.JoliboxSDK=de;export{de as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))ct.call(t,r)&&he(e,r,t[r]);return e},A=(e,t)=>st(e,it(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}var Q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))pt.call(t,r)&&_e(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Q(t,r,o),o},_t=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}function Et(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function bt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var St=(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))(St||{}),Y=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}},Se=class extends Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var xe=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var xt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:xt});var H=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[H]||(globalThis[H]=Rt);var Re={get config(){return globalThis[H]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<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}}var ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),wt=(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))(wt||{}),Ee=["name","params"],It=["name","type","location","target","extra","timestamp","userId"],Tt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Lt(e){let t=e.location?O(e.location,Ee):null,r=e.target?O(e.target,Ee):null;return O(ht(ft({},e),{location:t,target:r}),It)}function we(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);return[e.protocolVersion,t,r,e.project]}var Dt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function re(){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}}re();var At=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),U={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ut=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ot="device_id",kt="advertising_id",Ie=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),Pt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ie(Ot),Ct=()=>Ie(kt),Kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Mt=()=>{var e;let t=new URLSearchParams(window.location.search);return Kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Te=e=>{if(At())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ut(),n=navigator.language,o=Pt(),s=Ct();return`${t} (${Mt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};G.Undefined=new G(void 0);var d=G,jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Nt=0,S=class{constructor(e){this.value=e,this.id=Nt++}},x=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 S&&(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,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new S(t);return this._listeners?this._listeners instanceof S?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof S)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),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(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof S?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)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 jt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},z={};gt(z,{None:()=>Jt,filter:()=>Bt,once:()=>Le,toPromise:()=>Ft});var Jt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ft(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Bt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Vt=()=>{let e=new ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ht(e[n],t[n])}function Ht(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(bt(t)){try{if(e instanceof t)return}catch(r){}if(!vt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return $t(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=ye([be],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.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}}};q=ye([be],q);var De=Symbol.for("Jolibox.commands");function Gt(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Gt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Wt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function qt(){return{platform:1e3,os:"h5",appVersion:"1.1.18-beta.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.18-beta.5",extra:{}}}var Ae={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Yt(),er=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Te("1.1.18-beta.5"),o=Zt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=we(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=tr(),ke=h(),oe=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof Y?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ie=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Pe=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Me="jolibox-sdk-loadermeta",Ke,L=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ae=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function rr(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Me,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ce(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new xe(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),rr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Ne=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var nr="1.1.18-beta.5",M=nr,Be=I(M),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),or=Ve?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(M)?Be:M,Je=ce($e),Fe=le($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}ir();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.config[e])==null?void 0:r[t]}function qe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Xe="1.1.18-beta.5";function _(e){var l,i;let r=(i=(l=We().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=ze(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Z(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ve(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ye=h();function Ze(){return m(this,null,function*(){return _("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return _("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=h();function tt(e){return m(this,null,function*(){return _("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};var me=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},nt=window.JoliboxRuntime||me;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(cr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var N=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.18-beta.5";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var de=g;window.JoliboxSDK=de;})();
1
+ "use strict";(()=>{var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))ct.call(t,r)&&he(e,r,t[r]);return e},A=(e,t)=>st(e,it(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}var Q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))pt.call(t,r)&&_e(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Q(t,r,o),o},_t=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,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}function Et(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function St(e){return typeof e=="function"}function Se(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var bt=(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))(bt||{}),Y=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}},be=class extends Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var xe=class extends be{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends be{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var xt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:xt});var H=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[H]||(globalThis[H]=Rt);var Re={get config(){return globalThis[H]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<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}}var ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),wt=(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))(wt||{}),Ee=["name","params"],It=["name","type","location","target","extra","timestamp","userId"],Tt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Lt(e){let t=e.location?O(e.location,Ee):null,r=e.target?O(e.target,Ee):null;return O(ht(ft({},e),{location:t,target:r}),It)}function we(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);return[e.protocolVersion,t,r,e.project]}var Dt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function re(){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}}re();var At=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),U={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ut=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ot="device_id",kt="advertising_id",Ie=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),Pt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ie(Ot),Ct=()=>Ie(kt),Kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Mt=()=>{var e;let t=new URLSearchParams(window.location.search);return Kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Te=e=>{if(At())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ut(),n=navigator.language,o=Pt(),s=Ct();return`${t} (${Mt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};G.Undefined=new G(void 0);var d=G,jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Nt=0,b=class{constructor(e){this.value=e,this.id=Nt++}},x=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 b&&(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,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),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(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)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 jt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},z={};gt(z,{None:()=>Jt,filter:()=>Bt,once:()=>Le,toPromise:()=>Ft});var Jt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ft(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Bt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Vt=()=>{let e=new ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ht(e[n],t[n])}function Ht(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(St(t)){try{if(e instanceof t)return}catch(r){}if(!vt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return $t(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=ye([Se],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.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}}};q=ye([Se],q);var De=Symbol.for("Jolibox.commands");function Gt(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Gt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Wt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function qt(){return{platform:1e3,os:"h5",appVersion:"1.1.18",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.18",extra:{}}}var Ae={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Yt(),er=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Te("1.1.18"),o=Zt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=we(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=tr(),ke=h(),oe=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof Y?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ie=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Pe=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Me="jolibox-sdk-loadermeta",Ke,L=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ae=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function rr(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Me,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ce(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new xe(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),rr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Ne=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var nr="1.1.18",M=nr,Be=I(M),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),or=Ve?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(M)?Be:M,Je=ce($e),Fe=le($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}ir();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.config[e])==null?void 0:r[t]}function qe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Xe="1.1.18";function _(e){var l,i;let r=(i=(l=We().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=ze(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Z(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ve(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ye=h();function Ze(){return m(this,null,function*(){return _("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return _("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=h();function tt(e){return m(this,null,function*(){return _("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};var me=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},nt=window.JoliboxRuntime||me;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(cr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var N=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.18";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var de=g;window.JoliboxSDK=de;})();
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.1.18-beta.5",
4
+ "version": "1.1.18",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "@jolibox/common": "1.1.18-beta.5",
11
- "@jolibox/types": "1.1.18-beta.5"
10
+ "@jolibox/common": "1.1.18",
11
+ "@jolibox/types": "1.1.18"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
package/sdk.build.log CHANGED
@@ -1,17 +1,17 @@
1
1
  Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
2
2
 
3
- > @jolibox/sdk@1.1.18-beta.5 clean
3
+ > @jolibox/sdk@1.1.18 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.1.18-beta.5 build:cjs
7
+ > @jolibox/sdk@1.1.18 build:cjs
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
9
9
 
10
10
 
11
- > @jolibox/sdk@1.1.18-beta.5 build:esm
11
+ > @jolibox/sdk@1.1.18 build:esm
12
12
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
13
13
 
14
14
 
15
- > @jolibox/sdk@1.1.18-beta.5 build:iife
15
+ > @jolibox/sdk@1.1.18 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17