@everymatrix/casino-engagement-suite-tournament 1.39.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 (63) hide show
  1. package/dist/casino-engagement-suite-tournament/casino-engagement-suite-tournament.esm.js +1 -0
  2. package/dist/casino-engagement-suite-tournament/index.esm.js +0 -0
  3. package/dist/casino-engagement-suite-tournament/p-75de0549.entry.js +1 -0
  4. package/dist/casino-engagement-suite-tournament/p-86ce7485.js +1 -0
  5. package/dist/cjs/casino-engagement-suite-progress-bar_3.cjs.entry.js +824 -0
  6. package/dist/cjs/casino-engagement-suite-tournament.cjs.js +19 -0
  7. package/dist/cjs/index-e778ddd2.js +1733 -0
  8. package/dist/cjs/index.cjs.js +2 -0
  9. package/dist/cjs/loader.cjs.js +21 -0
  10. package/dist/collection/collection-manifest.json +25 -0
  11. package/dist/collection/components/casino-engagement-suite-tournament/casino-engagement-suite-tournament.css +374 -0
  12. package/dist/collection/components/casino-engagement-suite-tournament/casino-engagement-suite-tournament.js +601 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/shared/GradientRoundedButton.js +12 -0
  15. package/dist/collection/shared/icons.js +8 -0
  16. package/dist/collection/shared/renderBar.js +14 -0
  17. package/dist/collection/utils/api.apdater.js +35 -0
  18. package/dist/collection/utils/translations.js +28 -0
  19. package/dist/collection/utils/types.js +18 -0
  20. package/dist/collection/utils/util.date.js +38 -0
  21. package/dist/collection/utils/utils.js +18 -0
  22. package/dist/components/casino-engagement-suite-progress-bar.js +6 -0
  23. package/dist/components/casino-engagement-suite-progress-bar2.js +94 -0
  24. package/dist/components/casino-engagement-suite-tournament.d.ts +11 -0
  25. package/dist/components/casino-engagement-suite-tournament.js +716 -0
  26. package/dist/components/general-styling-wrapper.js +6 -0
  27. package/dist/components/general-styling-wrapper2.js +103 -0
  28. package/dist/components/index.d.ts +26 -0
  29. package/dist/components/index.js +1 -0
  30. package/dist/esm/casino-engagement-suite-progress-bar_3.entry.js +818 -0
  31. package/dist/esm/casino-engagement-suite-tournament.js +17 -0
  32. package/dist/esm/index-4e611d33.js +1704 -0
  33. package/dist/esm/index.js +1 -0
  34. package/dist/esm/loader.js +17 -0
  35. package/dist/esm/polyfills/core-js.js +11 -0
  36. package/dist/esm/polyfills/css-shim.js +1 -0
  37. package/dist/esm/polyfills/dom.js +79 -0
  38. package/dist/esm/polyfills/es5-html-element.js +1 -0
  39. package/dist/esm/polyfills/index.js +34 -0
  40. package/dist/esm/polyfills/system.js +6 -0
  41. package/dist/index.cjs.js +1 -0
  42. package/dist/index.js +1 -0
  43. package/dist/stencil.config.js +22 -0
  44. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-engagement-suite-tournament/.stencil/packages/casino-engagement-suite-tournament/stencil.config.d.ts +2 -0
  45. package/dist/types/components/casino-engagement-suite-tournament/casino-engagement-suite-tournament.d.ts +130 -0
  46. package/dist/types/components.d.ts +79 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/shared/GradientRoundedButton.d.ts +5 -0
  49. package/dist/types/shared/icons.d.ts +7 -0
  50. package/dist/types/shared/renderBar.d.ts +1 -0
  51. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  52. package/dist/types/utils/api.apdater.d.ts +31 -0
  53. package/dist/types/utils/translations.d.ts +42 -0
  54. package/dist/types/utils/types.d.ts +95 -0
  55. package/dist/types/utils/util.date.d.ts +6 -0
  56. package/dist/types/utils/utils.d.ts +1 -0
  57. package/loader/cdn.js +3 -0
  58. package/loader/index.cjs.js +3 -0
  59. package/loader/index.d.ts +12 -0
  60. package/loader/index.es2017.js +3 -0
  61. package/loader/index.js +4 -0
  62. package/loader/package.json +10 -0
  63. package/package.json +26 -0
