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