@everymatrix/gamification-dropdown 1.44.0 → 1.54.4

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