@everymatrix/casino-engagement-suite-challenges-details 1.43.4 → 1.45.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 (57) hide show
  1. package/dist/casino-engagement-suite-challenges-details/casino-engagement-suite-challenges-details.esm.js +1 -1
  2. package/dist/casino-engagement-suite-challenges-details/p-11d8b487.js +2 -0
  3. package/dist/casino-engagement-suite-challenges-details/p-8bbfff73.entry.js +1 -0
  4. package/dist/casino-engagement-suite-challenges-details/p-e1255160.js +1 -0
  5. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  6. package/dist/cjs/casino-engagement-suite-challenges-details.cjs.js +17 -11
  7. package/dist/cjs/casino-engagement-suite-challenges-details_2.cjs.entry.js +293 -323
  8. package/dist/cjs/index-a758ba24.js +1249 -0
  9. package/dist/cjs/loader.cjs.js +7 -13
  10. package/dist/collection/collection-manifest.json +3 -3
  11. package/dist/collection/components/casino-engagement-suite-challenges-details/casino-engagement-suite-challenges-details.css +63 -61
  12. package/dist/collection/components/casino-engagement-suite-challenges-details/casino-engagement-suite-challenges-details.js +438 -493
  13. package/dist/collection/components/casino-engagement-suite-challenges-details/index.js +1 -0
  14. package/dist/collection/models/casino-challenges-details.js +10 -10
  15. package/dist/collection/utils/index.js +8 -2
  16. package/dist/collection/utils/locale.utils.js +18 -18
  17. package/dist/collection/utils/utils.js +3 -0
  18. package/dist/esm/app-globals-0f993ce5.js +3 -0
  19. package/dist/esm/casino-engagement-suite-challenges-details.js +14 -11
  20. package/dist/esm/casino-engagement-suite-challenges-details_2.entry.js +293 -323
  21. package/dist/esm/index-c193b756.js +1221 -0
  22. package/dist/esm/loader.js +7 -13
  23. package/dist/stencil.config.dev.js +17 -0
  24. package/dist/stencil.config.js +14 -19
  25. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/casino-engagement-suite-challenges-details/.stencil/packages/stencil/casino-engagement-suite-challenges-details/stencil.config.d.ts +2 -0
  26. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/casino-engagement-suite-challenges-details/.stencil/packages/stencil/casino-engagement-suite-challenges-details/stencil.config.dev.d.ts +2 -0
  27. package/dist/types/components/casino-engagement-suite-challenges-details/casino-engagement-suite-challenges-details.d.ts +70 -70
  28. package/dist/types/components/casino-engagement-suite-challenges-details/index.d.ts +1 -0
  29. package/dist/types/components.d.ts +21 -3
  30. package/dist/types/models/casino-challenges-details.d.ts +46 -46
  31. package/dist/types/stencil-public-runtime.d.ts +142 -33
  32. package/dist/types/utils/index.d.ts +1 -0
  33. package/dist/types/utils/utils.d.ts +1 -0
  34. package/loader/cdn.js +1 -3
  35. package/loader/index.cjs.js +1 -3
  36. package/loader/index.d.ts +13 -1
  37. package/loader/index.es2017.js +1 -3
  38. package/loader/index.js +1 -3
  39. package/loader/package.json +1 -0
  40. package/package.json +12 -2
  41. package/dist/casino-engagement-suite-challenges-details/p-80848cd8.entry.js +0 -1
  42. package/dist/casino-engagement-suite-challenges-details/p-808a7dc5.js +0 -1
  43. package/dist/cjs/index-a0eb9215.js +0 -1279
  44. package/dist/components/casino-engagement-suite-challenges-details.d.ts +0 -11
  45. package/dist/components/casino-engagement-suite-challenges-details.js +0 -318
  46. package/dist/components/casino-engagement-suite-progress-bar.js +0 -6
  47. package/dist/components/casino-engagement-suite-progress-bar2.js +0 -107
  48. package/dist/components/index.d.ts +0 -26
  49. package/dist/components/index.js +0 -1
  50. package/dist/esm/index-c5abae48.js +0 -1252
  51. package/dist/esm/polyfills/core-js.js +0 -11
  52. package/dist/esm/polyfills/css-shim.js +0 -1
  53. package/dist/esm/polyfills/dom.js +0 -79
  54. package/dist/esm/polyfills/es5-html-element.js +0 -1
  55. package/dist/esm/polyfills/index.js +0 -34
  56. package/dist/esm/polyfills/system.js +0 -6
  57. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-engagement-suite-challenges-details/.stencil/packages/casino-engagement-suite-challenges-details/stencil.config.d.ts +0 -2
