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