@@ -0,0 +1,824 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-e778ddd2.js');
6
+
7
+ const casinoEngagementSuiteProgressBarCss = ":host{display:block;font-family:inherit}:host(.Desktop) .ProgressBarPercent{font-size:14px;line-height:14px}.ProgressBarBackground{height:8px;background-color:var(--emw--color-background, #666178);border-radius:4px;position:relative}.ProgressBarLine{position:absolute;left:0;top:0;bottom:0;border-radius:4px;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);transition:width ease-out 0.3s}.ProgressBarInfo{margin-bottom:8px;display:flex;justify-content:space-between;align-items:center}.ProgressBarPercent{font-weight:700;font-size:12px;line-height:12px}.HidePercent .ProgressBarPercent{display:none}.ProgressBar:not(.Disabled) .ProgressBarPercent{background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ProgressBar.Disabled .ProgressBarPercent{color:var(--emw--color-background, #666178)}.ProgressBar.Disabled .ProgressBarLine{background:var(--emw--color-background-secondary, #474668)}";
8
+
9
+ const CasinoEngagementSuiteProgressBar = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ /**
13
+ * Value for the widget
14
+ */
15
+ this.value = 0;
16
+ /**
17
+ * Shows disabled styles
18
+ */
19
+ this.disabled = false;
20
+ /**
21
+ * Hide percent value
22
+ */
23
+ this.hidePercent = false;
24
+ /**
25
+ * Client custom styling via string
26
+ */
27
+ this.clientStyling = '';
28
+ /**
29
+ * Client custom styling via url
30
+ */
31
+ this.clientStylingUrl = '';
32
+ this.limitStylingAppends = false;
33
+ this.setClientStyling = () => {
34
+ let sheet = document.createElement('style');
35
+ sheet.innerHTML = this.clientStyling;
36
+ this.host.prepend(sheet);
37
+ };
38
+ this.setClientStylingURL = () => {
39
+ let url = new URL(this.clientStylingUrl);
40
+ let cssFile = document.createElement('style');
41
+ fetch(url.href)
42
+ .then((res) => res.text())
43
+ .then((data) => {
44
+ cssFile.innerHTML = data;
45
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
46
+ })
47
+ .catch((err) => {
48
+ console.log('Error ', err);
49
+ });
50
+ };
51
+ }
52
+ componentDidRender() {
53
+ if (!this.limitStylingAppends && this.host) {
54
+ if (this.clientStyling)
55
+ this.setClientStyling();
56
+ if (this.clientStylingUrl)
57
+ this.setClientStylingURL();
58
+ this.limitStylingAppends = true;
59
+ }
60
+ }
61
+ getProgressBarClasses() {
62
+ return {
63
+ ProgressBar: true,
64
+ Completed: this.value === 100,
65
+ Disabled: this.disabled,
66
+ HidePercent: this.hidePercent
67
+ };
68
+ }
69
+ render() {
70
+ return index.h("div", { class: this.getProgressBarClasses(), part: "ProgressBar" }, index.h("div", { class: "ProgressBarInfo", part: "ProgressBarInfo" }, index.h("slot", { name: "Title" }, index.h("div", null)), index.h("slot", { name: "Percent" }, index.h("div", { class: "ProgressBarPercent", part: "ProgressBarPercent" }, this.value, "%"))), index.h("div", { class: "ProgressBarBackground", part: "ProgressBarBackground" }, index.h("div", { class: "ProgressBarLine", part: "ProgressBarLine", style: { width: this.value + '%' } })));
71
+ }
72
+ get host() { return index.getElement(this); }
73
+ };
74
+ CasinoEngagementSuiteProgressBar.style = casinoEngagementSuiteProgressBarCss;
75
+
76
+ /******************************************************************************
77
+ Copyright (c) Microsoft Corporation.
78
+
79
+ Permission to use, copy, modify, and/or distribute this software for any
80
+ purpose with or without fee is hereby granted.
81
+
82
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
83
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
84
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
85
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
86
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
87
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
88
+ PERFORMANCE OF THIS SOFTWARE.
89
+ ***************************************************************************** */
90
+
91
+ function __rest(s, e) {
92
+ var t = {};
93
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
94
+ t[p] = s[p];
95
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
96
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
97
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
98
+ t[p[i]] = s[p[i]];
99
+ }
100
+ return t;
101
+ }
102
+
103
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
104
+ var e = new Error(message);
105
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
106
+ };
107
+
108
+ var Tab;
109
+ (function (Tab) {
110
+ Tab["Info"] = "Info";
111
+ Tab["Leaderboard"] = "Leaderboard";
112
+ Tab["Games"] = "Games";
113
+ })(Tab || (Tab = {}));
114
+ var Time;
115
+ (function (Time) {
116
+ Time["Starts"] = "Starts";
117
+ Time["Ends"] = "Ends";
118
+ })(Time || (Time = {}));
119
+ const localePostprocess = (translationText, props) => {
120
+ Object.keys(props).map(key => {
121
+ translationText = translationText.replace(`{${key}}`, props[key]);
122
+ });
123
+ return translationText;
124
+ };
125
+ const TRANSLATIONS = Object.assign(Object.assign(Object.assign({ Join: 'Join', Unjoin: 'Unjoin' }, Tab), Time), { TC: 'Terms & Conditions', ScoreCriteria: 'Score Criteria', MinimumBetCriteria: 'Minimum bet criteria', Place: 'place', Prizes: 'Rewards', LeaderboardDetails: 'Leaderboard Details', UnjoinDialog: {
126
+ Title: 'Quit Leaderboard?',
127
+ Description: 'Any progress on the current Leaderboard won’t be kept and you can not rejoin the Leaderboard any more. <br /><br />Would you still like to quit?',
128
+ ButtonYes: 'Yes, I want to quit leaderboard',
129
+ ButtonNo: 'No, Stay on the leaderboard',
130
+ }, JoinDialog: {
131
+ Tile: 'Congratulations!',
132
+ Description: 'You have unlocked <span>{tournamentName}</span>! <br />Would you like to join?',
133
+ ButtonYes: 'Join',
134
+ ButtonNo: 'Not interested',
135
+ }, NoLeaderboards: 'No Leaderboards yet', NoLeaderboardsTip: 'Try winning tickets to Leaderboards as rewards or launching other booster games', Leaderboards: 'Leaderboards', TipPrize: 'You took <span>{place}</span> place and win <span>{prize}</span>', Tip: 'Competition where your real money bets contribute towards the leaderboard score calculation to win the leaderboard reward.' });
136
+
137
+ const classnames = (...args) => {
138
+ let classnameArray = [];
139
+ args.map(arg => {
140
+ switch (typeof arg) {
141
+ case 'string':
142
+ classnameArray.push(arg);
143
+ break;
144
+ case 'object':
145
+ Object.keys(arg).map(k => {
146
+ if (arg[k]) {
147
+ classnameArray.push(k);
148
+ }
149
+ });
150
+ break;
151
+ }
152
+ });
153
+ return classnameArray.join(' ');
154
+ };
155
+
156
+ var LeaderboardPage;
157
+ (function (LeaderboardPage) {
158
+ LeaderboardPage["Confirm"] = "Confirm";
159
+ LeaderboardPage["List"] = "List";
160
+ LeaderboardPage["Item"] = "Item";
161
+ })(LeaderboardPage || (LeaderboardPage = {}));
162
+ var TournamentState;
163
+ (function (TournamentState) {
164
+ TournamentState["Running"] = "Running";
165
+ TournamentState["Unstarted"] = "Unstarted";
166
+ TournamentState["Closed"] = "Closed";
167
+ TournamentState["Closing"] = "Closing";
168
+ })(TournamentState || (TournamentState = {}));
169
+ var DialogType;
170
+ (function (DialogType) {
171
+ DialogType["Unjoin"] = "Unjoin";
172
+ DialogType["Tip"] = "Tip";
173
+ })(DialogType || (DialogType = {}));
174
+
175
+ const GradientRoundedButton = (_a) => {
176
+ var { statedClasses, innerHTML } = _a, props = __rest(_a, ["statedClasses", "innerHTML"]);
177
+ const { isHollow, isPending } = statedClasses;
178
+ return (index.h("button", Object.assign({}, Object.assign({ class: classnames('GradientRoundedButton', 'GradientRounded', {
179
+ Hollow: isHollow || false,
180
+ Pending: isPending || false,
181
+ }) }, props)),
182
+ index.h("span", null, innerHTML)));
183
+ };
184
+
185
+ const iconClose = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg" });
186
+ const iconQuestion = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg" });
187
+ const iconEyeOpen = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/eye-open.svg" });
188
+ const iconEyeClose = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/eye-closed.svg" });
189
+ const iconBack = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/back.svg" });
190
+ const iconReward = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/reward.svg" });
191
+ const iconTrophy = index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/cup-congras.svg" });
192
+
193
+ const CloseBar = (props) => {
194
+ const { left, middle, right } = props;
195
+ const slots = {
196
+ left,
197
+ middle,
198
+ right,
199
+ };
200
+ const getFirstLetterUppercase = (str) => str
201
+ .split('')
202
+ .map((letter, index) => index === 0 ? letter.toUpperCase() : letter)
203
+ .join('');
204
+ return (index.h("div", { class: "WrapperBar" }, Object.keys(slots).map(slotKey => (index.h("div", { class: "WrapperBar" + getFirstLetterUppercase(slotKey) }, slots[slotKey] || '')))));
205
+ };
206
+
207
+ function formatDate(date) {
208
+ const options = {
209
+ year: 'numeric',
210
+ month: 'long',
211
+ day: 'numeric',
212
+ hour: '2-digit',
213
+ minute: '2-digit',
214
+ hour12: false
215
+ };
216
+ return date.toLocaleDateString('en-US', options).replace(' at', ',');
217
+ }
218
+ function addSeconds(date, seconds) {
219
+ const result = new Date(date);
220
+ result.setSeconds(result.getSeconds() + seconds);
221
+ return result;
222
+ }
223
+ function getDifference(startDate, endDate) {
224
+ const diffMs = Math.abs(endDate.getTime() - startDate.getTime()); // Difference in milliseconds
225
+ const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); // Difference in days
226
+ const diffHours = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); // Remaining hours
227
+ const diffMinutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60)); // Remaining minutes
228
+ // Format the output
229
+ const formattedDiff = `${String(diffDays).padStart(2, '0')}d:${String(diffHours).padStart(2, '0')}h:${String(diffMinutes).padStart(2, '0')}m`;
230
+ return formattedDiff;
231
+ }
232
+ function getProgress(startDate, endDate) {
233
+ return (100 * (new Date().getTime() - startDate.getTime()) / (endDate.getTime() - startDate.getTime())).toFixed(0);
234
+ }
235
+
236
+ const tournamentAdapter = (tournamentApi) => {
237
+ const keysTime = [
238
+ 'startTime',
239
+ 'endTime',
240
+ 'closeTime',
241
+ 'exhibitionStartTime',
242
+ 'exhibitionEndTime',
243
+ ];
244
+ const tournament = {};
245
+ Object.keys(tournamentApi).map((key) => {
246
+ const value = tournamentApi[key];
247
+ switch (key) {
248
+ case 'games':
249
+ tournament[key] = value.items;
250
+ break;
251
+ default:
252
+ tournament[key] = keysTime.includes(key) ? new Date(value) : value;
253
+ }
254
+ });
255
+ return tournament;
256
+ };
257
+ const leaderboardsAdapter = (leaderboardRes) => {
258
+ let { item, items: leaderboards } = leaderboardRes;
259
+ if (!item) {
260
+ return leaderboards;
261
+ }
262
+ return leaderboards.map(leaderboard => {
263
+ if (item && item.userID === leaderboard.userID) {
264
+ return Object.assign(Object.assign({}, leaderboard), { isMe: true });
265
+ }
266
+ else {
267
+ return leaderboard;
268
+ }
269
+ });
270
+ };
271
+
272
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
273
+
274
+ function createCommonjsModule(fn, basedir, module) {
275
+ return module = {
276
+ path: basedir,
277
+ exports: {},
278
+ require: function (path, base) {
279
+ return commonjsRequire();
280
+ }
281
+ }, fn(module, module.exports), module.exports;
282
+ }
283
+
284
+ function commonjsRequire () {
285
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
286
+ }
287
+
288
+ createCommonjsModule(function (module, exports) {
289
+ !function(t,e){module.exports=e();}(commonjsGlobal,(function(){function t(){}function e(t){return t()}function n(){return Object.create(null)}function i(t){t.forEach(e);}function s(t){return "function"==typeof t}function o(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t,e,n){t.insertBefore(e,n||null);}function r(t){t.parentNode&&t.parentNode.removeChild(t);}function c(t){const e={};for(const n of t)e[n.name]=n.value;return e}let a;function d(t){a=t;}const u=[],f=[];let p=[];const h=[],$=Promise.resolve();let m=!1;function g(t){p.push(t);}
290
+ // flush() calls callbacks in this order:
291
+ // 1. All beforeUpdate callbacks, in order: parents before children
292
+ // 2. All bind:this callbacks, in reverse order: children before parents.
293
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
294
+ // for afterUpdates called during the initial onMount, which are called in
295
+ // reverse order: children before parents.
296
+ // Since callbacks might update component values, which could trigger another
297
+ // call to flush(), the following steps guard against this:
298
+ // 1. During beforeUpdate, any updated components will be added to the
299
+ // dirty_components array and will cause a reentrant call to flush(). Because
300
+ // the flush index is kept outside the function, the reentrant call will pick
301
+ // up where the earlier call left off and go through all dirty components. The
302
+ // current_component value is saved and restored so that the reentrant call will
303
+ // not interfere with the "parent" flush() call.
304
+ // 2. bind:this callbacks cannot trigger new flush() calls.
305
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
306
+ // callback called a second time; the seen_callbacks set, outside the flush()
307
+ // function, guarantees this behavior.
308
+ const y=new Set;let b=0;// Do *not* move this inside the flush() function
309
+ function x(){
310
+ // Do not reenter flush while dirty components are updated, as this can
311
+ // result in an infinite loop. Instead, let the inner flush handle it.
312
+ // Reentrancy is ok afterwards for bindings etc.
313
+ if(0!==b)return;const t=a;do{
314
+ // first, call beforeUpdate functions
315
+ // and update components
316
+ try{for(;b<u.length;){const t=u[b];b++,d(t),v(t.$$);}}catch(t){
317
+ // reset dirty state to not end up in a deadlocked state and then rethrow
318
+ throw u.length=0,b=0,t}for(d(null),u.length=0,b=0;f.length;)f.pop()();
319
+ // then, once components are updated, call
320
+ // afterUpdate functions. This may cause
321
+ // subsequent updates...
322
+ for(let t=0;t<p.length;t+=1){const e=p[t];y.has(e)||(
323
+ // ...so guard against infinite loops
324
+ y.add(e),e());}p.length=0;}while(u.length);for(;h.length;)h.pop()();m=!1,y.clear(),d(t);}function v(t){if(null!==t.fragment){t.update(),i(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(g);}}
325
+ /**
326
+ * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.
327
+ */const _=new Set;function k(t,e){const n=t.$$;null!==n.fragment&&(!function(t){const e=[],n=[];p.forEach((i=>-1===t.indexOf(i)?e.push(i):n.push(i))),n.forEach((t=>t())),p=e;}(n.after_update),i(n.on_destroy),n.fragment&&n.fragment.d(e),
328
+ // TODO null out other refs, including component.$$ (but need to
329
+ // preserve final state?)
330
+ n.on_destroy=n.fragment=null,n.ctx=[]);}function E(t,e){-1===t.$$.dirty[0]&&(u.push(t),m||(m=!0,$.then(x)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31;}function C(o,l,c,u,f,p,h,$=[-1]){const m=a;d(o);const y=o.$$={fragment:null,ctx:[],
331
+ // state
332
+ props:p,update:t,not_equal:f,bound:n(),
333
+ // lifecycle
334
+ on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(l.context||(m?m.$$.context:[])),
335
+ // everything else
336
+ callbacks:n(),dirty:$,skip_bound:!1,root:l.target||m.$$.root};h&&h(y.root);let b=!1;if(y.ctx=c?c(o,l.props||{},((t,e,...n)=>{const i=n.length?n[0]:e;return y.ctx&&f(y.ctx[t],y.ctx[t]=i)&&(!y.skip_bound&&y.bound[t]&&y.bound[t](i),b&&E(o,t)),e})):[],y.update(),b=!0,i(y.before_update),
337
+ // `false` as a special case of no DOM component
338
+ y.fragment=!!u&&u(y.ctx),l.target){if(l.hydrate){const t=function(t){return Array.from(t.childNodes)}(l.target);
339
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
340
+ y.fragment&&y.fragment.l(t),t.forEach(r);}else
341
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
342
+ y.fragment&&y.fragment.c();l.intro&&((v=o.$$.fragment)&&v.i&&(_.delete(v),v.i(k))),function(t,n,o,l){const{fragment:r,after_update:c}=t.$$;r&&r.m(n,o),l||
343
+ // onMount happens before the initial afterUpdate
344
+ g((()=>{const n=t.$$.on_mount.map(e).filter(s);
345
+ // if the component was destroyed immediately
346
+ // it will update the `$$.on_destroy` reference to `null`.
347
+ // the destructured on_destroy may still reference to the old array
348
+ t.$$.on_destroy?t.$$.on_destroy.push(...n):
349
+ // Edge case - component was destroyed immediately,
350
+ // most likely as a result of a binding initialising
351
+ i(n),t.$$.on_mount=[];})),c.forEach(g);}(o,l.target,l.anchor,l.customElement),x();}var v,k;d(m);}let w;
352
+ /* src/GeneralAnimationLoading.svelte generated by Svelte v3.59.2 */
353
+ function L(e){let n;return {c(){var e;e="div",n=document.createElement(e),n.innerHTML='<section class="LoaderContainer" part="LoaderContainer"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></section>',this.c=t;},m(t,i){l(t,n,i),
354
+ /*div5_binding*/e[3](n);},p:t,i:t,o:t,d(t){t&&r(n)
355
+ /*div5_binding*/,e[3](null);}}}function T(t,e,n){let i,{clientstyling:s=""}=e,{clientstylingurl:o=""}=e;return t.$$set=t=>{"clientstyling"in t&&n(1,s=t.clientstyling),"clientstylingurl"in t&&n(2,o=t.clientstylingurl);},t.$$.update=()=>{/*clientstyling, customStylingContainer*/3&t.$$.dirty&&s&&i&&(()=>{let t=document.createElement("style");t.innerHTML=s,i.appendChild(t);})(),/*clientstylingurl, customStylingContainer*/5&t.$$.dirty&&o&&i&&(()=>{let t=new URL(o),e=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{e.innerHTML=t,setTimeout((()=>{i.appendChild(e);}),1),setTimeout((()=>{}),500);}));})();},[i,s,o,function(t){f[t?"unshift":"push"]((()=>{i=t,n(0,i);}));}]}"function"==typeof HTMLElement&&(w=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(e).filter(s);
356
+ // @ts-ignore todo: improve typings
357
+ for(const t in this.$$.slotted)
358
+ // @ts-ignore todo: improve typings
359
+ this.appendChild(this.$$.slotted[t]);}attributeChangedCallback(t,e,n){this[t]=n;}disconnectedCallback(){i(this.$$.on_disconnect);}$destroy(){k(this,1),this.$destroy=t;}$on(e,n){
360
+ // TODO should this delegate to addEventListener?
361
+ if(!s(n))return t;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const t=i.indexOf(n);-1!==t&&i.splice(t,1);}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1);}});class M extends w{constructor(t){super();const e=document.createElement("style");e.textContent=".LoaderContainer{display:flex;justify-content:center}.lds-ellipsis{display:inline-block;position:relative;width:80px;height:80px}.lds-ellipsis div{position:absolute;top:33px;width:13px;height:13px;border-radius:50%;background:#d1d1d1;animation-timing-function:cubic-bezier(0, 1, 1, 0)}.lds-ellipsis div:nth-child(1){left:8px;animation:lds-ellipsis1 0.6s infinite}.lds-ellipsis div:nth-child(2){left:8px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(3){left:32px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(4){left:56px;animation:lds-ellipsis3 0.6s infinite}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0, 0)}100%{transform:translate(24px, 0)}}",this.shadowRoot.appendChild(e),C(this,{target:this.shadowRoot,props:c(this.attributes),customElement:!0},T,L,o,{clientstyling:1,clientstylingurl:2},null),t&&(t.target&&l(t.target,this,t.anchor),t.props&&(this.$set(t.props),x()));}static get observedAttributes(){return ["clientstyling","clientstylingurl"]}get clientstyling(){return this.$$.ctx[1]}set clientstyling(t){this.$$set({clientstyling:t}),x();}get clientstylingurl(){return this.$$.ctx[2]}set clientstylingurl(t){this.$$set({clientstylingurl:t}),x();}}return !customElements.get("general-animation-loading")&&customElements.define("general-animation-loading",M),M}));
362
+ //# sourceMappingURL=general-animation-loading.js.map
363
+ });
364
+
365
+ const casinoEngagementSuiteTournamentCss = ".GradientRounded {\n display: block;\n background: linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);\n color: rgba(30, 22, 56, 1);\n \n position: relative;\n border-radius: 16px;\n\n &.Hollow {\n background: rgba(30, 22, 56, 1);\n color: #FFFFFF;\n &::before {\n content: \"\";\n position: absolute;\n inset: 0;\n border-radius: 15px;\n border: 1px solid transparent;\n background: linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%) border-box;\n -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);\n mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: destination-out;\n mask-composite: exclude;\n }\n\n }\n}\n\n.GradientRoundedButton {\n border: none;\n padding: 7px;\n \n height: 32px;\n width: 100%;\n \n font-size: 14px;\n font-weight: 700;\n line-height: 17.07px;\n text-align: center;\n \n transition: .5s opacity;\n\n cursor: pointer;\n &.Pending {\n cursor: not-allowed;\n opacity: .3;\n }\n\n &.Hollow {\n \n span {\n background: -webkit-linear-gradient(98.25deg, rgb(255, 148, 0) 22.48%, rgb(254, 247, 70) 131.02%, rgb(255, 226, 74) 131.9%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n }\n }\n}\n.Wrapper {\n height: 100%;\n position: relative;\n color: var(--emw--color-typography, #FFFFFF);\n display: flex;\n background-color: var(--emw--color-background, #1d1537);\n flex-direction: column;\n border-radius: 8px;\n overflow: hidden;\n}\n\n.WrapperContent {\n padding-bottom: 20px;\n transition: 0.5s filter;\n}\n.WrapperContent.faded {\n filter: brightness(53.3333333333%);\n}\n\n.WrapperBar {\n display: flex;\n width: 100%;\n padding: 12px 8px 8px;\n}\n\n.WrapperBarLeft, .WrapperBarRight {\n cursor: pointer;\n}\n\n.WrapperBarMiddle {\n flex-grow: 1;\n text-align: center;\n font-size: 16px;\n line-height: 16px;\n font-weight: 500;\n color: var(--emw--color-secondary, #bbb9c3);\n}\n\n:host {\n display: block;\n font-size: 12px;\n font-family: Inter;\n}\n\n.Row {\n margin: 24px 0;\n padding: 0 20px;\n}\n\n.LeaderboardsItem {\n margin: 10px 0;\n border: 1px solid #403956;\n border-radius: 16px;\n}\n.LeaderboardsItem.Hollow {\n border-color: transparent;\n}\n\n.LeaderboardsItemContainer {\n padding-top: 16px;\n}\n\n.Info {\n margin: 24px 0;\n padding: 0 20px;\n}\n\n.TimeContainer {\n margin: 24px 0;\n padding: 0 20px;\n}\n.TimeContainer .Time {\n display: flex;\n justify-content: space-between;\n font-size: 11px;\n align-items: center;\n color: var(--emw--color-secondary, #bbb9c3);\n}\n.TimeContainer .Time button {\n font-size: 12px;\n height: 20px;\n padding: 0;\n}\n.TimeContainer .Time button::before {\n inset: inherit;\n border: 0;\n}\n\n.ShowInfo {\n margin: 24px 0;\n padding: 0 20px;\n cursor: pointer;\n color: #666178;\n}\n.ShowInfo p {\n display: flex;\n gap: 4px;\n}\n\n.TitleContainer {\n display: flex;\n justify-content: space-between;\n margin: 24px 0;\n padding: 0 20px;\n margin-top: 0;\n gap: 10px;\n font-family: Montserrat;\n}\n.TitleContainer .GradientRoundedButton {\n width: 120px;\n}\n\n.TabsContainer {\n margin: 24px 0;\n padding: 0 20px;\n margin: 0 20px;\n padding: 0;\n border-bottom: 1px solid #575757;\n}\n\n.Tabs {\n display: flex;\n justify-content: space-between;\n justify-content: start;\n font-size: 12px;\n margin-bottom: -1px;\n}\n.Tabs > div {\n padding: 10px;\n color: #666178;\n cursor: pointer;\n}\n.Tabs > div.active {\n color: var(--emw--color-typography, #FFF);\n border-bottom: 2px solid var(--emw--color-typography, #FFF);\n}\n\n.Title {\n font-size: 16px;\n font-weight: 700;\n line-height: 19.5px;\n text-align: left;\n word-break: break-word;\n}\n\n.TC {\n margin-top: 12px;\n}\n.TC a {\n color: #59d1ff;\n}\n\n.Criterias {\n margin: 12px 0;\n}\n.Criterias span {\n color: var(--emw--color-primary, #ffd62f);\n font-weight: 400;\n}\n\n.ResultPrize {\n margin: 24px 0;\n padding: 0 20px;\n}\n.ResultPrize span {\n color: var(--emw--color-primary, #ffd62f);\n font-weight: 400;\n}\n\n.Prizes {\n margin: 24px 0;\n padding: 0 20px;\n}\n.Prizes .PrizesText {\n margin-left: 3px;\n font-weight: 600;\n}\n.Prizes .PrizesHeader {\n align-items: center;\n display: flex;\n}\n.Prizes .PrizesHeader img {\n width: 12px;\n}\n.Prizes .Prize {\n margin: 8px 0;\n}\n.Prizes .Prize .PrizeText {\n color: var(--emw--color-primary, #ffd62f);\n font-weight: 400;\n}\n\n* {\n box-sizing: border-box;\n}\n\n.Leaderboards {\n width: 100%;\n text-align: center;\n border-collapse: collapse;\n}\n.Leaderboards td {\n opacity: 0.6;\n padding: 20px 5px;\n}\n.Leaderboards td:first-child {\n padding-left: 20px;\n}\n.Leaderboards td:last-child {\n padding-right: 20px;\n}\n.Leaderboards .LeaderboardName {\n color: var(--emw--color-typography, #FFF);\n opacity: 1;\n}\n.Leaderboards tr.isMe {\n background: rgba(0, 0, 0, 0.2);\n}\n.Leaderboards tr.isMe .LeaderboardRank span {\n padding: 0px 3px;\n opacity: 1;\n border: 1px solid var(--emw--color-primary, #ffd62f);\n border-radius: 11px;\n}\n.Leaderboards tr.isMe td {\n color: var(--emw--color-primary, #ffd62f);\n}\n\n.Games {\n margin: 24px 0;\n padding: 0 20px;\n display: flex;\n flex-wrap: wrap;\n justify-content: space-evenly;\n gap: 4px 7.25px;\n}\n.Games img {\n width: 60px;\n}\n\ndialog {\n position: absolute;\n top: 30px;\n width: 100%;\n height: 100%;\n background: transparent;\n border: 0;\n padding: 0;\n color: var(--emw--color-typography, #FFFFFF);\n}\ndialog > div {\n margin: 32px;\n border-radius: 8px;\n background: var(--emw--color-background, #1d1537);\n border: 1px solid #403956;\n align-items: center;\n}\n\n.DialogContentUnjoin {\n padding: 32px;\n padding-top: 10px;\n display: flex;\n gap: 10px;\n flex-direction: column;\n}\n\n.DialogContentUnjoinTitle {\n font-family: Montserrat;\n font-size: 20px;\n font-weight: 600;\n line-height: 24.38px;\n text-align: center;\n}\n\n.DialogContentUnjoinDescription {\n color: var(--emw--color-secondary, #bbb9c3);\n margin-bottom: 30px;\n}\n\n.Tip {\n padding: 32px;\n padding-top: 10px;\n color: var(--emw--color-secondary, #bbb9c3);\n font-size: 14px;\n}\n\n.PageConfirmContainer {\n text-align: center;\n width: 80%;\n margin: 0 auto;\n}\n\n.PageConfirm {\n padding: 40px 32px;\n display: flex;\n flex-direction: column;\n gap: 20px;\n}\n.PageConfirm .Title {\n font-size: 20px;\n text-align: center;\n}\n.PageConfirm .Description {\n color: var(--emw--color-secondary, #bbb9c3);\n font-weight: 400;\n}\n.PageConfirm .Description span {\n color: var(--emw--color-typography, #FFF);\n font-weight: 600;\n}\n\n.PageConfirmButtonsGroup {\n width: 150px;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}";
366
+
367
+ const CasinoEngagementSuiteTournament = class {
368
+ constructor(hostRef) {
369
+ index.registerInstance(this, hostRef);
370
+ this.close = index.createEvent(this, "close", 7);
371
+ /**
372
+ * Language
373
+ */
374
+ this.language = 'en';
375
+ /**
376
+ * Client custom styling via string
377
+ */
378
+ this.clientStyling = '';
379
+ /**
380
+ * Client custom styling via url
381
+ */
382
+ this.clientStylingUrl = '';
383
+ /**
384
+ * Translation via url
385
+ */
386
+ this.translationUrl = '';
387
+ this.tab = Tab.Info;
388
+ this.locale = TRANSLATIONS;
389
+ this.tournamentItem = undefined;
390
+ this.tournamentList = undefined;
391
+ this.leaderboards = [];
392
+ this.isActionJoinPending = false;
393
+ this.isDialogOpen = false;
394
+ this.isShowInfo = false;
395
+ this.page = LeaderboardPage.List;
396
+ this.tournamentInDialog = undefined;
397
+ this.dialog = {
398
+ isOpen: false,
399
+ type: undefined,
400
+ data: undefined,
401
+ };
402
+ this.time = 0;
403
+ this.onClickConfirmJoin = () => {
404
+ this.actionJoin(this.tournamentItem);
405
+ this.nextPage = LeaderboardPage.List;
406
+ };
407
+ this.onClickConfirmUnjoin = () => {
408
+ this.close.emit();
409
+ };
410
+ this.onClickDialogUnjoin = () => {
411
+ this.actionJoin(this.dialog.data);
412
+ this.closeDialog();
413
+ };
414
+ this.onClickDialogJoin = () => {
415
+ this.closeDialog();
416
+ };
417
+ this.onClickBarInLayout = () => {
418
+ this.close.emit();
419
+ };
420
+ this.onClickBarInLayoutDialog = () => {
421
+ this.closeDialog();
422
+ };
423
+ this.onClickShowInfo = () => {
424
+ this.isShowInfo = !this.isShowInfo;
425
+ };
426
+ this.onClickBarTip = () => {
427
+ this.openDialog(DialogType.Tip);
428
+ };
429
+ this.onClickBarBack = () => {
430
+ this.setPage(LeaderboardPage.List);
431
+ };
432
+ }
433
+ setTimeInterval() {
434
+ this.timeHolder = setInterval(() => {
435
+ if (this.tournamentList || this.tournamentItem) {
436
+ this.time += 1;
437
+ }
438
+ else {
439
+ this.time = 0;
440
+ }
441
+ }, 1000);
442
+ }
443
+ updateTournamentListByItem(tournament) {
444
+ this.tournamentList = this.tournamentList.map((_tournament) => {
445
+ if (_tournament.id === tournament.id) {
446
+ return tournamentAdapter(tournament);
447
+ }
448
+ else {
449
+ return _tournament;
450
+ }
451
+ });
452
+ }
453
+ handleEvent(e) {
454
+ const _a = e.data, { type } = _a, rest = __rest(_a, ["type"]);
455
+ switch (type) {
456
+ case 'ShowLeaderboardRewardModal': {
457
+ const { tournament } = rest;
458
+ this.setPage(LeaderboardPage.Confirm, { tournament: tournamentAdapter(tournament) });
459
+ postMessage({ type: 'BarLeaderboardsClick' });
460
+ break;
461
+ }
462
+ case 'UpdateTournamentsItemRes': {
463
+ const tournamentNew = tournamentAdapter(rest.data.item);
464
+ this.tournamentItem = tournamentNew;
465
+ this.updateTournamentListByItem(tournamentNew);
466
+ break;
467
+ }
468
+ case 'UpdateLeaderboardsRes': {
469
+ this.leaderboards = leaderboardsAdapter(rest.data);
470
+ break;
471
+ }
472
+ case 'JoinTournamentRes':
473
+ case 'UnjoinTournamentRes':
474
+ const { success } = rest;
475
+ if (success) {
476
+ this.tournamentItem = Object.assign(Object.assign({}, this.tournamentItem), { playerEnrolled: !!!this.tournamentItem.playerEnrolled });
477
+ switch (this.page) {
478
+ case LeaderboardPage.Item: {
479
+ break;
480
+ }
481
+ case LeaderboardPage.List: {
482
+ this.updateTournamentListByItem(this.tournamentItem);
483
+ break;
484
+ }
485
+ }
486
+ }
487
+ if (this.nextPage) {
488
+ this.setPage(this.nextPage);
489
+ this.nextPage = undefined;
490
+ }
491
+ this.isActionJoinPending = false;
492
+ break;
493
+ }
494
+ }
495
+ get messageSender() {
496
+ return {
497
+ JoinTournamentReq: (tournament) => { var _a; return window.postMessage({ type: 'JoinTournamentReq', bonusCode: (_a = tournament.wallets[0]) === null || _a === void 0 ? void 0 : _a.code }); },
498
+ UnjoinTournamentReq: (tournament) => window.postMessage({ type: 'UnjoinTournamentReq', id: tournament.id }),
499
+ UpdateTournamentsItemReq: (tournament) => window.postMessage({ type: 'UpdateTournamentsItemReq', id: tournament.id }),
500
+ UpdateLeaderboardsReq: (tournament) => window.postMessage({ type: 'UpdateLeaderboardsReq', id: tournament.id }),
501
+ };
502
+ }
503
+ connectedCallback() {
504
+ this.setTimeInterval();
505
+ }
506
+ disconnectedCallback() {
507
+ clearInterval(this.timeHolder);
508
+ }
509
+ actionJoin(tournament) {
510
+ if (this.isActionJoinPending)
511
+ return;
512
+ this.isActionJoinPending = true;
513
+ try {
514
+ if (tournament.playerEnrolled) {
515
+ this.messageSender.UnjoinTournamentReq(tournament);
516
+ }
517
+ else {
518
+ this.messageSender.JoinTournamentReq(tournament);
519
+ }
520
+ }
521
+ catch (e) {
522
+ console.log('error', e);
523
+ return;
524
+ }
525
+ }
526
+ isTournamentClosed(tournament) {
527
+ return [
528
+ TournamentState.Closed,
529
+ TournamentState.Closing
530
+ ].includes(tournament.state);
531
+ }
532
+ setPage(page, metaData) {
533
+ switch (page) {
534
+ case LeaderboardPage.Confirm:
535
+ case LeaderboardPage.Item:
536
+ this.tournamentItem = metaData.tournament;
537
+ if (!this.tournamentItem) {
538
+ this.messageSender.UpdateTournamentsItemReq(metaData.tournament);
539
+ }
540
+ if (this.isTournamentClosed(this.tournamentItem)) {
541
+ this.messageSender.UpdateLeaderboardsReq(this.tournamentItem);
542
+ }
543
+ break;
544
+ }
545
+ this.tab = Tab.Info;
546
+ this.page = page;
547
+ }
548
+ renderPage() {
549
+ switch (this.page) {
550
+ case LeaderboardPage.Confirm: return this.renderPageConfirm();
551
+ case LeaderboardPage.Item: return this.renderPageLeaderboardItem();
552
+ case LeaderboardPage.List: return this.renderPageLeaderboardList();
553
+ }
554
+ }
555
+ render() {
556
+ return (index.h(index.Host, null, index.h("general-styling-wrapper", { clientStylingUrl: this.clientStylingUrl, clientStyling: this.clientStyling,
557
+ // @ts-ignore
558
+ targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), this.renderPage()));
559
+ }
560
+ onClickListItemChangePage(tournament) {
561
+ this.setPage(LeaderboardPage.Item, { tournament });
562
+ }
563
+ onClickItemJoin(tournament, e) {
564
+ e.stopPropagation();
565
+ if (tournament.playerEnrolled) {
566
+ this.openDialog(DialogType.Unjoin, tournament);
567
+ }
568
+ else {
569
+ this.actionJoin(tournament);
570
+ this.tournamentItem = tournament;
571
+ }
572
+ }
573
+ onClickTab(tab) {
574
+ this.tab = tab;
575
+ switch (tab) {
576
+ case Tab.Leaderboard:
577
+ this.leaderboards = undefined;
578
+ this.messageSender.UpdateLeaderboardsReq(this.tournamentItem);
579
+ break;
580
+ case Tab.Games:
581
+ this.messageSender.UpdateTournamentsItemReq(this.tournamentItem);
582
+ break;
583
+ }
584
+ }
585
+ renderPageLeaderboardList() {
586
+ var _a;
587
+ if (!this.tournamentList) {
588
+ this.tournamentList = (_a = this.leaderboardsInit) === null || _a === void 0 ? void 0 : _a.map(item => tournamentAdapter(item));
589
+ return index.h("general-animation-loading", null);
590
+ }
591
+ const { locale } = this;
592
+ if (this.tournamentList.length) {
593
+ return this.renderLeaderboardContainer(index.h(index.Fragment, null, index.h("div", { class: "Leaderboards Row" }, this.tournamentList.map(_tournament => (index.h("div", { class: classnames("LeaderboardsItem", _tournament.playerEnrolled ? ' GradientRounded Hollow' : ''), onClick: this.onClickListItemChangePage.bind(this, _tournament) }, index.h("div", { class: "LeaderboardsItemContainer" }, this.renderTitleContainer(_tournament), this.renderTimeBar(_tournament))))))));
594
+ }
595
+ else {
596
+ return (index.h("div", { class: "NoLeaderboards Row" }, index.h("div", null, locale.NoLeaderboards), index.h("div", null, locale.NoLeaderboardsTip)));
597
+ }
598
+ }
599
+ renderPageConfirm() {
600
+ if (!this.tournamentItem)
601
+ return index.h("general-animation-loading", null);
602
+ const tournamentName = this.tournamentItem.nameOrTitle;
603
+ const { locale } = this;
604
+ return (index.h("div", { class: "PageConfirmContainer" }, index.h("div", { class: "GradientRounded Hollow PageConfirm" }, index.h("div", null, iconTrophy), index.h("div", { class: "Title" }, locale.JoinDialog.Tile), index.h("div", { class: "Description", innerHTML: localePostprocess(locale.JoinDialog.Description, { tournamentName }) }), index.h("div", { class: "PageConfirmButtonsGroup" }, index.h(GradientRoundedButton, Object.assign({}, {
605
+ statedClasses: {
606
+ isPending: this.isActionJoinPending,
607
+ },
608
+ onClick: this.onClickConfirmJoin,
609
+ innerHTML: locale.JoinDialog.ButtonYes,
610
+ })), index.h(GradientRoundedButton, Object.assign({}, {
611
+ statedClasses: {
612
+ isPending: this.isActionJoinPending,
613
+ isHollow: true,
614
+ },
615
+ onClick: this.onClickConfirmUnjoin,
616
+ innerHTML: locale.JoinDialog.ButtonNo,
617
+ }))))));
618
+ }
619
+ renderPageLeaderboardItem() {
620
+ if (!this.tournamentItem)
621
+ return index.h("general-animation-loading", null);
622
+ return this.renderLeaderboardContainer(index.h(index.Fragment, null, this.renderTitleContainer(this.tournamentItem), this.renderTabs(), this.renderTabbedContent()));
623
+ }
624
+ renderDialogContent() {
625
+ switch (this.dialog.type) {
626
+ case DialogType.Unjoin:
627
+ return this.renderDialogContentUnjoin();
628
+ case DialogType.Tip:
629
+ return (index.h("div", { class: "Tip" }, this.locale.Tip));
630
+ }
631
+ }
632
+ renderDialogContentUnjoin() {
633
+ const { locale } = this;
634
+ return (index.h("div", { class: "DialogContentUnjoin" }, index.h("div", { class: "DialogContentUnjoinTitle" }, locale.UnjoinDialog.Title), index.h("div", { class: "DialogContentUnjoinDescription", innerHTML: locale.UnjoinDialog.Description }), index.h(GradientRoundedButton, Object.assign({}, {
635
+ statedClasses: {
636
+ isPending: this.isActionJoinPending,
637
+ },
638
+ onClick: this.onClickDialogUnjoin,
639
+ innerHTML: locale.UnjoinDialog.ButtonYes,
640
+ })), index.h(GradientRoundedButton, Object.assign({}, {
641
+ statedClasses: {
642
+ isHollow: true,
643
+ isPending: this.isActionJoinPending,
644
+ },
645
+ onClick: this.onClickDialogJoin,
646
+ innerHTML: locale.UnjoinDialog.ButtonNo,
647
+ }))));
648
+ }
649
+ renderTitleContainer(tournament) {
650
+ const { locale } = this;
651
+ return (index.h("div", { class: "TitleContainer" }, index.h("div", { class: "Title" }, tournament.nameOrTitle), tournament.state !== TournamentState.Closed && (index.h("div", null, index.h(GradientRoundedButton, Object.assign({}, {
652
+ statedClasses: {
653
+ isHollow: tournament.playerEnrolled,
654
+ isPending: this.isActionJoinPending,
655
+ },
656
+ onClick: this.onClickItemJoin.bind(this, tournament),
657
+ innerHTML: tournament.playerEnrolled ? locale.Unjoin : locale.Join,
658
+ }))))));
659
+ }
660
+ renderTabbedContent() {
661
+ switch (this.tab) {
662
+ case Tab.Info: return this.renderInfo();
663
+ case Tab.Leaderboard: return this.renderLeaderboard();
664
+ case Tab.Games: return this.renderGames();
665
+ }
666
+ }
667
+ renderGames() {
668
+ var _a;
669
+ return (index.h("div", { class: "Games" }, (_a = this.tournamentItem.games) === null || _a === void 0 ? void 0 : _a.map(game => (index.h("div", null, index.h("img", { src: game.defaultThumbnail, alt: "" }))))));
670
+ }
671
+ renderLeaderboard() {
672
+ if (!this.leaderboards)
673
+ return index.h("general-animation-loading", null);
674
+ if (!this.leaderboards.length)
675
+ return '';
676
+ return (index.h("table", { class: "Leaderboards" }, this.leaderboards.map(leaderboard => (index.h("tr", { class: classnames({ isMe: leaderboard.isMe }) }, index.h("td", { class: "LeaderboardRank" }, index.h("span", null, leaderboard.rank)), index.h("td", { class: "LeaderboardName" }, leaderboard.shortName), index.h("td", { class: "LeaderboardScore" }, leaderboard.score), index.h("td", { class: "LeaderboardPrize" }, leaderboard.prizeName))))));
677
+ }
678
+ renderTabs() {
679
+ const { locale, tab } = this;
680
+ return (index.h("div", { class: "TabsContainer" }, index.h("div", { class: "Tabs" }, Object.keys(Tab).map((_tab) => (index.h("div", Object.assign({}, {
681
+ class: classnames({ active: tab === _tab }),
682
+ onClick: this.onClickTab.bind(this, _tab)
683
+ }), locale[_tab]))))));
684
+ }
685
+ renderTimeBar(tournament) {
686
+ return (index.h("section", { class: "TimeContainer" }, index.h("div", { class: 'Time' }, tournament.playerEnrolled ? (index.h(index.Fragment, null, index.h("div", null, getDifference(addSeconds(tournament.startTime, this.time), tournament.endTime)), index.h("div", null, index.h(GradientRoundedButton, { statedClasses: {
687
+ isHollow: true,
688
+ isPendding: false,
689
+ }, innerHTML: `${getProgress(tournament.startTime, tournament.endTime)}%` })))) : (index.h(index.Fragment, null, index.h("div", null, formatDate(tournament.startTime)), index.h("div", null, formatDate(tournament.endTime))))), index.h("casino-engagement-suite-progress-bar", { value: Number(getProgress(tournament.startTime, tournament.endTime)), "hide-percent": true })));
690
+ }
691
+ renderInfo() {
692
+ var _a, _b;
693
+ const { locale, tournamentItem: tournament, isShowInfo } = this;
694
+ return (index.h("div", { class: "InfoContainer" }, this.renderTimeBar(tournament), (index.h("section", { class: "ShowInfo", onClick: this.onClickShowInfo }, index.h("p", null, index.h("span", null, isShowInfo ? iconEyeClose : iconEyeOpen), index.h("span", null, locale.LeaderboardDetails)))), isShowInfo && (index.h("section", { class: "Info" }, index.h("div", null, tournament.description), index.h("div", { class: "Criterias" }, index.h("div", null, locale.ScoreCriteria, ": ", index.h("span", null, tournament.scoreCriteria)), index.h("div", null, locale.MinimumBetCriteria, ": ", index.h("span", null, tournament.minBetCount))), index.h("div", { class: "TC" }, index.h("a", { href: tournament.termsUrl, target: '_blank' }, locale.TC)))), this.isTournamentClosed(this.tournamentItem) && ((_a = this.leaderboards) === null || _a === void 0 ? void 0 : _a.find(l => l.isMe)) && (index.h("section", { class: "ResultPrize", innerHTML: localePostprocess(locale.TipPrize, this.getResultPrize((_b = this.leaderboards) === null || _b === void 0 ? void 0 : _b.find(l => l.isMe))) })), index.h("section", { class: "Prizes" }, index.h("div", { class: "PrizesHeader" }, iconReward, index.h("span", { class: "PrizesText" }, locale.Prizes)), tournament.prizes.map((prize, index$1) => (index.h("div", { class: "Prize" }, index$1 + 1, " ", locale.Place, ": ", index.h("span", { class: "PrizeText" }, prize.name)))))));
695
+ }
696
+ getResultPrize(leaderboard) {
697
+ return {
698
+ prize: leaderboard.prizeName,
699
+ place: leaderboard.rank,
700
+ };
701
+ }
702
+ renderCloseBarInLayout() {
703
+ const { left, middle } = this.getWrapperBarData();
704
+ return (index.h(CloseBar, Object.assign({}, { left, middle,
705
+ right: (index.h("span", Object.assign({}, { onClick: this.onClickBarInLayout }), iconClose))
706
+ })));
707
+ }
708
+ renderCloseBarInLayoutDialog() {
709
+ return (index.h(CloseBar, Object.assign({}, {
710
+ right: (index.h("span", Object.assign({}, { onClick: this.onClickBarInLayoutDialog }), iconClose))
711
+ })));
712
+ }
713
+ renderLeaderboardContainer(render) {
714
+ const { dialog: { isOpen } } = this;
715
+ return (index.h("div", { class: "Wrapper" }, index.h("div", { class: classnames("WrapperContent", { faded: isOpen }) }, this.renderCloseBarInLayout(), index.h("div", { class: "Root" }, index.h("div", { class: "Main" }, render))), index.h("div", { class: "WrapperUtil" }, index.h("dialog", { open: isOpen }, index.h("div", null, this.renderCloseBarInLayoutDialog(), isOpen && this.renderDialogContent())))));
716
+ }
717
+ getWrapperBarData() {
718
+ const { page, locale } = this;
719
+ switch (page) {
720
+ case LeaderboardPage.List:
721
+ return {
722
+ left: index.h("span", { onClick: this.onClickBarTip }, iconQuestion),
723
+ middle: locale.Leaderboards
724
+ };
725
+ case LeaderboardPage.Item:
726
+ return {
727
+ left: (index.h("span", { onClick: this.onClickBarBack }, iconBack)),
728
+ middle: '',
729
+ };
730
+ }
731
+ }
732
+ openDialog(type, data = undefined) {
733
+ this.dialog = Object.assign(Object.assign({}, this.dialog), { isOpen: true, type, data });
734
+ }
735
+ closeDialog() {
736
+ this.dialog = Object.assign(Object.assign({}, this.dialog), { isOpen: false });
737
+ }
738
+ };
739
+ CasinoEngagementSuiteTournament.style = casinoEngagementSuiteTournamentCss;
740
+
741
+ const mergeTranslations = (url, target) => {
742
+ return new Promise((resolve) => {
743
+ fetch(url)
744
+ .then((res) => res.json())
745
+ .then((data) => {
746
+ Object.keys(data).forEach((item) => {
747
+ target[item] = target[item] ? target[item] : {};
748
+ for (let key in data[item]) {
749
+ target[item][key] = data[item][key];
750
+ }
751
+ });
752
+ resolve(true);
753
+ });
754
+ });
755
+ };
756
+
757
+ const generalStylingWrapperCss = ":host{display:block}";
758
+
759
+ const GeneralStylingWrapper = class {
760
+ constructor(hostRef) {
761
+ index.registerInstance(this, hostRef);
762
+ /**
763
+ * Client custom styling via inline styles
764
+ */
765
+ this.clientStyling = '';
766
+ /**
767
+ * Client custom styling via url
768
+ */
769
+ this.clientStylingUrl = '';
770
+ /**
771
+ * Translation via url
772
+ */
773
+ this.translationUrl = '';
774
+ this.stylingAppends = false;
775
+ this.setClientStyling = () => {
776
+ let sheet = document.createElement('style');
777
+ sheet.innerHTML = this.clientStyling;
778
+ this.el.prepend(sheet);
779
+ };
780
+ this.setClientStylingURL = () => {
781
+ let url = new URL(this.clientStylingUrl);
782
+ let cssFile = document.createElement('style');
783
+ fetch(url.href)
784
+ .then((res) => res.text())
785
+ .then((data) => {
786
+ cssFile.innerHTML = data;
787
+ setTimeout(() => {
788
+ this.el.prepend(cssFile);
789
+ }, 1);
790
+ })
791
+ .catch((err) => {
792
+ console.log('error ', err);
793
+ });
794
+ };
795
+ }
796
+ componentDidRender() {
797
+ // start custom styling area
798
+ if (!this.stylingAppends) {
799
+ if (this.clientStyling)
800
+ this.setClientStyling();
801
+ if (this.clientStylingUrl)
802
+ this.setClientStylingURL();
803
+ this.stylingAppends = true;
804
+ }
805
+ // end custom styling area
806
+ }
807
+ async componentWillLoad() {
808
+ const promises = [];
809
+ if (this.translationUrl) {
810
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
811
+ promises.push(translationPromise);
812
+ }
813
+ return await Promise.all(promises);
814
+ }
815
+ render() {
816
+ return (index.h("div", { class: "StyleShell" }, index.h("slot", { name: "mainContent" })));
817
+ }
818
+ get el() { return index.getElement(this); }
819
+ };
820
+ GeneralStylingWrapper.style = generalStylingWrapperCss;
821
+
822
+ exports.casino_engagement_suite_progress_bar = CasinoEngagementSuiteProgressBar;
823
+ exports.casino_engagement_suite_tournament = CasinoEngagementSuiteTournament;
824
+ exports.general_styling_wrapper = GeneralStylingWrapper;