@@ -1,507 +1,452 @@
1
- import { Component, h, Prop, State, Element, Event, Watch } from '@stencil/core';
2
- import { translate } from '../../utils/locale.utils';
3
- import { ChallengeProgressStatus } from '../../models/casino-challenges-details';
4
- import '@everymatrix/casino-engagement-suite-progress-bar';
5
- import { formatBalance } from '../../utils';
1
+ import { h } from "@stencil/core";
2
+ import { translate } from "../../utils/locale.utils";
3
+ import { ChallengeProgressStatus } from "../../models/casino-challenges-details";
4
+ import "../../../../../casino-engagement-suite-progress-bar/dist/types/index";
5
+ import { formatBalance } from "../../utils";
6
6
  export class CasinoEngagementSuiteChallengesDetails {
7
- constructor() {
8
- /**
9
- * Client custom styling via string
10
- */
11
- this.clientStyling = '';
12
- /**
13
- * Client custom styling via url
14
- */
15
- this.clientStylingUrl = '';
16
- /**
17
- * Language of the widget
18
- */
19
- this.language = 'en';
20
- /**
21
- * Current game slug
22
- */
23
- this.gameSlug = '';
24
- /**
25
- * User's device type
26
- */
27
- this.device = 'Mobile';
28
- /**
29
- *Paused Challenge Ids
30
- */
31
- this.pausedChallengeIds = [];
32
- this.limitStylingAppends = false;
33
- this.timer = '';
34
- this.showDetails = false;
35
- this.isExpiredChallenge = false;
36
- this.setClientStyling = () => {
37
- let sheet = document.createElement('style');
38
- sheet.innerHTML = this.clientStyling;
39
- this.host.prepend(sheet);
40
- };
41
- this.setClientStylingURL = () => {
42
- let url = new URL(this.clientStylingUrl);
43
- let cssFile = document.createElement('style');
44
- fetch(url.href)
45
- .then((res) => res.text())
46
- .then((data) => {
47
- cssFile.innerHTML = data;
48
- setTimeout(() => { this.host.prepend(cssFile); }, 1);
49
- })
50
- .catch((err) => {
51
- console.log('Error ', err);
52
- });
53
- };
54
- this.handleCloseClick = () => {
55
- this.resetNewLabel();
56
- this.close.emit();
57
- };
58
- this.handleBackClick = () => {
59
- this.resetNewLabel();
60
- this.back.emit();
61
- };
62
- this.onGameClick = (ev) => {
63
- const slug = ev.currentTarget.getAttribute('data-slug');
64
- if (slug) {
65
- window.postMessage({
66
- type: 'EngagementSuiteGameRedirect',
67
- data: {
68
- Slug: slug
69
- }
70
- });
71
- }
72
- };
73
- this.changeChallengeStatus = (e) => {
74
- var _a, _b;
75
- const id = e.currentTarget.getAttribute('data-id');
76
- if ((_a = this.inProgressChallenges) === null || _a === void 0 ? void 0 : _a.includes(id)) {
77
- window.postMessage({
78
- type: 'ShowConfirmationModal',
79
- ProgressToDeactivate: id,
80
- });
81
- return;
82
- }
83
- if (((_b = this.inProgressChallenges) === null || _b === void 0 ? void 0 : _b.length) > 0) {
84
- window.postMessage({
85
- type: 'ShowConfirmationModal',
86
- ProgressToActivate: id,
87
- ProgressToDeactivate: this.inProgressChallenges[0],
88
- });
89
- return;
90
- }
91
- window.postMessage({
92
- type: 'ChallengeJoinRequest',
93
- data: {
94
- ProgressToActivate: id,
95
- },
96
- });
97
- };
98
- this.toggle = () => {
99
- this.showDetails = !this.showDetails;
100
- };
101
- }
102
- challengePropHandler(value) {
103
- if (!this.interval && value) {
104
- this.updateTimer();
105
- this.startCountdown();
7
+ constructor() {
8
+ this.setClientStyling = () => {
9
+ let sheet = document.createElement('style');
10
+ sheet.innerHTML = this.clientStyling;
11
+ this.host.prepend(sheet);
12
+ };
13
+ this.setClientStylingURL = () => {
14
+ let url = new URL(this.clientStylingUrl);
15
+ let cssFile = document.createElement('style');
16
+ fetch(url.href)
17
+ .then((res) => res.text())
18
+ .then((data) => {
19
+ cssFile.innerHTML = data;
20
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
21
+ })
22
+ .catch((err) => {
23
+ console.log('Error ', err);
24
+ });
25
+ };
26
+ this.handleCloseClick = () => {
27
+ this.resetNewLabel();
28
+ this.close.emit();
29
+ };
30
+ this.handleBackClick = () => {
31
+ this.resetNewLabel();
32
+ this.back.emit();
33
+ };
34
+ this.onGameClick = (ev) => {
35
+ const slug = ev.currentTarget.getAttribute('data-slug');
36
+ if (slug) {
37
+ window.postMessage({
38
+ type: 'EngagementSuiteGameRedirect',
39
+ data: {
40
+ Slug: slug
41
+ }
42
+ });
43
+ }
44
+ };
45
+ this.changeChallengeStatus = (e) => {
46
+ var _a, _b;
47
+ const id = e.currentTarget.getAttribute('data-id');
48
+ if ((_a = this.inProgressChallenges) === null || _a === void 0 ? void 0 : _a.includes(id)) {
49
+ window.postMessage({
50
+ type: 'ShowConfirmationModal',
51
+ ProgressToDeactivate: id,
52
+ });
53
+ return;
54
+ }
55
+ if (((_b = this.inProgressChallenges) === null || _b === void 0 ? void 0 : _b.length) > 0) {
56
+ window.postMessage({
57
+ type: 'ShowConfirmationModal',
58
+ ProgressToActivate: id,
59
+ ProgressToDeactivate: this.inProgressChallenges[0],
60
+ });
61
+ return;
62
+ }
63
+ window.postMessage({
64
+ type: 'ChallengeJoinRequest',
65
+ data: {
66
+ ProgressToActivate: id,
67
+ },
68
+ });
69
+ };
70
+ this.toggle = () => {
71
+ this.showDetails = !this.showDetails;
72
+ };
73
+ this.clientStyling = '';
74
+ this.clientStylingUrl = '';
75
+ this.challenge = undefined;
76
+ this.inProgressChallenges = undefined;
77
+ this.language = 'en';
78
+ this.gameSlug = '';
79
+ this.device = 'Mobile';
80
+ this.isJoiningToChallenge = undefined;
81
+ this.pausedChallengeIds = [];
82
+ this.limitStylingAppends = false;
83
+ this.timer = '';
84
+ this.showDetails = false;
85
+ this.isExpiredChallenge = false;
106
86
  }
107
- if (this.interval && !value) {
108
- clearInterval(this.interval);
87
+ challengePropHandler(value) {
88
+ if (!this.interval && value) {
89
+ this.updateTimer();
90
+ this.startCountdown();
91
+ }
92
+ if (this.interval && !value) {
93
+ clearInterval(this.interval);
94
+ }
95
+ }
96
+ componentWillLoad() {
97
+ this.challengePropHandler(this.challenge);
98
+ }
99
+ componentDidRender() {
100
+ if (!this.limitStylingAppends && this.host) {
101
+ if (this.clientStyling)
102
+ this.setClientStyling();
103
+ if (this.clientStylingUrl)
104
+ this.setClientStylingURL();
105
+ this.limitStylingAppends = true;
106
+ }
109
107
  }
110
- }
111
- componentWillLoad() {
112
- this.challengePropHandler(this.challenge);
113
- }
114
- componentDidRender() {
115
- if (!this.limitStylingAppends && this.host) {
116
- if (this.clientStyling)
117
- this.setClientStyling();
118
- if (this.clientStylingUrl)
119
- this.setClientStylingURL();
120
- this.limitStylingAppends = true;
108
+ disconnectedCallback() {
109
+ this.interval && clearInterval(this.interval);
121
110
  }
122
- }
123
- disconnectedCallback() {
124
- this.interval && clearInterval(this.interval);
125
- }
126
- getActionsTemplate() {
127
- return (h("header", { class: "ChallengeActions" },
128
- h("button", { class: "ChallengeIconButton", onClick: this.handleBackClick },
129
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/back.svg", alt: "back" })),
130
- h("button", { class: "ChallengeIconButton", onClick: this.handleCloseClick },
131
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "close" }))));
132
- }
133
- getChallengeHeader() {
134
- const presentationName = this.challenge.ChallengePresentation.PresentationName;
135
- const inProgressChallenge = this.challenge.Status === ChallengeProgressStatus.InProgress
136
- || this.challenge.Status === ChallengeProgressStatus.PendingLevelReward;
137
- const isDisabledButton = this.isExpiredChallenge || this.isJoiningToChallenge ||
138
- this.pausedChallengeIds.includes(this.challenge.ChallengeId);
139
- const showJoinButton = ![ChallengeProgressStatus.Completed, ChallengeProgressStatus.Forfeited]
140
- .includes(this.challenge.Status);
141
- return (h("div", { class: "ChallengeDetailsHeader" },
142
- h("span", { class: "ChallengeName" }, presentationName),
143
- showJoinButton ? (h("button", { onClick: this.changeChallengeStatus, class: `ChallengeJoinButton ${inProgressChallenge ? 'Joined' : ''}
111
+ getActionsTemplate() {
112
+ return (h("header", { class: "ChallengeActions" }, h("button", { class: "EngagementSuiteIconButton Back", onClick: this.handleBackClick }), h("button", { class: "EngagementSuiteIconButton Close", onClick: this.handleCloseClick })));
113
+ }
114
+ getChallengeHeader() {
115
+ const presentationName = this.challenge.ChallengePresentation.PresentationName;
116
+ const inProgressChallenge = this.challenge.Status === ChallengeProgressStatus.InProgress
117
+ || this.challenge.Status === ChallengeProgressStatus.PendingLevelReward;
118
+ const isDisabledButton = this.isExpiredChallenge || this.isJoiningToChallenge ||
119
+ this.pausedChallengeIds.includes(this.challenge.ChallengeId);
120
+ const showJoinButton = ![ChallengeProgressStatus.Completed, ChallengeProgressStatus.Forfeited]
121
+ .includes(this.challenge.Status);
122
+ const showNewLabel = this.challenge.Status !== ChallengeProgressStatus.Forfeited;
123
+ return (h("div", { class: "ChallengeDetailsHeader" }, h("span", { class: "ChallengeName" }, presentationName), showJoinButton ? (h("button", { onClick: this.changeChallengeStatus, class: `EngagementSuiteButton ${inProgressChallenge ? 'Active' : ''}
144
124
  ${isDisabledButton ? 'Disabled' : ''}`, "data-id": this.challenge.Id }, inProgressChallenge
145
- ? translate('unjoin', this.language)
146
- : translate('join', this.language))) : null,
147
- h("div", { class: `ChallengeLabel ${this.challenge.IsNew ? 'ShowChallengeLabel' : ''}` },
148
- h("span", null, translate('new', this.language)))));
149
- }
150
- getChallengeCountdown() {
151
- const timerMessage = this.isExpiredChallenge ? 'Expired' : this.timer;
152
- const showChallengeCountdown = this.challenge.Status !== ChallengeProgressStatus.Forfeited;
153
- return (showChallengeCountdown ? (h("div", { class: `ChallengeCountdown ${this.isExpiredChallenge ? 'Expired' : ''}` }, timerMessage)) : null);
154
- }
155
- getChallengeDetails() {
156
- const description = this.challenge.ChallengePresentation.Description;
157
- const url = this.challenge.ChallengePresentation.Url;
158
- const games = this.challenge.Games;
159
- return (h("div", { class: `CollapseDetails ${this.showDetails ? 'ShowDetails' : ''}` },
160
- description && h("div", { class: "ChallengeDescription" }, description),
161
- url && (h("div", { class: "TC" },
162
- h("a", { href: url, target: "_blank" }, translate('tc', this.language)))),
163
- (games === null || games === void 0 ? void 0 : games.length) && (h("div", { class: "ChallengeGames" }, games.map((game) => (h("div", { class: "Game", key: game.CasinoGameId },
164
- h("img", { src: game.GameIcon, alt: game.GameName, onClick: this.onGameClick, class: `${game.GameSlug === this.gameSlug ? 'Disabled' : ''}`, "data-slug": game.GameSlug }))))))));
165
- }
166
- resetNewLabel() {
167
- this.resetNewChallengeLabel.emit(this.challenge.Id);
168
- }
169
- startCountdown() {
170
- this.interval = setInterval(() => {
171
- this.updateTimer();
172
- }, 1000);
173
- }
174
- updateTimer() {
175
- const expirationTime = new Date(this.challenge.ExpirationTime).getTime();
176
- const now = new Date().getTime();
177
- const distance = expirationTime - now;
178
- if (distance < 1) {
179
- clearInterval(this.interval);
180
- this.timer = '';
181
- this.isExpiredChallenge = true;
182
- return;
125
+ ? translate('unjoin', this.language)
126
+ : translate('join', this.language))) : null, showNewLabel ? (h("div", { class: `ChallengeLabel ${this.challenge.IsNew ? 'ShowChallengeLabel' : ''}` }, h("span", null, translate('new', this.language)))) : null));
127
+ }
128
+ getChallengeCountdown() {
129
+ const timerMessage = this.isExpiredChallenge ? 'Expired' : this.timer;
130
+ const showChallengeCountdown = this.challenge.Status !== ChallengeProgressStatus.Forfeited;
131
+ return (showChallengeCountdown ? (h("div", { class: `ChallengeCountdown ${this.isExpiredChallenge ? 'Expired' : ''}` }, timerMessage)) : null);
183
132
  }
184
- const { days, hours, minutes, seconds } = {
185
- days: String(Math.floor(distance / (1000 * 60 * 60 * 24))).padStart(2, '0'),
186
- hours: String(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
187
- minutes: String(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
188
- seconds: String(Math.floor((distance % (1000 * 60)) / 1000)).padStart(2, '0')
189
- };
190
- this.timer = days === '00'
191
- ? `${hours}h:${minutes}m:${seconds}s`
192
- : `${days}d:${hours}h:${minutes}m`;
193
- }
194
- getLevelTarget(level) {
195
- const targetTurnover = formatBalance(level.DisplayCurrencyTargetTurnover, this.challenge.CurrencySymbol);
196
- let levelTarget = `${translate('place', this.language)} ${targetTurnover}`;
197
- if (level.LevelTargetType === 1) {
198
- levelTarget += ` ${translate('bet', this.language)}`;
133
+ getChallengeDetails() {
134
+ const description = this.challenge.ChallengePresentation.Description;
135
+ const url = this.challenge.ChallengePresentation.Url;
136
+ const games = this.challenge.Games;
137
+ return (h("div", { class: `CollapseDetails ${this.showDetails ? 'ShowDetails' : ''}` }, description && h("div", { class: "ChallengeDescription" }, description), url && (h("div", { class: "TC" }, h("a", { href: url, target: "_blank" }, translate('tc', this.language)))), (games === null || games === void 0 ? void 0 : games.length) && (h("div", { class: "ChallengeGames" }, games.map((game) => (h("div", { class: "Game", key: game.CasinoGameId }, h("img", { src: game.GameIcon, alt: game.GameName, onClick: this.onGameClick, class: `${game.GameSlug === this.gameSlug ? 'Disabled' : ''}`, "data-slug": game.GameSlug }))))))));
199
138
  }
200
- else if (level.LevelTargetType === 2) {
201
- levelTarget += ` ${translate('bets', this.language)} X ${level.TargetBetCount}`;
139
+ resetNewLabel() {
140
+ this.resetNewChallengeLabel.emit(this.challenge.Id);
202
141
  }
203
- return (h("span", { class: "ChallengeLevelTarget" }, levelTarget));
204
- }
205
- getLevelBetRangesDetails(level) {
206
- var _a, _b, _c, _d;
207
- const isAccumulativeLevelType = level.LevelTargetType === 0;
208
- if (isAccumulativeLevelType) {
209
- const formattedMinBet = formatBalance((_a = level.BetRange) === null || _a === void 0 ? void 0 : _a.MinBet, this.challenge.CurrencySymbol);
210
- const formattedMaxBet = formatBalance((_b = level.BetRange) === null || _b === void 0 ? void 0 : _b.MaxBet, this.challenge.CurrencySymbol);
211
- const formattedContributionPercentage = level.LevelContributionPercent + '%';
212
- const showMinBet = !!((_c = level.BetRange) === null || _c === void 0 ? void 0 : _c.MinBet);
213
- const showMaxBet = !!((_d = level.BetRange) === null || _d === void 0 ? void 0 : _d.MaxBet);
214
- const showContributionPercentage = level.LevelContributionPercent !== 100;
215
- if (showMinBet || showMaxBet || showContributionPercentage) {
216
- return (h("div", { class: 'ChallengeLevelBetDetails' },
217
- showMinBet &&
218
- h("div", { class: 'ChallengeLevelBetDetail' },
219
- h("span", null,
220
- translate('minBet', this.language),
221
- ": "),
222
- h("span", { class: 'ChallengeLevelBetRange' }, formattedMinBet)),
223
- showMaxBet &&
224
- h("div", { class: 'ChallengeLevelBetDetail' },
225
- h("span", null,
226
- translate('maxBet', this.language),
227
- ": "),
228
- h("span", { class: 'ChallengeLevelBetRange' }, formattedMaxBet)),
229
- showContributionPercentage &&
230
- h("div", { class: 'ChallengeLevelBetDetail' },
231
- h("span", null,
232
- translate('contribution', this.language),
233
- ": "),
234
- h("span", { class: 'ChallengeLevelBetContribution' }, formattedContributionPercentage))));
235
- }
142
+ startCountdown() {
143
+ this.interval = setInterval(() => {
144
+ this.updateTimer();
145
+ }, 1000);
236
146
  }
237
- }
238
- getChallengeLevels() {
239
- const isChallengePaused = this.pausedChallengeIds.includes(this.challenge.ChallengeId);
240
- const InProgressLevel = (level) => {
241
- return level.ProgressStatus === 1 && !this.isExpiredChallenge && !isChallengePaused;
242
- };
243
- return (h("div", { class: "ChallengeLevels" }, this.challenge.LevelProgresses.map((level, index) => (h("div", { class: `ChallengeLevelCard ${InProgressLevel(level) ? 'InProgress' : ''}` },
244
- h("casino-engagement-suite-progress-bar", { class: this.device, value: level.ProgressPercentage, "hide-percent": (level.ProgressPercentage === 0 && !InProgressLevel(level)) || level.ProgressPercentage === 100, disabled: this.isExpiredChallenge || isChallengePaused },
245
- h("span", { slot: "Title", class: "ChallengeLevelTitle" },
246
- h("span", null,
247
- "Level ",
248
- index + 1,
249
- ": "),
250
- this.getLevelTarget(level))),
251
- h("div", { class: "ChallengeRewardMessage" },
252
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/reward.svg", alt: "win" }),
253
- h("span", null,
254
- translate('win', this.language),
255
- ": "),
256
- h("span", { class: "CustomRewardMessage" }, level.CustomRewardMessage)),
257
- this.getLevelBetRangesDetails(level))))));
258
- }
259
- getToggleButton() {
260
- return (h("div", { class: "ChallengeCollapseButton", onClick: this.toggle },
261
- h("span", { class: `Toggle ${this.showDetails ? 'Closed' : 'Open'}` }),
262
- h("span", null, translate('details', this.language))));
263
- }
264
- render() {
265
- return h("div", { class: `ChallengeDetailsPopup ${this.device}` },
266
- this.getActionsTemplate(),
267
- h("div", { class: `ChallengeDetails ${this.challenge.IsNew ? 'IsNewChallenge' : ''}` },
268
- this.getChallengeHeader(),
269
- this.getChallengeCountdown(),
270
- this.getToggleButton(),
271
- this.getChallengeDetails(),
272
- this.getChallengeLevels()));
273
- }
274
- static get is() { return "casino-engagement-suite-challenges-details"; }
275
- static get encapsulation() { return "shadow"; }
276
- static get originalStyleUrls() { return {
277
- "$": ["casino-engagement-suite-challenges-details.scss"]
278
- }; }
279
- static get styleUrls() { return {
280
- "$": ["casino-engagement-suite-challenges-details.css"]
281
- }; }
282
- static get properties() { return {
283
- "clientStyling": {
284
- "type": "string",
285
- "mutable": false,
286
- "complexType": {
287
- "original": "string",
288
- "resolved": "string",
289
- "references": {}
290
- },
291
- "required": false,
292
- "optional": false,
293
- "docs": {
294
- "tags": [],
295
- "text": "Client custom styling via string"
296
- },
297
- "attribute": "client-styling",
298
- "reflect": true,
299
- "defaultValue": "''"
300
- },
301
- "clientStylingUrl": {
302
- "type": "string",
303
- "mutable": false,
304
- "complexType": {
305
- "original": "string",
306
- "resolved": "string",
307
- "references": {}
308
- },
309
- "required": false,
310
- "optional": false,
311
- "docs": {
312
- "tags": [],
313
- "text": "Client custom styling via url"
314
- },
315
- "attribute": "client-styling-url",
316
- "reflect": true,
317
- "defaultValue": "''"
318
- },
319
- "challenge": {
320
- "type": "unknown",
321
- "mutable": true,
322
- "complexType": {
323
- "original": "Challenge",
324
- "resolved": "Challenge",
325
- "references": {
326
- "Challenge": {
327
- "location": "import",
328
- "path": "../../models/casino-challenges-details"
329
- }
147
+ updateTimer() {
148
+ const expirationTime = new Date(this.challenge.ExpirationTime).getTime();
149
+ const now = new Date().getTime();
150
+ const distance = expirationTime - now;
151
+ if (distance < 1) {
152
+ clearInterval(this.interval);
153
+ this.timer = '';
154
+ this.isExpiredChallenge = true;
155
+ return;
330
156
  }
331
- },
332
- "required": false,
333
- "optional": false,
334
- "docs": {
335
- "tags": [],
336
- "text": "Selected challenge"
337
- }
338
- },
339
- "inProgressChallenges": {
340
- "type": "unknown",
341
- "mutable": true,
342
- "complexType": {
343
- "original": "Array<string>",
344
- "resolved": "string[]",
345
- "references": {
346
- "Array": {
347
- "location": "global"
348
- }
157
+ const { days, hours, minutes, seconds } = {
158
+ days: String(Math.floor(distance / (1000 * 60 * 60 * 24))).padStart(2, '0'),
159
+ hours: String(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
160
+ minutes: String(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
161
+ seconds: String(Math.floor((distance % (1000 * 60)) / 1000)).padStart(2, '0')
162
+ };
163
+ this.timer = days === '00'
164
+ ? `${hours}h:${minutes}m:${seconds}s`
165
+ : `${days}d:${hours}h:${minutes}m`;
166
+ }
167
+ getLevelTarget(level) {
168
+ const targetTurnover = formatBalance(level.DisplayCurrencyTargetTurnover, this.challenge.CurrencySymbol);
169
+ let levelTarget = `${translate('place', this.language)} ${targetTurnover}`;
170
+ if (level.LevelTargetType === 1) {
171
+ levelTarget += ` ${translate('bet', this.language)}`;
349
172
  }
350
- },
351
- "required": false,
352
- "optional": false,
353
- "docs": {
354
- "tags": [],
355
- "text": "Active challenges"
356
- }
357
- },
358
- "language": {
359
- "type": "string",
360
- "mutable": false,
361
- "complexType": {
362
- "original": "string",
363
- "resolved": "string",
364
- "references": {}
365
- },
366
- "required": false,
367
- "optional": false,
368
- "docs": {
369
- "tags": [],
370
- "text": "Language of the widget"
371
- },
372
- "attribute": "language",
373
- "reflect": false,
374
- "defaultValue": "'en'"
375
- },
376
- "gameSlug": {
377
- "type": "string",
378
- "mutable": false,
379
- "complexType": {
380
- "original": "string",
381
- "resolved": "string",
382
- "references": {}
383
- },
384
- "required": false,
385
- "optional": false,
386
- "docs": {
387
- "tags": [],
388
- "text": "Current game slug"
389
- },
390
- "attribute": "game-slug",
391
- "reflect": false,
392
- "defaultValue": "''"
393
- },
394
- "device": {
395
- "type": "string",
396
- "mutable": false,
397
- "complexType": {
398
- "original": "\"Mobile\" | \"Tablet\" | \"Desktop\"",
399
- "resolved": "\"Desktop\" | \"Mobile\" | \"Tablet\"",
400
- "references": {}
401
- },
402
- "required": false,
403
- "optional": false,
404
- "docs": {
405
- "tags": [],
406
- "text": "User's device type"
407
- },
408
- "attribute": "device",
409
- "reflect": false,
410
- "defaultValue": "'Mobile' as 'Mobile' | 'Tablet' | 'Desktop'"
411
- },
412
- "isJoiningToChallenge": {
413
- "type": "boolean",
414
- "mutable": true,
415
- "complexType": {
416
- "original": "boolean",
417
- "resolved": "boolean",
418
- "references": {}
419
- },
420
- "required": false,
421
- "optional": false,
422
- "docs": {
423
- "tags": [],
424
- "text": "Is joining to challenge"
425
- },
426
- "attribute": "is-joining-to-challenge",
427
- "reflect": false
428
- },
429
- "pausedChallengeIds": {
430
- "type": "unknown",
431
- "mutable": true,
432
- "complexType": {
433
- "original": "string[]",
434
- "resolved": "string[]",
435
- "references": {
436
- "Array": {
437
- "location": "global"
438
- }
173
+ else if (level.LevelTargetType === 2) {
174
+ levelTarget += ` ${translate('bets', this.language)} X ${level.TargetBetCount}`;
175
+ }
176
+ return (h("span", { class: "ChallengeLevelTarget" }, levelTarget));
177
+ }
178
+ getLevelBetRangesDetails(level) {
179
+ var _a, _b, _c, _d;
180
+ const isAccumulativeLevelType = level.LevelTargetType === 0;
181
+ if (isAccumulativeLevelType) {
182
+ const formattedMinBet = formatBalance((_a = level.BetRange) === null || _a === void 0 ? void 0 : _a.MinBet, this.challenge.CurrencySymbol);
183
+ const formattedMaxBet = formatBalance((_b = level.BetRange) === null || _b === void 0 ? void 0 : _b.MaxBet, this.challenge.CurrencySymbol);
184
+ const formattedContributionPercentage = level.LevelContributionPercent + '%';
185
+ const showMinBet = !!((_c = level.BetRange) === null || _c === void 0 ? void 0 : _c.MinBet);
186
+ const showMaxBet = !!((_d = level.BetRange) === null || _d === void 0 ? void 0 : _d.MaxBet);
187
+ const showContributionPercentage = level.LevelContributionPercent !== 100;
188
+ if (showMinBet || showMaxBet || showContributionPercentage) {
189
+ return (h("div", { class: 'ChallengeLevelBetDetails' }, showMinBet &&
190
+ h("div", { class: 'ChallengeLevelBetDetail' }, h("span", null, translate('minBet', this.language), ": "), h("span", { class: 'ChallengeLevelBetRange' }, formattedMinBet)), showMaxBet &&
191
+ h("div", { class: 'ChallengeLevelBetDetail' }, h("span", null, translate('maxBet', this.language), ": "), h("span", { class: 'ChallengeLevelBetRange' }, formattedMaxBet)), showContributionPercentage &&
192
+ h("div", { class: 'ChallengeLevelBetDetail' }, h("span", null, translate('contribution', this.language), ": "), h("span", { class: 'ChallengeLevelBetContribution' }, formattedContributionPercentage))));
193
+ }
439
194
  }
440
- },
441
- "required": false,
442
- "optional": false,
443
- "docs": {
444
- "tags": [],
445
- "text": "Paused Challenge Ids"
446
- },
447
- "defaultValue": "[] as Array<string>"
448
195
  }
449
- }; }
450
- static get states() { return {
451
- "limitStylingAppends": {},
452
- "timer": {},
453
- "showDetails": {},
454
- "isExpiredChallenge": {}
455
- }; }
456
- static get events() { return [{
457
- "method": "close",
458
- "name": "close",
459
- "bubbles": true,
460
- "cancelable": true,
461
- "composed": true,
462
- "docs": {
463
- "tags": [],
464
- "text": ""
465
- },
466
- "complexType": {
467
- "original": "void",
468
- "resolved": "void",
469
- "references": {}
470
- }
471
- }, {
472
- "method": "back",
473
- "name": "back",
474
- "bubbles": true,
475
- "cancelable": true,
476
- "composed": true,
477
- "docs": {
478
- "tags": [],
479
- "text": ""
480
- },
481
- "complexType": {
482
- "original": "void",
483
- "resolved": "void",
484
- "references": {}
485
- }
486
- }, {
487
- "method": "resetNewChallengeLabel",
488
- "name": "resetNewChallengeLabel",
489
- "bubbles": true,
490
- "cancelable": true,
491
- "composed": true,
492
- "docs": {
493
- "tags": [],
494
- "text": ""
495
- },
496
- "complexType": {
497
- "original": "string",
498
- "resolved": "string",
499
- "references": {}
500
- }
501
- }]; }
502
- static get elementRef() { return "host"; }
503
- static get watchers() { return [{
504
- "propName": "challenge",
505
- "methodName": "challengePropHandler"
506
- }]; }
196
+ getChallengeLevels() {
197
+ const isChallengePaused = this.pausedChallengeIds.includes(this.challenge.ChallengeId);
198
+ const InProgressLevel = (level) => {
199
+ return level.ProgressStatus === 1 && !this.isExpiredChallenge && !isChallengePaused;
200
+ };
201
+ return (h("div", { class: "ChallengeLevels" }, this.challenge.LevelProgresses.map((level, index) => (h("div", { class: `ChallengeLevelCard ${InProgressLevel(level) ? 'InProgress' : ''}` }, h("casino-engagement-suite-progress-bar", { clientStylingUrl: this.clientStylingUrl, class: this.device, value: level.ProgressPercentage, "hide-percent": (level.ProgressPercentage === 0 && !InProgressLevel(level)) || level.ProgressPercentage === 100, disabled: this.isExpiredChallenge || isChallengePaused }, h("span", { slot: "Title", class: "ChallengeLevelTitle" }, h("span", null, "Level ", index + 1, ": "), this.getLevelTarget(level))), h("div", { class: "ChallengeRewardMessage" }, h("div", { class: "EngagementSuiteIconButton Reward" }), h("span", null, translate('win', this.language), ": "), h("span", { class: "CustomRewardMessage" }, level.CustomRewardMessage)), this.getLevelBetRangesDetails(level))))));
202
+ }
203
+ getToggleButton() {
204
+ return (h("div", { class: "ChallengeCollapseButton", onClick: this.toggle }, h("span", { class: `Toggle ${this.showDetails ? 'Closed' : 'Open'}` }), h("span", null, translate('details', this.language))));
205
+ }
206
+ render() {
207
+ return h("div", { key: '413a8354c03545a336b044a26f33275423548ee2', class: `ChallengeDetailsPopup ${this.device}` }, this.getActionsTemplate(), h("div", { key: 'e58aac0709effc8ed9df011c07b52ee6a0c4fa66', class: `ChallengeDetails ${this.challenge.IsNew ? 'IsNewChallenge' : ''}` }, this.getChallengeHeader(), this.getChallengeCountdown(), this.getToggleButton(), this.getChallengeDetails(), this.getChallengeLevels()));
208
+ }
209
+ static get is() { return "casino-engagement-suite-challenges-details"; }
210
+ static get encapsulation() { return "shadow"; }
211
+ static get originalStyleUrls() {
212
+ return {
213
+ "$": ["casino-engagement-suite-challenges-details.scss"]
214
+ };
215
+ }
216
+ static get styleUrls() {
217
+ return {
218
+ "$": ["casino-engagement-suite-challenges-details.css"]
219
+ };
220
+ }
221
+ static get properties() {
222
+ return {
223
+ "clientStyling": {
224
+ "type": "string",
225
+ "mutable": false,
226
+ "complexType": {
227
+ "original": "string",
228
+ "resolved": "string",
229
+ "references": {}
230
+ },
231
+ "required": false,
232
+ "optional": false,
233
+ "docs": {
234
+ "tags": [],
235
+ "text": "Client custom styling via string"
236
+ },
237
+ "attribute": "client-styling",
238
+ "reflect": true,
239
+ "defaultValue": "''"
240
+ },
241
+ "clientStylingUrl": {
242
+ "type": "string",
243
+ "mutable": false,
244
+ "complexType": {
245
+ "original": "string",
246
+ "resolved": "string",
247
+ "references": {}
248
+ },
249
+ "required": false,
250
+ "optional": false,
251
+ "docs": {
252
+ "tags": [],
253
+ "text": "Client custom styling via url"
254
+ },
255
+ "attribute": "client-styling-url",
256
+ "reflect": true,
257
+ "defaultValue": "''"
258
+ },
259
+ "challenge": {
260
+ "type": "unknown",
261
+ "mutable": true,
262
+ "complexType": {
263
+ "original": "Challenge",
264
+ "resolved": "Challenge",
265
+ "references": {
266
+ "Challenge": {
267
+ "location": "import",
268
+ "path": "../../models/casino-challenges-details",
269
+ "id": "../../../../packages/stencil/casino-engagement-suite-challenges-details/src/models/casino-challenges-details.ts::Challenge"
270
+ }
271
+ }
272
+ },
273
+ "required": false,
274
+ "optional": false,
275
+ "docs": {
276
+ "tags": [],
277
+ "text": "Selected challenge"
278
+ }
279
+ },
280
+ "inProgressChallenges": {
281
+ "type": "unknown",
282
+ "mutable": true,
283
+ "complexType": {
284
+ "original": "Array<string>",
285
+ "resolved": "string[]",
286
+ "references": {
287
+ "Array": {
288
+ "location": "global",
289
+ "id": "global::Array"
290
+ }
291
+ }
292
+ },
293
+ "required": false,
294
+ "optional": false,
295
+ "docs": {
296
+ "tags": [],
297
+ "text": "Active challenges"
298
+ }
299
+ },
300
+ "language": {
301
+ "type": "string",
302
+ "mutable": false,
303
+ "complexType": {
304
+ "original": "string",
305
+ "resolved": "string",
306
+ "references": {}
307
+ },
308
+ "required": false,
309
+ "optional": false,
310
+ "docs": {
311
+ "tags": [],
312
+ "text": "Language of the widget"
313
+ },
314
+ "attribute": "language",
315
+ "reflect": false,
316
+ "defaultValue": "'en'"
317
+ },
318
+ "gameSlug": {
319
+ "type": "string",
320
+ "mutable": false,
321
+ "complexType": {
322
+ "original": "string",
323
+ "resolved": "string",
324
+ "references": {}
325
+ },
326
+ "required": false,
327
+ "optional": false,
328
+ "docs": {
329
+ "tags": [],
330
+ "text": "Current game slug"
331
+ },
332
+ "attribute": "game-slug",
333
+ "reflect": false,
334
+ "defaultValue": "''"
335
+ },
336
+ "device": {
337
+ "type": "string",
338
+ "mutable": false,
339
+ "complexType": {
340
+ "original": "\"Mobile\" | \"Tablet\" | \"Desktop\"",
341
+ "resolved": "\"Desktop\" | \"Mobile\" | \"Tablet\"",
342
+ "references": {}
343
+ },
344
+ "required": false,
345
+ "optional": false,
346
+ "docs": {
347
+ "tags": [],
348
+ "text": "User's device type"
349
+ },
350
+ "attribute": "device",
351
+ "reflect": false,
352
+ "defaultValue": "'Mobile' as 'Mobile' | 'Tablet' | 'Desktop'"
353
+ },
354
+ "isJoiningToChallenge": {
355
+ "type": "boolean",
356
+ "mutable": true,
357
+ "complexType": {
358
+ "original": "boolean",
359
+ "resolved": "boolean",
360
+ "references": {}
361
+ },
362
+ "required": false,
363
+ "optional": false,
364
+ "docs": {
365
+ "tags": [],
366
+ "text": "Is joining to challenge"
367
+ },
368
+ "attribute": "is-joining-to-challenge",
369
+ "reflect": false
370
+ },
371
+ "pausedChallengeIds": {
372
+ "type": "unknown",
373
+ "mutable": true,
374
+ "complexType": {
375
+ "original": "string[]",
376
+ "resolved": "string[]",
377
+ "references": {}
378
+ },
379
+ "required": false,
380
+ "optional": false,
381
+ "docs": {
382
+ "tags": [],
383
+ "text": "Paused Challenge Ids"
384
+ },
385
+ "defaultValue": "[] as Array<string>"
386
+ }
387
+ };
388
+ }
389
+ static get states() {
390
+ return {
391
+ "limitStylingAppends": {},
392
+ "timer": {},
393
+ "showDetails": {},
394
+ "isExpiredChallenge": {}
395
+ };
396
+ }
397
+ static get events() {
398
+ return [{
399
+ "method": "close",
400
+ "name": "close",
401
+ "bubbles": true,
402
+ "cancelable": true,
403
+ "composed": true,
404
+ "docs": {
405
+ "tags": [],
406
+ "text": ""
407
+ },
408
+ "complexType": {
409
+ "original": "void",
410
+ "resolved": "void",
411
+ "references": {}
412
+ }
413
+ }, {
414
+ "method": "back",
415
+ "name": "back",
416
+ "bubbles": true,
417
+ "cancelable": true,
418
+ "composed": true,
419
+ "docs": {
420
+ "tags": [],
421
+ "text": ""
422
+ },
423
+ "complexType": {
424
+ "original": "void",
425
+ "resolved": "void",
426
+ "references": {}
427
+ }
428
+ }, {
429
+ "method": "resetNewChallengeLabel",
430
+ "name": "resetNewChallengeLabel",
431
+ "bubbles": true,
432
+ "cancelable": true,
433
+ "composed": true,
434
+ "docs": {
435
+ "tags": [],
436
+ "text": ""
437
+ },
438
+ "complexType": {
439
+ "original": "string",
440
+ "resolved": "string",
441
+ "references": {}
442
+ }
443
+ }];
444
+ }
445
+ static get elementRef() { return "host"; }
446
+ static get watchers() {
447
+ return [{
448
+ "propName": "challenge",
449
+ "methodName": "challengePropHandler"
450
+ }];
451
+ }
507
452
  }