@everymatrix/player-elevate-level 1.32.4 → 1.33.1

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