@everymatrix/casino-challenge-details 0.0.1

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 (83) hide show
  1. package/dist/casino-challenge-details/app-globals-0f993ce5.js +1 -0
  2. package/dist/casino-challenge-details/casino-challenge-details-5a765f2c.js +1 -0
  3. package/dist/casino-challenge-details/casino-challenge-details.esm.js +1 -0
  4. package/dist/casino-challenge-details/casino-challenge-details_4.entry.js +1 -0
  5. package/dist/casino-challenge-details/index-30adf0cb.js +2 -0
  6. package/dist/casino-challenge-details/index.esm.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-challenge-details-ddf27d4e.js +761 -0
  9. package/dist/cjs/casino-challenge-details.cjs.js +25 -0
  10. package/dist/cjs/casino-challenge-details_4.cjs.entry.js +144 -0
  11. package/dist/cjs/index-2a30d71d.js +1250 -0
  12. package/dist/cjs/index.cjs.js +10 -0
  13. package/dist/cjs/loader.cjs.js +15 -0
  14. package/dist/collection/assets/active-chevron.svg +3 -0
  15. package/dist/collection/assets/alert.svg +3 -0
  16. package/dist/collection/assets/back-arrow.svg +9 -0
  17. package/dist/collection/assets/check.svg +10 -0
  18. package/dist/collection/assets/finish.svg +7 -0
  19. package/dist/collection/assets/gift.svg +14 -0
  20. package/dist/collection/assets/inactive-chevron.svg +3 -0
  21. package/dist/collection/assets/info-circle.svg +3 -0
  22. package/dist/collection/assets/lock.svg +3 -0
  23. package/dist/collection/assets/notification.svg +20 -0
  24. package/dist/collection/assets/target.svg +9 -0
  25. package/dist/collection/assets/title-icon.svg +1 -0
  26. package/dist/collection/assets/trophy.svg +14 -0
  27. package/dist/collection/collection-manifest.json +15 -0
  28. package/dist/collection/components/casino-challenge-details/casino-challenge-details.css +592 -0
  29. package/dist/collection/components/casino-challenge-details/casino-challenge-details.js +684 -0
  30. package/dist/collection/components/casino-challenge-details/index.js +1 -0
  31. package/dist/collection/components/components/casino-challenge-expandable-paragraph.css +76 -0
  32. package/dist/collection/components/components/casino-challenge-expandable-paragraph.js +116 -0
  33. package/dist/collection/components/components/casino-challenge-level-progress-bar.css +33 -0
  34. package/dist/collection/components/components/casino-challenge-level-progress-bar.js +81 -0
  35. package/dist/collection/components/components/casino-challenge-progress-bar.css +66 -0
  36. package/dist/collection/components/components/casino-challenge-progress-bar.js +120 -0
  37. package/dist/collection/index.js +1 -0
  38. package/dist/collection/utils/locale.utils.js +166 -0
  39. package/dist/collection/utils/mock.js +238 -0
  40. package/dist/collection/utils/types.js +60 -0
  41. package/dist/collection/utils/utils.js +29 -0
  42. package/dist/esm/app-globals-0f993ce5.js +3 -0
  43. package/dist/esm/casino-challenge-details-5a765f2c.js +758 -0
  44. package/dist/esm/casino-challenge-details.js +20 -0
  45. package/dist/esm/casino-challenge-details_4.entry.js +138 -0
  46. package/dist/esm/index-30adf0cb.js +1221 -0
  47. package/dist/esm/index.js +2 -0
  48. package/dist/esm/loader.js +11 -0
  49. package/dist/index.cjs.js +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/stencil.config.dev.js +19 -0
  52. package/dist/stencil.config.js +19 -0
  53. package/dist/storybook/main.js +43 -0
  54. package/dist/storybook/preview.js +9 -0
  55. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  56. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/packages/stencil/casino-challenge-details/stencil.config.d.ts +2 -0
  57. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/packages/stencil/casino-challenge-details/stencil.config.dev.d.ts +2 -0
  58. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/packages/stencil/casino-challenge-details/storybook/main.d.ts +3 -0
  59. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/packages/stencil/casino-challenge-details/storybook/preview.d.ts +70 -0
  60. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/tools/plugins/index.d.ts +4 -0
  61. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  62. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  63. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  64. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-challenge-details/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  65. package/dist/types/components/casino-challenge-details/casino-challenge-details.d.ts +105 -0
  66. package/dist/types/components/casino-challenge-details/index.d.ts +1 -0
  67. package/dist/types/components/components/casino-challenge-expandable-paragraph.d.ts +16 -0
  68. package/dist/types/components/components/casino-challenge-level-progress-bar.d.ts +6 -0
  69. package/dist/types/components/components/casino-challenge-progress-bar.d.ts +8 -0
  70. package/dist/types/components.d.ts +198 -0
  71. package/dist/types/index.d.ts +1 -0
  72. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  73. package/dist/types/utils/locale.utils.d.ts +3 -0
  74. package/dist/types/utils/mock.d.ts +76 -0
  75. package/dist/types/utils/types.d.ts +127 -0
  76. package/dist/types/utils/utils.d.ts +3 -0
  77. package/loader/cdn.js +1 -0
  78. package/loader/index.cjs.js +1 -0
  79. package/loader/index.d.ts +24 -0
  80. package/loader/index.es2017.js +1 -0
  81. package/loader/index.js +2 -0
  82. package/loader/package.json +11 -0
  83. package/package.json +27 -0
