@everymatrix/pam-account-balance-modal 0.1.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.
Files changed (56) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-f01eba32.js +1227 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/pam-account-balance-modal-81ade12d.js +1704 -0
  6. package/dist/cjs/pam-account-balance-modal.cjs.js +25 -0
  7. package/dist/cjs/pam-account-balance-modal_2.cjs.entry.js +175 -0
  8. package/dist/collection/collection-manifest.json +19 -0
  9. package/dist/collection/components/pam-account-balance-modal/index.js +1 -0
  10. package/dist/collection/components/pam-account-balance-modal/pam-account-balance-modal.css +217 -0
  11. package/dist/collection/components/pam-account-balance-modal/pam-account-balance-modal.interface.js +1 -0
  12. package/dist/collection/components/pam-account-balance-modal/pam-account-balance-modal.js +635 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/utils/locale.utils.js +227 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-ee727666.js +1200 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/pam-account-balance-modal-8ebcc863.js +1702 -0
  20. package/dist/esm/pam-account-balance-modal.js +20 -0
  21. package/dist/esm/pam-account-balance-modal_2.entry.js +170 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/pam-account-balance-modal/index.esm.js +1 -0
  25. package/dist/pam-account-balance-modal/p-86b371f2.js +2 -0
  26. package/dist/pam-account-balance-modal/p-b60c42bd.js +7 -0
  27. package/dist/pam-account-balance-modal/p-d74c687e.entry.js +1 -0
  28. package/dist/pam-account-balance-modal/p-e1255160.js +1 -0
  29. package/dist/pam-account-balance-modal/pam-account-balance-modal.esm.js +1 -0
  30. package/dist/stencil.config.dev.js +19 -0
  31. package/dist/stencil.config.js +18 -0
  32. package/dist/storybook/main.js +43 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/stencil.config.d.ts +2 -0
  36. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/storybook/main.d.ts +3 -0
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/packages/stencil/pam-account-balance-modal/storybook/preview.d.ts +70 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/index.d.ts +3 -0
  40. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  41. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  42. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-account-balance-modal/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  43. package/dist/types/components/pam-account-balance-modal/index.d.ts +1 -0
  44. package/dist/types/components/pam-account-balance-modal/pam-account-balance-modal.d.ts +52 -0
  45. package/dist/types/components/pam-account-balance-modal/pam-account-balance-modal.interface.d.ts +10 -0
  46. package/dist/types/components.d.ts +65 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  49. package/dist/types/utils/locale.utils.d.ts +31 -0
  50. package/loader/cdn.js +1 -0
  51. package/loader/index.cjs.js +1 -0
  52. package/loader/index.d.ts +24 -0
  53. package/loader/index.es2017.js +1 -0
  54. package/loader/index.js +2 -0
  55. package/loader/package.json +11 -0
  56. package/package.json +27 -0
