@everymatrix/casino-game-thumb-view 1.31.2 → 1.32.4

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 (131) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +3 -2
  3. package/dist/assets/baccarat.svg +0 -43
  4. package/dist/assets/fav.svg +0 -9
  5. package/dist/assets/favorite.svg +0 -12
  6. package/dist/assets/seat.svg +0 -6
  7. package/dist/assets/unfav.svg +0 -20
  8. package/dist/casino-game-thumb-view/casino-game-thumb-view.esm.js +0 -1
  9. package/dist/casino-game-thumb-view/index.esm.js +0 -0
  10. package/dist/casino-game-thumb-view/p-1bbf4b70.entry.js +0 -1
  11. package/dist/casino-game-thumb-view/p-1e63a1ab.js +0 -1
  12. package/dist/casino-game-thumb-view/p-2d5f59fe.js +0 -1
  13. package/dist/casino-game-thumb-view/p-42bf2034.entry.js +0 -1
  14. package/dist/casino-game-thumb-view/p-46dbb1cb.js +0 -1
  15. package/dist/casino-game-thumb-view/p-6a6b2a78.js +0 -8
  16. package/dist/casino-game-thumb-view/p-7ae107ed.entry.js +0 -1
  17. package/dist/casino-game-thumb-view/p-9cbfffbc.entry.js +0 -1
  18. package/dist/casino-game-thumb-view/p-d961aec4.entry.js +0 -1
  19. package/dist/casino-game-thumb-view/p-db43bb56.entry.js +0 -7
  20. package/dist/cjs/casino-extrainfo-baccarat.cjs.entry.js +0 -366
  21. package/dist/cjs/casino-extrainfo-blackjack.cjs.entry.js +0 -58
  22. package/dist/cjs/casino-extrainfo-roulette.cjs.entry.js +0 -45
  23. package/dist/cjs/casino-game-thumb-view.cjs.js +0 -19
  24. package/dist/cjs/casino-game-thumb-view_2.cjs.entry.js +0 -1612
  25. package/dist/cjs/casino-game-thumbnail-betlimit_2.cjs.entry.js +0 -278
  26. package/dist/cjs/casino-normal-game-thumbnail.cjs.entry.js +0 -23
  27. package/dist/cjs/game-thumbnail-31d518f0.js +0 -78
  28. package/dist/cjs/index-65a1d768.js +0 -1796
  29. package/dist/cjs/index.cjs.js +0 -2
  30. package/dist/cjs/loader.cjs.js +0 -21
  31. package/dist/cjs/locale.utils-aa160787.js +0 -132
  32. package/dist/cjs/utils-a0afc0a9.js +0 -5745
  33. package/dist/collection/collection-manifest.json +0 -19
  34. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.css +0 -116
  35. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.js +0 -240
  36. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.css +0 -64
  37. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.js +0 -119
  38. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.css +0 -40
  39. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.js +0 -123
  40. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.css +0 -361
  41. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.js +0 -1064
  42. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.css +0 -3
  43. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.js +0 -86
  44. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.css +0 -154
  45. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.js +0 -158
  46. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.css +0 -58
  47. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.js +0 -209
  48. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.css +0 -3
  49. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.js +0 -62
  50. package/dist/collection/constants/game-thumbnail.js +0 -85
  51. package/dist/collection/index.js +0 -1
  52. package/dist/collection/models/casino-game-thumb-view.js +0 -12
  53. package/dist/collection/models/currency-symbols.js +0 -173
  54. package/dist/collection/static/baccarat.svg +0 -43
  55. package/dist/collection/static/fav.svg +0 -9
  56. package/dist/collection/static/favorite.svg +0 -12
  57. package/dist/collection/static/seat.svg +0 -6
  58. package/dist/collection/static/unfav.svg +0 -20
  59. package/dist/collection/utils/baccarat-board-svg.js +0 -234
  60. package/dist/collection/utils/locale.utils.js +0 -128
  61. package/dist/collection/utils/utils.js +0 -65
  62. package/dist/components/casino-extrainfo-baccarat.d.ts +0 -11
  63. package/dist/components/casino-extrainfo-baccarat.js +0 -400
  64. package/dist/components/casino-extrainfo-blackjack.d.ts +0 -11
  65. package/dist/components/casino-extrainfo-blackjack.js +0 -92
  66. package/dist/components/casino-extrainfo-roulette.d.ts +0 -11
  67. package/dist/components/casino-extrainfo-roulette.js +0 -78
  68. package/dist/components/casino-game-thumb-view.d.ts +0 -11
  69. package/dist/components/casino-game-thumb-view.js +0 -1625
  70. package/dist/components/casino-game-thumbnail-betlimit.d.ts +0 -11
  71. package/dist/components/casino-game-thumbnail-betlimit.js +0 -6
  72. package/dist/components/casino-game-thumbnail-betlimit2.js +0 -227
  73. package/dist/components/casino-game-thumbnail-extrainfo.d.ts +0 -11
  74. package/dist/components/casino-game-thumbnail-extrainfo.js +0 -6
  75. package/dist/components/casino-game-thumbnail-extrainfo2.js +0 -96
  76. package/dist/components/casino-game-thumbnail-overlay.d.ts +0 -11
  77. package/dist/components/casino-game-thumbnail-overlay.js +0 -6
  78. package/dist/components/casino-game-thumbnail-overlay2.js +0 -69
  79. package/dist/components/casino-normal-game-thumbnail.d.ts +0 -11
  80. package/dist/components/casino-normal-game-thumbnail.js +0 -52
  81. package/dist/components/game-thumbnail.js +0 -72
  82. package/dist/components/index.d.ts +0 -26
  83. package/dist/components/index.js +0 -1
  84. package/dist/components/locale.utils.js +0 -130
  85. package/dist/components/utils.js +0 -5739
  86. package/dist/esm/casino-extrainfo-baccarat.entry.js +0 -362
  87. package/dist/esm/casino-extrainfo-blackjack.entry.js +0 -54
  88. package/dist/esm/casino-extrainfo-roulette.entry.js +0 -41
  89. package/dist/esm/casino-game-thumb-view.js +0 -17
  90. package/dist/esm/casino-game-thumb-view_2.entry.js +0 -1607
  91. package/dist/esm/casino-game-thumbnail-betlimit_2.entry.js +0 -273
  92. package/dist/esm/casino-normal-game-thumbnail.entry.js +0 -19
  93. package/dist/esm/game-thumbnail-0a56ee03.js +0 -72
  94. package/dist/esm/index-1e44dd9f.js +0 -1769
  95. package/dist/esm/index.js +0 -1
  96. package/dist/esm/loader.js +0 -17
  97. package/dist/esm/locale.utils-e0cf897e.js +0 -130
  98. package/dist/esm/polyfills/core-js.js +0 -11
  99. package/dist/esm/polyfills/css-shim.js +0 -1
  100. package/dist/esm/polyfills/dom.js +0 -79
  101. package/dist/esm/polyfills/es5-html-element.js +0 -1
  102. package/dist/esm/polyfills/index.js +0 -34
  103. package/dist/esm/polyfills/system.js +0 -6
  104. package/dist/esm/utils-e9314132.js +0 -5739
  105. package/dist/index.cjs.js +0 -1
  106. package/dist/index.js +0 -1
  107. package/dist/stencil.config.js +0 -40
  108. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/casino-game-thumb-view/.stencil/packages/casino-game-thumb-view/stencil.config.d.ts +0 -2
  109. package/dist/types/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.d.ts +0 -40
  110. package/dist/types/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.d.ts +0 -36
  111. package/dist/types/components/casino-extrainfo-roulette/casino-extrainfo-roulette.d.ts +0 -21
  112. package/dist/types/components/casino-game-thumb-view/casino-game-thumb-view.d.ts +0 -221
  113. package/dist/types/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.d.ts +0 -17
  114. package/dist/types/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.d.ts +0 -16
  115. package/dist/types/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.d.ts +0 -31
  116. package/dist/types/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.d.ts +0 -7
  117. package/dist/types/components.d.ts +0 -480
  118. package/dist/types/constants/game-thumbnail.d.ts +0 -83
  119. package/dist/types/index.d.ts +0 -1
  120. package/dist/types/models/casino-game-thumb-view.d.ts +0 -132
  121. package/dist/types/models/currency-symbols.d.ts +0 -172
  122. package/dist/types/stencil-public-runtime.d.ts +0 -1565
  123. package/dist/types/utils/baccarat-board-svg.d.ts +0 -31
  124. package/dist/types/utils/locale.utils.d.ts +0 -1
  125. package/dist/types/utils/utils.d.ts +0 -19
  126. package/loader/cdn.js +0 -3
  127. package/loader/index.cjs.js +0 -3
  128. package/loader/index.d.ts +0 -12
  129. package/loader/index.es2017.js +0 -3
  130. package/loader/index.js +0 -4
  131. package/loader/package.json +0 -10