@@ -0,0 +1,684 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { resolveTranslationUrl, translate } from "../../utils/locale.utils";
4
+ import { formatDate, getTimeLeft } from "../../utils/utils";
5
+ import giftIcon from "../../assets/gift.svg";
6
+ import targetIcon from "../../assets/target.svg";
7
+ import backIcon from "../../assets/back-arrow.svg";
8
+ import lockIcon from "../../assets/lock.svg";
9
+ import alertIcon from "../../assets/alert.svg";
10
+ import checkIcon from "../../assets/check.svg";
11
+ import infoIcon from "../../assets/info-circle.svg";
12
+ import titleIcon from "../../assets/title-icon.svg";
13
+ import notificationIcon from "../../assets/notification.svg";
14
+ import { ChallengeStatusDictionary, EChallengeLevelTargetType, EChallengeProgressStatus, EChallengeStatus } from "../../utils/types";
15
+ export class CasinoChallengeDetails {
16
+ constructor() {
17
+ this.activeEntityRef = null;
18
+ this.scrollContainerRef = null;
19
+ this.challengesTabs = ['Active', 'Pending', 'Finished', 'Code'];
20
+ this.tabs = ['LEVELS', 'GAMES', 'RULES'];
21
+ this.showNotification = 10;
22
+ this.checkIsMobile = () => {
23
+ this.isMobile = window.innerWidth <= 768;
24
+ };
25
+ this.calculateTargetValue = (level, currencySymbol) => {
26
+ var _a;
27
+ if (!level)
28
+ return '';
29
+ const minbet = ((_a = level.BetRange) === null || _a === void 0 ? void 0 : _a.MinBet)
30
+ ? `, ${translate('minBet', this.language)} ${currencySymbol + level.BetRange.MinBet}`
31
+ : '';
32
+ switch (level.LevelTargetType) {
33
+ case EChallengeLevelTargetType.Accumulative:
34
+ return `${translate('placeBetsOf', this.language)} ${currencySymbol + level.DisplayCurrencyTargetTurnover + minbet}`;
35
+ case EChallengeLevelTargetType.SingleBet:
36
+ return `${translate('place', this.language)} ${currencySymbol + level.TargetTurnover} ${translate('bet', this.language)}`;
37
+ case EChallengeLevelTargetType.MultipleOneBetSize:
38
+ return `${translate('place', this.language)} ${level.TargetBetCount} ${translate('bets', this.language) + minbet}`;
39
+ default:
40
+ return '-';
41
+ }
42
+ };
43
+ this.getBadgeContent = () => {
44
+ var _a;
45
+ if (this.challenge) {
46
+ switch ((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) {
47
+ case EChallengeStatus.Expired:
48
+ return translate('expired', this.language);
49
+ case EChallengeStatus.Forfeited:
50
+ return translate('forfeited', this.language);
51
+ case EChallengeStatus.Completed:
52
+ return translate('finished', this.language);
53
+ case EChallengeStatus.Paused:
54
+ return translate('suspended', this.language);
55
+ default:
56
+ return [translate('endsIn', this.language), ' - ', h("span", null, this.timeLeft || null)];
57
+ }
58
+ }
59
+ else
60
+ return null;
61
+ };
62
+ this.checkAttrs = () => {
63
+ if (!this.endpoint) {
64
+ this.error = 'Endpoint is missing! Please provide a valid endpointURL.';
65
+ this.hasError = true;
66
+ console.error(this.error);
67
+ }
68
+ return this.hasError;
69
+ };
70
+ this.joinUnjoinProgress = async () => {
71
+ var _a, _b, _c, _d;
72
+ if (!this.isUserAuthorized) {
73
+ this.openLoginRegisterModal();
74
+ }
75
+ const join = ((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) === EChallengeStatus.Started || ((_b = this.challenge) === null || _b === void 0 ? void 0 : _b.Status) === EChallengeStatus.Paused;
76
+ const progress = (_d = (_c = this.challenge) === null || _c === void 0 ? void 0 : _c.LevelProgresses) === null || _d === void 0 ? void 0 : _d.find((x) => (x === null || x === void 0 ? void 0 : x.ProgressStatus) === EChallengeProgressStatus.InProgress);
77
+ if (!this.checkAttrs()) {
78
+ const url = `${this.endpoint}/challenge/ChangeProgressStatus`;
79
+ const body = Object.assign(Object.assign({ DomainId: this.domain }, (this.session && { PlayerSessionId: this.session })), (join ? { ProgressToActivate: progress.LevelId } : { ProgressToDeactivate: progress.LevelId }));
80
+ this.actionLoading = true;
81
+ return fetch(url, {
82
+ method: 'POST',
83
+ headers: {
84
+ 'Content-Type': 'application/json'
85
+ },
86
+ body: JSON.stringify(body)
87
+ })
88
+ .then((res) => res.json())
89
+ .finally(() => (this.actionLoading = false));
90
+ }
91
+ };
92
+ this.handleTabClick = (index) => () => {
93
+ if (index === 0) {
94
+ setTimeout(() => {
95
+ this.scrollToActiveLevel();
96
+ }, 0);
97
+ }
98
+ if (index === 1) {
99
+ this.fetchGames();
100
+ }
101
+ this.activeTabIndex = index;
102
+ };
103
+ this.handleChallengesTabClick = (tabIndex) => () => {
104
+ window.postMessage({ type: 'GoToChallengesPage', tabIndex }, window.location.href);
105
+ };
106
+ this.getBackButtonText = () => {
107
+ return (h("span", { class: "back-button__text" }, this.isMobile ? translate('all', this.language) : translate('back', this.language)));
108
+ };
109
+ this.mbSource = undefined;
110
+ this.clientStyling = undefined;
111
+ this.endpoint = '';
112
+ this.domain = '';
113
+ this.session = '';
114
+ this.clientStylingUrl = undefined;
115
+ this.translationUrl = '';
116
+ this.language = 'en';
117
+ this.isUserAuthorized = true;
118
+ this.challengeId = '';
119
+ this.activeChallengeTabIndex = '0';
120
+ this.timeLeft = undefined;
121
+ this.activeTabIndex = 0;
122
+ this.actionLoading = false;
123
+ this.isMobile = false;
124
+ this.error = '';
125
+ this.hasError = false;
126
+ this.games = [];
127
+ this.gamesAreLoading = false;
128
+ this.challenge = undefined;
129
+ this.loading = false;
130
+ }
131
+ handleClientStylingChange(newValue, oldValue) {
132
+ if (newValue != oldValue) {
133
+ setClientStyling(this.stylingContainer, this.clientStyling);
134
+ }
135
+ }
136
+ handleClientStylingUrlChange(newValue, oldValue) {
137
+ if (newValue != oldValue) {
138
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
139
+ }
140
+ }
141
+ handleMbSourceChange(newValue, oldValue) {
142
+ if (newValue != oldValue) {
143
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
144
+ }
145
+ }
146
+ onEntityChange(newChallenge, previousChallenge) {
147
+ var _a, _b, _c, _d;
148
+ const newActiveProgressId = (_b = (_a = newChallenge === null || newChallenge === void 0 ? void 0 : newChallenge.LevelProgresses) === null || _a === void 0 ? void 0 : _a.find((level) => level.ProgressStatus === EChallengeProgressStatus.InProgress)) === null || _b === void 0 ? void 0 : _b.LevelId;
149
+ const prevActiveProgressId = (_d = (_c = previousChallenge === null || previousChallenge === void 0 ? void 0 : previousChallenge.LevelProgresses) === null || _c === void 0 ? void 0 : _c.find((level) => level.ProgressStatus === EChallengeProgressStatus.InProgress)) === null || _d === void 0 ? void 0 : _d.LevelId;
150
+ if (newActiveProgressId == prevActiveProgressId) {
151
+ setTimeout(() => {
152
+ this.scrollToActiveLevel();
153
+ }, 0);
154
+ }
155
+ }
156
+ scrollToActiveLevel() {
157
+ if (this.activeEntityRef) {
158
+ const container = this.scrollContainerRef;
159
+ const target = this.activeEntityRef;
160
+ const containerTop = container.getBoundingClientRect().top;
161
+ const targetTop = target.getBoundingClientRect().top;
162
+ const scrollOffset = targetTop - containerTop;
163
+ container.scrollTo({
164
+ top: container.scrollTop + scrollOffset - container.clientHeight / 2 + target.clientHeight / 2,
165
+ behavior: 'smooth'
166
+ });
167
+ }
168
+ }
169
+ connectedCallback() {
170
+ this.timerId = setInterval(() => {
171
+ this.updateTime();
172
+ }, 1000);
173
+ }
174
+ async getChallenge() {
175
+ if (!this.checkAttrs()) {
176
+ const url = `${this.endpoint}/challenge/GetChallengesInfo`;
177
+ const body = Object.assign({ DomainId: this.domain, PlayerLanguage: this.language, PageNumber: 1, PageSize: 1, ChallengeId: this.challengeId }, (this.session && { PlayerSessionId: this.session }));
178
+ this.loading = true;
179
+ return fetch(url, {
180
+ method: 'POST',
181
+ headers: {
182
+ 'Content-Type': 'application/json'
183
+ },
184
+ body: JSON.stringify(body)
185
+ })
186
+ .then((res) => res.json())
187
+ .then((res) => {
188
+ this.challenge = res.Data[0];
189
+ })
190
+ .finally(() => (this.loading = false));
191
+ }
192
+ }
193
+ componentWillLoad() {
194
+ if (this.translationUrl) {
195
+ resolveTranslationUrl(this.translationUrl);
196
+ }
197
+ this.updateTime();
198
+ }
199
+ componentDidLoad() {
200
+ if (this.stylingContainer) {
201
+ if (this.mbSource)
202
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
203
+ if (this.clientStyling)
204
+ setClientStyling(this.stylingContainer, this.clientStyling);
205
+ if (this.clientStylingUrl)
206
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
207
+ }
208
+ this.getChallenge();
209
+ this.checkIsMobile();
210
+ window.addEventListener('resize', this.checkIsMobile);
211
+ setTimeout(() => {
212
+ this.scrollToActiveLevel();
213
+ }, 0);
214
+ }
215
+ disconnectedCallback() {
216
+ if (this.stylingSubscription) {
217
+ this.stylingSubscription.unsubscribe();
218
+ }
219
+ clearInterval(this.timerId);
220
+ window.removeEventListener('resize', this.checkIsMobile);
221
+ }
222
+ getReward(level) {
223
+ return level.Rewards.map((r) => r.RewardDescription).join(' + ') || '-';
224
+ }
225
+ getTarget(level) {
226
+ var _a;
227
+ return this.calculateTargetValue(level, (_a = this.challenge) === null || _a === void 0 ? void 0 : _a.CurrencySymbol) || '-';
228
+ }
229
+ updateTime() {
230
+ var _a, _b;
231
+ if (this.challenge) {
232
+ this.timeLeft = getTimeLeft((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.ExpirationTime);
233
+ if (!this.timeLeft && this.timerExpired) {
234
+ clearInterval(this.timerId);
235
+ this.timerExpired.emit((_b = this.challenge) === null || _b === void 0 ? void 0 : _b.Id);
236
+ }
237
+ }
238
+ }
239
+ get getCardBadge() {
240
+ var _a;
241
+ if (this.timeLeft) {
242
+ return (h("div", { class: `details__general-info-timer-badge ${ChallengeStatusDictionary[(_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status]}` }, this.getBadgeContent()));
243
+ }
244
+ return null;
245
+ }
246
+ get actionButtonText() {
247
+ var _a;
248
+ if (this.isUserAuthorized) {
249
+ let buttonText;
250
+ switch ((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) {
251
+ case EChallengeStatus.Started:
252
+ buttonText = 'start';
253
+ break;
254
+ case EChallengeStatus.Paused:
255
+ buttonText = 'resume';
256
+ break;
257
+ case EChallengeStatus.InProgress:
258
+ buttonText = 'resume';
259
+ break;
260
+ case EChallengeStatus.PendingLevelReward:
261
+ buttonText = 'pause';
262
+ break;
263
+ default:
264
+ buttonText = 'start';
265
+ break;
266
+ }
267
+ return buttonText;
268
+ }
269
+ return 'join';
270
+ }
271
+ openLoginRegisterModal() {
272
+ window.postMessage({
273
+ type: 'OpenLoginRegisterModal',
274
+ transition: 'Login'
275
+ });
276
+ }
277
+ async fetchGames() {
278
+ var _a;
279
+ if (!this.checkAttrs()) {
280
+ const url = `${this.endpoint}/challenge/GetChallengeGames`;
281
+ const body = Object.assign({ ChallengeId: (_a = this.challenge) === null || _a === void 0 ? void 0 : _a.ChallengeId }, (this.session && { PlayerSessionId: this.session }));
282
+ this.gamesAreLoading = true;
283
+ return fetch(url, {
284
+ method: 'POST',
285
+ headers: {
286
+ 'Content-Type': 'application/json'
287
+ },
288
+ body: JSON.stringify(body)
289
+ })
290
+ .then((res) => res.json())
291
+ .then((res) => {
292
+ this.games = res.ChallengeGames;
293
+ })
294
+ .finally(() => (this.gamesAreLoading = false));
295
+ }
296
+ }
297
+ getLevelStatus(level, active) {
298
+ if (this.isUserAuthorized) {
299
+ if (level.ProgressStatus === EChallengeProgressStatus.InProgress && !active)
300
+ return (h("div", { class: "level__status" }, h("span", null, level.ProgressPercentage, "%"), h("img", { src: lockIcon, alt: "lock-icon", title: "lock-icon" })));
301
+ else if (level.ProgressStatus === EChallengeProgressStatus.Closed || !active)
302
+ return (h("div", { class: "level__status" }, h("img", { src: lockIcon, alt: "lock-icon", title: "lock-icon" })));
303
+ else if (level.ProgressStatus === EChallengeProgressStatus.Fillup)
304
+ return (h("div", { class: "level__status" }, h("img", { src: lockIcon, alt: "lock-icon", title: "lock-icon" })));
305
+ else if (level.ProgressStatus === EChallengeProgressStatus.Completed)
306
+ return h("span", { class: "completed" }, translate('completed', this.language));
307
+ else if (level.ProgressStatus === EChallengeProgressStatus.InProgress)
308
+ return h("span", { class: "level__status in-progress" }, level.ProgressPercentage, "%");
309
+ }
310
+ return null;
311
+ }
312
+ get pageHeader() {
313
+ return (h("div", { class: "challenges-header" }, h("h1", { class: "challenges-title" }, h("img", { src: titleIcon, alt: "icon" }), translate('title', this.language)), this.isUserAuthorized && (h("div", { class: "challenges-tabs" }, this.challengesTabs.map((label, index) => (h("div", { class: `challenges-tab ${index === +this.activeChallengeTabIndex ? 'active' : ''}`, onClick: this.handleChallengesTabClick(index) }, label, this.showNotification === index && h("img", { src: notificationIcon }))))))));
314
+ }
315
+ get cardGeneralInfo() {
316
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
317
+ return (h("div", { class: "details__general-info" }, h("div", { class: "details__general-info-image-container" }, h("img", { class: {
318
+ 'details__general-info-image': true,
319
+ grayed: [EChallengeStatus.Expired, EChallengeStatus.Forfeited, EChallengeStatus.Completed].includes((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status)
320
+ }, src: (_c = (_b = this.challenge) === null || _b === void 0 ? void 0 : _b.ChallengePresentation) === null || _c === void 0 ? void 0 : _c.BannerUrl, alt: "banner-image", title: "banner-image" }), this.getCardBadge), h("div", { class: "details__general-info-content" }, h("h1", { class: "details__general-info-title" }, (_e = (_d = this.challenge) === null || _d === void 0 ? void 0 : _d.ChallengePresentation) === null || _e === void 0 ? void 0 : _e.PresentationName), h("h3", { class: "details__general-info-end-date_label" }, translate('endDate', this.language), " -", ' ', h("span", { class: "details__general-info-end-date_value" }, this.challenge ? formatDate((_f = this.challenge) === null || _f === void 0 ? void 0 : _f.ExpirationTime) : '-')), h("casino-challenge-progress-bar", { challenge: this.challenge, isUserAuthorized: this.isUserAuthorized, language: this.language }), h("button", { class: {
321
+ 'details__general-info-action-button': true,
322
+ filled: ((_g = this.challenge) === null || _g === void 0 ? void 0 : _g.Status) === EChallengeStatus.Started,
323
+ grayed: ((_h = this.challenge) === null || _h === void 0 ? void 0 : _h.Status) === EChallengeStatus.Paused ||
324
+ ((_j = this.challenge) === null || _j === void 0 ? void 0 : _j.Status) === EChallengeStatus.InProgress ||
325
+ ((_k = this.challenge) === null || _k === void 0 ? void 0 : _k.Status) === EChallengeStatus.PendingLevelReward
326
+ }, disabled: this.actionLoading, onClick: this.joinUnjoinProgress }, translate(this.actionButtonText, this.language)))));
327
+ }
328
+ get challengeTabs() {
329
+ return (h("div", { class: "details__tabs" }, this.tabs.map((label, index) => (h("div", { class: {
330
+ details__tab: true,
331
+ active: index === this.activeTabIndex
332
+ }, onClick: this.handleTabClick(index) }, label))), h("div", { class: "active-tab-indicator" })));
333
+ }
334
+ get levelsTab() {
335
+ var _a, _b;
336
+ return (h("div", { class: "levels__tab", ref: (el) => (this.scrollContainerRef = el) }, (_b = (_a = this.challenge) === null || _a === void 0 ? void 0 : _a.LevelProgresses) === null || _b === void 0 ? void 0 : _b.map((level, index) => {
337
+ var _a;
338
+ const activeChallenge = [0, 1, 2, 3].includes((_a = this === null || this === void 0 ? void 0 : this.challenge) === null || _a === void 0 ? void 0 : _a.Status);
339
+ const isGrayed = (this.isUserAuthorized && level.ProgressStatus !== EChallengeProgressStatus.InProgress) || !activeChallenge;
340
+ const isActiveMatch = level.ProgressStatus === EChallengeProgressStatus.InProgress;
341
+ return (h("div", { class: {
342
+ level: true,
343
+ active: this.isUserAuthorized &&
344
+ activeChallenge &&
345
+ level.ProgressStatus === EChallengeProgressStatus.InProgress,
346
+ completed: this.isUserAuthorized &&
347
+ activeChallenge &&
348
+ level.ProgressStatus === EChallengeProgressStatus.Completed,
349
+ grayed: this.isUserAuthorized &&
350
+ (level.ProgressStatus === EChallengeProgressStatus.Closed ||
351
+ level.ProgressStatus === EChallengeProgressStatus.Fillup)
352
+ }, ref: isActiveMatch ? (el) => (this.activeEntityRef = el) : undefined, key: level.LevelId }, h("div", { class: {
353
+ level__title: true,
354
+ grayed: isGrayed
355
+ } }, h("span", null, "Level ", index + 1), this.isUserAuthorized && this.getLevelStatus(level, activeChallenge)), this.isUserAuthorized && level.ProgressStatus === EChallengeProgressStatus.InProgress && (h("div", { class: "level__progress" }, h("casino-challenge-level-progress-bar", { height: "8px", value: level.ProgressPercentage, active: activeChallenge }))), h("casino-challenge-expandable-paragraph", { "max-height": "56", active: level.ProgressStatus === EChallengeProgressStatus.InProgress && activeChallenge }, h("div", { class: {
356
+ level__bonus: true,
357
+ grayed: isGrayed
358
+ } }, h("span", { class: "level__icon" }, h("img", { class: {
359
+ grayed: isGrayed
360
+ }, src: giftIcon, alt: "gift-icon", title: "gift-icon" })), h("span", { class: {
361
+ level__value: true,
362
+ grayed: isGrayed
363
+ } }, this.getTarget(level))), h("div", { class: {
364
+ level__target: true,
365
+ grayed: isGrayed
366
+ } }, h("span", { class: "level__icon" }, h("img", { class: {
367
+ grayed: isGrayed
368
+ }, src: targetIcon, alt: "target-icon", title: "target-icon" })), h("span", { class: {
369
+ level__value: true,
370
+ grayed: isGrayed
371
+ } }, this.getReward(level))))));
372
+ })));
373
+ }
374
+ handleGameClick(game) {
375
+ if (!this.isUserAuthorized) {
376
+ this.openLoginRegisterModal();
377
+ return;
378
+ }
379
+ window.postMessage({
380
+ type: 'GameClick',
381
+ detail: {
382
+ ClientCompatibility: game.ClientCompatibility,
383
+ GameId: game.GameId,
384
+ GameName: game.GameName,
385
+ GameLaunchUrl: game.GameLaunchUrl,
386
+ RestrictedCountries: game.RestrictedCountries,
387
+ Vendor: game.Vendor
388
+ }
389
+ });
390
+ }
391
+ get gamesTab() {
392
+ return (h("div", { class: "games__tab" }, this.gamesAreLoading ? (h("div", { class: "lds-dual-ring" })) : (this.games.map((game) => {
393
+ return (h("div", { class: "game", onClick: () => this.handleGameClick(game) }, h("img", { src: game.GameIcon, alt: "game-icon", title: "game-icon" }), h("span", { class: "contribution" }, translate('contribution', this.language), " ", game.Contribution, "%")));
394
+ }))));
395
+ }
396
+ get rulesTab() {
397
+ var _a, _b, _c, _d;
398
+ return (h("div", { class: "rules__tab" }, h("div", { class: "rule" }, (_b = (_a = this.challenge) === null || _a === void 0 ? void 0 : _a.ChallengePresentation) === null || _b === void 0 ? void 0 : _b.Description), h("a", { class: "link", href: (_d = (_c = this.challenge) === null || _c === void 0 ? void 0 : _c.ChallengePresentation) === null || _d === void 0 ? void 0 : _d.Url, target: "_blank" }, translate('terms', this.language))));
399
+ }
400
+ get footer() {
401
+ var _a, _b, _c, _d;
402
+ return (h("div", { class: "button__container" }, h("button", { class: {
403
+ 'footer-action-button': true,
404
+ filled: ((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) === EChallengeStatus.Started || !this.isUserAuthorized,
405
+ grayed: this.isUserAuthorized &&
406
+ (((_b = this.challenge) === null || _b === void 0 ? void 0 : _b.Status) === EChallengeStatus.Paused ||
407
+ ((_c = this.challenge) === null || _c === void 0 ? void 0 : _c.Status) === EChallengeStatus.InProgress ||
408
+ ((_d = this.challenge) === null || _d === void 0 ? void 0 : _d.Status) === EChallengeStatus.PendingLevelReward)
409
+ }, onClick: this.joinUnjoinProgress, disabled: this.actionLoading }, translate(this.actionButtonText, this.language))));
410
+ }
411
+ get forfeitedNofitication() {
412
+ var _a;
413
+ return (((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) === 5 && (h("div", { class: "notification" }, h("img", { class: "notification__icon", src: alertIcon }), h("span", { class: "notification__message" }, translate('forfeitNotification', this.language)))));
414
+ }
415
+ get completedNotification() {
416
+ var _a;
417
+ return (((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) === 3 && (h("div", { class: "notification" }, h("img", { class: "notification__icon", src: checkIcon }), h("div", { class: "notification__column" }, h("span", { class: "notification__title" }, translate('congrats', this.language)), h("span", { class: "notification__message" }, translate('completedNofitication', this.language))))));
418
+ }
419
+ get expiredNotification() {
420
+ var _a;
421
+ return (((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) === 4 && (h("div", { class: "notification" }, h("img", { class: "notification__icon", src: infoIcon }), h("span", { class: "notification__message" }, translate('expiredNotification', this.language)))));
422
+ }
423
+ render() {
424
+ return (h("div", { key: 'ac5dde048e4d00efd0a174bb3b077ecc5e7abce7', ref: (el) => (this.stylingContainer = el), class: "container" }, this.pageHeader, this.loading ? (h("div", { class: "lds-dual-ring" })) : (h("div", null, h("button", { class: "back-button" }, h("img", { class: "back-button__icon", src: backIcon }), this.getBackButtonText()), this.forfeitedNofitication, this.completedNotification, this.expiredNotification, h("div", { class: "details" }, this.cardGeneralInfo, h("div", { class: "details__tabs-container" }, this.challengeTabs, this.activeTabIndex === 0 && this.levelsTab, this.activeTabIndex === 1 && this.gamesTab, this.activeTabIndex === 2 && this.rulesTab), this.footer)))));
425
+ }
426
+ static get is() { return "casino-challenge-details"; }
427
+ static get encapsulation() { return "shadow"; }
428
+ static get originalStyleUrls() {
429
+ return {
430
+ "$": ["casino-challenge-details.scss"]
431
+ };
432
+ }
433
+ static get styleUrls() {
434
+ return {
435
+ "$": ["casino-challenge-details.css"]
436
+ };
437
+ }
438
+ static get properties() {
439
+ return {
440
+ "mbSource": {
441
+ "type": "string",
442
+ "mutable": false,
443
+ "complexType": {
444
+ "original": "string",
445
+ "resolved": "string",
446
+ "references": {}
447
+ },
448
+ "required": false,
449
+ "optional": false,
450
+ "docs": {
451
+ "tags": [],
452
+ "text": "Client custom styling via message bus"
453
+ },
454
+ "attribute": "mb-source",
455
+ "reflect": true
456
+ },
457
+ "clientStyling": {
458
+ "type": "string",
459
+ "mutable": false,
460
+ "complexType": {
461
+ "original": "string",
462
+ "resolved": "string",
463
+ "references": {}
464
+ },
465
+ "required": false,
466
+ "optional": false,
467
+ "docs": {
468
+ "tags": [],
469
+ "text": "Client custom styling via string"
470
+ },
471
+ "attribute": "client-styling",
472
+ "reflect": true
473
+ },
474
+ "endpoint": {
475
+ "type": "string",
476
+ "mutable": false,
477
+ "complexType": {
478
+ "original": "string",
479
+ "resolved": "string",
480
+ "references": {}
481
+ },
482
+ "required": false,
483
+ "optional": false,
484
+ "docs": {
485
+ "tags": [],
486
+ "text": "Client endpoint to fetch data"
487
+ },
488
+ "attribute": "endpoint",
489
+ "reflect": true,
490
+ "defaultValue": "''"
491
+ },
492
+ "domain": {
493
+ "type": "string",
494
+ "mutable": false,
495
+ "complexType": {
496
+ "original": "string",
497
+ "resolved": "string",
498
+ "references": {}
499
+ },
500
+ "required": false,
501
+ "optional": false,
502
+ "docs": {
503
+ "tags": [],
504
+ "text": "Domain Id"
505
+ },
506
+ "attribute": "domain",
507
+ "reflect": true,
508
+ "defaultValue": "''"
509
+ },
510
+ "session": {
511
+ "type": "string",
512
+ "mutable": false,
513
+ "complexType": {
514
+ "original": "string",
515
+ "resolved": "string",
516
+ "references": {}
517
+ },
518
+ "required": false,
519
+ "optional": false,
520
+ "docs": {
521
+ "tags": [],
522
+ "text": "User session Id"
523
+ },
524
+ "attribute": "session",
525
+ "reflect": true,
526
+ "defaultValue": "''"
527
+ },
528
+ "clientStylingUrl": {
529
+ "type": "string",
530
+ "mutable": false,
531
+ "complexType": {
532
+ "original": "string",
533
+ "resolved": "string",
534
+ "references": {}
535
+ },
536
+ "required": false,
537
+ "optional": false,
538
+ "docs": {
539
+ "tags": [],
540
+ "text": "Client custom styling via css file url"
541
+ },
542
+ "attribute": "client-styling-url",
543
+ "reflect": true
544
+ },
545
+ "translationUrl": {
546
+ "type": "string",
547
+ "mutable": false,
548
+ "complexType": {
549
+ "original": "string",
550
+ "resolved": "string",
551
+ "references": {}
552
+ },
553
+ "required": false,
554
+ "optional": false,
555
+ "docs": {
556
+ "tags": [],
557
+ "text": "Client custom translation via json file url"
558
+ },
559
+ "attribute": "translation-url",
560
+ "reflect": true,
561
+ "defaultValue": "''"
562
+ },
563
+ "language": {
564
+ "type": "string",
565
+ "mutable": false,
566
+ "complexType": {
567
+ "original": "string",
568
+ "resolved": "string",
569
+ "references": {}
570
+ },
571
+ "required": false,
572
+ "optional": false,
573
+ "docs": {
574
+ "tags": [],
575
+ "text": "Client custom language for translation"
576
+ },
577
+ "attribute": "language",
578
+ "reflect": true,
579
+ "defaultValue": "'en'"
580
+ },
581
+ "isUserAuthorized": {
582
+ "type": "boolean",
583
+ "mutable": false,
584
+ "complexType": {
585
+ "original": "boolean",
586
+ "resolved": "boolean",
587
+ "references": {}
588
+ },
589
+ "required": false,
590
+ "optional": false,
591
+ "docs": {
592
+ "tags": [],
593
+ "text": "Is User authorized"
594
+ },
595
+ "attribute": "is-user-authorized",
596
+ "reflect": true,
597
+ "defaultValue": "true"
598
+ },
599
+ "challengeId": {
600
+ "type": "string",
601
+ "mutable": false,
602
+ "complexType": {
603
+ "original": "string",
604
+ "resolved": "string",
605
+ "references": {}
606
+ },
607
+ "required": false,
608
+ "optional": false,
609
+ "docs": {
610
+ "tags": [],
611
+ "text": "Challenge id"
612
+ },
613
+ "attribute": "challenge-id",
614
+ "reflect": true,
615
+ "defaultValue": "''"
616
+ },
617
+ "activeChallengeTabIndex": {
618
+ "type": "string",
619
+ "mutable": false,
620
+ "complexType": {
621
+ "original": "string",
622
+ "resolved": "string",
623
+ "references": {}
624
+ },
625
+ "required": false,
626
+ "optional": false,
627
+ "docs": {
628
+ "tags": [],
629
+ "text": "Challenges active tab index"
630
+ },
631
+ "attribute": "active-challenge-tab-index",
632
+ "reflect": true,
633
+ "defaultValue": "'0'"
634
+ }
635
+ };
636
+ }
637
+ static get states() {
638
+ return {
639
+ "timeLeft": {},
640
+ "activeTabIndex": {},
641
+ "actionLoading": {},
642
+ "isMobile": {},
643
+ "error": {},
644
+ "hasError": {},
645
+ "games": {},
646
+ "gamesAreLoading": {},
647
+ "challenge": {},
648
+ "loading": {}
649
+ };
650
+ }
651
+ static get events() {
652
+ return [{
653
+ "method": "timerExpired",
654
+ "name": "timerExpired",
655
+ "bubbles": true,
656
+ "cancelable": true,
657
+ "composed": true,
658
+ "docs": {
659
+ "tags": [],
660
+ "text": ""
661
+ },
662
+ "complexType": {
663
+ "original": "any",
664
+ "resolved": "any",
665
+ "references": {}
666
+ }
667
+ }];
668
+ }
669
+ static get watchers() {
670
+ return [{
671
+ "propName": "clientStyling",
672
+ "methodName": "handleClientStylingChange"
673
+ }, {
674
+ "propName": "clientStylingUrl",
675
+ "methodName": "handleClientStylingUrlChange"
676
+ }, {
677
+ "propName": "mbSource",
678
+ "methodName": "handleMbSourceChange"
679
+ }, {
680
+ "propName": "challenge",
681
+ "methodName": "onEntityChange"
682
+ }];
683
+ }
684
+ }