@@ -0,0 +1,1702 @@
1
+ import { r as registerInstance, h } from './index-ee727666.js';
2
+
3
+ /**
4
+ * @name setClientStyling
5
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
6
+ * @param {HTMLElement} stylingContainer The reference element of the widget
7
+ * @param {string} clientStyling The style content
8
+ */
9
+ function setClientStyling(stylingContainer, clientStyling) {
10
+ if (stylingContainer) {
11
+ const sheet = document.createElement('style');
12
+ sheet.innerHTML = clientStyling;
13
+ stylingContainer.appendChild(sheet);
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @name setClientStylingURL
19
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
20
+ * @param {HTMLElement} stylingContainer The reference element of the widget
21
+ * @param {string} clientStylingUrl The URL of the style content
22
+ */
23
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
24
+ const url = new URL(clientStylingUrl);
25
+
26
+ fetch(url.href)
27
+ .then((res) => res.text())
28
+ .then((data) => {
29
+ const cssFile = document.createElement('style');
30
+ cssFile.innerHTML = data;
31
+ if (stylingContainer) {
32
+ stylingContainer.appendChild(cssFile);
33
+ }
34
+ })
35
+ .catch((err) => {
36
+ console.error('There was an error while trying to load client styling from URL', err);
37
+ });
38
+ }
39
+
40
+ /**
41
+ * @name setStreamLibrary
42
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
43
+ * @param {HTMLElement} stylingContainer The highest element of the widget
44
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
45
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
46
+ */
47
+ function setStreamStyling(stylingContainer, domain, subscription) {
48
+ if (window.emMessageBus) {
49
+ const sheet = document.createElement('style');
50
+
51
+ window.emMessageBus.subscribe(domain, (data) => {
52
+ sheet.innerHTML = data;
53
+ if (stylingContainer) {
54
+ stylingContainer.appendChild(sheet);
55
+ }
56
+ });
57
+ }
58
+ }
59
+
60
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
61
+
62
+ var eventsource = {exports: {}};
63
+
64
+ /** @license
65
+ * eventsource.js
66
+ * Available under MIT License (MIT)
67
+ * https://github.com/Yaffle/EventSource/
68
+ */
69
+
70
+ (function (module, exports) {
71
+ /*jslint indent: 2, vars: true, plusplus: true */
72
+ /*global setTimeout, clearTimeout */
73
+
74
+ (function (global) {
75
+
76
+ var setTimeout = global.setTimeout;
77
+ var clearTimeout = global.clearTimeout;
78
+ var XMLHttpRequest = global.XMLHttpRequest;
79
+ var XDomainRequest = global.XDomainRequest;
80
+ var ActiveXObject = global.ActiveXObject;
81
+ var NativeEventSource = global.EventSource;
82
+
83
+ var document = global.document;
84
+ var Promise = global.Promise;
85
+ var fetch = global.fetch;
86
+ var Response = global.Response;
87
+ var TextDecoder = global.TextDecoder;
88
+ var TextEncoder = global.TextEncoder;
89
+ var AbortController = global.AbortController;
90
+
91
+ if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
92
+ document.readyState = "loading";
93
+ window.addEventListener("load", function (event) {
94
+ document.readyState = "complete";
95
+ }, false);
96
+ }
97
+
98
+ if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
99
+ XMLHttpRequest = function () {
100
+ return new ActiveXObject("Microsoft.XMLHTTP");
101
+ };
102
+ }
103
+
104
+ if (Object.create == undefined) {
105
+ Object.create = function (C) {
106
+ function F(){}
107
+ F.prototype = C;
108
+ return new F();
109
+ };
110
+ }
111
+
112
+ if (!Date.now) {
113
+ Date.now = function now() {
114
+ return new Date().getTime();
115
+ };
116
+ }
117
+
118
+ // see #118 (Promise#finally with polyfilled Promise)
119
+ // see #123 (data URLs crash Edge)
120
+ // see #125 (CSP violations)
121
+ // see pull/#138
122
+ // => No way to polyfill Promise#finally
123
+
124
+ if (AbortController == undefined) {
125
+ var originalFetch2 = fetch;
126
+ fetch = function (url, options) {
127
+ var signal = options.signal;
128
+ return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
129
+ var reader = response.body.getReader();
130
+ signal._reader = reader;
131
+ if (signal._aborted) {
132
+ signal._reader.cancel();
133
+ }
134
+ return {
135
+ status: response.status,
136
+ statusText: response.statusText,
137
+ headers: response.headers,
138
+ body: {
139
+ getReader: function () {
140
+ return reader;
141
+ }
142
+ }
143
+ };
144
+ });
145
+ };
146
+ AbortController = function () {
147
+ this.signal = {
148
+ _reader: null,
149
+ _aborted: false
150
+ };
151
+ this.abort = function () {
152
+ if (this.signal._reader != null) {
153
+ this.signal._reader.cancel();
154
+ }
155
+ this.signal._aborted = true;
156
+ };
157
+ };
158
+ }
159
+
160
+ function TextDecoderPolyfill() {
161
+ this.bitsNeeded = 0;
162
+ this.codePoint = 0;
163
+ }
164
+
165
+ TextDecoderPolyfill.prototype.decode = function (octets) {
166
+ function valid(codePoint, shift, octetsCount) {
167
+ if (octetsCount === 1) {
168
+ return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
169
+ }
170
+ if (octetsCount === 2) {
171
+ return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
172
+ }
173
+ if (octetsCount === 3) {
174
+ return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
175
+ }
176
+ throw new Error();
177
+ }
178
+ function octetsCount(bitsNeeded, codePoint) {
179
+ if (bitsNeeded === 6 * 1) {
180
+ return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
181
+ }
182
+ if (bitsNeeded === 6 * 2) {
183
+ return codePoint > 15 ? 3 : 2;
184
+ }
185
+ if (bitsNeeded === 6 * 3) {
186
+ return 3;
187
+ }
188
+ throw new Error();
189
+ }
190
+ var REPLACER = 0xFFFD;
191
+ var string = "";
192
+ var bitsNeeded = this.bitsNeeded;
193
+ var codePoint = this.codePoint;
194
+ for (var i = 0; i < octets.length; i += 1) {
195
+ var octet = octets[i];
196
+ if (bitsNeeded !== 0) {
197
+ if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
198
+ bitsNeeded = 0;
199
+ codePoint = REPLACER;
200
+ string += String.fromCharCode(codePoint);
201
+ }
202
+ }
203
+ if (bitsNeeded === 0) {
204
+ if (octet >= 0 && octet <= 127) {
205
+ bitsNeeded = 0;
206
+ codePoint = octet;
207
+ } else if (octet >= 192 && octet <= 223) {
208
+ bitsNeeded = 6 * 1;
209
+ codePoint = octet & 31;
210
+ } else if (octet >= 224 && octet <= 239) {
211
+ bitsNeeded = 6 * 2;
212
+ codePoint = octet & 15;
213
+ } else if (octet >= 240 && octet <= 247) {
214
+ bitsNeeded = 6 * 3;
215
+ codePoint = octet & 7;
216
+ } else {
217
+ bitsNeeded = 0;
218
+ codePoint = REPLACER;
219
+ }
220
+ if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
221
+ bitsNeeded = 0;
222
+ codePoint = REPLACER;
223
+ }
224
+ } else {
225
+ bitsNeeded -= 6;
226
+ codePoint = codePoint << 6 | octet & 63;
227
+ }
228
+ if (bitsNeeded === 0) {
229
+ if (codePoint <= 0xFFFF) {
230
+ string += String.fromCharCode(codePoint);
231
+ } else {
232
+ string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
233
+ string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
234
+ }
235
+ }
236
+ }
237
+ this.bitsNeeded = bitsNeeded;
238
+ this.codePoint = codePoint;
239
+ return string;
240
+ };
241
+
242
+ // Firefox < 38 throws an error with stream option
243
+ var supportsStreamOption = function () {
244
+ try {
245
+ return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
246
+ } catch (error) {
247
+ console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
248
+ }
249
+ return false;
250
+ };
251
+
252
+ // IE, Edge
253
+ if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
254
+ TextDecoder = TextDecoderPolyfill;
255
+ }
256
+
257
+ var k = function () {
258
+ };
259
+
260
+ function XHRWrapper(xhr) {
261
+ this.withCredentials = false;
262
+ this.readyState = 0;
263
+ this.status = 0;
264
+ this.statusText = "";
265
+ this.responseText = "";
266
+ this.onprogress = k;
267
+ this.onload = k;
268
+ this.onerror = k;
269
+ this.onreadystatechange = k;
270
+ this._contentType = "";
271
+ this._xhr = xhr;
272
+ this._sendTimeout = 0;
273
+ this._abort = k;
274
+ }
275
+
276
+ XHRWrapper.prototype.open = function (method, url) {
277
+ this._abort(true);
278
+
279
+ var that = this;
280
+ var xhr = this._xhr;
281
+ var state = 1;
282
+ var timeout = 0;
283
+
284
+ this._abort = function (silent) {
285
+ if (that._sendTimeout !== 0) {
286
+ clearTimeout(that._sendTimeout);
287
+ that._sendTimeout = 0;
288
+ }
289
+ if (state === 1 || state === 2 || state === 3) {
290
+ state = 4;
291
+ xhr.onload = k;
292
+ xhr.onerror = k;
293
+ xhr.onabort = k;
294
+ xhr.onprogress = k;
295
+ xhr.onreadystatechange = k;
296
+ // IE 8 - 9: XDomainRequest#abort() does not fire any event
297
+ // Opera < 10: XMLHttpRequest#abort() does not fire any event
298
+ xhr.abort();
299
+ if (timeout !== 0) {
300
+ clearTimeout(timeout);
301
+ timeout = 0;
302
+ }
303
+ if (!silent) {
304
+ that.readyState = 4;
305
+ that.onabort(null);
306
+ that.onreadystatechange();
307
+ }
308
+ }
309
+ state = 0;
310
+ };
311
+
312
+ var onStart = function () {
313
+ if (state === 1) {
314
+ //state = 2;
315
+ var status = 0;
316
+ var statusText = "";
317
+ var contentType = undefined;
318
+ if (!("contentType" in xhr)) {
319
+ try {
320
+ status = xhr.status;
321
+ statusText = xhr.statusText;
322
+ contentType = xhr.getResponseHeader("Content-Type");
323
+ } catch (error) {
324
+ // IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
325
+ // Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
326
+ // https://bugs.webkit.org/show_bug.cgi?id=29121
327
+ status = 0;
328
+ statusText = "";
329
+ contentType = undefined;
330
+ // Firefox < 14, Chrome ?, Safari ?
331
+ // https://bugs.webkit.org/show_bug.cgi?id=29658
332
+ // https://bugs.webkit.org/show_bug.cgi?id=77854
333
+ }
334
+ } else {
335
+ status = 200;
336
+ statusText = "OK";
337
+ contentType = xhr.contentType;
338
+ }
339
+ if (status !== 0) {
340
+ state = 2;
341
+ that.readyState = 2;
342
+ that.status = status;
343
+ that.statusText = statusText;
344
+ that._contentType = contentType;
345
+ that.onreadystatechange();
346
+ }
347
+ }
348
+ };
349
+ var onProgress = function () {
350
+ onStart();
351
+ if (state === 2 || state === 3) {
352
+ state = 3;
353
+ var responseText = "";
354
+ try {
355
+ responseText = xhr.responseText;
356
+ } catch (error) {
357
+ // IE 8 - 9 with XMLHttpRequest
358
+ }
359
+ that.readyState = 3;
360
+ that.responseText = responseText;
361
+ that.onprogress();
362
+ }
363
+ };
364
+ var onFinish = function (type, event) {
365
+ if (event == null || event.preventDefault == null) {
366
+ event = {
367
+ preventDefault: k
368
+ };
369
+ }
370
+ // Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
371
+ // IE 8 fires "onload" without "onprogress"
372
+ onProgress();
373
+ if (state === 1 || state === 2 || state === 3) {
374
+ state = 4;
375
+ if (timeout !== 0) {
376
+ clearTimeout(timeout);
377
+ timeout = 0;
378
+ }
379
+ that.readyState = 4;
380
+ if (type === "load") {
381
+ that.onload(event);
382
+ } else if (type === "error") {
383
+ that.onerror(event);
384
+ } else if (type === "abort") {
385
+ that.onabort(event);
386
+ } else {
387
+ throw new TypeError();
388
+ }
389
+ that.onreadystatechange();
390
+ }
391
+ };
392
+ var onReadyStateChange = function (event) {
393
+ if (xhr != undefined) { // Opera 12
394
+ if (xhr.readyState === 4) {
395
+ if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
396
+ onFinish(xhr.responseText === "" ? "error" : "load", event);
397
+ }
398
+ } else if (xhr.readyState === 3) {
399
+ if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
400
+ // and in Firefox 3.6
401
+ onProgress();
402
+ }
403
+ } else if (xhr.readyState === 2) {
404
+ onStart();
405
+ }
406
+ }
407
+ };
408
+ var onTimeout = function () {
409
+ timeout = setTimeout(function () {
410
+ onTimeout();
411
+ }, 500);
412
+ if (xhr.readyState === 3) {
413
+ onProgress();
414
+ }
415
+ };
416
+
417
+ // XDomainRequest#abort removes onprogress, onerror, onload
418
+ if ("onload" in xhr) {
419
+ xhr.onload = function (event) {
420
+ onFinish("load", event);
421
+ };
422
+ }
423
+ if ("onerror" in xhr) {
424
+ xhr.onerror = function (event) {
425
+ onFinish("error", event);
426
+ };
427
+ }
428
+ // improper fix to match Firefox behaviour, but it is better than just ignore abort
429
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
430
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=880200
431
+ // https://code.google.com/p/chromium/issues/detail?id=153570
432
+ // IE 8 fires "onload" without "onprogress
433
+ if ("onabort" in xhr) {
434
+ xhr.onabort = function (event) {
435
+ onFinish("abort", event);
436
+ };
437
+ }
438
+
439
+ if ("onprogress" in xhr) {
440
+ xhr.onprogress = onProgress;
441
+ }
442
+
443
+ // IE 8 - 9 (XMLHTTPRequest)
444
+ // Opera < 12
445
+ // Firefox < 3.5
446
+ // Firefox 3.5 - 3.6 - ? < 9.0
447
+ // onprogress is not fired sometimes or delayed
448
+ // see also #64 (significant lag in IE 11)
449
+ if ("onreadystatechange" in xhr) {
450
+ xhr.onreadystatechange = function (event) {
451
+ onReadyStateChange(event);
452
+ };
453
+ }
454
+
455
+ if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
456
+ url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
457
+ }
458
+ xhr.open(method, url, true);
459
+
460
+ if ("readyState" in xhr) {
461
+ // workaround for Opera 12 issue with "progress" events
462
+ // #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
463
+ timeout = setTimeout(function () {
464
+ onTimeout();
465
+ }, 0);
466
+ }
467
+ };
468
+ XHRWrapper.prototype.abort = function () {
469
+ this._abort(false);
470
+ };
471
+ XHRWrapper.prototype.getResponseHeader = function (name) {
472
+ return this._contentType;
473
+ };
474
+ XHRWrapper.prototype.setRequestHeader = function (name, value) {
475
+ var xhr = this._xhr;
476
+ if ("setRequestHeader" in xhr) {
477
+ xhr.setRequestHeader(name, value);
478
+ }
479
+ };
480
+ XHRWrapper.prototype.getAllResponseHeaders = function () {
481
+ // XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
482
+ return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
483
+ };
484
+ XHRWrapper.prototype.send = function () {
485
+ // loading indicator in Safari < ? (6), Chrome < 14, Firefox
486
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=736723
487
+ if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
488
+ document != undefined &&
489
+ document.readyState != undefined &&
490
+ document.readyState !== "complete") {
491
+ var that = this;
492
+ that._sendTimeout = setTimeout(function () {
493
+ that._sendTimeout = 0;
494
+ that.send();
495
+ }, 4);
496
+ return;
497
+ }
498
+
499
+ var xhr = this._xhr;
500
+ // withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
501
+ if ("withCredentials" in xhr) {
502
+ xhr.withCredentials = this.withCredentials;
503
+ }
504
+ try {
505
+ // xhr.send(); throws "Not enough arguments" in Firefox 3.0
506
+ xhr.send(undefined);
507
+ } catch (error1) {
508
+ // Safari 5.1.7, Opera 12
509
+ throw error1;
510
+ }
511
+ };
512
+
513
+ function toLowerCase(name) {
514
+ return name.replace(/[A-Z]/g, function (c) {
515
+ return String.fromCharCode(c.charCodeAt(0) + 0x20);
516
+ });
517
+ }
518
+
519
+ function HeadersPolyfill(all) {
520
+ // Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
521
+ var map = Object.create(null);
522
+ var array = all.split("\r\n");
523
+ for (var i = 0; i < array.length; i += 1) {
524
+ var line = array[i];
525
+ var parts = line.split(": ");
526
+ var name = parts.shift();
527
+ var value = parts.join(": ");
528
+ map[toLowerCase(name)] = value;
529
+ }
530
+ this._map = map;
531
+ }
532
+ HeadersPolyfill.prototype.get = function (name) {
533
+ return this._map[toLowerCase(name)];
534
+ };
535
+
536
+ if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
537
+ XMLHttpRequest.HEADERS_RECEIVED = 2;
538
+ }
539
+
540
+ function XHRTransport() {
541
+ }
542
+
543
+ XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
544
+ xhr.open("GET", url);
545
+ var offset = 0;
546
+ xhr.onprogress = function () {
547
+ var responseText = xhr.responseText;
548
+ var chunk = responseText.slice(offset);
549
+ offset += chunk.length;
550
+ onProgressCallback(chunk);
551
+ };
552
+ xhr.onerror = function (event) {
553
+ event.preventDefault();
554
+ onFinishCallback(new Error("NetworkError"));
555
+ };
556
+ xhr.onload = function () {
557
+ onFinishCallback(null);
558
+ };
559
+ xhr.onabort = function () {
560
+ onFinishCallback(null);
561
+ };
562
+ xhr.onreadystatechange = function () {
563
+ if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
564
+ var status = xhr.status;
565
+ var statusText = xhr.statusText;
566
+ var contentType = xhr.getResponseHeader("Content-Type");
567
+ var headers = xhr.getAllResponseHeaders();
568
+ onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
569
+ }
570
+ };
571
+ xhr.withCredentials = withCredentials;
572
+ for (var name in headers) {
573
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
574
+ xhr.setRequestHeader(name, headers[name]);
575
+ }
576
+ }
577
+ xhr.send();
578
+ return xhr;
579
+ };
580
+
581
+ function HeadersWrapper(headers) {
582
+ this._headers = headers;
583
+ }
584
+ HeadersWrapper.prototype.get = function (name) {
585
+ return this._headers.get(name);
586
+ };
587
+
588
+ function FetchTransport() {
589
+ }
590
+
591
+ FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
592
+ var reader = null;
593
+ var controller = new AbortController();
594
+ var signal = controller.signal;
595
+ var textDecoder = new TextDecoder();
596
+ fetch(url, {
597
+ headers: headers,
598
+ credentials: withCredentials ? "include" : "same-origin",
599
+ signal: signal,
600
+ cache: "no-store"
601
+ }).then(function (response) {
602
+ reader = response.body.getReader();
603
+ onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
604
+ // see https://github.com/promises-aplus/promises-spec/issues/179
605
+ return new Promise(function (resolve, reject) {
606
+ var readNextChunk = function () {
607
+ reader.read().then(function (result) {
608
+ if (result.done) {
609
+ //Note: bytes in textDecoder are ignored
610
+ resolve(undefined);
611
+ } else {
612
+ var chunk = textDecoder.decode(result.value, {stream: true});
613
+ onProgressCallback(chunk);
614
+ readNextChunk();
615
+ }
616
+ })["catch"](function (error) {
617
+ reject(error);
618
+ });
619
+ };
620
+ readNextChunk();
621
+ });
622
+ })["catch"](function (error) {
623
+ if (error.name === "AbortError") {
624
+ return undefined;
625
+ } else {
626
+ return error;
627
+ }
628
+ }).then(function (error) {
629
+ onFinishCallback(error);
630
+ });
631
+ return {
632
+ abort: function () {
633
+ if (reader != null) {
634
+ reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
635
+ }
636
+ controller.abort();
637
+ }
638
+ };
639
+ };
640
+
641
+ function EventTarget() {
642
+ this._listeners = Object.create(null);
643
+ }
644
+
645
+ function throwError(e) {
646
+ setTimeout(function () {
647
+ throw e;
648
+ }, 0);
649
+ }
650
+
651
+ EventTarget.prototype.dispatchEvent = function (event) {
652
+ event.target = this;
653
+ var typeListeners = this._listeners[event.type];
654
+ if (typeListeners != undefined) {
655
+ var length = typeListeners.length;
656
+ for (var i = 0; i < length; i += 1) {
657
+ var listener = typeListeners[i];
658
+ try {
659
+ if (typeof listener.handleEvent === "function") {
660
+ listener.handleEvent(event);
661
+ } else {
662
+ listener.call(this, event);
663
+ }
664
+ } catch (e) {
665
+ throwError(e);
666
+ }
667
+ }
668
+ }
669
+ };
670
+ EventTarget.prototype.addEventListener = function (type, listener) {
671
+ type = String(type);
672
+ var listeners = this._listeners;
673
+ var typeListeners = listeners[type];
674
+ if (typeListeners == undefined) {
675
+ typeListeners = [];
676
+ listeners[type] = typeListeners;
677
+ }
678
+ var found = false;
679
+ for (var i = 0; i < typeListeners.length; i += 1) {
680
+ if (typeListeners[i] === listener) {
681
+ found = true;
682
+ }
683
+ }
684
+ if (!found) {
685
+ typeListeners.push(listener);
686
+ }
687
+ };
688
+ EventTarget.prototype.removeEventListener = function (type, listener) {
689
+ type = String(type);
690
+ var listeners = this._listeners;
691
+ var typeListeners = listeners[type];
692
+ if (typeListeners != undefined) {
693
+ var filtered = [];
694
+ for (var i = 0; i < typeListeners.length; i += 1) {
695
+ if (typeListeners[i] !== listener) {
696
+ filtered.push(typeListeners[i]);
697
+ }
698
+ }
699
+ if (filtered.length === 0) {
700
+ delete listeners[type];
701
+ } else {
702
+ listeners[type] = filtered;
703
+ }
704
+ }
705
+ };
706
+
707
+ function Event(type) {
708
+ this.type = type;
709
+ this.target = undefined;
710
+ }
711
+
712
+ function MessageEvent(type, options) {
713
+ Event.call(this, type);
714
+ this.data = options.data;
715
+ this.lastEventId = options.lastEventId;
716
+ }
717
+
718
+ MessageEvent.prototype = Object.create(Event.prototype);
719
+
720
+ function ConnectionEvent(type, options) {
721
+ Event.call(this, type);
722
+ this.status = options.status;
723
+ this.statusText = options.statusText;
724
+ this.headers = options.headers;
725
+ }
726
+
727
+ ConnectionEvent.prototype = Object.create(Event.prototype);
728
+
729
+ function ErrorEvent(type, options) {
730
+ Event.call(this, type);
731
+ this.error = options.error;
732
+ }
733
+
734
+ ErrorEvent.prototype = Object.create(Event.prototype);
735
+
736
+ var WAITING = -1;
737
+ var CONNECTING = 0;
738
+ var OPEN = 1;
739
+ var CLOSED = 2;
740
+
741
+ var AFTER_CR = -1;
742
+ var FIELD_START = 0;
743
+ var FIELD = 1;
744
+ var VALUE_START = 2;
745
+ var VALUE = 3;
746
+
747
+ var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
748
+
749
+ var MINIMUM_DURATION = 1000;
750
+ var MAXIMUM_DURATION = 18000000;
751
+
752
+ var parseDuration = function (value, def) {
753
+ var n = value == null ? def : parseInt(value, 10);
754
+ if (n !== n) {
755
+ n = def;
756
+ }
757
+ return clampDuration(n);
758
+ };
759
+ var clampDuration = function (n) {
760
+ return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
761
+ };
762
+
763
+ var fire = function (that, f, event) {
764
+ try {
765
+ if (typeof f === "function") {
766
+ f.call(that, event);
767
+ }
768
+ } catch (e) {
769
+ throwError(e);
770
+ }
771
+ };
772
+
773
+ function EventSourcePolyfill(url, options) {
774
+ EventTarget.call(this);
775
+ options = options || {};
776
+
777
+ this.onopen = undefined;
778
+ this.onmessage = undefined;
779
+ this.onerror = undefined;
780
+
781
+ this.url = undefined;
782
+ this.readyState = undefined;
783
+ this.withCredentials = undefined;
784
+ this.headers = undefined;
785
+
786
+ this._close = undefined;
787
+
788
+ start(this, url, options);
789
+ }
790
+
791
+ function getBestXHRTransport() {
792
+ return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
793
+ ? new XMLHttpRequest()
794
+ : new XDomainRequest();
795
+ }
796
+
797
+ var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
798
+
799
+ function start(es, url, options) {
800
+ url = String(url);
801
+ var withCredentials = Boolean(options.withCredentials);
802
+ var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
803
+
804
+ var initialRetry = clampDuration(1000);
805
+ var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
806
+
807
+ var lastEventId = "";
808
+ var retry = initialRetry;
809
+ var wasActivity = false;
810
+ var textLength = 0;
811
+ var headers = options.headers || {};
812
+ var TransportOption = options.Transport;
813
+ var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
814
+ var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
815
+ var abortController = undefined;
816
+ var timeout = 0;
817
+ var currentState = WAITING;
818
+ var dataBuffer = "";
819
+ var lastEventIdBuffer = "";
820
+ var eventTypeBuffer = "";
821
+
822
+ var textBuffer = "";
823
+ var state = FIELD_START;
824
+ var fieldStart = 0;
825
+ var valueStart = 0;
826
+
827
+ var onStart = function (status, statusText, contentType, headers) {
828
+ if (currentState === CONNECTING) {
829
+ if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
830
+ currentState = OPEN;
831
+ wasActivity = Date.now();
832
+ retry = initialRetry;
833
+ es.readyState = OPEN;
834
+ var event = new ConnectionEvent("open", {
835
+ status: status,
836
+ statusText: statusText,
837
+ headers: headers
838
+ });
839
+ es.dispatchEvent(event);
840
+ fire(es, es.onopen, event);
841
+ } else {
842
+ var message = "";
843
+ if (status !== 200) {
844
+ if (statusText) {
845
+ statusText = statusText.replace(/\s+/g, " ");
846
+ }
847
+ message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
848
+ } else {
849
+ message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
850
+ }
851
+ close();
852
+ var event = new ConnectionEvent("error", {
853
+ status: status,
854
+ statusText: statusText,
855
+ headers: headers
856
+ });
857
+ es.dispatchEvent(event);
858
+ fire(es, es.onerror, event);
859
+ console.error(message);
860
+ }
861
+ }
862
+ };
863
+
864
+ var onProgress = function (textChunk) {
865
+ if (currentState === OPEN) {
866
+ var n = -1;
867
+ for (var i = 0; i < textChunk.length; i += 1) {
868
+ var c = textChunk.charCodeAt(i);
869
+ if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
870
+ n = i;
871
+ }
872
+ }
873
+ var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
874
+ textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
875
+ if (textChunk !== "") {
876
+ wasActivity = Date.now();
877
+ textLength += textChunk.length;
878
+ }
879
+ for (var position = 0; position < chunk.length; position += 1) {
880
+ var c = chunk.charCodeAt(position);
881
+ if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
882
+ state = FIELD_START;
883
+ } else {
884
+ if (state === AFTER_CR) {
885
+ state = FIELD_START;
886
+ }
887
+ if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
888
+ if (state !== FIELD_START) {
889
+ if (state === FIELD) {
890
+ valueStart = position + 1;
891
+ }
892
+ var field = chunk.slice(fieldStart, valueStart - 1);
893
+ var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
894
+ if (field === "data") {
895
+ dataBuffer += "\n";
896
+ dataBuffer += value;
897
+ } else if (field === "id") {
898
+ lastEventIdBuffer = value;
899
+ } else if (field === "event") {
900
+ eventTypeBuffer = value;
901
+ } else if (field === "retry") {
902
+ initialRetry = parseDuration(value, initialRetry);
903
+ retry = initialRetry;
904
+ } else if (field === "heartbeatTimeout") {
905
+ heartbeatTimeout = parseDuration(value, heartbeatTimeout);
906
+ if (timeout !== 0) {
907
+ clearTimeout(timeout);
908
+ timeout = setTimeout(function () {
909
+ onTimeout();
910
+ }, heartbeatTimeout);
911
+ }
912
+ }
913
+ }
914
+ if (state === FIELD_START) {
915
+ if (dataBuffer !== "") {
916
+ lastEventId = lastEventIdBuffer;
917
+ if (eventTypeBuffer === "") {
918
+ eventTypeBuffer = "message";
919
+ }
920
+ var event = new MessageEvent(eventTypeBuffer, {
921
+ data: dataBuffer.slice(1),
922
+ lastEventId: lastEventIdBuffer
923
+ });
924
+ es.dispatchEvent(event);
925
+ if (eventTypeBuffer === "open") {
926
+ fire(es, es.onopen, event);
927
+ } else if (eventTypeBuffer === "message") {
928
+ fire(es, es.onmessage, event);
929
+ } else if (eventTypeBuffer === "error") {
930
+ fire(es, es.onerror, event);
931
+ }
932
+ if (currentState === CLOSED) {
933
+ return;
934
+ }
935
+ }
936
+ dataBuffer = "";
937
+ eventTypeBuffer = "";
938
+ }
939
+ state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
940
+ } else {
941
+ if (state === FIELD_START) {
942
+ fieldStart = position;
943
+ state = FIELD;
944
+ }
945
+ if (state === FIELD) {
946
+ if (c === ":".charCodeAt(0)) {
947
+ valueStart = position + 1;
948
+ state = VALUE_START;
949
+ }
950
+ } else if (state === VALUE_START) {
951
+ state = VALUE;
952
+ }
953
+ }
954
+ }
955
+ }
956
+ }
957
+ };
958
+
959
+ var onFinish = function (error) {
960
+ if (currentState === OPEN || currentState === CONNECTING) {
961
+ currentState = WAITING;
962
+ if (timeout !== 0) {
963
+ clearTimeout(timeout);
964
+ timeout = 0;
965
+ }
966
+ timeout = setTimeout(function () {
967
+ onTimeout();
968
+ }, retry);
969
+ retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
970
+
971
+ es.readyState = CONNECTING;
972
+ var event = new ErrorEvent("error", {error: error});
973
+ es.dispatchEvent(event);
974
+ fire(es, es.onerror, event);
975
+ if (error != undefined) {
976
+ console.error(error);
977
+ }
978
+ }
979
+ };
980
+
981
+ var close = function () {
982
+ currentState = CLOSED;
983
+ if (abortController != undefined) {
984
+ abortController.abort();
985
+ abortController = undefined;
986
+ }
987
+ if (timeout !== 0) {
988
+ clearTimeout(timeout);
989
+ timeout = 0;
990
+ }
991
+ es.readyState = CLOSED;
992
+ };
993
+
994
+ var onTimeout = function () {
995
+ timeout = 0;
996
+
997
+ if (currentState !== WAITING) {
998
+ if (!wasActivity && abortController != undefined) {
999
+ onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
1000
+ if (abortController != undefined) {
1001
+ abortController.abort();
1002
+ abortController = undefined;
1003
+ }
1004
+ } else {
1005
+ var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
1006
+ wasActivity = false;
1007
+ timeout = setTimeout(function () {
1008
+ onTimeout();
1009
+ }, nextHeartbeat);
1010
+ }
1011
+ return;
1012
+ }
1013
+
1014
+ wasActivity = false;
1015
+ textLength = 0;
1016
+ timeout = setTimeout(function () {
1017
+ onTimeout();
1018
+ }, heartbeatTimeout);
1019
+
1020
+ currentState = CONNECTING;
1021
+ dataBuffer = "";
1022
+ eventTypeBuffer = "";
1023
+ lastEventIdBuffer = lastEventId;
1024
+ textBuffer = "";
1025
+ fieldStart = 0;
1026
+ valueStart = 0;
1027
+ state = FIELD_START;
1028
+
1029
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=428916
1030
+ // Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
1031
+ var requestURL = url;
1032
+ if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
1033
+ if (lastEventId !== "") {
1034
+ // Remove the lastEventId parameter if it's already part of the request URL.
1035
+ var i = url.indexOf("?");
1036
+ requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
1037
+ return paramName === lastEventIdQueryParameterName ? '' : p;
1038
+ });
1039
+ // Append the current lastEventId to the request URL.
1040
+ requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
1041
+ }
1042
+ }
1043
+ var withCredentials = es.withCredentials;
1044
+ var requestHeaders = {};
1045
+ requestHeaders["Accept"] = "text/event-stream";
1046
+ var headers = es.headers;
1047
+ if (headers != undefined) {
1048
+ for (var name in headers) {
1049
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
1050
+ requestHeaders[name] = headers[name];
1051
+ }
1052
+ }
1053
+ }
1054
+ try {
1055
+ abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
1056
+ } catch (error) {
1057
+ close();
1058
+ throw error;
1059
+ }
1060
+ };
1061
+
1062
+ es.url = url;
1063
+ es.readyState = CONNECTING;
1064
+ es.withCredentials = withCredentials;
1065
+ es.headers = headers;
1066
+ es._close = close;
1067
+
1068
+ onTimeout();
1069
+ }
1070
+
1071
+ EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
1072
+ EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
1073
+ EventSourcePolyfill.prototype.OPEN = OPEN;
1074
+ EventSourcePolyfill.prototype.CLOSED = CLOSED;
1075
+ EventSourcePolyfill.prototype.close = function () {
1076
+ this._close();
1077
+ };
1078
+
1079
+ EventSourcePolyfill.CONNECTING = CONNECTING;
1080
+ EventSourcePolyfill.OPEN = OPEN;
1081
+ EventSourcePolyfill.CLOSED = CLOSED;
1082
+ EventSourcePolyfill.prototype.withCredentials = undefined;
1083
+
1084
+ var R = NativeEventSource;
1085
+ if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
1086
+ // Why replace a native EventSource ?
1087
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=444328
1088
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=831392
1089
+ // https://code.google.com/p/chromium/issues/detail?id=260144
1090
+ // https://code.google.com/p/chromium/issues/detail?id=225654
1091
+ // ...
1092
+ R = EventSourcePolyfill;
1093
+ }
1094
+
1095
+ (function (factory) {
1096
+ {
1097
+ var v = factory(exports);
1098
+ if (v !== undefined) module.exports = v;
1099
+ }
1100
+ })(function (exports) {
1101
+ exports.EventSourcePolyfill = EventSourcePolyfill;
1102
+ exports.NativeEventSource = NativeEventSource;
1103
+ exports.EventSource = R;
1104
+ });
1105
+ }(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal) : globalThis));
1106
+ }(eventsource, eventsource.exports));
1107
+
1108
+ var currency_min$1 = {exports: {}};
1109
+
1110
+ /*
1111
+ currency.js - v2.0.4
1112
+ http://scurker.github.io/currency.js
1113
+
1114
+ Copyright (c) 2021 Jason Wilson
1115
+ Released under MIT license
1116
+ */
1117
+
1118
+ (function (module, exports) {
1119
+ (function(e,g){module.exports=g();})(commonjsGlobal,function(){function e(b,a){if(!(this instanceof e))return new e(b,a);a=Object.assign({},m,a);var d=Math.pow(10,a.precision);this.intValue=b=g(b,a);this.value=b/d;a.increment=a.increment||1/d;a.groups=a.useVedic?n:p;this.s=a;this.p=d;}function g(b,a){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:!0;var c=a.decimal;
1120
+ var h=a.errorOnInvalid,k=a.fromCents,l=Math.pow(10,a.precision),f=b instanceof e;if(f&&k)return b.intValue;if("number"===typeof b||f)c=f?b.value:b;else if("string"===typeof b)h=new RegExp("[^-\\d"+c+"]","g"),c=new RegExp("\\"+c,"g"),c=(c=b.replace(/\((.*)\)/,"-$1").replace(h,"").replace(c,"."))||0;else {if(h)throw Error("Invalid Input");c=0;}k||(c=(c*l).toFixed(4));return d?Math.round(c):c}var m={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:function(b,
1121
+ a){var d=a.pattern,c=a.negativePattern,h=a.symbol,k=a.separator,l=a.decimal;a=a.groups;var f=(""+b).replace(/^-/,"").split("."),q=f[0];f=f[1];return (0<=b.value?d:c).replace("!",h).replace("#",q.replace(a,"$1"+k)+(f?l+f:""))},fromCents:!1},p=/(\d)(?=(\d{3})+\b)/g,n=/(\d)(?=(\d\d)+\d\b)/g;e.prototype={add:function(b){var a=this.s,d=this.p;return e((this.intValue+g(b,a))/(a.fromCents?1:d),a)},subtract:function(b){var a=this.s,d=this.p;return e((this.intValue-g(b,a))/(a.fromCents?1:d),a)},multiply:function(b){var a=
1122
+ this.s;return e(this.intValue*b/(a.fromCents?1:Math.pow(10,a.precision)),a)},divide:function(b){var a=this.s;return e(this.intValue/g(b,a,!1),a)},distribute:function(b){var a=this.intValue,d=this.p,c=this.s,h=[],k=Math[0<=a?"floor":"ceil"](a/b),l=Math.abs(a-k*b);for(d=c.fromCents?1:d;0!==b;b--){var f=e(k/d,c);0<l--&&(f=f[0<=a?"add":"subtract"](1/d));h.push(f);}return h},dollars:function(){return ~~this.value},cents:function(){return ~~(this.intValue%this.p)},format:function(b){var a=this.s;return "function"===
1123
+ typeof b?b(this,a):a.format(this,Object.assign({},a,b))},toString:function(){var b=this.s,a=b.increment;return (Math.round(this.intValue/this.p/a)*a).toFixed(b.precision)},toJSON:function(){return this.value}};return e});
1124
+ }(currency_min$1));
1125
+
1126
+ const currency_min = currency_min$1.exports;
1127
+
1128
+ const DEFAULT_LANGUAGE = 'en';
1129
+ const TRANSLATIONS = {
1130
+ "en": {
1131
+ "Title": "Your Balance",
1132
+ "Total": "Total Balance",
1133
+ "Real": "Cash Balance",
1134
+ "Bonus": "Bonus Balance",
1135
+ "Credit": "Credit Balance",
1136
+ "Casino": "Casino",
1137
+ "Sports": "Sports",
1138
+ "DepositButton": "Deposit",
1139
+ "Loading": "Loading ..."
1140
+ },
1141
+ "zh-hk": {
1142
+ "Title": "您的結餘",
1143
+ "Total": "總結餘",
1144
+ "Real": "現金結餘",
1145
+ "Bonus": "紅利結餘",
1146
+ "Credit": "信用結餘",
1147
+ "Casino": "賭場",
1148
+ "Sports": "體育",
1149
+ "DepositButton": "存款",
1150
+ "Loading": "載入中 ..."
1151
+ },
1152
+ "de": {
1153
+ "Title": "Ihr Guthaben",
1154
+ "Total": "Gesamtguthaben",
1155
+ "Real": "Barguthaben",
1156
+ "Bonus": "Bonusguthaben",
1157
+ "Credit": "Kreditguthaben",
1158
+ "Casino": "Casino",
1159
+ "Sports": "Sport",
1160
+ "DepositButton": "Einzahlen",
1161
+ "Loading": "Wird geladen ..."
1162
+ },
1163
+ "it": {
1164
+ "Title": "Il tuo saldo",
1165
+ "Total": "Saldo totale",
1166
+ "Real": "Saldo in contanti",
1167
+ "Bonus": "Saldo bonus",
1168
+ "Credit": "Saldo di credito",
1169
+ "Casino": "Casinò",
1170
+ "Sports": "Sport",
1171
+ "DepositButton": "Deposita",
1172
+ "Loading": "Caricamento ..."
1173
+ },
1174
+ "fr": {
1175
+ "Title": "Votre solde",
1176
+ "Total": "Solde total",
1177
+ "Real": "Solde en espèces",
1178
+ "Bonus": "Solde bonus",
1179
+ "Credit": "Solde de crédit",
1180
+ "Casino": "Casino",
1181
+ "Sports": "Sports",
1182
+ "DepositButton": "Dépôt",
1183
+ "Loading": "Chargement ..."
1184
+ },
1185
+ "es": {
1186
+ "Title": "Tu saldo",
1187
+ "Total": "Saldo total",
1188
+ "Real": "Saldo en efectivo",
1189
+ "Bonus": "Saldo de bono",
1190
+ "Credit": "Saldo de crédito",
1191
+ "Casino": "Casino",
1192
+ "Sports": "Deportes",
1193
+ "DepositButton": "Depósito",
1194
+ "Loading": "Cargando ..."
1195
+ },
1196
+ "tr": {
1197
+ "Title": "Bakiyeniz",
1198
+ "Total": "Toplam Bakiye",
1199
+ "Real": "Nakit Bakiye",
1200
+ "Bonus": "Bonus Bakiyesi",
1201
+ "Credit": "Kredi Bakiyesi",
1202
+ "Casino": "Kumarhane",
1203
+ "Sports": "Spor",
1204
+ "DepositButton": "Yatır",
1205
+ "Loading": "Yükleniyor ..."
1206
+ },
1207
+ "ru": {
1208
+ "Title": "Ваш баланс",
1209
+ "Total": "Общий баланс",
1210
+ "Real": "Денежный баланс",
1211
+ "Bonus": "Бонусный баланс",
1212
+ "Credit": "Кредитный баланс",
1213
+ "Casino": "Казино",
1214
+ "Sports": "Спорт",
1215
+ "DepositButton": "Депозит",
1216
+ "Loading": "Загружается ..."
1217
+ },
1218
+ "ro": {
1219
+ "Title": "Soldul tău",
1220
+ "Total": "Sold total",
1221
+ "Real": "Sold în numerar",
1222
+ "Bonus": "Sold bonus",
1223
+ "Credit": "Sold credit",
1224
+ "Casino": "Cazinou",
1225
+ "Sports": "Sporturi",
1226
+ "DepositButton": "Depozit",
1227
+ "Loading": "Se încarcă ..."
1228
+ },
1229
+ "hr": {
1230
+ "Title": "Vaš saldo",
1231
+ "Total": "Ukupni saldo",
1232
+ "Real": "Gotovinski saldo",
1233
+ "Bonus": "Bonus saldo",
1234
+ "Credit": "Kreditni saldo",
1235
+ "Casino": "Casino",
1236
+ "Sports": "Sportovi",
1237
+ "DepositButton": "Depozit",
1238
+ "Loading": "Učitavanje ..."
1239
+ },
1240
+ "hu": {
1241
+ "Title": "Az egyenleged",
1242
+ "Total": "Teljes egyenleg",
1243
+ "Real": "Készpénz egyenleg",
1244
+ "Bonus": "Bónusz egyenleg",
1245
+ "Credit": "Hitel egyenleg",
1246
+ "Casino": "Kaszinó",
1247
+ "Sports": "Sport",
1248
+ "DepositButton": "Befizetés",
1249
+ "Loading": "Betöltés ..."
1250
+ },
1251
+ "pl": {
1252
+ "Title": "Twoje saldo",
1253
+ "Total": "Całkowite saldo",
1254
+ "Real": "Saldo gotówkowe",
1255
+ "Bonus": "Saldo bonusowe",
1256
+ "Credit": "Saldo kredytowe",
1257
+ "Casino": "Kasyno",
1258
+ "Sports": "Sport",
1259
+ "DepositButton": "Wpłać",
1260
+ "Loading": "Ładowanie ..."
1261
+ },
1262
+ "pt": {
1263
+ "Title": "Seu Saldo",
1264
+ "Total": "Saldo Total",
1265
+ "Real": "Saldo em Dinheiro",
1266
+ "Bonus": "Saldo de Bônus",
1267
+ "Credit": "Saldo de Crédito",
1268
+ "Casino": "Cassino",
1269
+ "Sports": "Esportes",
1270
+ "DepositButton": "Depositar",
1271
+ "Loading": "Carregando ..."
1272
+ },
1273
+ "sl": {
1274
+ "Title": "Vaš saldo",
1275
+ "Total": "Skupni saldo",
1276
+ "Real": "Gotovinski saldo",
1277
+ "Bonus": "Bonus saldo",
1278
+ "Credit": "Kreditni saldo",
1279
+ "Casino": "Kasino",
1280
+ "Sports": "Šport",
1281
+ "DepositButton": "Depozit",
1282
+ "Loading": "Nalaganje ..."
1283
+ },
1284
+ "sr": {
1285
+ "Title": "Vaš saldo",
1286
+ "Total": "Ukupan saldo",
1287
+ "Real": "Gotovinski saldo",
1288
+ "Bonus": "Bonus saldo",
1289
+ "Credit": "Kreditni saldo",
1290
+ "Casino": "Kasino",
1291
+ "Sports": "Sport",
1292
+ "DepositButton": "Depozit",
1293
+ "Loading": "Učitavanje ..."
1294
+ },
1295
+ "pt-br": {
1296
+ "Title": "Seu Saldo",
1297
+ "Total": "Saldo Total",
1298
+ "Real": "Saldo em Dinheiro",
1299
+ "Bonus": "Saldo de Bônus",
1300
+ "Credit": "Saldo de Crédito",
1301
+ "Casino": "Cassino",
1302
+ "Sports": "Esportes",
1303
+ "DepositButton": "Depositar",
1304
+ "Loading": "Carregando ..."
1305
+ },
1306
+ "es-mx": {
1307
+ "Title": "Tu saldo",
1308
+ "Total": "Saldo total",
1309
+ "Real": "Saldo en efectivo",
1310
+ "Bonus": "Saldo de bono",
1311
+ "Credit": "Saldo de crédito",
1312
+ "Casino": "Casino",
1313
+ "Sports": "Deportes",
1314
+ "DepositButton": "Depósito",
1315
+ "Loading": "Cargando ..."
1316
+ },
1317
+ "en-us": {
1318
+ "Title": "Your Balance",
1319
+ "Total": "Total Balance",
1320
+ "Real": "Cash Balance",
1321
+ "Bonus": "Bonus Balance",
1322
+ "Credit": "Credit Balance",
1323
+ "Casino": "Casino",
1324
+ "Sports": "Sports",
1325
+ "DepositButton": "Deposit",
1326
+ "Loading": "Loading ..."
1327
+ }
1328
+ };
1329
+ const translate = (key, customLang, values) => {
1330
+ let lang = TRANSLATIONS[customLang] ? customLang : DEFAULT_LANGUAGE;
1331
+ let translation = TRANSLATIONS[lang][key];
1332
+ if (values !== undefined) {
1333
+ for (const [key, value] of Object.entries(values.values)) {
1334
+ const regex = new RegExp(`{${key}}`, 'g');
1335
+ translation = translation.replace(regex, value);
1336
+ }
1337
+ }
1338
+ return translation;
1339
+ };
1340
+
1341
+ const pamAccountBalanceModalCss = "*,*::before,*::after{font-family:inherit}:host{font-family:inherit}input,textarea,button{font-family:inherit}p{padding:0;margin:0}.PamAccountBalanceModal{position:relative}.PamAccountBalanceModal .LoadingSkeleton{border-radius:10px;overflow:hidden;width:60px}.PamAccountBalanceModal .BalanceValue{font-size:14px;cursor:pointer;background:transparent;border:none;font:inherit;color:inherit;display:flex;flex-wrap:nowrap;white-space:nowrap}.PamAccountBalanceModal .BalanceValue svg{width:16px;fill:var(--emw--color-black, #000000)}.PamAccountBalanceModal .BalanceValue span{padding-left:5px}.PamAccountBalanceModal .BalanceValue .TriangleActive,.PamAccountBalanceModal .BalanceValue .TriangleInactive{display:block;margin:0 3px;transition:all 0.2s}.PamAccountBalanceModal .BalanceValue .TriangleActive:hover,.PamAccountBalanceModal .BalanceValue .TriangleInactive:hover{transform:scale(1.2)}.PamAccountBalanceModal .BalanceValue .TriangleActive svg,.PamAccountBalanceModal .BalanceValue .TriangleInactive svg{margin:2px 0px}.PamAccountBalanceModal .BalanceValue .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px)}.PamAccountBalanceModal .BalanceValue .TriangleActive:hover{transform:scale(1.1) rotateX(180deg) translateY(3px)}@media only screen and (max-width: 360px){.PamAccountBalanceModal .BalanceValue{font-size:12px}.PamAccountBalanceModal .BalanceValue svg{width:12px}}.PamAccountBalanceModal .BalanceModalWrapper{background:linear-gradient(90deg, rgb(42, 79, 55) 0%, rgb(0, 61, 92) 100%);position:absolute;top:40px;padding:10px;transform:translateX(-45%);box-shadow:0px 30px 30px var(--emw--header-color-primary, var(--emw--color-primary, #22B04E));border-radius:5px;z-index:17;box-shadow:0px 5px 20px 0px #191919;transition:all 0.2s ease-in;opacity:0}.PamAccountBalanceModal .BalanceModalWrapper:before{content:\"\";background:linear-gradient(90deg, rgb(42, 79, 55) 0%, rgb(0, 61, 92) 100%);clip-path:polygon(50% 0, 0% 100%, 100% 100%);position:absolute;top:-8px;left:50%;width:25px;height:10px;z-index:1}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose{position:absolute;top:5px;right:5px;width:20px;height:20px;z-index:1;cursor:pointer;transition:all 0.3s ease;background:transparent;border:none;font:inherit}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose:before{content:\"\";background:var(--emw--color-secondary, #FFFFFF);position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(45deg)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose:after{content:\"\";background:var(--emw--color-secondary, #FFFFFF);position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(-45deg)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModalClose:hover{transform:scale(1.1)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal{transition:all 0.2s ease-in;width:270px}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalHeader{display:flex;align-items:center;justify-content:center;padding:20px 0}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalHeader .BalanceModalTitle{font-size:16px;font-weight:bold;color:var(--emw--header-contrast, var(--emw--color-contrast, #FFFFFF))}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth{display:flex;flex-direction:column;gap:5px;padding:20px 0;border-bottom:1px solid var(--emw--color-gray-100, #E6E6E6)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth:last-child{border-bottom:none}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth .BalanceModalRowLine{display:flex;width:100%;justify-content:space-between}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth .BalanceModalText{color:var(--emw--header-contrast, var(--emw--color-contrast, #FFFFFF));font-size:14px;text-transform:capitalize}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalBody .BalanceModalRowBoth .BalanceModalValue{font-size:14px;font-weight:bold;color:var(--emw--header-contrast, var(--emw--color-contrast, #FFFFFF))}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter{display:flex;align-items:center;padding:20px 0 10px}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter .BalanceModalAction{background:var(--emw--color-primary, #22B04E);font-size:12px;color:var(--emw--color-white, #FFFFFF);text-transform:uppercase;width:100%;border-radius:30px;border:none;padding:10px 0;cursor:pointer;transition:all 0.2s ease-in;box-shadow:0px 3px 7px 0px rgba(0, 0, 0, 0.2)}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter .BalanceModalAction:hover{background:rgba(255, 255, 255, 0.1);color:var(--emw--color-primary, #22B04E);box-shadow:0px 0px 0px 2px inset var(--emw--color-primary, #22B04E);font-size:14px}.PamAccountBalanceModal .BalanceModalWrapper .BalanceModal .BalanceModalFooter .BalanceModalAction:active{background:rgba(255, 255, 255, 0.5)}.PamAccountBalanceModal .BalanceModalWrapper.Open{opacity:1}.PamAccountBalanceModalOverlay{background-color:rgba(0, 0, 0, 0.7);position:fixed;top:0;bottom:0;left:0;right:0;z-index:16;opacity:0;transition:all 0.2s linear}.PamAccountBalanceModalOverlay.Open{opacity:1}";
1342
+ const PamAccountBalanceModalStyle0 = pamAccountBalanceModalCss;
1343
+
1344
+ const PamAccountBalanceModal = class {
1345
+ constructor(hostRef) {
1346
+ registerInstance(this, hostRef);
1347
+ this.totalCalculationModes = ['totalCashAmount', 'totalRealAmount'];
1348
+ this.setLocaleIdentifier = () => {
1349
+ if (this.customLocaleIdentifier.includes(this.language)) {
1350
+ return this.customLocaleIdentifier;
1351
+ }
1352
+ };
1353
+ this.formatBalance = (balance) => {
1354
+ if (this.customLocaleIdentifier) {
1355
+ return new Intl.NumberFormat(this.setLocaleIdentifier(), { useGrouping: true }).format(balance);
1356
+ }
1357
+ if (this.currencySeparator && this.currencyDecimal) {
1358
+ // @ts-ignore
1359
+ return currency_min(balance, { separator: this.currencySeparator, decimal: this.currencyDecimal, symbol: '', precision: parseInt(this.currencyPrecision || '2', 10) }).format();
1360
+ }
1361
+ // @ts-ignore
1362
+ return currency_min(balance, { separator: '.', decimal: ',', symbol: '', precision: parseInt(this.currencyPrecision || '2', 10) }).format();
1363
+ };
1364
+ this.getBalances = () => {
1365
+ this.isLoading = true;
1366
+ const url = new URL(`/v2/player/${this.userId}/balance/`, this.endpoint);
1367
+ const headers = new Headers();
1368
+ headers.append('X-SessionID', this.session);
1369
+ const params = {
1370
+ method: 'GET',
1371
+ headers: headers
1372
+ };
1373
+ return new Promise((resolve) => {
1374
+ return fetch(url, params)
1375
+ .then(res => res.json())
1376
+ .then(res => resolve(res))
1377
+ .catch((err) => {
1378
+ console.log('Balance fetch error', err);
1379
+ throw new Error('Failed to fetch balance data!');
1380
+ })
1381
+ .finally(() => this.isLoading = false);
1382
+ });
1383
+ };
1384
+ this.subscribeToBalanceUpdates = () => {
1385
+ if (this.currentStream) {
1386
+ this.currentStream.close();
1387
+ }
1388
+ if (this.session.length < 1) {
1389
+ return;
1390
+ }
1391
+ const url = new URL(`/v2/player/${this.userId}/information/updates/`, this.endpoint);
1392
+ const headers = {
1393
+ 'accept': 'text/event-stream',
1394
+ 'X-SessionId': this.session
1395
+ };
1396
+ const stream = new eventsource.exports.EventSourcePolyfill(url, { headers: headers });
1397
+ this.currentStream = stream;
1398
+ stream.addEventListener("message", this.updateBalances);
1399
+ };
1400
+ this.parseData = (data) => {
1401
+ let parsedData;
1402
+ try {
1403
+ parsedData = JSON.parse(data);
1404
+ }
1405
+ catch (e) {
1406
+ console.log('Balance stream failed: ', e);
1407
+ return;
1408
+ }
1409
+ return parsedData;
1410
+ };
1411
+ this.updateRealAmount = (currentRealAmount, state, balanceItem) => {
1412
+ let updatedRealAmount = null;
1413
+ switch (balanceItem.walletAccountType) {
1414
+ case 'Ordinary':
1415
+ if (balanceItem.afterAmount !== balanceItem.affectedAmount || state.lastOrdinaryAfterAmount === 0) {
1416
+ state.lastOrdinaryAfterAmount = balanceItem.afterAmount;
1417
+ if (!state.showCreditLineAfterAmount) {
1418
+ updatedRealAmount = balanceItem.afterAmount;
1419
+ }
1420
+ }
1421
+ break;
1422
+ case 'CreditLine':
1423
+ if (balanceItem.afterAmount !== 0) {
1424
+ updatedRealAmount = balanceItem.afterAmount;
1425
+ state.showCreditLineAfterAmount = true;
1426
+ }
1427
+ else {
1428
+ updatedRealAmount = state.lastOrdinaryAfterAmount;
1429
+ state.showCreditLineAfterAmount = false;
1430
+ }
1431
+ break;
1432
+ default:
1433
+ updatedRealAmount = balanceItem.afterAmount;
1434
+ }
1435
+ return updatedRealAmount === null ? currentRealAmount : updatedRealAmount;
1436
+ };
1437
+ this.updateTotalAmount = () => {
1438
+ switch (this.totalCalculationMode) {
1439
+ case 'totalCashAmount':
1440
+ let totalCashAmount = 0;
1441
+ for (const balanceType of ['Real', 'Bonus']) {
1442
+ for (const balance of this.balances[balanceType]) {
1443
+ totalCashAmount += Math.max(balance.amount, 0);
1444
+ }
1445
+ }
1446
+ this.balances['Total'][0].amount = totalCashAmount;
1447
+ break;
1448
+ case 'totalRealAmount':
1449
+ if (!this.isSplitWallet) {
1450
+ return;
1451
+ }
1452
+ let totalRealAmount = 0;
1453
+ for (const balance of this.balances['Real']) {
1454
+ totalRealAmount += balance.amount;
1455
+ }
1456
+ this.balances['Total'][0].amount = totalRealAmount;
1457
+ break;
1458
+ }
1459
+ };
1460
+ this.updateBalances = (e) => {
1461
+ const parsedData = this.parseData(e.data);
1462
+ if (!parsedData) {
1463
+ this.subscribeToBalanceUpdates();
1464
+ return;
1465
+ }
1466
+ if (parsedData.type !== 'BALANCE_UPDATE_V2') {
1467
+ return;
1468
+ }
1469
+ const balanceChange = parsedData.body.balanceChange;
1470
+ for (const [balanceType, balanceItem] of Object.entries(balanceChange)) {
1471
+ // Compute totalRealAmount for single wallet
1472
+ if (this.totalCalculationMode === 'totalRealAmount' && balanceType === 'Real' && !this.isSplitWallet) {
1473
+ this.balances["Total"][0].amount = this.updateRealAmount(this.balances["Total"][0].amount, this.updateRealAmountState, balanceItem);
1474
+ }
1475
+ if (!this.balances[balanceType]) {
1476
+ continue;
1477
+ }
1478
+ // Assign new balance values
1479
+ for (const balance of this.balances[balanceType]) {
1480
+ if (!this.isSplitWallet) {
1481
+ balance.amount = balanceType === 'Real'
1482
+ ? this.updateRealAmount(balance.amount, this.updateRealAmountState, balanceItem)
1483
+ : balanceItem.afterAmount;
1484
+ continue;
1485
+ }
1486
+ if (balanceItem.productType === balance.productType) {
1487
+ balance.amount = balanceType === 'Real'
1488
+ ? this.updateRealAmount(balance.amount, this.updateRealAmountState[balance.productType], balanceItem)
1489
+ : balanceItem.afterAmount;
1490
+ }
1491
+ }
1492
+ }
1493
+ this.updateTotalAmount();
1494
+ this.balances = Object.assign({}, this.balances);
1495
+ };
1496
+ this.balanceModalOpenDeposit = () => {
1497
+ this.toggleModal('close');
1498
+ window.postMessage({ type: 'GoToDeposit' }, window.location.href);
1499
+ // @ts-ignore Analytics event
1500
+ if (typeof gtag == 'function') {
1501
+ // @ts-ignore
1502
+ gtag('event', 'GoToDeposit', {
1503
+ 'context': 'PlayerAccountBalanceModal'
1504
+ });
1505
+ }
1506
+ };
1507
+ this.validateTotalCalculationMode = () => {
1508
+ if (!this.totalCalculationModes.includes(this.totalCalculationMode)) {
1509
+ console.error(`Unsupported value ('${this.totalCalculationMode}') for totalcalculationmode parameter. Only the following values are supported ${this.totalCalculationModes}. Using default value ('${this.totalCalculationModes[0]}').`);
1510
+ this.totalCalculationMode = this.totalCalculationModes[0];
1511
+ }
1512
+ };
1513
+ this.messageHandler = (e) => e.data && e.data.type === 'LogoutSuccessfull' && this.currentStream.close();
1514
+ this.updateBalanceStyling = () => {
1515
+ window.postMessage({ type: 'UpdateBalanceBackground' }, window.location.href);
1516
+ };
1517
+ this.toggleModal = (action) => {
1518
+ switch (action) {
1519
+ case 'open':
1520
+ window.postMessage({ type: 'BalanceModalStatus', status: 'open' }, window.location.href);
1521
+ this.isModalDisplayed = true;
1522
+ break;
1523
+ case 'close':
1524
+ window.postMessage({ type: 'BalanceModalStatus', status: 'close' }, window.location.href);
1525
+ this.isModalDisplayed = false;
1526
+ break;
1527
+ }
1528
+ };
1529
+ this.userId = undefined;
1530
+ this.session = undefined;
1531
+ this.endpoint = undefined;
1532
+ this.customLocaleIdentifier = undefined;
1533
+ this.displayBalanceOption = undefined;
1534
+ this.totalCalculationMode = undefined;
1535
+ this.currencySeparator = undefined;
1536
+ this.currencyDecimal = undefined;
1537
+ this.currencyPrecision = undefined;
1538
+ this.mbSource = undefined;
1539
+ this.clientStyling = undefined;
1540
+ this.clientStylingUrl = undefined;
1541
+ this.translationUrl = undefined;
1542
+ this.language = 'en';
1543
+ this.isLoading = true;
1544
+ this.isModalDisplayed = false;
1545
+ this.isSplitWallet = false;
1546
+ this.currentStream = undefined;
1547
+ this.currency = undefined;
1548
+ this.updateRealAmountState = undefined;
1549
+ this.balances = { Total: [], Real: [], Bonus: [], Credit: [] };
1550
+ }
1551
+ handleClientStylingChange(newValue, oldValue) {
1552
+ if (newValue != oldValue) {
1553
+ setClientStyling(this.stylingContainer, this.clientStyling);
1554
+ }
1555
+ }
1556
+ handleClientStylingUrlChange(newValue, oldValue) {
1557
+ if (newValue != oldValue) {
1558
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
1559
+ }
1560
+ }
1561
+ handleMbSourceChange(newValue, oldValue) {
1562
+ if (newValue != oldValue) {
1563
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
1564
+ }
1565
+ }
1566
+ componentWillLoad() {
1567
+ this.validateTotalCalculationMode();
1568
+ this.getBalances()
1569
+ .then(balanceData => this.setBalances(balanceData));
1570
+ this.subscribeToBalanceUpdates();
1571
+ }
1572
+ componentDidLoad() {
1573
+ if (this.stylingContainer) {
1574
+ if (this.mbSource)
1575
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
1576
+ if (this.clientStyling)
1577
+ setClientStyling(this.stylingContainer, this.clientStyling);
1578
+ if (this.clientStylingUrl)
1579
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
1580
+ }
1581
+ }
1582
+ disconnectedCallback() {
1583
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
1584
+ }
1585
+ setBalances(balanceData) {
1586
+ if (!balanceData[this.totalCalculationMode]) {
1587
+ this.totalCalculationMode = this.totalCalculationModes[0];
1588
+ }
1589
+ this.balances.Total.push({ amount: 0, productType: '' });
1590
+ // we consider the first real ordinary balance to be a source of truth
1591
+ const firstRealOrdinaryBalance = balanceData.items.find(item => item['type'] === 'Real' && item['walletAccountType'] === 'Ordinary');
1592
+ this.currency = firstRealOrdinaryBalance['currency'];
1593
+ this.isSplitWallet = Boolean(firstRealOrdinaryBalance['productType']);
1594
+ if (this.isSplitWallet) {
1595
+ this.setBalancesWhenSplitWallet(balanceData);
1596
+ }
1597
+ else {
1598
+ this.setBalancesWhenSingleWallet(balanceData);
1599
+ }
1600
+ }
1601
+ setBalancesWhenSingleWallet(balanceData) {
1602
+ this.updateRealAmountState = { lastOrdinaryAfterAmount: 0, showCreditLineAfterAmount: false };
1603
+ this.balances['Total'][0].amount = balanceData[this.totalCalculationMode][this.currency];
1604
+ for (const balance of balanceData.items) {
1605
+ switch (balance.type) {
1606
+ case 'Bonus':
1607
+ if (this.balances['Bonus'].length === 0) {
1608
+ this.balances['Bonus'].push({ amount: balance.amount, productType: '' });
1609
+ }
1610
+ else {
1611
+ this.balances['Bonus'][0].amount += balance.amount;
1612
+ }
1613
+ break;
1614
+ case 'Real':
1615
+ if (balance.creditLine && this.balances['Credit'].length === 0) {
1616
+ this.balances['Credit'].push({ amount: balance.creditLine, productType: '' });
1617
+ }
1618
+ /*
1619
+ In the case of "totalRealAmount", Real and Total will always have the same value,
1620
+ therefore we only show the Total balance ( required for Fitzdares )
1621
+ **/
1622
+ if (this.totalCalculationMode === 'totalRealAmount') {
1623
+ continue;
1624
+ }
1625
+ if (this.balances['Real'].length === 0) {
1626
+ this.balances['Real'].push({ amount: balance.amount, productType: '' });
1627
+ }
1628
+ else {
1629
+ this.balances['Real'][0].amount += balance.amount;
1630
+ }
1631
+ break;
1632
+ }
1633
+ }
1634
+ for (const [balanceType, balance] of Object.entries(this.balances)) {
1635
+ if (balance.length < 1) {
1636
+ delete this.balances[balanceType];
1637
+ }
1638
+ }
1639
+ }
1640
+ setBalancesWhenSplitWallet(balanceData) {
1641
+ this.updateRealAmountState = {
1642
+ 'Casino': { lastOrdinaryAfterAmount: 0, showCreditLineAfterAmount: false },
1643
+ 'Sports': { lastOrdinaryAfterAmount: 0, showCreditLineAfterAmount: false }
1644
+ };
1645
+ let balanceItems = balanceData.items;
1646
+ if (this.displayBalanceOption && this.displayBalanceOption !== 'All') {
1647
+ balanceItems = balanceData.items.filter((elem) => elem.productType === this.displayBalanceOption);
1648
+ }
1649
+ for (const balance of balanceItems) {
1650
+ let idx;
1651
+ switch (balance.type) {
1652
+ case 'Bonus':
1653
+ idx = this.balances['Bonus'].findIndex(b => b.productType === balance.productType);
1654
+ if (idx > 0) {
1655
+ this.balances['Bonus'][idx].amount += balance.amount;
1656
+ }
1657
+ else {
1658
+ this.balances['Bonus'].push({ amount: balance.amount, productType: balance.productType });
1659
+ }
1660
+ break;
1661
+ case 'Real':
1662
+ if (balance.creditLine) {
1663
+ this.balances['Credit'].push({ amount: balance.creditLine, productType: balance.productType });
1664
+ }
1665
+ idx = this.balances['Real'].findIndex(b => b.productType === balance.productType);
1666
+ if (idx > 0) {
1667
+ this.balances['Real'][idx].amount += balance.amount;
1668
+ }
1669
+ else {
1670
+ this.balances['Real'].push({ amount: balance.amount, productType: balance.productType });
1671
+ }
1672
+ break;
1673
+ }
1674
+ }
1675
+ this.updateTotalAmount();
1676
+ for (const [balanceType, balance] of Object.entries(this.balances)) {
1677
+ if (balance.length < 1) {
1678
+ delete this.balances[balanceType];
1679
+ }
1680
+ }
1681
+ }
1682
+ render() {
1683
+ const balanceButton = (h("button", { class: "BalanceValue", onClick: () => this.toggleModal('open') }, h("p", null, this.balances['Total'].length > 0 ? this.formatBalance(this.balances['Total'][0].amount) : '0', " ", this.currency), h("span", { class: " {isModalDisplayed ? 'TriangleActive' : 'TriangleInactive'}" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" }, h("path", { id: "arrow", d: "M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z", transform: "translate(-274.511 -441.088)", fill: "#d1d1d1" })))));
1684
+ const balanceModal = (h("div", { class: this.isModalDisplayed ? 'BalanceModalWrapper Open' : 'BalanceModalWrapper' }, h("button", { class: "BalanceModalClose", onClick: () => this.toggleModal('close') }), h("div", { class: "BalanceModal" }, h("div", { class: "ModalContent" }, h("div", { class: "BalanceModalHeader" }, h("p", { class: "BalanceModalTitle" }, translate('Title', this.language))), h("div", { class: "BalanceModalBody" }, Object.keys(this.balances).map((key) => {
1685
+ return (h("div", { class: "BalanceModalRowBoth" }, this.balances[key].map((balance) => {
1686
+ return (h("div", { class: "BalanceModalRowLine" }, h("p", { class: "BalanceModalText" }, translate(key, this.language), " ", balance.productType ? translate(balance.productType, this.language) : ''), h("p", { class: "BalanceModalValue" }, h("span", { class: "BalanceModalAmount" }, balance.amount ? this.formatBalance(balance.amount) : '0'), h("span", { class: "BalanceModalCurrency" }, " " + this.currency))));
1687
+ })));
1688
+ })), h("div", { class: "BalanceModalFooter" }, h("button", { class: "BalanceModalAction", onClick: () => this.balanceModalOpenDeposit() }, translate('DepositButton', this.language)))))));
1689
+ const skeleton = (h("div", { class: "LoadingSkeleton" }, h("ui-skeleton", { structure: "title", height: "20px", width: "auto" })));
1690
+ return (h("div", { ref: (el) => (this.stylingContainer = el) }, h("div", { class: "PamAccountBalanceModal" }, this.isLoading
1691
+ ? skeleton
1692
+ : h("div", null, balanceButton, balanceModal)), this.isModalDisplayed && (h("button", { class: "PamAccountBalanceModalOverlay", onClick: () => this.toggleModal('close') }))));
1693
+ }
1694
+ static get watchers() { return {
1695
+ "clientStyling": ["handleClientStylingChange"],
1696
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
1697
+ "mbSource": ["handleMbSourceChange"]
1698
+ }; }
1699
+ };
1700
+ PamAccountBalanceModal.style = PamAccountBalanceModalStyle0;
1701
+
1702
+ export { PamAccountBalanceModal as P };