@@ -1,1625 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { c as convertGicBaccaratUpdateItem, i as isMobile } from './utils.js';
3
- import { G as GAME_CATEGORY, c as GAME_TYPE, a as WIDGETTYPE_GAMECATEGORY } from './game-thumbnail.js';
4
- import { d as defineCustomElement$2 } from './casino-game-thumbnail-overlay2.js';
5
-
6
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7
-
8
- function createCommonjsModule(fn, basedir, module) {
9
- return module = {
10
- path: basedir,
11
- exports: {},
12
- require: function (path, base) {
13
- return commonjsRequire();
14
- }
15
- }, fn(module, module.exports), module.exports;
16
- }
17
-
18
- function commonjsRequire () {
19
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
20
- }
21
-
22
- var eventsource = createCommonjsModule(function (module, exports) {
23
- /** @license
24
- * eventsource.js
25
- * Available under MIT License (MIT)
26
- * https://github.com/Yaffle/EventSource/
27
- */
28
-
29
- /*jslint indent: 2, vars: true, plusplus: true */
30
- /*global setTimeout, clearTimeout */
31
-
32
- (function (global) {
33
-
34
- var setTimeout = global.setTimeout;
35
- var clearTimeout = global.clearTimeout;
36
- var XMLHttpRequest = global.XMLHttpRequest;
37
- var XDomainRequest = global.XDomainRequest;
38
- var ActiveXObject = global.ActiveXObject;
39
- var NativeEventSource = global.EventSource;
40
-
41
- var document = global.document;
42
- var Promise = global.Promise;
43
- var fetch = global.fetch;
44
- var Response = global.Response;
45
- var TextDecoder = global.TextDecoder;
46
- var TextEncoder = global.TextEncoder;
47
- var AbortController = global.AbortController;
48
-
49
- if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
50
- document.readyState = "loading";
51
- window.addEventListener("load", function (event) {
52
- document.readyState = "complete";
53
- }, false);
54
- }
55
-
56
- if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
57
- XMLHttpRequest = function () {
58
- return new ActiveXObject("Microsoft.XMLHTTP");
59
- };
60
- }
61
-
62
- if (Object.create == undefined) {
63
- Object.create = function (C) {
64
- function F(){}
65
- F.prototype = C;
66
- return new F();
67
- };
68
- }
69
-
70
- if (!Date.now) {
71
- Date.now = function now() {
72
- return new Date().getTime();
73
- };
74
- }
75
-
76
- // see #118 (Promise#finally with polyfilled Promise)
77
- // see #123 (data URLs crash Edge)
78
- // see #125 (CSP violations)
79
- // see pull/#138
80
- // => No way to polyfill Promise#finally
81
-
82
- if (AbortController == undefined) {
83
- var originalFetch2 = fetch;
84
- fetch = function (url, options) {
85
- var signal = options.signal;
86
- return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
87
- var reader = response.body.getReader();
88
- signal._reader = reader;
89
- if (signal._aborted) {
90
- signal._reader.cancel();
91
- }
92
- return {
93
- status: response.status,
94
- statusText: response.statusText,
95
- headers: response.headers,
96
- body: {
97
- getReader: function () {
98
- return reader;
99
- }
100
- }
101
- };
102
- });
103
- };
104
- AbortController = function () {
105
- this.signal = {
106
- _reader: null,
107
- _aborted: false
108
- };
109
- this.abort = function () {
110
- if (this.signal._reader != null) {
111
- this.signal._reader.cancel();
112
- }
113
- this.signal._aborted = true;
114
- };
115
- };
116
- }
117
-
118
- function TextDecoderPolyfill() {
119
- this.bitsNeeded = 0;
120
- this.codePoint = 0;
121
- }
122
-
123
- TextDecoderPolyfill.prototype.decode = function (octets) {
124
- function valid(codePoint, shift, octetsCount) {
125
- if (octetsCount === 1) {
126
- return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
127
- }
128
- if (octetsCount === 2) {
129
- return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
130
- }
131
- if (octetsCount === 3) {
132
- return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
133
- }
134
- throw new Error();
135
- }
136
- function octetsCount(bitsNeeded, codePoint) {
137
- if (bitsNeeded === 6 * 1) {
138
- return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
139
- }
140
- if (bitsNeeded === 6 * 2) {
141
- return codePoint > 15 ? 3 : 2;
142
- }
143
- if (bitsNeeded === 6 * 3) {
144
- return 3;
145
- }
146
- throw new Error();
147
- }
148
- var REPLACER = 0xFFFD;
149
- var string = "";
150
- var bitsNeeded = this.bitsNeeded;
151
- var codePoint = this.codePoint;
152
- for (var i = 0; i < octets.length; i += 1) {
153
- var octet = octets[i];
154
- if (bitsNeeded !== 0) {
155
- if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
156
- bitsNeeded = 0;
157
- codePoint = REPLACER;
158
- string += String.fromCharCode(codePoint);
159
- }
160
- }
161
- if (bitsNeeded === 0) {
162
- if (octet >= 0 && octet <= 127) {
163
- bitsNeeded = 0;
164
- codePoint = octet;
165
- } else if (octet >= 192 && octet <= 223) {
166
- bitsNeeded = 6 * 1;
167
- codePoint = octet & 31;
168
- } else if (octet >= 224 && octet <= 239) {
169
- bitsNeeded = 6 * 2;
170
- codePoint = octet & 15;
171
- } else if (octet >= 240 && octet <= 247) {
172
- bitsNeeded = 6 * 3;
173
- codePoint = octet & 7;
174
- } else {
175
- bitsNeeded = 0;
176
- codePoint = REPLACER;
177
- }
178
- if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
179
- bitsNeeded = 0;
180
- codePoint = REPLACER;
181
- }
182
- } else {
183
- bitsNeeded -= 6;
184
- codePoint = codePoint << 6 | octet & 63;
185
- }
186
- if (bitsNeeded === 0) {
187
- if (codePoint <= 0xFFFF) {
188
- string += String.fromCharCode(codePoint);
189
- } else {
190
- string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
191
- string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
192
- }
193
- }
194
- }
195
- this.bitsNeeded = bitsNeeded;
196
- this.codePoint = codePoint;
197
- return string;
198
- };
199
-
200
- // Firefox < 38 throws an error with stream option
201
- var supportsStreamOption = function () {
202
- try {
203
- return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
204
- } catch (error) {
205
- console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
206
- }
207
- return false;
208
- };
209
-
210
- // IE, Edge
211
- if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
212
- TextDecoder = TextDecoderPolyfill;
213
- }
214
-
215
- var k = function () {
216
- };
217
-
218
- function XHRWrapper(xhr) {
219
- this.withCredentials = false;
220
- this.readyState = 0;
221
- this.status = 0;
222
- this.statusText = "";
223
- this.responseText = "";
224
- this.onprogress = k;
225
- this.onload = k;
226
- this.onerror = k;
227
- this.onreadystatechange = k;
228
- this._contentType = "";
229
- this._xhr = xhr;
230
- this._sendTimeout = 0;
231
- this._abort = k;
232
- }
233
-
234
- XHRWrapper.prototype.open = function (method, url) {
235
- this._abort(true);
236
-
237
- var that = this;
238
- var xhr = this._xhr;
239
- var state = 1;
240
- var timeout = 0;
241
-
242
- this._abort = function (silent) {
243
- if (that._sendTimeout !== 0) {
244
- clearTimeout(that._sendTimeout);
245
- that._sendTimeout = 0;
246
- }
247
- if (state === 1 || state === 2 || state === 3) {
248
- state = 4;
249
- xhr.onload = k;
250
- xhr.onerror = k;
251
- xhr.onabort = k;
252
- xhr.onprogress = k;
253
- xhr.onreadystatechange = k;
254
- // IE 8 - 9: XDomainRequest#abort() does not fire any event
255
- // Opera < 10: XMLHttpRequest#abort() does not fire any event
256
- xhr.abort();
257
- if (timeout !== 0) {
258
- clearTimeout(timeout);
259
- timeout = 0;
260
- }
261
- if (!silent) {
262
- that.readyState = 4;
263
- that.onabort(null);
264
- that.onreadystatechange();
265
- }
266
- }
267
- state = 0;
268
- };
269
-
270
- var onStart = function () {
271
- if (state === 1) {
272
- //state = 2;
273
- var status = 0;
274
- var statusText = "";
275
- var contentType = undefined;
276
- if (!("contentType" in xhr)) {
277
- try {
278
- status = xhr.status;
279
- statusText = xhr.statusText;
280
- contentType = xhr.getResponseHeader("Content-Type");
281
- } catch (error) {
282
- // IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
283
- // Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
284
- // https://bugs.webkit.org/show_bug.cgi?id=29121
285
- status = 0;
286
- statusText = "";
287
- contentType = undefined;
288
- // Firefox < 14, Chrome ?, Safari ?
289
- // https://bugs.webkit.org/show_bug.cgi?id=29658
290
- // https://bugs.webkit.org/show_bug.cgi?id=77854
291
- }
292
- } else {
293
- status = 200;
294
- statusText = "OK";
295
- contentType = xhr.contentType;
296
- }
297
- if (status !== 0) {
298
- state = 2;
299
- that.readyState = 2;
300
- that.status = status;
301
- that.statusText = statusText;
302
- that._contentType = contentType;
303
- that.onreadystatechange();
304
- }
305
- }
306
- };
307
- var onProgress = function () {
308
- onStart();
309
- if (state === 2 || state === 3) {
310
- state = 3;
311
- var responseText = "";
312
- try {
313
- responseText = xhr.responseText;
314
- } catch (error) {
315
- // IE 8 - 9 with XMLHttpRequest
316
- }
317
- that.readyState = 3;
318
- that.responseText = responseText;
319
- that.onprogress();
320
- }
321
- };
322
- var onFinish = function (type, event) {
323
- if (event == null || event.preventDefault == null) {
324
- event = {
325
- preventDefault: k
326
- };
327
- }
328
- // Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
329
- // IE 8 fires "onload" without "onprogress"
330
- onProgress();
331
- if (state === 1 || state === 2 || state === 3) {
332
- state = 4;
333
- if (timeout !== 0) {
334
- clearTimeout(timeout);
335
- timeout = 0;
336
- }
337
- that.readyState = 4;
338
- if (type === "load") {
339
- that.onload(event);
340
- } else if (type === "error") {
341
- that.onerror(event);
342
- } else if (type === "abort") {
343
- that.onabort(event);
344
- } else {
345
- throw new TypeError();
346
- }
347
- that.onreadystatechange();
348
- }
349
- };
350
- var onReadyStateChange = function (event) {
351
- if (xhr != undefined) { // Opera 12
352
- if (xhr.readyState === 4) {
353
- if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
354
- onFinish(xhr.responseText === "" ? "error" : "load", event);
355
- }
356
- } else if (xhr.readyState === 3) {
357
- if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
358
- // and in Firefox 3.6
359
- onProgress();
360
- }
361
- } else if (xhr.readyState === 2) {
362
- onStart();
363
- }
364
- }
365
- };
366
- var onTimeout = function () {
367
- timeout = setTimeout(function () {
368
- onTimeout();
369
- }, 500);
370
- if (xhr.readyState === 3) {
371
- onProgress();
372
- }
373
- };
374
-
375
- // XDomainRequest#abort removes onprogress, onerror, onload
376
- if ("onload" in xhr) {
377
- xhr.onload = function (event) {
378
- onFinish("load", event);
379
- };
380
- }
381
- if ("onerror" in xhr) {
382
- xhr.onerror = function (event) {
383
- onFinish("error", event);
384
- };
385
- }
386
- // improper fix to match Firefox behaviour, but it is better than just ignore abort
387
- // see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
388
- // https://bugzilla.mozilla.org/show_bug.cgi?id=880200
389
- // https://code.google.com/p/chromium/issues/detail?id=153570
390
- // IE 8 fires "onload" without "onprogress
391
- if ("onabort" in xhr) {
392
- xhr.onabort = function (event) {
393
- onFinish("abort", event);
394
- };
395
- }
396
-
397
- if ("onprogress" in xhr) {
398
- xhr.onprogress = onProgress;
399
- }
400
-
401
- // IE 8 - 9 (XMLHTTPRequest)
402
- // Opera < 12
403
- // Firefox < 3.5
404
- // Firefox 3.5 - 3.6 - ? < 9.0
405
- // onprogress is not fired sometimes or delayed
406
- // see also #64 (significant lag in IE 11)
407
- if ("onreadystatechange" in xhr) {
408
- xhr.onreadystatechange = function (event) {
409
- onReadyStateChange(event);
410
- };
411
- }
412
-
413
- if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
414
- url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
415
- }
416
- xhr.open(method, url, true);
417
-
418
- if ("readyState" in xhr) {
419
- // workaround for Opera 12 issue with "progress" events
420
- // #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
421
- timeout = setTimeout(function () {
422
- onTimeout();
423
- }, 0);
424
- }
425
- };
426
- XHRWrapper.prototype.abort = function () {
427
- this._abort(false);
428
- };
429
- XHRWrapper.prototype.getResponseHeader = function (name) {
430
- return this._contentType;
431
- };
432
- XHRWrapper.prototype.setRequestHeader = function (name, value) {
433
- var xhr = this._xhr;
434
- if ("setRequestHeader" in xhr) {
435
- xhr.setRequestHeader(name, value);
436
- }
437
- };
438
- XHRWrapper.prototype.getAllResponseHeaders = function () {
439
- // XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
440
- return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
441
- };
442
- XHRWrapper.prototype.send = function () {
443
- // loading indicator in Safari < ? (6), Chrome < 14, Firefox
444
- // https://bugzilla.mozilla.org/show_bug.cgi?id=736723
445
- if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
446
- document != undefined &&
447
- document.readyState != undefined &&
448
- document.readyState !== "complete") {
449
- var that = this;
450
- that._sendTimeout = setTimeout(function () {
451
- that._sendTimeout = 0;
452
- that.send();
453
- }, 4);
454
- return;
455
- }
456
-
457
- var xhr = this._xhr;
458
- // withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
459
- if ("withCredentials" in xhr) {
460
- xhr.withCredentials = this.withCredentials;
461
- }
462
- try {
463
- // xhr.send(); throws "Not enough arguments" in Firefox 3.0
464
- xhr.send(undefined);
465
- } catch (error1) {
466
- // Safari 5.1.7, Opera 12
467
- throw error1;
468
- }
469
- };
470
-
471
- function toLowerCase(name) {
472
- return name.replace(/[A-Z]/g, function (c) {
473
- return String.fromCharCode(c.charCodeAt(0) + 0x20);
474
- });
475
- }
476
-
477
- function HeadersPolyfill(all) {
478
- // Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
479
- var map = Object.create(null);
480
- var array = all.split("\r\n");
481
- for (var i = 0; i < array.length; i += 1) {
482
- var line = array[i];
483
- var parts = line.split(": ");
484
- var name = parts.shift();
485
- var value = parts.join(": ");
486
- map[toLowerCase(name)] = value;
487
- }
488
- this._map = map;
489
- }
490
- HeadersPolyfill.prototype.get = function (name) {
491
- return this._map[toLowerCase(name)];
492
- };
493
-
494
- if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
495
- XMLHttpRequest.HEADERS_RECEIVED = 2;
496
- }
497
-
498
- function XHRTransport() {
499
- }
500
-
501
- XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
502
- xhr.open("GET", url);
503
- var offset = 0;
504
- xhr.onprogress = function () {
505
- var responseText = xhr.responseText;
506
- var chunk = responseText.slice(offset);
507
- offset += chunk.length;
508
- onProgressCallback(chunk);
509
- };
510
- xhr.onerror = function (event) {
511
- event.preventDefault();
512
- onFinishCallback(new Error("NetworkError"));
513
- };
514
- xhr.onload = function () {
515
- onFinishCallback(null);
516
- };
517
- xhr.onabort = function () {
518
- onFinishCallback(null);
519
- };
520
- xhr.onreadystatechange = function () {
521
- if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
522
- var status = xhr.status;
523
- var statusText = xhr.statusText;
524
- var contentType = xhr.getResponseHeader("Content-Type");
525
- var headers = xhr.getAllResponseHeaders();
526
- onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
527
- }
528
- };
529
- xhr.withCredentials = withCredentials;
530
- for (var name in headers) {
531
- if (Object.prototype.hasOwnProperty.call(headers, name)) {
532
- xhr.setRequestHeader(name, headers[name]);
533
- }
534
- }
535
- xhr.send();
536
- return xhr;
537
- };
538
-
539
- function HeadersWrapper(headers) {
540
- this._headers = headers;
541
- }
542
- HeadersWrapper.prototype.get = function (name) {
543
- return this._headers.get(name);
544
- };
545
-
546
- function FetchTransport() {
547
- }
548
-
549
- FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
550
- var reader = null;
551
- var controller = new AbortController();
552
- var signal = controller.signal;
553
- var textDecoder = new TextDecoder();
554
- fetch(url, {
555
- headers: headers,
556
- credentials: withCredentials ? "include" : "same-origin",
557
- signal: signal,
558
- cache: "no-store"
559
- }).then(function (response) {
560
- reader = response.body.getReader();
561
- onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
562
- // see https://github.com/promises-aplus/promises-spec/issues/179
563
- return new Promise(function (resolve, reject) {
564
- var readNextChunk = function () {
565
- reader.read().then(function (result) {
566
- if (result.done) {
567
- //Note: bytes in textDecoder are ignored
568
- resolve(undefined);
569
- } else {
570
- var chunk = textDecoder.decode(result.value, {stream: true});
571
- onProgressCallback(chunk);
572
- readNextChunk();
573
- }
574
- })["catch"](function (error) {
575
- reject(error);
576
- });
577
- };
578
- readNextChunk();
579
- });
580
- })["catch"](function (error) {
581
- if (error.name === "AbortError") {
582
- return undefined;
583
- } else {
584
- return error;
585
- }
586
- }).then(function (error) {
587
- onFinishCallback(error);
588
- });
589
- return {
590
- abort: function () {
591
- if (reader != null) {
592
- reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
593
- }
594
- controller.abort();
595
- }
596
- };
597
- };
598
-
599
- function EventTarget() {
600
- this._listeners = Object.create(null);
601
- }
602
-
603
- function throwError(e) {
604
- setTimeout(function () {
605
- throw e;
606
- }, 0);
607
- }
608
-
609
- EventTarget.prototype.dispatchEvent = function (event) {
610
- event.target = this;
611
- var typeListeners = this._listeners[event.type];
612
- if (typeListeners != undefined) {
613
- var length = typeListeners.length;
614
- for (var i = 0; i < length; i += 1) {
615
- var listener = typeListeners[i];
616
- try {
617
- if (typeof listener.handleEvent === "function") {
618
- listener.handleEvent(event);
619
- } else {
620
- listener.call(this, event);
621
- }
622
- } catch (e) {
623
- throwError(e);
624
- }
625
- }
626
- }
627
- };
628
- EventTarget.prototype.addEventListener = function (type, listener) {
629
- type = String(type);
630
- var listeners = this._listeners;
631
- var typeListeners = listeners[type];
632
- if (typeListeners == undefined) {
633
- typeListeners = [];
634
- listeners[type] = typeListeners;
635
- }
636
- var found = false;
637
- for (var i = 0; i < typeListeners.length; i += 1) {
638
- if (typeListeners[i] === listener) {
639
- found = true;
640
- }
641
- }
642
- if (!found) {
643
- typeListeners.push(listener);
644
- }
645
- };
646
- EventTarget.prototype.removeEventListener = function (type, listener) {
647
- type = String(type);
648
- var listeners = this._listeners;
649
- var typeListeners = listeners[type];
650
- if (typeListeners != undefined) {
651
- var filtered = [];
652
- for (var i = 0; i < typeListeners.length; i += 1) {
653
- if (typeListeners[i] !== listener) {
654
- filtered.push(typeListeners[i]);
655
- }
656
- }
657
- if (filtered.length === 0) {
658
- delete listeners[type];
659
- } else {
660
- listeners[type] = filtered;
661
- }
662
- }
663
- };
664
-
665
- function Event(type) {
666
- this.type = type;
667
- this.target = undefined;
668
- }
669
-
670
- function MessageEvent(type, options) {
671
- Event.call(this, type);
672
- this.data = options.data;
673
- this.lastEventId = options.lastEventId;
674
- }
675
-
676
- MessageEvent.prototype = Object.create(Event.prototype);
677
-
678
- function ConnectionEvent(type, options) {
679
- Event.call(this, type);
680
- this.status = options.status;
681
- this.statusText = options.statusText;
682
- this.headers = options.headers;
683
- }
684
-
685
- ConnectionEvent.prototype = Object.create(Event.prototype);
686
-
687
- function ErrorEvent(type, options) {
688
- Event.call(this, type);
689
- this.error = options.error;
690
- }
691
-
692
- ErrorEvent.prototype = Object.create(Event.prototype);
693
-
694
- var WAITING = -1;
695
- var CONNECTING = 0;
696
- var OPEN = 1;
697
- var CLOSED = 2;
698
-
699
- var AFTER_CR = -1;
700
- var FIELD_START = 0;
701
- var FIELD = 1;
702
- var VALUE_START = 2;
703
- var VALUE = 3;
704
-
705
- var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
706
-
707
- var MINIMUM_DURATION = 1000;
708
- var MAXIMUM_DURATION = 18000000;
709
-
710
- var parseDuration = function (value, def) {
711
- var n = value == null ? def : parseInt(value, 10);
712
- if (n !== n) {
713
- n = def;
714
- }
715
- return clampDuration(n);
716
- };
717
- var clampDuration = function (n) {
718
- return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
719
- };
720
-
721
- var fire = function (that, f, event) {
722
- try {
723
- if (typeof f === "function") {
724
- f.call(that, event);
725
- }
726
- } catch (e) {
727
- throwError(e);
728
- }
729
- };
730
-
731
- function EventSourcePolyfill(url, options) {
732
- EventTarget.call(this);
733
- options = options || {};
734
-
735
- this.onopen = undefined;
736
- this.onmessage = undefined;
737
- this.onerror = undefined;
738
-
739
- this.url = undefined;
740
- this.readyState = undefined;
741
- this.withCredentials = undefined;
742
- this.headers = undefined;
743
-
744
- this._close = undefined;
745
-
746
- start(this, url, options);
747
- }
748
-
749
- function getBestXHRTransport() {
750
- return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
751
- ? new XMLHttpRequest()
752
- : new XDomainRequest();
753
- }
754
-
755
- var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
756
-
757
- function start(es, url, options) {
758
- url = String(url);
759
- var withCredentials = Boolean(options.withCredentials);
760
- var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
761
-
762
- var initialRetry = clampDuration(1000);
763
- var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
764
-
765
- var lastEventId = "";
766
- var retry = initialRetry;
767
- var wasActivity = false;
768
- var textLength = 0;
769
- var headers = options.headers || {};
770
- var TransportOption = options.Transport;
771
- var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
772
- var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
773
- var abortController = undefined;
774
- var timeout = 0;
775
- var currentState = WAITING;
776
- var dataBuffer = "";
777
- var lastEventIdBuffer = "";
778
- var eventTypeBuffer = "";
779
-
780
- var textBuffer = "";
781
- var state = FIELD_START;
782
- var fieldStart = 0;
783
- var valueStart = 0;
784
-
785
- var onStart = function (status, statusText, contentType, headers) {
786
- if (currentState === CONNECTING) {
787
- if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
788
- currentState = OPEN;
789
- wasActivity = Date.now();
790
- retry = initialRetry;
791
- es.readyState = OPEN;
792
- var event = new ConnectionEvent("open", {
793
- status: status,
794
- statusText: statusText,
795
- headers: headers
796
- });
797
- es.dispatchEvent(event);
798
- fire(es, es.onopen, event);
799
- } else {
800
- var message = "";
801
- if (status !== 200) {
802
- if (statusText) {
803
- statusText = statusText.replace(/\s+/g, " ");
804
- }
805
- message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
806
- } else {
807
- message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
808
- }
809
- close();
810
- var event = new ConnectionEvent("error", {
811
- status: status,
812
- statusText: statusText,
813
- headers: headers
814
- });
815
- es.dispatchEvent(event);
816
- fire(es, es.onerror, event);
817
- console.error(message);
818
- }
819
- }
820
- };
821
-
822
- var onProgress = function (textChunk) {
823
- if (currentState === OPEN) {
824
- var n = -1;
825
- for (var i = 0; i < textChunk.length; i += 1) {
826
- var c = textChunk.charCodeAt(i);
827
- if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
828
- n = i;
829
- }
830
- }
831
- var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
832
- textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
833
- if (textChunk !== "") {
834
- wasActivity = Date.now();
835
- textLength += textChunk.length;
836
- }
837
- for (var position = 0; position < chunk.length; position += 1) {
838
- var c = chunk.charCodeAt(position);
839
- if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
840
- state = FIELD_START;
841
- } else {
842
- if (state === AFTER_CR) {
843
- state = FIELD_START;
844
- }
845
- if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
846
- if (state !== FIELD_START) {
847
- if (state === FIELD) {
848
- valueStart = position + 1;
849
- }
850
- var field = chunk.slice(fieldStart, valueStart - 1);
851
- var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
852
- if (field === "data") {
853
- dataBuffer += "\n";
854
- dataBuffer += value;
855
- } else if (field === "id") {
856
- lastEventIdBuffer = value;
857
- } else if (field === "event") {
858
- eventTypeBuffer = value;
859
- } else if (field === "retry") {
860
- initialRetry = parseDuration(value, initialRetry);
861
- retry = initialRetry;
862
- } else if (field === "heartbeatTimeout") {
863
- heartbeatTimeout = parseDuration(value, heartbeatTimeout);
864
- if (timeout !== 0) {
865
- clearTimeout(timeout);
866
- timeout = setTimeout(function () {
867
- onTimeout();
868
- }, heartbeatTimeout);
869
- }
870
- }
871
- }
872
- if (state === FIELD_START) {
873
- if (dataBuffer !== "") {
874
- lastEventId = lastEventIdBuffer;
875
- if (eventTypeBuffer === "") {
876
- eventTypeBuffer = "message";
877
- }
878
- var event = new MessageEvent(eventTypeBuffer, {
879
- data: dataBuffer.slice(1),
880
- lastEventId: lastEventIdBuffer
881
- });
882
- es.dispatchEvent(event);
883
- if (eventTypeBuffer === "open") {
884
- fire(es, es.onopen, event);
885
- } else if (eventTypeBuffer === "message") {
886
- fire(es, es.onmessage, event);
887
- } else if (eventTypeBuffer === "error") {
888
- fire(es, es.onerror, event);
889
- }
890
- if (currentState === CLOSED) {
891
- return;
892
- }
893
- }
894
- dataBuffer = "";
895
- eventTypeBuffer = "";
896
- }
897
- state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
898
- } else {
899
- if (state === FIELD_START) {
900
- fieldStart = position;
901
- state = FIELD;
902
- }
903
- if (state === FIELD) {
904
- if (c === ":".charCodeAt(0)) {
905
- valueStart = position + 1;
906
- state = VALUE_START;
907
- }
908
- } else if (state === VALUE_START) {
909
- state = VALUE;
910
- }
911
- }
912
- }
913
- }
914
- }
915
- };
916
-
917
- var onFinish = function (error) {
918
- if (currentState === OPEN || currentState === CONNECTING) {
919
- currentState = WAITING;
920
- if (timeout !== 0) {
921
- clearTimeout(timeout);
922
- timeout = 0;
923
- }
924
- timeout = setTimeout(function () {
925
- onTimeout();
926
- }, retry);
927
- retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
928
-
929
- es.readyState = CONNECTING;
930
- var event = new ErrorEvent("error", {error: error});
931
- es.dispatchEvent(event);
932
- fire(es, es.onerror, event);
933
- if (error != undefined) {
934
- console.error(error);
935
- }
936
- }
937
- };
938
-
939
- var close = function () {
940
- currentState = CLOSED;
941
- if (abortController != undefined) {
942
- abortController.abort();
943
- abortController = undefined;
944
- }
945
- if (timeout !== 0) {
946
- clearTimeout(timeout);
947
- timeout = 0;
948
- }
949
- es.readyState = CLOSED;
950
- };
951
-
952
- var onTimeout = function () {
953
- timeout = 0;
954
-
955
- if (currentState !== WAITING) {
956
- if (!wasActivity && abortController != undefined) {
957
- onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
958
- if (abortController != undefined) {
959
- abortController.abort();
960
- abortController = undefined;
961
- }
962
- } else {
963
- var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
964
- wasActivity = false;
965
- timeout = setTimeout(function () {
966
- onTimeout();
967
- }, nextHeartbeat);
968
- }
969
- return;
970
- }
971
-
972
- wasActivity = false;
973
- textLength = 0;
974
- timeout = setTimeout(function () {
975
- onTimeout();
976
- }, heartbeatTimeout);
977
-
978
- currentState = CONNECTING;
979
- dataBuffer = "";
980
- eventTypeBuffer = "";
981
- lastEventIdBuffer = lastEventId;
982
- textBuffer = "";
983
- fieldStart = 0;
984
- valueStart = 0;
985
- state = FIELD_START;
986
-
987
- // https://bugzilla.mozilla.org/show_bug.cgi?id=428916
988
- // Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
989
- var requestURL = url;
990
- if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
991
- if (lastEventId !== "") {
992
- // Remove the lastEventId parameter if it's already part of the request URL.
993
- var i = url.indexOf("?");
994
- requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
995
- return paramName === lastEventIdQueryParameterName ? '' : p;
996
- });
997
- // Append the current lastEventId to the request URL.
998
- requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
999
- }
1000
- }
1001
- var withCredentials = es.withCredentials;
1002
- var requestHeaders = {};
1003
- requestHeaders["Accept"] = "text/event-stream";
1004
- var headers = es.headers;
1005
- if (headers != undefined) {
1006
- for (var name in headers) {
1007
- if (Object.prototype.hasOwnProperty.call(headers, name)) {
1008
- requestHeaders[name] = headers[name];
1009
- }
1010
- }
1011
- }
1012
- try {
1013
- abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
1014
- } catch (error) {
1015
- close();
1016
- throw error;
1017
- }
1018
- };
1019
-
1020
- es.url = url;
1021
- es.readyState = CONNECTING;
1022
- es.withCredentials = withCredentials;
1023
- es.headers = headers;
1024
- es._close = close;
1025
-
1026
- onTimeout();
1027
- }
1028
-
1029
- EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
1030
- EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
1031
- EventSourcePolyfill.prototype.OPEN = OPEN;
1032
- EventSourcePolyfill.prototype.CLOSED = CLOSED;
1033
- EventSourcePolyfill.prototype.close = function () {
1034
- this._close();
1035
- };
1036
-
1037
- EventSourcePolyfill.CONNECTING = CONNECTING;
1038
- EventSourcePolyfill.OPEN = OPEN;
1039
- EventSourcePolyfill.CLOSED = CLOSED;
1040
- EventSourcePolyfill.prototype.withCredentials = undefined;
1041
-
1042
- var R = NativeEventSource;
1043
- if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
1044
- // Why replace a native EventSource ?
1045
- // https://bugzilla.mozilla.org/show_bug.cgi?id=444328
1046
- // https://bugzilla.mozilla.org/show_bug.cgi?id=831392
1047
- // https://code.google.com/p/chromium/issues/detail?id=260144
1048
- // https://code.google.com/p/chromium/issues/detail?id=225654
1049
- // ...
1050
- R = EventSourcePolyfill;
1051
- }
1052
-
1053
- (function (factory) {
1054
- {
1055
- var v = factory(exports);
1056
- if (v !== undefined) module.exports = v;
1057
- }
1058
- })(function (exports) {
1059
- exports.EventSourcePolyfill = EventSourcePolyfill;
1060
- exports.NativeEventSource = NativeEventSource;
1061
- exports.EventSource = R;
1062
- });
1063
- }(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal) : globalThis));
1064
- });
1065
-
1066
- const Fav = `<svg
1067
- version="1.1"
1068
- xmlns="http://www.w3.org/2000/svg"
1069
- viewBox="0 0 19.481 19.481"
1070
- enable-background="new 0 0 19.481 19.481"
1071
- >
1072
- <path
1073
- d="m10.201,.758l2.478,5.865 6.344,.545c0.44,0.038 0.619,0.587 0.285,0.876l-4.812,4.169 1.442,6.202c0.1,0.431-0.367,0.77-0.745,0.541l-5.452-3.288-5.452,3.288c-0.379,0.228-0.845-0.111-0.745-0.541l1.442-6.202-4.813-4.17c-0.334-0.289-0.156-0.838 0.285-0.876l6.344-.545 2.478-5.864c0.172-0.408 0.749-0.408 0.921,0z"/>
1074
- </svg>
1075
- `;
1076
-
1077
- const UnFavSvg = `<svg
1078
- version="1.1"
1079
- class="UnfavoredIcon"
1080
- xmlns="http://www.w3.org/2000/svg"
1081
- x="20px"
1082
- y="20px"
1083
- viewBox="0 0 512.001 512.001"
1084
- >
1085
- <path
1086
- d="M511.266,197.256c-1.764-5.431-6.458-9.388-12.108-10.209l-158.722-23.065L269.452,20.155
1087
- c-2.527-5.12-7.741-8.361-13.451-8.361c-5.709,0-10.924,3.242-13.451,8.361l-70.988,143.828L12.843,187.047
1088
- c-5.65,0.821-10.344,4.779-12.108,10.209c-1.765,5.43-0.293,11.391,3.795,15.376l114.848,111.955L92.27,482.67
1089
- c-0.965,5.627,1.349,11.315,5.968,14.67c4.618,3.355,10.74,3.798,15.797,1.142L256,423.846l141.961,74.637
1090
- c2.195,1.154,4.591,1.723,6.979,1.723c3.11,0,6.206-0.966,8.818-2.865c4.619-3.356,6.933-9.043,5.968-14.671L392.61,324.587
1091
- l114.86-111.954C511.559,208.647,513.031,202.686,511.266,197.256z M366.023,308.608c-3.536,3.446-5.15,8.412-4.314,13.278
1092
- l23.311,135.898l-122.038-64.162c-4.37-2.297-9.591-2.297-13.961,0l-122.045,64.163l23.304-135.9
1093
- c0.834-4.866-0.779-9.83-4.313-13.276l-98.731-96.244l136.445-19.829c4.886-0.71,9.108-3.778,11.294-8.205L256,60.685
1094
- l61.023,123.645c2.186,4.427,6.408,7.496,11.294,8.206l136.447,19.828L366.023,308.608z"
1095
- />
1096
- </svg>
1097
- `;
1098
-
1099
- const casinoGameThumbViewCss = ":host{display:block}*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}.GameContainer{width:100%;height:100%;position:relative}.GameInnerContainer{position:relative;width:100%;height:100%;overflow:hidden;border-radius:5px}.GameInnerContainer .GameBg{width:100%;height:100%;object-fit:unset;transition:all 150ms ease-in-out}.GameInnerContainer .GameBg.GameBg-1x2,.GameInnerContainer .GameBg.GameBg-2x1,.GameInnerContainer .GameBg.GameBg-2x2{object-fit:cover}.GameInnerContainer:hover{cursor:pointer}.GameInnerContainer:hover .GameInfoWrapper{display:block}.GameInnerContainer:hover .GameBg{filter:blur(5px) grayscale(1)}.ListGame.GameBackdrop .GameInnerContainer::after{content:\"\";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(0deg, black 15%, rgba(0, 0, 0, 0) 100%)}.ListGame .GameInnerContainer{z-index:0}.ListGame .GameInnerContainer .GameBg{z-index:5}.ListGame .GameInnerContainer::after{content:\"\";position:absolute;top:0;right:0;bottom:0;left:0}.ListGame .GameInnerContainer.GameInnerContainerUnavailable::after{content:\"\";position:absolute;top:0;right:0;bottom:0;left:0;background:rgba(0, 0, 0, 0.9)}.ListGame .GameInnerContainer .ListGame:hover .OpenSeat,.ListGame .GameInnerContainer .ListGame:hover .ClosedSeat,.ListGame .GameInnerContainer .ListGame:hover .LiveLimits,.ListGame .GameInnerContainer .ListGame:hover .LatestResult,.ListGame .GameInnerContainer .ListGame:hover .FullTable,.ListGame .GameInnerContainer .ListGame:active .OpenSeat,.ListGame .GameInnerContainer .ListGame:active .ClosedSeat,.ListGame .GameInnerContainer .ListGame:active .LiveLimits,.ListGame .GameInnerContainer .ListGame:active .LatestResult,.ListGame .GameInnerContainer .ListGame:active .FullTable{opacity:0.2}.ListGame .GameInnerContainer .ListGame.GameContainerDimmed:before{display:block;content:\" \";width:100%;height:100%;position:absolute;top:0;right:0;bottom:0;left:0;z-index:5;background:rgba(0, 0, 0, 0.4);color:var(--emfe-w-color-white, #FFFFFF);fill:var(--emfe-w-color-white, #FFFFFF);opacity:1;border-radius:4px}.ListGame .GameInnerContainer .ListGame.GameContainerFullyDimmed:before{display:block;content:\" \";width:100%;height:100%;position:absolute;top:0;right:0;bottom:0;left:0;z-index:5;background:rgba(0, 0, 0, 0.8);color:var(--emfe-w-color-white, #FFFFFF);fill:var(--emfe-w-color-white, #FFFFFF);opacity:1;border-radius:4px}.ListGame .GameInnerContainer .ListGame:hover .LiveProps,.ListGame .GameInnerContainer .ListGameLink:hover .LiveProps{opacity:0}@keyframes red-pulse{0%{box-shadow:0 0 2px 0 rgba(255, 0, 0, 0.75)}15%{box-shadow:0 0 10px 2px rgba(255, 0, 0, 0.75)}30%{box-shadow:0 0 2px 0 rgba(255, 0, 0, 0.75)}50%{box-shadow:0 0 10px 2px rgba(255, 0, 0, 0.75)}65%{box-shadow:0 0 2px 0 rgba(255, 0, 0, 0.75)}80%{box-shadow:0 0 10px 2px rgba(255, 0, 0, 0.75)}100%{box-shadow:0 0 0 0 rgba(255, 0, 0, 0.75)}}@keyframes green-pulse{0%{box-shadow:0 0 2px 0 rgba(86, 168, 10, 0.75)}15%{box-shadow:0 0 10px 2px rgba(86, 168, 10, 0.75)}30%{box-shadow:0 0 2px 0 rgba(86, 168, 10, 0.75)}50%{box-shadow:0 0 10px 2px rgba(86, 168, 10, 0.75)}65%{box-shadow:0 0 2px 0 rgba(86, 168, 10, 0.75)}80%{box-shadow:0 0 10px 2px rgba(86, 168, 10, 0.75)}100%{box-shadow:0 0 0 0 rgba(86, 168, 10, 0.75)}}@keyframes flip-open{0%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 90deg);transform:perspective(400px) rotate3d(0, 1, 0, 90deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in;opacity:0}40%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -20deg);transform:perspective(400px) rotate3d(0, 1, 0, -20deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in}60%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 10deg);transform:perspective(400px) rotate3d(0, 1, 0, 10deg);opacity:1}80%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -5deg);transform:perspective(400px) rotate3d(0, 1, 0, -5deg)}100%{-webkit-transform:perspective(400px);transform:perspective(400px)}}.ListGame .GameInnerContainer .silde-in-from-left{-webkit-animation-name:silde-in-from-left;animation-name:silde-in-from-left;-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-fill-mode:both;animation-fill-mode:both}@-webkit-keyframes silde-in-from-left{0%{-webkit-transform:translateX(-100%);transform:translateX(-100%);visibility:visible}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes silde-in-from-left{0%{-webkit-transform:translateX(-100%);transform:translateX(-100%);visibility:visible}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes flip-closed-seat{0%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 90deg);transform:perspective(400px) rotate3d(0, 1, 0, 90deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in;opacity:0}40%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -20deg);transform:perspective(400px) rotate3d(0, 1, 0, -20deg);-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in}60%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, 10deg);transform:perspective(400px) rotate3d(0, 1, 0, 10deg);opacity:1}80%{-webkit-transform:perspective(400px) rotate3d(0, 1, 0, -5deg);transform:perspective(400px) rotate3d(0, 1, 0, -5deg)}100%{-webkit-transform:perspective(400px);transform:perspective(400px)}}.ListGame .GameInnerContainer .ListGame.PulsatingGreenShadow{animation:green-pulse 2s linear}.ListGame .GameInnerContainer .ListGame.PulsatingRedShadow{animation:red-pulse 2s linear}.ListGame .GameInnerContainer .Blue{color:#4d90a7}.ListGame .GameInnerContainer .Red{background-color:red}.ListGame .GameInnerContainer .Black{background-color:var(--emfe-w-color-black, #000000)}.ListGame .GameInnerContainer .Green{background-color:#56A80A}.ListGame .GameInnerContainer .White{background-color:var(--emfe-w-color-white, #FFFFFF)}.ListGame .GameInnerContainer .Yellow{background-color:#eeca3d}.ListGame .GameInnerContainer .Gold{background-color:#866d0c}.ListGame .GameInnerContainer .Orange{background-color:#574708}.ListGame .GameInnerContainer .Purple{background-color:#330033}.ListGame .GameInnerContainer .Tie{background-color:var(--emfe-w-color-white, #FFFFFF);background-image:linear-gradient(135deg, var(--emfe-w-color-white, #FFFFFF) 25%, transparent 25%, transparent 50%, #212121 50%, var(--emfe-w-color-white, #FFFFFF) 75%, transparent 75%, var(--emfe-w-color-white, #FFFFFF))}.ListGame .GameInnerContainer .PlayersDisplay{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;padding:2px 10px;background:linear-gradient(to bottom, rgba(33, 33, 33, 0.9) 0%, rgba(33, 33, 33, 0.1) 100%);color:var(--emfe-w-color-white, #FFFFFF)}.ListGame .GameInnerContainer .PlayersDisplay .PlayersIcon{width:14px;height:14px;margin-right:4px}.ListGame .GameInnerContainer .PlayersDisplay .PlayersIcon svg{fill:var(--emfe-w-color-white, #FFFFFF);width:100%;height:100%}.ListGame .GameInnerContainer .ClosedGame{opacity:1;z-index:10;padding:8px 10px;color:var(--emfe-w-color-white, #FFFFFF);font-size:18px}.ListGame .GameInnerContainer .ClosedGame span{font-size:18px}.ListGame .GameInnerContainer .Players{display:inline-block;width:19px;height:19px}.FavIconContainer{position:absolute;top:10px;right:10px;cursor:pointer;z-index:16;width:15px;height:15px;opacity:0}.FavIconContainer.Favorited{opacity:1}.FavIconContainer svg path{fill:#fff}.Hovered .FavIconContainer{opacity:1}.GameNameBelow{color:var(--emfe-w-color-white, #FFFFFF);position:relative;bottom:-5px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";
1100
-
1101
- const CasinoGameThumbView$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
1102
- constructor() {
1103
- super();
1104
- this.__registerHost();
1105
- this.__attachShadow();
1106
- this.toggleFavoriteCasinoGameEvent = createEvent(this, "toggleCasinoGameFavorite", 7);
1107
- /**
1108
- * Widget Setting, Game language
1109
- */
1110
- this.language = 'en';
1111
- /**
1112
- * Widget Setting, Client custom styling via string
1113
- */
1114
- this.clientStyling = '';
1115
- /**
1116
- * Widget Setting, Client custom styling via url content
1117
- */
1118
- this.clientStylingUrl = '';
1119
- /**
1120
- * Widget Setting, show game in a frame when user clicked 'start'
1121
- */
1122
- this.integratedGameframeMobile = false;
1123
- /**
1124
- * Widget Setting, show game in a frame when user clicked 'start', Open game aframe,
1125
- * gamepageModalurl value should be set
1126
- */
1127
- this.integratedGameframeDesktop = false;
1128
- /**
1129
- * Widget Setting, Load game details when set it as true, default value: false
1130
- * When loadDetails is true and type=='live-casino-tables',
1131
- * Load gameDetails by endpoint/vendor/gameId if livelobbyEndpoint is null
1132
- */
1133
- this.loadDetails = false;
1134
- /**
1135
- * Widget Setting, showRoundBoard, default value: false
1136
- */
1137
- this.showRoundBoard = false;
1138
- /**
1139
- * Game Property, default ''
1140
- */
1141
- this.gameCategory = '';
1142
- /**
1143
- * Game Property, Game lunch platform
1144
- */
1145
- this.platform = 'PC';
1146
- this.thumbnailLoaded = false;
1147
- this.containerClassWhenDetailChange = '';
1148
- this.isUserLoggedIn = false;
1149
- this.limitStylingAppends = false;
1150
- //customize style setting
1151
- this.setClientStyling = () => {
1152
- let sheet = document.createElement('style');
1153
- sheet.innerHTML = this.clientStyling;
1154
- this.stylingContainer.prepend(sheet);
1155
- };
1156
- //customize style setting
1157
- this.setClientStylingURL = () => {
1158
- let url = new URL(this.clientStylingUrl);
1159
- let cssFile = document.createElement('style');
1160
- fetch(url.href)
1161
- .then((res) => res.text())
1162
- .then((data) => {
1163
- cssFile.innerHTML = data;
1164
- setTimeout(() => {
1165
- this.stylingContainer.prepend(cssFile);
1166
- }, 1);
1167
- })
1168
- .catch((err) => {
1169
- console.error('error ', err);
1170
- });
1171
- };
1172
- this.getGameCategoryType = () => {
1173
- if (this.isLiveCasino &&
1174
- this.gameCategory &&
1175
- this.getWidgetTypeByGameCategory(this.gameCategory)) {
1176
- return `casino-extrainfo-${this.getWidgetTypeByGameCategory(this.gameCategory).toLowerCase()}`;
1177
- }
1178
- return `casino-normal-game-thumbnail`;
1179
- };
1180
- this.getGameContainerClass = () => {
1181
- let gameContainerClass = `GameContainer `;
1182
- if (this.gameInfo) {
1183
- if (this.gameInfo && this.gameInfo.details) {
1184
- gameContainerClass += ' ListGame ';
1185
- if (this.gameInfo.details.isOpen &&
1186
- this.gameInfo.details.currentRouletteNumbers) {
1187
- gameContainerClass += ' GameBackdrop ';
1188
- }
1189
- }
1190
- }
1191
- return gameContainerClass;
1192
- };
1193
- }
1194
- onSessionChanged() {
1195
- this.isUserLoggedIn = !!(this.session && this.userId);
1196
- }
1197
- onTableFullChanged(newVal, oldVal) {
1198
- if (oldVal == undefined) {
1199
- return;
1200
- }
1201
- this.containerClassWhenDetailChange =
1202
- newVal && !oldVal ? 'PulsatingRedShadow' : 'PulsatingGreenShadow';
1203
- }
1204
- handleMouseOver(event) {
1205
- this.hover = event.type === 'mouseenter';
1206
- }
1207
- gameFavoritedHandler(event) {
1208
- let eventDetail = event.detail;
1209
- this.gameInfo.isFavorite = eventDetail[this.gameId];
1210
- this.gameInfo = Object.assign({}, this.gameInfo);
1211
- }
1212
- connectLiveHandler() {
1213
- this.toggleConnect();
1214
- }
1215
- visibilityConnectHandler() {
1216
- this.toggleVisibilityConnect();
1217
- }
1218
- gameDetailChangeHandler(e) {
1219
- var _a, _b;
1220
- let message = JSON.parse(e.data);
1221
- if (message.needReconnect && this.liveLobbyConnection) {
1222
- this.liveLobbyConnection.close();
1223
- this.liveLobbyConnection = null;
1224
- this.connectGameToLiveLobby();
1225
- return;
1226
- }
1227
- if (!(message && message.InternalTableId == this.gameId)) {
1228
- return;
1229
- }
1230
- let MessageType = message.MessageType;
1231
- switch (MessageType) {
1232
- case 'TableOpened':
1233
- case 'TableClosed':
1234
- this.gameInfo.details.isOpen = message.Open;
1235
- break;
1236
- case 'PlayersUpdated':
1237
- this.gameInfo.details.numberOfPlayers = message.Players;
1238
- break;
1239
- case 'RouletteResultsUpdated':
1240
- this.gameInfo.details.currentRouletteNumbers = message.Results;
1241
- break;
1242
- case 'DoubleBallRouletteResultsUpdated':
1243
- this.gameInfo.details.currentDoubleBallRouletteNumbers =
1244
- message.Results;
1245
- break;
1246
- case 'SeatsUpdated':
1247
- this.gameInfo.details.currentOccupiedSeats = message.Seats;
1248
- break;
1249
- case 'DealerChanged':
1250
- this.gameInfo.details.dealer = message.Dealer;
1251
- break;
1252
- case 'BaccaratResultsUpdated':
1253
- if (this.showRoundBoard) {
1254
- const Results = message.Results;
1255
- this.gameInfo.details.results = [];
1256
- Results.forEach((item) => {
1257
- this.gameInfo.details.results.push(convertGicBaccaratUpdateItem(item));
1258
- });
1259
- (_a = this.extraInfoRef) === null || _a === void 0 ? void 0 : _a.onBaccaratResultChanged(this.gameInfo.details.results);
1260
- }
1261
- break;
1262
- }
1263
- this.resetLiveProperties();
1264
- (_b = this.extraInfoRef) === null || _b === void 0 ? void 0 : _b.onGameDetailUpdated(this.gameInfo.details);
1265
- window.postMessage({ messageType: MessageType, value: e.data });
1266
- }
1267
- messageHandler(e) {
1268
- if (e.data.type === `AddFavoriteThumbnail_${this.gameId}` &&
1269
- !this.showFavoredCategory) {
1270
- this.gameInfo.isFavorite = true;
1271
- }
1272
- if (e.data.type === `RemoveFavoriteThumbnail_${this.gameId}` &&
1273
- !this.showFavoredCategory) {
1274
- this.gameInfo.isFavorite = false;
1275
- }
1276
- if (e.data.type === 'UserSessionID') {
1277
- this.isUserLoggedIn = true;
1278
- this.session = e.data.session;
1279
- this.userId = e.data.userID;
1280
- }
1281
- }
1282
- resetLiveProperties() {
1283
- var _a, _b;
1284
- const details = this.gameInfo.details;
1285
- if (this.isBlackJack(this.gameCategory.toLowerCase())) {
1286
- this.isTableFull =
1287
- details.totalSeats == ((_a = details.currentOccupiedSeats) === null || _a === void 0 ? void 0 : _a.length);
1288
- }
1289
- else if (this.isBaccarat(this.gameCategory.toLowerCase()) &&
1290
- ((_b = details.baccaratResults) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1291
- this.gameInfo.details.results = [];
1292
- details.baccaratResults.forEach((item) => {
1293
- this.gameInfo.details.results.push(convertGicBaccaratUpdateItem(item));
1294
- });
1295
- delete details.baccaratResults;
1296
- }
1297
- }
1298
- isBlackJack(gameCategory) {
1299
- return gameCategory.toLowerCase() === GAME_CATEGORY.BLACKJACK;
1300
- }
1301
- isBaccarat(gameCategory) {
1302
- return gameCategory.toLowerCase() === GAME_CATEGORY.BACCARAT;
1303
- }
1304
- /**
1305
- * Calculate component properties by game info,
1306
- * eg: isLiveCasino, gameInfo, isTableFull
1307
- */
1308
- initCtrlProperties() {
1309
- var _a;
1310
- if (this.isLiveCasino && ((_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.details)) {
1311
- this.resetLiveProperties();
1312
- }
1313
- this.gameInfo = Object.assign({}, this.gameInfo);
1314
- this.triggerExtraInfoLoad();
1315
- if (this.isLiveCasino && this.connectLive === 'connect') {
1316
- this.connectGameToLiveLobby();
1317
- }
1318
- }
1319
- /**
1320
- * Parse game info by game info api response
1321
- * @param data
1322
- */
1323
- parseGameResponse(data) {
1324
- if (data.length == 1) {
1325
- this.gameInfo = data[0];
1326
- if (this.isLiveCasino) {
1327
- if (!this.gameInfo.details) {
1328
- this.loadGameDetailInfo();
1329
- }
1330
- else {
1331
- this.parseGameDetailsResponse();
1332
- }
1333
- }
1334
- else {
1335
- this.initCtrlProperties();
1336
- }
1337
- }
1338
- }
1339
- /**
1340
- * Parse game detail info, set it to game info
1341
- */
1342
- parseGameDetailsResponse() {
1343
- this.initCtrlProperties();
1344
- }
1345
- connectGameToLiveLobby() {
1346
- if (EventSource && !this.liveLobbyConnection) {
1347
- const updateUrl = `${this.endpoint}/v1/encoder/lobby/updates/${this.gameInfo.vendor.name}/${this.gameInfo.id}`;
1348
- this.liveLobbyConnection = new eventsource.EventSourcePolyfill(updateUrl);
1349
- this.liveLobbyConnection.addEventListener('message', (evt) => {
1350
- this.gameDetailChangeHandler(evt);
1351
- });
1352
- }
1353
- }
1354
- disconnectGameFromLiveLobby() {
1355
- if (this.liveLobbyConnection) {
1356
- this.liveLobbyConnection.removeEventListener('message');
1357
- this.liveLobbyConnection.close();
1358
- this.liveLobbyConnection = undefined;
1359
- }
1360
- }
1361
- toggleConnect() {
1362
- if (!this.isLiveCasino) {
1363
- return;
1364
- }
1365
- if (this.connectLive === 'disconnect') {
1366
- this.disconnectGameFromLiveLobby();
1367
- }
1368
- else if (this.connectLive === 'connect') {
1369
- this.connectGameToLiveLobby();
1370
- }
1371
- }
1372
- toggleVisibilityConnect() {
1373
- if (!this.isLiveCasino) {
1374
- return;
1375
- }
1376
- if (this.visibilityConnect === 'disconnect') {
1377
- this.disconnectGameFromLiveLobby();
1378
- }
1379
- else if (this.visibilityConnect === 'connect' &&
1380
- this.connectLive === 'connect') {
1381
- this.connectGameToLiveLobby();
1382
- }
1383
- }
1384
- /**
1385
- * Get game base info from game api(casino/games/{id})
1386
- * @private
1387
- */
1388
- loadGameById() {
1389
- let url = `${this.endpoint}/v1/casino/games/${this.gameId}?expand=vendor&platform=${this.platform}&language=${this.language}`;
1390
- fetch(url)
1391
- .then((res) => res.json())
1392
- .then((data) => this.parseGameResponse(data))
1393
- .catch((err) => {
1394
- console.error(err);
1395
- });
1396
- }
1397
- /*
1398
- * Load game info when widget property 'livelobbyEndpoint' set
1399
- * @private
1400
- */
1401
- loadGameInfoByLobbyEndpoint() {
1402
- let url = new URL(`${this.livelobbyEndpoint.split('?')[0]}`);
1403
- url.searchParams.append('expand', 'vendor');
1404
- url.searchParams.append('platform', this.platform);
1405
- url.searchParams.append('language', this.language);
1406
- fetch(url.toString())
1407
- .then((res) => res.json())
1408
- .then((data) => this.parseGameResponse(data))
1409
- .catch((error) => console.error(error));
1410
- }
1411
- /*
1412
- * load game info when widget property 'livelobbyEndpoint' setted
1413
- * @private
1414
- */
1415
- loadGameDetailInfo() {
1416
- let url = new URL(`${this.endpoint}/v1/lobby/tables/${this.gameId}`);
1417
- url.searchParams.append('platform', this.platform);
1418
- url.searchParams.append('language', this.language);
1419
- fetch(url.toString())
1420
- .then((res) => res.json())
1421
- .then((data) => {
1422
- if (!(data === null || data === void 0 ? void 0 : data.category)) {
1423
- return;
1424
- }
1425
- this.gameInfo.details = data;
1426
- this.parseGameDetailsResponse();
1427
- })
1428
- .catch((err) => {
1429
- console.error(err);
1430
- setTimeout(() => this.loadGameDetailInfo(), 1000);
1431
- });
1432
- }
1433
- /**
1434
- * Toggle game favorite property
1435
- * @param gameId
1436
- * @private
1437
- */
1438
- toggleFavoriteGame(gameId) {
1439
- let triggerFactor = 'thumbnail';
1440
- if (this.gameInfo.isFavorite) {
1441
- window.postMessage({ type: 'SetUnfavoredGame', gameId, triggerFactor }, window.location.href);
1442
- }
1443
- else {
1444
- window.postMessage({ type: 'SetFavoredGame', gameId, triggerFactor }, window.location.href);
1445
- }
1446
- this.toggleFavoriteCasinoGameEvent.emit(gameId);
1447
- }
1448
- /**
1449
- * Generate gameInfo obj by props
1450
- * @private
1451
- */
1452
- generateGameInfoByProps() {
1453
- return {
1454
- id: this.gameId,
1455
- name: this.gameName,
1456
- subVendor: this.subVendor,
1457
- hasFunMode: this.hasFunMode,
1458
- hasAnonymousFunMode: this.hasAnonymousFunMode,
1459
- thumbnail: this.thumbnail,
1460
- cellSize: this.cellSize,
1461
- gameTag: this.gameTag,
1462
- vendor: { href: '', name: this.gameVendor },
1463
- isFavorite: this.isFavorite,
1464
- isNew: this.isNew,
1465
- type: this.type,
1466
- liveCasinoCategory: this.gameCategory || '',
1467
- };
1468
- }
1469
- triggerExtraInfoLoad() {
1470
- var _a, _b;
1471
- //Init this.extraInfoRef, prepare for data loader, this.gameInfo did not inited might
1472
- this.extraInfoRef =
1473
- this.extraInfoRef ||
1474
- ((_a = this.extraInfoSlotRef) === null || _a === void 0 ? void 0 : _a.querySelector(this.getGameCategoryType()));
1475
- (_b = this.extraInfoRef) === null || _b === void 0 ? void 0 : _b.onGameLoaded(this.gameInfo);
1476
- window.postMessage({
1477
- type: 'casinoGameLoaded',
1478
- gameInfo: this.gameInfo,
1479
- });
1480
- }
1481
- componentDidRender() {
1482
- // start custom styling area
1483
- if (!this.limitStylingAppends && this.stylingContainer) {
1484
- if (this.clientStyling)
1485
- this.setClientStyling();
1486
- if (this.clientStylingUrl)
1487
- this.setClientStylingURL();
1488
- this.limitStylingAppends = true;
1489
- }
1490
- // end custom styling area 500)
1491
- if (this.gameInfo) {
1492
- this.triggerExtraInfoLoad();
1493
- }
1494
- }
1495
- componentDidLoad() {
1496
- window.addEventListener('message', this.messageHandler);
1497
- }
1498
- componentWillLoad() {
1499
- this.isLiveCasino = this.type == GAME_TYPE.LIVE_CASINO;
1500
- this.extraInfoWidget = this.getGameCategoryType();
1501
- this.isUserLoggedIn = !!(this.session && this.userId);
1502
- if (this.isLiveCasino && this.livelobbyEndpoint) {
1503
- this.loadGameInfoByLobbyEndpoint();
1504
- return;
1505
- }
1506
- //generate gameInfo obj by props
1507
- if (this.thumbnail) {
1508
- this.gameInfo = this.generateGameInfoByProps();
1509
- // loadLiveDetails if game is live casino
1510
- if (this.isLiveCasino &&
1511
- this.endpoint &&
1512
- this.loadDetails &&
1513
- this.gameId) {
1514
- this.loadGameDetailInfo();
1515
- }
1516
- return;
1517
- }
1518
- //fetch data from api if no game properties set except gameId
1519
- if (this.gameId && this.endpoint) {
1520
- this.loadGameById();
1521
- }
1522
- }
1523
- disconnectedCallback() {
1524
- if (this.liveLobbyConnection) {
1525
- this.liveLobbyConnection.removeEventListener('message', this.gameDetailChangeHandler);
1526
- }
1527
- window.removeEventListener('message', this.messageHandler);
1528
- }
1529
- // end custom styling area
1530
- getWidgetTypeByGameCategory(gameCategory) {
1531
- return WIDGETTYPE_GAMECATEGORY[gameCategory.toLowerCase()];
1532
- }
1533
- getGameOverlayProps() {
1534
- var _a, _b;
1535
- return {
1536
- gameName: this.gameInfo.name,
1537
- gameId: this.gameInfo.gameId,
1538
- gameVendor: this.gameVendor || ((_b = (_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.vendor) === null || _b === void 0 ? void 0 : _b.name),
1539
- hasFunMode: this.gameInfo.hasFunMode,
1540
- language: this.language,
1541
- integratedGameframeMobile: this.integratedGameframeMobile,
1542
- integratedGameframeDesktop: this.integratedGameframeDesktop,
1543
- gamepageModalurl: this.gamepageModalurl,
1544
- };
1545
- }
1546
- render() {
1547
- var _a, _b;
1548
- if (!this.gameInfo) {
1549
- return (h("div", { class: "GameInnerContainer", part: "GameInnerContainer", slot: "Game-Inner" }, h("img", { src: this.thumbnail, alt: "", loading: "lazy", part: "GameContainer", class: "GameContainer", onLoad: () => (this.thumbnailLoaded = true) })));
1550
- }
1551
- const gameOverlayProps = this.getGameOverlayProps();
1552
- const gameThumbnail = ((_a = this.gameInfo) === null || _a === void 0 ? void 0 : _a.thumbnail) || ((_b = this.gameInfo) === null || _b === void 0 ? void 0 : _b.defaultThumbnail);
1553
- const gameContainerClass = this.getGameContainerClass();
1554
- const gameThumbnailClass = `GameBg ${this.cellSize ? 'GameBg-' + this.cellSize : ''}
1555
- ${this.hover ? ' GameContainerHovered' : ''} ${this.thumbnailLoaded ? ' Loaded' : ''}`;
1556
- return (h("div", { class: `${gameContainerClass} ${this.containerClassWhenDetailChange}`, part: `${gameContainerClass} ${this.containerClassWhenDetailChange}`, ref: (el) => (this.stylingContainer = el), "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrl }, h("div", { class: `GameInnerContainer ${this.hover ? 'Hovered' : ''}`, part: `GameInnerContainer ${this.hover ? 'Hovered' : ''}` }, h("img", { src: gameThumbnail, alt: "Game Thumbnail ", loading: "lazy", part: gameThumbnailClass, class: gameThumbnailClass, onLoad: () => (this.thumbnailLoaded = true) }), this.isUserLoggedIn && (h("div", { class: `FavIconContainer ${this.gameInfo.isFavorite ? 'Favorited' : ''}`, part: `FavIconContainer ${this.gameInfo.isFavorite ? 'Favorited' : ''}`, onClick: () => this.toggleFavoriteGame(this.gameId) }, this.gameInfo.isFavorite ? (h("slot", { name: "fav-icon" }, h("span", { class: "FavoredIcon", part: "FavoredIcon", innerHTML: Fav }))) : (h("slot", { name: "UnFavIcon" }, !isMobile(window.navigator.userAgent) && (h("span", { class: "UnfavoredIcon", part: "UnfavoredIcon", innerHTML: UnFavSvg })))))), h("slot", { name: "game-overlay" }, h("casino-game-thumbnail-overlay", Object.assign({ language: this.language }, gameOverlayProps))), h("slot", { name: "extra-info", ref: (el) => (this.extraInfoSlotRef = el) }, h(this.extraInfoWidget, { language: this.language, "show-round-board": this.showRoundBoard })), h("slot", { name: "game-property-slot" })), this.showGameName && (h("slot", { name: "game-name" }, h("p", { class: "GameNameBelow", part: "GameNameBelow", title: gameOverlayProps.gameName }, gameOverlayProps.gameName)))));
1557
- }
1558
- static get assetsDirs() { return ["static"]; }
1559
- static get watchers() { return {
1560
- "session": ["onSessionChanged"],
1561
- "userId": ["onSessionChanged"],
1562
- "isTableFull": ["onTableFullChanged"],
1563
- "connectLive": ["connectLiveHandler"],
1564
- "visibilityConnect": ["visibilityConnectHandler"]
1565
- }; }
1566
- static get style() { return casinoGameThumbViewCss; }
1567
- }, [1, "casino-game-thumb-view", {
1568
- "language": [1],
1569
- "endpoint": [1],
1570
- "userId": [8, "user-id"],
1571
- "showGameName": [4, "show-game-name"],
1572
- "session": [1],
1573
- "showFavoredCategory": [4, "show-favored-category"],
1574
- "clientStyling": [1, "client-styling"],
1575
- "clientStylingUrl": [1, "client-styling-url"],
1576
- "integratedGameframeMobile": [4, "integrated-gameframe-mobile"],
1577
- "gamepageModalurl": [1, "gamepage-modalurl"],
1578
- "integratedGameframeDesktop": [4, "integrated-gameframe-desktop"],
1579
- "loadDetails": [4, "load-details"],
1580
- "showRoundBoard": [4, "show-round-board"],
1581
- "visibilityConnect": [1, "visibility-connect"],
1582
- "connectLive": [1, "connect-live"],
1583
- "gameCategory": [1, "game-category"],
1584
- "livelobbyEndpoint": [1, "livelobby-endpoint"],
1585
- "gameId": [8, "game-id"],
1586
- "gameName": [1, "game-name"],
1587
- "subVendor": [1, "sub-vendor"],
1588
- "gameVendor": [1, "game-vendor"],
1589
- "hasFunMode": [4, "has-fun-mode"],
1590
- "hasAnonymousFunMode": [4, "has-anonymous-fun-mode"],
1591
- "platform": [1],
1592
- "thumbnail": [1],
1593
- "isFavorite": [4, "is-favorite"],
1594
- "isNew": [4, "is-new"],
1595
- "cellSize": [1, "cell-size"],
1596
- "gameTag": [1, "game-tag"],
1597
- "type": [1],
1598
- "gameInfo": [32],
1599
- "isTableFull": [32],
1600
- "hover": [32]
1601
- }, [[1, "mouseenter", "handleMouseOver"], [1, "mouseleave", "handleMouseOver"], [4, "gameFavorited", "gameFavoritedHandler"], [0, "gameDetailChange", "gameDetailChangeHandler"]]]);
1602
- function defineCustomElement$1() {
1603
- if (typeof customElements === "undefined") {
1604
- return;
1605
- }
1606
- const components = ["casino-game-thumb-view", "casino-game-thumbnail-overlay"];
1607
- components.forEach(tagName => { switch (tagName) {
1608
- case "casino-game-thumb-view":
1609
- if (!customElements.get(tagName)) {
1610
- customElements.define(tagName, CasinoGameThumbView$1);
1611
- }
1612
- break;
1613
- case "casino-game-thumbnail-overlay":
1614
- if (!customElements.get(tagName)) {
1615
- defineCustomElement$2();
1616
- }
1617
- break;
1618
- } });
1619
- }
1620
- defineCustomElement$1();
1621
-
1622
- const CasinoGameThumbView = CasinoGameThumbView$1;
1623
- const defineCustomElement = defineCustomElement$1;
1624
-
1625
- export { CasinoGameThumbView, defineCustomElement };