@jolibox/sdk 1.1.27 → 1.1.28
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.
- package/.rush/temp/package-deps_build.json +15 -15
- package/.rush/temp/shrinkwrap-deps.json +7 -2
- package/dist/api/can-i-use.d.ts +27 -0
- package/dist/api/get-system-info.d.ts +26 -2
- package/dist/api/login.d.ts +31 -4
- package/dist/api/on-custom-event.d.ts +27 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +126 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +224 -9
- package/dist/sdks/ads.d.ts +11 -2
- package/dist/sdks/keyboard.d.ts +7 -3
- package/dist/sdks/lifecycle.d.ts +37 -2
- package/dist/sdks/router.d.ts +47 -6
- package/dist/sdks/runtime.d.ts +2 -2
- package/dist/sdks/sdk.d.ts +8 -0
- package/dist/sdks/storage.d.ts +34 -3
- package/dist/sdks/task.d.ts +6 -0
- package/package.json +14 -3
- package/sdk.build.log +4 -4
- package/src/api/can-i-use.ts +27 -0
- package/src/api/get-system-info.ts +28 -2
- package/src/api/login.ts +37 -5
- package/src/api/on-custom-event.ts +40 -9
- package/src/index.ts +137 -2
- package/src/sdks/ads.ts +14 -1
- package/src/sdks/keyboard.ts +7 -3
- package/src/sdks/lifecycle.ts +41 -4
- package/src/sdks/router.ts +59 -10
- package/src/sdks/runtime.ts +2 -1
- package/src/sdks/sdk.ts +9 -0
- package/src/sdks/storage.ts +38 -7
- package/src/sdks/task.ts +6 -0
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var lt=Object.defineProperty,mt=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var ye=(e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&ye(e,r,t[r]);if(_e)for(var r of _e(t))pt.call(t,r)&&ye(e,r,t[r]);return e},O=(e,t)=>mt(e,dt(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 Z=Object.defineProperty,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&be(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&be(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),bt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},xe=(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&&Z(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 ee(e){return typeof e=="string"}function Re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rt(e){return typeof e=="undefined"}function It(e){return Rt(e)||e===null}function wt(e){return typeof e=="function"}function Ie(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||{}),K=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}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Te=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var At={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:At});var z=Symbol.for("Jolibox.canIUseMap"),Lt={};globalThis[z]||(globalThis[z]=Lt);var Ae={get config(){return globalThis[z]}};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||{}),Dt=(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))(Dt||{}),Se=["name","params"],Pt=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(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 Ut(e){let t=e.location?C(e.location,Se):null,r=e.target?C(e.target,Se):null;return C(vt(yt({},e),{location:t,target:r}),Pt)}function Le(e){let t=e.events.map(n=>Ut(n)),r=C(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Ct=()=>"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 se=()=>!!(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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Kt="device_id",Nt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ct()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Kt),jt=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(Nt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Pe=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Bt=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}},Vt=0,R=class{constructor(e){this.value=e,this.id=Vt++}},I=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 R&&(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 R(t);return this._listeners?this._listeners instanceof R?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,_,ge;if(!this._disposed){if(this._listeners instanceof R)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 Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||ge.call(_)))}}}}),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 R?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.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 Bt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};bt(q,{None:()=>$t,filter:()=>Ht,once:()=>Oe,toPromise:()=>Gt});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ht(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Wt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Wt();function zt(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(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 I,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 zt(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=xe([Ie],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,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=xe([Ie],X);var Ue=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Yt();if(e)return e;let t=new k,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 qt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.27",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.27",extra:{}}}var Ce={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"}},er=()=>{var t;let e=(t=Ce[window.location.host])!=null?t:Ce.default;return M?e.test:e.prod},tr=er(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>m(void 0,null,function*(){try{let r=`${tr}/report`,n=Pe("1.1.27"),o=nr,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:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Le(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=sr(),Ne=h(),ae=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 K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.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()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{b({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}},A=e=>parseInt(ce(e).major,10),L=(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 Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},S=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Fe="jolibox-sdk-loadermeta",Je,D=JSON.parse((Je=window.__joliboxLocalStorage__.getItem(Fe))!=null?Je:"{}"),le=Date.now(),je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){return m(this,null,function*(){let t=`${M?"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=O(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&L(a,o)>=0||(s=O(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&L(a,n)>=0||(s=O(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Fe,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Be=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!je(le,c)&&A(i)==t&&L(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 Te(`Bootstrap module faile to fetch ${u}`);b({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let _=document.createElement("script");_.type="text/javascript",_.innerHTML=c,document.head.appendChild(_),S("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!je(le,u)&&A(c)==t&&L(c,r)>=0&&(o=de(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{S("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new w(`module evaluate error: ${i}`);b({err:`${c}`})}}};var Ve=(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){y(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),S("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),S("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new w(`module load failed ${o}`))}}};var ar="1.1.27",J=ar,We=A(J),ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=ze?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,ue="https://jsdelivr.jolibox.com",$e=window.document.currentScript;$e&&(ue=new URL($e.src).origin);var me=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=lr(J)?We:J,Ge=me(Qe),He=de(Qe);function mr(){ze?Ve(cr,{bootstrapUrl:Ge,implementUrl:He})():Be({bootstrapUrl:Ge,implementUrl:He,currentMajorVersion:We,currentVersion:J})()}mr();var dr=h();function Ye(){return dr.excuteCommandSync("API.getSystemInfoSync")}function qe(e,t){var r;return(r=Ae.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 et="1.1.27";function E(e){let[t,...r]=e.split(":"),n=qe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(et,o,"<")?!1:r.length===0?!0:Ze(n,r)||Ze(n.properties,r)}function Ze(e,t){if(!e)return!1;let r=Xe(e,t);return r?Re(r)?!0:ee(r)?te(et,r,">="):!1:!1}var tt=h();function rt(){return m(this,null,function*(){return E("login")?yield tt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function nt(){return m(this,null,function*(){return E("checkSession")?yield tt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function ot(e){return m(this,null,function*(){return E("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],st=(e,t)=>{pe.includes(e)||y(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3)),v.on(e,t)},it=(e,t)=>{pe.includes(e)||y(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3)),v.off(e,t)},at=(e,t)=>{pe.includes(e)||y(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3)),v.once(e,t)};var fe=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)}}},ct=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",F=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 B=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 V=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 $=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 G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var fr=["openHistory"],H=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))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(fr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.27";this.runtime=new ct;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=rt.bind(this);this.checkSession=nt.bind(this);this.request=ot.bind(this);this.on=st.bind(this);this.off=it.bind(this);this.once=at.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 he=g;window.JoliboxSDK=he;export{he as JoliboxSDK};
|
|
1
|
+
var lt=Object.defineProperty,dt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))pt.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>dt(e,mt(t));var d=(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 Z=Object.defineProperty,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_t=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))yt.call(t,r)&&Se(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),St=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},Re=(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&&Z(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 Rt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function xt(e){return typeof e=="undefined"}function It(e){return xt(e)||e===null}function wt(e){return typeof e=="function"}function Ie(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||{}),K=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}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Te=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Lt});var z=Symbol.for("Jolibox.canIUseMap"),At={};globalThis[z]||(globalThis[z]=At);var Le={get config(){return globalThis[z]}};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||{}),Dt=(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))(Dt||{}),be=["name","params"],Pt=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(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 Ut(e){let t=e.location?C(e.location,be):null,r=e.target?C(e.target,be):null;return C(vt(_t({},e),{location:t,target:r}),Pt)}function Ae(e){let t=e.events.map(n=>Ut(n)),r=C(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Ct=()=>"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 se=()=>!!(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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Kt="device_id",Nt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ct()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Kt),jt=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(Nt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Pe=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var m=Q,Bt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Vt=0,x=class{constructor(e){this.value=e,this.id=Vt++}},I=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 x&&(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 x(t);return this._listeners?this._listeners instanceof x?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,y,ge;if(!this._disposed){if(this._listeners instanceof x)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 Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.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 Bt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};St(q,{None:()=>$t,filter:()=>Ht,once:()=>Oe,toPromise:()=>Gt});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ht(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Wt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Wt();function zt(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(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 I,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 zt(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=Re([Ie],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Rt(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=Re([Ie],X);var Ue=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Yt();if(e)return e;let t=new k,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 qt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.28",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.28",extra:{}}}var Ce={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"}},er=()=>{var t;let e=(t=Ce[window.location.host])!=null?t:Ce.default;return M?e.test:e.prod},tr=er(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>d(void 0,null,function*(){try{let r=`${tr}/report`,n=Pe("1.1.28"),o=nr,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:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Ae(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=sr(),Ne=h(),ae=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 K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.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()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({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}},L=e=>parseInt(ce(e).major,10),A=(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 Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Fe="jolibox-sdk-loadermeta",Je,D=JSON.parse((Je=window.__joliboxLocalStorage__.getItem(Fe))!=null?Je:"{}"),le=Date.now(),je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){return d(this,null,function*(){let t=`${M?"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=O(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=O(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=O(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Fe,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Be=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=de(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 Te(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!je(le,u)&&L(c)==t&&A(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Ve=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(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){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var ar="1.1.28",J=ar,We=L(J),ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=ze?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,ue="https://jsdelivr.jolibox.com",$e=window.document.currentScript;$e&&(ue=new URL($e.src).origin);var de=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=lr(J)?We:J,Ge=de(Qe),He=me(Qe);function dr(){ze?Ve(cr,{bootstrapUrl:Ge,implementUrl:He})():Be({bootstrapUrl:Ge,implementUrl:He,currentMajorVersion:We,currentVersion:J})()}dr();var mr=h();function Ye(){return mr.excuteCommandSync("API.getSystemInfoSync")}function qe(e,t){var r;return(r=Le.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 et="1.1.28";function E(e){let[t,...r]=e.split(":"),n=qe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(et,o,"<")?!1:r.length===0?!0:Ze(n,r)||Ze(n.properties,r)}function Ze(e,t){if(!e)return!1;let r=Xe(e,t);return r?xe(r)?!0:ee(r)?te(et,r,">="):!1:!1}var tt=h();function rt(){return d(this,null,function*(){return E("login")?yield tt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function nt(){return d(this,null,function*(){return E("checkSession")?yield tt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function ot(e){return d(this,null,function*(){return E("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],st=(e,t)=>{if(!pe.includes(e)){_(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},it=(e,t)=>{if(!pe.includes(e)){_(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},at=(e,t)=>{if(!pe.includes(e)){_(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var fe=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)}}},ct=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",F=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 B=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=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)}}initAd(r){return d(this,null,function*(){})}};var $=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 G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var fr=["openHistory"],H=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(fr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.28";this.runtime=new ct;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=rt.bind(this);this.checkSession=nt.bind(this);this.request=ot.bind(this);this.on=st.bind(this);this.off=it.bind(this);this.once=at.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 he=g;window.JoliboxSDK=he;export{he as JoliboxSDK};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var lt=Object.defineProperty,mt=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var ye=(e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&ye(e,r,t[r]);if(_e)for(var r of _e(t))pt.call(t,r)&&ye(e,r,t[r]);return e},O=(e,t)=>mt(e,dt(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 Z=Object.defineProperty,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&be(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&be(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),bt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},xe=(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&&Z(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 ee(e){return typeof e=="string"}function Re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rt(e){return typeof e=="undefined"}function It(e){return Rt(e)||e===null}function wt(e){return typeof e=="function"}function Ie(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||{}),K=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}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Te=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var At={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:At});var z=Symbol.for("Jolibox.canIUseMap"),Lt={};globalThis[z]||(globalThis[z]=Lt);var Ae={get config(){return globalThis[z]}};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||{}),Dt=(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))(Dt||{}),Se=["name","params"],Pt=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(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 Ut(e){let t=e.location?C(e.location,Se):null,r=e.target?C(e.target,Se):null;return C(vt(yt({},e),{location:t,target:r}),Pt)}function Le(e){let t=e.events.map(n=>Ut(n)),r=C(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Ct=()=>"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 se=()=>!!(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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Kt="device_id",Nt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ct()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Kt),jt=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(Nt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Pe=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Bt=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}},Vt=0,R=class{constructor(e){this.value=e,this.id=Vt++}},I=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 R&&(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 R(t);return this._listeners?this._listeners instanceof R?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,_,ge;if(!this._disposed){if(this._listeners instanceof R)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 Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||ge.call(_)))}}}}),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 R?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.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 Bt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};bt(q,{None:()=>$t,filter:()=>Ht,once:()=>Oe,toPromise:()=>Gt});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ht(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Wt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Wt();function zt(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(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 I,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 zt(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=xe([Ie],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,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=xe([Ie],X);var Ue=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Yt();if(e)return e;let t=new k,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 qt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.27",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.27",extra:{}}}var Ce={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"}},er=()=>{var t;let e=(t=Ce[window.location.host])!=null?t:Ce.default;return M?e.test:e.prod},tr=er(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>m(void 0,null,function*(){try{let r=`${tr}/report`,n=Pe("1.1.27"),o=nr,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:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Le(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=sr(),Ne=h(),ae=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 K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.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()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{b({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}},A=e=>parseInt(ce(e).major,10),L=(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 Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},S=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Fe="jolibox-sdk-loadermeta",Je,D=JSON.parse((Je=window.__joliboxLocalStorage__.getItem(Fe))!=null?Je:"{}"),le=Date.now(),je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){return m(this,null,function*(){let t=`${M?"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=O(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&L(a,o)>=0||(s=O(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&L(a,n)>=0||(s=O(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Fe,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Be=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!je(le,c)&&A(i)==t&&L(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 Te(`Bootstrap module faile to fetch ${u}`);b({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let _=document.createElement("script");_.type="text/javascript",_.innerHTML=c,document.head.appendChild(_),S("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!je(le,u)&&A(c)==t&&L(c,r)>=0&&(o=de(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{S("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new w(`module evaluate error: ${i}`);b({err:`${c}`})}}};var Ve=(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){y(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),S("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),S("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new w(`module load failed ${o}`))}}};var ar="1.1.27",J=ar,We=A(J),ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=ze?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,ue="https://jsdelivr.jolibox.com",$e=window.document.currentScript;$e&&(ue=new URL($e.src).origin);var me=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=lr(J)?We:J,Ge=me(Qe),He=de(Qe);function mr(){ze?Ve(cr,{bootstrapUrl:Ge,implementUrl:He})():Be({bootstrapUrl:Ge,implementUrl:He,currentMajorVersion:We,currentVersion:J})()}mr();var dr=h();function Ye(){return dr.excuteCommandSync("API.getSystemInfoSync")}function qe(e,t){var r;return(r=Ae.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 et="1.1.27";function E(e){let[t,...r]=e.split(":"),n=qe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(et,o,"<")?!1:r.length===0?!0:Ze(n,r)||Ze(n.properties,r)}function Ze(e,t){if(!e)return!1;let r=Xe(e,t);return r?Re(r)?!0:ee(r)?te(et,r,">="):!1:!1}var tt=h();function rt(){return m(this,null,function*(){return E("login")?yield tt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function nt(){return m(this,null,function*(){return E("checkSession")?yield tt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function ot(e){return m(this,null,function*(){return E("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],st=(e,t)=>{pe.includes(e)||y(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3)),v.on(e,t)},it=(e,t)=>{pe.includes(e)||y(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3)),v.off(e,t)},at=(e,t)=>{pe.includes(e)||y(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3)),v.once(e,t)};var fe=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)}}},ct=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",F=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 B=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 V=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 $=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 G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var fr=["openHistory"],H=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))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(fr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.27";this.runtime=new ct;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=rt.bind(this);this.checkSession=nt.bind(this);this.request=ot.bind(this);this.on=st.bind(this);this.off=it.bind(this);this.once=at.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 he=g;window.JoliboxSDK=he;})();
|
|
1
|
+
"use strict";(()=>{var lt=Object.defineProperty,dt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))pt.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>dt(e,mt(t));var d=(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 Z=Object.defineProperty,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_t=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))yt.call(t,r)&&Se(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),St=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},Re=(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&&Z(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 Rt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function xt(e){return typeof e=="undefined"}function It(e){return xt(e)||e===null}function wt(e){return typeof e=="function"}function Ie(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||{}),K=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}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Te=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Lt});var z=Symbol.for("Jolibox.canIUseMap"),At={};globalThis[z]||(globalThis[z]=At);var Le={get config(){return globalThis[z]}};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||{}),Dt=(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))(Dt||{}),be=["name","params"],Pt=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(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 Ut(e){let t=e.location?C(e.location,be):null,r=e.target?C(e.target,be):null;return C(vt(_t({},e),{location:t,target:r}),Pt)}function Ae(e){let t=e.events.map(n=>Ut(n)),r=C(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Ct=()=>"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 se=()=>!!(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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Kt="device_id",Nt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ct()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Kt),jt=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(Nt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Pe=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var m=Q,Bt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Vt=0,x=class{constructor(e){this.value=e,this.id=Vt++}},I=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 x&&(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 x(t);return this._listeners?this._listeners instanceof x?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,y,ge;if(!this._disposed){if(this._listeners instanceof x)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 Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.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 Bt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};St(q,{None:()=>$t,filter:()=>Ht,once:()=>Oe,toPromise:()=>Gt});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ht(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Wt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Wt();function zt(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(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 I,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 zt(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=Re([Ie],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Rt(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=Re([Ie],X);var Ue=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Yt();if(e)return e;let t=new k,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 qt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.28",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.28",extra:{}}}var Ce={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"}},er=()=>{var t;let e=(t=Ce[window.location.host])!=null?t:Ce.default;return M?e.test:e.prod},tr=er(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>d(void 0,null,function*(){try{let r=`${tr}/report`,n=Pe("1.1.28"),o=nr,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:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Ae(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=sr(),Ne=h(),ae=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 K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.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()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({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}},L=e=>parseInt(ce(e).major,10),A=(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 Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Fe="jolibox-sdk-loadermeta",Je,D=JSON.parse((Je=window.__joliboxLocalStorage__.getItem(Fe))!=null?Je:"{}"),le=Date.now(),je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){return d(this,null,function*(){let t=`${M?"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=O(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=O(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=O(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Fe,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Be=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=de(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 Te(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!je(le,u)&&L(c)==t&&A(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Ve=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(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){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var ar="1.1.28",J=ar,We=L(J),ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=ze?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,ue="https://jsdelivr.jolibox.com",$e=window.document.currentScript;$e&&(ue=new URL($e.src).origin);var de=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=lr(J)?We:J,Ge=de(Qe),He=me(Qe);function dr(){ze?Ve(cr,{bootstrapUrl:Ge,implementUrl:He})():Be({bootstrapUrl:Ge,implementUrl:He,currentMajorVersion:We,currentVersion:J})()}dr();var mr=h();function Ye(){return mr.excuteCommandSync("API.getSystemInfoSync")}function qe(e,t){var r;return(r=Le.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 et="1.1.28";function E(e){let[t,...r]=e.split(":"),n=qe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(et,o,"<")?!1:r.length===0?!0:Ze(n,r)||Ze(n.properties,r)}function Ze(e,t){if(!e)return!1;let r=Xe(e,t);return r?xe(r)?!0:ee(r)?te(et,r,">="):!1:!1}var tt=h();function rt(){return d(this,null,function*(){return E("login")?yield tt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function nt(){return d(this,null,function*(){return E("checkSession")?yield tt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function ot(e){return d(this,null,function*(){return E("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],st=(e,t)=>{if(!pe.includes(e)){_(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},it=(e,t)=>{if(!pe.includes(e)){_(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},at=(e,t)=>{if(!pe.includes(e)){_(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var fe=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)}}},ct=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",F=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 B=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=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)}}initAd(r){return d(this,null,function*(){})}};var $=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 G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var fr=["openHistory"],H=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(fr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.28";this.runtime=new ct;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=rt.bind(this);this.checkSession=nt.bind(this);this.request=ot.bind(this);this.on=st.bind(this);this.off=it.bind(this);this.once=at.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 he=g;window.JoliboxSDK=he;})();
|