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