@kalamba/sdk 0.8.0 → 0.9.0
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/dist/index.cjs +1 -1
- package/dist/index.d.ts +53 -3
- package/dist/index.js +49 -45
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.ts +88 -15
- package/dist/plugins.js +762 -676
- package/dist/wrapper.cjs +1 -1
- package/dist/wrapper.d.ts +55 -3
- package/dist/wrapper.js +432 -353
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
"use strict";var b=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(b(r,i,"read from private field"),t?t.call(r):i.get(r)),
|
|
5
|
+
"use strict";var b=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(b(r,i,"read from private field"),t?t.call(r):i.get(r)),e=(r,i,t)=>{if(i.has(r))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(r):i.set(r,t)},u=(r,i,t,n)=>(b(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./errors-358575c3.cjs");function I(r){const i=Object.prototype.toString.call(r);return r instanceof Date||typeof r=="object"&&i==="[object Date]"?new r.constructor(+r):typeof r=="number"||i==="[object Number]"||typeof r=="string"||i==="[object String]"?new Date(r):new Date(NaN)}function U(r){const i=I(r);return i.setHours(23,59,59,999),i}function k(){return U(Date.now())}function L(r){const i=I(r);return i.setHours(0,0,0,0),i}function P(){return L(Date.now())}const $=3e4;var F,S;class G{constructor(i){e(this,F,void 0);e(this,S,$);u(this,F,i)}buildHeaders(){const i={};return m(this,F).token&&(i.Authorization=`Bearer ${m(this,F).token}`),i}async request(i,t){const n=new URL(i,m(this,F).apiUrl??window.location.origin);return n.search=new URLSearchParams({...t}).toString(),await(await fetch(n,{signal:AbortSignal.timeout(m(this,S)),headers:this.buildHeaders()})).json()}async getRounds(i){return this.request("/rounds",i)}async getRound(i,t){return this.request(`/rounds/${i}`,t)}}F=new WeakMap,S=new WeakMap;const N={limit:100,page:0};var s,l;class A{constructor({config:i}){e(this,s,void 0);e(this,l,void 0);u(this,s,i),u(this,l,new G({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=N}={}){return m(this,l).getRound(i,{gameCode:m(this,s).api.game,operatorCode:m(this,s).api.brand,username:m(this,s).api.user,...t})}async getLastRound(){return m(this,s).api.lastRoundId?this.getRound(m(this,s).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:P(),toDateTime:k()},pagination:t=N}={}){const n=m(this,s).api.user.replace(/^user_/,"").replace(new RegExp(`_${m(this,s).api.integration}$`),"");return m(this,l).getRounds({gameCode:m(this,s).api.game,operatorCode:m(this,s).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}s=new WeakMap,l=new WeakMap;function _(r,i){return r*i/100}function O(r,i,t){if(!["string","number"].includes(typeof i))return"NaN";const{locales:n}=r;try{return new Intl.NumberFormat(n,{...t,numberingSystem:"latn",style:"decimal"}).format(+i)}catch{return`${i}`}}const w="XTS";var y=(r=>(r.Currency="Currency",r.Number="Number",r))(y||{}),f=(r=>(r.Coins="Coins",r.Money="Money",r))(f||{});const T={ARSB:{displayAs:"ARS",maximumFractionDigits:2,minimumFractionDigits:2},CHIPS:{maximumFractionDigits:0,minimumFractionDigits:0},BNB:{maximumFractionDigits:6,minimumFractionDigits:6},BUSD:{maximumFractionDigits:4,minimumFractionDigits:4},BTC:{maximumFractionDigits:8,minimumFractionDigits:2},mBTC:{maximumFractionDigits:5,minimumFractionDigits:2},uBTC:{maximumFractionDigits:2,minimumFractionDigits:2},BCH:{maximumFractionDigits:8,minimumFractionDigits:2},mBCH:{maximumFractionDigits:2,minimumFractionDigits:2},ETH:{maximumFractionDigits:8,minimumFractionDigits:2},mETH:{maximumFractionDigits:5,minimumFractionDigits:2},uETH:{maximumFractionDigits:2,minimumFractionDigits:2},SOC:{maximumFractionDigits:8,minimumFractionDigits:2},LTC:{maximumFractionDigits:8,minimumFractionDigits:2},mLTC:{maximumFractionDigits:5,minimumFractionDigits:2},uLTC:{maximumFractionDigits:2,minimumFractionDigits:2},DOG:{maximumFractionDigits:4,minimumFractionDigits:2},USDC:{maximumFractionDigits:4,minimumFractionDigits:4},USDT:{maximumFractionDigits:4,minimumFractionDigits:2},TRX:{maximumFractionDigits:2,minimumFractionDigits:2},TUSD:{maximumFractionDigits:2,minimumFractionDigits:2},DAI:{maximumFractionDigits:2,minimumFractionDigits:2},XMR:{maximumFractionDigits:4,minimumFractionDigits:4},CBET:{maximumFractionDigits:0,minimumFractionDigits:0},kCBET:{maximumFractionDigits:2,minimumFractionDigits:2},SHIB:{maximumFractionDigits:0,minimumFractionDigits:0},kSHIB:{maximumFractionDigits:4,minimumFractionDigits:2},NEO:{maximumFractionDigits:4,minimumFractionDigits:4},BSV:{maximumFractionDigits:4,minimumFractionDigits:4},EOS:{maximumFractionDigits:4,minimumFractionDigits:4},DASH:{maximumFractionDigits:4,minimumFractionDigits:4},XLM:{maximumFractionDigits:2,minimumFractionDigits:2},KRW:{maximumFractionDigits:2,minimumFractionDigits:2},kVND:{maximumFractionDigits:4,minimumFractionDigits:2},kIDR:{maximumFractionDigits:4,minimumFractionDigits:2},RSD:{maximumFractionDigits:2,minimumFractionDigits:2},STAKEGC:{displayAs:"GC",maximumFractionDigits:0,minimumFractionDigits:0},STAKESC:{displayAs:"SC",maximumFractionDigits:2,minimumFractionDigits:2},"BK.":{maximumFractionDigits:2,minimumFractionDigits:2},"BT.":{maximumFractionDigits:2,minimumFractionDigits:2},"FC.":{maximumFractionDigits:2,minimumFractionDigits:2},"GC.":{maximumFractionDigits:2,minimumFractionDigits:2},"SC.":{maximumFractionDigits:2,minimumFractionDigits:2},GLD:{displayAs:"GC.",maximumFractionDigits:2,minimumFractionDigits:2},SS1:{displayAs:"SC.",maximumFractionDigits:2,minimumFractionDigits:2},SVC:{maximumFractionDigits:2,minimumFractionDigits:2},DOT:{maximumFractionDigits:4,minimumFractionDigits:4},SOL:{maximumFractionDigits:4,minimumFractionDigits:4},XRP:{maximumFractionDigits:4,minimumFractionDigits:4},ADA:{maximumFractionDigits:4,minimumFractionDigits:4},TON:{maximumFractionDigits:4,minimumFractionDigits:4},FTN:{maximumFractionDigits:4,minimumFractionDigits:4}};function M(r){return r in T}function j(r){return M(r)?{...T[r],currency:w}:{currency:r}}function q(r,i,t){const n=i.format(+r);return M(t)?n.replace(w,T[t].displayAs??t):n}function K(r,i,t){const{maximumFractionDigits:n,minimumFractionDigits:o}=t.resolvedOptions();return O(r,i,{maximumFractionDigits:n,minimumFractionDigits:o})}function V(r,i,{as:t}={as:"Currency"}){const{canShowCurrency:n,currency:o}=r;return t==="Number"||!n?`${i}`:`${i} ${o}`}function v(r,i,{as:t,from:n}={as:"Currency",from:"Money"},o){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:a=!0,coinValueInCents:g,currency:x,locales:R}=r;n==="Coins"&&(i=_(+i,g));try{const H=j(x),E=new Intl.NumberFormat(R,{...H,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!a?K(r,i,E):q(i,E,x)}catch{return V(r,i,{as:t})}}var c;class B{constructor({config:i}){e(this,c,void 0);u(this,c,i)}formatNumber(i,t){const n={locales:[m(this,c).ui.language]};return O(n,i,t)}formatCurrency(i,t={as:y.Currency,from:f.Money},n){const o=m(this,c).ui.feature.showCurrency,a=m(this,c).api.coinValueInCents,g=m(this,c).api.currency||w,x=[m(this,c).ui.language];return v({canShowCurrency:o,coinValueInCents:a,currency:g,locales:x},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Money},t)}}c=new WeakMap;const X=()=>{};var d,h,p,C;class z{constructor({messagePort:i}){e(this,d,void 0);e(this,h,void 0);e(this,p,void 0);e(this,C,void 0);u(this,C,i),this.on("configured",t=>{u(this,d,t),u(this,p,new B({config:t})),u(this,h,new A({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!m(this,d))throw new Error("config is not initialized, you must open game first");return m(this,d)}get history(){if(!m(this,h))throw new Error("config is not initialized, you must open game first");return m(this,h)}get i18n(){if(!m(this,p))throw new Error("i18n is not initialized, you must open game first");return m(this,p)}request(i,...[t]){return new Promise(n=>{this.on(`${i}Response`,o=>n({type:"response",response:o}),{once:!0}),this.on(`${i}Error`,o=>n({type:"error",error:o}),{once:!0}),this.send(i,t)})}on(i,t,n){const o=function a(g){g.data.message===`kalamba:wrapper:${i}`&&(X("on",g.data.message.replace(/^kalamba:/,""),g.data.payload),t(g.data.payload),n!=null&&n.once&&window.removeEventListener("message",a))};window.addEventListener("message",o)}send(i,...[t]){m(this,C).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}configure(i){this.send("configure",i)}async openGame(){const i=new Promise(n=>this.on("configured",n,{once:!0})),t=await this.request("openGame");if(t.type==="response")return await i,t.response;throw t.error.type==="timeout"?new D.TimeoutError:new D.RgsError(t.error.data)}async play(i,t,n="SPIN"){const o={contract:i,extra:t,actionType:n},a=await this.request("play",o);if(a.type==="response")return a.response;throw a.error.type==="timeout"?new D.TimeoutError:new D.RgsError(a.error.data)}}d=new WeakMap,h=new WeakMap,p=new WeakMap,C=new WeakMap;exports.RgsError=D.RgsError;exports.RgsErrorCode=D.RgsErrorCode;exports.TimeoutError=D.TimeoutError;exports.History=A;exports.I18n=B;exports.KalambaSdk=z;
|
package/dist/index.d.ts
CHANGED
|
@@ -99,6 +99,34 @@ export declare type ForwardToSdkMessage = keyof ToSdkForwardedMessageMap;
|
|
|
99
99
|
|
|
100
100
|
export declare type ForwardToSdkMessagePayload<M extends ForwardToSdkMessage> = ToSdkForwardedMessageMap[M];
|
|
101
101
|
|
|
102
|
+
export declare type FreeRound = {
|
|
103
|
+
conf: {
|
|
104
|
+
base: number;
|
|
105
|
+
multiplier: number;
|
|
106
|
+
numAwarded: number;
|
|
107
|
+
};
|
|
108
|
+
data: {
|
|
109
|
+
numPlayed: number;
|
|
110
|
+
win: number;
|
|
111
|
+
numLeft: number;
|
|
112
|
+
};
|
|
113
|
+
id: string;
|
|
114
|
+
rejectable: boolean;
|
|
115
|
+
skippable: boolean;
|
|
116
|
+
status: 'PENDING' | 'ACTIVE' | 'FINISHED';
|
|
117
|
+
type: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export declare type FreeRoundsAction = {
|
|
121
|
+
action: 'ACCEPT' | 'REJECT' | 'SKIP';
|
|
122
|
+
id: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export declare type FreeRoundsResponse = {
|
|
126
|
+
action: 'ACCEPT' | 'REJECT' | 'SKIP';
|
|
127
|
+
id: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
102
130
|
export declare interface GetRoundOptions {
|
|
103
131
|
pagination?: Pagination;
|
|
104
132
|
}
|
|
@@ -176,6 +204,7 @@ export declare type OpenGameResponse = {
|
|
|
176
204
|
coins: number;
|
|
177
205
|
version: number;
|
|
178
206
|
};
|
|
207
|
+
freeRounds: FreeRound[];
|
|
179
208
|
gameModel: string;
|
|
180
209
|
metaData: {
|
|
181
210
|
rtpValues: {
|
|
@@ -226,6 +255,7 @@ export declare type PlayResponse = {
|
|
|
226
255
|
coins: number;
|
|
227
256
|
version: number;
|
|
228
257
|
};
|
|
258
|
+
freeRounds: FreeRound[];
|
|
229
259
|
roundId: string;
|
|
230
260
|
serverTime: number;
|
|
231
261
|
stateType: {
|
|
@@ -330,6 +360,8 @@ export declare type RgsOnlyMessagePayloadMap = {
|
|
|
330
360
|
openGameResponse: OpenGameResponse;
|
|
331
361
|
playError: RgsErrorWithType;
|
|
332
362
|
playResponse: PlayResponse;
|
|
363
|
+
freeRoundsResponse: FreeRoundsResponse;
|
|
364
|
+
freeRoundsError: RgsErrorWithType;
|
|
333
365
|
realityCheck: {
|
|
334
366
|
duration: number;
|
|
335
367
|
sumBetAmount: number;
|
|
@@ -402,6 +434,12 @@ export declare interface SdkConfig {
|
|
|
402
434
|
maximumBet?: number;
|
|
403
435
|
minimumSpinDuration: number;
|
|
404
436
|
requestTimeoutMs: number;
|
|
437
|
+
incompleteGameResolution: {
|
|
438
|
+
type: 'NONE' | 'MANUAL';
|
|
439
|
+
} | {
|
|
440
|
+
daysToAutoResolution: number;
|
|
441
|
+
type: 'AUTOMATIC';
|
|
442
|
+
};
|
|
405
443
|
realityCheck: RealityCheckConfig;
|
|
406
444
|
skipInsufficientFundsCheck: boolean;
|
|
407
445
|
skipSplash: boolean;
|
|
@@ -450,9 +488,7 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
450
488
|
playCycleEnd: PlayResponse;
|
|
451
489
|
playCycleStart: ContractPlayPayload;
|
|
452
490
|
playEnd: PlayResponse;
|
|
453
|
-
playReady:
|
|
454
|
-
ready: boolean;
|
|
455
|
-
};
|
|
491
|
+
playReady: never;
|
|
456
492
|
playStart: ContractPlayPayload;
|
|
457
493
|
/**
|
|
458
494
|
* ```typescript
|
|
@@ -473,6 +509,8 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
473
509
|
name: string;
|
|
474
510
|
};
|
|
475
511
|
'telemetry.orientationChange': never;
|
|
512
|
+
freeRounds: FreeRoundsAction;
|
|
513
|
+
freeRoundsPopup: never;
|
|
476
514
|
};
|
|
477
515
|
|
|
478
516
|
export declare interface SearchPeriod {
|
|
@@ -542,11 +580,23 @@ export declare type WrapperOnlyMessagePayloadMap = {
|
|
|
542
580
|
state: WrapperState;
|
|
543
581
|
suspend: never;
|
|
544
582
|
unfreeze: never;
|
|
583
|
+
legalBets: Record<number, number[]>;
|
|
584
|
+
play: PlayRequest & {
|
|
585
|
+
payloadToInject?: Record<string, unknown>;
|
|
586
|
+
};
|
|
587
|
+
freeRounds: FreeRoundsAction;
|
|
588
|
+
freeRoundsOffer: FreeRound;
|
|
589
|
+
freeRoundsInfo: FreeRound;
|
|
590
|
+
freeRoundsComplete: FreeRound;
|
|
591
|
+
freeRoundsPopup: never;
|
|
545
592
|
};
|
|
546
593
|
|
|
547
594
|
export declare type WrapperState = {
|
|
548
595
|
balance: number;
|
|
549
596
|
bet: Bet;
|
|
597
|
+
openGameResponse?: OpenGameResponse;
|
|
598
|
+
lastPlayResponse?: PlayResponse;
|
|
599
|
+
freeRoundId?: string;
|
|
550
600
|
};
|
|
551
601
|
|
|
552
602
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -13,23 +13,23 @@ var m = (n, i, t) => (N(n, i, "read from private field"), t ? t.call(n) : i.get(
|
|
|
13
13
|
}, u = (n, i, t, r) => (N(n, i, "write to private field"), r ? r.call(n, t) : i.set(n, t), t);
|
|
14
14
|
import { T as b, R as E } from "./errors-afd9f527.js";
|
|
15
15
|
import { a as ii } from "./errors-afd9f527.js";
|
|
16
|
-
function
|
|
16
|
+
function I(n) {
|
|
17
17
|
const i = Object.prototype.toString.call(n);
|
|
18
18
|
return n instanceof Date || typeof n == "object" && i === "[object Date]" ? new n.constructor(+n) : typeof n == "number" || i === "[object Number]" || typeof n == "string" || i === "[object String]" ? new Date(n) : /* @__PURE__ */ new Date(NaN);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const i =
|
|
20
|
+
function H(n) {
|
|
21
|
+
const i = I(n);
|
|
22
22
|
return i.setHours(23, 59, 59, 999), i;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function U() {
|
|
25
|
+
return H(Date.now());
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const i =
|
|
27
|
+
function L(n) {
|
|
28
|
+
const i = I(n);
|
|
29
29
|
return i.setHours(0, 0, 0, 0), i;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function k() {
|
|
32
|
+
return L(Date.now());
|
|
33
33
|
}
|
|
34
34
|
const P = 3e4;
|
|
35
35
|
var D, x;
|
|
@@ -60,12 +60,12 @@ class $ {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
D = new WeakMap(), x = new WeakMap();
|
|
63
|
-
const
|
|
63
|
+
const A = {
|
|
64
64
|
limit: 100,
|
|
65
65
|
page: 0
|
|
66
66
|
};
|
|
67
67
|
var s, y;
|
|
68
|
-
class
|
|
68
|
+
class G {
|
|
69
69
|
constructor({
|
|
70
70
|
config: i
|
|
71
71
|
}) {
|
|
@@ -76,7 +76,7 @@ class _ {
|
|
|
76
76
|
}));
|
|
77
77
|
}
|
|
78
78
|
async getRound(i, {
|
|
79
|
-
pagination: t =
|
|
79
|
+
pagination: t = A
|
|
80
80
|
} = {}) {
|
|
81
81
|
return m(this, y).getRound(i, {
|
|
82
82
|
gameCode: m(this, s).api.game,
|
|
@@ -90,10 +90,10 @@ class _ {
|
|
|
90
90
|
}
|
|
91
91
|
async getRounds({
|
|
92
92
|
searchPeriod: i = {
|
|
93
|
-
fromDateTime:
|
|
94
|
-
toDateTime:
|
|
93
|
+
fromDateTime: k(),
|
|
94
|
+
toDateTime: U()
|
|
95
95
|
},
|
|
96
|
-
pagination: t =
|
|
96
|
+
pagination: t = A
|
|
97
97
|
} = {}) {
|
|
98
98
|
const r = m(this, s).api.user.replace(/^user_/, "").replace(new RegExp(`_${m(this, s).api.integration}$`), "");
|
|
99
99
|
return m(this, y).getRounds({
|
|
@@ -107,7 +107,7 @@ class _ {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
s = new WeakMap(), y = new WeakMap();
|
|
110
|
-
function
|
|
110
|
+
function _(n, i) {
|
|
111
111
|
return n * i / 100;
|
|
112
112
|
}
|
|
113
113
|
function O(n, i, t) {
|
|
@@ -126,9 +126,9 @@ function O(n, i, t) {
|
|
|
126
126
|
return `${i}`;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
129
|
+
const S = "XTS";
|
|
130
130
|
var F = /* @__PURE__ */ ((n) => (n.Currency = "Currency", n.Number = "Number", n))(F || {}), f = /* @__PURE__ */ ((n) => (n.Coins = "Coins", n.Money = "Money", n))(f || {});
|
|
131
|
-
const
|
|
131
|
+
const w = {
|
|
132
132
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
133
133
|
// ARSB is the internal currency relevant for invoicing purposes, players should see it as ARS
|
|
134
134
|
ARSB: { displayAs: "ARS", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
@@ -203,9 +203,13 @@ const S = {
|
|
|
203
203
|
STAKEGC: { displayAs: "GC", maximumFractionDigits: 0, minimumFractionDigits: 0 },
|
|
204
204
|
STAKESC: { displayAs: "SC", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
205
205
|
// Social currency on Relax
|
|
206
|
+
"BK.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
207
|
+
"BT.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
206
208
|
"FC.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
207
209
|
"GC.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
208
210
|
"SC.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
211
|
+
GLD: { displayAs: "GC.", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
212
|
+
SS1: { displayAs: "SC.", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
209
213
|
// Silvercash
|
|
210
214
|
SVC: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
211
215
|
// Polkadot
|
|
@@ -222,33 +226,33 @@ const S = {
|
|
|
222
226
|
FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 }
|
|
223
227
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
224
228
|
};
|
|
225
|
-
function
|
|
226
|
-
return n in
|
|
229
|
+
function B(n) {
|
|
230
|
+
return n in w;
|
|
227
231
|
}
|
|
228
232
|
function j(n) {
|
|
229
|
-
return
|
|
230
|
-
...
|
|
231
|
-
currency:
|
|
233
|
+
return B(n) ? {
|
|
234
|
+
...w[n],
|
|
235
|
+
currency: S
|
|
232
236
|
} : {
|
|
233
237
|
currency: n
|
|
234
238
|
};
|
|
235
239
|
}
|
|
236
240
|
function q(n, i, t) {
|
|
237
241
|
const r = i.format(+n);
|
|
238
|
-
return
|
|
242
|
+
return B(t) ? r.replace(S, w[t].displayAs ?? t) : r;
|
|
239
243
|
}
|
|
240
244
|
function V(n, i, t) {
|
|
241
245
|
const { maximumFractionDigits: r, minimumFractionDigits: o } = t.resolvedOptions();
|
|
242
246
|
return O(n, i, { maximumFractionDigits: r, minimumFractionDigits: o });
|
|
243
247
|
}
|
|
244
|
-
function
|
|
248
|
+
function K(n, i, { as: t } = {
|
|
245
249
|
as: "Currency"
|
|
246
250
|
/* Currency */
|
|
247
251
|
}) {
|
|
248
252
|
const { canShowCurrency: r, currency: o } = n;
|
|
249
253
|
return t === "Number" || !r ? `${i}` : `${i} ${o}`;
|
|
250
254
|
}
|
|
251
|
-
function
|
|
255
|
+
function X(n, i, { as: t, from: r } = {
|
|
252
256
|
as: "Currency",
|
|
253
257
|
from: "Money"
|
|
254
258
|
/* Money */
|
|
@@ -256,10 +260,10 @@ function v(n, i, { as: t, from: r } = {
|
|
|
256
260
|
if (!["string", "number"].includes(typeof i))
|
|
257
261
|
return "NaN";
|
|
258
262
|
const { canShowCurrency: a = !0, coinValueInCents: g, currency: C, locales: T } = n;
|
|
259
|
-
r === "Coins" && (i =
|
|
263
|
+
r === "Coins" && (i = _(+i, g));
|
|
260
264
|
try {
|
|
261
|
-
const
|
|
262
|
-
...
|
|
265
|
+
const M = j(C), R = new Intl.NumberFormat(T, {
|
|
266
|
+
...M,
|
|
263
267
|
...o,
|
|
264
268
|
currencyDisplay: "symbol",
|
|
265
269
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -269,11 +273,11 @@ function v(n, i, { as: t, from: r } = {
|
|
|
269
273
|
});
|
|
270
274
|
return t === "Number" || !a ? V(n, i, R) : q(i, R, C);
|
|
271
275
|
} catch {
|
|
272
|
-
return
|
|
276
|
+
return K(n, i, { as: t });
|
|
273
277
|
}
|
|
274
278
|
}
|
|
275
279
|
var c;
|
|
276
|
-
class
|
|
280
|
+
class v {
|
|
277
281
|
constructor({ config: i }) {
|
|
278
282
|
e(this, c, void 0);
|
|
279
283
|
u(this, c, i);
|
|
@@ -283,8 +287,8 @@ class z {
|
|
|
283
287
|
return O(r, i, t);
|
|
284
288
|
}
|
|
285
289
|
formatCurrency(i, t = { as: F.Currency, from: f.Money }, r) {
|
|
286
|
-
const o = m(this, c).ui.feature.showCurrency, a = m(this, c).api.coinValueInCents, g = m(this, c).api.currency ||
|
|
287
|
-
return
|
|
290
|
+
const o = m(this, c).ui.feature.showCurrency, a = m(this, c).api.coinValueInCents, g = m(this, c).api.currency || S, C = [m(this, c).ui.language];
|
|
291
|
+
return X({
|
|
288
292
|
canShowCurrency: o,
|
|
289
293
|
coinValueInCents: a,
|
|
290
294
|
currency: g,
|
|
@@ -305,30 +309,30 @@ class z {
|
|
|
305
309
|
}
|
|
306
310
|
}
|
|
307
311
|
c = new WeakMap();
|
|
308
|
-
const
|
|
312
|
+
const z = () => {
|
|
309
313
|
};
|
|
310
|
-
var
|
|
314
|
+
var l, h, p, d;
|
|
311
315
|
class Y {
|
|
312
316
|
constructor({ messagePort: i }) {
|
|
313
|
-
e(this, h, void 0);
|
|
314
317
|
e(this, l, void 0);
|
|
318
|
+
e(this, h, void 0);
|
|
315
319
|
e(this, p, void 0);
|
|
316
320
|
e(this, d, void 0);
|
|
317
321
|
u(this, d, i), this.on("configured", (t) => {
|
|
318
|
-
u(this,
|
|
322
|
+
u(this, l, t), u(this, p, new v({ config: t })), u(this, h, new G({ config: t }));
|
|
319
323
|
}), this.on("playResponse", (t) => {
|
|
320
324
|
this.config.api.lastRoundId = t.contract.roundId;
|
|
321
325
|
});
|
|
322
326
|
}
|
|
323
327
|
get config() {
|
|
324
|
-
if (!m(this,
|
|
328
|
+
if (!m(this, l))
|
|
325
329
|
throw new Error("config is not initialized, you must open game first");
|
|
326
|
-
return m(this,
|
|
330
|
+
return m(this, l);
|
|
327
331
|
}
|
|
328
332
|
get history() {
|
|
329
|
-
if (!m(this,
|
|
333
|
+
if (!m(this, h))
|
|
330
334
|
throw new Error("config is not initialized, you must open game first");
|
|
331
|
-
return m(this,
|
|
335
|
+
return m(this, h);
|
|
332
336
|
}
|
|
333
337
|
get i18n() {
|
|
334
338
|
if (!m(this, p))
|
|
@@ -344,7 +348,7 @@ class Y {
|
|
|
344
348
|
}
|
|
345
349
|
on(i, t, r) {
|
|
346
350
|
const o = function a(g) {
|
|
347
|
-
g.data.message === `kalamba:wrapper:${i}` && (
|
|
351
|
+
g.data.message === `kalamba:wrapper:${i}` && (z("on", g.data.message.replace(/^kalamba:/, ""), g.data.payload), t(g.data.payload), r != null && r.once && window.removeEventListener("message", a));
|
|
348
352
|
};
|
|
349
353
|
window.addEventListener("message", o);
|
|
350
354
|
}
|
|
@@ -374,10 +378,10 @@ class Y {
|
|
|
374
378
|
throw a.error.type === "timeout" ? new b() : new E(a.error.data);
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
|
-
|
|
381
|
+
l = new WeakMap(), h = new WeakMap(), p = new WeakMap(), d = new WeakMap();
|
|
378
382
|
export {
|
|
379
|
-
|
|
380
|
-
|
|
383
|
+
G as History,
|
|
384
|
+
v as I18n,
|
|
381
385
|
Y as KalambaSdk,
|
|
382
386
|
E as RgsError,
|
|
383
387
|
ii as RgsErrorCode,
|