@everymatrix/player-elevate-level 1.32.4 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/cjs/bonus-elevate-levels_8.cjs.entry.js +919 -0
  2. package/dist/cjs/index-c706b0d2.js +1726 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/player-elevate-card-items-31eb5d57.js +2477 -0
  6. package/dist/cjs/player-elevate-card.cjs.entry.js +77 -0
  7. package/dist/cjs/player-elevate-level.cjs.js +19 -0
  8. package/dist/cjs/player-elevate-pointcard.cjs.entry.js +84 -0
  9. package/dist/collection/collection-manifest.json +37 -0
  10. package/dist/collection/components/player-elevate-level/player-elevate-level.css +13 -0
  11. package/dist/collection/components/player-elevate-level/player-elevate-level.js +212 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/utils.js +0 -0
  14. package/dist/components/bonus-elevate-levels.js +6 -0
  15. package/dist/components/bonus-elevate-levels2.js +133 -0
  16. package/dist/components/elevate-level-list.js +6 -0
  17. package/dist/components/elevate-level-list2.js +177 -0
  18. package/dist/components/elevate-level-presentation.js +6 -0
  19. package/dist/components/elevate-level-presentation2.js +31 -0
  20. package/dist/components/elevate-levels-data.js +6 -0
  21. package/dist/components/elevate-levels-data2.js +102 -0
  22. package/dist/components/general-styling-wrapper.js +6 -0
  23. package/dist/components/general-styling-wrapper2.js +103 -0
  24. package/dist/components/index.d.ts +26 -0
  25. package/dist/components/index.js +1 -0
  26. package/dist/components/player-elevate-card-data.js +6 -0
  27. package/dist/components/player-elevate-card-data2.js +624 -0
  28. package/dist/components/player-elevate-card-items.js +2250 -0
  29. package/dist/components/player-elevate-card.js +118 -0
  30. package/dist/components/player-elevate-level.d.ts +11 -0
  31. package/dist/components/player-elevate-level.js +107 -0
  32. package/dist/components/player-elevate-loyaltycard.js +6 -0
  33. package/dist/components/player-elevate-loyaltycard2.js +121 -0
  34. package/dist/components/player-elevate-pointcard.js +127 -0
  35. package/dist/esm/bonus-elevate-levels_8.entry.js +908 -0
  36. package/dist/esm/index-104132db.js +1696 -0
  37. package/dist/esm/index.js +1 -0
  38. package/dist/esm/loader.js +17 -0
  39. package/dist/esm/player-elevate-card-items-289d91dc.js +2464 -0
  40. package/dist/esm/player-elevate-card.entry.js +73 -0
  41. package/dist/esm/player-elevate-level.js +17 -0
  42. package/dist/esm/player-elevate-pointcard.entry.js +80 -0
  43. package/dist/esm/polyfills/core-js.js +11 -0
  44. package/dist/esm/polyfills/css-shim.js +1 -0
  45. package/dist/esm/polyfills/dom.js +79 -0
  46. package/dist/esm/polyfills/es5-html-element.js +1 -0
  47. package/dist/esm/polyfills/index.js +34 -0
  48. package/dist/esm/polyfills/system.js +6 -0
  49. package/dist/index.cjs.js +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/player-elevate-level/index.esm.js +0 -0
  52. package/dist/player-elevate-level/p-34b6a7b6.entry.js +1 -0
  53. package/dist/player-elevate-level/p-46fd6f51.js +1 -0
  54. package/dist/player-elevate-level/p-b67b6b93.entry.js +1 -0
  55. package/dist/player-elevate-level/p-c73cc225.entry.js +1 -0
  56. package/dist/player-elevate-level/p-f43f6ed2.js +1 -0
  57. package/dist/player-elevate-level/player-elevate-level.esm.js +1 -0
  58. package/dist/static/button-default.svg +42 -0
  59. package/dist/static/button-disabled.svg +4 -0
  60. package/dist/static/button-hover.svg +4 -0
  61. package/dist/static/button-level.svg +27 -0
  62. package/dist/static/button-pressed.svg +18 -0
  63. package/dist/static/button-redeem.svg +36 -0
  64. package/dist/static/card-ground-over.png +0 -0
  65. package/dist/static/card-ground-over.svg +903 -0
  66. package/dist/static/card-ground.png +0 -0
  67. package/dist/static/card-ground.svg +34 -0
  68. package/dist/static/info.svg +4 -0
  69. package/dist/static/level-badge.png +0 -0
  70. package/dist/static/level-percent.svg +80 -0
  71. package/dist/static/tips-info.svg +21 -0
  72. package/dist/static/user.svg +3 -0
  73. package/dist/stencil.config.js +25 -0
  74. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/player-elevate-level/.stencil/packages/player-elevate-level/stencil.config.d.ts +2 -0
  75. package/dist/types/components/player-elevate-level/player-elevate-level.d.ts +43 -0
  76. package/dist/types/components.d.ts +109 -0
  77. package/dist/types/index.d.ts +1 -0
  78. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  79. package/dist/types/utils/utils.d.ts +0 -0
  80. package/loader/cdn.js +3 -0
  81. package/loader/index.cjs.js +3 -0
  82. package/loader/index.d.ts +12 -0
  83. package/loader/index.es2017.js +3 -0
  84. package/loader/index.js +4 -0
  85. package/loader/package.json +10 -0
  86. package/package.json +2 -3
  87. package/LICENSE +0 -21
