@everymatrix/gamification-dropdown 1.43.4 → 1.54.2

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 (77) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/gamification-dropdown-0fd9c5b8.js +186 -0
  3. package/dist/cjs/gamification-dropdown.cjs.js +17 -11
  4. package/dist/cjs/gamification-dropdown_4.cjs.entry.js +408 -528
  5. package/dist/cjs/index-c535ed72.js +1796 -0
  6. package/dist/cjs/index.cjs.js +8 -0
  7. package/dist/cjs/loader.cjs.js +7 -13
  8. package/dist/cjs/{player-elevate-card-items-1cb6488c.js → player-elevate-card-items-42538012.js} +195 -180
  9. package/dist/cjs/player-elevate-card.cjs.entry.js +71 -70
  10. package/dist/cjs/player-elevate-pointcard.cjs.entry.js +79 -78
  11. package/dist/collection/collection-manifest.json +3 -3
  12. package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +272 -257
  13. package/dist/collection/components/gamification-dropdown/index.js +1 -0
  14. package/dist/collection/index.js +1 -1
  15. package/dist/collection/utils/locale.utils.js +34 -34
  16. package/dist/collection/utils/utils.js +1 -1
  17. package/dist/esm/app-globals-0f993ce5.js +3 -0
  18. package/dist/esm/gamification-dropdown-ae7b7c69.js +184 -0
  19. package/dist/esm/gamification-dropdown.js +14 -11
  20. package/dist/esm/gamification-dropdown_4.entry.js +408 -528
  21. package/dist/esm/index-ea7720e4.js +1766 -0
  22. package/dist/esm/index.js +2 -1
  23. package/dist/esm/loader.js +7 -13
  24. package/dist/esm/{player-elevate-card-items-5bf07fe3.js → player-elevate-card-items-9d490a3b.js} +196 -180
  25. package/dist/esm/player-elevate-card.entry.js +71 -70
  26. package/dist/esm/player-elevate-pointcard.entry.js +79 -78
  27. package/dist/gamification-dropdown/gamification-dropdown.esm.js +1 -1
  28. package/dist/gamification-dropdown/index.esm.js +1 -0
  29. package/dist/gamification-dropdown/p-10486e5b.entry.js +1 -0
  30. package/dist/gamification-dropdown/p-21507480.js +1 -0
  31. package/dist/gamification-dropdown/p-3f7623db.js +2 -0
  32. package/dist/gamification-dropdown/p-422d11f7.entry.js +1 -0
  33. package/dist/gamification-dropdown/p-4b1d42b5.entry.js +1 -0
  34. package/dist/gamification-dropdown/p-c5998a81.js +1 -0
  35. package/dist/gamification-dropdown/p-e1255160.js +1 -0
  36. package/dist/stencil.config.dev.js +15 -0
  37. package/dist/stencil.config.js +14 -19
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.d.ts +2 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/gamification-dropdown/.stencil/packages/stencil/gamification-dropdown/stencil.config.dev.d.ts +2 -0
  40. package/dist/types/components/gamification-dropdown/gamification-dropdown.d.ts +41 -41
  41. package/dist/types/components/gamification-dropdown/index.d.ts +1 -0
  42. package/dist/types/index.d.ts +1 -1
  43. package/dist/types/stencil-public-runtime.d.ts +148 -33
  44. package/loader/cdn.js +1 -3
  45. package/loader/index.cjs.js +1 -3
  46. package/loader/index.d.ts +13 -1
  47. package/loader/index.es2017.js +1 -3
  48. package/loader/index.js +1 -3
  49. package/loader/package.json +1 -0
  50. package/package.json +11 -4
  51. package/dist/cjs/index-4aa14dda.js +0 -1717
  52. package/dist/components/gamification-dropdown.d.ts +0 -11
  53. package/dist/components/gamification-dropdown.js +0 -230
  54. package/dist/components/general-styling-wrapper.js +0 -6
  55. package/dist/components/general-styling-wrapper2.js +0 -103
  56. package/dist/components/index.d.ts +0 -26
  57. package/dist/components/index.js +0 -1
  58. package/dist/components/player-elevate-card-data.js +0 -6
  59. package/dist/components/player-elevate-card-data2.js +0 -635
  60. package/dist/components/player-elevate-card-items.js +0 -2149
  61. package/dist/components/player-elevate-card.js +0 -126
  62. package/dist/components/player-elevate-loyaltycard.js +0 -6
  63. package/dist/components/player-elevate-loyaltycard2.js +0 -129
  64. package/dist/components/player-elevate-pointcard.js +0 -135
  65. package/dist/esm/index-a803f08b.js +0 -1688
  66. package/dist/esm/polyfills/core-js.js +0 -11
  67. package/dist/esm/polyfills/css-shim.js +0 -1
  68. package/dist/esm/polyfills/dom.js +0 -79
  69. package/dist/esm/polyfills/es5-html-element.js +0 -1
  70. package/dist/esm/polyfills/index.js +0 -34
  71. package/dist/esm/polyfills/system.js +0 -6
  72. package/dist/gamification-dropdown/p-118adbd3.entry.js +0 -1
  73. package/dist/gamification-dropdown/p-1bea1936.js +0 -1
  74. package/dist/gamification-dropdown/p-727c8663.js +0 -1
  75. package/dist/gamification-dropdown/p-bf29bfd4.entry.js +0 -1
  76. package/dist/gamification-dropdown/p-cdf41413.entry.js +0 -1
  77. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/gamification-dropdown/.stencil/packages/gamification-dropdown/stencil.config.d.ts +0 -2
