@jolibox/sdk 1.1.4-beta.12 → 1.1.4-beta.14

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