@@ -0,0 +1,908 @@
1
+ import { r as registerInstance, h, c as createEvent, H as Host, g as getElement, a as getAssetPath, F as Fragment } from './index-104132db.js';
2
+ import { r as requiredArgs, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translateWithParams, T as TRANSLATIONS$1, P as PlayerAvatar, b as PlayerElevateLoyaltyLevel, c as PlayerPoints, d as PlayerLoyaltyProcess } from './player-elevate-card-items-289d91dc.js';
3
+
4
+ const DEFAULT_LANGUAGE = 'en';
5
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hu', 'hr'];
6
+ const TRANSLATIONS = {
7
+ en: {
8
+ seeAll: 'See All',
9
+ termsAndConditions: 'Terms & Conditions',
10
+ loadElevateLevelErrorMessage: 'Error when load elevate levels',
11
+ noLevelsSet: 'There is no level set',
12
+ },
13
+ fr: {
14
+ seeAll: 'See All',
15
+ termsAndConditions: 'Terms & Conditions',
16
+ loadElevateLevelErrorMessage: 'Error when load elevate levels',
17
+ noLevelsSet: 'There is no level set',
18
+ },
19
+ hr: {
20
+ level: 'Razina',
21
+ seeAll: 'Vidi sve',
22
+ privilegesFor: 'Privilegije za',
23
+ termsAndConditions: 'Uvjeti i odredbe',
24
+ noLevelsSet: 'There is no level set',
25
+ }
26
+ };
27
+ const translate = (key, customLang) => {
28
+ const lang = customLang;
29
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
30
+ };
31
+
32
+ const bonusElevateLevelsCss = ":host{display:block}.ElevateLevelContent{padding:20px;position:relative}.ElevateLevelContent .Privileges{padding-bottom:30px}.ElevateLevelContent .tc{position:absolute;right:10px;bottom:10px;text-align:right;display:none}";
33
+
34
+ const BonusElevateLevels = class {
35
+ constructor(hostRef) {
36
+ registerInstance(this, hostRef);
37
+ /**
38
+ * Client custom styling via string
39
+ */
40
+ this.clientStyling = '';
41
+ /**
42
+ * Client custom styling via url
43
+ */
44
+ this.clientStylingUrl = '';
45
+ /**
46
+ * Language of the widget
47
+ */
48
+ this.language = 'en';
49
+ /**
50
+ * The translationUrl
51
+ */
52
+ this.translationUrl = '';
53
+ /**
54
+ * Used in elevate level list
55
+ */
56
+ this.elevateLevels = [];
57
+ }
58
+ selectedLevelChangedHandler(event) {
59
+ if (event.detail) {
60
+ this.currentLevel = Object.assign({}, event.detail.level);
61
+ }
62
+ }
63
+ selectedLevelIdChangedHandler() {
64
+ if (this.selectedLevelId && this.elevateLevels) {
65
+ const currentLevel = this.elevateLevels.filter((item) => {
66
+ return item.id == this.selectedLevelId;
67
+ })[0];
68
+ this.currentLevel = Object.assign({}, currentLevel);
69
+ }
70
+ }
71
+ elevateLevelsDataChangeHandler(event) {
72
+ if (!event.detail) {
73
+ return;
74
+ }
75
+ if (event.detail.currentLevel) {
76
+ this.currentLevel = Object.assign({}, event.detail.currentLevel);
77
+ }
78
+ if (event.detail.elevateLevels) {
79
+ this.elevateLevels = [...event.detail.elevateLevels];
80
+ }
81
+ if (event.detail.clearError) {
82
+ this.errorMessage = null;
83
+ }
84
+ if (event.detail.errorMessage) {
85
+ if (event.detail.errorMessage['errorWhenLoadElevateLevels']) {
86
+ this.errorMessage = translate('loadElevateLevelErrorMessage', this.language);
87
+ }
88
+ }
89
+ }
90
+ onTCClick() {
91
+ window.postMessage({ type: 'termAndConditionClicked' }, window.location.href);
92
+ }
93
+ componentWillLoad() {
94
+ this.elevateLevelParamProxy = {
95
+ endpoint: this.endpoint, language: this.language, selectedLevelId: this.selectedLevelId,
96
+ showDefault: this.showDefault
97
+ };
98
+ }
99
+ render() {
100
+ return (h("div", { class: "ElevateLevelContent" }, h("elevate-levels-data", { scopeParams: this.elevateLevelParamProxy }), h("div", { class: "LevelContent" }, this.elevateLevels ?
101
+ h("elevate-level-list", { language: this.language, selectedLevelId: this.selectedLevelId, levels: this.elevateLevels }) : translate('noLevelsSet', this.language), this.currentLevel &&
102
+ h("elevate-level-presentation", { elevateLevel: this.currentLevel }), h("div", { class: "tc", onClick: this.onTCClick }, translate('termsAndConditions', this.language), ' ')), this.errorMessage && h("div", null, this.errorMessage), h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl })));
103
+ }
104
+ static get watchers() { return {
105
+ "selectedLevelId": ["selectedLevelIdChangedHandler"],
106
+ "elevateLevels": ["selectedLevelIdChangedHandler"]
107
+ }; }
108
+ };
109
+ BonusElevateLevels.style = bonusElevateLevelsCss;
110
+
111
+ /**
112
+ * @name isMobile
113
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
114
+ * @param {String} userAgent window.navigator.userAgent
115
+ * @returns {Boolean} true or false
116
+ */
117
+ const isMobile = (userAgent) => {
118
+ return !!(userAgent.toLowerCase().match(/android/i) ||
119
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
120
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
121
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
122
+ };
123
+ var MOVE_TO;
124
+ (function (MOVE_TO) {
125
+ MOVE_TO[MOVE_TO["slideToRight"] = 1] = "slideToRight";
126
+ MOVE_TO[MOVE_TO["slideToLeft"] = -1] = "slideToLeft";
127
+ })(MOVE_TO || (MOVE_TO = {}));
128
+
129
+ const elevateLevelListCss = "elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emfe-w-color-gray-50, #f4f4f4);box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emfe-w-color-gray-100, #767171);font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emfe-w-color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}";
130
+
131
+ const ElevateLevelList = class {
132
+ constructor(hostRef) {
133
+ registerInstance(this, hostRef);
134
+ this.selectedLevelChanged = createEvent(this, "selectedLevelChanged", 7);
135
+ this.isShowSliderButton = false;
136
+ this.offset = 0;
137
+ this.minOffset = 0;
138
+ this.isMobile = isMobile(window.navigator.userAgent);
139
+ }
140
+ onLevelClicked(elevateLevel) {
141
+ this.selectedLevelChanged.emit({ level: elevateLevel });
142
+ this.selectedLevelId = elevateLevel.id;
143
+ }
144
+ levelsChangedHandler() {
145
+ this.initOffsetOfLevelItems();
146
+ }
147
+ initOffsetOfLevelItems() {
148
+ if (!this.levels || this.levels.length == 0 || !this.selectedLevelId) {
149
+ return;
150
+ }
151
+ const currentLevelIndex = this.levels.findIndex((item) => {
152
+ return this.selectedLevelId == item.id;
153
+ });
154
+ this.onLevelClicked(this.levels[currentLevelIndex == -1 ? 0 : currentLevelIndex]);
155
+ //do not need change the slider offset when level items less than moveCountForOneTouch
156
+ if (this.levels.length <= this.moveCountForOneTouch) {
157
+ return;
158
+ }
159
+ //to avoid the slider do not move when currentLevelIndex = moveCountForOneTouch - 1
160
+ let newOffset = Math.floor((currentLevelIndex == -1 ? 1 : currentLevelIndex + 1) / this.moveCountForOneTouch)
161
+ * this.moveCountForOneTouch * this.childElementWidth * (-1);
162
+ this.offset = newOffset <= this.minOffset ? this.minOffset : (newOffset >= 0 ? 0 : newOffset);
163
+ }
164
+ onTouchStart(e) {
165
+ this.touchPosStart = { clientX: e.touches[0].clientX, clientY: e.touches[0].clientY };
166
+ }
167
+ onTouchMove(e) {
168
+ this.touchPosEnd = { clientX: e.touches[0].clientX, clientY: e.touches[0].clientY };
169
+ const diffX = this.touchPosEnd.clientX - this.touchPosStart.clientX;
170
+ const diffY = this.touchPosEnd.clientY - this.touchPosStart.clientY;
171
+ if (Math.abs(diffX) > Math.abs(diffY)) {
172
+ this.slideTo(diffX > 0 ? MOVE_TO.slideToRight : MOVE_TO.slideToLeft);
173
+ }
174
+ }
175
+ slideTo(direction) {
176
+ let newOffset = this.levelsElement.offsetLeft +
177
+ (this.childElementWidth) * this.moveCountForOneTouch * direction;
178
+ if (newOffset % this.childElementWidth != 0) {
179
+ const leftOfPreNode = (Math.floor(newOffset / this.childElementWidth)) * this.childElementWidth;
180
+ const leftOfNextNode = (Math.ceil(newOffset / this.childElementWidth)) * this.childElementWidth;
181
+ //touchmove to right, get left of pre-node; touchmove to left, get left of next-node
182
+ newOffset = direction == MOVE_TO.slideToRight ? leftOfPreNode : leftOfNextNode;
183
+ }
184
+ this.offset = newOffset < this.minOffset ? this.minOffset : (newOffset >= 0 ? 0 : newOffset);
185
+ }
186
+ initLevelSlider() {
187
+ var _a;
188
+ if (!((_a = this.levelsElement) === null || _a === void 0 ? void 0 : _a.firstElementChild)) {
189
+ console.log('Widget[elevate-level-list] DOM is not ready.');
190
+ return;
191
+ }
192
+ this.isShowSliderButton = !this.isMobile && (this.levelsElement.clientWidth > this.levelsElement.parentElement.clientWidth);
193
+ this.minOffset = this.levelsElement.parentElement.clientWidth - this.levelsElement.clientWidth;
194
+ this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
195
+ this.moveCountForOneTouch = Math.ceil(this.levelsElement.parentElement.clientWidth / this.childElementWidth) - 1;
196
+ const childElementCount = this.levelsElement.childElementCount;
197
+ this.childElementWidth += (this.levelsElement.clientWidth - this.childElementWidth * childElementCount) / (childElementCount - 1);
198
+ }
199
+ debounce(callback, delay) {
200
+ {
201
+ let timer;
202
+ return () => {
203
+ clearTimeout(timer);
204
+ timer = setTimeout(() => {
205
+ callback();
206
+ }, delay);
207
+ };
208
+ }
209
+ }
210
+ ;
211
+ handleResize() {
212
+ this.debounce(this.initLevelSlider.bind(this), 200)();
213
+ }
214
+ componentDidRender() {
215
+ this.host.componentOnReady().then(() => {
216
+ this.initLevelSlider();
217
+ });
218
+ }
219
+ render() {
220
+ return (h(Host, null, this.levels && [
221
+ h("div", { class: `SliderButton LeftButton ${this.offset == 0 ? 'Disabled' : ''} ${this.isShowSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToRight) }, h("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 19l-7-7 7-7" }))),
222
+ h("div", { class: 'LevelItemsWrapper' }, h("div", { style: { 'left': `${this.offset}px` }, class: `LevelItems ${this.isMobile ? 'Mobile' : ''}`, id: 'levelItems', ref: (el) => { this.levelsElement = el; } }, this.levels.map((level, idx) => {
223
+ return (h("div", { class: `Item ${this.selectedLevelId == level.id ? 'Active' : ''}`, onClick: this.onLevelClicked.bind(this, level) }, h("img", { alt: `Presentation Icon for ${level.presentation.displayName}`, class: "LevelImg", src: level.presentation.asset }), h("span", { class: "LevelName", title: level.presentation.displayName }, level.presentation.displayName), h("span", { class: "LevelPoints" }, idx == 0 ? '' : '>', level.firstEntryPoints, ' ', translate('points', this.language))));
224
+ }))),
225
+ h("div", { class: `SliderButton RightButton ${this.offset <= this.minOffset ? 'Disabled' : ''} ${this.isShowSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToLeft) }, h("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 5l7 7-7 7" })))
226
+ ]));
227
+ }
228
+ get host() { return getElement(this); }
229
+ static get watchers() { return {
230
+ "selectedLevelId": ["levelsChangedHandler"]
231
+ }; }
232
+ };
233
+ ElevateLevelList.style = elevateLevelListCss;
234
+
235
+ const elevateLevelPresentationCss = ":host{display:block}.PriviliegeList{padding-inline-start:5px}.PriviliegeList li{display:flex}.PriviliegeList li .Img{width:80px}.PriviliegeList li .Img img{width:60px;margin:10px}.PriviliegeList li .Content h4{text-transform:capitalize;margin-block-start:10px}";
236
+
237
+ const ElevateLevelPresentation = class {
238
+ constructor(hostRef) {
239
+ registerInstance(this, hostRef);
240
+ }
241
+ render() {
242
+ return h(Host, null, h("div", { class: "Row Desc" }, h("h3", null, this.elevateLevel.presentation.displayName), h("p", null, h("span", { class: "TxtDesc", innerHTML: this.elevateLevel.presentation.description }))));
243
+ }
244
+ };
245
+ ElevateLevelPresentation.style = elevateLevelPresentationCss;
246
+
247
+ function createCommonjsModule(fn, basedir, module) {
248
+ return module = {
249
+ path: basedir,
250
+ exports: {},
251
+ require: function (path, base) {
252
+ return commonjsRequire();
253
+ }
254
+ }, fn(module, module.exports), module.exports;
255
+ }
256
+
257
+ function commonjsRequire () {
258
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
259
+ }
260
+
261
+ var browser = createCommonjsModule(function (module, exports) {
262
+
263
+ // ref: https://github.com/tc39/proposal-global
264
+ var getGlobal = function () {
265
+ // the only reliable means to get the global object is
266
+ // `Function('return this')()`
267
+ // However, this causes CSP violations in Chrome apps.
268
+ if (typeof self !== 'undefined') { return self; }
269
+ if (typeof window !== 'undefined') { return window; }
270
+ if (typeof global !== 'undefined') { return global; }
271
+ throw new Error('unable to locate global object');
272
+ };
273
+
274
+ var global = getGlobal();
275
+
276
+ module.exports = exports = global.fetch;
277
+
278
+ // Needed for TypeScript and Webpack.
279
+ if (global.fetch) {
280
+ exports.default = global.fetch.bind(global);
281
+ }
282
+
283
+ exports.Headers = global.Headers;
284
+ exports.Request = global.Request;
285
+ exports.Response = global.Response;
286
+ });
287
+
288
+ const elevateLevelsDataCss = ":host{display:block}";
289
+
290
+ const ElevateLevelsData = class {
291
+ constructor(hostRef) {
292
+ registerInstance(this, hostRef);
293
+ this.elevateLevelsDataChange = createEvent(this, "elevateLevelsDataChange", 7);
294
+ }
295
+ async componentWillLoad() {
296
+ //load data
297
+ if (!this.scopeParams.endpoint) {
298
+ return;
299
+ }
300
+ const endpoint = this.scopeParams.endpoint;
301
+ let url = new URL(`${endpoint}/v1/elevate/levels?language=${this.scopeParams.language}`);
302
+ await browser(url.href)
303
+ .then((res) => res.json())
304
+ .then((res) => {
305
+ const elevateLevels = res.data.sort((a, b) => {
306
+ return a.firstEntryPoints < b.firstEntryPoints ? -1 : 1;
307
+ });
308
+ let selectedLevelId = this.scopeParams.selectedLevelId;
309
+ // if selected level is not set, set first(basic) as default
310
+ if (!selectedLevelId && this.scopeParams.showDefault && elevateLevels.length > 0) {
311
+ selectedLevelId = elevateLevels[0].id;
312
+ }
313
+ if (selectedLevelId) {
314
+ // get current level by name
315
+ const currentLevel = elevateLevels.filter((item) => {
316
+ return item.id == selectedLevelId;
317
+ })[0];
318
+ this.elevateLevelsDataChange.emit({ currentLevel: currentLevel });
319
+ }
320
+ this.elevateLevelsDataChange.emit({ 'clearError': true });
321
+ this.elevateLevelsDataChange.emit({ 'elevateLevels': elevateLevels });
322
+ }).catch((err) => {
323
+ this.elevateLevelsDataChange.emit({ errorMessage: { type: 'errorWhenLoadElevateLevels', err } });
324
+ console.error(err);
325
+ });
326
+ }
327
+ };
328
+ ElevateLevelsData.style = elevateLevelsDataCss;
329
+
330
+ const mergeTranslations = (url, target) => {
331
+ return new Promise((resolve) => {
332
+ fetch(url)
333
+ .then((res) => res.json())
334
+ .then((data) => {
335
+ Object.keys(data).forEach((item) => {
336
+ target[item] = target[item] ? target[item] : {};
337
+ for (let key in data[item]) {
338
+ target[item][key] = data[item][key];
339
+ }
340
+ });
341
+ resolve(true);
342
+ });
343
+ });
344
+ };
345
+
346
+ const generalStylingWrapperCss = ":host{display:block}";
347
+
348
+ const GeneralStylingWrapper = class {
349
+ constructor(hostRef) {
350
+ registerInstance(this, hostRef);
351
+ /**
352
+ * Client custom styling via inline styles
353
+ */
354
+ this.clientStyling = '';
355
+ /**
356
+ * Client custom styling via url
357
+ */
358
+ this.clientStylingUrl = '';
359
+ /**
360
+ * Translation via url
361
+ */
362
+ this.translationUrl = '';
363
+ this.stylingAppends = false;
364
+ this.setClientStyling = () => {
365
+ let sheet = document.createElement('style');
366
+ sheet.innerHTML = this.clientStyling;
367
+ this.el.prepend(sheet);
368
+ };
369
+ this.setClientStylingURL = () => {
370
+ let url = new URL(this.clientStylingUrl);
371
+ let cssFile = document.createElement('style');
372
+ fetch(url.href)
373
+ .then((res) => res.text())
374
+ .then((data) => {
375
+ cssFile.innerHTML = data;
376
+ setTimeout(() => {
377
+ this.el.prepend(cssFile);
378
+ }, 1);
379
+ })
380
+ .catch((err) => {
381
+ console.log('error ', err);
382
+ });
383
+ };
384
+ }
385
+ componentDidRender() {
386
+ // start custom styling area
387
+ if (!this.stylingAppends) {
388
+ if (this.clientStyling)
389
+ this.setClientStyling();
390
+ if (this.clientStylingUrl)
391
+ this.setClientStylingURL();
392
+ this.stylingAppends = true;
393
+ }
394
+ // end custom styling area
395
+ }
396
+ async componentWillLoad() {
397
+ const promises = [];
398
+ if (this.translationUrl) {
399
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
400
+ promises.push(translationPromise);
401
+ }
402
+ return await Promise.all(promises);
403
+ }
404
+ render() {
405
+ return (h("div", { class: "StyleShell" }, h("slot", { name: "mainContent" })));
406
+ }
407
+ get el() { return getElement(this); }
408
+ };
409
+ GeneralStylingWrapper.style = generalStylingWrapperCss;
410
+
411
+ /**
412
+ * @name startOfDay
413
+ * @category Day Helpers
414
+ * @summary Return the start of a day for the given date.
415
+ *
416
+ * @description
417
+ * Return the start of a day for the given date.
418
+ * The result will be in the local timezone.
419
+ *
420
+ * @param {Date|Number} date - the original date
421
+ * @returns {Date} the start of a day
422
+ * @throws {TypeError} 1 argument required
423
+ *
424
+ * @example
425
+ * // The start of a day for 2 September 2014 11:55:00:
426
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
427
+ * //=> Tue Sep 02 2014 00:00:00
428
+ */
429
+ function startOfDay(dirtyDate) {
430
+ requiredArgs(1, arguments);
431
+ var date = toDate(dirtyDate);
432
+ date.setHours(0, 0, 0, 0);
433
+ return date;
434
+ }
435
+
436
+ var MILLISECONDS_IN_DAY = 86400000;
437
+
438
+ /**
439
+ * @name differenceInCalendarDays
440
+ * @category Day Helpers
441
+ * @summary Get the number of calendar days between the given dates.
442
+ *
443
+ * @description
444
+ * Get the number of calendar days between the given dates. This means that the times are removed
445
+ * from the dates and then the difference in days is calculated.
446
+ *
447
+ * @param {Date|Number} dateLeft - the later date
448
+ * @param {Date|Number} dateRight - the earlier date
449
+ * @returns {Number} the number of calendar days
450
+ * @throws {TypeError} 2 arguments required
451
+ *
452
+ * @example
453
+ * // How many calendar days are between
454
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
455
+ * const result = differenceInCalendarDays(
456
+ * new Date(2012, 6, 2, 0, 0),
457
+ * new Date(2011, 6, 2, 23, 0)
458
+ * )
459
+ * //=> 366
460
+ * // How many calendar days are between
461
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
462
+ * const result = differenceInCalendarDays(
463
+ * new Date(2011, 6, 3, 0, 1),
464
+ * new Date(2011, 6, 2, 23, 59)
465
+ * )
466
+ * //=> 1
467
+ */
468
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
469
+ requiredArgs(2, arguments);
470
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
471
+ var startOfDayRight = startOfDay(dirtyDateRight);
472
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
473
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
474
+
475
+ // Round the number of days to the nearest integer
476
+ // because the number of milliseconds in a day is not constant
477
+ // (e.g. it's different in the day of the daylight saving time clock shift)
478
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
479
+ }
480
+
481
+ /**
482
+ * Days in 1 week.
483
+ *
484
+ * @name daysInWeek
485
+ * @constant
486
+ * @type {number}
487
+ * @default
488
+ */
489
+
490
+ /**
491
+ * Milliseconds in 1 hour
492
+ *
493
+ * @name millisecondsInHour
494
+ * @constant
495
+ * @type {number}
496
+ * @default
497
+ */
498
+ var millisecondsInHour = 3600000;
499
+
500
+ /**
501
+ * @name differenceInMilliseconds
502
+ * @category Millisecond Helpers
503
+ * @summary Get the number of milliseconds between the given dates.
504
+ *
505
+ * @description
506
+ * Get the number of milliseconds between the given dates.
507
+ *
508
+ * @param {Date|Number} dateLeft - the later date
509
+ * @param {Date|Number} dateRight - the earlier date
510
+ * @returns {Number} the number of milliseconds
511
+ * @throws {TypeError} 2 arguments required
512
+ *
513
+ * @example
514
+ * // How many milliseconds are between
515
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
516
+ * const result = differenceInMilliseconds(
517
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
518
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
519
+ * )
520
+ * //=> 1100
521
+ */
522
+ function differenceInMilliseconds(dateLeft, dateRight) {
523
+ requiredArgs(2, arguments);
524
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
525
+ }
526
+
527
+ var roundingMap = {
528
+ ceil: Math.ceil,
529
+ round: Math.round,
530
+ floor: Math.floor,
531
+ trunc: function trunc(value) {
532
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
533
+ } // Math.trunc is not supported by IE
534
+ };
535
+
536
+ var defaultRoundingMethod = 'trunc';
537
+ function getRoundingMethod(method) {
538
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
539
+ }
540
+
541
+ /**
542
+ * @name differenceInHours
543
+ * @category Hour Helpers
544
+ * @summary Get the number of hours between the given dates.
545
+ *
546
+ * @description
547
+ * Get the number of hours between the given dates.
548
+ *
549
+ * @param {Date|Number} dateLeft - the later date
550
+ * @param {Date|Number} dateRight - the earlier date
551
+ * @param {Object} [options] - an object with options.
552
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
553
+ * @returns {Number} the number of hours
554
+ * @throws {TypeError} 2 arguments required
555
+ *
556
+ * @example
557
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
558
+ * const result = differenceInHours(
559
+ * new Date(2014, 6, 2, 19, 0),
560
+ * new Date(2014, 6, 2, 6, 50)
561
+ * )
562
+ * //=> 12
563
+ */
564
+ function differenceInHours(dateLeft, dateRight, options) {
565
+ requiredArgs(2, arguments);
566
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
567
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
568
+ }
569
+
570
+ /**
571
+ * @name isBefore
572
+ * @category Common Helpers
573
+ * @summary Is the first date before the second one?
574
+ *
575
+ * @description
576
+ * Is the first date before the second one?
577
+ *
578
+ * @param {Date|Number} date - the date that should be before the other one to return true
579
+ * @param {Date|Number} dateToCompare - the date to compare with
580
+ * @returns {Boolean} the first date is before the second date
581
+ * @throws {TypeError} 2 arguments required
582
+ *
583
+ * @example
584
+ * // Is 10 July 1989 before 11 February 1987?
585
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
586
+ * //=> false
587
+ */
588
+ function isBefore(dirtyDate, dirtyDateToCompare) {
589
+ requiredArgs(2, arguments);
590
+ var date = toDate(dirtyDate);
591
+ var dateToCompare = toDate(dirtyDateToCompare);
592
+ return date.getTime() < dateToCompare.getTime();
593
+ }
594
+
595
+ function updateProgressSvg(progressElementRef, percent) {
596
+ const svgElement = progressElementRef.querySelector('#total_level');
597
+ const endLockWidth = 15;
598
+ const barWidth = svgElement.getBBox().width;
599
+ const widthOnBar = percent * barWidth - endLockWidth < 0 ? 0 : percent * barWidth - endLockWidth;
600
+ //update bar's width, widthOnBar
601
+ const levelBar = progressElementRef.querySelector('#current_level');
602
+ //update filters, x = widthOnBar
603
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
604
+ //update circle, widthOnBar+10
605
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
606
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
607
+ levelBar.setAttribute('width', `${widthOnBar}`);
608
+ levelCircle.setAttribute('cx', `${widthOnBar + 3}`);
609
+ levelFilter.setAttribute('x', `${widthOnBar - 4}`);
610
+ //update lock location
611
+ const endLockElement = progressElementRef.querySelector('#lock');
612
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
613
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
614
+ // ball in endlockfilter2_i_305_23
615
+ const filter2 = progressElementRef.querySelector('#filter_ball');
616
+ // heart in endlockfilter3_d_305_23
617
+ const filter3 = progressElementRef.querySelector('#filter_heart');
618
+ //wrapper of lockfilter4_d_305_23
619
+ const filterLock = progressElementRef.querySelector('#filter_lock');
620
+ // shadow of ball paint0_linear_305_23
621
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
622
+ //paint in lockpaint1_linear_305_23
623
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
624
+ // box of lock and heart, for move position dynamically
625
+ const lockBox = progressElementRef.querySelector('#lock_box');
626
+ const heartBox = progressElementRef.querySelector('#heart_box');
627
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
628
+ //set cx of lockElement
629
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
630
+ //set cx of sub Elements
631
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
632
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
633
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
634
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
635
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
636
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
637
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
638
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
639
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
640
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
641
+ }
642
+
643
+ 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 .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}";
644
+
645
+ const PlayerElevateCardData = class {
646
+ constructor(hostRef) {
647
+ registerInstance(this, hostRef);
648
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
649
+ }
650
+ handleWindowResizs() {
651
+ this.initLevelProgressbar();
652
+ }
653
+ onRedeemClick() {
654
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
655
+ }
656
+ loadLevels() {
657
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
658
+ return new Promise((resolve, reject) => {
659
+ return fetch(url.href, {
660
+ method: 'GET',
661
+ })
662
+ .then((res) => res.json())
663
+ .then((res) => {
664
+ this.levels = res.data;
665
+ resolve(true);
666
+ })
667
+ .catch((err) => {
668
+ reject(err);
669
+ });
670
+ });
671
+ }
672
+ calcuatePointsToBeExpired(walletTotalInfo) {
673
+ let pointExpireInfoAsString = '';
674
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
675
+ walletTotalInfo.aboutToExpire.length == 0 ||
676
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
677
+ return pointExpireInfoAsString;
678
+ }
679
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
680
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
681
+ ? -1
682
+ : 1;
683
+ });
684
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
685
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
686
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
687
+ if (daysToExpried == 0) {
688
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
689
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
690
+ }
691
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
692
+ expirationPoints: aboutToExpire.points,
693
+ expireDay: daysToExpried,
694
+ });
695
+ return pointExpireInfoAsString;
696
+ }
697
+ loadPlayerLevelInfo() {
698
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
699
+ return new Promise((resolve, reject) => {
700
+ return fetch(url.href, {
701
+ method: 'GET',
702
+ headers: {
703
+ 'X-Sessionid': this.params.session,
704
+ 'Content-Type': 'application/json',
705
+ },
706
+ })
707
+ .then((res) => res.json())
708
+ .then((res) => {
709
+ var _a, _b, _c;
710
+ if (!res.success) {
711
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
712
+ reject(true);
713
+ return;
714
+ }
715
+ let playerElevateInfo = res.data;
716
+ this.playerElevateLevel = playerElevateInfo.level;
717
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
718
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
719
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
720
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
721
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
722
+ this.playerElevateLeveLoaded.emit({
723
+ elevateLevelWalletTotal: spendableTotal,
724
+ loyaltyWalletTotal
725
+ });
726
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
727
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
728
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
729
+ this.playerElevateLeveLoaded.emit({
730
+ pointExpireString: spExpireInfoAsString,
731
+ xpExpireString: xpExpireInfoAsString
732
+ });
733
+ }
734
+ resolve(this.playerElevateLevel);
735
+ })
736
+ .catch((err) => {
737
+ console.log('error ', err);
738
+ reject(true);
739
+ });
740
+ });
741
+ }
742
+ setLoyaltyProgress(percent) {
743
+ updateProgressSvg(this.loyaltyProgressEle, percent);
744
+ }
745
+ initLevelProgressbar() {
746
+ setTimeout(() => {
747
+ this.loyaltyProgressEle =
748
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
749
+ if (!this.loyaltyProgressEle) {
750
+ return;
751
+ }
752
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
753
+ ? 1
754
+ : (this.playerElevateLevel.loyaltyPoints -
755
+ this.playerElevateLevel.entryPoints) /
756
+ (this.playerElevateLevel.nextLevel.entryPoints -
757
+ this.playerElevateLevel.loyaltyPoints));
758
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
759
+ }, 80);
760
+ }
761
+ componentWillRender() { }
762
+ componentDidRender() {
763
+ this.initLevelProgressbar();
764
+ }
765
+ componentWillLoad() {
766
+ if (!this.params.endpoint || !this.params.session) {
767
+ return;
768
+ }
769
+ const promises = [];
770
+ promises.push(this.loadPlayerLevelInfo());
771
+ if (this.params.calculateLevelFlag) {
772
+ promises.push(this.loadLevels());
773
+ }
774
+ Promise.all(promises).then((res) => {
775
+ console.log('elevate-init', res);
776
+ this.initLevelProgressbar();
777
+ if (!this.levels) {
778
+ return;
779
+ }
780
+ this.levels.sort((level1, level2) => {
781
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
782
+ });
783
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
784
+ let playerLevelNumber = 0;
785
+ this.levels.forEach((elevateLevel, idx) => {
786
+ if (playerPoints > elevateLevel.firstEntryPoints) {
787
+ playerLevelNumber = idx;
788
+ }
789
+ });
790
+ this.playerElevateLeveLoaded.emit({
791
+ calculatedLevelFlag: playerLevelNumber,
792
+ });
793
+ });
794
+ }
795
+ get elevateCardRef() { return getElement(this); }
796
+ };
797
+ PlayerElevateCardData.style = playerElevateCardDataCss;
798
+
799
+ const playerElevateLevelCss = ":host{display:block}.PlayerElevateCard{height:160px;width:100%;overflow:hidden}.ElevateLevelsInfo{background-color:var(--emw--color-background, #e6e8ea)}";
800
+
801
+ const PlayerElevateLevel = class {
802
+ constructor(hostRef) {
803
+ registerInstance(this, hostRef);
804
+ /**
805
+ * datePattern
806
+ */
807
+ this.dateFormat = 'yyyy-MM-dd';
808
+ /**
809
+ * Client custom styling via inline styles
810
+ */
811
+ this.clientStyling = '';
812
+ /**
813
+ * Client custom styling via url
814
+ */
815
+ this.clientStylingUrl = '';
816
+ /**
817
+ * Translation via url
818
+ */
819
+ this.translationUrl = '';
820
+ }
821
+ async setPlayerElevateLevelInfo(event) {
822
+ if (event.type == 'playerElevateLeveLoaded' && event.detail['elevateLevel']) {
823
+ this.userLevelId = event.detail['elevateLevel'].id;
824
+ }
825
+ }
826
+ render() {
827
+ return h(Host, null, h("div", { class: 'PlayerElevateCard' }, h("player-elevate-loyaltycard", { playerName: this.playerName, dateFormat: this.dateFormat, clientStylingUrl: this.clientStylingUrl, translationUrl: this.translationUrl, clientStyling: `${this.clientStyling} .Outer{height: 185px}`, endpoint: this.endpoint, language: this.language, session: this.session })), h("div", { class: 'ElevateLevelsInfo' }, h("bonus-elevate-levels", { selectedLevelId: this.userLevelId, clientStyling: this.clientStyling, translationUrl: this.translationUrl, language: this.language, endpoint: this.endpoint })));
828
+ }
829
+ };
830
+ PlayerElevateLevel.style = playerElevateLevelCss;
831
+
832
+ 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 .NextLevelTip{text-align:right;font-size:11px;color:var(--emfe-w-color-black, #000);opacity:0.8;font-weight:bold}";
833
+
834
+ const PlayerElevateLoyaltycard = class {
835
+ constructor(hostRef) {
836
+ registerInstance(this, hostRef);
837
+ /**
838
+ * The style that widget shows,available value: Dark, Light
839
+ * Default: Dark
840
+ */
841
+ this.theme = 'Dark';
842
+ /**
843
+ * Widget Language to show
844
+ */
845
+ this.language = 'en';
846
+ /**
847
+ * datePattern
848
+ */
849
+ this.dateFormat = 'yyyy-MM-dd';
850
+ /**
851
+ * Client custom styling via inline styles
852
+ */
853
+ this.clientStyling = '';
854
+ /**
855
+ * Client custom styling via url
856
+ */
857
+ this.clientStylingUrl = '';
858
+ /**
859
+ * Translation via url
860
+ */
861
+ this.translationUrl = '';
862
+ }
863
+ playerElevateLeveLoadedHandler(event) {
864
+ if (!event.detail) {
865
+ return;
866
+ }
867
+ if (event.detail['elevateLevelWalletTotal']) {
868
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
869
+ }
870
+ if (event.detail['elevateLevel']) {
871
+ this.playerElevateLevel = event.detail['elevateLevel'];
872
+ }
873
+ if (event.detail['pointExpireString']) {
874
+ this.pointExpireString = event.detail.xpExpireString;
875
+ }
876
+ }
877
+ onRedeemClick() {
878
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
879
+ }
880
+ componentWillLoad() {
881
+ this.paramsProxy = {
882
+ endpoint: this.endpoint,
883
+ session: this.session,
884
+ language: this.language,
885
+ };
886
+ }
887
+ getNextLevelTips() {
888
+ var _a;
889
+ //need xx to reach Diamond
890
+ let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
891
+ if (this.playerElevateLevel && nextLevel) {
892
+ const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
893
+ return translateWithParams('tipsForNextLevel', {
894
+ pointsToReach,
895
+ levelName: nextLevel.name,
896
+ });
897
+ }
898
+ return '';
899
+ }
900
+ render() {
901
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
902
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
903
+ 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.paramsProxy }), 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(PlayerElevateLoyaltyLevel, { hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), h(PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), this.pointExpireString && (h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), h(PlayerLoyaltyProcess, null), h("div", { class: "NextLevelTip" }, this.getNextLevelTips())))))))));
904
+ }
905
+ };
906
+ PlayerElevateLoyaltycard.style = playerElevateLoyaltycardCss;
907
+
908
+ export { BonusElevateLevels as bonus_elevate_levels, ElevateLevelList as elevate_level_list, ElevateLevelPresentation as elevate_level_presentation, ElevateLevelsData as elevate_levels_data, GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCardData as player_elevate_card_data, PlayerElevateLevel as player_elevate_level, PlayerElevateLoyaltycard as player_elevate_loyaltycard };