@jolibox/implement 1.1.4-beta.10
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/.eslintrc.js +13 -0
- package/.rush/temp/package-deps_build.json +105 -0
- package/.rush/temp/shrinkwrap-deps.json +79 -0
- package/README.md +1 -0
- package/dist/common/api-factory/index.d.ts +21 -0
- package/dist/common/api-factory/validator/__tests__/validate/any.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/array.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/arraybuffer.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/boolean.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/enum.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/function.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/literal.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/nullish.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/number.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/object.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/or.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/record.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/string.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/symbol.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/tuple.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/type-asserts.test.d.ts +1 -0
- package/dist/common/api-factory/validator/__tests__/validate/utils.test.d.ts +1 -0
- package/dist/common/api-factory/validator/index.d.ts +29 -0
- package/dist/common/api-factory/validator/validate.d.ts +119 -0
- package/dist/common/can-i-use.d.ts +2 -0
- package/dist/common/context/index.d.ts +16 -0
- package/dist/common/context/types.d.ts +5 -0
- package/dist/common/context/url-parse.d.ts +22 -0
- package/dist/common/http/index.d.ts +13 -0
- package/dist/common/http/uuid.d.ts +2 -0
- package/dist/common/http/xua.d.ts +17 -0
- package/dist/common/report/base-tracker.d.ts +13 -0
- package/dist/common/report/create-trace.d.ts +7 -0
- package/dist/common/report/errors/error-types.d.ts +122 -0
- package/dist/common/report/errors/index.d.ts +13 -0
- package/dist/common/report/errors/report/index.d.ts +51 -0
- package/dist/common/report/errors/report/listeners.d.ts +1 -0
- package/dist/common/report/index.d.ts +3 -0
- package/dist/common/report/task-track/index.d.ts +25 -0
- package/dist/common/report/track.d.ts +3 -0
- package/dist/common/report/types.d.ts +75 -0
- package/dist/h5/ads/ads-action-detection.d.ts +6 -0
- package/dist/h5/ads/anti-cheating.d.ts +61 -0
- package/dist/h5/ads/index.d.ts +275 -0
- package/dist/h5/api/base.d.ts +13 -0
- package/dist/h5/api/get-system-info.d.ts +1 -0
- package/dist/h5/api/index.d.ts +4 -0
- package/dist/h5/api/lifecycle.d.ts +1 -0
- package/dist/h5/api/storage.d.ts +27 -0
- package/dist/h5/api/task.d.ts +1 -0
- package/dist/h5/bootstrap/index.d.ts +1 -0
- package/dist/h5/http/index.d.ts +33 -0
- package/dist/h5/http/utils/__tests__/uuid.test.d.ts +1 -0
- package/dist/h5/http/utils/__tests__/xua.test.d.ts +1 -0
- package/dist/h5/http/utils/index.d.ts +14 -0
- package/dist/h5/http/utils/session.d.ts +1 -0
- package/dist/h5/report/errors/index.d.ts +4 -0
- package/dist/h5/report/event-tracker.d.ts +8 -0
- package/dist/h5/report/index.d.ts +10 -0
- package/dist/h5/report/task-tracker.d.ts +18 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -0
- package/dist/index.native.d.ts +2 -0
- package/dist/index.native.js +3 -0
- package/dist/native/api/ads.d.ts +1 -0
- package/dist/native/api/base.d.ts +13 -0
- package/dist/native/api/get-system-info.d.ts +1 -0
- package/dist/native/api/index.d.ts +8 -0
- package/dist/native/api/keyboard.d.ts +9 -0
- package/dist/native/api/lifecycle.d.ts +1 -0
- package/dist/native/api/login.d.ts +1 -0
- package/dist/native/api/request.d.ts +1 -0
- package/dist/native/api/storage.d.ts +25 -0
- package/dist/native/api/task.d.ts +1 -0
- package/dist/native/bootstrap/bridge.d.ts +4 -0
- package/dist/native/bootstrap/index.d.ts +1 -0
- package/dist/native/js-bridge/const.d.ts +5 -0
- package/dist/native/js-bridge/index.d.ts +2 -0
- package/dist/native/js-bridge/invoke.d.ts +21 -0
- package/dist/native/js-bridge/js-bridge.d.ts +6 -0
- package/dist/native/js-bridge/report.d.ts +63 -0
- package/dist/native/js-bridge/subscribe.d.ts +8 -0
- package/dist/native/js-bridge/types.d.ts +14 -0
- package/dist/native/js-bridge/utils.d.ts +17 -0
- package/dist/native/js-core/index.d.ts +3 -0
- package/dist/native/js-core/jolibox-js-core.d.ts +45 -0
- package/dist/native/js-core/message-port.d.ts +12 -0
- package/dist/native/js-core/utils.d.ts +7 -0
- package/dist/native/network/create-fetch.d.ts +27 -0
- package/dist/native/network/index.d.ts +11 -0
- package/dist/native/network/report.d.ts +15 -0
- package/dist/native/network/types.d.ts +61 -0
- package/dist/native/network/utils.d.ts +9 -0
- package/dist/native/report/errors/index.d.ts +4 -0
- package/dist/native/report/index.d.ts +10 -0
- package/dist/native/report/task-tracker.d.ts +24 -0
- package/dist/utils/index.d.ts +0 -0
- package/esbuild.config.js +66 -0
- package/implement.build.log +9 -0
- package/package.json +30 -0
- package/src/common/api-factory/index.ts +188 -0
- package/src/common/api-factory/validator/__tests__/validate/any.test.ts +68 -0
- package/src/common/api-factory/validator/__tests__/validate/array.test.ts +402 -0
- package/src/common/api-factory/validator/__tests__/validate/arraybuffer.test.ts +48 -0
- package/src/common/api-factory/validator/__tests__/validate/boolean.test.ts +27 -0
- package/src/common/api-factory/validator/__tests__/validate/enum.test.ts +106 -0
- package/src/common/api-factory/validator/__tests__/validate/function.test.ts +54 -0
- package/src/common/api-factory/validator/__tests__/validate/literal.test.ts +130 -0
- package/src/common/api-factory/validator/__tests__/validate/nullish.test.ts +41 -0
- package/src/common/api-factory/validator/__tests__/validate/number.test.ts +147 -0
- package/src/common/api-factory/validator/__tests__/validate/object.test.ts +131 -0
- package/src/common/api-factory/validator/__tests__/validate/or.test.ts +96 -0
- package/src/common/api-factory/validator/__tests__/validate/record.test.ts +274 -0
- package/src/common/api-factory/validator/__tests__/validate/string.test.ts +187 -0
- package/src/common/api-factory/validator/__tests__/validate/symbol.test.ts +23 -0
- package/src/common/api-factory/validator/__tests__/validate/tuple.test.ts +86 -0
- package/src/common/api-factory/validator/__tests__/validate/type-asserts.test.ts +13 -0
- package/src/common/api-factory/validator/__tests__/validate/utils.test.ts +44 -0
- package/src/common/api-factory/validator/index.ts +107 -0
- package/src/common/api-factory/validator/validate.ts +641 -0
- package/src/common/can-i-use.ts +19 -0
- package/src/common/context/index.ts +85 -0
- package/src/common/context/types.ts +5 -0
- package/src/common/context/url-parse.ts +63 -0
- package/src/common/http/index.ts +29 -0
- package/src/common/http/uuid.ts +11 -0
- package/src/common/http/xua.ts +79 -0
- package/src/common/report/base-tracker.ts +134 -0
- package/src/common/report/create-trace.ts +17 -0
- package/src/common/report/errors/error-types.ts +206 -0
- package/src/common/report/errors/index.ts +20 -0
- package/src/common/report/errors/report/index.ts +63 -0
- package/src/common/report/errors/report/listeners.ts +80 -0
- package/src/common/report/index.ts +3 -0
- package/src/common/report/task-track/index.ts +102 -0
- package/src/common/report/track.ts +49 -0
- package/src/common/report/types.ts +90 -0
- package/src/h5/ads/ads-action-detection.ts +31 -0
- package/src/h5/ads/anti-cheating.ts +244 -0
- package/src/h5/ads/index.ts +658 -0
- package/src/h5/api/base.ts +9 -0
- package/src/h5/api/get-system-info.ts +59 -0
- package/src/h5/api/index.ts +4 -0
- package/src/h5/api/lifecycle.ts +95 -0
- package/src/h5/api/storage.ts +173 -0
- package/src/h5/api/task.ts +190 -0
- package/src/h5/bootstrap/index.ts +16 -0
- package/src/h5/http/index.ts +189 -0
- package/src/h5/http/utils/__tests__/uuid.test.ts +16 -0
- package/src/h5/http/utils/__tests__/xua.test.ts +27 -0
- package/src/h5/http/utils/index.ts +19 -0
- package/src/h5/http/utils/session.ts +10 -0
- package/src/h5/report/errors/index.ts +40 -0
- package/src/h5/report/event-tracker.ts +40 -0
- package/src/h5/report/index.ts +56 -0
- package/src/h5/report/task-tracker.ts +42 -0
- package/src/index.native.ts +7 -0
- package/src/index.ts +9 -0
- package/src/native/api/ads.ts +52 -0
- package/src/native/api/base.ts +8 -0
- package/src/native/api/get-system-info.ts +44 -0
- package/src/native/api/index.ts +8 -0
- package/src/native/api/keyboard.ts +75 -0
- package/src/native/api/lifecycle.ts +76 -0
- package/src/native/api/login.ts +73 -0
- package/src/native/api/request.ts +154 -0
- package/src/native/api/storage.ts +287 -0
- package/src/native/api/task.ts +227 -0
- package/src/native/bootstrap/bridge.ts +59 -0
- package/src/native/bootstrap/index.ts +59 -0
- package/src/native/js-bridge/const.ts +11 -0
- package/src/native/js-bridge/index.ts +2 -0
- package/src/native/js-bridge/invoke.ts +210 -0
- package/src/native/js-bridge/js-bridge.ts +23 -0
- package/src/native/js-bridge/report.ts +311 -0
- package/src/native/js-bridge/subscribe.ts +50 -0
- package/src/native/js-bridge/types.ts +26 -0
- package/src/native/js-bridge/utils.ts +116 -0
- package/src/native/js-core/index.ts +4 -0
- package/src/native/js-core/jolibox-js-core.ts +188 -0
- package/src/native/js-core/message-port.ts +52 -0
- package/src/native/js-core/utils.ts +9 -0
- package/src/native/network/create-fetch.ts +237 -0
- package/src/native/network/index.ts +15 -0
- package/src/native/network/report.ts +58 -0
- package/src/native/network/types.ts +77 -0
- package/src/native/network/utils.ts +90 -0
- package/src/native/report/errors/index.ts +27 -0
- package/src/native/report/index.ts +51 -0
- package/src/native/report/task-tracker.ts +72 -0
- package/src/native/types/global.d.ts +26 -0
- package/src/native/types/native-method-map.d.ts +282 -0
- package/src/native/types/native-method.d.ts +30 -0
- package/src/utils/index.ts +0 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StorageResponse } from '@jolibox/types';
|
|
2
|
+
export declare class JoliboxCloudStorage {
|
|
3
|
+
private gameId;
|
|
4
|
+
private httpClient;
|
|
5
|
+
private gameStore;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Cloud storage getItem api
|
|
9
|
+
*/
|
|
10
|
+
private getGameId;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param key getItem key
|
|
14
|
+
*/
|
|
15
|
+
getItem: (key: string) => Promise<StorageResponse<string | null>>;
|
|
16
|
+
/**
|
|
17
|
+
* Cloud storage setItem api
|
|
18
|
+
* @param progress - The progress of the loading, should be an integer between 0 and 100
|
|
19
|
+
*/
|
|
20
|
+
setItem: (key: string, value: string | boolean | number) => Promise<StorageResponse<void>>;
|
|
21
|
+
removeItem: (key: string) => Promise<StorageResponse<void>>;
|
|
22
|
+
clear: () => Promise<StorageResponse<void>>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 移除指定key
|
|
26
|
+
*/
|
|
27
|
+
export declare const removeStorage: (...inputs: unknown[]) => Promise<import("@jolibox/types").StandardResponse<void>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function config(): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IHttpClient } from '@/common/http';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
JoliboxHttpClient: typeof JoliboxHttpClient;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
interface IHttpClientInitParams {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class JoliboxHttpClient implements IHttpClient {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private xua;
|
|
13
|
+
private getJoliSource;
|
|
14
|
+
constructor(config?: IHttpClientInitParams);
|
|
15
|
+
get<T>(path: string, { query, headers, timeout }: {
|
|
16
|
+
query?: Record<string, string>;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}): Promise<T>;
|
|
20
|
+
post<T = any>(path: string, { data, query, headers, timeout }: {
|
|
21
|
+
data?: any;
|
|
22
|
+
query?: Record<string, string>;
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
}): Promise<T>;
|
|
26
|
+
put<T>(path: string, { data, query, headers }: {
|
|
27
|
+
data?: any;
|
|
28
|
+
query?: Record<string, string>;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}): Promise<T>;
|
|
32
|
+
}
|
|
33
|
+
export default JoliboxHttpClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as xua from '@/common/http/xua';
|
|
2
|
+
import * as session from './session';
|
|
3
|
+
import * as uuid from '@/common/http/uuid';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
JoliboxUtil: typeof JoliboxUtil;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare class JoliboxUtil {
|
|
10
|
+
static xua: typeof xua;
|
|
11
|
+
static session: typeof session;
|
|
12
|
+
static uuid: typeof uuid;
|
|
13
|
+
}
|
|
14
|
+
export { JoliboxUtil };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGameSessionId: () => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventTracker } from '@/common/report';
|
|
2
|
+
export declare class H5EventTracker extends EventTracker {
|
|
3
|
+
private hostToApiMap;
|
|
4
|
+
private get apiBaseURL();
|
|
5
|
+
private httpClient;
|
|
6
|
+
doReport(event: unknown[]): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const tracker: H5EventTracker;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './errors';
|
|
2
|
+
import { EventEmitter } from '@jolibox/common';
|
|
3
|
+
import { H5TaskTracker } from './task-tracker';
|
|
4
|
+
export * from '../../common/report/types';
|
|
5
|
+
declare const track: import("../../common/report").Track, trackPerformance: import("../../common/report").TrackPerformance;
|
|
6
|
+
export { track, trackPerformance };
|
|
7
|
+
export declare const h5TaskEmitter: EventEmitter<{
|
|
8
|
+
visible: [boolean];
|
|
9
|
+
}, "visible">;
|
|
10
|
+
export declare const taskTracker: H5TaskTracker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H5任务上报
|
|
3
|
+
*/
|
|
4
|
+
import { TaskTracker, TaskPoint } from '@/common/report/task-track';
|
|
5
|
+
import { EventEmitter } from '@jolibox/common';
|
|
6
|
+
import type { Track } from '.';
|
|
7
|
+
import type { TrackEvent } from '@jolibox/types';
|
|
8
|
+
export declare class H5TaskTracker extends TaskTracker {
|
|
9
|
+
private gameId;
|
|
10
|
+
private sessionId;
|
|
11
|
+
private httpClient;
|
|
12
|
+
private track;
|
|
13
|
+
constructor(track: Track, eventEmitter: EventEmitter<{
|
|
14
|
+
visible: [boolean];
|
|
15
|
+
}>, interval?: number);
|
|
16
|
+
reporter(point: TaskPoint): Promise<void>;
|
|
17
|
+
tracker(event: TrackEvent, info?: Record<string, unknown> | null): void;
|
|
18
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var ro=Object.create;var _r=Object.defineProperty;var no=Object.getOwnPropertyDescriptor;var oo=Object.getOwnPropertyNames;var io=Object.getPrototypeOf,so=Object.prototype.hasOwnProperty;var Te=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ao=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var co=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of oo(e))!so.call(t,u)&&u!==n&&_r(t,u,{get:()=>e[u],enumerable:!(i=no(e,u))||i.enumerable});return t};var uo=(t,e,n)=>(n=t!=null?ro(io(t)):{},co(e||!t||!t.__esModule?_r(n,"default",{value:t,enumerable:!0}):n,t));var Xr=ao((Qr,qt)=>{(function(t){if(typeof Qr=="object"&&typeof qt<"u")qt.exports=t();else if(typeof define=="function"&&define.amd)define([],t);else{var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e=this,e.localforage=t()}})(function(){var t,e,n;return function i(u,d,m){function b(I,x){if(!d[I]){if(!u[I]){var p=typeof Te=="function"&&Te;if(!x&&p)return p(I,!0);if(_)return _(I,!0);var T=new Error("Cannot find module '"+I+"'");throw T.code="MODULE_NOT_FOUND",T}var P=d[I]={exports:{}};u[I][0].call(P.exports,function(N){var K=u[I][1][N];return b(K||N)},P,P.exports,i,u,d,m)}return d[I].exports}for(var _=typeof Te=="function"&&Te,A=0;A<m.length;A++)b(m[A]);return b}({1:[function(i,u,d){(function(m){"use strict";var b=m.MutationObserver||m.WebKitMutationObserver,_;if(b){var A=0,I=new b(N),x=m.document.createTextNode("");I.observe(x,{characterData:!0}),_=function(){x.data=A=++A%2}}else if(!m.setImmediate&&typeof m.MessageChannel<"u"){var p=new m.MessageChannel;p.port1.onmessage=N,_=function(){p.port2.postMessage(0)}}else"document"in m&&"onreadystatechange"in m.document.createElement("script")?_=function(){var V=m.document.createElement("script");V.onreadystatechange=function(){N(),V.onreadystatechange=null,V.parentNode.removeChild(V),V=null},m.document.documentElement.appendChild(V)}:_=function(){setTimeout(N,0)};var T,P=[];function N(){T=!0;for(var V,ne,J=P.length;J;){for(ne=P,P=[],V=-1;++V<J;)ne[V]();J=P.length}T=!1}u.exports=K;function K(V){P.push(V)===1&&!T&&_()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,u,d){"use strict";var m=i(1);function b(){}var _={},A=["REJECTED"],I=["FULFILLED"],x=["PENDING"];u.exports=p;function p(E){if(typeof E!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,E!==b&&K(this,E)}p.prototype.catch=function(E){return this.then(null,E)},p.prototype.then=function(E,D){if(typeof E!="function"&&this.state===I||typeof D!="function"&&this.state===A)return this;var C=new this.constructor(b);if(this.state!==x){var U=this.state===I?E:D;P(C,U,this.outcome)}else this.queue.push(new T(C,E,D));return C};function T(E,D,C){this.promise=E,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}T.prototype.callFulfilled=function(E){_.resolve(this.promise,E)},T.prototype.otherCallFulfilled=function(E){P(this.promise,this.onFulfilled,E)},T.prototype.callRejected=function(E){_.reject(this.promise,E)},T.prototype.otherCallRejected=function(E){P(this.promise,this.onRejected,E)};function P(E,D,C){m(function(){var U;try{U=D(C)}catch(H){return _.reject(E,H)}U===E?_.reject(E,new TypeError("Cannot resolve promise with itself")):_.resolve(E,U)})}_.resolve=function(E,D){var C=V(N,D);if(C.status==="error")return _.reject(E,C.value);var U=C.value;if(U)K(E,U);else{E.state=I,E.outcome=D;for(var H=-1,z=E.queue.length;++H<z;)E.queue[H].callFulfilled(D)}return E},_.reject=function(E,D){E.state=A,E.outcome=D;for(var C=-1,U=E.queue.length;++C<U;)E.queue[C].callRejected(D);return E};function N(E){var D=E&&E.then;if(E&&(typeof E=="object"||typeof E=="function")&&typeof D=="function")return function(){D.apply(E,arguments)}}function K(E,D){var C=!1;function U(q){C||(C=!0,_.reject(E,q))}function H(q){C||(C=!0,_.resolve(E,q))}function z(){D(H,U)}var Y=V(z);Y.status==="error"&&U(Y.value)}function V(E,D){var C={};try{C.value=E(D),C.status="success"}catch(U){C.status="error",C.value=U}return C}p.resolve=ne;function ne(E){return E instanceof this?E:_.resolve(new this(b),E)}p.reject=J;function J(E){var D=new this(b);return _.reject(D,E)}p.all=pt;function pt(E){var D=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=E.length,U=!1;if(!C)return this.resolve([]);for(var H=new Array(C),z=0,Y=-1,q=new this(b);++Y<C;)oe(E[Y],Y);return q;function oe(be,xe){D.resolve(be).then(ht,function(me){U||(U=!0,_.reject(q,me))});function ht(me){H[xe]=me,++z===C&&!U&&(U=!0,_.resolve(q,H))}}}p.race=le;function le(E){var D=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=E.length,U=!1;if(!C)return this.resolve([]);for(var H=-1,z=new this(b);++H<C;)Y(E[H]);return z;function Y(q){D.resolve(q).then(function(oe){U||(U=!0,_.resolve(z,oe))},function(oe){U||(U=!0,_.reject(z,oe))})}}},{1:1}],3:[function(i,u,d){(function(m){"use strict";typeof m.Promise!="function"&&(m.Promise=i(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(i,u,d){"use strict";var m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r};function b(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function _(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var A=_();function I(){try{if(!A||!A.open)return!1;var r=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!r||s)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function x(r,s){r=r||[],s=s||{};try{return new Blob(r,s)}catch(a){if(a.name!=="TypeError")throw a;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,c=new o,l=0;l<r.length;l+=1)c.append(r[l]);return c.getBlob(s.type)}}typeof Promise>"u"&&i(3);var p=Promise;function T(r,s){s&&r.then(function(o){s(null,o)},function(o){s(o)})}function P(r,s,o){typeof s=="function"&&r.then(s),typeof o=="function"&&r.catch(o)}function N(r){return typeof r!="string"&&(console.warn(r+" used as a key, but it is not a string."),r=String(r)),r}function K(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var V="local-forage-detect-blob-support",ne=void 0,J={},pt=Object.prototype.toString,le="readonly",E="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),c=new Uint8Array(o),l=0;l<s;l++)c[l]=r.charCodeAt(l);return o}function C(r){return new p(function(s){var o=r.transaction(V,E),c=x([""]);o.objectStore(V).put(c,"key"),o.onabort=function(l){l.preventDefault(),l.stopPropagation(),s(!1)},o.oncomplete=function(){var l=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);s(a||!l||parseInt(l[1],10)>=43)}}).catch(function(){return!1})}function U(r){return typeof ne=="boolean"?p.resolve(ne):C(r).then(function(s){return ne=s,ne})}function H(r){var s=J[r.name],o={};o.promise=new p(function(c,l){o.resolve=c,o.reject=l}),s.deferredOperations.push(o),s.dbReady?s.dbReady=s.dbReady.then(function(){return o.promise}):s.dbReady=o.promise}function z(r){var s=J[r.name],o=s.deferredOperations.pop();if(o)return o.resolve(),o.promise}function Y(r,s){var o=J[r.name],c=o.deferredOperations.pop();if(c)return c.reject(s),c.promise}function q(r,s){return new p(function(o,c){if(J[r.name]=J[r.name]||er(),r.db)if(s)H(r),r.db.close();else return o(r.db);var l=[r.name];s&&l.push(r.version);var a=A.open.apply(A,l);s&&(a.onupgradeneeded=function(f){var h=a.result;try{h.createObjectStore(r.storeName),f.oldVersion<=1&&h.createObjectStore(V)}catch(g){if(g.name==="ConstraintError")console.warn('The database "'+r.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+r.storeName+'" already exists.');else throw g}}),a.onerror=function(f){f.preventDefault(),c(a.error)},a.onsuccess=function(){var f=a.result;f.onversionchange=function(h){h.target.close()},o(f),z(r)}})}function oe(r){return q(r,!1)}function be(r){return q(r,!0)}function xe(r,s){if(!r.db)return!0;var o=!r.db.objectStoreNames.contains(r.storeName),c=r.version<r.db.version,l=r.version>r.db.version;if(c&&(r.version!==s&&console.warn('The database "'+r.name+`" can't be downgraded from version `+r.db.version+" to version "+r.version+"."),r.version=r.db.version),l||o){if(o){var a=r.db.version+1;a>r.version&&(r.version=a)}return!0}return!1}function ht(r){return new p(function(s,o){var c=new FileReader;c.onerror=o,c.onloadend=function(l){var a=btoa(l.target.result||"");s({__local_forage_encoded_blob:!0,data:a,type:r.type})},c.readAsBinaryString(r)})}function me(r){var s=D(atob(r.data));return x([s],{type:r.type})}function Zt(r){return r&&r.__local_forage_encoded_blob}function rn(r){var s=this,o=s._initReady().then(function(){var c=J[s._dbInfo.name];if(c&&c.dbReady)return c.dbReady});return P(o,r,r),o}function nn(r){H(r);for(var s=J[r.name],o=s.forages,c=0;c<o.length;c++){var l=o[c];l._dbInfo.db&&(l._dbInfo.db.close(),l._dbInfo.db=null)}return r.db=null,oe(r).then(function(a){return r.db=a,xe(r)?be(r):a}).then(function(a){r.db=s.db=a;for(var f=0;f<o.length;f++)o[f]._dbInfo.db=a}).catch(function(a){throw Y(r,a),a})}function ie(r,s,o,c){c===void 0&&(c=1);try{var l=r.db.transaction(r.storeName,s);o(null,l)}catch(a){if(c>0&&(!r.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return p.resolve().then(function(){if(!r.db||a.name==="NotFoundError"&&!r.db.objectStoreNames.contains(r.storeName)&&r.version<=r.db.version)return r.db&&(r.version=r.db.version+1),be(r)}).then(function(){return nn(r).then(function(){ie(r,s,o,c-1)})}).catch(o);o(a)}}function er(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function on(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=r[c];var l=J[o.name];l||(l=er(),J[o.name]=l),l.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=rn);var a=[];function f(){return p.resolve()}for(var h=0;h<l.forages.length;h++){var g=l.forages[h];g!==s&&a.push(g._initReady().catch(f))}var v=l.forages.slice(0);return p.all(a).then(function(){return o.db=l.db,oe(o)}).then(function(y){return o.db=y,xe(o,s._defaultConfig.version)?be(o):y}).then(function(y){o.db=l.db=y,s._dbInfo=o;for(var w=0;w<v.length;w++){var k=v[w];k!==s&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function sn(r,s){var o=this;r=N(r);var c=new p(function(l,a){o.ready().then(function(){ie(o._dbInfo,le,function(f,h){if(f)return a(f);try{var g=h.objectStore(o._dbInfo.storeName),v=g.get(r);v.onsuccess=function(){var y=v.result;y===void 0&&(y=null),Zt(y)&&(y=me(y)),l(y)},v.onerror=function(){a(v.error)}}catch(y){a(y)}})}).catch(a)});return T(c,s),c}function an(r,s){var o=this,c=new p(function(l,a){o.ready().then(function(){ie(o._dbInfo,le,function(f,h){if(f)return a(f);try{var g=h.objectStore(o._dbInfo.storeName),v=g.openCursor(),y=1;v.onsuccess=function(){var w=v.result;if(w){var k=w.value;Zt(k)&&(k=me(k));var O=r(k,w.key,y++);O!==void 0?l(O):w.continue()}else l()},v.onerror=function(){a(v.error)}}catch(w){a(w)}})}).catch(a)});return T(c,s),c}function cn(r,s,o){var c=this;r=N(r);var l=new p(function(a,f){var h;c.ready().then(function(){return h=c._dbInfo,pt.call(s)==="[object Blob]"?U(h.db).then(function(g){return g?s:ht(s)}):s}).then(function(g){ie(c._dbInfo,E,function(v,y){if(v)return f(v);try{var w=y.objectStore(c._dbInfo.storeName);g===null&&(g=void 0);var k=w.put(g,r);y.oncomplete=function(){g===void 0&&(g=null),a(g)},y.onabort=y.onerror=function(){var O=k.error?k.error:k.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return T(l,o),l}function un(r,s){var o=this;r=N(r);var c=new p(function(l,a){o.ready().then(function(){ie(o._dbInfo,E,function(f,h){if(f)return a(f);try{var g=h.objectStore(o._dbInfo.storeName),v=g.delete(r);h.oncomplete=function(){l()},h.onerror=function(){a(v.error)},h.onabort=function(){var y=v.error?v.error:v.transaction.error;a(y)}}catch(y){a(y)}})}).catch(a)});return T(c,s),c}function ln(r){var s=this,o=new p(function(c,l){s.ready().then(function(){ie(s._dbInfo,E,function(a,f){if(a)return l(a);try{var h=f.objectStore(s._dbInfo.storeName),g=h.clear();f.oncomplete=function(){c()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;l(v)}}catch(v){l(v)}})}).catch(l)});return T(o,r),o}function dn(r){var s=this,o=new p(function(c,l){s.ready().then(function(){ie(s._dbInfo,le,function(a,f){if(a)return l(a);try{var h=f.objectStore(s._dbInfo.storeName),g=h.count();g.onsuccess=function(){c(g.result)},g.onerror=function(){l(g.error)}}catch(v){l(v)}})}).catch(l)});return T(o,r),o}function fn(r,s){var o=this,c=new p(function(l,a){if(r<0){l(null);return}o.ready().then(function(){ie(o._dbInfo,le,function(f,h){if(f)return a(f);try{var g=h.objectStore(o._dbInfo.storeName),v=!1,y=g.openKeyCursor();y.onsuccess=function(){var w=y.result;if(!w){l(null);return}r===0||v?l(w.key):(v=!0,w.advance(r))},y.onerror=function(){a(y.error)}}catch(w){a(w)}})}).catch(a)});return T(c,s),c}function mn(r){var s=this,o=new p(function(c,l){s.ready().then(function(){ie(s._dbInfo,le,function(a,f){if(a)return l(a);try{var h=f.objectStore(s._dbInfo.storeName),g=h.openKeyCursor(),v=[];g.onsuccess=function(){var y=g.result;if(!y){c(v);return}v.push(y.key),y.continue()},g.onerror=function(){l(g.error)}}catch(y){l(y)}})}).catch(l)});return T(o,r),o}function pn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,l;if(!r.name)l=p.reject("Invalid arguments");else{var a=r.name===o.name&&c._dbInfo.db,f=a?p.resolve(c._dbInfo.db):oe(r).then(function(h){var g=J[r.name],v=g.forages;g.db=h;for(var y=0;y<v.length;y++)v[y]._dbInfo.db=h;return h});r.storeName?l=f.then(function(h){if(h.objectStoreNames.contains(r.storeName)){var g=h.version+1;H(r);var v=J[r.name],y=v.forages;h.close();for(var w=0;w<y.length;w++){var k=y[w];k._dbInfo.db=null,k._dbInfo.version=g}var O=new p(function(F,M){var B=A.open(r.name,g);B.onerror=function(Q){var Ee=B.result;Ee.close(),M(Q)},B.onupgradeneeded=function(){var Q=B.result;Q.deleteObjectStore(r.storeName)},B.onsuccess=function(){var Q=B.result;Q.close(),F(Q)}});return O.then(function(F){v.db=F;for(var M=0;M<y.length;M++){var B=y[M];B._dbInfo.db=F,z(B._dbInfo)}}).catch(function(F){throw(Y(r,F)||p.resolve()).catch(function(){}),F})}}):l=f.then(function(h){H(r);var g=J[r.name],v=g.forages;h.close();for(var y=0;y<v.length;y++){var w=v[y];w._dbInfo.db=null}var k=new p(function(O,F){var M=A.deleteDatabase(r.name);M.onerror=function(){var B=M.result;B&&B.close(),F(M.error)},M.onblocked=function(){console.warn('dropInstance blocked for database "'+r.name+'" until all open connections are closed')},M.onsuccess=function(){var B=M.result;B&&B.close(),O(B)}});return k.then(function(O){g.db=O;for(var F=0;F<v.length;F++){var M=v[F];z(M._dbInfo)}}).catch(function(O){throw(Y(r,O)||p.resolve()).catch(function(){}),O})})}return T(l,s),l}var hn={_driver:"asyncStorage",_initStorage:on,_support:I(),iterate:an,getItem:sn,setItem:cn,removeItem:un,clear:ln,length:dn,key:fn,keys:mn,dropInstance:pn};function gn(){return typeof openDatabase=="function"}var ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vn="~~local_forage_type~",tr=/^~~local_forage_type~([^~]+)~/,ke="__lfsc__:",gt=ke.length,vt="arbf",yt="blob",rr="si08",nr="ui08",or="uic8",ir="si16",sr="si32",ar="ur16",cr="ui32",ur="fl32",lr="fl64",dr=gt+vt.length,fr=Object.prototype.toString;function mr(r){var s=r.length*.75,o=r.length,c,l=0,a,f,h,g;r[r.length-1]==="="&&(s--,r[r.length-2]==="="&&s--);var v=new ArrayBuffer(s),y=new Uint8Array(v);for(c=0;c<o;c+=4)a=ae.indexOf(r[c]),f=ae.indexOf(r[c+1]),h=ae.indexOf(r[c+2]),g=ae.indexOf(r[c+3]),y[l++]=a<<2|f>>4,y[l++]=(f&15)<<4|h>>2,y[l++]=(h&3)<<6|g&63;return v}function bt(r){var s=new Uint8Array(r),o="",c;for(c=0;c<s.length;c+=3)o+=ae[s[c]>>2],o+=ae[(s[c]&3)<<4|s[c+1]>>4],o+=ae[(s[c+1]&15)<<2|s[c+2]>>6],o+=ae[s[c+2]&63];return s.length%3===2?o=o.substring(0,o.length-1)+"=":s.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function yn(r,s){var o="";if(r&&(o=fr.call(r)),r&&(o==="[object ArrayBuffer]"||r.buffer&&fr.call(r.buffer)==="[object ArrayBuffer]")){var c,l=ke;r instanceof ArrayBuffer?(c=r,l+=vt):(c=r.buffer,o==="[object Int8Array]"?l+=rr:o==="[object Uint8Array]"?l+=nr:o==="[object Uint8ClampedArray]"?l+=or:o==="[object Int16Array]"?l+=ir:o==="[object Uint16Array]"?l+=ar:o==="[object Int32Array]"?l+=sr:o==="[object Uint32Array]"?l+=cr:o==="[object Float32Array]"?l+=ur:o==="[object Float64Array]"?l+=lr:s(new Error("Failed to get type for BinaryArray"))),s(l+bt(c))}else if(o==="[object Blob]"){var a=new FileReader;a.onload=function(){var f=vn+r.type+"~"+bt(this.result);s(ke+yt+f)},a.readAsArrayBuffer(r)}else try{s(JSON.stringify(r))}catch(f){console.error("Couldn't convert value into a JSON string: ",r),s(null,f)}}function bn(r){if(r.substring(0,gt)!==ke)return JSON.parse(r);var s=r.substring(dr),o=r.substring(gt,dr),c;if(o===yt&&tr.test(s)){var l=s.match(tr);c=l[1],s=s.substring(l[0].length)}var a=mr(s);switch(o){case vt:return a;case yt:return x([a],{type:c});case rr:return new Int8Array(a);case nr:return new Uint8Array(a);case or:return new Uint8ClampedArray(a);case ir:return new Int16Array(a);case ar:return new Uint16Array(a);case sr:return new Int32Array(a);case cr:return new Uint32Array(a);case ur:return new Float32Array(a);case lr:return new Float64Array(a);default:throw new Error("Unkown type: "+o)}}var _t={serialize:yn,deserialize:bn,stringToBuffer:mr,bufferToString:bt};function pr(r,s,o,c){r.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,c)}function _n(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=typeof r[c]!="string"?r[c].toString():r[c];var l=new p(function(a,f){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(h){return f(h)}o.db.transaction(function(h){pr(h,o,function(){s._dbInfo=o,a()},function(g,v){f(v)})},f)});return o.serializer=_t,l}function ce(r,s,o,c,l,a){r.executeSql(o,c,l,function(f,h){h.code===h.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(g,v){v.rows.length?a(g,h):pr(g,s,function(){g.executeSql(o,c,l,a)},a)},a):a(f,h)},a)}function En(r,s){var o=this;r=N(r);var c=new p(function(l,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(h){ce(h,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[r],function(g,v){var y=v.rows.length?v.rows.item(0).value:null;y&&(y=f.serializer.deserialize(y)),l(y)},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function Tn(r,s){var o=this,c=new p(function(l,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(h){ce(h,f,"SELECT * FROM "+f.storeName,[],function(g,v){for(var y=v.rows,w=y.length,k=0;k<w;k++){var O=y.item(k),F=O.value;if(F&&(F=f.serializer.deserialize(F)),F=r(F,O.key,k+1),F!==void 0){l(F);return}}l()},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function hr(r,s,o,c){var l=this;r=N(r);var a=new p(function(f,h){l.ready().then(function(){s===void 0&&(s=null);var g=s,v=l._dbInfo;v.serializer.serialize(s,function(y,w){w?h(w):v.db.transaction(function(k){ce(k,v,"INSERT OR REPLACE INTO "+v.storeName+" (key, value) VALUES (?, ?)",[r,y],function(){f(g)},function(O,F){h(F)})},function(k){if(k.code===k.QUOTA_ERR){if(c>0){f(hr.apply(l,[r,g,o,c-1]));return}h(k)}})})}).catch(h)});return T(a,o),a}function In(r,s,o){return hr.apply(this,[r,s,o,1])}function wn(r,s){var o=this;r=N(r);var c=new p(function(l,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(h){ce(h,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[r],function(){l()},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function Sn(r){var s=this,o=new p(function(c,l){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"DELETE FROM "+a.storeName,[],function(){c()},function(h,g){l(g)})})}).catch(l)});return T(o,r),o}function An(r){var s=this,o=new p(function(c,l){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(h,g){var v=g.rows.item(0).c;c(v)},function(h,g){l(g)})})}).catch(l)});return T(o,r),o}function Rn(r,s){var o=this,c=new p(function(l,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(h){ce(h,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[r+1],function(g,v){var y=v.rows.length?v.rows.item(0).key:null;l(y)},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function xn(r){var s=this,o=new p(function(c,l){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"SELECT key FROM "+a.storeName,[],function(h,g){for(var v=[],y=0;y<g.rows.length;y++)v.push(g.rows.item(y).key);c(v)},function(h,g){l(g)})})}).catch(l)});return T(o,r),o}function kn(r){return new p(function(s,o){r.transaction(function(c){c.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(l,a){for(var f=[],h=0;h<a.rows.length;h++)f.push(a.rows.item(h).name);s({db:r,storeNames:f})},function(l,a){o(a)})},function(c){o(c)})})}function Cn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,l;return r.name?l=new p(function(a){var f;r.name===o.name?f=c._dbInfo.db:f=openDatabase(r.name,"","",0),r.storeName?a({db:f,storeNames:[r.storeName]}):a(kn(f))}).then(function(a){return new p(function(f,h){a.db.transaction(function(g){function v(O){return new p(function(F,M){g.executeSql("DROP TABLE IF EXISTS "+O,[],function(){F()},function(B,Q){M(Q)})})}for(var y=[],w=0,k=a.storeNames.length;w<k;w++)y.push(v(a.storeNames[w]));p.all(y).then(function(){f()}).catch(function(O){h(O)})},function(g){h(g)})})}):l=p.reject("Invalid arguments"),T(l,s),l}var Pn={_driver:"webSQLStorage",_initStorage:_n,_support:gn(),iterate:Tn,getItem:En,setItem:In,removeItem:wn,clear:Sn,length:An,key:Rn,keys:xn,dropInstance:Cn};function Dn(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function gr(r,s){var o=r.name+"/";return r.storeName!==s.storeName&&(o+=r.storeName+"/"),o}function On(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Fn(){return!On()||localStorage.length>0}function Nn(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=gr(r,s._defaultConfig),Fn()?(s._dbInfo=o,o.serializer=_t,p.resolve()):p.reject()}function Un(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo.keyPrefix,l=localStorage.length-1;l>=0;l--){var a=localStorage.key(l);a.indexOf(c)===0&&localStorage.removeItem(a)}});return T(o,r),o}function Ln(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var l=o._dbInfo,a=localStorage.getItem(l.keyPrefix+r);return a&&(a=l.serializer.deserialize(a)),a});return T(c,s),c}function Bn(r,s){var o=this,c=o.ready().then(function(){for(var l=o._dbInfo,a=l.keyPrefix,f=a.length,h=localStorage.length,g=1,v=0;v<h;v++){var y=localStorage.key(v);if(y.indexOf(a)===0){var w=localStorage.getItem(y);if(w&&(w=l.serializer.deserialize(w)),w=r(w,y.substring(f),g++),w!==void 0)return w}}});return T(c,s),c}function Mn(r,s){var o=this,c=o.ready().then(function(){var l=o._dbInfo,a;try{a=localStorage.key(r)}catch{a=null}return a&&(a=a.substring(l.keyPrefix.length)),a});return T(c,s),c}function $n(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo,l=localStorage.length,a=[],f=0;f<l;f++){var h=localStorage.key(f);h.indexOf(c.keyPrefix)===0&&a.push(h.substring(c.keyPrefix.length))}return a});return T(o,r),o}function Vn(r){var s=this,o=s.keys().then(function(c){return c.length});return T(o,r),o}function jn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var l=o._dbInfo;localStorage.removeItem(l.keyPrefix+r)});return T(c,s),c}function Kn(r,s,o){var c=this;r=N(r);var l=c.ready().then(function(){s===void 0&&(s=null);var a=s;return new p(function(f,h){var g=c._dbInfo;g.serializer.serialize(s,function(v,y){if(y)h(y);else try{localStorage.setItem(g.keyPrefix+r,v),f(a)}catch(w){(w.name==="QuotaExceededError"||w.name==="NS_ERROR_DOM_QUOTA_REACHED")&&h(w),h(w)}})})});return T(l,o),l}function Jn(r,s){if(s=K.apply(this,arguments),r=typeof r!="function"&&r||{},!r.name){var o=this.config();r.name=r.name||o.name,r.storeName=r.storeName||o.storeName}var c=this,l;return r.name?l=new p(function(a){r.storeName?a(gr(r,c._defaultConfig)):a(r.name+"/")}).then(function(a){for(var f=localStorage.length-1;f>=0;f--){var h=localStorage.key(f);h.indexOf(a)===0&&localStorage.removeItem(h)}}):l=p.reject("Invalid arguments"),T(l,s),l}var Gn={_driver:"localStorageWrapper",_initStorage:Nn,_support:Dn(),iterate:Bn,getItem:Ln,setItem:Kn,removeItem:jn,clear:Un,length:Vn,key:Mn,keys:$n,dropInstance:Jn},Hn=function(s,o){return s===o||typeof s=="number"&&typeof o=="number"&&isNaN(s)&&isNaN(o)},Wn=function(s,o){for(var c=s.length,l=0;l<c;){if(Hn(s[l],o))return!0;l++}return!1},vr=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"},_e={},yr={},pe={INDEXEDDB:hn,WEBSQL:Pn,LOCALSTORAGE:Gn},zn=[pe.INDEXEDDB._driver,pe.WEBSQL._driver,pe.LOCALSTORAGE._driver],Ce=["dropInstance"],Et=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ce),Yn={description:"",driver:zn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function qn(r,s){r[s]=function(){var o=arguments;return r.ready().then(function(){return r[s].apply(r,o)})}}function Tt(){for(var r=1;r<arguments.length;r++){var s=arguments[r];if(s)for(var o in s)s.hasOwnProperty(o)&&(vr(s[o])?arguments[0][o]=s[o].slice():arguments[0][o]=s[o])}return arguments[0]}var Qn=function(){function r(s){b(this,r);for(var o in pe)if(pe.hasOwnProperty(o)){var c=pe[o],l=c._driver;this[o]=l,_e[l]||this.defineDriver(c)}this._defaultConfig=Tt({},Yn),this._config=Tt({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return r.prototype.config=function(o){if((typeof o>"u"?"undefined":m(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var c in o){if(c==="storeName"&&(o[c]=o[c].replace(/\W/g,"_")),c==="version"&&typeof o[c]!="number")return new Error("Database version must be a number.");this._config[c]=o[c]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},r.prototype.defineDriver=function(o,c,l){var a=new p(function(f,h){try{var g=o._driver,v=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){h(v);return}for(var y=Et.concat("_initStorage"),w=0,k=y.length;w<k;w++){var O=y[w],F=!Wn(Ce,O);if((F||o[O])&&typeof o[O]!="function"){h(v);return}}var M=function(){for(var Ee=function(eo){return function(){var to=new Error("Method "+eo+" is not implemented by the current driver"),br=p.reject(to);return T(br,arguments[arguments.length-1]),br}},It=0,Zn=Ce.length;It<Zn;It++){var wt=Ce[It];o[wt]||(o[wt]=Ee(wt))}};M();var B=function(Ee){_e[g]&&console.info("Redefining LocalForage driver: "+g),_e[g]=o,yr[g]=Ee,f()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(B,h):B(!!o._support):B(!0)}catch(Q){h(Q)}});return P(a,c,l),a},r.prototype.driver=function(){return this._driver||null},r.prototype.getDriver=function(o,c,l){var a=_e[o]?p.resolve(_e[o]):p.reject(new Error("Driver not found."));return P(a,c,l),a},r.prototype.getSerializer=function(o){var c=p.resolve(_t);return P(c,o),c},r.prototype.ready=function(o){var c=this,l=c._driverSet.then(function(){return c._ready===null&&(c._ready=c._initDriver()),c._ready});return P(l,o,o),l},r.prototype.setDriver=function(o,c,l){var a=this;vr(o)||(o=[o]);var f=this._getSupportedDrivers(o);function h(){a._config.driver=a.driver()}function g(w){return a._extend(w),h(),a._ready=a._initStorage(a._config),a._ready}function v(w){return function(){var k=0;function O(){for(;k<w.length;){var F=w[k];return k++,a._dbInfo=null,a._ready=null,a.getDriver(F).then(g).catch(O)}h();var M=new Error("No available storage method found.");return a._driverSet=p.reject(M),a._driverSet}return O()}}var y=this._driverSet!==null?this._driverSet.catch(function(){return p.resolve()}):p.resolve();return this._driverSet=y.then(function(){var w=f[0];return a._dbInfo=null,a._ready=null,a.getDriver(w).then(function(k){a._driver=k._driver,h(),a._wrapLibraryMethodsWithReady(),a._initDriver=v(f)})}).catch(function(){h();var w=new Error("No available storage method found.");return a._driverSet=p.reject(w),a._driverSet}),P(this._driverSet,c,l),this._driverSet},r.prototype.supports=function(o){return!!yr[o]},r.prototype._extend=function(o){Tt(this,o)},r.prototype._getSupportedDrivers=function(o){for(var c=[],l=0,a=o.length;l<a;l++){var f=o[l];this.supports(f)&&c.push(f)}return c},r.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,c=Et.length;o<c;o++)qn(this,Et[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),Xn=new Qn;u.exports=Xn},{3:3}]},{},[4])(4)})});var Tr=Object.defineProperty,lo=Object.getOwnPropertyDescriptor,fo=(t,e)=>{for(var n in e)Tr(t,n,{get:e[n],enumerable:!0})},Ir=(t,e,n,i)=>{for(var u=i>1?void 0:i?lo(e,n):e,d=t.length-1,m;d>=0;d--)(m=t[d])&&(u=(i?m(e,n,u):m(u))||u);return i&&u&&Tr(e,n,u),u};function mo(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}function kt(t){return typeof t=="string"}function wr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}function Sr(t){return typeof t=="object"&&Array.isArray(t)}function po(t){return typeof t>"u"}function ho(t){return po(t)||t===null}function go(t){return typeof t=="function"}function Ar(t){let e=t,n=null,i=function(...u){return n||(n=new e(...u)),n};return i.prototype=e.prototype,i}function Rr(t,e,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function i(u,d){for(let m in d)if(Object.prototype.hasOwnProperty.call(d,m)){let b=u[m],_=d[m],A=n(b,_,m,u,d);A!==void 0?u[m]=A:Er(_)&&Er(b)?u[m]=i({...b},_):Array.isArray(_)&&Array.isArray(b)?u[m]=[...b,..._]:u[m]=_}return u}return i(t,e)}function Er(t){return t&&typeof t=="object"&&t.constructor===Object}function xr(t,e){if(Array.isArray(t))return t.concat(e)}function Se(t,e,n={}){let i=null,u,d,m,{leading:b=!1,trailing:_=!0}=n,A=()=>(m=t.apply(d,u),u=void 0,d=void 0,m),I=function(...x){u=x,d=this;let p=b&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,_&&!p&&A()},e),p)return A()};return I.cancel=()=>{i&&clearTimeout(i),i=null,u=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,A()},I}var vo=(t=>(t[t.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",t[t.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",t[t.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",t[t.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",t[t.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",t[t.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",t[t.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",t[t.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",t))(vo||{}),Ct=class extends Error{constructor(t){if(typeof t=="string"){super(t),this.priority="P1";return}super(t.message),this.priority="P1",this.stack=t.stack,this.raw=t}},Pt=class extends Ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},yo=class extends Ct{constructor(){super(...arguments),this.kind="USER_ERROR"}};var Dt=class extends yo{constructor(t,e,n){super(t),this.message=t,this.errNo=e,this.name="USER_CUSTOM_ERROR",this.errMsg=t,n&&(this.extra=Object.assign({},this.extra,n))}};var kr=class extends Pt{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Cr=class extends Pt{constructor(t,e){super(t),this.message=t,this.name="INTERNAL_CONTEXT_ERROR",this.property=e}},Fe=class extends Ct{constructor(t,e,n,i,u){super(t),this.message=t,this.code=e,this.kind="API_ERROR",this.name="API_ERROR",n&&(this.errorType=n),i!==void 0&&(this.stack=i),u&&(this.priority=u)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};var Ot=class extends Pt{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function bo(t,e){return(...n)=>e(t,...n)}function Pr(t){return e=>bo(e,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(u){t(new Dt(`${u}`))}})}function Ie(t){return(...e)=>{(globalThis.VConsole?.[t]??globalThis.console[t])(...e)}}var W={log:Ie("log"),warn:Ie("warn"),info:Ie("info"),error:Ie("error"),debug:Ie("debug")};Object.assign(globalThis,{logger:W});var Dr=Symbol.for("Jolibox.canIUseMap"),_o={};globalThis[Dr]=_o;var Ft={get config(){return globalThis[Dr]}};var L=class De{static{this.Undefined=new De(void 0)}constructor(e){this.element=e,this.next=De.Undefined,this.prev=De.Undefined}},Eo=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 t=this._first;for(;t!==L.Undefined;){let e=t.next;t.prev=L.Undefined,t.next=L.Undefined,t=e}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let n=new L(t);if(this._first===L.Undefined)this._first=n,this._last=n;else if(e){let u=this._last;this._last=n,n.prev=u,u.next=n}else{let u=this._first;this._first=n,n.next=u,u.prev=n}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(n))}}shift(){if(this._first!==L.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==L.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==L.Undefined&&t.next!==L.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===L.Undefined&&t.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):t.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):t.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==L.Undefined;)yield t.element,t=t.next}},To=0,Pe=class{constructor(t){this.value=t,this.id=To++}},we=class{constructor(t){this.options=t,this._size=0}dispose(t){this._disposed||(this._disposed=!0,this._listeners&&(t?(this._listeners instanceof Pe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(e=>e?.value===t)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(t,e)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};e&&(t=t.bind(e));let n=new Pe(t);this._listeners?this._listeners instanceof Pe?this._listeners=[this._listeners,n]:this._listeners.push(n):(this.options?.onWillAddFirstListener?.(this),this._listeners=n,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(t,e){if(!t)return;let n=this.options?.onListenerError||Error.constructor;if(!n){t.value(e);return}try{t.value(e)}catch(i){n(i)}}fire(t){this._listeners&&(this._listeners instanceof Pe?this._deliver(this._listeners,t):this._listeners.forEach(e=>this._deliver(e,t)))}hasListeners(){return this._size>0}},he=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(t,e){let n=this.listeners.get(t)??new we,i=d=>e(...d.args);this.listerHandlerMap.set(e,i),n.event(i),this.listeners.set(t,n);let u=this.cachedEventQueue.get(t);if(u)for(;u.size>0;)n.fire({event:t,...u.shift()})}off(t,e){let n=this.listeners.get(t);if(n){let i=this.listerHandlerMap.get(e);n.dispose(i)}}emit(t,...e){let n=this.listeners.get(t);if(n)n.fire({event:t,args:e});else{let i=this.cachedEventQueue.get(t);i||(i=new Eo,this.cachedEventQueue.set(t,i)),i.push({args:e})}}},Rt={};fo(Rt,{None:()=>Io,filter:()=>So,once:()=>Or,toPromise:()=>wo});var Io=()=>{console.log("[Jolibox SDK] None Event")};function wo(t){return new Promise(e=>Or(t)(e))}function Or(t){return(e,n=null)=>{let i=!1;return t(u=>{if(!i)return i=!0,e.call(n,u)},null)}}function So(t,e){return(n=>{let i,u={onWillAddFirstListener(){i=n(d.fire,d)}},d=new we(u);return d.event})((n,i=null)=>t(u=>e(u)&&n.call(i,u),null))}var St=Symbol.for("Jolibox.hostEmitter"),Ao=()=>{let t=new he;return globalThis[St]||(globalThis[St]={on:t.on.bind(t),off:t.off.bind(t),emit:t.emit.bind(t)}),globalThis[St]},Ae=Ao();function Ro(t,e){let n=Math.min(t.length,e.length);for(let i=0;i<n;i++)xo(t[i],e[i])}function xo(t,e){if(kt(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(go(e)){try{if(t instanceof e)return}catch{}if(!ho(t)&&t.constructor===e||e.length===1&&e.call(void 0,t)===!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 Oe=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new we,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(t){if(!t)throw new Error("invalid command");if(t.metadata&&Array.isArray(t.metadata.args)){let n=[];for(let u of t.metadata.args)n.push(u.constraint);let i=t.handler;t.handler=function(...u){return Ro(u,n),i(...u)}}let{id:e}=t;this._commands.get(e)&&console.info(`[Jolibox SDK] duplicated command is registered ${e}`),this._commands.set(e,t),this._onDidRegisterCommand.fire(e)}getCommand(t){return this._commands.get(t)}getCommands(){let t=new Map;for(let e of this._commands.keys()){let n=this.getCommand(e);n&&t.set(e,n)}return t}};Oe=Ir([Ar],Oe);var xt=class{constructor(){this._onWillExecuteCommand=new we,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new we,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Oe,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=mo(3e4)),this._starActivation}async executeCommand(t,...e){return this.registry.getCommand(t)?this._tryExecuteCommand(t,e):(await Promise.all([Promise.race([this._activateStar(),Rt.toPromise(Rt.filter(this.registry.onDidRegisterCommand,n=>n===t))])]),this._tryExecuteCommand(t,e))}executeCommandThowErr(t,...e){if(!this.registry.getCommand(t))throw new Error(`command '${t}' not found`);let n=this.registry.getCommand(t);this._onWillExecuteCommand.fire({commandId:t,args:e});let i=this.invokeFunction(n.handler,...e);return this._onDidExecuteCommand.fire({commandId:t,args:e}),i}_tryExecuteCommand(t,e){let n=this.registry.getCommand(t);if(!n)return Promise.reject(new Error(`command '${t}' not found`));try{this._onWillExecuteCommand.fire({commandId:t,args:e});let i=this.invokeFunction(n.handler,...e);return this._onDidExecuteCommand.fire({commandId:t,args:e}),Promise.resolve(i)}catch(i){return Promise.reject(i)}}invokeFunction(t,...e){let n=!1;try{return t(...e)}finally{n=!0}}};xt=Ir([Ar],xt);var At=Symbol.for("Jolibox.commands");function X(){if(globalThis[At])return globalThis[At];let t=new Oe,e=new xt,n={registerCommand(i,u,d){t.registerCommand({id:i,handler:u,metadata:d})},executeCommand(i,...u){return e.executeCommand(i,...u)},excuteCommandSync(i,...u){return e.executeCommandThowErr(i,...u)}};return globalThis[At]=n,n}var Nt=new he,de=new he;function ee(t,e={}){Nt.emit("ERROR_REPORT",{error:t,options:e})}ee.debounce=Se(ee,50,{leading:!0});var Ut=t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),i=atob(e+n);try{return JSON.parse(i)}catch{return{}}},Fr=t=>{try{let i=new URL(t).searchParams.get("joliSource")?.split(".");if(i?.length){let[u,d,m]=i;return{headerJson:Ut(u),payloadJson:Ut(d),signature:Ut(m)}}else throw"joli_source is missing"}catch(e){return ee(new kr(`${t} not a valid schema: ${e}`)),{headerJson:{},payloadJson:{},signature:{}}}};var Nr=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)});var Ne={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let t=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[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")},ko=()=>Ne.isiOS?"iOS":Ne.isAndroid?"Android":Ne.isMac?"Mac":Ne.isFacebook?"Facebook":"PC",Co="1.1.4-beta.10",Ue=()=>Co,Po="device_id",Do="advertising_id",Ur=t=>(localStorage.getItem(t)||localStorage.setItem(t,Nr()),localStorage.getItem(t)),Lt=()=>Ur(Po),Oo=()=>Ur(Do),Fo=t=>t.charAt(0).toUpperCase()+t.slice(1),No=()=>{let t=new URLSearchParams(window.location.search);return Fo(t.get("utm_source")??"")||"JoliboxSDK"},Lr=()=>{let t="JoliboxWebSDK",e=ko(),n=navigator.language,i=Lt(),u=Oo(),d=Ue();return`${t} (${No()}${e}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${u} version/${d||""}`};var Uo={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Lt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ue()},schema:"",platform:"h5"},Lo=globalThis.joliboxJSCore?.env,te=Object.assign({},Lo?.()??Uo),Bo=()=>{let{payloadJson:t,headerJson:e}=Fr(te.schema),n=`${te.deviceInfo.did}-${new Date().getTime()}`,i=new URLSearchParams(te.schema.length?te.schema:window.location.search),u=i.get("appId")??i.get("gameId")??"",d=t.sessionId??i.get("sessionId")??n,m=!!(t.testAdsMode??i.get("testAdsMode")==="true"),b=t.joliboxEnv??i.get("joliboxEnv")??"production",_=b==="staging";return{get testMode(){return _},get testAdsMode(){return m},get joliboxEnv(){return b},get mpId(){return u??t.id},get mpVersion(){return e.ver??Ue()},get platform(){return te.platform},get deviceInfo(){return te.deviceInfo},get sdkInfo(){return te.sdkInfo},get hostInfo(){return te.hostInfo},get hostUserInfo(){return te.hostUserInfo},get sessionId(){return te.clientSessionId??d??n},onEnvConfigChanged:A=>{Rr(te,A,xr)}}},R=Bo();var Bt=!1,Mr=(t,e)=>t==null?!1:e in t,Mo=t=>Mr(t,"kind"),$o=t=>{let e=t.toLowerCase().split("_");return e[0]+e.slice(1).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Br=(t,e={},n)=>{let i=t.priority??"P1",d={...{user_id:R.hostUserInfo?.uid??"",device_id:R.deviceInfo.did??"",timestamp:Date.now(),tag:$o(t.name)},env:e.environment,isFromUser:n};n?de.emit("GLOBAL_USER_ERROR",t,d):de.emit("GLOBAL_ERROR",t,d)},Vo=t=>Mr(t,"kind")&&t.kind==="USER_ERROR";Nt.on("ERROR_REPORT",({error:t,options:e})=>{if(Bt)return;Bt=!0;let n=Mo(t)&&t.raw?t.raw:t;try{let i=Vo(t);Br(t,e,i)}catch(i){let u=i instanceof Error?i.message:String(i),d=new Ot(`${u}, origin error: ${n.message}`);W.error(d),Br(new Ot(d.message),{environment:e.environment},!1)}finally{Bt=!1}});var Mt=t=>new Dt(t);function $r(t,e){let n=(i,u,d)=>{let m={tag:i,...e,extra:{...u}};i=="globalJsError"?ee(new Cr(JSON.stringify(m),"P0")):t("systemLog",m,d)};return n.debounce=Se(n,500,{leading:!0}),n}function Vr(t){let e=(n,i,u)=>{let d=(u&&JSON.stringify(u))??0,m={speed_value_type:n,total_duration:i};d&&Object.assign(m,{extra:d}),t("joliboxSpeedAnalysis",m)};return e.debounce=Se(e,500,{leading:!0}),e}function jr(t,e){let n=$r(t,e),i=Vr(n);return{track:n,trackPerformance:i}}var Kr=["name","params"],jo=["name","type","location","target","extra","timestamp","userId"],Ko=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function Le(t,e){return e.map(n=>{if(n==="params"&&t[n]){let i=t[n];return Object.keys(i).reduce((u,d)=>(u[d]=String(i[d]),u),{})}return t[n]})}function Jo(t){let e=t.location?Le(t.location,Kr):null,n=t.target?Le(t.target,Kr):null;return Le({...t,location:e,target:n},jo)}function Jr(t){let e=t.events.map(i=>Jo(i)),n=Le(t.device,Ko);return[t.protocolVersion,e,n,t.project]}var Be=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.pushPastTracking=e=>{this.pastTrackings.push(e),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)}}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}getDevice(){let{nativeSDKVersion:e,jssdkVersion:n}=R.sdkInfo;return{platform:1e3,os:R.deviceInfo.platform,appVersion:e??n??"1.0.0",appId:R.hostInfo?.aid??"1",model:R.deviceInfo.model??"UnknownModel",brand:R.deviceInfo.brand??"UnknownBrand",uuid:R.deviceInfo.did,jsSdkVersion:n,extra:{}}}getLocation(){let e=new URLSearchParams(window.location.search),n={};return e.forEach((i,u)=>{n[u]=i}),{name:"GamePage",params:n}}async trackEvent(e,n,i){let u=e.location?e.location:await this.getLocation(),d=e.target||null,m=e.extra||null;this.deviceInfo||(this.deviceInfo=await this.getDevice());let b=this.deviceInfo,A={protocolVersion:"1.0.0",events:[{...e,location:u,target:d,extra:m,timestamp:Date.now(),userId:null}],device:b,project:n};try{i?this.doReport(Jr(A),i):this.doReport(Jr(A)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),W.log("[Jolibox SDK] report API error",I)}}};var $t=t=>{let e=new AbortController;return setTimeout(()=>e.abort(),t),e.signal};AbortSignal.timeout??=$t;var Me=class{constructor(e){this.xua=Lr();this.getJoliSource=()=>new URLSearchParams(window.location.search).get("joliSource")??null;let n=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=e?.baseUrl??n}async get(e,{query:n,headers:i,timeout:u}){let m=new URLSearchParams(n).toString(),b=`${this.baseUrl}${e}${m?`?${m}`:""}`,_=this.xua,A=this.getJoliSource();return i=Object.assign({},i,_?{"x-user-agent":_}:{},A?{"x-joli-source":A}:{}),await(await fetch(b,{method:"GET",headers:i,signal:$t(u??3e4)})).json()}async post(e,{data:n,query:i,headers:u,timeout:d}){let b=new URLSearchParams(i).toString(),_=`${this.baseUrl}${e}${b?`?${b}`:""}`,A=this.xua,I=this.getJoliSource();u=Object.assign({},u,{"Content-Type":"application/json"},A?{"x-user-agent":A}:{},I?{"x-joli-source":I}:{});let x=await fetch(_,{method:"POST",headers:u,body:JSON.stringify(n),signal:$t(d??3e4)}),p=x.headers.get("content-type");if(p?.includes("application/octet-stream"))try{return x.blob()}catch{return await x.arrayBuffer()}if(p?.includes("multipart/form-data")||p?.includes("application/x-www-form-urlencoded"))try{return x.formData()}catch{return await x.text()}if(p?.includes("application/json"))try{return await x.json()}catch{return await x.text()}return x}async put(e,{data:n,query:i,headers:u}){try{let m=new URLSearchParams(i).toString(),b=`${this.baseUrl}${e}${m?`?${m}`:""}`,_=this.xua,A=this.getJoliSource();u=Object.assign({},u,{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},A?{"x-joli-source":A}:{});let I=await fetch(b,{method:"PUT",headers:u,body:JSON.stringify(n??{})});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);return await I.json()}catch(d){throw console.error("Error:",d),d}}};window.JoliboxHttpClient=Me;var ue=Me;var Vt=class extends Be{constructor(){super(...arguments);this.hostToApiMap={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"}};this.httpClient=new ue({baseUrl:this.apiBaseURL})}get apiBaseURL(){let n=this.hostToApiMap[window.location.host]??this.hostToApiMap.default;return R.testMode??!1?n.test:n.prod}doReport(n){this.httpClient.post("/report",{data:n,timeout:5e3}),W.info("Track",n)}},ge=new Vt;var Wo=(t,e)=>{let n={message:e.message,stack:e.stack??"",errorType:e.name,source:0},i={name:t,type:1001,location:null,target:null,extra:n,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ge.trackEvent(i,"web-sdk")};de.on("GLOBAL_ERROR",(t,e)=>{Wo(e.tag,t)});de.on("GLOBAL_USER_ERROR",(t,e)=>{W.log("UserError",t,e)});var $e=class{constructor(e,n){this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(e=>{this.reporter({event:"PLAY_GAME",params:{duration:e}}),this.tracker("PlayGame",{duration:e})});this.interval=n??5*1e3,e.on("visible",i=>{this.visible=i})}start(e){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:e??0}}),this.tracker("OpenGame",{duration:e??0}),this.timer.start()}close(e){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:e}}),this.tracker("CloseGame",{duration:e}),this.timer.stop()}createRAFTimer(e){let n=performance.now(),i,u=!1,d=0,m=b=>{if(!u)return;let _=b-n;_>=this.interval&&(this.visible&&(d+=_,e(d)),n=b),i=requestAnimationFrame(m)};return{start(){u||(u=!0,n=performance.now(),i=requestAnimationFrame(m))},stop(){u=!1,i&&cancelAnimationFrame(i)}}}};var Ve=class extends $e{constructor(n,i,u){super(i,u);this.httpClient=new ue;this.gameId=R.mpId,this.sessionId=R.sessionId,this.track=n}async reporter(n){let{event:i,params:u}=n;await this.httpClient.post("/api/base/app-event",{data:{eventType:i,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...u}}}),W.log("-----task tracker-----",i,u)}tracker(n,i=null){this.track(n,i)}};var Gr=X(),zo={type:"web-sdk",platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:G,trackPerformance:Yo}=jr((...t)=>{let[,e]=t,n=e,u={...wr(n.extra)?n.extra:kt(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""},d={name:e.tag,type:1e3,location:null,target:null,extra:u,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ge.trackEvent(d,"web-sdk")},zo);Gr.registerCommand("ReportSDK.traceSystemTimeline",({event:t,duration:e})=>{Yo(t,e)});Gr.registerCommand("ReportSDK.traceSystem",({event:t,info:e})=>{G(t,e)});var jt=new he,re=new Ve(G,jt);function Hr(t){let e=Ft.config[t];return e||(e={},Ft.config[t]=e),(n,i)=>{if(e[n]){W.warn(`[can i use] ${n} already registered`);return}e[n]={...i}}}var Wr=!1;function Kt(t){Wr=t}function je(t){return t===null||typeof t!="object"?t:Array.isArray(t)?t.map(e=>je(e)):Object.keys(t).reduce((e,n)=>(e[n]=je(t[n]),e),{})}var $=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(e){if(Wr)if(typeof e=="string")this.errors.push(e);else{let n=`${this.path} should be ${e.expect}`;this._optional&&e.expect!=="undefined"?n+=" or undefined, ":n+=", ",n+=`but got ${Jt(e.actual)}`,this.errors.push(n)}return!1}fallback(e){return this.hasFallback=!0,this._fallback=e,this}get fallbackValue(){return je(this._fallback)}default(e){return this.hasDefault=!0,this._default=e,this}get defaultValue(){return typeof this._default=="function"?this._default:je(this._default)}optional(){return this._optional=!0,this}};function se(t){return typeof t=="number"}function Jt(t){let e=Gt(t);switch(e){case"string":return`"${t}"`;case"number":case"boolean":case"null":case"undefined":return String(t);default:return`a(n) ${e}`}}function Gt(t){return typeof t=="function"?"function":Object.prototype.toString.call(t).slice(8).slice(0,-1).toLowerCase()}var Ke=class extends ${validate(e){return this._optional&&e===void 0?!0:se(e)?se(this._min)&&e<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):se(this._max)&&e>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):se(this._greater)&&e<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&e!==Math.floor(e)?this.fail(`the value of ${this.path} should be integer but got ${e}`):!0:this.fail({expect:"number",actual:e})}min(e){return this._min=e,this}max(e){return this._max=e,this}isInt(e){return this._isInt=e,this}greater(e){return this._greater=e,this}},Je=class extends ${validate(e){return this._optional&&e===void 0?!0:typeof e!="boolean"?this.fail({expect:"boolean",actual:e}):!0}},Ge=class extends ${validate(e){if(this._optional&&e===void 0)return!0;if(typeof e!="string")return this.fail({expect:"string",actual:e});if(se(this._maxLength)&&e.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(se(this._minLength)&&e.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(e))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(e))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(e){return this._minLength=e,this}maxLength(e){return this._maxLength=e,this}pattern(e){return this._pattern=e,this}},He=class extends ${validate(e){return this._optional&&e===void 0?!0:typeof e!="symbol"?this.fail({expect:"symbol",actual:e}):!0}},ve=class extends ${validate(e){return!0}},We=class extends ${validate(e){return e!==void 0?this.fail({expect:"undefined",actual:e}):!0}},ze=class extends ${validate(e){return this._optional&&e===void 0?!0:e!==null?this.fail({expect:"null",actual:e}):!0}},Ye=class extends ${validate(e){return this._optional&&e===void 0?!0:typeof e!="function"?this.fail({expect:"function",actual:e}):!0}},qe=class extends ${constructor(...e){super(),this._items=e}validate(e){if(this._optional&&e===void 0)return!0;if(!this._items.includes(e)){let n=this._items.map(i=>JSON.stringify(i)).join(", ");return this.fail(`expect ${this.path} to be one of ${n}, but got ${Jt(e)}`)}return!0}},Qe=class extends ${constructor(n){super();this._item=n}validate(n){if(this._optional&&n===void 0)return!0;if(!Array.isArray(n))return this.fail({expect:"array",actual:n});if(se(this._minItems)&&n.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(se(this._maxItems)&&n.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(se(this._length)&&n.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let i=this._item;if(!i)return!0;let u=!0;if(n.forEach((d,m)=>{if(i.path=`${this.path}[${m}]`,i.errors=this.errors,d===void 0&&i.hasDefault){n[m]=i.defaultValue;return}i.validate(d)||(i.hasFallback?n[m]=i.fallbackValue:u=!1)}),this._uniqueItems){let d=new Map;for(let m in n)d.has(n[m])?u=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${d.get(n[m])}] and ${this.path}[${m}] are identical)`):d.set(n[m],m)}return u}minItems(n){return this._minItems=n,this}maxItems(n){return this._maxItems=n,this}uniqueItems(){return this._uniqueItems=!0,this}length(n){return this._length=n,this}},Xe=class extends ${constructor(n){super();this._value=n}validate(n){if(this._optional&&n===void 0)return!0;if(Gt(n)!=="object")return this.fail({expect:"object",actual:n});let u=n,d=this._value;d.errors=this.errors;let m=!0;for(let b in u){let _=u[b];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(b)?d.path=`${this.path}.${b}`:d.path=`${this.path}["${b}"]`,!(_===void 0&&d._optional)){if(_===void 0&&d.hasDefault){u[b]=d.defaultValue;continue}d.validate(_)||(d.hasFallback?u[b]=d.fallbackValue:m=!1)}}return m}},Ze=class extends ${constructor(n={}){super();this._object=n}validate(n){if(this._optional&&n===void 0)return!0;if(Gt(n)!=="object")return this.fail({expect:"object",actual:n});let i=n,u=!0;for(let d in this._object){let m=i[d],b=this._object[d];if(b.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?b.path=`${this.path}.${d}`:b.path=`${this.path}["${d}"]`,!(b._optional&&m===void 0)){if(m===void 0&&b.hasDefault){i[d]=b.defaultValue;continue}b.validate(m)||(b.hasFallback?i[d]=b.fallbackValue:u=!1)}}return u}},et=class extends ${constructor(n){super();this.value=n}validate(n){return n===void 0&&this._optional?!0:n!==this.value?this.fail({expect:Jt(this.value),actual:n}):!0}},tt=class extends ${constructor(...e){super(),this._items=e}validate(e){if(e===void 0&&this._optional)return!0;let n=[],i=!1,u=this._items.length;for(let d=0;d<u;d++){let m=this._items[d];if(m.errors=[],m.path=this.path,!m.validate(e))n.push(m.errors.join("; "));else if(!i){i=!0;break}}if(!i){let d=n.join(`
|
|
2
|
+
or `);this.errors.push(d)}return i}},rt=class extends ${constructor(...e){super(),this._items=e;let n=0,i=e.length-1;for(;i>=0;i--){let u=e[i];if(u._optional||u.hasDefault)n+=1;else break}this._minItems=e.length-n}validate(e){if(e===void 0&&this._optional)return!0;if(!Array.isArray(e))return this.fail({expect:"array",actual:e});if(e.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let n=!0;return this._items.forEach((i,u)=>{if(i.path=`${this.path}[${u}]`,i.errors=this.errors,e[u]===void 0&&i.hasDefault){e[u]=i.defaultValue;return}i.validate(e[u])||(i.hasFallback?e[u]=i._fallback:n=!1)}),n}},nt=class extends ${validate(e){return e===void 0&&this._optional||e instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:e})}},ot=class extends ${constructor(e){super(),this._ctor=e}validate(e){return e===void 0&&this._optional||e instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:e})}};var S={object(t){return new Ze(t)},array(t){return new Qe(t)},tuple(...t){return new rt(...t)},literal(t){return new et(t)},or(...t){return new tt(...t)},symbol(){return new He},record(t){return new Xe(t)},function(){return new Ye},boolean(){return new Je},string(){return new Ge},number(){return new Ke},undefined(){return new We},null(){return new ze},unknown(){return new ve},any(){return new ve},as(){return new ve},arraybuffer(){return new nt},enum(...t){return new qe(...t)},typedarray(t){return new ot(t)}};function Ht(t,e,n="param"){if(t.errors=[],t.path=n,Kt(!0),!t.validate(e)){let i=t.errors.join(`
|
|
3
|
+
`);throw t.errors.length=0,Kt(!1),new TypeError(i)}}var it=1,zr=t=>{function e(i,u){return(...d)=>{let m=Date.now(),b={method:i,trace_id:it};it+=1;let _="SUCCESS",A=`${i}:ok`,I=0;try{if(u.paramsSchema)try{Ht(u.paramsSchema,d,"params")}catch(P){throw Mt(`${i}:fail ${P.message}`)}let x=u.implement(...d),p=x,T=`${i}:ok`;if(x&&"code"in x){let{code:P,data:N,message:K}=x;_=P,p=N,T=K}return{code:_,message:T,data:p}}catch(x){let p=x;I=p.code??p.errNo??2e3,_="FAILURE";let T=p.message??p.errMsg??`${x}`;return A=`${i}:${_} ${T.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Fe(A,I)),{code:_,message:A}}finally{let x=Date.now()-m;t("apiInvoked",{...b,duration:x,status:_})}}}function n(i,u){return async(...d)=>{let m=Sr(d)?d:[d],b=Date.now(),_={method:i,trace_id:it};it+=1;let A=`${i}:ok`,I="SUCCESS",x={code:I,message:A};try{if(u.paramsSchema)try{Ht(u.paramsSchema,m,"params")}catch(P){throw Mt(P.message)}let T=await u.implement(...m);if(T&&"code"in T){let{code:P,data:N,message:K}=T;I=P,A=K,T=N}return Object.assign(x,{code:I,message:A,data:T}),x}catch(p){let T=p,P=T.code??T.errNo??2e3;I="FAILURE";let N=T.message??T.errMsg??`${p}`,K=`${i}:${I} ${N.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:I,message:K}),ee(new Fe(K,P)),x}finally{let p=Date.now()-b;t("apiInvoked",{..._,duration:p,status:I})}}}return{createAPI:n,createSyncAPI:e}};var{createAPI:Z,createSyncAPI:fe}=zr(G),j=Hr("h5");var Yr=X(),Qo="env",Xo="getSystemInfoSync",Zo=()=>{let t={system:R.deviceInfo.system,platform:R.deviceInfo.platform,brand:R.deviceInfo.brand,pixelRatio:R.deviceInfo.pixelRatio,language:R.deviceInfo.lang,version:R.sdkInfo.jssdkVersion,appName:R.hostInfo?.appName,SDKVersion:R.sdkInfo.nativeSDKVersion},e=R.hostInfo?.version;e&&(t={...t,version:e});let n=R.hostInfo?.appName;n&&(t={...t,appName:n});let i=R.sdkInfo?.jssdkVersion;return i&&(t={...t,SDKVersion:i}),t},ei=fe(Xo,{implement:Zo}),ti=fe(Qo,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Yr.registerCommand("API.env",ti);Yr.registerCommand("API.getSystemInfoSync",ei);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var ri="onJoliboxShow",ni="onJoliboxHide",oi="onReady",zt=X(),Yt=Pr(ee),Wt=!0,Re=!0,st=0,at=jt;function ii(){let t=Date.now();if(t-st<100)return;st=t;let e=document.visibilityState==="visible";e!==Wt&&(Wt=e,at.emit("visible",Wt))}function qr(t){let e=Date.now();e-st<100||(st=e,t==="focus"&&!Re?Re=!0:t==="blur"&&Re&&(Re=!1),at.emit("visible",Re))}document.addEventListener("visibilitychange",ii);window.addEventListener("focus",()=>qr("focus"));window.addEventListener("blur",()=>qr("blur"));var si=fe(ri,{paramsSchema:S.tuple(S.function()),implement(t){let e=Yt(t);at.on("visible",n=>{n&&e()})}}),ai=fe(ni,{paramsSchema:S.tuple(S.function()),implement(t){let e=Yt(t);at.on("visible",n=>{!n&&e()})}}),ci=fe(oi,{paramsSchema:S.tuple(S.function()),implement(t){let e=Yt(t);Ae.on("LifecycleEvent.onReady",n=>{e(n)})}});zt.registerCommand("LifecycleSDK.onReady",ci);zt.registerCommand("LifecycleSDK.onJoliboxShow",si);zt.registerCommand("LifecycleSDK.onJoliboxHide",ai);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var Zr=uo(Xr()),ct=X(),Qt=class{constructor(){this.getGameId=()=>R.mpId;this.getItem=async e=>{let{code:n,data:i,message:u}=await this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:e}}),d=i?.value,m=u;return n!=="SUCCESS"&&(d=await this.gameStore.getItem(e),console.info("[SDK] cloud storage getItem failed, read from localstorage",d),m+="fallback to localstorage"),{code:n,message:m,data:d&&d!=="undefined"?d:null}};this.setItem=async(e,n)=>{let i=typeof n=="string"?n:String(n),{code:u,message:d}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:e,value:i}});return await this.gameStore.setItem(e,i),{code:u,message:d}};this.removeItem=async e=>{await this.gameStore.removeItem(e);let{code:n,message:i}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:e}});return{code:n,message:i}};this.clear=async()=>{await this.gameStore.clear();let{code:e,message:n}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:e,message:n}};this.gameId=this.getGameId(),this.httpClient=new ue({baseUrl:R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}),this.gameStore=Zr.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},ut=new Qt,ui=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(t){return await ut.getItem(t)}});ct.registerCommand("StorageSDK.getItem",ui);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var li=Z("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),async implement(t,e){return await ut.setItem(t,e)}});ct.registerCommand("StorageSDK.setItem",li);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var di=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(t){return await ut.removeItem(t)}});ct.registerCommand("StorageSDK.removeItem",di);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var fi=Z("clearStorage",{async implement(){return await ut.clear()}});ct.registerCommand("StorageSDK.clear",fi);j("storage.clear",{version:"1.0.0"});var ye=X(),mi=Z("levelFinished",{paramsSchema:S.tuple(S.string(),S.object({result:S.boolean(),duration:S.number()})),implement:async(t,e)=>{let{result:n,duration:i}=e;W.info("onLevelFinished",n,i),await Promise.all([re.reporter({event:"COMPLETE_GAME_LEVEL"}),re.tracker("LevelFinished",{levelId:t,result:n,duration:i})])}}),pi=Z("taskFinished",{paramsSchema:S.tuple(S.string(),S.object({duration:S.number()})),implement:async(t,e)=>{let{duration:n}=e;await re.tracker("TaskFinished",{duration:n,taskId:t})}}),hi=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(t,e)=>await re.tracker("LevelUpgrade",{name:e,levelId:t})}),gi=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async t=>await re.tracker("HistoryUserLevel",{level:t})}),vi=Z("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:async t=>await re.tracker("HistoryUserScore",{score:t})}),yi=Z("taskEvent",{paramsSchema:S.tuple(S.string(),S.object({tools:S.array(S.object({id:S.string(),name:S.string(),count:S.number(),description:S.string().optional(),price:S.object({amount:S.number(),unit:S.string()}).optional()})).optional(),awards:S.array(S.object({id:S.string(),name:S.string()})).optional()})),implement:async(t,e)=>{e.tools?.length&&await Promise.all([re.reporter({event:"USE_GAME_ITEM"}),re.tracker("UseGameItem",{taskId:t,...e})])}});ye.registerCommand("TaskTrackerSDK.levelFinished",mi);ye.registerCommand("TaskTrackerSDK.taskFinished",pi);ye.registerCommand("TaskTrackerSDK.levelUpgrade",hi);ye.registerCommand("TaskTrackerSDK.historyUserLevel",gi);ye.registerCommand("TaskTrackerSDK.historyUserScore",vi);ye.registerCommand("TaskTrackerSDK.taskEvent",yi);j("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});j("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});j("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});j("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}});var lt=class{constructor(){this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{G("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{G("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",e=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};var en="jolibox-sdk-ads-callbreak-timestamps",dt=class{constructor(e){this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.report=ge;this.initCallAdsTimestampsForTime=()=>{try{let e=JSON.parse(window.localStorage.getItem(en)??"[]");Array.isArray(e)?this._callAdsTimestampsForTime=e:this._callAdsTimestampsForTime=[]}catch{this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=e=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let n=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:n,type:e}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&n-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=e=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let n=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:n,type:e}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&n-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=e=>{if(!this.report.networkIsOk)return"NETWORK_NOT_OK";let n=this.checkShouldBannedInitial();if(n)return n;let i=this.checkShouldBannedForSession(e);if(i)return i;let u=this.checkShouldBannedForTime(e);return u||"ALLOWED"};if(this.maxAllowedAdsForTime=e?.maxAllowedAdsForTime??8,this.bannedForTimeThreshold=e?.bannedForTimeThreshold??6e4,this.bannedReleaseTime=e?.bannedReleaseTime??6e4,this.maxAllowedAdsForSession=e?.maxAllowedAdsForSession??200,this.bannedForSessionThreshold=e?.bannedForSessionThreshold??6e5,this.initialThreshold=e?.initialThreshold??2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(e){try{window.localStorage.setItem(en,JSON.stringify(e))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=e}};var ft=X(),Xt=class{constructor(){this.configured=!1;this.config={};this.httpClient=new ue;this.getGameId=()=>new URLSearchParams(window.location.search).get("gameId")??this.config.gameId;this.getTestAdsMode=()=>new URLSearchParams(window.location.search).get("testAdsMode")==="true";this.asyncLoad=async()=>{let e="ca-pub-7171363994453626",n,i,u=window.encodeURIComponent(window.btoa(this.getGameId()??"")),d=this.getTestAdsMode()??!1;try{let m=await this.httpClient.get("/public/ads",{query:{objectId:u,testAdsMode:`${d}`}});e=m.data?.clientId,n=m.data?.channelId,i=m.data?.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=e,this.channelId=n,this.unitId=i};this.asyncInit=async e=>{if(typeof window>"u")return;await this.asyncLoad();let n="google-adsense",i=this.getTestAdsMode()??!1;if(!document.getElementById(n)&&this.clientId){let u=document.createElement("script");u.id=n,u.async=!0,u.crossOrigin="anonymous",u.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,i&&u.setAttribute("data-adbreak-test","on"),this.channelId&&u.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(u),G("LoadAdsenseCompleted",null)}};this.push=(e={})=>{window.adsbygoogle.push(e)};this.adConfig=e=>{let{onReady:n,...i}=e;G("CallAdConfig",i),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(e))};this.adBreak=e=>{if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}let n=this.antiCheating.checkAdsDisplayPermission(e.type==="reward"?"reward":"interstitial");switch(n){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",n),e.adBreakDone?.({breakType:e.type,breakName:n,breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),G("PreventAdsCheating",{reason:n});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",n),e.adBreakDone?.({breakType:e.type,breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),G("PreventAdsCheating",{reason:n});return;default:break}let i=e.type,u=e.adBreakDone,d=b=>{this.adsActionDetection.adBreakIsShowing=!1,G("CallAdBreakDone",{breakType:b.breakType,breakName:b.breakName??"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),u&&u(b)};if(e.adBreakDone=d,e.type==="reward"){let b=e.beforeReward,_=I=>()=>{G("CallShowAdFn",null),I()},A=I=>{b&&b(_(I))};e.beforeReward=A}let m;switch(i){case"preroll":m={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":m={type:i,name:e.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,G("CallAdBreak",m),this.push(e),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=async e=>{if(G("CallAdUnit",{adFormat:e.adFormat?.toString()??null,fullWidthResponsive:e.fullWidthResponsive??null}),this.clientId||await this.asyncLoad(),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:n,slot:i,adFormat:u,fullWidthResponsive:d,style:m}=e,b;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?b=document.querySelector(n):b=n,!b)throw new Error("targeting element not found");let _=i;if(_||(_=this.unitId),!_)throw new Error("slot is required");let A=typeof u=="object"&&Array.isArray(u)?u.join(", "):u,I=document.createElement("ins");if(I.className="adsbygoogle",I.id="jolibox-ads",I.style.display="block",I.setAttribute("data-ad-client",this.clientId),I.setAttribute("data-ad-slot",_),A&&I.setAttribute("data-ad-format",A),d&&I.setAttribute("data-full-width-responsive",d),m&&I.setAttribute("style",m),this.getTestAdsMode()??!1){let p=document.createElement("div");p.style.position="absolute",p.style.top="0",p.style.left="0",p.style.width="100%",p.style.height="100%",p.style.display="flex",p.style.justifyContent="center",p.style.alignItems="center",p.style.backgroundColor="rgba(0, 0, 0, 0.5)",p.style.color="white",p.innerHTML="Test Ad",I.style.position="relative",b.appendChild(I),I.appendChild(p)}else b.appendChild(I),new MutationObserver(T=>{T.forEach(P=>{if(P.type==="attributes"&&P.attributeName==="data-ad-status"){let N=I.getAttribute("data-ad-status");G("AdSenseUnitStatusChanged",{status:N??"null"})}})}).observe(I,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new dt,this.adsActionDetection=new lt}init(e){G("CallAdsInit",null),!(typeof window>"u")&&(this.config=e??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(e))}};var mt=new Xt;ft.registerCommand("AdsSDK.init",t=>{mt.init(t)});ft.registerCommand("AdsSDK.adConfig",t=>{mt.adConfig(t)});ft.registerCommand("AdsSDK.adBreak",t=>{mt.adBreak(t)});ft.registerCommand("AdsSDK.adUnit",t=>{mt.adUnit(t)});function bi(){Ae.on("onDocumentReady",t=>{Ae.emit("LifecycleEvent.onReady",{isLogin:!1}),re.start(Date.now()-t)})}function tn(){bi()}tn();
|
|
4
|
+
/*! Bundled license information:
|
|
5
|
+
|
|
6
|
+
localforage/dist/localforage.js:
|
|
7
|
+
(*!
|
|
8
|
+
localForage -- Offline Storage, Improved
|
|
9
|
+
Version 1.10.0
|
|
10
|
+
https://localforage.github.io/localForage
|
|
11
|
+
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
12
|
+
*)
|
|
13
|
+
*/
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var ln=Object.create;var Mt=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var d=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var hn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pn(t))!fn.call(e,o)&&o!==r&&Mt(e,o,{get:()=>t[o],enumerable:!(n=mn(t,o))||n.enumerable});return e};var vn=(e,t,r)=>(r=e!=null?ln(dn(e)):{},hn(t||!e||!e.__esModule?Mt(r,"default",{value:e,enumerable:!0}):r,e));function yn(e){return!!e?.__nativeBuffers__}function le(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!yn(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=bn(n.base64)),typeof o<"u"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Lt(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:kn(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var bn,kn,Ze=d(()=>{"use strict";bn=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};kn=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function _n(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vt(e){return typeof e=="object"&&Array.isArray(e)}function Rn(e){return typeof e>"u"}function Sn(e){return Rn(e)||e===null}function $t(e){return typeof e=="function"}function Kt(e){return N(e)&&$t(e.then)}function Ht(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function Bt(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],l=s[i],u=r(a,l,i,o,s);u!==void 0?o[i]=u:Ft(l)&&Ft(a)?o[i]=n({...a},l):Array.isArray(l)&&Array.isArray(a)?o[i]=[...a,...l]:o[i]=l}return o}return n(e,t)}function Ft(e){return e&&typeof e=="object"&&e.constructor===Object}function qt(e,t){if(Array.isArray(e))return e.concat(t)}function de(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:l=!0}=r,u=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),m=function(...p){o=p,s=this;let f=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!f&&u()},t),f)return u()};return m.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,u()},m}function wn(e,t){return(...r)=>t(e,...r)}function ke(e){return t=>wn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new st(`${o}`))}})}function me(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function Pn(e){return new Promise(t=>Zt(e)(t))}function Zt(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Dn(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new pe(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Mn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ln(e[n],t[n])}function Ln(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if($t(t)){try{if(e instanceof t)return}catch{}if(!Sn(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function S(){if(globalThis[tt])return globalThis[tt];let e=new ye,t=new nt,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[tt]=r,r}var jt,Tn,En,Jt,W,xn,ot,ee,In,st,Gt,zt,Wt,Qt,Yt,fe,be,it,R,Xt,An,at,b,Cn,Nn,he,pe,Q,rt,On,et,Un,K,ye,nt,tt,h=d(()=>{"use strict";jt=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,En=(e,t)=>{for(var r in t)jt(e,r,{get:t[r],enumerable:!0})},Jt=(e,t,r,n)=>{for(var o=n>1?void 0:n?Tn(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&&jt(t,r,o),o};W=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};xn=(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))(xn||{}),ot=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}},ee=class extends ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},In=class extends ot{constructor(){super(...arguments),this.kind="USER_ERROR"}},st=class extends In{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Gt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},zt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Wt=class extends ee{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Qt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Yt=class extends ee{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends ot{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}}},be=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},it=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};R={log:me("log"),warn:me("warn"),info:me("info"),error:me("error"),debug:me("debug")};Object.assign(globalThis,{logger:R});Xt=Symbol.for("Jolibox.canIUseMap"),An={};globalThis[Xt]=An;at={get config(){return globalThis[Xt]}},b=class ve{static{this.Undefined=new ve(void 0)}constructor(t){this.element=t,this.next=ve.Undefined,this.prev=ve.Undefined}},Cn=class{constructor(){this._first=b.Undefined,this._last=b.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===b.Undefined}clear(){let e=this._first;for(;e!==b.Undefined;){let t=e.next;e.prev=b.Undefined,e.next=b.Undefined,e=t}this._first=b.Undefined,this._last=b.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new b(e);if(this._first===b.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!==b.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==b.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==b.Undefined&&e.next!==b.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===b.Undefined&&e.next===b.Undefined?(this._first=b.Undefined,this._last=b.Undefined):e.next===b.Undefined?(this._last=this._last.prev,this._last.next=b.Undefined):e.prev===b.Undefined&&(this._first=this._first.next,this._first.prev=b.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==b.Undefined;)yield e.element,e=e.next}},Nn=0,he=class{constructor(e){this.value=e,this.id=Nn++}},pe=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof he&&(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 he(e);this._listeners?this._listeners instanceof he?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 he?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 pe,n=s=>t(...s.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire({event:e,...o.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 Cn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rt={};En(rt,{None:()=>On,filter:()=>Dn,once:()=>Zt,toPromise:()=>Pn});On=()=>{console.log("[Jolibox SDK] None Event")};et=Symbol.for("Jolibox.hostEmitter"),Un=()=>{let e=new Q;return globalThis[et]||(globalThis[et]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[et]},K=Un();ye=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new pe,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 Mn(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}};ye=Jt([Ht],ye);nt=class{constructor(){this._onWillExecuteCommand=new pe,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new pe,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new ye,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=_n(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),rt.toPromise(rt.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}}};nt=Jt([Ht],nt);tt=Symbol.for("Jolibox.commands")});function I(e,t={}){ct.emit("ERROR_REPORT",{error:e,options:t})}var ct,te,U=d(()=>{"use strict";h();h();ct=new Q,te=new Q;I.debounce=de(I,50,{leading:!0})});function Te(e,t){return`[${e}]:${t}`}var re,ut,Y=d(()=>{"use strict";U();h();U();re=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),ut=e=>new st(e)});var er,tr,rr,nr=d(()=>{"use strict";er=[],tr=[],rr=["env","createRequestTask","login"]});function sr(e,t){or||(lt=new ne({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),mt=new ne({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),pt=new ne({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{lt.flush(),mt.flush(),pt.flush()}),or=!0);function r(o){let{method:s,args:i,startTime:a,isForeground:l,errMsg:u=`${s}:fail no errMsg`,errNo:m=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:f,invokeCallback:v}=p,_=u.match(/\S:(\S+)\s?/)?.[1]??"fail";lt.report({status:_,method:n(s,i),errNo:`${m}`,errMsg:u,isForeground:l,duration:Date.now()-a}),a&&f&&v&&(mt.report({status:_,method:s,isForeground:l,duration:Number((f-a).toFixed(3))}),pt.report({status:_,method:s,isForeground:l,duration:Number((Date.now()-v).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s?.method?`${o}-${s.method}`:o}return r}var Fn,ne,or,lt,mt,pt,dt=d(()=>{"use strict";h();Fn=e=>e==="pv"?e:"default",ne=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=Fn(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,o,s,i)=>{let a=o.shift();if(a){let l=i[a];n[l]||(n[l]={}),r(n[l],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let l=s.shift();if(!l&&N(a))throw new be(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(l){let u=[];if(N(a))u.push(...Object.keys(a));else if(Z(a)){if(s.length>0)throw new be(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);u.push(a)}else throw new be(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);u.forEach(m=>{o[m]||(o[m]={});let p=N(a)?a[m]:a;r(o[m],[...s],i,p)})}else o[i]?o[i]++:o[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},or=!1});function ar(e,t){let r=0,n=!0,o=new Map,s=sr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ft.forEach(async({method:u,args:m,resolve:p})=>{let f=await a(u,m);p(f)}),ft.length=0});let i=(u,m)=>{R.info("----resolveId",u,m);let p=o.get(Number(u));if(!p)return;let f=le(m);p(f),o.delete(Number(u))},a=(u,m)=>{let p=Date.now(),f=`${n}`;r+=1;let v=new W;if(o.set(r,v.resolve),!n&&tr.includes(u))return new Promise(C=>{ft.push({method:u,args:m,resolve:C})});let A={...{method:u,startTime:p,args:m,isForeground:f},invokeType:"js-bridge"},O=!jn&&er.includes(u),G=Lt(m,O),z=O?G:JSON.stringify(G),k;if(u.endsWith("Sync")||rr.includes(u)?k=e.call?.(u,G,r):typeof z=="string"?(console.log("-----params",u,r),k=e.invoke(u,z,r)):k=e.call?.(u,z,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=le(k)}catch(C){R.error(C)}return o.delete(r),k.errorCode&&(k.errorCode=Te(u,k.errorCode)),s({...A,...k}),k}return u.endsWith("Sync")&&o.delete(r),v.promise.then(C=>(C.errorCode&&(C.errorCode=Te(u,C.errorCode)),s({...A,...C}),C))};return{invokeNative:a,applyNative:(u,m)=>{let p=a(u,m);return Kt(p)?p.then(f=>ir(u,f)):ir(u,p)},invokeHandler:i}}function ir(e,t){if(!N(t)){R.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:o,errorCode:s,...i}=t;if(r&&r!==`${e}:ok`)throw new Wt(r,n,o,s);return i}var ft,jn,cr=d(()=>{"use strict";Ze();h();Y();nr();dt();ft=[],jn=!1});function ur(e){let t=new Q,r=new ne({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,o,s){let i=le(o),a;if(i.__extra){a=i.params;let{type:l,startTime:u}=i.__extra;r.report({type:l,event:n,duration:Date.now()-u})}else a=i;t.emit(n,a,s)}}}var lr=d(()=>{"use strict";h();Ze();dt()});function gt(e){let{subscribeHandler:t,onNative:r,offNative:n}=ur(e),{invokeNative:o,invokeHandler:s,applyNative:i}=ar(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var mr=d(()=>{"use strict";cr();lr()});var pr=d(()=>{"use strict"});var dr=d(()=>{"use strict";mr();pr()});var X,M,fr,gr=d(()=>{"use strict";h();U();M={trigger(){},exit(){return!1},onReady(e){M.trigger=e},doExit(e){M.exit=e}},fr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)I(new zt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{M.trigger(),e.onDocumentReady.postMessage({path:o})};X={onDocumentReady:t,doExit:o=>{let s=M.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})},invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:fr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{M.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};X={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=M.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:fr};globalThis.joliboxJSCore={...n}}});function ht(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var vt=d(()=>{"use strict"});function yt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ie]=e.ports,ie.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ie.publish=function(t,r){let n=ht(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,hr=d(()=>{"use strict";vt()});var Ee=d(()=>{"use strict";gr();hr();vt()});var yr,Jn,br,vr,P,w,J,ui,Vn,L=d(()=>{"use strict";dr();Ee();Y();h();Ee();yr=X;if(!yr)throw new Qt("No joliboxJScore is found, native bridge not found.");yt();Jn={...yr},br=gt(Jn),{invokeHandler:vr}=br,{applyNative:P,invokeNative:w,onNative:J,offNative:ui,subscribeHandler:Vn}=br;globalThis.joliboxJSBridge={callHandler:vr,invokeHandler:vr,subscribeHandler:Vn}});var bt,kr,Tr=d(()=>{"use strict";h();U();bt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch{return{}}},kr=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[o,s,i]=n;return{headerJson:bt(o),payloadJson:bt(s),signature:bt(i)}}else throw"joli_source is missing"}catch(t){return I(new Gt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Er,_r=d(()=>{"use strict";Er=()=>"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 _e,$n,Kn,Re,Hn,Bn,Rr,kt,qn,Gn,zn,Sr,Tt=d(()=>{"use strict";_r();_e={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")},$n=()=>_e.isiOS?"iOS":_e.isAndroid?"Android":_e.isMac?"Mac":_e.isFacebook?"Facebook":"PC",Kn="1.1.4-beta.10",Re=()=>Kn,Hn="device_id",Bn="advertising_id",Rr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Er()),localStorage.getItem(e)),kt=()=>Rr(Hn),qn=()=>Rr(Bn),Gn=e=>e.charAt(0).toUpperCase()+e.slice(1),zn=()=>{let e=new URLSearchParams(window.location.search);return Gn(e.get("utm_source")??"")||"JoliboxSDK"},Sr=()=>{let e="JoliboxWebSDK",t=$n(),r=navigator.language,n=kt(),o=qn(),s=Re();return`${e} (${zn()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${n} adid/${o} version/${s||""}`}});var Wn,Qn,F,Yn,y,H=d(()=>{"use strict";h();Tr();Tt();Wn={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:kt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Re()},schema:"",platform:"h5"},Qn=globalThis.joliboxJSCore?.env,F=Object.assign({},Qn?.()??Wn),Yn=()=>{let{payloadJson:e,headerJson:t}=kr(F.schema),r=`${F.deviceInfo.did}-${new Date().getTime()}`,n=new URLSearchParams(F.schema.length?F.schema:window.location.search),o=n.get("appId")??n.get("gameId")??"",s=e.sessionId??n.get("sessionId")??r,i=!!(e.testAdsMode??n.get("testAdsMode")==="true"),a=e.joliboxEnv??n.get("joliboxEnv")??"production",l=a==="staging";return{get testMode(){return l},get testAdsMode(){return i},get joliboxEnv(){return a},get mpId(){return o??e.id},get mpVersion(){return t.ver??Re()},get platform(){return F.platform},get deviceInfo(){return F.deviceInfo},get sdkInfo(){return F.sdkInfo},get hostInfo(){return F.hostInfo},get hostUserInfo(){return F.hostUserInfo},get sessionId(){return F.clientSessionId??s??r},onEnvConfigChanged:u=>{Bt(F,u,qt)}}},y=Yn()});var Et,Ir,Xn,Zn,xr,eo,wr=d(()=>{"use strict";h();U();H();h();Et=!1,Ir=(e,t)=>e==null?!1:t in e,Xn=e=>Ir(e,"kind"),Zn=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},xr=(e,t={},r)=>{let n=e.priority??"P1",s={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:Zn(e.name)},env:t.environment,isFromUser:r};r?te.emit("GLOBAL_USER_ERROR",e,s):te.emit("GLOBAL_ERROR",e,s)},eo=e=>Ir(e,"kind")&&e.kind==="USER_ERROR";ct.on("ERROR_REPORT",({error:e,options:t})=>{if(Et)return;Et=!0;let r=Xn(e)&&e.raw?e.raw:e;try{let n=eo(e);xr(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new it(`${o}, origin error: ${r.message}`);R.error(s),xr(new it(s.message),{environment:t.environment},!1)}finally{Et=!1}})});var Ar=d(()=>{"use strict";wr();Y();h();L();te.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};w("trackAsync",{event:"reportJsError",data:r})});te.on("GLOBAL_USER_ERROR",(e,t)=>{R.log("UserError",e,t)})});var _t=d(()=>{"use strict"});function Cr(e,t){let r=(n,o,s)=>{let i={tag:n,...t,extra:{...o}};n=="globalJsError"?I(new Yt(JSON.stringify(i),"P0")):e("systemLog",i,s)};return r.debounce=de(r,500,{leading:!0}),r}function Nr(e){let t=(r,n,o)=>{let s=(o&&JSON.stringify(o))??0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=de(t,500,{leading:!0}),t}var Or=d(()=>{"use strict";h();h();U()});function Pr(e,t){let r=Cr(e,t),n=Nr(r);return{track:r,trackPerformance:n}}var Dr=d(()=>{"use strict";Or()});var Ur=d(()=>{"use strict";H();h()});var Mr=d(()=>{"use strict";Dr();_t();Ur()});var Se,Lr=d(()=>{"use strict";Se=class{constructor(t,r){this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r??5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration:t??0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=performance.now(),n,o=!1,s=0,i=a=>{if(!o)return;let l=a-r;l>=this.interval&&(this.visible&&(s+=l,t(s)),r=a),n=requestAnimationFrame(i)};return{start(){o||(o=!0,r=performance.now(),n=requestAnimationFrame(i))},stop(){o=!1,n&&cancelAnimationFrame(n)}}}}});var Rt=d(()=>{"use strict"});function jr(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:l={}}=n,m={duration:s-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:l.socketReused?1:0,request_from:i};(i==="public"&&Fr<ro||i==="inner")&&(m.joli_request_number=Fr++,setTimeout(()=>{V("joliboxNetRequestResult",m)},500))}var Fr,ro,Jr=d(()=>{"use strict";Rt();oe();Fr=0,ro=10});function xe(e,t,r){let n=new Map,o=r?.baseUrl??"https://api.jolibox.com",s=r?.type??"public",i=r?.defaultHeaders??{};return J("onRequestTaskStateChange",l=>{if(typeof l.requestTaskId!="string")return;let u=n.get(l.requestTaskId);if(u)if(l.state==="success"){let{requestTaskId:m,state:p,...f}=l;u.resolve(f),n.delete(m)}else if(l.state==="fail"){let{requestTaskId:m,state:p,...f}=l;u.reject(f),n.delete(m)}else R.warn("onRequestTaskStateChange unknown event",l)}),K.on("onLoginComplete",({isLogin:l,token:u})=>{l&&u&&(i["X-JOLI-TOKEN"]=u)}),async(l,u={})=>{let m=Date.now(),p=no(l,{...u,baseUrl:o}),{method:f="GET",responseType:v="text",dataType:_="json",timeout:A,enableCache:O=!1,appendHostCookie:G=!0}=u,z=Object.assign({"content-type":"application/json"},i,u.header),k={url:p,method:f,header:z,enableCache:O,responseType:v,appendHostCookie:G};if(f=="POST"||f=="PUT"){let j=so(u.data,z["content-type"]);k.data=j}A&&Object.assign(k,{timeout:A});let{data:{requestTaskId:C}}=w(e,k);if(typeof C!="string")throw re({code:-1,msg:"requestTaskId is not a string"});let ue=(j,$)=>{jr("request",p,{state:j,startTime:m,endTime:Date.now(),params:k,response:$,requestId:C,requestFrom:s=="public"?"public":"inner"})},{resolve:Xe,reject:on,promise:sn}=new W;n.set(C,{resolve:Xe,reject:on});try{let j=await sn;ue("success",j);let{data:$}=j;return _==="json"&&typeof $=="string"&&($=oo($)),{url:p,timeout:A,method:f,response:{...j,data:$}}}catch(j){let $=j;if(N($)){let{errMsg:ge,prefetchDetail:an,isPrefetch:cn,errNo:un}=$;Z(ge)&&(ue("fail",{errMsg:ge,isPrefetch:cn,prefetchDetail:an}),I(re({code:-1,msg:ge},{errNo:un,errMsg:ge})))}throw j}}}function oo(e){try{return JSON.parse(e.trim())}catch{return e}}function so(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var no,St=d(()=>{"use strict";h();Jr();Rt();L();U();Y();no=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,o=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var se,xt=d(()=>{"use strict";Tt();St();H();se=xe("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":Sr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ie,Vr=d(()=>{"use strict";H();Lr();xt();L();Ie=class extends Se{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,o=[];o.push(se("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(o)}async reportToNative(t){let{event:r,params:n}=t;await P("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var io,V,ao,$r,we,D,oe=d(()=>{"use strict";Ar();h();_t();Mr();H();Vr();L();io=(e,t,r)=>{let n=t,s={...N(n.extra)?n.extra:Z(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};w("trackAsync",{event:e,data:s,webviewId:r})},{track:V,trackPerformance:ao}=Pr(io,{type:"app-sdk",platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),$r=S();$r.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{ao(e,t)});$r.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{V(e,t)});we=new Q,D=new Ie(V,we)});function Hr(e){let t=at.config[e];return t||(t={},at.config[e]=t),(r,n)=>{if(t[r]){R.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Br=d(()=>{"use strict";h()});function It(e){qr=e}function Ce(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ce(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ce(e[r]),t),{})}function B(e){return typeof e=="number"}function wt(e){let t=At(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function At(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var qr,T,Ne,Oe,Pe,De,ae,Ue,Me,Le,Fe,je,Je,Ve,$e,Ke,He,Be,qe,Ct=d(()=>{"use strict";qr=!1;T=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(qr)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${wt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ce(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ce(this._default)}optional(){return this._optional=!0,this}};Ne=class extends T{validate(t){return this._optional&&t===void 0?!0:B(t)?B(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):B(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):B(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Oe=class extends T{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Pe=class extends T{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(B(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(B(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},De=class extends T{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends T{validate(t){return!0}},Ue=class extends T{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends T{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends T{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Fe=class extends T{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${wt(t)}`)}return!0}},je=class extends T{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(B(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(B(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(B(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},Je=class extends T{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(At(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let l=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(l===void 0&&s._optional)){if(l===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(l)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},Ve=class extends T{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(At(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},$e=class extends T{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:wt(this.value),actual:r}):!0}},Ke=class extends T{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
|
|
2
|
+
or `);this.errors.push(s)}return n}},He=class extends T{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let o=t[n];if(o._optional||o.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,o)=>{if(n.path=`${this.path}[${o}]`,n.errors=this.errors,t[o]===void 0&&n.hasDefault){t[o]=n.defaultValue;return}n.validate(t[o])||(n.hasFallback?t[o]=n._fallback:r=!1)}),r}},Be=class extends T{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},qe=class extends T{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Nt(e,t,r="param"){if(e.errors=[],e.path=r,It(!0),!e.validate(t)){let n=e.errors.join(`
|
|
3
|
+
`);throw e.errors.length=0,It(!1),new TypeError(n)}}var c,Ot=d(()=>{"use strict";Ct();Ct();c={object(e){return new Ve(e)},array(e){return new je(e)},tuple(...e){return new He(...e)},literal(e){return new $e(e)},or(...e){return new Ke(...e)},symbol(){return new De},record(e){return new Je(e)},function(){return new Le},boolean(){return new Oe},string(){return new Pe},number(){return new Ne},undefined(){return new Ue},null(){return new Me},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Be},enum(...e){return new Fe(...e)},typedarray(e){return new qe(e)}}});var Ge,Gr,zr=d(()=>{"use strict";h();U();Ot();Y();Ge=1,Gr=e=>{function t(n,o){return(...s)=>{let i=Date.now(),a={method:n,trace_id:Ge};Ge+=1;let l="SUCCESS",u=`${n}:ok`,m=0;try{if(o.paramsSchema)try{Nt(o.paramsSchema,s,"params")}catch(_){throw ut(`${n}:fail ${_.message}`)}let p=o.implement(...s),f=p,v=`${n}:ok`;if(p&&"code"in p){let{code:_,data:A,message:O}=p;l=_,f=A,v=O}return{code:l,message:v,data:f}}catch(p){let f=p;m=f.code??f.errNo??2e3,l="FAILURE";let v=f.message??f.errMsg??`${p}`;return u=`${n}:${l} ${v.replace(/^\S+:(fail|cancel)\s?/,"")}`,I(new fe(u,m)),{code:l,message:u}}finally{let p=Date.now()-i;e("apiInvoked",{...a,duration:p,status:l})}}}function r(n,o){return async(...s)=>{let i=Vt(s)?s:[s],a=Date.now(),l={method:n,trace_id:Ge};Ge+=1;let u=`${n}:ok`,m="SUCCESS",p={code:m,message:u};try{if(o.paramsSchema)try{Nt(o.paramsSchema,i,"params")}catch(_){throw ut(_.message)}let v=await o.implement(...i);if(v&&"code"in v){let{code:_,data:A,message:O}=v;m=_,u=O,v=A}return Object.assign(p,{code:m,message:u,data:v}),p}catch(f){let v=f,_=v.code??v.errNo??2e3;m="FAILURE";let A=v.message??v.errMsg??`${f}`,O=`${n}:${m} ${A.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(p,{code:m,message:O}),I(new fe(O,_)),p}finally{let f=Date.now()-a;e("apiInvoked",{...l,duration:f,status:m})}}}return{createAPI:r,createSyncAPI:t}}});var E,x,g,q=d(()=>{"use strict";Br();oe();zr();Ot();({createAPI:E,createSyncAPI:x}=Gr(V)),g=Hr("native")});var Yr=gn(Qr=>{"use strict";h();q();U();L();oe();var ho="exitGame",vo="onReady",yo="onJoliboxShow",bo="onJoliboxHide",ze=S(),We=ke(I),ko=E(ho,{paramsSchema:c.tuple(c.function()),implement:async e=>{We(e).call(Qr),await P("exitAppAsync")}}),To=x(yo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterForeground",()=>{t.call(this),we.emit("visible",!0)})}}),Eo=x(bo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterBackground",()=>{t.call(this),we.emit("visible",!1)})}}),_o=x(vo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});ze.registerCommand("LifecycleSDK.exit",ko);ze.registerCommand("LifecycleSDK.onReady",_o);ze.registerCommand("LifecycleSDK.onJoliboxShow",To);ze.registerCommand("LifecycleSDK.onJoliboxHide",Eo);g("lifeCycle.exit",{version:"1.0.0"});g("lifeCycle.onReady",{version:"1.0.0"});g("lifeCycle.onJoliboxShow",{version:"1.0.0"});g("lifeCycle.onJoliboxHide",{version:"1.0.0"})});L();Ee();H();h();oe();M.onReady(()=>{});M.doExit(()=>(V("onBeforeExit",{timestamp:Date.now()}),D.close(Date.now()-Ae),!1));function co(){K.on("onDocumentReady",()=>{X?.onDocumentReady(window.location.href),V("onDocumentReady",{start_timestamp:Ae,timestamp:Date.now()})})}function uo(){J("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),K.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),V("joliboxServiceReady",{start_timestamp:Ae,timestamp:Date.now()}),D.start(t)}),J("onBeforeExit",({uuid:e})=>{X?.doExit(e)})}var Ae;function Kr(){Ae=Date.now(),uo(),co()}h();q();L();var Wr=S(),mo="env",po="getSystemInfoSync",fo=x(po,{implement:()=>{let e=w("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:t.hostInfo?.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),go=x(mo,{implement:()=>w("envSync")?.data??void 0});Wr.registerCommand("API.getSystemInfoSync",fo);Wr.registerCommand("API.env",go);g("env",{version:"1.0.0"});g("getSystemInfoSync",{version:"1.0.0"});var Kc=vn(Yr());Y();St();q();h();function Xr(e){let t={};if(!N(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function Zr(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function en(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function tn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!N(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify({...JSON.parse(o),...r});return`${n}?${s}`}h();U();var Ro=15,So=xe("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Pt=0,Dt=[],rn=ke(I),xo=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Io=e=>{let t=new W,r=()=>{};return E("request",{paramsSchema:c.tuple(c.object({url:c.string(),method:c.string(),header:c.object(),data:c.object().optional(),query:c.object().optional(),dataType:c.string().default("json"),responseType:c.string().default("text"),enableCache:c.boolean().default(!1),appendHostCookie:c.boolean().default(!0),timeout:c.number().default(3e4),success:c.function(),fail:c.function()})),implement(o){let s=async()=>{let i=rn(o.fail);try{if(Pt+=1,t.state!=="pending")return;let{data:a,dataType:l,responseType:u,enableCache:m,appendHostCookie:p}=o,f=Xr(o.header),v=Zr(o.method),_=en(o.timeout),A=tn(o.url,v,a),O=rn(o.success),G=Object.assign({},o,{method:v,header:f,data:v==="GET"||v==="HEAD"?void 0:a,enableCache:m,query:o.query??{},dataType:l,responseType:u,appendHostCookie:p});_&&(G.timeout=_);let z=So(A,G);{let{response:k}=await z,{code:C,data:ue,message:Xe}=k;t.resolve({code:C??"SUCCESS",data:ue,message:Xe??"request:ok"}),O({code:"SUCCESS",message:"request:ok",data:ue})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Pt-=1,Dt.shift()?.()}};return Pt>=Ro?(r=()=>{xo(Dt,i=>i===s)},Dt.push(s)):s(),t.promise}})(e),{abort(){t.reject(re({code:-1,msg:"request:fail abort"})),r()}}},wo=S();wo.registerCommand("HttpSDK.request",Io);g("request",{version:"1.0.0"});q();L();h();xt();H();var Qe=S(),Ao=E("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await se(`/api/games/user-storage/${y.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:o?.value};try{let{data:{data:s,dataType:i}}=await P("getLocalStorageAsync",{key:e}),a=Uo(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch{return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}}});Qe.registerCommand("StorageSDK.getItem",Ao);g("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Co=E("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:o}=await se(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Do(t),l=Mo(t,a);return await P("setLocalStorageAsync",{key:e,data:l,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}}});Qe.registerCommand("StorageSDK.setItem",Co);g("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var No=E("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=y.mpId,{response:r}=await se(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return await P("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}}});Qe.registerCommand("StorageSDK.removeItem",No);g("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Oo=E("clearStorage",{async implement(){let e=y.mpId,{response:t}=await se(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});P("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});Qe.registerCommand("StorageSDK.clear",Oo);g("storage.clear",{version:"1.0.0"});var _c=E("getStorageInfo",{async implement(){let{data:e}=await P("getStorageInfoAsync");return e}});g("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});var Rc=x("getStorageInfoSync",{implement(){return w("getStorageInfoSync")}}),Po=["string","number","boolean","object",""];function Do(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Po.includes(t)?t:""}function Uo(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch{return""}}function Mo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}h();L();q();var Lo=x("showKeyboard",{paramsSchema:c.tuple(c.object({defaultValue:c.string().optional().default(""),multiple:c.boolean().optional().default(!1),maxLength:c.unknown().optional().default(1e5)})),implement(e){let t=Math.floor(Number(e.maxLength)??1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),w("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});g("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});var Fo=x("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){w("updateKeyboardSync",e)}});g("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});var jo=x("hideKeyboard",{implement(){w("hideKeyboardSync")}});g("keyboard.hideKeyboard",{version:"1.0.0"});var Ut=S();Ut.registerCommand("KeyboardSDK.showKeyboard",Lo);Ut.registerCommand("KeyboardSDK.updateKeyboard",Fo);Ut.registerCommand("KeyboardSDK.hideKeyboard",jo);h();q();oe();var ce=S(),Jo=E("levelFinished",{paramsSchema:c.tuple(c.string(),c.object({result:c.boolean(),duration:c.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,o=[];o.push(D.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(D.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(o)}}),Vo=E("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await D.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),$o=E("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),Ko=E("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Ho=E("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserScore",params:{score:e}})}),Bo=E("taskEvent",{paramsSchema:c.tuple(c.string(),c.object({tools:c.array(c.object({id:c.string(),name:c.string(),count:c.number(),description:c.string().optional(),price:c.object({amount:c.number(),unit:c.string()}).optional()})).optional(),awards:c.array(c.object({id:c.string(),name:c.string()})).optional()})),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(D.reporter({event:"USE_GAME_ITEM"})),r.push(D.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",Jo);ce.registerCommand("TaskTrackerSDK.taskFinished",Vo);ce.registerCommand("TaskTrackerSDK.levelUpgrade",$o);ce.registerCommand("TaskTrackerSDK.historyUserLevel",Ko);ce.registerCommand("TaskTrackerSDK.historyUserScore",Ho);ce.registerCommand("TaskTrackerSDK.taskEvent",Bo);g("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});g("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});g("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});g("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}});H();L();q();h();Y();g("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});g("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});var qo=E("login",{async implement(){let{data:{isLogin:e}}=await P("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};J("onLoginStateChange",({isLogin:i,token:a,uuid:l})=>{l==r&&o({isLogin:i,token:a})});let t=w("loginSync"),{data:{uuid:r}}=t;if(!r)throw re({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new W,s=await n;return y.onEnvConfigChanged({hostUserInfo:s}),K.emit("onLoginComplete",s),s}}),Go=E("checkSession",{async implement(){let{data:{isLogin:e}}=await P("checkLoginAsync");return{isLogin:e}}}),nn=S();nn.registerCommand("API.login",qo);nn.registerCommand("API.checkSession",Go);h();q();var Ye=S(),zo=x("adInit",{implement:e=>{R.log("[JoliboxAdsSDK] adInit",e)}}),Wo=x("adConfig",{implement:e=>{R.log("[JoliboxAdsSDK] adConfig",e)}}),Qo=x("adBreak",{implement:e=>{R.log("[JoliboxAdsSDK] adBreak",e)}}),Yo=x("adUnit",{implement:e=>{R.log("[JoliboxAdsSDK] adUnit",e)}});Ye.registerCommand("AdsSDK.init",zo);Ye.registerCommand("AdsSDK.adConfig",Wo);Ye.registerCommand("AdsSDK.adBreak",Qo);Ye.registerCommand("AdsSDK.adUnit",Yo);g("AdsSDK.init",{version:"1.0.0"});g("AdsSDK.adConfig",{version:"1.0.0"});g("AdsSDK.adBreak",{version:"1.0.0"});g("AdsSDK.adUnit",{version:"1.0.0"});oe();Kr();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const createAPI: <ParamsSchema extends import("@/common/api-factory/validator").Validator<unknown[]>, Inputs extends import("@/common/api-factory/validator").Type<ParamsSchema> & unknown[], Return>(method: string, config: {
|
|
2
|
+
paramsSchema?: ParamsSchema;
|
|
3
|
+
implement: Inputs extends undefined ? () => Promise<Return | import("@jolibox/types").StandardResponse<Return>> : (...params: Inputs) => Promise<Return | import("@jolibox/types").StandardResponse<Return>>;
|
|
4
|
+
}) => (...inputs: unknown[]) => Promise<import("@jolibox/types").StandardResponse<Return>>, createSyncAPI: <ParamsSchema extends import("@/common/api-factory/validator").Validator<unknown[]>, Inputs extends import("@/common/api-factory/validator").Type<ParamsSchema> & unknown[], Return = void>(method: string, config: {
|
|
5
|
+
paramsSchema?: ParamsSchema;
|
|
6
|
+
implement: (...inputs: Inputs) => Return | {
|
|
7
|
+
code: import("@jolibox/types").ResponseType;
|
|
8
|
+
data: Return;
|
|
9
|
+
};
|
|
10
|
+
}) => (...inputs: Inputs) => import("@jolibox/types").StandardResponse<Return>;
|
|
11
|
+
export declare const registerCanIUse: (name: string, config: import("@jolibox/common").CanIUseInfo) => void;
|
|
12
|
+
import { t } from '@/common/api-factory/validator';
|
|
13
|
+
export { t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const showKeyboard: (params: {
|
|
2
|
+
defaultValue?: string | undefined;
|
|
3
|
+
maxLength?: unknown;
|
|
4
|
+
multiple?: boolean | undefined;
|
|
5
|
+
}) => import("@jolibox/types").StandardResponse<void>;
|
|
6
|
+
export declare const updateKeyboard: (params: {
|
|
7
|
+
value: string;
|
|
8
|
+
}) => import("@jolibox/types").StandardResponse<void>;
|
|
9
|
+
export declare const hideKeyboard: () => import("@jolibox/types").StandardResponse<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StandardResponse } from '@jolibox/types';
|
|
2
|
+
/**
|
|
3
|
+
* 移除指定key
|
|
4
|
+
*/
|
|
5
|
+
export declare const removeStorage: (...inputs: unknown[]) => Promise<StandardResponse<void>>;
|
|
6
|
+
/**
|
|
7
|
+
* 异步获取当前storage的相关信息
|
|
8
|
+
*/
|
|
9
|
+
export declare const getStorageInfo: (...inputs: unknown[]) => Promise<StandardResponse<{
|
|
10
|
+
currentSize: number;
|
|
11
|
+
limitSize: number;
|
|
12
|
+
keys: string[];
|
|
13
|
+
}>>;
|
|
14
|
+
/**
|
|
15
|
+
* 同步获取当前storage的相关信息
|
|
16
|
+
*/
|
|
17
|
+
export declare const getStorageInfoSync: () => StandardResponse<{
|
|
18
|
+
errMsg: string;
|
|
19
|
+
errNo?: number;
|
|
20
|
+
data: {
|
|
21
|
+
currentSize: number;
|
|
22
|
+
limitSize: number;
|
|
23
|
+
keys: string[];
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { On } from '../js-bridge';
|
|
2
|
+
export declare const applyNative: jsb.service.ApplyNative, invokeNative: jsb.service.InvokeNative, onNative: jsb.service.OnNative, offNative: jsb.service.OnNative, subscribeHandler: import("../js-bridge").SubscribeHandler;
|
|
3
|
+
export declare const onNativeWithError: On;
|
|
4
|
+
export { RuntimeLoader } from '../js-core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function config(): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CUSTOM_EVENT_PREFIX = "custom_event_";
|
|
2
|
+
export declare const HOST_EVENT_PREFIX = "host_event_";
|
|
3
|
+
export declare const BUFFER_METHODS: string[];
|
|
4
|
+
export declare const BACKGROUND_FORBIDDEN_METHODS: string[];
|
|
5
|
+
export declare const SYNC_METHODS: string[];
|