@@ -1,266 +1,88 @@
1
- import { r as registerInstance, h, g as getElement, c as createEvent, a as getAssetPath, F as Fragment } from './index-a803f08b.js';
2
- import { r as requiredArgs, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translateWithParams, T as TRANSLATIONS$1, P as PlayerAvatar, b as PlayerPoints, c as PlayerLoyaltyProcess, d as translate$1, f as format } from './player-elevate-card-items-5bf07fe3.js';
3
-
4
- const DEFAULT_LANGUAGE = 'en';
5
- let TRANSLATIONS = {
6
- en: {
7
- gamificationNoPoints: "No points"
8
- },
9
- de: {
10
- gamificationNoPoints: "No points"
11
- },
12
- ro: {
13
- gamificationNoPoints: "No points"
14
- },
15
- fr: {
16
- gamificationNoPoints: "No points"
17
- },
18
- ar: {
19
- gamificationNoPoints: "No points"
20
- },
21
- hr: {
22
- gamificationNoPoints: "No points"
23
- }
24
- };
25
- const getTranslations = (url) => {
26
- return new Promise((resolve) => {
27
- fetch(url)
28
- .then((res) => res.json())
29
- .then((data) => {
30
- Object.keys(data).forEach((lang) => {
31
- if (!TRANSLATIONS[lang]) {
32
- TRANSLATIONS[lang] = {};
33
- }
34
- for (let key in data[lang]) {
35
- TRANSLATIONS[lang][key] = data[lang][key];
36
- }
37
- });
38
- resolve(true);
39
- });
40
- });
41
- };
42
- const translate = (key, customLang) => {
43
- const lang = customLang;
44
- return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
45
- };
46
-
47
- const gamificationDropdownCss = ":host{display:block}.GamificationDropdownContainer{position:relative}.GamificationDropdownContainer .GamificationDropdown{position:absolute;left:0;z-index:200;overflow:hidden;cursor:pointer}.GamificationDropdownButton{cursor:pointer;font-size:14px;height:20px;background-color:unset;color:var(--emw--color-typography, #FFFFFF);padding:0;border:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:flex;align-items:center;justify-content:center;line-height:0}.GamificationDropdownButton:hover{color:var(--emw--color-primary, #52d004)}.GamificationDropdownButton:hover svg{fill:var(--emw--color-primary, #52d004)}.GamificationDropdownButton.IsOpen{color:var(--emw--color-primary, #52d004)}.GamificationDropdownButton.IsOpen svg{fill:var(--emw--color-primary, #52d004)}.GamificationDropdownButton .TriangleActive,.GamificationDropdownButton .TriangleInactive{display:block;transition:all 0.2s}.GamificationDropdownButton .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px);fill:var(--emw--color-primary, #52d004);margin-top:4px}.GamificationDropdownButton svg{fill:var(--emw--color-typography, #FFFFFF);margin-left:8px;width:16px}";
48
-
49
- const GamificationDropdown = class {
50
- constructor(hostRef) {
51
- registerInstance(this, hostRef);
52
- /**
53
- * Language of the widget
54
- */
55
- this.language = 'en';
56
- /**
57
- * Session of the user
58
- */
59
- this.session = '';
60
- /**
61
- * Client custom styling via string
62
- */
63
- this.clientStyling = '';
64
- /**
65
- * Client custom styling via url
66
- */
67
- this.clientStylingUrl = '';
68
- /**
69
- * Translations via URL
70
- */
71
- this.translationUrl = '';
72
- this.isOpen = false;
73
- this.isLoading = false;
74
- this.stylingAppends = false;
75
- this.setClientStyling = () => {
76
- let sheet = document.createElement('style');
77
- sheet.innerHTML = this.clientStyling;
78
- this.stylingContainer.prepend(sheet);
79
- };
80
- this.setClientStylingURL = () => {
81
- let url = new URL(this.clientStylingUrl);
82
- let cssFile = document.createElement('style');
83
- fetch(url.href)
84
- .then((res) => res.text())
85
- .then((data) => {
86
- cssFile.innerHTML = data;
87
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
88
- })
89
- .catch((err) => {
90
- console.log('error ', err);
91
- });
92
- };
93
- this.navigateToGamification = () => {
94
- window.postMessage({ type: 'NavigateToGamification' }, window.location.href);
95
- this.isOpen = false;
96
- };
97
- this.handleOutsideClick = (event) => {
98
- const path = event.composedPath();
99
- if (!path.includes(this.el)) {
100
- this.isOpen = false;
101
- document.removeEventListener('click', this.handleOutsideClick);
102
- }
103
- };
104
- this.handleDropdownClick = (event) => {
105
- event.stopPropagation();
106
- this.isOpen = !this.isOpen;
107
- if (this.isOpen) {
108
- document.addEventListener('click', this.handleOutsideClick);
109
- }
110
- else {
111
- document.removeEventListener('click', this.handleOutsideClick);
112
- }
113
- };
114
- }
115
- handleNewTranslations() {
116
- this.isLoading = true;
117
- getTranslations(this.translationUrl).then(() => {
118
- this.isLoading = false;
119
- });
120
- }
121
- async componentWillLoad() {
122
- if (this.translationUrl.length > 2) {
123
- await getTranslations(this.translationUrl);
124
- }
125
- if (this.endpoint && this.language) {
126
- return this.fetchPointsData();
127
- }
128
- }
129
- componentDidRender() {
130
- // start custom styling area
131
- if (!this.stylingAppends && this.stylingContainer) {
132
- if (this.clientStyling)
133
- this.setClientStyling();
134
- if (this.clientStylingUrl)
135
- this.setClientStylingURL();
136
- this.stylingAppends = true;
137
- }
138
- // end custom styling area
139
- }
140
- fetchPointsData() {
141
- let url = new URL(`${this.endpoint}/v1/elevate/playerInfo`);
142
- url.searchParams.append('language', this.language);
143
- const headers = new Headers();
144
- headers.append('X-SessionId', this.session);
145
- const options = {
146
- method: 'GET',
147
- headers
148
- };
149
- return new Promise((resolve, reject) => {
150
- this.isLoading = true;
151
- fetch(url.href, options)
152
- .then((res) => res.json())
153
- .then((data) => {
154
- var _a, _b;
155
- this.loyaltyPoints = (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.level) === null || _b === void 0 ? void 0 : _b.loyaltyPoints;
156
- resolve(true);
157
- }).catch((err) => {
158
- console.error(err);
159
- reject(err);
160
- }).finally(() => {
161
- this.isLoading = false;
162
- });
163
- });
164
- }
165
- render() {
166
- if (this.isLoading) {
167
- return null;
168
- }
169
- else {
170
- return (h("div", { ref: el => this.stylingContainer = el, class: "GamificationDropdownContainer" }, h("button", { class: `GamificationDropdownButton ${this.isOpen ? 'IsOpen' : ''}`, type: "button", onClick: (e) => this.handleDropdownClick(e), title: typeof this.loyaltyPoints === 'number'
171
- ? String(this.loyaltyPoints)
172
- : translate('gamificationNoPoints', this.language) }, typeof this.loyaltyPoints === 'number'
173
- ? `${this.loyaltyPoints} XP`
174
- : '...', h("span", { class: this.isOpen ? 'TriangleActive' : 'TriangleInactive' }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" }, h("path", { id: "arrow", d: "M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z", transform: "translate(-274.511 -441.088)" })))), this.isOpen && (h("div", { class: "GamificationDropdown", onClick: this.navigateToGamification }, h("player-elevate-loyaltycard", { endpoint: this.endpoint, session: this.session, language: this.language, "client-styling-url": this.clientStylingUrl, "client-styling": this.clientStyling })))));
175
- }
176
- }
177
- get el() { return getElement(this); }
178
- static get watchers() { return {
179
- "translationUrl": ["handleNewTranslations"]
180
- }; }
181
- };
182
- GamificationDropdown.style = gamificationDropdownCss;
1
+ export { G as gamification_dropdown } from './gamification-dropdown-ae7b7c69.js';
2
+ import { r as registerInstance, h, g as getElement, c as createEvent, a as getAssetPath, F as Fragment } from './index-ea7720e4.js';
3
+ import { r as requiredArgs, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translateWithParams, T as TRANSLATIONS, P as PlayerAvatar, b as PlayerElevateLoyaltyLevel, c as PlayerPoints, d as PlayerLoyaltyProcess } from './player-elevate-card-items-9d490a3b.js';
183
4
 
184
5
  const mergeTranslations = (url, target) => {
185
- return new Promise((resolve) => {
186
- fetch(url)
187
- .then((res) => res.json())
188
- .then((data) => {
189
- Object.keys(data).forEach((item) => {
190
- target[item] = target[item] ? target[item] : {};
191
- for (let key in data[item]) {
192
- target[item][key] = data[item][key];
193
- }
194
- });
195
- resolve(true);
6
+ return new Promise((resolve) => {
7
+ fetch(url)
8
+ .then((res) => res.json())
9
+ .then((data) => {
10
+ Object.keys(data).forEach((item) => {
11
+ target[item] = target[item] ? target[item] : {};
12
+ for (let key in data[item]) {
13
+ target[item][key] = data[item][key];
14
+ }
15
+ });
16
+ resolve(true);
17
+ });
196
18
  });
197
- });
198
19
  };
199
20
 
200
21
  const generalStylingWrapperCss = ":host{display:block}";
22
+ const GeneralStylingWrapperStyle0 = generalStylingWrapperCss;
201
23
 
202
24
  const GeneralStylingWrapper = class {
203
- constructor(hostRef) {
204
- registerInstance(this, hostRef);
205
- /**
206
- * Client custom styling via inline styles
207
- */
208
- this.clientStyling = '';
209
- /**
210
- * Client custom styling via url
211
- */
212
- this.clientStylingUrl = '';
213
- /**
214
- * Translation via url
215
- */
216
- this.translationUrl = '';
217
- this.stylingAppends = false;
218
- this.setClientStyling = () => {
219
- let sheet = document.createElement('style');
220
- sheet.innerHTML = this.clientStyling;
221
- this.el.prepend(sheet);
222
- };
223
- this.setClientStylingURL = () => {
224
- let url = new URL(this.clientStylingUrl);
225
- let cssFile = document.createElement('style');
226
- fetch(url.href)
227
- .then((res) => res.text())
228
- .then((data) => {
229
- cssFile.innerHTML = data;
230
- setTimeout(() => {
231
- this.el.prepend(cssFile);
232
- }, 1);
233
- })
234
- .catch((err) => {
235
- console.log('error ', err);
236
- });
237
- };
238
- }
239
- componentDidRender() {
240
- // start custom styling area
241
- if (!this.stylingAppends) {
242
- if (this.clientStyling)
243
- this.setClientStyling();
244
- if (this.clientStylingUrl)
245
- this.setClientStylingURL();
246
- this.stylingAppends = true;
25
+ constructor(hostRef) {
26
+ registerInstance(this, hostRef);
27
+ /**
28
+ * Client custom styling via inline styles
29
+ */
30
+ this.clientStyling = '';
31
+ /**
32
+ * Client custom styling via url
33
+ */
34
+ this.clientStylingUrl = '';
35
+ /**
36
+ * Translation via url
37
+ */
38
+ this.translationUrl = '';
39
+ this.stylingAppends = false;
40
+ this.setClientStyling = () => {
41
+ let sheet = document.createElement('style');
42
+ sheet.innerHTML = this.clientStyling;
43
+ this.el.prepend(sheet);
44
+ };
45
+ this.setClientStylingURL = () => {
46
+ let url = new URL(this.clientStylingUrl);
47
+ let cssFile = document.createElement('style');
48
+ fetch(url.href)
49
+ .then((res) => res.text())
50
+ .then((data) => {
51
+ cssFile.innerHTML = data;
52
+ setTimeout(() => {
53
+ this.el.prepend(cssFile);
54
+ }, 1);
55
+ })
56
+ .catch((err) => {
57
+ console.log('error ', err);
58
+ });
59
+ };
247
60
  }
248
- // end custom styling area
249
- }
250
- async componentWillLoad() {
251
- const promises = [];
252
- if (this.translationUrl) {
253
- const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
254
- promises.push(translationPromise);
61
+ componentDidRender() {
62
+ // start custom styling area
63
+ if (!this.stylingAppends) {
64
+ if (this.clientStyling)
65
+ this.setClientStyling();
66
+ if (this.clientStylingUrl)
67
+ this.setClientStylingURL();
68
+ this.stylingAppends = true;
69
+ }
70
+ // end custom styling area
71
+ }
72
+ async componentWillLoad() {
73
+ const promises = [];
74
+ if (this.translationUrl) {
75
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
76
+ promises.push(translationPromise);
77
+ }
78
+ return await Promise.all(promises);
255
79
  }
256
- return await Promise.all(promises);
257
- }
258
- render() {
259
- return (h("div", { class: "StyleShell" }, h("slot", { name: "mainContent" })));
260
- }
261
- get el() { return getElement(this); }
80
+ render() {
81
+ return (h("div", { key: '4d3414408c7662f88331dbe655966237f74d6958', class: "StyleShell" }, h("slot", { key: '1d004644d84602c4314bdf5dfc26b55b160f57df', name: "mainContent" })));
82
+ }
83
+ get el() { return getElement(this); }
262
84
  };
263
- GeneralStylingWrapper.style = generalStylingWrapperCss;
85
+ GeneralStylingWrapper.style = GeneralStylingWrapperStyle0;
264
86
 
265
87
  /**
266
88
  * @name startOfDay
@@ -341,6 +163,16 @@ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
341
163
  * @default
342
164
  */
343
165
 
166
+ /**
167
+ * Milliseconds in 1 minute
168
+ *
169
+ * @name millisecondsInMinute
170
+ * @constant
171
+ * @type {number}
172
+ * @default
173
+ */
174
+ var millisecondsInMinute = 60000;
175
+
344
176
  /**
345
177
  * Milliseconds in 1 hour
346
178
  *
@@ -421,6 +253,43 @@ function differenceInHours(dateLeft, dateRight, options) {
421
253
  return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
422
254
  }
423
255
 
256
+ /**
257
+ * @name differenceInMinutes
258
+ * @category Minute Helpers
259
+ * @summary Get the number of minutes between the given dates.
260
+ *
261
+ * @description
262
+ * Get the signed number of full (rounded towards 0) minutes between the given dates.
263
+ *
264
+ * @param {Date|Number} dateLeft - the later date
265
+ * @param {Date|Number} dateRight - the earlier date
266
+ * @param {Object} [options] - an object with options.
267
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
268
+ * @returns {Number} the number of minutes
269
+ * @throws {TypeError} 2 arguments required
270
+ *
271
+ * @example
272
+ * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
273
+ * const result = differenceInMinutes(
274
+ * new Date(2014, 6, 2, 12, 20, 0),
275
+ * new Date(2014, 6, 2, 12, 7, 59)
276
+ * )
277
+ * //=> 12
278
+ *
279
+ * @example
280
+ * // How many minutes are between 10:01:59 and 10:00:00
281
+ * const result = differenceInMinutes(
282
+ * new Date(2000, 0, 1, 10, 0, 0),
283
+ * new Date(2000, 0, 1, 10, 1, 59)
284
+ * )
285
+ * //=> -1
286
+ */
287
+ function differenceInMinutes(dateLeft, dateRight, options) {
288
+ requiredArgs(2, arguments);
289
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
290
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
291
+ }
292
+
424
293
  /**
425
294
  * @name isBefore
426
295
  * @category Common Helpers
@@ -447,302 +316,313 @@ function isBefore(dirtyDate, dirtyDateToCompare) {
447
316
  }
448
317
 
449
318
  function updateProgressSvg(progressElementRef, percent) {
450
- const svgElement = progressElementRef.querySelector('#total_level');
451
- const endLockWidth = 17, pointR = 6.5;
452
- //Total Widget of the progress
453
- const barWidth = svgElement.getBBox().width;
454
- //The filled width according to current progress
455
- const levelPercent = percent > 1 ? 1 : percent;
456
- const widthOnBar = (levelPercent * barWidth - endLockWidth) < 0 ? 0 : levelPercent * barWidth - endLockWidth;
457
- //update bar's width, widthOnBar
458
- const levelBar = progressElementRef.querySelector('#current_level');
459
- //update filters, x = widthOnBar
460
- const levelFilter = progressElementRef.querySelector('#filter_current_level');
461
- //update circle, widthOnBar+10
462
- const levelCircle = progressElementRef.querySelector('#circle_current_level');
463
- svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
464
- levelBar.setAttribute('width', `${widthOnBar}`);
465
- levelCircle.setAttribute('cx', `${(widthOnBar < pointR ? pointR : widthOnBar)}`);
466
- levelFilter.setAttribute('x', `${widthOnBar - 8}`);
467
- //update lock location
468
- const endLockElement = progressElementRef.querySelector('#lock');
469
- // wrapper of endLock, include ball and heatfilter1_d_305_23
470
- const filter1 = progressElementRef.querySelector('#filter_heart_ball');
471
- // ball in endlockfilter2_i_305_23
472
- const filter2 = progressElementRef.querySelector('#filter_ball');
473
- // heart in endlockfilter3_d_305_23
474
- const filter3 = progressElementRef.querySelector('#filter_heart');
475
- //wrapper of lockfilter4_d_305_23
476
- const filterLock = progressElementRef.querySelector('#filter_lock');
477
- // shadow of ball paint0_linear_305_23
478
- const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
479
- //paint in lockpaint1_linear_305_23
480
- const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
481
- // box of lock and heart, for move position dynamically
482
- const lockBox = progressElementRef.querySelector('#lock_box');
483
- const heartBox = progressElementRef.querySelector('#heart_box');
484
- const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
485
- //set cx of lockElement
486
- endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
487
- //set cx of sub Elements
488
- paint1.setAttribute('x1', `${cxOfEndLockEle}`);
489
- paint1.setAttribute('x2', `${cxOfEndLockEle}`);
490
- paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
491
- paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
492
- filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
493
- filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
494
- filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
495
- filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
496
- lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
497
- heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
498
- svgElement.parentElement.style.opacity = '1';
319
+ const svgElement = progressElementRef.querySelector('#total_level');
320
+ const endLockWidth = 17, pointR = 6.5;
321
+ //Total Widget of the progress
322
+ const barWidth = svgElement.getBBox().width;
323
+ //The filled width according to current progress
324
+ const levelPercent = percent > 1 ? 1 : percent;
325
+ const widthOnBar = (levelPercent * barWidth - endLockWidth) < 0 ? 0 : levelPercent * barWidth - endLockWidth;
326
+ //update bar's width, widthOnBar
327
+ const levelBar = progressElementRef.querySelector('#current_level');
328
+ //update filters, x = widthOnBar
329
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
330
+ //update circle, widthOnBar+10
331
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
332
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
333
+ levelBar.setAttribute('width', `${widthOnBar}`);
334
+ levelCircle.setAttribute('cx', `${(widthOnBar < pointR ? pointR : widthOnBar)}`);
335
+ levelFilter.setAttribute('x', `${widthOnBar - 8}`);
336
+ //update lock location
337
+ const endLockElement = progressElementRef.querySelector('#lock');
338
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
339
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
340
+ // ball in endlockfilter2_i_305_23
341
+ const filter2 = progressElementRef.querySelector('#filter_ball');
342
+ // heart in endlockfilter3_d_305_23
343
+ const filter3 = progressElementRef.querySelector('#filter_heart');
344
+ //wrapper of lockfilter4_d_305_23
345
+ const filterLock = progressElementRef.querySelector('#filter_lock');
346
+ // shadow of ball paint0_linear_305_23
347
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
348
+ //paint in lockpaint1_linear_305_23
349
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
350
+ // box of lock and heart, for move position dynamically
351
+ const lockBox = progressElementRef.querySelector('#lock_box');
352
+ const heartBox = progressElementRef.querySelector('#heart_box');
353
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
354
+ //set cx of lockElement
355
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
356
+ //set cx of sub Elements
357
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
358
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
359
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
360
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
361
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
362
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
363
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
364
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
365
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
366
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
367
+ svgElement.parentElement.style.opacity = '1';
499
368
  }
500
369
 
501
- const playerElevateCardDataCss = ":host {\n display: block;\n width: 360px;\n height: 230px;\n}\n\n.ElevateCardWrapper {\n contain: layout inline-size;\n width: 100%;\n height: fit-content;\n min-height: 218px;\n}\n\n.Outer {\n container-type: inline-size;\n font-size: 12px;\n background-size: cover;\n background-repeat: no-repeat;\n line-height: initial;\n width: 100%;\n height: 100%;\n}\n\n.Dark {\n color: var(--emfe-w-color-gray150, #efefef);\n}\n\n.Light {\n color: var(--emfe-w-color-black, #0e0e0e);\n}\n\n@container (min-width: 381px) {\n .Outer {\n background-size: cover;\n }\n .Outer .OuterCover {\n min-height: 190px;\n }\n}\n@container (min-width: 260px) {\n .Outer {\n background-size: contain;\n }\n}\n.OuterCover {\n width: 100%;\n height: 100%;\n content: \"\";\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 15px;\n}\n\n.Inner {\n display: flex;\n flex-direction: column;\n min-height: 158px;\n}\n.Inner .Content {\n padding: 15px;\n flex-wrap: wrap;\n gap: 8px;\n}\n.Inner .Row {\n display: flex;\n flex-direction: row;\n}\n.Inner .CardCell {\n display: flex;\n}\n.Inner .LevelProgress svg {\n transition: opacity 0.4s;\n}\n.Inner .LevelInfo {\n display: flex;\n flex-direction: column;\n}\n.Inner .LevelInfo .ElevateLevel .LevelName {\n height: 28px;\n border-radius: 5px;\n line-height: 28px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.Inner .LevelInfo.Level0 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level0button-shadow, rgba(191, 84, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level0-bg0, #E2792C) 0%, var(--emfe-w-elevate-color-level0-bg1, rgba(242, 151, 99, 0)) 100%);\n}\n.Inner .LevelInfo.Level1 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level1button-shadow, rgba(151, 151, 151, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level1-bg0, #BEBFED) 0%, var(--emfe-w-elevate-color-level1-bg1, rgba(216, 217, 233, 0)) 100%);\n}\n.Inner .LevelInfo.Level2 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level2button-shadow, rgba(191, 120, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level2-bg0, #FCC410) 0%, var(--emfe-w-elevate-color-level2-bg1, rgba(255, 189, 43, 0)) 100%);\n}\n.Inner .LevelInfo.Level3 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level3button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level3-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level3-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo.Level4 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level4button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level4-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level4-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo .ElevateLevel {\n display: flex;\n}\n.Inner .LevelInfo {\n flex: 1;\n flex-grow: 1;\n min-width: 150px;\n}\n.Inner .PlayerImg {\n width: 29%;\n margin: auto;\n max-width: 100px;\n min-width: 30px;\n order: 0;\n}\n.Inner .PlayerAvatar {\n max-width: 100px;\n flex-basis: 100px;\n height: auto;\n margin: auto;\n padding-top: 10px;\n}\n.Inner .PlayerAvatar .Avatar, .Inner .PlayerAvatar .Badge {\n width: 100%;\n height: 100%;\n}\n.Inner .PlayerAvatar .Avatar {\n border-radius: 50%;\n background-size: contain;\n background-repeat: no-repeat;\n}\n.Inner .ElevateLevel .ExpirationDate {\n max-width: 138px;\n min-width: 118px;\n}\n.Inner .PlayerName, .Inner .RedeemButton, .Inner .ElevateLevel {\n text-transform: capitalize;\n width: 100%;\n}\n.Inner .PlayerName {\n font-size: 16px;\n}\n.Inner .Row .PointsInfo {\n display: table;\n font-weight: 600;\n}\n.Inner .Row .Redeem {\n justify-content: flex-end;\n margin-left: auto;\n}\n.Inner .Row .Redeem:hover {\n color: var(--emfe-w-elevate-color-redeem-hover, #00ABA4);\n cursor: pointer;\n}\n.Inner .Row .RedeemButton:hover span {\n color: var(emfe-w-elevate-color-redeem-text-hover, #f1f1f1);\n font-weight: bold;\n}\n.Inner .Row .RedeemButton {\n width: 95px;\n height: 35px;\n display: flex;\n align-items: center;\n border-radius: 10px;\n background: var(--emfe-w-elevate-color-redeem-bg, linear-gradient(0deg, #26CC37, #26CC37)), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%);\n box-shadow: 0px 4px 4px 0px #00000040;\n}\n.Inner .Row .RedeemButton span {\n color: var(--emfe-w-color-white, #fff);\n line-height: 18px;\n font-size: 15px;\n text-align: center;\n width: 100%;\n}\n.Inner .Row .Points {\n font-size: large;\n vertical-align: middle;\n}\n.Inner .Row .Points .XP {\n font-size: x-small;\n}\n.Inner .Row .ExpirationPoints {\n font-size: small;\n text-align: right;\n font-weight: bold;\n color: var(--emfe-w-color-red, #9e595f);\n}";
370
+ const playerElevateCardDataCss = ":host {\n display: block;\n width: 360px;\n height: 230px;\n}\n\n.ElevateCardWrapper {\n contain: layout inline-size;\n width: 100%;\n height: fit-content;\n min-height: 218px;\n}\n\n.Outer {\n container-type: inline-size;\n font-size: 12px;\n background-size: cover;\n background-repeat: no-repeat;\n line-height: initial;\n width: 100%;\n height: 100%;\n}\n\n.Dark {\n color: var(--emw--color-gray150, #efefef);\n}\n\n.Light {\n color: var(--emw--color-black, #0e0e0e);\n}\n\n@container (min-width: 381px) {\n .Outer {\n background-size: cover;\n }\n .Outer .OuterCover {\n min-height: 190px;\n }\n}\n@container (min-width: 260px) {\n .Outer {\n background-size: contain;\n }\n}\n.OuterCover {\n width: 100%;\n height: 100%;\n content: \"\";\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 15px;\n}\n\n.Inner {\n display: flex;\n flex-direction: column;\n min-height: 158px;\n}\n.Inner .Content {\n padding: 15px;\n flex-wrap: wrap;\n gap: 8px;\n}\n.Inner .Row {\n display: flex;\n flex-direction: row;\n}\n.Inner .CardCell {\n display: flex;\n}\n.Inner .LevelProgress svg {\n transition: opacity 0.4s;\n}\n.Inner .LevelInfo {\n display: flex;\n flex-direction: column;\n}\n.Inner .LevelInfo .ElevateLevel .LevelName {\n height: 28px;\n border-radius: 5px;\n line-height: 28px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.Inner .LevelInfo.Level0 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level0button-shadow, rgba(191, 84, 6, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level0-bg0, #E2792C) 0%, var(--emw--elevate-color-level0-bg1, rgba(242, 151, 99, 0)) 100%);\n}\n.Inner .LevelInfo.Level1 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level1button-shadow, rgba(151, 151, 151, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level1-bg0, #BEBFED) 0%, var(--emw--elevate-color-level1-bg1, rgba(216, 217, 233, 0)) 100%);\n}\n.Inner .LevelInfo.Level2 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level2button-shadow, rgba(191, 120, 6, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level2-bg0, #FCC410) 0%, var(--emw--elevate-color-level2-bg1, rgba(255, 189, 43, 0)) 100%);\n}\n.Inner .LevelInfo.Level3 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level3button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level3-bg0, #B1A2DB) 0%, var(--emw--elevate-color-level3-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo.Level4 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level4button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level4-bg0, #B1A2DB) 0%, var(--emw--elevate-color-level4-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo .ElevateLevel {\n display: flex;\n}\n.Inner .LevelInfo {\n flex: 1;\n flex-grow: 1;\n min-width: 150px;\n}\n.Inner .PlayerImg {\n width: 29%;\n margin: auto;\n max-width: 100px;\n min-width: 30px;\n order: 0;\n}\n.Inner .PlayerAvatar {\n max-width: 100px;\n flex-basis: 100px;\n height: auto;\n margin: auto;\n padding-top: 10px;\n}\n.Inner .PlayerAvatar .Avatar, .Inner .PlayerAvatar .Badge {\n width: 100%;\n height: 100%;\n}\n.Inner .PlayerAvatar .Avatar {\n border-radius: 50%;\n background-size: contain;\n background-repeat: no-repeat;\n}\n.Inner .ElevateLevel .ExpirationDate {\n max-width: 138px;\n min-width: 118px;\n}\n.Inner .PlayerName, .Inner .RedeemButton, .Inner .ElevateLevel {\n text-transform: capitalize;\n width: 100%;\n}\n.Inner .PlayerName {\n font-size: 16px;\n}\n.Inner .Row .PointsInfo {\n display: table;\n font-weight: 600;\n}\n.Inner .Row .Redeem {\n justify-content: flex-end;\n margin-left: auto;\n}\n.Inner .Row .Redeem:hover {\n color: var(--emw--elevate-color-redeem-hover, #00ABA4);\n cursor: pointer;\n}\n.Inner .Row .RedeemButton:hover span {\n color: var(emfe-w-elevate-color-redeem-text-hover, #f1f1f1);\n font-weight: bold;\n}\n.Inner .Row .RedeemButton {\n width: 95px;\n height: 35px;\n display: flex;\n align-items: center;\n border-radius: 10px;\n background: var(--emw--elevate-color-redeem-bg, linear-gradient(0deg, #26CC37, #26CC37)), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%);\n box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.2509803922);\n}\n.Inner .Row .RedeemButton span {\n color: var(--emw--color-white, #fff);\n line-height: 18px;\n font-size: 15px;\n text-align: center;\n width: 100%;\n}\n.Inner .Row .Points {\n font-size: large;\n vertical-align: middle;\n}\n.Inner .Row .Points .XP {\n font-size: x-small;\n}\n.Inner .Row .ExpirationPoints {\n font-size: small;\n text-align: right;\n font-weight: bold;\n color: var(--emw--color-red, #9e595f);\n}";
371
+ const PlayerElevateCardDataStyle0 = playerElevateCardDataCss;
502
372
 
503
373
  const PlayerElevateCardData = class {
504
- constructor(hostRef) {
505
- registerInstance(this, hostRef);
506
- this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
507
- }
508
- handleWindowResizs() {
509
- this.initLevelProgressbar();
510
- }
511
- onParamsChanged() {
512
- this.loadElevateInfo();
513
- }
514
- redeemGiftButtonHandler() {
515
- this.loadElevateInfo();
516
- }
517
- onRedeemClick() {
518
- window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
519
- }
520
- loadLevels() {
521
- let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
522
- return new Promise((resolve, reject) => {
523
- return fetch(url.href, {
524
- method: 'GET',
525
- })
526
- .then((res) => res.json())
527
- .then((res) => {
528
- this.levels = res.data;
529
- resolve(true);
530
- })
531
- .catch((err) => {
532
- reject(err);
533
- });
534
- });
535
- }
536
- calcuatePointsToBeExpired(walletTotalInfo) {
537
- let pointExpireInfoAsString = '';
538
- if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
539
- walletTotalInfo.aboutToExpire.length == 0 ||
540
- walletTotalInfo.aboutToExpire[0].points <= 0) {
541
- return pointExpireInfoAsString;
374
+ constructor(hostRef) {
375
+ registerInstance(this, hostRef);
376
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
542
377
  }
543
- walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
544
- return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
545
- ? -1
546
- : 1;
547
- });
548
- const aboutToExpire = walletTotalInfo.aboutToExpire[0];
549
- const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
550
- let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
551
- if (daysToExpried == 0) {
552
- hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
553
- expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
378
+ handleWindowResizs() {
379
+ this.initLevelProgressbar();
554
380
  }
555
- pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
556
- expirationPoints: aboutToExpire.points,
557
- expireDay: daysToExpried,
558
- });
559
- return pointExpireInfoAsString;
560
- }
561
- loadPlayerLevelInfo() {
562
- let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
563
- return new Promise((resolve, reject) => {
564
- return fetch(url.href, {
565
- method: 'GET',
566
- headers: {
567
- 'X-Sessionid': this.params.session,
568
- 'Content-Type': 'application/json',
569
- },
570
- })
571
- .then((res) => res.json())
572
- .then((res) => {
573
- var _a, _b, _c;
574
- if (!res.success) {
575
- console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
576
- reject(true);
577
- return;
381
+ onParamsChanged() {
382
+ this.loadElevateInfo();
383
+ }
384
+ redeemGiftButtonHandler() {
385
+ this.loadElevateInfo();
386
+ }
387
+ onRedeemClick() {
388
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
389
+ }
390
+ loadLevels() {
391
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
392
+ return new Promise((resolve, reject) => {
393
+ return fetch(url.href, {
394
+ method: 'GET',
395
+ })
396
+ .then((res) => res.json())
397
+ .then((res) => {
398
+ this.levels = res.data;
399
+ resolve(true);
400
+ })
401
+ .catch((err) => {
402
+ reject(err);
403
+ });
404
+ });
405
+ }
406
+ calcuatePointsToBeExpired(walletTotalInfo) {
407
+ let pointExpireInfoAsString = '';
408
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
409
+ walletTotalInfo.aboutToExpire.length == 0 ||
410
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
411
+ return pointExpireInfoAsString;
578
412
  }
579
- let playerElevateInfo = res.data;
580
- this.playerElevateLevel = playerElevateInfo.level;
581
- this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
582
- this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
583
- this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
584
- const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
585
- const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
586
- this.playerElevateLeveLoaded.emit({
587
- elevateLevelWalletTotal: spendableTotal,
588
- loyaltyWalletTotal
413
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
414
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
415
+ ? -1
416
+ : 1;
589
417
  });
590
- let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
591
- let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
592
- if (spExpireInfoAsString || xpExpireInfoAsString) {
593
- this.playerElevateLeveLoaded.emit({
594
- pointExpireString: spExpireInfoAsString,
595
- xpExpireString: xpExpireInfoAsString
596
- });
418
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
419
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
420
+ let hoursToExpired = 0, minutesToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
421
+ if (daysToExpried <= 0) {
422
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date(), { roundingMethod: 'floor' });
423
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
424
+ if (hoursToExpired <= 0) {
425
+ minutesToExpired = differenceInMinutes(new Date(aboutToExpire.expireTime), new Date(), { roundingMethod: 'floor' });
426
+ expiredTranslationKey = minutesToExpired > 1 ? 'pointsToBeExpiredMinutes' : 'pointsToBeExpiredMinute';
427
+ }
597
428
  }
598
- resolve(this.playerElevateLevel);
599
- })
600
- .catch((err) => {
601
- console.log('error ', err);
602
- reject(true);
603
- });
604
- });
605
- }
606
- setLoyaltyProgress(percent) {
607
- updateProgressSvg(this.loyaltyProgressEle, percent);
608
- }
609
- initLevelProgressbar() {
610
- setTimeout(() => {
611
- this.loyaltyProgressEle =
612
- this.elevateCardRef.parentElement.querySelector('#LevelProgress');
613
- if (!this.loyaltyProgressEle) {
614
- return;
615
- }
616
- this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
617
- ? 1 : (this.playerElevateLevel.loyaltyPoints / this.playerElevateLevel.nextLevel.entryPoints));
618
- this.params['playerElevateLevel'] = this.playerElevateLevel;
619
- }, 80);
620
- }
621
- componentDidRender() {
622
- this.initLevelProgressbar();
623
- }
624
- loadElevateInfo() {
625
- if (!this.params.endpoint || !this.params.session) {
626
- return;
429
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
430
+ expirationPoints: aboutToExpire.points,
431
+ expireDay: Math.max(daysToExpried, hoursToExpired, minutesToExpired),
432
+ });
433
+ return pointExpireInfoAsString;
434
+ }
435
+ loadPlayerLevelInfo() {
436
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
437
+ return new Promise((resolve, reject) => {
438
+ return fetch(url.href, {
439
+ method: 'GET',
440
+ headers: {
441
+ 'X-Sessionid': this.params.session,
442
+ 'Content-Type': 'application/json',
443
+ },
444
+ })
445
+ .then((res) => res.json())
446
+ .then((res) => {
447
+ var _a, _b, _c;
448
+ if (!res.success) {
449
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
450
+ reject(true);
451
+ return;
452
+ }
453
+ let playerElevateInfo = res.data;
454
+ this.playerElevateLevel = playerElevateInfo.level;
455
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
456
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
457
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
458
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
459
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
460
+ this.playerElevateLeveLoaded.emit({
461
+ elevateLevelWalletTotal: spendableTotal,
462
+ loyaltyWalletTotal
463
+ });
464
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
465
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
466
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
467
+ this.playerElevateLeveLoaded.emit({
468
+ pointExpireString: spExpireInfoAsString,
469
+ xpExpireString: xpExpireInfoAsString
470
+ });
471
+ }
472
+ resolve(this.playerElevateLevel);
473
+ })
474
+ .catch((err) => {
475
+ console.log('error ', err);
476
+ reject(true);
477
+ });
478
+ });
479
+ }
480
+ setLoyaltyProgress(percent) {
481
+ updateProgressSvg(this.loyaltyProgressEle, percent);
482
+ }
483
+ initLevelProgressbar() {
484
+ setTimeout(() => {
485
+ this.loyaltyProgressEle =
486
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
487
+ if (!this.loyaltyProgressEle) {
488
+ return;
489
+ }
490
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
491
+ ? 1 : (this.playerElevateLevel.loyaltyPoints / this.playerElevateLevel.nextLevel.entryPoints));
492
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
493
+ }, 80);
627
494
  }
628
- const promises = [];
629
- promises.push(this.loadPlayerLevelInfo());
630
- if (this.params.calculateLevelFlag) {
631
- promises.push(this.loadLevels());
495
+ componentDidRender() {
496
+ this.initLevelProgressbar();
632
497
  }
633
- Promise.all(promises).then((res) => {
634
- console.log('elevate-init', res);
635
- this.initLevelProgressbar();
636
- if (!this.levels) {
637
- return;
638
- }
639
- this.levels.sort((level1, level2) => {
640
- return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
641
- });
642
- const playerPoints = this.playerElevateLevel.loyaltyPoints;
643
- let playerLevelNumber = 0;
644
- this.levels.forEach((elevateLevel, idx) => {
645
- if (playerPoints > elevateLevel.firstEntryPoints) {
646
- playerLevelNumber = idx;
498
+ loadElevateInfo() {
499
+ if (!this.params.endpoint || !this.params.session) {
500
+ return;
647
501
  }
648
- });
649
- this.playerElevateLeveLoaded.emit({
650
- calculatedLevelFlag: playerLevelNumber,
651
- });
652
- });
653
- }
654
- componentWillLoad() {
655
- this.loadElevateInfo();
656
- }
657
- get elevateCardRef() { return getElement(this); }
658
- static get watchers() { return {
659
- "params": ["onParamsChanged"]
660
- }; }
502
+ const promises = [];
503
+ promises.push(this.loadPlayerLevelInfo());
504
+ if (this.params.calculateLevelFlag) {
505
+ promises.push(this.loadLevels());
506
+ }
507
+ Promise.all(promises).then((res) => {
508
+ console.log('elevate-init', res);
509
+ this.initLevelProgressbar();
510
+ if (!this.levels) {
511
+ return;
512
+ }
513
+ this.levels.sort((level1, level2) => {
514
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
515
+ });
516
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
517
+ let playerLevelNumber = 0;
518
+ this.levels.forEach((elevateLevel, idx) => {
519
+ if (playerPoints > elevateLevel.firstEntryPoints) {
520
+ playerLevelNumber = idx;
521
+ }
522
+ });
523
+ this.playerElevateLeveLoaded.emit({
524
+ calculatedLevelFlag: playerLevelNumber,
525
+ });
526
+ });
527
+ }
528
+ componentWillLoad() {
529
+ this.loadElevateInfo();
530
+ }
531
+ get elevateCardRef() { return getElement(this); }
532
+ static get watchers() { return {
533
+ "params": ["onParamsChanged"]
534
+ }; }
661
535
  };
662
- PlayerElevateCardData.style = playerElevateCardDataCss;
536
+ PlayerElevateCardData.style = PlayerElevateCardDataStyle0;
663
537
 
664
- const playerElevateLoyaltycardCss = ":host{display:block}@media screen and (min-width: 501px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:nowrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:11px;margin-left:5px}}@media screen and (max-width: 500px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:wrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:0px;margin-left:0px}}.LoyaltyCard .Inner .LevelProgress{margin-left:0px}.LoyaltyCard .Inner .Row .PointsInfo{width:100%}.LoyaltyCard .Inner .Row .PointsInfo.ExpirationPoints{text-align:left;color:var(--emfe-w-color-red-50, red)}.LoyaltyCard .Inner .PlayerAvatar .Avatar{display:none}.LoyaltyCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%}.LoyaltyCard .Inner .LevelInfo .ElevateLevel{display:flex;flex:1;align-items:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{position:relative;padding-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate .ExpireTime{margin-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .LevelName{padding-left:0;font-size:var(--emfe-w-elevate-fontsize-2xlarge, 21px);position:relative;width:auto;color:var(--emfe-w-elevate-color-levelname, #FFBD2B);font-weight:bold}.LoyaltyCard .Row{padding-top:3px;padding-bottom:5px}.LoyaltyCard .ExpireTime{margin-left:5px}.LoyaltyCard .NextLevelTip{text-align:right;font-size:11px;color:var(--emfe-w-color-black, #000);opacity:0.8;font-weight:bold}";
538
+ const playerElevateLoyaltycardCss = ":host{display:block}@media screen and (min-width: 501px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:nowrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:11px;margin-left:5px}}@media screen and (max-width: 500px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:wrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:0px;margin-left:0px}}.LoyaltyCard .Inner .LevelProgress{margin-left:0px}.LoyaltyCard .Inner .Row .PointsInfo.ExpirationPoints{text-align:left;color:var(--emw--color-red-50, red)}.LoyaltyCard .Inner .PlayerAvatar .Avatar{display:none}.LoyaltyCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%}.LoyaltyCard .Inner .LevelInfo .ElevateLevel{display:flex;flex:1;align-items:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{position:relative;padding-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate .ExpireTime{margin-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .LevelName{padding-left:0;font-size:var(--emw--elevate-fontsize-2xlarge, 21px);position:relative;width:auto;color:var(--emw--elevate-color-levelname, #FFBD2B);font-weight:bold}.LoyaltyCard .PointsRange{display:flex;justify-content:space-between}.LoyaltyCard .PointsRange .PointsInfo{width:auto}.LoyaltyCard .NextLevelTip{text-align:right;font-size:11px;color:var(--emw--color-black, #000);opacity:0.8;font-weight:bold}";
539
+ const PlayerElevateLoyaltycardStyle0 = playerElevateLoyaltycardCss;
665
540
 
666
541
  const PlayerElevateLoyaltycard = class {
667
- constructor(hostRef) {
668
- registerInstance(this, hostRef);
669
- /**
670
- * The style that widget shows,available value: Dark, Light
671
- * Default: Dark
672
- */
673
- this.theme = 'Dark';
674
- /**
675
- * Widget Language to show
676
- */
677
- this.language = 'en';
678
- /**
679
- * datePattern
680
- */
681
- this.dateFormat = 'yyyy-MM-dd';
682
- /**
683
- * Client custom styling via inline styles
684
- */
685
- this.clientStyling = '';
686
- /**
687
- * Client custom styling via url
688
- */
689
- this.clientStylingUrl = '';
690
- /**
691
- * Translation via url
692
- */
693
- this.translationUrl = '';
694
- }
695
- onSessionOrEndpointChange() {
696
- this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
697
- }
698
- playerElevateLeveLoadedHandler(event) {
699
- if (!event.detail) {
700
- return;
542
+ constructor(hostRef) {
543
+ registerInstance(this, hostRef);
544
+ /**
545
+ * The style that widget shows,available value: Dark, Light
546
+ * Default: Dark
547
+ */
548
+ this.theme = 'Dark';
549
+ /**
550
+ * Widget Language to show
551
+ */
552
+ this.language = 'en';
553
+ /**
554
+ * datePattern
555
+ */
556
+ this.dateFormat = 'yyyy-MM-dd';
557
+ /**
558
+ * Client custom styling via inline styles
559
+ */
560
+ this.clientStyling = '';
561
+ /**
562
+ * Client custom styling via url
563
+ */
564
+ this.clientStylingUrl = '';
565
+ /**
566
+ * Translation via url
567
+ */
568
+ this.translationUrl = '';
569
+ }
570
+ onSessionOrEndpointChange() {
571
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
572
+ }
573
+ playerElevateLeveLoadedHandler(event) {
574
+ if (!event.detail) {
575
+ return;
576
+ }
577
+ if (event.detail['elevateLevelWalletTotal']) {
578
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
579
+ }
580
+ if (event.detail['elevateLevel']) {
581
+ this.playerElevateLevel = event.detail['elevateLevel'];
582
+ }
583
+ if (event.detail['pointExpireString']) {
584
+ this.pointExpireString = event.detail.xpExpireString;
585
+ }
701
586
  }
702
- if (event.detail['elevateLevelWalletTotal']) {
703
- this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
587
+ onRedeemClick() {
588
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
704
589
  }
705
- if (event.detail['elevateLevel']) {
706
- this.playerElevateLevel = event.detail['elevateLevel'];
590
+ componentWillLoad() {
591
+ this.paramProxy = {
592
+ endpoint: this.endpoint,
593
+ session: this.session,
594
+ language: this.language,
595
+ };
707
596
  }
708
- if (event.detail['pointExpireString']) {
709
- this.pointExpireString = event.detail.xpExpireString;
597
+ getNextLevelPoints() {
598
+ var _a, _b;
599
+ return ((_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel) ? (_b = this.playerElevateLevel) === null || _b === void 0 ? void 0 : _b.nextLevel.entryPoints : -1;
600
+ }
601
+ getNextLevelTips() {
602
+ var _a;
603
+ //need xx to reach Diamond
604
+ let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
605
+ if (this.playerElevateLevel && nextLevel) {
606
+ const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
607
+ return translateWithParams('tipsForNextLevel', {
608
+ pointsToReach,
609
+ levelName: nextLevel.name,
610
+ lang: this.language
611
+ });
612
+ }
613
+ return '';
710
614
  }
711
- }
712
- onRedeemClick() {
713
- window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
714
- }
715
- componentWillLoad() {
716
- this.paramProxy = {
717
- endpoint: this.endpoint,
718
- session: this.session,
719
- language: this.language,
720
- };
721
- }
722
- getNextLevelTips() {
723
- var _a;
724
- //need xx to reach Diamond
725
- let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
726
- if (this.playerElevateLevel && nextLevel) {
727
- const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
728
- return translateWithParams('tipsForNextLevel', {
729
- pointsToReach,
730
- levelName: nextLevel.name,
731
- });
615
+ render() {
616
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
617
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
618
+ return (h("div", { key: '2b0944f8317a94621e1bc65bbbb3726654b8963b', class: `ElevateCardWrapper ${this.theme}` }, h("div", { key: 'c6d4dbba143435b4485d7fde91ab0a48a2f6688b', class: "LoyaltyCard Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { key: 'e47a4efe925eb35d4449c6ff33a0afef9d284e55', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), h("player-elevate-card-data", { key: 'a560991893305894ddd41756cd7b3c32d0ef9e03', params: this.paramProxy }), h("div", { key: 'ceb8b71386f84f54518a3694535aa16c2c3d3951', class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, h("div", { key: '1df9647c3de42e74adee0f8895511442118ae381', class: 'Content Row' }, this.playerElevateLevel && (h(Fragment, { key: '569bcd5fc3c578d2e6cc7442d28444e29688660c' }, h("div", { key: 'aa40032bff99c5462b906e4427232ca2d4019017', class: "PlayerImg" }, h(PlayerAvatar, { key: '7a2d535b0c2029c90b9f1c123f9feebafca6bdde', onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), h("div", { key: '90999da8fc2a3102eac235fcbc8afbec2a2bbdf8', class: `LevelInfo ${this.playerElevateLevel.name}` }, h(PlayerElevateLoyaltyLevel, { key: '67e8bf370b1b77e776fb6d955ae63928fd1338d8', hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), h("div", { key: '1e0fefc6a23f4aeeef5e19828399fe1229a3fc81', class: 'PointsRange' }, h(PlayerPoints, { key: 'dd176e624cde3b6f517101d7702a15465305174d', loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), h(PlayerPoints, { key: '6cddb64c92545803d08fbbc513cc951b2691a42e', loyaltyPoints: this.getNextLevelPoints(), language: this.language })), h(PlayerLoyaltyProcess, { key: '08817ca979ea784aeb735579b0d52e5150eb0852' }), h("div", { key: 'be9a1b40a8145d5e6d329d8e9f047296e84dd24b', class: "NextLevelTip" }, this.getNextLevelTips()), this.pointExpireString && (h("div", { key: 'f9cbb7d06e34717cb9f74cb8d2e506e49969e775', class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " "))))))))));
732
619
  }
733
- return '';
734
- }
735
- render() {
736
- const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
737
- const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
738
- return (h("div", { class: `ElevateCardWrapper ${this.theme}` }, h("div", { class: "LoyaltyCard Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS$1, translationUrl: this.translationUrl }), h("player-elevate-card-data", { params: this.paramProxy }), h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, h("div", { class: 'Content Row' }, this.playerElevateLevel && (h(Fragment, null, h("div", { class: "PlayerImg" }, h(PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, h("div", { class: 'CardCell ElevateLevel' }, h("span", { class: "LevelName", title: this.playerElevateLevel.name }, this.playerElevateLevel.name)), h(PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), this.pointExpireString && (h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), h(PlayerLoyaltyProcess, null), h("div", { class: "Row NextLevelTip" }, this.getNextLevelTips()), this.playerElevateLevel.expireTime && (h("div", { class: "Row CardCell ExpirationDate Txt" }, translate$1('expireOn', this.language), h("span", { class: "ExpireTime" }, format(new Date(this.playerElevateLevel.expireTime), this.dateFormat || 'yyyy-MM-dd'))))))))))));
739
- }
740
- static get watchers() { return {
741
- "session": ["onSessionOrEndpointChange"],
742
- "endpoint": ["onSessionOrEndpointChange"],
743
- "language": ["onSessionOrEndpointChange"]
744
- }; }
620
+ static get watchers() { return {
621
+ "session": ["onSessionOrEndpointChange"],
622
+ "endpoint": ["onSessionOrEndpointChange"],
623
+ "language": ["onSessionOrEndpointChange"]
624
+ }; }
745
625
  };
746
- PlayerElevateLoyaltycard.style = playerElevateLoyaltycardCss;
626
+ PlayerElevateLoyaltycard.style = PlayerElevateLoyaltycardStyle0;
747
627
 
748
- export { GamificationDropdown as gamification_dropdown, GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCardData as player_elevate_card_data, PlayerElevateLoyaltycard as player_elevate_loyaltycard };
628
+ export { GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCardData as player_elevate_card_data, PlayerElevateLoyaltycard as player_elevate_loyaltycard };