@everymatrix/player-elevate-card-jojogroup 1.80.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/general-styling-wrapper_6.cjs.entry.js +3570 -0
  3. package/dist/cjs/index-51874d29.js +1619 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +15 -0
  6. package/dist/cjs/player-elevate-card-jojogroup.cjs.js +25 -0
  7. package/dist/collection/collection-manifest.json +23 -0
  8. package/dist/collection/components/player-elevate-card-data/player-elevate-card-data.css +192 -0
  9. package/dist/collection/components/player-elevate-card-data/player-elevate-card-data.js +244 -0
  10. package/dist/collection/components/player-elevate-card-jojogroup/index.js +1 -0
  11. package/dist/collection/components/player-elevate-card-jojogroup/player-elevate-card-jojogroup-items.js +23 -0
  12. package/dist/collection/components/player-elevate-card-jojogroup/player-elevate-card-jojogroup.css +64 -0
  13. package/dist/collection/components/player-elevate-card-jojogroup/player-elevate-card-jojogroup.js +297 -0
  14. package/dist/collection/components/player-elevate-loyaltycard-jojogroup/player-elevate-loyaltycard-jojogroup.css +98 -0
  15. package/dist/collection/components/player-elevate-loyaltycard-jojogroup/player-elevate-loyaltycard-jojogroup.js +310 -0
  16. package/dist/collection/components/player-elevate-pointcard/player-elevate-pointcard.css +70 -0
  17. package/dist/collection/components/player-elevate-pointcard/player-elevate-pointcard.js +334 -0
  18. package/dist/collection/components/player-rakeback-card/player-rakeback-card.css +87 -0
  19. package/dist/collection/components/player-rakeback-card/player-rakeback-card.js +357 -0
  20. package/dist/collection/components/static/button-default.svg +42 -0
  21. package/dist/collection/components/static/button-disabled.svg +4 -0
  22. package/dist/collection/components/static/button-hover.svg +4 -0
  23. package/dist/collection/components/static/button-level.svg +27 -0
  24. package/dist/collection/components/static/button-pressed.svg +18 -0
  25. package/dist/collection/components/static/button-redeem.svg +36 -0
  26. package/dist/collection/components/static/card-ground-over.png +0 -0
  27. package/dist/collection/components/static/card-ground-over.svg +903 -0
  28. package/dist/collection/components/static/card-ground.png +0 -0
  29. package/dist/collection/components/static/card-ground.svg +34 -0
  30. package/dist/collection/components/static/info.svg +4 -0
  31. package/dist/collection/components/static/level-badge.png +0 -0
  32. package/dist/collection/components/static/level-percent.svg +80 -0
  33. package/dist/collection/components/static/tips-info.svg +21 -0
  34. package/dist/collection/components/static/user.svg +3 -0
  35. package/dist/collection/index.js +1 -0
  36. package/dist/collection/models/player-elevate.js +1 -0
  37. package/dist/collection/utils/locale.utils.js +238 -0
  38. package/dist/collection/utils/utils.js +51 -0
  39. package/dist/esm/app-globals-0f993ce5.js +3 -0
  40. package/dist/esm/general-styling-wrapper_6.entry.js +3561 -0
  41. package/dist/esm/index-9498ebd7.js +1589 -0
  42. package/dist/esm/index.js +1 -0
  43. package/dist/esm/loader.js +11 -0
  44. package/dist/esm/player-elevate-card-jojogroup.js +20 -0
  45. package/dist/index.cjs.js +1 -0
  46. package/dist/index.js +1 -0
  47. package/dist/player-elevate-card-jojogroup/app-globals-0f993ce5.js +1 -0
  48. package/dist/player-elevate-card-jojogroup/general-styling-wrapper_6.entry.js +1 -0
  49. package/dist/player-elevate-card-jojogroup/index-9498ebd7.js +2 -0
  50. package/dist/player-elevate-card-jojogroup/index.esm.js +0 -0
  51. package/dist/player-elevate-card-jojogroup/player-elevate-card-jojogroup.esm.js +1 -0
  52. package/dist/static/button-default.svg +42 -0
  53. package/dist/static/button-disabled.svg +4 -0
  54. package/dist/static/button-hover.svg +4 -0
  55. package/dist/static/button-level.svg +27 -0
  56. package/dist/static/button-pressed.svg +18 -0
  57. package/dist/static/button-redeem.svg +36 -0
  58. package/dist/static/card-ground-over.png +0 -0
  59. package/dist/static/card-ground-over.svg +903 -0
  60. package/dist/static/card-ground.png +0 -0
  61. package/dist/static/card-ground.svg +34 -0
  62. package/dist/static/info.svg +4 -0
  63. package/dist/static/level-badge.png +0 -0
  64. package/dist/static/level-percent.svg +80 -0
  65. package/dist/static/tips-info.svg +21 -0
  66. package/dist/static/user.svg +3 -0
  67. package/dist/stencil.config.dev.js +18 -0
  68. package/dist/stencil.config.js +20 -0
  69. package/dist/storybook/main.js +47 -0
  70. package/dist/storybook/preview.js +9 -0
  71. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  72. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/packages/stencil/player-elevate-card-jojogroup/stencil.config.d.ts +2 -0
  73. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/packages/stencil/player-elevate-card-jojogroup/stencil.config.dev.d.ts +2 -0
  74. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/packages/stencil/player-elevate-card-jojogroup/storybook/main.d.ts +3 -0
  75. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/packages/stencil/player-elevate-card-jojogroup/storybook/preview.d.ts +70 -0
  76. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/tools/plugins/index.d.ts +4 -0
  77. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  78. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  79. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  80. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-card-jojogroup/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  81. package/dist/types/components/player-elevate-card-data/player-elevate-card-data.d.ts +24 -0
  82. package/dist/types/components/player-elevate-card-jojogroup/index.d.ts +1 -0
  83. package/dist/types/components/player-elevate-card-jojogroup/player-elevate-card-jojogroup-items.d.ts +20 -0
  84. package/dist/types/components/player-elevate-card-jojogroup/player-elevate-card-jojogroup.d.ts +56 -0
  85. package/dist/types/components/player-elevate-loyaltycard-jojogroup/player-elevate-loyaltycard-jojogroup.d.ts +59 -0
  86. package/dist/types/components/player-elevate-pointcard/player-elevate-pointcard.d.ts +69 -0
  87. package/dist/types/components/player-rakeback-card/player-rakeback-card.d.ts +65 -0
  88. package/dist/types/components.d.ts +461 -0
  89. package/dist/types/index.d.ts +1 -0
  90. package/dist/types/models/player-elevate.d.ts +40 -0
  91. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  92. package/dist/types/utils/locale.utils.d.ts +15 -0
  93. package/dist/types/utils/utils.d.ts +1 -0
  94. package/loader/cdn.js +1 -0
  95. package/loader/index.cjs.js +1 -0
  96. package/loader/index.d.ts +24 -0
  97. package/loader/index.es2017.js +1 -0
  98. package/loader/index.js +2 -0
  99. package/loader/package.json +11 -0
  100. package/package.json +26 -0
@@ -0,0 +1,3570 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-51874d29.js');
6
+
7
+ const mergeTranslations = (url, target) => {
8
+ return new Promise((resolve) => {
9
+ fetch(url)
10
+ .then((res) => res.json())
11
+ .then((data) => {
12
+ Object.keys(data).forEach((item) => {
13
+ target[item] = target[item] || {};
14
+ Object.keys(data[item]).forEach((key) => {
15
+ //if there is no key in target, do nothing
16
+ if (!target['en'][key]) {
17
+ return;
18
+ }
19
+ const defaultTranslation = target['en'][key];
20
+ if (typeof data[item][key] === 'object') {
21
+ // if the key is not in target, then take from en
22
+ target[item][key] = target[item][key] || Object.assign({}, defaultTranslation);
23
+ Object.keys(data[item][key]).forEach((subKey) => {
24
+ target[item][key][subKey] = data[item][key][subKey];
25
+ });
26
+ }
27
+ else {
28
+ target[item][key] = data[item][key] || Object.assign({}, defaultTranslation);
29
+ }
30
+ });
31
+ });
32
+ resolve(true);
33
+ })
34
+ .catch(err => {
35
+ console.error("Failed to load translations:", err);
36
+ resolve(false);
37
+ });
38
+ });
39
+ };
40
+
41
+ /**
42
+ * @name setClientStyling
43
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
44
+ * @param {HTMLElement} stylingContainer The reference element of the widget
45
+ * @param {string} clientStyling The style content
46
+ */
47
+ function setClientStyling(stylingContainer, clientStyling) {
48
+ if (stylingContainer) {
49
+ const sheet = document.createElement('style');
50
+ sheet.innerHTML = clientStyling;
51
+ stylingContainer.appendChild(sheet);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * @name setClientStylingURL
57
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
58
+ * @param {HTMLElement} stylingContainer The reference element of the widget
59
+ * @param {string} clientStylingUrl The URL of the style content
60
+ */
61
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
62
+ const url = new URL(clientStylingUrl);
63
+
64
+ fetch(url.href)
65
+ .then((res) => res.text())
66
+ .then((data) => {
67
+ const cssFile = document.createElement('style');
68
+ cssFile.innerHTML = data;
69
+ if (stylingContainer) {
70
+ stylingContainer.appendChild(cssFile);
71
+ }
72
+ })
73
+ .catch((err) => {
74
+ console.error('There was an error while trying to load client styling from URL', err);
75
+ });
76
+ }
77
+
78
+ /**
79
+ * @name setStreamLibrary
80
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
81
+ * @param {HTMLElement} stylingContainer The highest element of the widget
82
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
83
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
84
+ */
85
+ function setStreamStyling(stylingContainer, domain, subscription) {
86
+ if (window.emMessageBus) {
87
+ const sheet = document.createElement('style');
88
+
89
+ window.emMessageBus.subscribe(domain, (data) => {
90
+ sheet.innerHTML = data;
91
+ if (stylingContainer) {
92
+ stylingContainer.appendChild(sheet);
93
+ }
94
+ });
95
+ }
96
+ }
97
+
98
+ const generalStylingWrapperCss = ":host{display:block}";
99
+ const GeneralStylingWrapperStyle0 = generalStylingWrapperCss;
100
+
101
+ const GeneralStylingWrapper = class {
102
+ constructor(hostRef) {
103
+ index.registerInstance(this, hostRef);
104
+ this.stylingAppends = false;
105
+ this.clientStyling = '';
106
+ this.clientStylingUrl = '';
107
+ this.mbSource = undefined;
108
+ this.translationUrl = '';
109
+ this.targetTranslations = undefined;
110
+ }
111
+ componentDidLoad() {
112
+ if (this.el) {
113
+ if (window.emMessageBus != undefined) {
114
+ setStreamStyling(this.el, `${this.mbSource}.Style`);
115
+ }
116
+ else {
117
+ if (this.clientStyling)
118
+ setClientStyling(this.el, this.clientStyling);
119
+ if (this.clientStylingUrl)
120
+ setClientStylingURL(this.el, this.clientStylingUrl);
121
+ this.stylingAppends = true;
122
+ }
123
+ }
124
+ }
125
+ disconnectedCallback() {
126
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
127
+ }
128
+ handleClientStylingChange(newValue, oldValue) {
129
+ if (newValue != oldValue) {
130
+ setClientStyling(this.el, this.clientStyling);
131
+ }
132
+ }
133
+ handleClientStylingUrlChange(newValue, oldValue) {
134
+ if (newValue != oldValue) {
135
+ if (this.clientStylingUrl)
136
+ setClientStylingURL(this.el, this.clientStylingUrl);
137
+ }
138
+ }
139
+ componentDidRender() {
140
+ // start custom styling area
141
+ if (!this.stylingAppends) {
142
+ if (this.clientStyling)
143
+ setClientStyling(this.el, this.clientStyling);
144
+ if (this.clientStylingUrl)
145
+ setClientStylingURL(this.el, this.clientStylingUrl);
146
+ this.stylingAppends = true;
147
+ }
148
+ // end custom styling area
149
+ }
150
+ async componentWillLoad() {
151
+ const promises = [];
152
+ if (this.translationUrl) {
153
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
154
+ promises.push(translationPromise);
155
+ }
156
+ return await Promise.all(promises);
157
+ }
158
+ render() {
159
+ return (index.h("div", { key: '09ad83748bbad518743c8671b986c541c52bf3f0', class: "StyleShell" }, index.h("slot", { key: '3b28b776d3944410c717b002b70946d274a4e8e7', name: "mainContent" })));
160
+ }
161
+ get el() { return index.getElement(this); }
162
+ static get watchers() { return {
163
+ "clientStyling": ["handleClientStylingChange"],
164
+ "clientStylingUrl": ["handleClientStylingUrlChange"]
165
+ }; }
166
+ };
167
+ GeneralStylingWrapper.style = GeneralStylingWrapperStyle0;
168
+
169
+ function _typeof(o) {
170
+ "@babel/helpers - typeof";
171
+
172
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
173
+ return typeof o;
174
+ } : function (o) {
175
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
176
+ }, _typeof(o);
177
+ }
178
+
179
+ function toInteger(dirtyNumber) {
180
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
181
+ return NaN;
182
+ }
183
+ var number = Number(dirtyNumber);
184
+ if (isNaN(number)) {
185
+ return number;
186
+ }
187
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
188
+ }
189
+
190
+ function requiredArgs(required, args) {
191
+ if (args.length < required) {
192
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
193
+ }
194
+ }
195
+
196
+ /**
197
+ * @name toDate
198
+ * @category Common Helpers
199
+ * @summary Convert the given argument to an instance of Date.
200
+ *
201
+ * @description
202
+ * Convert the given argument to an instance of Date.
203
+ *
204
+ * If the argument is an instance of Date, the function returns its clone.
205
+ *
206
+ * If the argument is a number, it is treated as a timestamp.
207
+ *
208
+ * If the argument is none of the above, the function returns Invalid Date.
209
+ *
210
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
211
+ *
212
+ * @param {Date|Number} argument - the value to convert
213
+ * @returns {Date} the parsed date in the local time zone
214
+ * @throws {TypeError} 1 argument required
215
+ *
216
+ * @example
217
+ * // Clone the date:
218
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
219
+ * //=> Tue Feb 11 2014 11:30:30
220
+ *
221
+ * @example
222
+ * // Convert the timestamp to date:
223
+ * const result = toDate(1392098430000)
224
+ * //=> Tue Feb 11 2014 11:30:30
225
+ */
226
+ function toDate(argument) {
227
+ requiredArgs(1, arguments);
228
+ var argStr = Object.prototype.toString.call(argument);
229
+
230
+ // Clone the date
231
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
232
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
233
+ return new Date(argument.getTime());
234
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
235
+ return new Date(argument);
236
+ } else {
237
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
238
+ // eslint-disable-next-line no-console
239
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
240
+ // eslint-disable-next-line no-console
241
+ console.warn(new Error().stack);
242
+ }
243
+ return new Date(NaN);
244
+ }
245
+ }
246
+
247
+ /**
248
+ * @name addMilliseconds
249
+ * @category Millisecond Helpers
250
+ * @summary Add the specified number of milliseconds to the given date.
251
+ *
252
+ * @description
253
+ * Add the specified number of milliseconds to the given date.
254
+ *
255
+ * @param {Date|Number} date - the date to be changed
256
+ * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
257
+ * @returns {Date} the new date with the milliseconds added
258
+ * @throws {TypeError} 2 arguments required
259
+ *
260
+ * @example
261
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
262
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
263
+ * //=> Thu Jul 10 2014 12:45:30.750
264
+ */
265
+ function addMilliseconds(dirtyDate, dirtyAmount) {
266
+ requiredArgs(2, arguments);
267
+ var timestamp = toDate(dirtyDate).getTime();
268
+ var amount = toInteger(dirtyAmount);
269
+ return new Date(timestamp + amount);
270
+ }
271
+
272
+ var defaultOptions = {};
273
+ function getDefaultOptions() {
274
+ return defaultOptions;
275
+ }
276
+
277
+ /**
278
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
279
+ * They usually appear for dates that denote time before the timezones were introduced
280
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
281
+ * and GMT+01:00:00 after that date)
282
+ *
283
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
284
+ * which would lead to incorrect calculations.
285
+ *
286
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
287
+ */
288
+ function getTimezoneOffsetInMilliseconds(date) {
289
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
290
+ utcDate.setUTCFullYear(date.getFullYear());
291
+ return date.getTime() - utcDate.getTime();
292
+ }
293
+
294
+ /**
295
+ * @name startOfDay
296
+ * @category Day Helpers
297
+ * @summary Return the start of a day for the given date.
298
+ *
299
+ * @description
300
+ * Return the start of a day for the given date.
301
+ * The result will be in the local timezone.
302
+ *
303
+ * @param {Date|Number} date - the original date
304
+ * @returns {Date} the start of a day
305
+ * @throws {TypeError} 1 argument required
306
+ *
307
+ * @example
308
+ * // The start of a day for 2 September 2014 11:55:00:
309
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
310
+ * //=> Tue Sep 02 2014 00:00:00
311
+ */
312
+ function startOfDay(dirtyDate) {
313
+ requiredArgs(1, arguments);
314
+ var date = toDate(dirtyDate);
315
+ date.setHours(0, 0, 0, 0);
316
+ return date;
317
+ }
318
+
319
+ var MILLISECONDS_IN_DAY$1 = 86400000;
320
+
321
+ /**
322
+ * @name differenceInCalendarDays
323
+ * @category Day Helpers
324
+ * @summary Get the number of calendar days between the given dates.
325
+ *
326
+ * @description
327
+ * Get the number of calendar days between the given dates. This means that the times are removed
328
+ * from the dates and then the difference in days is calculated.
329
+ *
330
+ * @param {Date|Number} dateLeft - the later date
331
+ * @param {Date|Number} dateRight - the earlier date
332
+ * @returns {Number} the number of calendar days
333
+ * @throws {TypeError} 2 arguments required
334
+ *
335
+ * @example
336
+ * // How many calendar days are between
337
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
338
+ * const result = differenceInCalendarDays(
339
+ * new Date(2012, 6, 2, 0, 0),
340
+ * new Date(2011, 6, 2, 23, 0)
341
+ * )
342
+ * //=> 366
343
+ * // How many calendar days are between
344
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
345
+ * const result = differenceInCalendarDays(
346
+ * new Date(2011, 6, 3, 0, 1),
347
+ * new Date(2011, 6, 2, 23, 59)
348
+ * )
349
+ * //=> 1
350
+ */
351
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
352
+ requiredArgs(2, arguments);
353
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
354
+ var startOfDayRight = startOfDay(dirtyDateRight);
355
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
356
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
357
+
358
+ // Round the number of days to the nearest integer
359
+ // because the number of milliseconds in a day is not constant
360
+ // (e.g. it's different in the day of the daylight saving time clock shift)
361
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY$1);
362
+ }
363
+
364
+ /**
365
+ * Days in 1 week.
366
+ *
367
+ * @name daysInWeek
368
+ * @constant
369
+ * @type {number}
370
+ * @default
371
+ */
372
+
373
+ /**
374
+ * Milliseconds in 1 minute
375
+ *
376
+ * @name millisecondsInMinute
377
+ * @constant
378
+ * @type {number}
379
+ * @default
380
+ */
381
+ var millisecondsInMinute = 60000;
382
+
383
+ /**
384
+ * Milliseconds in 1 hour
385
+ *
386
+ * @name millisecondsInHour
387
+ * @constant
388
+ * @type {number}
389
+ * @default
390
+ */
391
+ var millisecondsInHour = 3600000;
392
+
393
+ /**
394
+ * @name isDate
395
+ * @category Common Helpers
396
+ * @summary Is the given value a date?
397
+ *
398
+ * @description
399
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
400
+ *
401
+ * @param {*} value - the value to check
402
+ * @returns {boolean} true if the given value is a date
403
+ * @throws {TypeError} 1 arguments required
404
+ *
405
+ * @example
406
+ * // For a valid date:
407
+ * const result = isDate(new Date())
408
+ * //=> true
409
+ *
410
+ * @example
411
+ * // For an invalid date:
412
+ * const result = isDate(new Date(NaN))
413
+ * //=> true
414
+ *
415
+ * @example
416
+ * // For some value:
417
+ * const result = isDate('2014-02-31')
418
+ * //=> false
419
+ *
420
+ * @example
421
+ * // For an object:
422
+ * const result = isDate({})
423
+ * //=> false
424
+ */
425
+ function isDate(value) {
426
+ requiredArgs(1, arguments);
427
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
428
+ }
429
+
430
+ /**
431
+ * @name isValid
432
+ * @category Common Helpers
433
+ * @summary Is the given date valid?
434
+ *
435
+ * @description
436
+ * Returns false if argument is Invalid Date and true otherwise.
437
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
438
+ * Invalid Date is a Date, whose time value is NaN.
439
+ *
440
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
441
+ *
442
+ * @param {*} date - the date to check
443
+ * @returns {Boolean} the date is valid
444
+ * @throws {TypeError} 1 argument required
445
+ *
446
+ * @example
447
+ * // For the valid date:
448
+ * const result = isValid(new Date(2014, 1, 31))
449
+ * //=> true
450
+ *
451
+ * @example
452
+ * // For the value, convertable into a date:
453
+ * const result = isValid(1393804800000)
454
+ * //=> true
455
+ *
456
+ * @example
457
+ * // For the invalid date:
458
+ * const result = isValid(new Date(''))
459
+ * //=> false
460
+ */
461
+ function isValid(dirtyDate) {
462
+ requiredArgs(1, arguments);
463
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
464
+ return false;
465
+ }
466
+ var date = toDate(dirtyDate);
467
+ return !isNaN(Number(date));
468
+ }
469
+
470
+ /**
471
+ * @name differenceInMilliseconds
472
+ * @category Millisecond Helpers
473
+ * @summary Get the number of milliseconds between the given dates.
474
+ *
475
+ * @description
476
+ * Get the number of milliseconds between the given dates.
477
+ *
478
+ * @param {Date|Number} dateLeft - the later date
479
+ * @param {Date|Number} dateRight - the earlier date
480
+ * @returns {Number} the number of milliseconds
481
+ * @throws {TypeError} 2 arguments required
482
+ *
483
+ * @example
484
+ * // How many milliseconds are between
485
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
486
+ * const result = differenceInMilliseconds(
487
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
488
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
489
+ * )
490
+ * //=> 1100
491
+ */
492
+ function differenceInMilliseconds(dateLeft, dateRight) {
493
+ requiredArgs(2, arguments);
494
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
495
+ }
496
+
497
+ var roundingMap = {
498
+ ceil: Math.ceil,
499
+ round: Math.round,
500
+ floor: Math.floor,
501
+ trunc: function trunc(value) {
502
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
503
+ } // Math.trunc is not supported by IE
504
+ };
505
+
506
+ var defaultRoundingMethod = 'trunc';
507
+ function getRoundingMethod(method) {
508
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
509
+ }
510
+
511
+ /**
512
+ * @name differenceInHours
513
+ * @category Hour Helpers
514
+ * @summary Get the number of hours between the given dates.
515
+ *
516
+ * @description
517
+ * Get the number of hours between the given dates.
518
+ *
519
+ * @param {Date|Number} dateLeft - the later date
520
+ * @param {Date|Number} dateRight - the earlier date
521
+ * @param {Object} [options] - an object with options.
522
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
523
+ * @returns {Number} the number of hours
524
+ * @throws {TypeError} 2 arguments required
525
+ *
526
+ * @example
527
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
528
+ * const result = differenceInHours(
529
+ * new Date(2014, 6, 2, 19, 0),
530
+ * new Date(2014, 6, 2, 6, 50)
531
+ * )
532
+ * //=> 12
533
+ */
534
+ function differenceInHours(dateLeft, dateRight, options) {
535
+ requiredArgs(2, arguments);
536
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
537
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
538
+ }
539
+
540
+ /**
541
+ * @name differenceInMinutes
542
+ * @category Minute Helpers
543
+ * @summary Get the number of minutes between the given dates.
544
+ *
545
+ * @description
546
+ * Get the signed number of full (rounded towards 0) minutes between the given dates.
547
+ *
548
+ * @param {Date|Number} dateLeft - the later date
549
+ * @param {Date|Number} dateRight - the earlier date
550
+ * @param {Object} [options] - an object with options.
551
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
552
+ * @returns {Number} the number of minutes
553
+ * @throws {TypeError} 2 arguments required
554
+ *
555
+ * @example
556
+ * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
557
+ * const result = differenceInMinutes(
558
+ * new Date(2014, 6, 2, 12, 20, 0),
559
+ * new Date(2014, 6, 2, 12, 7, 59)
560
+ * )
561
+ * //=> 12
562
+ *
563
+ * @example
564
+ * // How many minutes are between 10:01:59 and 10:00:00
565
+ * const result = differenceInMinutes(
566
+ * new Date(2000, 0, 1, 10, 0, 0),
567
+ * new Date(2000, 0, 1, 10, 1, 59)
568
+ * )
569
+ * //=> -1
570
+ */
571
+ function differenceInMinutes(dateLeft, dateRight, options) {
572
+ requiredArgs(2, arguments);
573
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
574
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
575
+ }
576
+
577
+ /**
578
+ * @name subMilliseconds
579
+ * @category Millisecond Helpers
580
+ * @summary Subtract the specified number of milliseconds from the given date.
581
+ *
582
+ * @description
583
+ * Subtract the specified number of milliseconds from the given date.
584
+ *
585
+ * @param {Date|Number} date - the date to be changed
586
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
587
+ * @returns {Date} the new date with the milliseconds subtracted
588
+ * @throws {TypeError} 2 arguments required
589
+ *
590
+ * @example
591
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
592
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
593
+ * //=> Thu Jul 10 2014 12:45:29.250
594
+ */
595
+ function subMilliseconds(dirtyDate, dirtyAmount) {
596
+ requiredArgs(2, arguments);
597
+ var amount = toInteger(dirtyAmount);
598
+ return addMilliseconds(dirtyDate, -amount);
599
+ }
600
+
601
+ var MILLISECONDS_IN_DAY = 86400000;
602
+ function getUTCDayOfYear(dirtyDate) {
603
+ requiredArgs(1, arguments);
604
+ var date = toDate(dirtyDate);
605
+ var timestamp = date.getTime();
606
+ date.setUTCMonth(0, 1);
607
+ date.setUTCHours(0, 0, 0, 0);
608
+ var startOfYearTimestamp = date.getTime();
609
+ var difference = timestamp - startOfYearTimestamp;
610
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
611
+ }
612
+
613
+ function startOfUTCISOWeek(dirtyDate) {
614
+ requiredArgs(1, arguments);
615
+ var weekStartsOn = 1;
616
+ var date = toDate(dirtyDate);
617
+ var day = date.getUTCDay();
618
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
619
+ date.setUTCDate(date.getUTCDate() - diff);
620
+ date.setUTCHours(0, 0, 0, 0);
621
+ return date;
622
+ }
623
+
624
+ function getUTCISOWeekYear(dirtyDate) {
625
+ requiredArgs(1, arguments);
626
+ var date = toDate(dirtyDate);
627
+ var year = date.getUTCFullYear();
628
+ var fourthOfJanuaryOfNextYear = new Date(0);
629
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
630
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
631
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
632
+ var fourthOfJanuaryOfThisYear = new Date(0);
633
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
634
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
635
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
636
+ if (date.getTime() >= startOfNextYear.getTime()) {
637
+ return year + 1;
638
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
639
+ return year;
640
+ } else {
641
+ return year - 1;
642
+ }
643
+ }
644
+
645
+ function startOfUTCISOWeekYear(dirtyDate) {
646
+ requiredArgs(1, arguments);
647
+ var year = getUTCISOWeekYear(dirtyDate);
648
+ var fourthOfJanuary = new Date(0);
649
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
650
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
651
+ var date = startOfUTCISOWeek(fourthOfJanuary);
652
+ return date;
653
+ }
654
+
655
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
656
+ function getUTCISOWeek(dirtyDate) {
657
+ requiredArgs(1, arguments);
658
+ var date = toDate(dirtyDate);
659
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
660
+
661
+ // Round the number of days to the nearest integer
662
+ // because the number of milliseconds in a week is not constant
663
+ // (e.g. it's different in the week of the daylight saving time clock shift)
664
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
665
+ }
666
+
667
+ function startOfUTCWeek(dirtyDate, options) {
668
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
669
+ requiredArgs(1, arguments);
670
+ var defaultOptions = getDefaultOptions();
671
+ var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
672
+
673
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
674
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
675
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
676
+ }
677
+ var date = toDate(dirtyDate);
678
+ var day = date.getUTCDay();
679
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
680
+ date.setUTCDate(date.getUTCDate() - diff);
681
+ date.setUTCHours(0, 0, 0, 0);
682
+ return date;
683
+ }
684
+
685
+ function getUTCWeekYear(dirtyDate, options) {
686
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
687
+ requiredArgs(1, arguments);
688
+ var date = toDate(dirtyDate);
689
+ var year = date.getUTCFullYear();
690
+ var defaultOptions = getDefaultOptions();
691
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
692
+
693
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
694
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
695
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
696
+ }
697
+ var firstWeekOfNextYear = new Date(0);
698
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
699
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
700
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
701
+ var firstWeekOfThisYear = new Date(0);
702
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
703
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
704
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
705
+ if (date.getTime() >= startOfNextYear.getTime()) {
706
+ return year + 1;
707
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
708
+ return year;
709
+ } else {
710
+ return year - 1;
711
+ }
712
+ }
713
+
714
+ function startOfUTCWeekYear(dirtyDate, options) {
715
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
716
+ requiredArgs(1, arguments);
717
+ var defaultOptions = getDefaultOptions();
718
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
719
+ var year = getUTCWeekYear(dirtyDate, options);
720
+ var firstWeek = new Date(0);
721
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
722
+ firstWeek.setUTCHours(0, 0, 0, 0);
723
+ var date = startOfUTCWeek(firstWeek, options);
724
+ return date;
725
+ }
726
+
727
+ var MILLISECONDS_IN_WEEK = 604800000;
728
+ function getUTCWeek(dirtyDate, options) {
729
+ requiredArgs(1, arguments);
730
+ var date = toDate(dirtyDate);
731
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
732
+
733
+ // Round the number of days to the nearest integer
734
+ // because the number of milliseconds in a week is not constant
735
+ // (e.g. it's different in the week of the daylight saving time clock shift)
736
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
737
+ }
738
+
739
+ function addLeadingZeros(number, targetLength) {
740
+ var sign = number < 0 ? '-' : '';
741
+ var output = Math.abs(number).toString();
742
+ while (output.length < targetLength) {
743
+ output = '0' + output;
744
+ }
745
+ return sign + output;
746
+ }
747
+
748
+ /*
749
+ * | | Unit | | Unit |
750
+ * |-----|--------------------------------|-----|--------------------------------|
751
+ * | a | AM, PM | A* | |
752
+ * | d | Day of month | D | |
753
+ * | h | Hour [1-12] | H | Hour [0-23] |
754
+ * | m | Minute | M | Month |
755
+ * | s | Second | S | Fraction of second |
756
+ * | y | Year (abs) | Y | |
757
+ *
758
+ * Letters marked by * are not implemented but reserved by Unicode standard.
759
+ */
760
+ var formatters$2 = {
761
+ // Year
762
+ y: function y(date, token) {
763
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
764
+ // | Year | y | yy | yyy | yyyy | yyyyy |
765
+ // |----------|-------|----|-------|-------|-------|
766
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
767
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
768
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
769
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
770
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
771
+
772
+ var signedYear = date.getUTCFullYear();
773
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
774
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
775
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
776
+ },
777
+ // Month
778
+ M: function M(date, token) {
779
+ var month = date.getUTCMonth();
780
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
781
+ },
782
+ // Day of the month
783
+ d: function d(date, token) {
784
+ return addLeadingZeros(date.getUTCDate(), token.length);
785
+ },
786
+ // AM or PM
787
+ a: function a(date, token) {
788
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
789
+ switch (token) {
790
+ case 'a':
791
+ case 'aa':
792
+ return dayPeriodEnumValue.toUpperCase();
793
+ case 'aaa':
794
+ return dayPeriodEnumValue;
795
+ case 'aaaaa':
796
+ return dayPeriodEnumValue[0];
797
+ case 'aaaa':
798
+ default:
799
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
800
+ }
801
+ },
802
+ // Hour [1-12]
803
+ h: function h(date, token) {
804
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
805
+ },
806
+ // Hour [0-23]
807
+ H: function H(date, token) {
808
+ return addLeadingZeros(date.getUTCHours(), token.length);
809
+ },
810
+ // Minute
811
+ m: function m(date, token) {
812
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
813
+ },
814
+ // Second
815
+ s: function s(date, token) {
816
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
817
+ },
818
+ // Fraction of second
819
+ S: function S(date, token) {
820
+ var numberOfDigits = token.length;
821
+ var milliseconds = date.getUTCMilliseconds();
822
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
823
+ return addLeadingZeros(fractionalSeconds, token.length);
824
+ }
825
+ };
826
+ const formatters$3 = formatters$2;
827
+
828
+ var dayPeriodEnum = {
829
+ am: 'am',
830
+ pm: 'pm',
831
+ midnight: 'midnight',
832
+ noon: 'noon',
833
+ morning: 'morning',
834
+ afternoon: 'afternoon',
835
+ evening: 'evening',
836
+ night: 'night'
837
+ };
838
+ /*
839
+ * | | Unit | | Unit |
840
+ * |-----|--------------------------------|-----|--------------------------------|
841
+ * | a | AM, PM | A* | Milliseconds in day |
842
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
843
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
844
+ * | d | Day of month | D | Day of year |
845
+ * | e | Local day of week | E | Day of week |
846
+ * | f | | F* | Day of week in month |
847
+ * | g* | Modified Julian day | G | Era |
848
+ * | h | Hour [1-12] | H | Hour [0-23] |
849
+ * | i! | ISO day of week | I! | ISO week of year |
850
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
851
+ * | k | Hour [1-24] | K | Hour [0-11] |
852
+ * | l* | (deprecated) | L | Stand-alone month |
853
+ * | m | Minute | M | Month |
854
+ * | n | | N | |
855
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
856
+ * | p! | Long localized time | P! | Long localized date |
857
+ * | q | Stand-alone quarter | Q | Quarter |
858
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
859
+ * | s | Second | S | Fraction of second |
860
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
861
+ * | u | Extended year | U* | Cyclic year |
862
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
863
+ * | w | Local week of year | W* | Week of month |
864
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
865
+ * | y | Year (abs) | Y | Local week-numbering year |
866
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
867
+ *
868
+ * Letters marked by * are not implemented but reserved by Unicode standard.
869
+ *
870
+ * Letters marked by ! are non-standard, but implemented by date-fns:
871
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
872
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
873
+ * i.e. 7 for Sunday, 1 for Monday, etc.
874
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
875
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
876
+ * `R` is supposed to be used in conjunction with `I` and `i`
877
+ * for universal ISO week-numbering date, whereas
878
+ * `Y` is supposed to be used in conjunction with `w` and `e`
879
+ * for week-numbering date specific to the locale.
880
+ * - `P` is long localized date format
881
+ * - `p` is long localized time format
882
+ */
883
+
884
+ var formatters = {
885
+ // Era
886
+ G: function G(date, token, localize) {
887
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
888
+ switch (token) {
889
+ // AD, BC
890
+ case 'G':
891
+ case 'GG':
892
+ case 'GGG':
893
+ return localize.era(era, {
894
+ width: 'abbreviated'
895
+ });
896
+ // A, B
897
+ case 'GGGGG':
898
+ return localize.era(era, {
899
+ width: 'narrow'
900
+ });
901
+ // Anno Domini, Before Christ
902
+ case 'GGGG':
903
+ default:
904
+ return localize.era(era, {
905
+ width: 'wide'
906
+ });
907
+ }
908
+ },
909
+ // Year
910
+ y: function y(date, token, localize) {
911
+ // Ordinal number
912
+ if (token === 'yo') {
913
+ var signedYear = date.getUTCFullYear();
914
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
915
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
916
+ return localize.ordinalNumber(year, {
917
+ unit: 'year'
918
+ });
919
+ }
920
+ return formatters$3.y(date, token);
921
+ },
922
+ // Local week-numbering year
923
+ Y: function Y(date, token, localize, options) {
924
+ var signedWeekYear = getUTCWeekYear(date, options);
925
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
926
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
927
+
928
+ // Two digit year
929
+ if (token === 'YY') {
930
+ var twoDigitYear = weekYear % 100;
931
+ return addLeadingZeros(twoDigitYear, 2);
932
+ }
933
+
934
+ // Ordinal number
935
+ if (token === 'Yo') {
936
+ return localize.ordinalNumber(weekYear, {
937
+ unit: 'year'
938
+ });
939
+ }
940
+
941
+ // Padding
942
+ return addLeadingZeros(weekYear, token.length);
943
+ },
944
+ // ISO week-numbering year
945
+ R: function R(date, token) {
946
+ var isoWeekYear = getUTCISOWeekYear(date);
947
+
948
+ // Padding
949
+ return addLeadingZeros(isoWeekYear, token.length);
950
+ },
951
+ // Extended year. This is a single number designating the year of this calendar system.
952
+ // The main difference between `y` and `u` localizers are B.C. years:
953
+ // | Year | `y` | `u` |
954
+ // |------|-----|-----|
955
+ // | AC 1 | 1 | 1 |
956
+ // | BC 1 | 1 | 0 |
957
+ // | BC 2 | 2 | -1 |
958
+ // Also `yy` always returns the last two digits of a year,
959
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
960
+ u: function u(date, token) {
961
+ var year = date.getUTCFullYear();
962
+ return addLeadingZeros(year, token.length);
963
+ },
964
+ // Quarter
965
+ Q: function Q(date, token, localize) {
966
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
967
+ switch (token) {
968
+ // 1, 2, 3, 4
969
+ case 'Q':
970
+ return String(quarter);
971
+ // 01, 02, 03, 04
972
+ case 'QQ':
973
+ return addLeadingZeros(quarter, 2);
974
+ // 1st, 2nd, 3rd, 4th
975
+ case 'Qo':
976
+ return localize.ordinalNumber(quarter, {
977
+ unit: 'quarter'
978
+ });
979
+ // Q1, Q2, Q3, Q4
980
+ case 'QQQ':
981
+ return localize.quarter(quarter, {
982
+ width: 'abbreviated',
983
+ context: 'formatting'
984
+ });
985
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
986
+ case 'QQQQQ':
987
+ return localize.quarter(quarter, {
988
+ width: 'narrow',
989
+ context: 'formatting'
990
+ });
991
+ // 1st quarter, 2nd quarter, ...
992
+ case 'QQQQ':
993
+ default:
994
+ return localize.quarter(quarter, {
995
+ width: 'wide',
996
+ context: 'formatting'
997
+ });
998
+ }
999
+ },
1000
+ // Stand-alone quarter
1001
+ q: function q(date, token, localize) {
1002
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1003
+ switch (token) {
1004
+ // 1, 2, 3, 4
1005
+ case 'q':
1006
+ return String(quarter);
1007
+ // 01, 02, 03, 04
1008
+ case 'qq':
1009
+ return addLeadingZeros(quarter, 2);
1010
+ // 1st, 2nd, 3rd, 4th
1011
+ case 'qo':
1012
+ return localize.ordinalNumber(quarter, {
1013
+ unit: 'quarter'
1014
+ });
1015
+ // Q1, Q2, Q3, Q4
1016
+ case 'qqq':
1017
+ return localize.quarter(quarter, {
1018
+ width: 'abbreviated',
1019
+ context: 'standalone'
1020
+ });
1021
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1022
+ case 'qqqqq':
1023
+ return localize.quarter(quarter, {
1024
+ width: 'narrow',
1025
+ context: 'standalone'
1026
+ });
1027
+ // 1st quarter, 2nd quarter, ...
1028
+ case 'qqqq':
1029
+ default:
1030
+ return localize.quarter(quarter, {
1031
+ width: 'wide',
1032
+ context: 'standalone'
1033
+ });
1034
+ }
1035
+ },
1036
+ // Month
1037
+ M: function M(date, token, localize) {
1038
+ var month = date.getUTCMonth();
1039
+ switch (token) {
1040
+ case 'M':
1041
+ case 'MM':
1042
+ return formatters$3.M(date, token);
1043
+ // 1st, 2nd, ..., 12th
1044
+ case 'Mo':
1045
+ return localize.ordinalNumber(month + 1, {
1046
+ unit: 'month'
1047
+ });
1048
+ // Jan, Feb, ..., Dec
1049
+ case 'MMM':
1050
+ return localize.month(month, {
1051
+ width: 'abbreviated',
1052
+ context: 'formatting'
1053
+ });
1054
+ // J, F, ..., D
1055
+ case 'MMMMM':
1056
+ return localize.month(month, {
1057
+ width: 'narrow',
1058
+ context: 'formatting'
1059
+ });
1060
+ // January, February, ..., December
1061
+ case 'MMMM':
1062
+ default:
1063
+ return localize.month(month, {
1064
+ width: 'wide',
1065
+ context: 'formatting'
1066
+ });
1067
+ }
1068
+ },
1069
+ // Stand-alone month
1070
+ L: function L(date, token, localize) {
1071
+ var month = date.getUTCMonth();
1072
+ switch (token) {
1073
+ // 1, 2, ..., 12
1074
+ case 'L':
1075
+ return String(month + 1);
1076
+ // 01, 02, ..., 12
1077
+ case 'LL':
1078
+ return addLeadingZeros(month + 1, 2);
1079
+ // 1st, 2nd, ..., 12th
1080
+ case 'Lo':
1081
+ return localize.ordinalNumber(month + 1, {
1082
+ unit: 'month'
1083
+ });
1084
+ // Jan, Feb, ..., Dec
1085
+ case 'LLL':
1086
+ return localize.month(month, {
1087
+ width: 'abbreviated',
1088
+ context: 'standalone'
1089
+ });
1090
+ // J, F, ..., D
1091
+ case 'LLLLL':
1092
+ return localize.month(month, {
1093
+ width: 'narrow',
1094
+ context: 'standalone'
1095
+ });
1096
+ // January, February, ..., December
1097
+ case 'LLLL':
1098
+ default:
1099
+ return localize.month(month, {
1100
+ width: 'wide',
1101
+ context: 'standalone'
1102
+ });
1103
+ }
1104
+ },
1105
+ // Local week of year
1106
+ w: function w(date, token, localize, options) {
1107
+ var week = getUTCWeek(date, options);
1108
+ if (token === 'wo') {
1109
+ return localize.ordinalNumber(week, {
1110
+ unit: 'week'
1111
+ });
1112
+ }
1113
+ return addLeadingZeros(week, token.length);
1114
+ },
1115
+ // ISO week of year
1116
+ I: function I(date, token, localize) {
1117
+ var isoWeek = getUTCISOWeek(date);
1118
+ if (token === 'Io') {
1119
+ return localize.ordinalNumber(isoWeek, {
1120
+ unit: 'week'
1121
+ });
1122
+ }
1123
+ return addLeadingZeros(isoWeek, token.length);
1124
+ },
1125
+ // Day of the month
1126
+ d: function d(date, token, localize) {
1127
+ if (token === 'do') {
1128
+ return localize.ordinalNumber(date.getUTCDate(), {
1129
+ unit: 'date'
1130
+ });
1131
+ }
1132
+ return formatters$3.d(date, token);
1133
+ },
1134
+ // Day of year
1135
+ D: function D(date, token, localize) {
1136
+ var dayOfYear = getUTCDayOfYear(date);
1137
+ if (token === 'Do') {
1138
+ return localize.ordinalNumber(dayOfYear, {
1139
+ unit: 'dayOfYear'
1140
+ });
1141
+ }
1142
+ return addLeadingZeros(dayOfYear, token.length);
1143
+ },
1144
+ // Day of week
1145
+ E: function E(date, token, localize) {
1146
+ var dayOfWeek = date.getUTCDay();
1147
+ switch (token) {
1148
+ // Tue
1149
+ case 'E':
1150
+ case 'EE':
1151
+ case 'EEE':
1152
+ return localize.day(dayOfWeek, {
1153
+ width: 'abbreviated',
1154
+ context: 'formatting'
1155
+ });
1156
+ // T
1157
+ case 'EEEEE':
1158
+ return localize.day(dayOfWeek, {
1159
+ width: 'narrow',
1160
+ context: 'formatting'
1161
+ });
1162
+ // Tu
1163
+ case 'EEEEEE':
1164
+ return localize.day(dayOfWeek, {
1165
+ width: 'short',
1166
+ context: 'formatting'
1167
+ });
1168
+ // Tuesday
1169
+ case 'EEEE':
1170
+ default:
1171
+ return localize.day(dayOfWeek, {
1172
+ width: 'wide',
1173
+ context: 'formatting'
1174
+ });
1175
+ }
1176
+ },
1177
+ // Local day of week
1178
+ e: function e(date, token, localize, options) {
1179
+ var dayOfWeek = date.getUTCDay();
1180
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1181
+ switch (token) {
1182
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
1183
+ case 'e':
1184
+ return String(localDayOfWeek);
1185
+ // Padded numerical value
1186
+ case 'ee':
1187
+ return addLeadingZeros(localDayOfWeek, 2);
1188
+ // 1st, 2nd, ..., 7th
1189
+ case 'eo':
1190
+ return localize.ordinalNumber(localDayOfWeek, {
1191
+ unit: 'day'
1192
+ });
1193
+ case 'eee':
1194
+ return localize.day(dayOfWeek, {
1195
+ width: 'abbreviated',
1196
+ context: 'formatting'
1197
+ });
1198
+ // T
1199
+ case 'eeeee':
1200
+ return localize.day(dayOfWeek, {
1201
+ width: 'narrow',
1202
+ context: 'formatting'
1203
+ });
1204
+ // Tu
1205
+ case 'eeeeee':
1206
+ return localize.day(dayOfWeek, {
1207
+ width: 'short',
1208
+ context: 'formatting'
1209
+ });
1210
+ // Tuesday
1211
+ case 'eeee':
1212
+ default:
1213
+ return localize.day(dayOfWeek, {
1214
+ width: 'wide',
1215
+ context: 'formatting'
1216
+ });
1217
+ }
1218
+ },
1219
+ // Stand-alone local day of week
1220
+ c: function c(date, token, localize, options) {
1221
+ var dayOfWeek = date.getUTCDay();
1222
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1223
+ switch (token) {
1224
+ // Numerical value (same as in `e`)
1225
+ case 'c':
1226
+ return String(localDayOfWeek);
1227
+ // Padded numerical value
1228
+ case 'cc':
1229
+ return addLeadingZeros(localDayOfWeek, token.length);
1230
+ // 1st, 2nd, ..., 7th
1231
+ case 'co':
1232
+ return localize.ordinalNumber(localDayOfWeek, {
1233
+ unit: 'day'
1234
+ });
1235
+ case 'ccc':
1236
+ return localize.day(dayOfWeek, {
1237
+ width: 'abbreviated',
1238
+ context: 'standalone'
1239
+ });
1240
+ // T
1241
+ case 'ccccc':
1242
+ return localize.day(dayOfWeek, {
1243
+ width: 'narrow',
1244
+ context: 'standalone'
1245
+ });
1246
+ // Tu
1247
+ case 'cccccc':
1248
+ return localize.day(dayOfWeek, {
1249
+ width: 'short',
1250
+ context: 'standalone'
1251
+ });
1252
+ // Tuesday
1253
+ case 'cccc':
1254
+ default:
1255
+ return localize.day(dayOfWeek, {
1256
+ width: 'wide',
1257
+ context: 'standalone'
1258
+ });
1259
+ }
1260
+ },
1261
+ // ISO day of week
1262
+ i: function i(date, token, localize) {
1263
+ var dayOfWeek = date.getUTCDay();
1264
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1265
+ switch (token) {
1266
+ // 2
1267
+ case 'i':
1268
+ return String(isoDayOfWeek);
1269
+ // 02
1270
+ case 'ii':
1271
+ return addLeadingZeros(isoDayOfWeek, token.length);
1272
+ // 2nd
1273
+ case 'io':
1274
+ return localize.ordinalNumber(isoDayOfWeek, {
1275
+ unit: 'day'
1276
+ });
1277
+ // Tue
1278
+ case 'iii':
1279
+ return localize.day(dayOfWeek, {
1280
+ width: 'abbreviated',
1281
+ context: 'formatting'
1282
+ });
1283
+ // T
1284
+ case 'iiiii':
1285
+ return localize.day(dayOfWeek, {
1286
+ width: 'narrow',
1287
+ context: 'formatting'
1288
+ });
1289
+ // Tu
1290
+ case 'iiiiii':
1291
+ return localize.day(dayOfWeek, {
1292
+ width: 'short',
1293
+ context: 'formatting'
1294
+ });
1295
+ // Tuesday
1296
+ case 'iiii':
1297
+ default:
1298
+ return localize.day(dayOfWeek, {
1299
+ width: 'wide',
1300
+ context: 'formatting'
1301
+ });
1302
+ }
1303
+ },
1304
+ // AM or PM
1305
+ a: function a(date, token, localize) {
1306
+ var hours = date.getUTCHours();
1307
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1308
+ switch (token) {
1309
+ case 'a':
1310
+ case 'aa':
1311
+ return localize.dayPeriod(dayPeriodEnumValue, {
1312
+ width: 'abbreviated',
1313
+ context: 'formatting'
1314
+ });
1315
+ case 'aaa':
1316
+ return localize.dayPeriod(dayPeriodEnumValue, {
1317
+ width: 'abbreviated',
1318
+ context: 'formatting'
1319
+ }).toLowerCase();
1320
+ case 'aaaaa':
1321
+ return localize.dayPeriod(dayPeriodEnumValue, {
1322
+ width: 'narrow',
1323
+ context: 'formatting'
1324
+ });
1325
+ case 'aaaa':
1326
+ default:
1327
+ return localize.dayPeriod(dayPeriodEnumValue, {
1328
+ width: 'wide',
1329
+ context: 'formatting'
1330
+ });
1331
+ }
1332
+ },
1333
+ // AM, PM, midnight, noon
1334
+ b: function b(date, token, localize) {
1335
+ var hours = date.getUTCHours();
1336
+ var dayPeriodEnumValue;
1337
+ if (hours === 12) {
1338
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1339
+ } else if (hours === 0) {
1340
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1341
+ } else {
1342
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1343
+ }
1344
+ switch (token) {
1345
+ case 'b':
1346
+ case 'bb':
1347
+ return localize.dayPeriod(dayPeriodEnumValue, {
1348
+ width: 'abbreviated',
1349
+ context: 'formatting'
1350
+ });
1351
+ case 'bbb':
1352
+ return localize.dayPeriod(dayPeriodEnumValue, {
1353
+ width: 'abbreviated',
1354
+ context: 'formatting'
1355
+ }).toLowerCase();
1356
+ case 'bbbbb':
1357
+ return localize.dayPeriod(dayPeriodEnumValue, {
1358
+ width: 'narrow',
1359
+ context: 'formatting'
1360
+ });
1361
+ case 'bbbb':
1362
+ default:
1363
+ return localize.dayPeriod(dayPeriodEnumValue, {
1364
+ width: 'wide',
1365
+ context: 'formatting'
1366
+ });
1367
+ }
1368
+ },
1369
+ // in the morning, in the afternoon, in the evening, at night
1370
+ B: function B(date, token, localize) {
1371
+ var hours = date.getUTCHours();
1372
+ var dayPeriodEnumValue;
1373
+ if (hours >= 17) {
1374
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1375
+ } else if (hours >= 12) {
1376
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1377
+ } else if (hours >= 4) {
1378
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1379
+ } else {
1380
+ dayPeriodEnumValue = dayPeriodEnum.night;
1381
+ }
1382
+ switch (token) {
1383
+ case 'B':
1384
+ case 'BB':
1385
+ case 'BBB':
1386
+ return localize.dayPeriod(dayPeriodEnumValue, {
1387
+ width: 'abbreviated',
1388
+ context: 'formatting'
1389
+ });
1390
+ case 'BBBBB':
1391
+ return localize.dayPeriod(dayPeriodEnumValue, {
1392
+ width: 'narrow',
1393
+ context: 'formatting'
1394
+ });
1395
+ case 'BBBB':
1396
+ default:
1397
+ return localize.dayPeriod(dayPeriodEnumValue, {
1398
+ width: 'wide',
1399
+ context: 'formatting'
1400
+ });
1401
+ }
1402
+ },
1403
+ // Hour [1-12]
1404
+ h: function h(date, token, localize) {
1405
+ if (token === 'ho') {
1406
+ var hours = date.getUTCHours() % 12;
1407
+ if (hours === 0) hours = 12;
1408
+ return localize.ordinalNumber(hours, {
1409
+ unit: 'hour'
1410
+ });
1411
+ }
1412
+ return formatters$3.h(date, token);
1413
+ },
1414
+ // Hour [0-23]
1415
+ H: function H(date, token, localize) {
1416
+ if (token === 'Ho') {
1417
+ return localize.ordinalNumber(date.getUTCHours(), {
1418
+ unit: 'hour'
1419
+ });
1420
+ }
1421
+ return formatters$3.H(date, token);
1422
+ },
1423
+ // Hour [0-11]
1424
+ K: function K(date, token, localize) {
1425
+ var hours = date.getUTCHours() % 12;
1426
+ if (token === 'Ko') {
1427
+ return localize.ordinalNumber(hours, {
1428
+ unit: 'hour'
1429
+ });
1430
+ }
1431
+ return addLeadingZeros(hours, token.length);
1432
+ },
1433
+ // Hour [1-24]
1434
+ k: function k(date, token, localize) {
1435
+ var hours = date.getUTCHours();
1436
+ if (hours === 0) hours = 24;
1437
+ if (token === 'ko') {
1438
+ return localize.ordinalNumber(hours, {
1439
+ unit: 'hour'
1440
+ });
1441
+ }
1442
+ return addLeadingZeros(hours, token.length);
1443
+ },
1444
+ // Minute
1445
+ m: function m(date, token, localize) {
1446
+ if (token === 'mo') {
1447
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1448
+ unit: 'minute'
1449
+ });
1450
+ }
1451
+ return formatters$3.m(date, token);
1452
+ },
1453
+ // Second
1454
+ s: function s(date, token, localize) {
1455
+ if (token === 'so') {
1456
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1457
+ unit: 'second'
1458
+ });
1459
+ }
1460
+ return formatters$3.s(date, token);
1461
+ },
1462
+ // Fraction of second
1463
+ S: function S(date, token) {
1464
+ return formatters$3.S(date, token);
1465
+ },
1466
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1467
+ X: function X(date, token, _localize, options) {
1468
+ var originalDate = options._originalDate || date;
1469
+ var timezoneOffset = originalDate.getTimezoneOffset();
1470
+ if (timezoneOffset === 0) {
1471
+ return 'Z';
1472
+ }
1473
+ switch (token) {
1474
+ // Hours and optional minutes
1475
+ case 'X':
1476
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1477
+
1478
+ // Hours, minutes and optional seconds without `:` delimiter
1479
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1480
+ // so this token always has the same output as `XX`
1481
+ case 'XXXX':
1482
+ case 'XX':
1483
+ // Hours and minutes without `:` delimiter
1484
+ return formatTimezone(timezoneOffset);
1485
+
1486
+ // Hours, minutes and optional seconds with `:` delimiter
1487
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1488
+ // so this token always has the same output as `XXX`
1489
+ case 'XXXXX':
1490
+ case 'XXX': // Hours and minutes with `:` delimiter
1491
+ default:
1492
+ return formatTimezone(timezoneOffset, ':');
1493
+ }
1494
+ },
1495
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1496
+ x: function x(date, token, _localize, options) {
1497
+ var originalDate = options._originalDate || date;
1498
+ var timezoneOffset = originalDate.getTimezoneOffset();
1499
+ switch (token) {
1500
+ // Hours and optional minutes
1501
+ case 'x':
1502
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1503
+
1504
+ // Hours, minutes and optional seconds without `:` delimiter
1505
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1506
+ // so this token always has the same output as `xx`
1507
+ case 'xxxx':
1508
+ case 'xx':
1509
+ // Hours and minutes without `:` delimiter
1510
+ return formatTimezone(timezoneOffset);
1511
+
1512
+ // Hours, minutes and optional seconds with `:` delimiter
1513
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1514
+ // so this token always has the same output as `xxx`
1515
+ case 'xxxxx':
1516
+ case 'xxx': // Hours and minutes with `:` delimiter
1517
+ default:
1518
+ return formatTimezone(timezoneOffset, ':');
1519
+ }
1520
+ },
1521
+ // Timezone (GMT)
1522
+ O: function O(date, token, _localize, options) {
1523
+ var originalDate = options._originalDate || date;
1524
+ var timezoneOffset = originalDate.getTimezoneOffset();
1525
+ switch (token) {
1526
+ // Short
1527
+ case 'O':
1528
+ case 'OO':
1529
+ case 'OOO':
1530
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1531
+ // Long
1532
+ case 'OOOO':
1533
+ default:
1534
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1535
+ }
1536
+ },
1537
+ // Timezone (specific non-location)
1538
+ z: function z(date, token, _localize, options) {
1539
+ var originalDate = options._originalDate || date;
1540
+ var timezoneOffset = originalDate.getTimezoneOffset();
1541
+ switch (token) {
1542
+ // Short
1543
+ case 'z':
1544
+ case 'zz':
1545
+ case 'zzz':
1546
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1547
+ // Long
1548
+ case 'zzzz':
1549
+ default:
1550
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1551
+ }
1552
+ },
1553
+ // Seconds timestamp
1554
+ t: function t(date, token, _localize, options) {
1555
+ var originalDate = options._originalDate || date;
1556
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1557
+ return addLeadingZeros(timestamp, token.length);
1558
+ },
1559
+ // Milliseconds timestamp
1560
+ T: function T(date, token, _localize, options) {
1561
+ var originalDate = options._originalDate || date;
1562
+ var timestamp = originalDate.getTime();
1563
+ return addLeadingZeros(timestamp, token.length);
1564
+ }
1565
+ };
1566
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1567
+ var sign = offset > 0 ? '-' : '+';
1568
+ var absOffset = Math.abs(offset);
1569
+ var hours = Math.floor(absOffset / 60);
1570
+ var minutes = absOffset % 60;
1571
+ if (minutes === 0) {
1572
+ return sign + String(hours);
1573
+ }
1574
+ var delimiter = dirtyDelimiter || '';
1575
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1576
+ }
1577
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1578
+ if (offset % 60 === 0) {
1579
+ var sign = offset > 0 ? '-' : '+';
1580
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1581
+ }
1582
+ return formatTimezone(offset, dirtyDelimiter);
1583
+ }
1584
+ function formatTimezone(offset, dirtyDelimiter) {
1585
+ var delimiter = dirtyDelimiter || '';
1586
+ var sign = offset > 0 ? '-' : '+';
1587
+ var absOffset = Math.abs(offset);
1588
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1589
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1590
+ return sign + hours + delimiter + minutes;
1591
+ }
1592
+ const formatters$1 = formatters;
1593
+
1594
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1595
+ switch (pattern) {
1596
+ case 'P':
1597
+ return formatLong.date({
1598
+ width: 'short'
1599
+ });
1600
+ case 'PP':
1601
+ return formatLong.date({
1602
+ width: 'medium'
1603
+ });
1604
+ case 'PPP':
1605
+ return formatLong.date({
1606
+ width: 'long'
1607
+ });
1608
+ case 'PPPP':
1609
+ default:
1610
+ return formatLong.date({
1611
+ width: 'full'
1612
+ });
1613
+ }
1614
+ };
1615
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1616
+ switch (pattern) {
1617
+ case 'p':
1618
+ return formatLong.time({
1619
+ width: 'short'
1620
+ });
1621
+ case 'pp':
1622
+ return formatLong.time({
1623
+ width: 'medium'
1624
+ });
1625
+ case 'ppp':
1626
+ return formatLong.time({
1627
+ width: 'long'
1628
+ });
1629
+ case 'pppp':
1630
+ default:
1631
+ return formatLong.time({
1632
+ width: 'full'
1633
+ });
1634
+ }
1635
+ };
1636
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1637
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1638
+ var datePattern = matchResult[1];
1639
+ var timePattern = matchResult[2];
1640
+ if (!timePattern) {
1641
+ return dateLongFormatter(pattern, formatLong);
1642
+ }
1643
+ var dateTimeFormat;
1644
+ switch (datePattern) {
1645
+ case 'P':
1646
+ dateTimeFormat = formatLong.dateTime({
1647
+ width: 'short'
1648
+ });
1649
+ break;
1650
+ case 'PP':
1651
+ dateTimeFormat = formatLong.dateTime({
1652
+ width: 'medium'
1653
+ });
1654
+ break;
1655
+ case 'PPP':
1656
+ dateTimeFormat = formatLong.dateTime({
1657
+ width: 'long'
1658
+ });
1659
+ break;
1660
+ case 'PPPP':
1661
+ default:
1662
+ dateTimeFormat = formatLong.dateTime({
1663
+ width: 'full'
1664
+ });
1665
+ break;
1666
+ }
1667
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1668
+ };
1669
+ var longFormatters = {
1670
+ p: timeLongFormatter,
1671
+ P: dateTimeLongFormatter
1672
+ };
1673
+ const longFormatters$1 = longFormatters;
1674
+
1675
+ var protectedDayOfYearTokens = ['D', 'DD'];
1676
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1677
+ function isProtectedDayOfYearToken(token) {
1678
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1679
+ }
1680
+ function isProtectedWeekYearToken(token) {
1681
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1682
+ }
1683
+ function throwProtectedError(token, format, input) {
1684
+ if (token === 'YYYY') {
1685
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1686
+ } else if (token === 'YY') {
1687
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1688
+ } else if (token === 'D') {
1689
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1690
+ } else if (token === 'DD') {
1691
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1692
+ }
1693
+ }
1694
+
1695
+ var formatDistanceLocale = {
1696
+ lessThanXSeconds: {
1697
+ one: 'less than a second',
1698
+ other: 'less than {{count}} seconds'
1699
+ },
1700
+ xSeconds: {
1701
+ one: '1 second',
1702
+ other: '{{count}} seconds'
1703
+ },
1704
+ halfAMinute: 'half a minute',
1705
+ lessThanXMinutes: {
1706
+ one: 'less than a minute',
1707
+ other: 'less than {{count}} minutes'
1708
+ },
1709
+ xMinutes: {
1710
+ one: '1 minute',
1711
+ other: '{{count}} minutes'
1712
+ },
1713
+ aboutXHours: {
1714
+ one: 'about 1 hour',
1715
+ other: 'about {{count}} hours'
1716
+ },
1717
+ xHours: {
1718
+ one: '1 hour',
1719
+ other: '{{count}} hours'
1720
+ },
1721
+ xDays: {
1722
+ one: '1 day',
1723
+ other: '{{count}} days'
1724
+ },
1725
+ aboutXWeeks: {
1726
+ one: 'about 1 week',
1727
+ other: 'about {{count}} weeks'
1728
+ },
1729
+ xWeeks: {
1730
+ one: '1 week',
1731
+ other: '{{count}} weeks'
1732
+ },
1733
+ aboutXMonths: {
1734
+ one: 'about 1 month',
1735
+ other: 'about {{count}} months'
1736
+ },
1737
+ xMonths: {
1738
+ one: '1 month',
1739
+ other: '{{count}} months'
1740
+ },
1741
+ aboutXYears: {
1742
+ one: 'about 1 year',
1743
+ other: 'about {{count}} years'
1744
+ },
1745
+ xYears: {
1746
+ one: '1 year',
1747
+ other: '{{count}} years'
1748
+ },
1749
+ overXYears: {
1750
+ one: 'over 1 year',
1751
+ other: 'over {{count}} years'
1752
+ },
1753
+ almostXYears: {
1754
+ one: 'almost 1 year',
1755
+ other: 'almost {{count}} years'
1756
+ }
1757
+ };
1758
+ var formatDistance = function formatDistance(token, count, options) {
1759
+ var result;
1760
+ var tokenValue = formatDistanceLocale[token];
1761
+ if (typeof tokenValue === 'string') {
1762
+ result = tokenValue;
1763
+ } else if (count === 1) {
1764
+ result = tokenValue.one;
1765
+ } else {
1766
+ result = tokenValue.other.replace('{{count}}', count.toString());
1767
+ }
1768
+ if (options !== null && options !== void 0 && options.addSuffix) {
1769
+ if (options.comparison && options.comparison > 0) {
1770
+ return 'in ' + result;
1771
+ } else {
1772
+ return result + ' ago';
1773
+ }
1774
+ }
1775
+ return result;
1776
+ };
1777
+ const formatDistance$1 = formatDistance;
1778
+
1779
+ function buildFormatLongFn(args) {
1780
+ return function () {
1781
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1782
+ // TODO: Remove String()
1783
+ var width = options.width ? String(options.width) : args.defaultWidth;
1784
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1785
+ return format;
1786
+ };
1787
+ }
1788
+
1789
+ var dateFormats = {
1790
+ full: 'EEEE, MMMM do, y',
1791
+ long: 'MMMM do, y',
1792
+ medium: 'MMM d, y',
1793
+ short: 'MM/dd/yyyy'
1794
+ };
1795
+ var timeFormats = {
1796
+ full: 'h:mm:ss a zzzz',
1797
+ long: 'h:mm:ss a z',
1798
+ medium: 'h:mm:ss a',
1799
+ short: 'h:mm a'
1800
+ };
1801
+ var dateTimeFormats = {
1802
+ full: "{{date}} 'at' {{time}}",
1803
+ long: "{{date}} 'at' {{time}}",
1804
+ medium: '{{date}}, {{time}}',
1805
+ short: '{{date}}, {{time}}'
1806
+ };
1807
+ var formatLong = {
1808
+ date: buildFormatLongFn({
1809
+ formats: dateFormats,
1810
+ defaultWidth: 'full'
1811
+ }),
1812
+ time: buildFormatLongFn({
1813
+ formats: timeFormats,
1814
+ defaultWidth: 'full'
1815
+ }),
1816
+ dateTime: buildFormatLongFn({
1817
+ formats: dateTimeFormats,
1818
+ defaultWidth: 'full'
1819
+ })
1820
+ };
1821
+ const formatLong$1 = formatLong;
1822
+
1823
+ var formatRelativeLocale = {
1824
+ lastWeek: "'last' eeee 'at' p",
1825
+ yesterday: "'yesterday at' p",
1826
+ today: "'today at' p",
1827
+ tomorrow: "'tomorrow at' p",
1828
+ nextWeek: "eeee 'at' p",
1829
+ other: 'P'
1830
+ };
1831
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1832
+ return formatRelativeLocale[token];
1833
+ };
1834
+ const formatRelative$1 = formatRelative;
1835
+
1836
+ function buildLocalizeFn(args) {
1837
+ return function (dirtyIndex, options) {
1838
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1839
+ var valuesArray;
1840
+ if (context === 'formatting' && args.formattingValues) {
1841
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1842
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1843
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1844
+ } else {
1845
+ var _defaultWidth = args.defaultWidth;
1846
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1847
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1848
+ }
1849
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1850
+ // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1851
+ return valuesArray[index];
1852
+ };
1853
+ }
1854
+
1855
+ var eraValues = {
1856
+ narrow: ['B', 'A'],
1857
+ abbreviated: ['BC', 'AD'],
1858
+ wide: ['Before Christ', 'Anno Domini']
1859
+ };
1860
+ var quarterValues = {
1861
+ narrow: ['1', '2', '3', '4'],
1862
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1863
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1864
+ };
1865
+
1866
+ // Note: in English, the names of days of the week and months are capitalized.
1867
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1868
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1869
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1870
+ var monthValues = {
1871
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1872
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1873
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1874
+ };
1875
+ var dayValues = {
1876
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1877
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1878
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1879
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1880
+ };
1881
+ var dayPeriodValues = {
1882
+ narrow: {
1883
+ am: 'a',
1884
+ pm: 'p',
1885
+ midnight: 'mi',
1886
+ noon: 'n',
1887
+ morning: 'morning',
1888
+ afternoon: 'afternoon',
1889
+ evening: 'evening',
1890
+ night: 'night'
1891
+ },
1892
+ abbreviated: {
1893
+ am: 'AM',
1894
+ pm: 'PM',
1895
+ midnight: 'midnight',
1896
+ noon: 'noon',
1897
+ morning: 'morning',
1898
+ afternoon: 'afternoon',
1899
+ evening: 'evening',
1900
+ night: 'night'
1901
+ },
1902
+ wide: {
1903
+ am: 'a.m.',
1904
+ pm: 'p.m.',
1905
+ midnight: 'midnight',
1906
+ noon: 'noon',
1907
+ morning: 'morning',
1908
+ afternoon: 'afternoon',
1909
+ evening: 'evening',
1910
+ night: 'night'
1911
+ }
1912
+ };
1913
+ var formattingDayPeriodValues = {
1914
+ narrow: {
1915
+ am: 'a',
1916
+ pm: 'p',
1917
+ midnight: 'mi',
1918
+ noon: 'n',
1919
+ morning: 'in the morning',
1920
+ afternoon: 'in the afternoon',
1921
+ evening: 'in the evening',
1922
+ night: 'at night'
1923
+ },
1924
+ abbreviated: {
1925
+ am: 'AM',
1926
+ pm: 'PM',
1927
+ midnight: 'midnight',
1928
+ noon: 'noon',
1929
+ morning: 'in the morning',
1930
+ afternoon: 'in the afternoon',
1931
+ evening: 'in the evening',
1932
+ night: 'at night'
1933
+ },
1934
+ wide: {
1935
+ am: 'a.m.',
1936
+ pm: 'p.m.',
1937
+ midnight: 'midnight',
1938
+ noon: 'noon',
1939
+ morning: 'in the morning',
1940
+ afternoon: 'in the afternoon',
1941
+ evening: 'in the evening',
1942
+ night: 'at night'
1943
+ }
1944
+ };
1945
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1946
+ var number = Number(dirtyNumber);
1947
+
1948
+ // If ordinal numbers depend on context, for example,
1949
+ // if they are different for different grammatical genders,
1950
+ // use `options.unit`.
1951
+ //
1952
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1953
+ // 'day', 'hour', 'minute', 'second'.
1954
+
1955
+ var rem100 = number % 100;
1956
+ if (rem100 > 20 || rem100 < 10) {
1957
+ switch (rem100 % 10) {
1958
+ case 1:
1959
+ return number + 'st';
1960
+ case 2:
1961
+ return number + 'nd';
1962
+ case 3:
1963
+ return number + 'rd';
1964
+ }
1965
+ }
1966
+ return number + 'th';
1967
+ };
1968
+ var localize = {
1969
+ ordinalNumber: ordinalNumber,
1970
+ era: buildLocalizeFn({
1971
+ values: eraValues,
1972
+ defaultWidth: 'wide'
1973
+ }),
1974
+ quarter: buildLocalizeFn({
1975
+ values: quarterValues,
1976
+ defaultWidth: 'wide',
1977
+ argumentCallback: function argumentCallback(quarter) {
1978
+ return quarter - 1;
1979
+ }
1980
+ }),
1981
+ month: buildLocalizeFn({
1982
+ values: monthValues,
1983
+ defaultWidth: 'wide'
1984
+ }),
1985
+ day: buildLocalizeFn({
1986
+ values: dayValues,
1987
+ defaultWidth: 'wide'
1988
+ }),
1989
+ dayPeriod: buildLocalizeFn({
1990
+ values: dayPeriodValues,
1991
+ defaultWidth: 'wide',
1992
+ formattingValues: formattingDayPeriodValues,
1993
+ defaultFormattingWidth: 'wide'
1994
+ })
1995
+ };
1996
+ const localize$1 = localize;
1997
+
1998
+ function buildMatchFn(args) {
1999
+ return function (string) {
2000
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2001
+ var width = options.width;
2002
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
2003
+ var matchResult = string.match(matchPattern);
2004
+ if (!matchResult) {
2005
+ return null;
2006
+ }
2007
+ var matchedString = matchResult[0];
2008
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
2009
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
2010
+ return pattern.test(matchedString);
2011
+ }) : findKey(parsePatterns, function (pattern) {
2012
+ return pattern.test(matchedString);
2013
+ });
2014
+ var value;
2015
+ value = args.valueCallback ? args.valueCallback(key) : key;
2016
+ value = options.valueCallback ? options.valueCallback(value) : value;
2017
+ var rest = string.slice(matchedString.length);
2018
+ return {
2019
+ value: value,
2020
+ rest: rest
2021
+ };
2022
+ };
2023
+ }
2024
+ function findKey(object, predicate) {
2025
+ for (var key in object) {
2026
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
2027
+ return key;
2028
+ }
2029
+ }
2030
+ return undefined;
2031
+ }
2032
+ function findIndex(array, predicate) {
2033
+ for (var key = 0; key < array.length; key++) {
2034
+ if (predicate(array[key])) {
2035
+ return key;
2036
+ }
2037
+ }
2038
+ return undefined;
2039
+ }
2040
+
2041
+ function buildMatchPatternFn(args) {
2042
+ return function (string) {
2043
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2044
+ var matchResult = string.match(args.matchPattern);
2045
+ if (!matchResult) return null;
2046
+ var matchedString = matchResult[0];
2047
+ var parseResult = string.match(args.parsePattern);
2048
+ if (!parseResult) return null;
2049
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
2050
+ value = options.valueCallback ? options.valueCallback(value) : value;
2051
+ var rest = string.slice(matchedString.length);
2052
+ return {
2053
+ value: value,
2054
+ rest: rest
2055
+ };
2056
+ };
2057
+ }
2058
+
2059
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
2060
+ var parseOrdinalNumberPattern = /\d+/i;
2061
+ var matchEraPatterns = {
2062
+ narrow: /^(b|a)/i,
2063
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
2064
+ wide: /^(before christ|before common era|anno domini|common era)/i
2065
+ };
2066
+ var parseEraPatterns = {
2067
+ any: [/^b/i, /^(a|c)/i]
2068
+ };
2069
+ var matchQuarterPatterns = {
2070
+ narrow: /^[1234]/i,
2071
+ abbreviated: /^q[1234]/i,
2072
+ wide: /^[1234](th|st|nd|rd)? quarter/i
2073
+ };
2074
+ var parseQuarterPatterns = {
2075
+ any: [/1/i, /2/i, /3/i, /4/i]
2076
+ };
2077
+ var matchMonthPatterns = {
2078
+ narrow: /^[jfmasond]/i,
2079
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
2080
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
2081
+ };
2082
+ var parseMonthPatterns = {
2083
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
2084
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
2085
+ };
2086
+ var matchDayPatterns = {
2087
+ narrow: /^[smtwf]/i,
2088
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
2089
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2090
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2091
+ };
2092
+ var parseDayPatterns = {
2093
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2094
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2095
+ };
2096
+ var matchDayPeriodPatterns = {
2097
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2098
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
2099
+ };
2100
+ var parseDayPeriodPatterns = {
2101
+ any: {
2102
+ am: /^a/i,
2103
+ pm: /^p/i,
2104
+ midnight: /^mi/i,
2105
+ noon: /^no/i,
2106
+ morning: /morning/i,
2107
+ afternoon: /afternoon/i,
2108
+ evening: /evening/i,
2109
+ night: /night/i
2110
+ }
2111
+ };
2112
+ var match = {
2113
+ ordinalNumber: buildMatchPatternFn({
2114
+ matchPattern: matchOrdinalNumberPattern,
2115
+ parsePattern: parseOrdinalNumberPattern,
2116
+ valueCallback: function valueCallback(value) {
2117
+ return parseInt(value, 10);
2118
+ }
2119
+ }),
2120
+ era: buildMatchFn({
2121
+ matchPatterns: matchEraPatterns,
2122
+ defaultMatchWidth: 'wide',
2123
+ parsePatterns: parseEraPatterns,
2124
+ defaultParseWidth: 'any'
2125
+ }),
2126
+ quarter: buildMatchFn({
2127
+ matchPatterns: matchQuarterPatterns,
2128
+ defaultMatchWidth: 'wide',
2129
+ parsePatterns: parseQuarterPatterns,
2130
+ defaultParseWidth: 'any',
2131
+ valueCallback: function valueCallback(index) {
2132
+ return index + 1;
2133
+ }
2134
+ }),
2135
+ month: buildMatchFn({
2136
+ matchPatterns: matchMonthPatterns,
2137
+ defaultMatchWidth: 'wide',
2138
+ parsePatterns: parseMonthPatterns,
2139
+ defaultParseWidth: 'any'
2140
+ }),
2141
+ day: buildMatchFn({
2142
+ matchPatterns: matchDayPatterns,
2143
+ defaultMatchWidth: 'wide',
2144
+ parsePatterns: parseDayPatterns,
2145
+ defaultParseWidth: 'any'
2146
+ }),
2147
+ dayPeriod: buildMatchFn({
2148
+ matchPatterns: matchDayPeriodPatterns,
2149
+ defaultMatchWidth: 'any',
2150
+ parsePatterns: parseDayPeriodPatterns,
2151
+ defaultParseWidth: 'any'
2152
+ })
2153
+ };
2154
+ const match$1 = match;
2155
+
2156
+ /**
2157
+ * @type {Locale}
2158
+ * @category Locales
2159
+ * @summary English locale (United States).
2160
+ * @language English
2161
+ * @iso-639-2 eng
2162
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
2163
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
2164
+ */
2165
+ var locale = {
2166
+ code: 'en-US',
2167
+ formatDistance: formatDistance$1,
2168
+ formatLong: formatLong$1,
2169
+ formatRelative: formatRelative$1,
2170
+ localize: localize$1,
2171
+ match: match$1,
2172
+ options: {
2173
+ weekStartsOn: 0 /* Sunday */,
2174
+ firstWeekContainsDate: 1
2175
+ }
2176
+ };
2177
+ const defaultLocale = locale;
2178
+
2179
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2180
+ // (one of the certain letters followed by `o`)
2181
+ // - (\w)\1* matches any sequences of the same letter
2182
+ // - '' matches two quote characters in a row
2183
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2184
+ // except a single quote symbol, which ends the sequence.
2185
+ // Two quote characters do not end the sequence.
2186
+ // If there is no matching single quote
2187
+ // then the sequence will continue until the end of the string.
2188
+ // - . matches any single character unmatched by previous parts of the RegExps
2189
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2190
+
2191
+ // This RegExp catches symbols escaped by quotes, and also
2192
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2193
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2194
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2195
+ var doubleQuoteRegExp = /''/g;
2196
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2197
+
2198
+ /**
2199
+ * @name format
2200
+ * @category Common Helpers
2201
+ * @summary Format the date.
2202
+ *
2203
+ * @description
2204
+ * Return the formatted date string in the given format. The result may vary by locale.
2205
+ *
2206
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2207
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2208
+ *
2209
+ * The characters wrapped between two single quotes characters (') are escaped.
2210
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2211
+ * (see the last example)
2212
+ *
2213
+ * Format of the string is based on Unicode Technical Standard #35:
2214
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2215
+ * with a few additions (see note 7 below the table).
2216
+ *
2217
+ * Accepted patterns:
2218
+ * | Unit | Pattern | Result examples | Notes |
2219
+ * |---------------------------------|---------|-----------------------------------|-------|
2220
+ * | Era | G..GGG | AD, BC | |
2221
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2222
+ * | | GGGGG | A, B | |
2223
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2224
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2225
+ * | | yy | 44, 01, 00, 17 | 5 |
2226
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2227
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2228
+ * | | yyyyy | ... | 3,5 |
2229
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2230
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2231
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2232
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2233
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2234
+ * | | YYYYY | ... | 3,5 |
2235
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2236
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2237
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2238
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2239
+ * | | RRRRR | ... | 3,5,7 |
2240
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2241
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2242
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2243
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2244
+ * | | uuuuu | ... | 3,5 |
2245
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2246
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2247
+ * | | QQ | 01, 02, 03, 04 | |
2248
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2249
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2250
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2251
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2252
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2253
+ * | | qq | 01, 02, 03, 04 | |
2254
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2255
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2256
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2257
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2258
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2259
+ * | | MM | 01, 02, ..., 12 | |
2260
+ * | | MMM | Jan, Feb, ..., Dec | |
2261
+ * | | MMMM | January, February, ..., December | 2 |
2262
+ * | | MMMMM | J, F, ..., D | |
2263
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2264
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2265
+ * | | LL | 01, 02, ..., 12 | |
2266
+ * | | LLL | Jan, Feb, ..., Dec | |
2267
+ * | | LLLL | January, February, ..., December | 2 |
2268
+ * | | LLLLL | J, F, ..., D | |
2269
+ * | Local week of year | w | 1, 2, ..., 53 | |
2270
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2271
+ * | | ww | 01, 02, ..., 53 | |
2272
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2273
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2274
+ * | | II | 01, 02, ..., 53 | 7 |
2275
+ * | Day of month | d | 1, 2, ..., 31 | |
2276
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2277
+ * | | dd | 01, 02, ..., 31 | |
2278
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2279
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2280
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2281
+ * | | DDD | 001, 002, ..., 365, 366 | |
2282
+ * | | DDDD | ... | 3 |
2283
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2284
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2285
+ * | | EEEEE | M, T, W, T, F, S, S | |
2286
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2287
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2288
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2289
+ * | | ii | 01, 02, ..., 07 | 7 |
2290
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2291
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2292
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2293
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2294
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2295
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2296
+ * | | ee | 02, 03, ..., 01 | |
2297
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2298
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2299
+ * | | eeeee | M, T, W, T, F, S, S | |
2300
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2301
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2302
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2303
+ * | | cc | 02, 03, ..., 01 | |
2304
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2305
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2306
+ * | | ccccc | M, T, W, T, F, S, S | |
2307
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2308
+ * | AM, PM | a..aa | AM, PM | |
2309
+ * | | aaa | am, pm | |
2310
+ * | | aaaa | a.m., p.m. | 2 |
2311
+ * | | aaaaa | a, p | |
2312
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2313
+ * | | bbb | am, pm, noon, midnight | |
2314
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2315
+ * | | bbbbb | a, p, n, mi | |
2316
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2317
+ * | | BBBB | at night, in the morning, ... | 2 |
2318
+ * | | BBBBB | at night, in the morning, ... | |
2319
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2320
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2321
+ * | | hh | 01, 02, ..., 11, 12 | |
2322
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2323
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2324
+ * | | HH | 00, 01, 02, ..., 23 | |
2325
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2326
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2327
+ * | | KK | 01, 02, ..., 11, 00 | |
2328
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2329
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2330
+ * | | kk | 24, 01, 02, ..., 23 | |
2331
+ * | Minute | m | 0, 1, ..., 59 | |
2332
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2333
+ * | | mm | 00, 01, ..., 59 | |
2334
+ * | Second | s | 0, 1, ..., 59 | |
2335
+ * | | so | 0th, 1st, ..., 59th | 7 |
2336
+ * | | ss | 00, 01, ..., 59 | |
2337
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2338
+ * | | SS | 00, 01, ..., 99 | |
2339
+ * | | SSS | 000, 001, ..., 999 | |
2340
+ * | | SSSS | ... | 3 |
2341
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2342
+ * | | XX | -0800, +0530, Z | |
2343
+ * | | XXX | -08:00, +05:30, Z | |
2344
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2345
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2346
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2347
+ * | | xx | -0800, +0530, +0000 | |
2348
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2349
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2350
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2351
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2352
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2353
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2354
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2355
+ * | Seconds timestamp | t | 512969520 | 7 |
2356
+ * | | tt | ... | 3,7 |
2357
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2358
+ * | | TT | ... | 3,7 |
2359
+ * | Long localized date | P | 04/29/1453 | 7 |
2360
+ * | | PP | Apr 29, 1453 | 7 |
2361
+ * | | PPP | April 29th, 1453 | 7 |
2362
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2363
+ * | Long localized time | p | 12:00 AM | 7 |
2364
+ * | | pp | 12:00:00 AM | 7 |
2365
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2366
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2367
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2368
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2369
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2370
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2371
+ * Notes:
2372
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2373
+ * are the same as "stand-alone" units, but are different in some languages.
2374
+ * "Formatting" units are declined according to the rules of the language
2375
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2376
+ *
2377
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2378
+ *
2379
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2380
+ *
2381
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2382
+ * the single quote characters (see below).
2383
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2384
+ * the output will be the same as default pattern for this unit, usually
2385
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2386
+ * are marked with "2" in the last column of the table.
2387
+ *
2388
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2389
+ *
2390
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2391
+ *
2392
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2393
+ *
2394
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2395
+ *
2396
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2397
+ *
2398
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2399
+ * The output will be padded with zeros to match the length of the pattern.
2400
+ *
2401
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2402
+ *
2403
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2404
+ * These tokens represent the shortest form of the quarter.
2405
+ *
2406
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2407
+ *
2408
+ * | Year | `y` | `u` |
2409
+ * |------|-----|-----|
2410
+ * | AC 1 | 1 | 1 |
2411
+ * | BC 1 | 1 | 0 |
2412
+ * | BC 2 | 2 | -1 |
2413
+ *
2414
+ * Also `yy` always returns the last two digits of a year,
2415
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2416
+ *
2417
+ * | Year | `yy` | `uu` |
2418
+ * |------|------|------|
2419
+ * | 1 | 01 | 01 |
2420
+ * | 14 | 14 | 14 |
2421
+ * | 376 | 76 | 376 |
2422
+ * | 1453 | 53 | 1453 |
2423
+ *
2424
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2425
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2426
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2427
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2428
+ *
2429
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2430
+ * so right now these tokens fall back to GMT timezones.
2431
+ *
2432
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2433
+ * - `i`: ISO day of week
2434
+ * - `I`: ISO week of year
2435
+ * - `R`: ISO week-numbering year
2436
+ * - `t`: seconds timestamp
2437
+ * - `T`: milliseconds timestamp
2438
+ * - `o`: ordinal number modifier
2439
+ * - `P`: long localized date
2440
+ * - `p`: long localized time
2441
+ *
2442
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2443
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2444
+ *
2445
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2446
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2447
+ *
2448
+ * @param {Date|Number} date - the original date
2449
+ * @param {String} format - the string of tokens
2450
+ * @param {Object} [options] - an object with options.
2451
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2452
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2453
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2454
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2455
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2456
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2457
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2458
+ * @returns {String} the formatted date string
2459
+ * @throws {TypeError} 2 arguments required
2460
+ * @throws {RangeError} `date` must not be Invalid Date
2461
+ * @throws {RangeError} `options.locale` must contain `localize` property
2462
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2463
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2464
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2465
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2466
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2467
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2468
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2469
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2470
+ *
2471
+ * @example
2472
+ * // Represent 11 February 2014 in middle-endian format:
2473
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2474
+ * //=> '02/11/2014'
2475
+ *
2476
+ * @example
2477
+ * // Represent 2 July 2014 in Esperanto:
2478
+ * import { eoLocale } from 'date-fns/locale/eo'
2479
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2480
+ * locale: eoLocale
2481
+ * })
2482
+ * //=> '2-a de julio 2014'
2483
+ *
2484
+ * @example
2485
+ * // Escape string by single quote characters:
2486
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2487
+ * //=> "3 o'clock"
2488
+ */
2489
+
2490
+ function format(dirtyDate, dirtyFormatStr, options) {
2491
+ var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2492
+ requiredArgs(2, arguments);
2493
+ var formatStr = String(dirtyFormatStr);
2494
+ var defaultOptions = getDefaultOptions();
2495
+ var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
2496
+ var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2497
+
2498
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2499
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2500
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2501
+ }
2502
+ var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2503
+
2504
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2505
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2506
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2507
+ }
2508
+ if (!locale.localize) {
2509
+ throw new RangeError('locale must contain localize property');
2510
+ }
2511
+ if (!locale.formatLong) {
2512
+ throw new RangeError('locale must contain formatLong property');
2513
+ }
2514
+ var originalDate = toDate(dirtyDate);
2515
+ if (!isValid(originalDate)) {
2516
+ throw new RangeError('Invalid time value');
2517
+ }
2518
+
2519
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2520
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2521
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2522
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2523
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2524
+ var formatterOptions = {
2525
+ firstWeekContainsDate: firstWeekContainsDate,
2526
+ weekStartsOn: weekStartsOn,
2527
+ locale: locale,
2528
+ _originalDate: originalDate
2529
+ };
2530
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2531
+ var firstCharacter = substring[0];
2532
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2533
+ var longFormatter = longFormatters$1[firstCharacter];
2534
+ return longFormatter(substring, locale.formatLong);
2535
+ }
2536
+ return substring;
2537
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2538
+ // Replace two single quote characters with one single quote character
2539
+ if (substring === "''") {
2540
+ return "'";
2541
+ }
2542
+ var firstCharacter = substring[0];
2543
+ if (firstCharacter === "'") {
2544
+ return cleanEscapedString(substring);
2545
+ }
2546
+ var formatter = formatters$1[firstCharacter];
2547
+ if (formatter) {
2548
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2549
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2550
+ }
2551
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2552
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2553
+ }
2554
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2555
+ }
2556
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2557
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2558
+ }
2559
+ return substring;
2560
+ }).join('');
2561
+ return result;
2562
+ }
2563
+ function cleanEscapedString(input) {
2564
+ var matched = input.match(escapedStringRegExp);
2565
+ if (!matched) {
2566
+ return input;
2567
+ }
2568
+ return matched[1].replace(doubleQuoteRegExp, "'");
2569
+ }
2570
+
2571
+ /**
2572
+ * @name isBefore
2573
+ * @category Common Helpers
2574
+ * @summary Is the first date before the second one?
2575
+ *
2576
+ * @description
2577
+ * Is the first date before the second one?
2578
+ *
2579
+ * @param {Date|Number} date - the date that should be before the other one to return true
2580
+ * @param {Date|Number} dateToCompare - the date to compare with
2581
+ * @returns {Boolean} the first date is before the second date
2582
+ * @throws {TypeError} 2 arguments required
2583
+ *
2584
+ * @example
2585
+ * // Is 10 July 1989 before 11 February 1987?
2586
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
2587
+ * //=> false
2588
+ */
2589
+ function isBefore(dirtyDate, dirtyDateToCompare) {
2590
+ requiredArgs(2, arguments);
2591
+ var date = toDate(dirtyDate);
2592
+ var dateToCompare = toDate(dirtyDateToCompare);
2593
+ return date.getTime() < dateToCompare.getTime();
2594
+ }
2595
+
2596
+ const DEFAULT_LANGUAGE = 'en';
2597
+ const SUPPORTED_LANGUAGES = ['en', 'zh-hk', 'it', 'fr', 'tr', 'hr'];
2598
+ const TRANSLATIONS = {
2599
+ en: {
2600
+ redeem: 'Redeem',
2601
+ claim: 'Claim',
2602
+ expireOn: 'Expire on ',
2603
+ coinsToBeExpired: '${expirationPoints} coins to expire in ${expireDay} days',
2604
+ coinsToBeExpiredDay: '${expirationPoints} coins to expire in ${expireDay} day',
2605
+ coinsToBeExpiredHours: '${expirationPoints} coins to expire in ${expireDay} hours',
2606
+ coinsToBeExpiredHour: '${expirationPoints} coins to expire in ${expireDay} hour',
2607
+ coinsToBeExpiredMinutes: '${expirationPoints} coins to expire in ${expireDay} minutes',
2608
+ coinsToBeExpiredMinute: '${expirationPoints} coins to expire in ${expireDay} minute',
2609
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
2610
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
2611
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2612
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2613
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2614
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2615
+ tipsForNextLevel: 'Next level is ${levelName}. ${pointsToReach} XP to level up',
2616
+ spendablePoints: 'Spendable Points:',
2617
+ details: 'Details',
2618
+ earningRules: 'Earning Rules',
2619
+ xp: 'XP',
2620
+ sp: 'Coins',
2621
+ termAndConditions: 'Term & Conditions',
2622
+ rakebackTitle: 'Available Rakeback',
2623
+ loading: 'Loading',
2624
+ minutesCanClaim: 'Next Claim is available in ${minutes} minutes'
2625
+ },
2626
+ 'zh-hk': {
2627
+ redeem: '兑奖',
2628
+ claim: '返佣',
2629
+ expireOn: 'Expire on ',
2630
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
2631
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
2632
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2633
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2634
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2635
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2636
+ tipsForNextLevel: 'Next level is ${levelName}. ${pointsToReach} XP to level up',
2637
+ spendablePoints: 'Spendable Points:',
2638
+ details: '明细',
2639
+ earningRules: 'Earning Rules',
2640
+ xp: 'XP',
2641
+ sp: 'Coins',
2642
+ termAndConditions: 'Term & Conditions',
2643
+ rakebackTitle: '可用的返利',
2644
+ loading: '加載中',
2645
+ minutesCanClaim: '下次可領取時間為${minutes}分鐘後'
2646
+ },
2647
+ de: {
2648
+ redeem: 'Redeem',
2649
+ claim: 'Anspruch',
2650
+ expireOn: 'Expire on ',
2651
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
2652
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
2653
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2654
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2655
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2656
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2657
+ tipsForNextLevel: 'Next level is ${levelName}. ${pointsToReach} XP to level up',
2658
+ spendablePoints: 'Spendable Points:',
2659
+ details: 'Details',
2660
+ earningRules: 'Earning Rules',
2661
+ xp: 'XP',
2662
+ sp: 'Coins',
2663
+ termAndConditions: 'Term & Conditions',
2664
+ rakebackTitle: 'Verfügbarer Rakeback',
2665
+ loading: 'Laden',
2666
+ minutesCanClaim: 'Nächster Anspruch ist in ${minutes} Minuten verfügbar'
2667
+ },
2668
+ it: {
2669
+ redeem: 'Redeem',
2670
+ claim: 'Richiesta',
2671
+ expireOn: 'Expire on ',
2672
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
2673
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
2674
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2675
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2676
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2677
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2678
+ tipsForNextLevel: 'Next level is ${levelName}. ${pointsToReach} XP to level up',
2679
+ spendablePoints: 'Spendable Points:',
2680
+ details: 'Details',
2681
+ earningRules: 'Earning Rules',
2682
+ xp: 'XP',
2683
+ sp: 'Coins',
2684
+ termAndConditions: 'Term & Conditions',
2685
+ rakebackTitle: 'Rakeback Disponibile',
2686
+ loading: 'Caricamento',
2687
+ minutesCanClaim: 'La prossima richiesta sarà disponibile tra ${minutes} minuti'
2688
+ },
2689
+ fr: {
2690
+ redeem: 'Redeem',
2691
+ claim: 'Réclamer',
2692
+ expireOn: 'Expire on ',
2693
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
2694
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
2695
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2696
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2697
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2698
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2699
+ tipsForNextLevel: 'Next level is ${levelName}. ${pointsToReach} XP to level up',
2700
+ spendablePoints: 'Spendable Points:',
2701
+ details: 'Details',
2702
+ earningRules: 'Earning Rules',
2703
+ xp: 'XP',
2704
+ sp: 'Coins',
2705
+ termAndConditions: 'Term & Conditions',
2706
+ rakebackTitle: 'Rakeback Disponible',
2707
+ loading: 'Chargement',
2708
+ minutesCanClaim: 'La prochaine réclamation sera disponible dans ${minutes} minutes'
2709
+ },
2710
+ es: {
2711
+ redeem: 'Redeem',
2712
+ claim: 'Reclamar',
2713
+ rakebackTitle: 'Rakeback Disponible',
2714
+ loading: 'Cargando',
2715
+ minutesCanClaim: 'La próxima reclamación estará disponible en ${minutes} minutos'
2716
+ },
2717
+ tr: {
2718
+ redeem: 'Redeem',
2719
+ claim: 'Talep',
2720
+ expireOn: 'Expire on ',
2721
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
2722
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
2723
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2724
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2725
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2726
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2727
+ tipsForNextLevel: 'Next level is ${levelName}. ${pointsToReach} XP to level up',
2728
+ spendablePoints: 'Spendable Points:',
2729
+ details: 'Details',
2730
+ earningRules: 'Earning Rules',
2731
+ xp: 'XP',
2732
+ sp: 'Coins',
2733
+ termAndConditions: 'Term & Conditions',
2734
+ rakebackTitle: 'Mevcut Rakeback',
2735
+ loading: 'Yükleniyor',
2736
+ minutesCanClaim: 'Sonraki talep ${minutes} dakika içinde kullanılabilir'
2737
+ },
2738
+ ru: {
2739
+ redeem: 'Redeem',
2740
+ claim: 'Требовать',
2741
+ rakebackTitle: 'Доступный Рейкбек',
2742
+ loading: 'Загрузка',
2743
+ minutesCanClaim: 'Следующее требование будет доступно через ${minutes} минут'
2744
+ },
2745
+ ro: {
2746
+ redeem: 'Redeem',
2747
+ claim: 'Revendicare',
2748
+ rakebackTitle: 'Rakeback Disponibil',
2749
+ loading: 'Se încarcă',
2750
+ minutesCanClaim: 'Următoarea revendicare va fi disponibilă în ${minutes} minute'
2751
+ },
2752
+ hr: {
2753
+ redeem: 'Otkupiti',
2754
+ claim: 'Zahtjev',
2755
+ expireOn: 'Istječe',
2756
+ pointsToBeExpired: '${expirationPoints} bodova ističe za ${expireDay} dana',
2757
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
2758
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
2759
+ pointsToBeExpiredMinutes: '${expirationPoints} points to expire in ${expireDay} minutes',
2760
+ pointsToBeExpiredMinute: '${expirationPoints} points to expire in ${expireDay} minute',
2761
+ tipsForNextLevel: 'Trebate ${pointsToReach} da dosegnete razinu ${levelName}',
2762
+ spendablePoints: 'Bodovi za potrošit:',
2763
+ details: 'Detalji',
2764
+ xp: 'XP',
2765
+ rakebackTitle: 'Dostupan Rakeback',
2766
+ loading: 'Učitavanje',
2767
+ minutesCanClaim: 'Sljedeći zahtjev bit će dostupan za ${minutes} minuta'
2768
+ },
2769
+ hu: {
2770
+ redeem: 'Redeem',
2771
+ claim: 'Igény',
2772
+ rakebackTitle: 'Elérhető Rakeback',
2773
+ loading: 'Betöltés',
2774
+ minutesCanClaim: 'A következő igény ${minutes} perc múlva lesz elérhető'
2775
+ },
2776
+ pl: {
2777
+ redeem: 'Redeem',
2778
+ claim: 'Roszczenie',
2779
+ rakebackTitle: 'Dostępny Rakeback',
2780
+ loading: 'Ładowanie',
2781
+ minutesCanClaim: 'Następne roszczenie będzie dostępne za ${minutes} minut'
2782
+ },
2783
+ pt: {
2784
+ redeem: 'Redeem',
2785
+ claim: 'Reivindicar',
2786
+ rakebackTitle: 'Rakeback Disponível',
2787
+ loading: 'Carregando',
2788
+ minutesCanClaim: 'Próxima reivindicação disponível em ${minutes} minutos'
2789
+ },
2790
+ sl: {
2791
+ redeem: 'Redeem',
2792
+ claim: 'Zahtevek',
2793
+ rakebackTitle: 'Razpoložljiv Rakeback',
2794
+ loading: 'Nalaganje',
2795
+ minutesCanClaim: 'Naslednji zahtevek bo na voljo čez ${minutes} minut'
2796
+ },
2797
+ sr: {
2798
+ redeem: 'Redeem',
2799
+ claim: 'Zahtev',
2800
+ rakebackTitle: 'Dostupan Rakeback',
2801
+ loading: 'Učitavanje',
2802
+ minutesCanClaim: 'Sledeći zahtev biće dostupan za ${minutes} minuta'
2803
+ }
2804
+ };
2805
+ const translate = (key, customLang) => {
2806
+ const lang = customLang;
2807
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2808
+ };
2809
+ const translateWithParams = (key, params) => {
2810
+ const lang = params['lang'];
2811
+ let templateString = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2812
+ if (!params) {
2813
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2814
+ }
2815
+ Object.keys(params).forEach((paramName) => {
2816
+ templateString = templateString.replace(new RegExp('\\$\{' + paramName + '\}', 'gm'), params[paramName]);
2817
+ });
2818
+ return templateString;
2819
+ };
2820
+
2821
+ function updateProgressSvg(progressElementRef, percent) {
2822
+ const svgElement = progressElementRef.querySelector('#total_level');
2823
+ const endLockWidth = 17, pointR = 6.5;
2824
+ //Total Widget of the progress
2825
+ const barWidth = svgElement.getBBox().width;
2826
+ //The filled width according to current progress
2827
+ const levelPercent = percent > 1 ? 1 : percent;
2828
+ const widthOnBar = (levelPercent * barWidth - endLockWidth) < 0 ? 0 : levelPercent * barWidth - endLockWidth;
2829
+ //update bar's width, widthOnBar
2830
+ const levelBar = progressElementRef.querySelector('#current_level');
2831
+ //update filters, x = widthOnBar
2832
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
2833
+ //update circle, widthOnBar+10
2834
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
2835
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
2836
+ levelBar.setAttribute('width', `${widthOnBar}`);
2837
+ levelCircle.setAttribute('cx', `${(widthOnBar < pointR ? pointR : widthOnBar)}`);
2838
+ levelFilter.setAttribute('x', `${widthOnBar - 8}`);
2839
+ //update lock location
2840
+ const endLockElement = progressElementRef.querySelector('#lock');
2841
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
2842
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
2843
+ // ball in endlockfilter2_i_305_23
2844
+ const filter2 = progressElementRef.querySelector('#filter_ball');
2845
+ // heart in endlockfilter3_d_305_23
2846
+ const filter3 = progressElementRef.querySelector('#filter_heart');
2847
+ //wrapper of lockfilter4_d_305_23
2848
+ const filterLock = progressElementRef.querySelector('#filter_lock');
2849
+ // shadow of ball paint0_linear_305_23
2850
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
2851
+ //paint in lockpaint1_linear_305_23
2852
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
2853
+ // box of lock and heart, for move position dynamically
2854
+ const lockBox = progressElementRef.querySelector('#lock_box');
2855
+ const heartBox = progressElementRef.querySelector('#heart_box');
2856
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
2857
+ //set cx of lockElement
2858
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
2859
+ //set cx of sub Elements
2860
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
2861
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
2862
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
2863
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
2864
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
2865
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
2866
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
2867
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
2868
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
2869
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
2870
+ svgElement.parentElement.style.opacity = '1';
2871
+ }
2872
+
2873
+ const playerElevateCardDataCss = ":host {\n display: block;\n width: 360px;\n height: 230px;\n}\n\n.ElevateCardWrapper {\n contain: layout inline-size;\n width: 100%;\n height: fit-content;\n min-height: 218px;\n}\n\n.Outer {\n container-type: inline-size;\n font-size: 12px;\n background-size: cover;\n background-repeat: no-repeat;\n line-height: initial;\n width: 100%;\n height: 100%;\n}\n\n.Dark {\n color: var(--emw--color-gray150, #efefef);\n}\n\n.Light {\n color: var(--emw--color-black, #0e0e0e);\n}\n\n@container (min-width: 381px) {\n .Outer {\n background-size: cover;\n }\n .Outer .OuterCover {\n min-height: 190px;\n }\n}\n@container (min-width: 260px) {\n .Outer {\n background-size: contain;\n }\n}\n.OuterCover {\n width: 100%;\n height: 100%;\n content: \"\";\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 15px;\n}\n\n.Inner {\n display: flex;\n flex-direction: column;\n min-height: 158px;\n}\n.Inner .Content {\n padding: 15px;\n flex-wrap: wrap;\n gap: 8px;\n}\n.Inner .Row {\n display: flex;\n flex-direction: row;\n}\n.Inner .CardCell {\n display: flex;\n}\n.Inner .LevelProgress svg {\n transition: opacity 0.4s;\n}\n.Inner .LevelInfo {\n display: flex;\n flex-direction: column;\n}\n.Inner .LevelInfo .ElevateLevel .LevelName {\n height: 28px;\n border-radius: 5px;\n line-height: 28px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.Inner .LevelInfo.Level0 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level0button-shadow, rgba(191, 84, 6, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level0-bg0, #E2792C) 0%, var(--emw--elevate-color-level0-bg1, rgba(242, 151, 99, 0)) 100%);\n}\n.Inner .LevelInfo.Level1 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level1button-shadow, rgba(151, 151, 151, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level1-bg0, #BEBFED) 0%, var(--emw--elevate-color-level1-bg1, rgba(216, 217, 233, 0)) 100%);\n}\n.Inner .LevelInfo.Level2 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level2button-shadow, rgba(191, 120, 6, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level2-bg0, #FCC410) 0%, var(--emw--elevate-color-level2-bg1, rgba(255, 189, 43, 0)) 100%);\n}\n.Inner .LevelInfo.Level3 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level3button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level3-bg0, #B1A2DB) 0%, var(--emw--elevate-color-level3-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo.Level4 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emw--elevate-color-level4button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emw--elevate-color-level4-bg0, #B1A2DB) 0%, var(--emw--elevate-color-level4-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo .ElevateLevel {\n display: flex;\n}\n.Inner .LevelInfo {\n flex: 1;\n flex-grow: 1;\n min-width: 150px;\n}\n.Inner .PlayerImg {\n width: 29%;\n margin: auto;\n max-width: 100px;\n min-width: 30px;\n order: 0;\n}\n.Inner .PlayerAvatar {\n max-width: 100px;\n flex-basis: 100px;\n height: auto;\n margin: auto;\n padding-top: 10px;\n}\n.Inner .PlayerAvatar .Avatar, .Inner .PlayerAvatar .Badge {\n width: 100%;\n height: 100%;\n}\n.Inner .PlayerAvatar .Avatar {\n border-radius: 50%;\n background-size: contain;\n background-repeat: no-repeat;\n}\n.Inner .ElevateLevel .ExpirationDate {\n max-width: 138px;\n min-width: 118px;\n}\n.Inner .PlayerName, .Inner .RedeemButton, .Inner .ElevateLevel {\n text-transform: capitalize;\n width: 100%;\n}\n.Inner .PlayerName {\n font-size: 16px;\n}\n.Inner .Row .PointsInfo {\n display: table;\n font-weight: 600;\n}\n.Inner .Row .Redeem {\n justify-content: flex-end;\n margin-left: auto;\n}\n.Inner .Row .Redeem:hover {\n color: var(--emw--elevate-color-redeem-hover, #00ABA4);\n cursor: pointer;\n}\n.Inner .Row .RedeemButton:hover span {\n color: var(emfe-w-elevate-color-redeem-text-hover, #f1f1f1);\n font-weight: bold;\n}\n.Inner .Row .RedeemButton {\n width: 95px;\n height: 35px;\n display: flex;\n align-items: center;\n border-radius: var(--emw--border-radius-medium, 10px);\n background: var(--emw--elevate-color-redeem-bg, linear-gradient(0deg, #26CC37, #26CC37)), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%);\n box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.2509803922);\n}\n.Inner .Row .RedeemButton span {\n color: var(--emw--color-white, #fff);\n line-height: 18px;\n font-size: 15px;\n text-align: center;\n width: 100%;\n}\n.Inner .Row .Points {\n font-size: large;\n vertical-align: middle;\n}\n.Inner .Row .Points .XP {\n font-size: x-small;\n}\n.Inner .Row .ExpirationPoints {\n font-size: small;\n text-align: right;\n font-weight: bold;\n color: var(--emw--color-red, #9e595f);\n}";
2874
+ const PlayerElevateCardDataStyle0 = playerElevateCardDataCss;
2875
+
2876
+ const PlayerElevateCardData = class {
2877
+ constructor(hostRef) {
2878
+ index.registerInstance(this, hostRef);
2879
+ this.playerElevateLeveLoaded = index.createEvent(this, "playerElevateLeveLoaded", 7);
2880
+ this.params = undefined;
2881
+ this.playerElevateLevel = undefined;
2882
+ this.pointExpireString = undefined;
2883
+ }
2884
+ handleWindowResizs() {
2885
+ this.initLevelProgressbar();
2886
+ }
2887
+ onParamsChanged() {
2888
+ this.loadElevateInfo();
2889
+ }
2890
+ redeemGiftButtonHandler() {
2891
+ this.loadElevateInfo();
2892
+ }
2893
+ onRedeemClick() {
2894
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
2895
+ }
2896
+ loadLevels() {
2897
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
2898
+ return new Promise((resolve, reject) => {
2899
+ return fetch(url.href, {
2900
+ method: 'GET',
2901
+ })
2902
+ .then((res) => res.json())
2903
+ .then((res) => {
2904
+ this.levels = res.data;
2905
+ resolve(true);
2906
+ })
2907
+ .catch((err) => {
2908
+ reject(err);
2909
+ });
2910
+ });
2911
+ }
2912
+ calcuatePointsToBeExpired(walletTotalInfo, translationPrefix) {
2913
+ let pointExpireInfoAsString = '';
2914
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
2915
+ walletTotalInfo.aboutToExpire.length == 0 ||
2916
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
2917
+ return pointExpireInfoAsString;
2918
+ }
2919
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
2920
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
2921
+ ? -1
2922
+ : 1;
2923
+ });
2924
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
2925
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
2926
+ let hoursToExpired = 0, minutesToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? `${translationPrefix}Day` : translationPrefix;
2927
+ if (daysToExpried <= 0) {
2928
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date(), { roundingMethod: 'floor' });
2929
+ expiredTranslationKey = hoursToExpired > 1 ? `${translationPrefix}Hours` : `${translationPrefix}Hour`;
2930
+ if (hoursToExpired <= 0) {
2931
+ minutesToExpired = differenceInMinutes(new Date(aboutToExpire.expireTime), new Date(), { roundingMethod: 'floor' });
2932
+ expiredTranslationKey = minutesToExpired > 1 ? `${translationPrefix}Minutes` : `${translationPrefix}Minute`;
2933
+ }
2934
+ }
2935
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
2936
+ expirationPoints: aboutToExpire.points,
2937
+ expireDay: Math.max(daysToExpried, hoursToExpired, minutesToExpired),
2938
+ lang: this.params.language,
2939
+ });
2940
+ return pointExpireInfoAsString;
2941
+ }
2942
+ loadPlayerLevelInfo() {
2943
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
2944
+ return new Promise((resolve, reject) => {
2945
+ return fetch(url.href, {
2946
+ method: 'GET',
2947
+ headers: {
2948
+ 'X-Sessionid': this.params.session,
2949
+ 'Content-Type': 'application/json',
2950
+ },
2951
+ })
2952
+ .then((res) => res.json())
2953
+ .then((res) => {
2954
+ var _a, _b, _c, _d, _e;
2955
+ if (!res.success) {
2956
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
2957
+ reject(true);
2958
+ return;
2959
+ }
2960
+ window.postMessage({ type: 'UpdateGamificationXp', points: (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.level) === null || _b === void 0 ? void 0 : _b.loyaltyPoints }, window.location.href);
2961
+ let playerElevateInfo = res.data;
2962
+ this.playerElevateLevel = playerElevateInfo.level;
2963
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
2964
+ this.playerElevateLevel.spendablePoints = ((_c = playerElevateInfo.spendableWallet) === null || _c === void 0 ? void 0 : _c.total.points) || 0;
2965
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
2966
+ const spendableTotal = (_d = res.data.spendableWallet) === null || _d === void 0 ? void 0 : _d.total;
2967
+ const loyaltyWalletTotal = (_e = res.data.loyaltyWallet) === null || _e === void 0 ? void 0 : _e.total;
2968
+ this.playerElevateLeveLoaded.emit({
2969
+ elevateLevelWalletTotal: spendableTotal,
2970
+ loyaltyWalletTotal
2971
+ });
2972
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal, 'coinsToBeExpired');
2973
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal, 'pointsToBeExpired');
2974
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
2975
+ this.playerElevateLeveLoaded.emit({
2976
+ pointExpireString: spExpireInfoAsString,
2977
+ xpExpireString: xpExpireInfoAsString
2978
+ });
2979
+ }
2980
+ resolve(this.playerElevateLevel);
2981
+ })
2982
+ .catch((err) => {
2983
+ console.log('error ', err);
2984
+ reject(true);
2985
+ });
2986
+ });
2987
+ }
2988
+ setLoyaltyProgress(percent) {
2989
+ updateProgressSvg(this.loyaltyProgressEle, percent);
2990
+ }
2991
+ initLevelProgressbar() {
2992
+ setTimeout(() => {
2993
+ this.loyaltyProgressEle =
2994
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
2995
+ if (!this.loyaltyProgressEle) {
2996
+ return;
2997
+ }
2998
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
2999
+ ? 1 : (this.playerElevateLevel.loyaltyPoints / this.playerElevateLevel.nextLevel.entryPoints));
3000
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
3001
+ }, 80);
3002
+ }
3003
+ componentDidRender() {
3004
+ this.initLevelProgressbar();
3005
+ }
3006
+ loadElevateInfo() {
3007
+ if (!this.params.endpoint || !this.params.session) {
3008
+ return;
3009
+ }
3010
+ const promises = [];
3011
+ promises.push(this.loadPlayerLevelInfo());
3012
+ if (this.params.calculateLevelFlag) {
3013
+ promises.push(this.loadLevels());
3014
+ }
3015
+ Promise.all(promises).then((res) => {
3016
+ console.log('elevate-init', res);
3017
+ this.initLevelProgressbar();
3018
+ if (!this.levels) {
3019
+ return;
3020
+ }
3021
+ this.levels.sort((level1, level2) => {
3022
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
3023
+ });
3024
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
3025
+ let playerLevelNumber = 0;
3026
+ this.levels.forEach((elevateLevel, idx) => {
3027
+ if (playerPoints > elevateLevel.firstEntryPoints) {
3028
+ playerLevelNumber = idx;
3029
+ }
3030
+ });
3031
+ this.playerElevateLeveLoaded.emit({
3032
+ calculatedLevelFlag: playerLevelNumber,
3033
+ });
3034
+ });
3035
+ }
3036
+ componentWillLoad() {
3037
+ this.loadElevateInfo();
3038
+ }
3039
+ get elevateCardRef() { return index.getElement(this); }
3040
+ static get watchers() { return {
3041
+ "params": ["onParamsChanged"]
3042
+ }; }
3043
+ };
3044
+ PlayerElevateCardData.style = PlayerElevateCardDataStyle0;
3045
+
3046
+ const LoyaltyProgress = `<svg width="100%" height="28" style="opacity: 0" fill="none" xmlns="http://www.w3.org/2000/svg">
3047
+ <rect y="12" x="2" width="100%" id="total_level" height="5" rx="2.5" fill="white" fill-opacity="0.5"/>
3048
+ <rect y="12" x="2" id="current_level" width="64" height="5" rx="2.5" fill="white"/>
3049
+ <g filter="url(#filter_current_level)">
3050
+ <circle id="circle_current_level" cx="74.5" cy="14.5" r="6.5" fill="white"/>
3051
+ </g>
3052
+ <g filter="url(#filter_heart_ball)">
3053
+ <g filter="url(#filter_ball)">
3054
+ <circle cx="169" cy="14" r="10" id="lock" fill="url(#paint0_linear_ball)"/>
3055
+ </g>
3056
+ <g filter="url(#filter_heart)">
3057
+ <svg x="0" y="4" id="lock_box">
3058
+ <path d="M10.217 6.42442c-0.713,-0.574,-1.304,-1.083,-1.928,-1.622c-0.348,-0.299,-0.707,-0.611,-1.101,-0.943l-0.013,-0.01c0,0,-0.023,-0.017,-0.04,-0.027l-0.167,-0.095l-0.15,0.12c0,0,-0.015,0.012,-0.024,0.02c-0.391,0.33,-0.749,0.64,-1.094,0.939c-0.622,0.539,-1.211,1.048,-1.924,1.624c-1.816,1.463,-3.598,3.263,-3.033,5.506c0.404,1.601,2.104,2.905,3.789,2.905c0.211,0,0.423,-0.02,0.626,-0.061c0.286,-0.058,0.572,-0.145,0.864,-0.265c-0.079,0.962,-0.413,1.864,-0.881,2.369l-0.423,0.459h0.633c0.633,0,1.018,-0.007,1.356,-0.013c0.248,-0.004,0.462,-0.008,0.72,-0.008c0.335,0,0.709,0.006,1.215,0.021l0.686,0.02l-0.474,-0.483c-0.504,-0.514,-0.847,-1.403,-0.923,-2.385c0.311,0.132,0.616,0.227,0.916,0.287c0.204,0.039,0.411,0.059,0.623,0.059c1.687,0,3.386,-1.304,3.789,-2.909c0.56,-2.243,-1.224,-4.041,-3.042,-5.504v-0.004z" fill="#933CBF"/>
3059
+ <path d="M9.727,6.98459c-1.004,-0.83,-1.741,-1.515,-2.723,-2.365c-0.002,0,-0.004,-0.004,-0.007,-0.006c-0.002,0,-0.004,0.004,-0.006,0.006c-0.98,0.85,-1.715,1.537,-2.721,2.367c-1.455,1.202,-3.126,2.821,-2.638,4.81c0.37,1.511,2.091,2.751,3.665,2.43c0.389,-0.08,0.75,-0.224,1.094,-0.402c0,0.116,-0.004,0.233,-0.012,0.353c-0.064,0.991,-0.398,1.892,-0.86,2.401c1.481,0,1.481,-0.043,2.961,0c-0.481,-0.503,-0.834,-1.382,-0.9,-2.401c-0.008,-0.127,-0.012,-0.253,-0.012,-0.378c0.357,0.19,0.733,0.342,1.14,0.425c1.574,0.319,3.292,-0.922,3.661,-2.433c0.486,-1.992,-1.189,-3.609,-2.644,
3060
+ -4.809l0.002,0.002z" fill="url(#paint1_linear_lock)"/>
3061
+ <path d="M9.255,7.551c-0.844,-0.716,-1.462,-1.309,-2.286,-2.045c-0.002,0,-0.004,-0.004,-0.006,-0.006c0,0,-0.004,0.004,-0.006,0.006c-0.824,0.736,-1.44,1.329,-2.284,2.047c-0.919,0.782,-1.94,1.769,-2.214,2.943c-0.115,0.021,-0.914,0.044,-0.914,0.044l0.887,0.083c-0.039,0.206,-0.055,0.418,-0.041,0.638c0.087,-1.371,1.25,-2.507,2.282,-3.384c0.844,-0.718,1.462,-1.313,2.284,-2.047c0.002,-0.002,0.004,-0.004,0.006,-0.006c0.002,0,0.004,0.004,0.006,0.004c0.824,0.734,1.442,1.329,2.286,2.045c1.034,0.879,2.198,2.013,2.286,3.386c0.093,-1.517,-1.173,-2.761,-2.286,-3.708z" fill="#9040C9"/>
3062
+ </svg>
3063
+ </g>
3064
+ </g>
3065
+ <g filter="url(#filter_lock)">
3066
+ <svg x="100%" y="9" id="heart_box">
3067
+ <path d="M7,6c-0.19,-0.002,-0.377,0.052,-0.534,0.154c-0.158,0.103,-0.278,0.25,-0.346,0.42c-0.069,0.171,-0.081,0.357,-0.035,0.535c0.046,0.177,0.147,0.337,0.29,0.457v0.834c0,0.159,0.066,0.312,0.183,0.424c0.117,0.113,0.276,0.176,0.442,0.176c0.166,0,0.325,-0.063,0.442,-0.176c0.117,-0.112,0.183,-0.265,0.183,-0.424v-0.834c0.143,-0.12,0.244,-0.28,0.29,-0.457c0.046,-0.178,0.034,-0.364,-0.035,-0.535c-0.068,-0.17,-0.188,-0.317,-0.346,-0.42c-0.157,-0.102,-0.344,-0.156,-0.534,-0.154zm3.125,-2.4v-1.2c0,-0.796,-0.329,-1.559,-0.915,-2.121c-0.586,-0.563,-1.381,-0.879,-2.21,-0.879c-0.829,0,-1.624,0.316,-2.21,0.879c-0.586,0.562,-0.915,1.325,-0.915,2.121v1.2c-0.497,0,-0.974,0.19,-1.326,0.527c-0.351,0.338,-0.549,0.796,-0.549,1.273v4.2c0,0.477,0.198,0.935,0.549,1.273c0.352,0.337,0.829,0.527,1.326,0.527h6.25c0.497,0,0.974,-0.19,1.326,-0.527c0.351,-0.338,0.549,-0.796,0.549,-1.273v-4.2c0,-0.477,-0.198,-0.935,-0.549,-1.273c-0.352,-0.337,-0.829,-0.527,-1.326,-0.527zm-5,-1.2c0,-0.477,0.198,-0.935,0.549,-1.273c0.352,-0.337,0.829,-0.527,1.326,-0.527c0.497,0,0.974,0.19,1.326,0.527c0.351,0.338,0.549,0.796,0.549,1.273v1.2h-3.75v-1.2zm5.625,7.2c0,0.159,-0.066,0.312,-0.183,0.424c-0.117,0.113,-0.276,0.176,-0.442,0.176h-6.25c-0.166,0,-0.325,-0.063,-0.442,-0.176c-0.117,-0.112,-0.183,-0.265,-0.183,-0.424v-4.2c0,-0.159,0.066,-0.312,0.183,-0.424c0.117,-0.113,0.276,-0.176,0.442,-0.176h6.25c0.166,0,0.325,0.063,0.442,0.176c0.117,0.112,0.183,0.265,0.183,0.424v4.2z" fill="white"/>
3068
+ </svg>
3069
+ </g>
3070
+ <defs>
3071
+ <filter id="filter_current_level" x="64" y="4" width="21" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3072
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
3073
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
3074
+ <feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_305_23"/>
3075
+ </filter>
3076
+ <filter id="filter_heart_ball" x="155" y="0" width="28" height="28" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3077
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
3078
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
3079
+ <feOffset/>
3080
+ <feGaussianBlur stdDeviation="2"/>
3081
+ <feComposite in2="hardAlpha" operator="out"/>
3082
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
3083
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
3084
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
3085
+ </filter>
3086
+ <filter id="filter_ball" x="159" y="4" width="20" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3087
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
3088
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
3089
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
3090
+ <feOffset dy="1"/>
3091
+ <feGaussianBlur stdDeviation="1"/>
3092
+ <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
3093
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0"/>
3094
+ <feBlend mode="normal" in2="shape" result="effect1_innerShadow_305_23"/>
3095
+ </filter>
3096
+ <filter id="filter_heart" x="161.636" y="5.72727" width="14.7271" height="15.6364" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3097
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
3098
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
3099
+ <feOffset/>
3100
+ <feGaussianBlur stdDeviation="0.5"/>
3101
+ <feComposite in2="hardAlpha" operator="out"/>
3102
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
3103
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
3104
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
3105
+ </filter>
3106
+ <filter id="filter_lock" x="50" y="7" width="12" height="14" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3107
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
3108
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
3109
+ <feOffset/>
3110
+ <feGaussianBlur stdDeviation="0.5"/>
3111
+ <feComposite in2="hardAlpha" operator="out"/>
3112
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
3113
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
3114
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
3115
+ </filter>
3116
+ <linearGradient id="paint0_linear_ball" x1="163" y1="6" x2="174.2" y2="22.6" gradientUnits="userSpaceOnUse">
3117
+ <stop stop-color="#946AD7"/>
3118
+ <stop offset="1" stop-color="#EFABEB"/>
3119
+ </linearGradient>
3120
+ <linearGradient id="paint1_linear_lock" x1="100%" y1="18.4056" x2="169.002" y2="10.2845" gradientUnits="userSpaceOnUse">
3121
+ <stop stop-color="#814FD6"/>
3122
+ <stop offset="1" stop-color="#D679D8"/>
3123
+ </linearGradient>
3124
+ </defs>
3125
+ </svg>
3126
+ `;
3127
+
3128
+ const TipsInfo = `<svg width="126" height="92" viewBox="0 0 126 92" fill="none" xmlns="http://www.w3.org/2000/svg">
3129
+ <g filter="url(#filter0_d_242_4231)">
3130
+ <rect x="24" y="20" width="78" height="36" rx="4" fill="white"/>
3131
+ <path d="M24 24C24 21.7909 25.7909 20 28 20H64V56H28C25.7909 56 24 54.2091 24 52V24Z" fill="#464646"/>
3132
+ <path d="M51 56H37L43.2474 63.1399C43.6458 63.5952 44.3542 63.5952 44.7526 63.1399L51 56Z" fill="#464646"/>
3133
+ <circle cx="44" cy="38" r="7" fill="white"/>
3134
+ <path d="M43.9405 34C44.5456 34 45.0362 34.4906 45.0362 35.0957C45.0362 35.7009 44.5456 36.1915 43.9405 36.1915C43.3353 36.1915 42.8447 35.7009 42.8447 35.0957C42.8447 34.4906 43.3353 34 43.9405 34Z" fill="#464646"/>
3135
+ <path d="M45.8801 41.3737C45.8801 41.7617 45.5626 42.0791 45.1746 42.0791H44.3233H43.551H42.7055C42.3175 42.0791 42 41.7617 42 41.3737V41.3575C42 40.9695 42.3175 40.6521 42.7055 40.6521H42.8455V37.8714H42.3528C42.1588 37.8714 42 37.7127 42 37.5187V37.4936C42 37.2996 42.1588 37.1409 42.3528 37.1409H43.551H44.031H44.3233C44.7113 37.1409 45.0287 37.4583 45.0287 37.8463V40.6521H45.1746C45.5626 40.6521 45.8801 40.9696 45.8801 41.3576V41.3737Z" fill="#464646"/>
3136
+ </g>
3137
+ <defs>
3138
+ <filter id="filter0_d_242_4231" x="0" y="0" width="126" height="91.4814" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
3139
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
3140
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
3141
+ <feOffset dy="4"/>
3142
+ <feGaussianBlur stdDeviation="12"/>
3143
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
3144
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_242_4231"/>
3145
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_242_4231" result="shape"/>
3146
+ </filter>
3147
+ </defs>
3148
+ </svg>
3149
+ `;
3150
+
3151
+ const PlayerLoyaltyProcess = () => (index.h("span", { class: "LevelProgress", id: 'LevelProgress', innerHTML: LoyaltyProgress }));
3152
+ const PlayerPoints = ({ loyaltyPoints, spendablePoints, pointExpireString, language, }) => (index.h("div", { class: "PointsInfo" },
3153
+ (loyaltyPoints && loyaltyPoints >= 0) &&
3154
+ index.h("div", { class: 'Points' },
3155
+ loyaltyPoints,
3156
+ " ",
3157
+ index.h("sub", { class: "XP" }, translate('xp', language))),
3158
+ spendablePoints &&
3159
+ index.h("div", { class: 'Points' },
3160
+ spendablePoints,
3161
+ " ",
3162
+ index.h("sub", { class: "XP" }, translate('sp', language))),
3163
+ pointExpireString && (index.h("div", { class: 'ExpirationPoints' },
3164
+ pointExpireString,
3165
+ " "))));
3166
+ const PlayerElevateCardRedeem = ({ language, onRedeemClick }) => (index.h("div", { class: "CardCell Redeem" },
3167
+ index.h("div", { class: "RedeemButton", onClick: () => {
3168
+ onRedeemClick();
3169
+ } },
3170
+ index.h("span", null, translate('redeem', language)))));
3171
+ const PlayerNameDiv = (props) => (index.h("div", { class: 'CardCell PlayerName Txt' }, props.playerName));
3172
+ const PlayerElevateLoyaltyLevel = (props) => (index.h("div", { class: 'CardCell ElevateLevel' },
3173
+ index.h("span", { class: "LevelName", title: props.level }, props.level),
3174
+ props.expireTime && (index.h("div", { class: "CardCell ExpirationDate Txt" },
3175
+ translate('expireOn', props.language),
3176
+ index.h("span", { class: "ExpireTime" }, format(new Date(props.expireTime), props.dateFormat || 'yyyy-MM-dd')),
3177
+ !props.hideInfo && (index.h("span", { class: "fa Info", style: { 'background': `url(${index.getAssetPath('../static/info.svg')})` } },
3178
+ index.h("span", { class: "InfoTips", innerHTML: TipsInfo })))))));
3179
+ const LoyaltyLevelExpireDay = (props) => (index.h("div", { class: 'CardCell ElevateLevel Expire' },
3180
+ index.h("div", { class: "CardCell ExpirationDate Txt" },
3181
+ translate('expireOn', props.language),
3182
+ index.h("span", { class: "ExpireTime" }, format(new Date(props.expireTime), props.dateFormat || 'yyyy-MM-dd')))));
3183
+ const PlayerAvatar = (props) => {
3184
+ const badge = props.loyaltyIconUrl
3185
+ ? index.h("img", { class: "Badge", src: props.loyaltyIconUrl })
3186
+ : props.hideIfNull ? '' : index.h("div", { class: "Badge" });
3187
+ const avatarSrc = props.playerAvatarUrl || index.getAssetPath('../static/user.svg');
3188
+ return index.h("div", { class: "PlayerAvatar", style: { 'position': `${props.onlyBadge ? '' : 'relative'}` } },
3189
+ !props.onlyBadge && index.h("img", { class: "Avatar", src: avatarSrc }),
3190
+ badge);
3191
+ };
3192
+
3193
+ const playerElevateCardJojogroupCss = "@container (max-width: 270px) {\n .Card .Inner {\n flex-direction: column;\n }\n .Card .Inner .Content {\n padding: 9px;\n }\n .Inner .Row .ExpirationPoints {\n order: 1;\n }\n}\n.Card .PlayerImg {\n order: 0;\n}\n.Card .ExpirationPoints {\n order: 3;\n}\n.Card .LevelInfo {\n order: 2;\n}\n.Card .Inner .Row .PlayerImg {\n flex-direction: column;\n}\n.Card .Inner .Row .PointsInfo {\n width: 100%;\n text-align: center;\n display: flex;\n flex-direction: column;\n max-height: 50%;\n}\n.Card .Inner .PlayerAvatar .Badge {\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n right: 5px;\n bottom: -5px;\n width: 40%;\n height: 40%;\n overflow: visible;\n}\n.Card .Inner .Row .ExpirationPoints {\n text-align: left;\n color: var(--emw--color-red, red);\n}\n.Card .Inner .Row .Points {\n text-wrap: nowrap;\n}\n.Card .Inner .LevelInfo .ElevateLevel {\n flex-direction: column;\n}\n.Card .Inner .LevelInfo .ElevateLevel .LevelName {\n width: calc(100% - 20px);\n text-align: left;\n font-size: 13px;\n padding-left: 20px;\n margin: 10px 0;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpirationDate {\n text-align: center;\n font-size: smaller;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpireTime {\n margin-left: 5px;\n}";
3194
+ const PlayerElevateCardJojogroupStyle0 = playerElevateCardJojogroupCss;
3195
+
3196
+ const PlayerElevateCardJojogroup = class {
3197
+ constructor(hostRef) {
3198
+ index.registerInstance(this, hostRef);
3199
+ this.endpoint = undefined;
3200
+ this.theme = 'Dark';
3201
+ this.session = undefined;
3202
+ this.playerAvatarUrl = undefined;
3203
+ this.language = 'en';
3204
+ this.playerName = undefined;
3205
+ this.dateFormat = 'yyyy-MM-dd';
3206
+ this.mbSource = undefined;
3207
+ this.clientStyling = '';
3208
+ this.clientStylingUrl = '';
3209
+ this.translationUrl = '';
3210
+ this.pointExpireString = undefined;
3211
+ this.playerLevelFlag = 0;
3212
+ this.playerElevateLevel = undefined;
3213
+ this.elevateWalletTotal = undefined;
3214
+ }
3215
+ onSessionOrEndpointChange() {
3216
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
3217
+ }
3218
+ playerElevateLeveLoadedHandler(event) {
3219
+ if (!event.detail) {
3220
+ return;
3221
+ }
3222
+ if (event.detail['elevateLevelWalletTotal']) {
3223
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3224
+ }
3225
+ if (event.detail['elevateLevel']) {
3226
+ this.playerElevateLevel = event.detail['elevateLevel'];
3227
+ }
3228
+ if (event.detail['pointExpireString']) {
3229
+ this.pointExpireString = event.detail.xpExpireString;
3230
+ }
3231
+ if (event.detail.calculatedLevelFlag) {
3232
+ this.playerLevelFlag = event.detail.calculatedLevelFlag;
3233
+ }
3234
+ }
3235
+ onRedeemClick() {
3236
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
3237
+ }
3238
+ componentWillLoad() {
3239
+ this.paramProxy = {
3240
+ endpoint: this.endpoint,
3241
+ session: this.session,
3242
+ language: this.language,
3243
+ calculateLevelFlag: true,
3244
+ };
3245
+ }
3246
+ render() {
3247
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
3248
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
3249
+ return (index.h("div", { key: '8c86c146c8f68edbafcd7b24f611dc8078b987a3', class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { key: '2273ad46cd7d12af9381b49abcef845e4fb2c1ea', class: "Card Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { key: '059a83126b0d72dcbb313cdd403af8f2017b0aa3', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl, mbSource: this.mbSource }), index.h("player-elevate-card-data", { key: '2ad65d182873df99f9a64d0c749cf0b620e0d502', params: this.paramProxy }), index.h("div", { key: 'd2e992c3b04e547743efd7a669d7ac8095e85a93', class: "OuterCover Inner", style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, this.playerElevateLevel && (index.h(index.Fragment, { key: '52d2392de4e1385a8b859e0707c93a4438aee7f8' }, index.h("div", { key: '2b30a05a04f62dc533efa3f499af6ad03a594fc1', class: 'Content Row' }, index.h("div", { key: 'f675cbcfd702d7661b90d243dc82d4ae44b6f1b2', class: "PlayerImg" }, index.h(PlayerAvatar, { key: 'e2cef080372b41b2fcc5031dcf71a7554c1aad20', playerAvatarUrl: this.playerAvatarUrl, loyaltyIconUrl: this.playerElevateLevel.presentation.asset }), index.h(PlayerPoints, { key: 'a51f2fa52a39cbbab786e2fa349c2125e8991df0', loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language })), this.pointExpireString && (index.h("div", { key: 'fc5a55e079e36c9397ee3d3e48eca22133e92006', class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), index.h("div", { key: '8afa183b3cb73c7309021f47d35199760b3068c4', class: `LevelInfo Level${this.playerLevelFlag} ${this.playerElevateLevel.presentation.displayName}` }, index.h(PlayerNameDiv, { key: '4f027b896cbeff8ee27c2d56b79664dac9269529', playerName: this.playerName }), index.h(PlayerElevateLoyaltyLevel, { key: '61f4c0124fb91c5ab2183cb9c249d01ff5f144df', hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), index.h(PlayerLoyaltyProcess, { key: '96ded134514a3f69f6192ab3e7645a7eef76da45' }), index.h(PlayerElevateCardRedeem, { key: '5c5df70825273a064533d660dfd35279c9832b42', onRedeemClick: this.onRedeemClick, language: this.language })))))))));
3250
+ }
3251
+ static get assetsDirs() { return ["../static"]; }
3252
+ static get watchers() { return {
3253
+ "session": ["onSessionOrEndpointChange"],
3254
+ "endpoint": ["onSessionOrEndpointChange"],
3255
+ "language": ["onSessionOrEndpointChange"]
3256
+ }; }
3257
+ };
3258
+ PlayerElevateCardJojogroup.style = PlayerElevateCardJojogroupStyle0;
3259
+
3260
+ const playerElevateLoyaltycardJojogroupCss = ":host{display:block}@media screen and (min-width: 501px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:nowrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:6px;margin-left:0px}}@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{min-height:auto}.LoyaltyCard .Inner .LevelProgress{margin-left:0px}.LoyaltyCard .Inner .Row .PointsInfo.ExpirationPoints{text-align:left;color:var(--emw--color-red-50, red)}.LoyaltyCard .Inner .PlayerAvatar{padding:0;flex-basis:auto;margin:0}.LoyaltyCard .Inner .PlayerContainer{display:flex}.LoyaltyCard .Inner .PlayerAvatar .Avatar{display:none}.LoyaltyCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:40px;height:40px}.LoyaltyCard .Inner .PlayerImg{max-width:none;width:auto;margin:0;justify-content:space-between;align-items:flex-end}.LoyaltyCard .Inner .PlayerInfo{display:flex;flex-direction:column;justify-content:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel{display:flex;flex:1;align-items:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{position:relative;padding-left:0px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate .ExpireTime{margin-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .LevelName{padding-left:0;font-size:var(--emw--elevate-fontsize-2xlarge, 21px);position:relative;width:auto;color:var(--emw--elevate-color-levelname, #FFBD2B);font-weight:bold}.LoyaltyCard .LevelRange{justify-content:space-between}.LoyaltyCard .PointsRange{display:flex;justify-content:flex-end}.LoyaltyCard .PointsRange .PointsInfo{width:auto}.LoyaltyCard .NextLevelTip{text-align:right;font-size:11px;color:var(--emw--color-black, #000);opacity:0.8;font-weight:bold}";
3261
+ const PlayerElevateLoyaltycardJojogroupStyle0 = playerElevateLoyaltycardJojogroupCss;
3262
+
3263
+ const PlayerElevateLoyaltycardJojogroup = class {
3264
+ constructor(hostRef) {
3265
+ index.registerInstance(this, hostRef);
3266
+ this.endpoint = undefined;
3267
+ this.theme = 'Dark';
3268
+ this.session = undefined;
3269
+ this.playerAvatarUrl = undefined;
3270
+ this.language = 'en';
3271
+ this.playerName = undefined;
3272
+ this.dateFormat = 'yyyy-MM-dd';
3273
+ this.mbSource = undefined;
3274
+ this.clientStyling = '';
3275
+ this.clientStylingUrl = '';
3276
+ this.translationUrl = '';
3277
+ this.pointExpireString = undefined;
3278
+ this.playerElevateLevel = undefined;
3279
+ this.elevateWalletTotal = undefined;
3280
+ }
3281
+ onSessionOrEndpointChange() {
3282
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
3283
+ }
3284
+ playerElevateLeveLoadedHandler(event) {
3285
+ if (!event.detail) {
3286
+ return;
3287
+ }
3288
+ if (event.detail['elevateLevelWalletTotal']) {
3289
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3290
+ }
3291
+ if (event.detail['elevateLevel']) {
3292
+ this.playerElevateLevel = event.detail['elevateLevel'];
3293
+ }
3294
+ if (event.detail['pointExpireString']) {
3295
+ this.pointExpireString = event.detail.xpExpireString;
3296
+ }
3297
+ }
3298
+ onRedeemClick() {
3299
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
3300
+ }
3301
+ componentWillLoad() {
3302
+ this.paramProxy = {
3303
+ endpoint: this.endpoint,
3304
+ session: this.session,
3305
+ language: this.language,
3306
+ };
3307
+ }
3308
+ getNextLevelPoints() {
3309
+ var _a, _b;
3310
+ return ((_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel) ? (_b = this.playerElevateLevel) === null || _b === void 0 ? void 0 : _b.nextLevel.entryPoints : -1;
3311
+ }
3312
+ getNextLevelTips() {
3313
+ var _a;
3314
+ //need xx to reach Diamond
3315
+ let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
3316
+ if (this.playerElevateLevel && nextLevel) {
3317
+ const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
3318
+ return translateWithParams('tipsForNextLevel', {
3319
+ pointsToReach,
3320
+ levelName: nextLevel.name,
3321
+ lang: this.language
3322
+ });
3323
+ }
3324
+ return '';
3325
+ }
3326
+ render() {
3327
+ var _a, _b, _c;
3328
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
3329
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
3330
+ return (index.h("div", { key: 'ef2c203816bdbd8146ac0e02435bdf4ffcc75bec', class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { key: '7078fdc223dc7ffaac850243f6a04e3d7c63d22d', class: "LoyaltyCard Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { key: '04480062cf7da6b511a43205d7bfb6398404bd6a', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl, mbSource: this.mbSource }), index.h("player-elevate-card-data", { key: 'aa0c7abb7916865b404da21aa87ce6a7ba2f39d4', params: this.paramProxy }), index.h("div", { key: '900c8fba904daa860a456b38b4905ca8c5c30fa5', class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, index.h("div", { key: '1f1a6d6423f07eaba470fd2c95c8249213c346d2', class: 'Content' }, this.playerElevateLevel && (index.h(index.Fragment, { key: '2eada6942e44a5d14e5295b88a0d82f9f5372c57' }, index.h("div", { key: '49a29540d068555fb3fe23859e2f4d1f4f7f488a', class: "PlayerImg Row" }, index.h("div", { key: '68b195d5e4bf205922998d5479cdb6c14e6abfac', class: "PlayerContainer" }, index.h(PlayerAvatar, { key: '86123e3ded6ec5bcd62c5b339809f50b075ba4ab', onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset }), index.h("div", { key: '8e8b8ea0961c5596c3aff7d689431dc39faedd14', class: "PlayerInfo" }, index.h("div", { key: '92d8b6abceea88af846203f2aca7b95e3582e2ab', class: 'CardCell ElevateLevel' }, index.h("span", { key: 'ba74043443ed78fc8e3f34689b7410783e6137c8', class: "PlayerName", title: this.playerElevateLevel.name }, this.playerName || this.playerElevateLevel.name)), index.h("div", { key: '9e84f0ce13a02152e8a347b947ac35623625be9d' }, (((_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.loyaltyPoints) / ((_c = (_b = this.playerElevateLevel) === null || _b === void 0 ? void 0 : _b.nextLevel) === null || _c === void 0 ? void 0 : _c.entryPoints)) * 100, "%"))), index.h("div", { key: '1cd88a2cfefbb2326ac13fdadcf448bac075c316', class: 'PointsRange' }, index.h(PlayerPoints, { key: '21e27273e2e43b672b55fa13997e7db109be8070', loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), index.h("span", { key: '329844014f55bbd8bf35bff81626da66c0c9b91a' }, "/"), index.h(PlayerPoints, { key: 'e8cac4c5e5d6bd8f0da9d6c0de84dce36110a747', loyaltyPoints: this.getNextLevelPoints(), language: this.language }))), index.h("div", { key: '1051f633025bc516201dc1861b8404d5c9f6713b', class: `LevelInfo ${this.playerElevateLevel.name}` }, index.h(PlayerLoyaltyProcess, { key: 'b5cb209cfca2166b7848b3196067d9c39259f1ae' }), index.h("div", { key: 'd9820322d3087e8eebfc238f1668f4c11fdaef57', class: "Row LevelRange" }, index.h("div", { key: '36b14cfcf0a7d428da82557c4f96a3db45a6d454' }, this.playerElevateLevel.name), index.h("div", { key: '61c6d3ba379d5ec1184f46d5e6d782d3a196fcf2' }, this.playerElevateLevel.nextLevel.name)), index.h("div", { key: '5bb2a4994885b38df7882cdf7c5a738e14bccef0', class: "NextLevelTip" }, this.getNextLevelTips()), this.pointExpireString && (index.h("div", { key: 'f2ac7fc7a633d312e6aa355e8faaabadf43e6984', class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), this.playerElevateLevel.expireTime &&
3331
+ index.h(LoyaltyLevelExpireDay, { key: 'a75969ed01f62def9c66a4c9b42c8e884b3f819b', expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat, language: this.language })))))))));
3332
+ }
3333
+ static get watchers() { return {
3334
+ "session": ["onSessionOrEndpointChange"],
3335
+ "endpoint": ["onSessionOrEndpointChange"],
3336
+ "language": ["onSessionOrEndpointChange"]
3337
+ }; }
3338
+ };
3339
+ PlayerElevateLoyaltycardJojogroup.style = PlayerElevateLoyaltycardJojogroupStyle0;
3340
+
3341
+ const playerElevatePointcardCss = ":host{display:block}.PointsCard .Inner .Row .ExpirationPoints{text-align:left}.PointsCard .Inner .PlayerAvatar .Avatar{display:none}.PointsCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%;position:inherit}.PointsCard .Inner .PointsTxt{display:flex;flex-direction:row;justify-content:space-between}.PointsCard .Inner .DetailButton{background:linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%), linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));border-radius:5px;box-shadow:0px 4px 4px 0px rgba(0, 0, 0, 0.25);border:2px solid;font-size:11px;width:108px;padding:4px;cursor:pointer;margin-top:5px;height:16px;min-width:45px;text-align:center}.PointsCard .Inner .DetailButton span{color:var(--emw--color-gray-150, #6D6D6D)}.PointsCard .Inner .DetailButton span{display:inline-block;vertical-align:middle}.PointsCard .Inner .DetailButton:hover span{color:var(--emw--color-gray-150, #6D6D6D)}.PointsCard .Inner .LevelInfo{gap:15px;width:70%}.PointsCard .Inner .LevelInfo .PointsTxt{font-size:15px}.PointsCard .Inner .LevelInfo .PointsTxt.Label{display:none}.PointsCard .Inner .LevelInfo .PointsTxt.SPPoints{padding-top:15px}.PointsCard .Inner .LevelInfo .PointsTxt .TC{font-size:x-small;color:var(--emw--color-gray-300, #58586B);display:flex;align-content:center;height:100%;flex-wrap:wrap;text-decoration:underline;cursor:pointer;display:none}";
3342
+ const PlayerElevatePointcardStyle0 = playerElevatePointcardCss;
3343
+
3344
+ const PlayerElevatePointcard = class {
3345
+ constructor(hostRef) {
3346
+ index.registerInstance(this, hostRef);
3347
+ this.isPointDetailCard = this.buttonType === 'earningRule';
3348
+ this.endpoint = undefined;
3349
+ this.theme = 'Dark';
3350
+ this.session = undefined;
3351
+ this.playerAvatarUrl = undefined;
3352
+ this.language = 'en';
3353
+ this.mbSource = undefined;
3354
+ this.playerName = undefined;
3355
+ this.cardTitle = undefined;
3356
+ this.buttonType = 'earningRule';
3357
+ this.dateFormat = 'yyyy-MM-dd';
3358
+ this.clientStyling = '';
3359
+ this.clientStylingUrl = '';
3360
+ this.translationUrl = '';
3361
+ this.pointExpireString = undefined;
3362
+ this.playerElevateLevel = undefined;
3363
+ this.elevateWalletTotal = undefined;
3364
+ this.elevateSPTotal = undefined;
3365
+ }
3366
+ onSessionOrEndpointChange() {
3367
+ this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
3368
+ }
3369
+ playerElevateLeveLoadedHandler(event) {
3370
+ if (!event.detail) {
3371
+ return;
3372
+ }
3373
+ if (event.detail['elevateLevelWalletTotal']) {
3374
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3375
+ this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
3376
+ }
3377
+ if (event.detail['elevateLevel']) {
3378
+ this.playerElevateLevel = event.detail['elevateLevel'];
3379
+ }
3380
+ if (event.detail['pointExpireString']) {
3381
+ this.pointExpireString = event.detail.pointExpireString;
3382
+ }
3383
+ }
3384
+ onDetailsClick() {
3385
+ window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
3386
+ path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
3387
+ }
3388
+ componentWillLoad() {
3389
+ this.paramProxy = {
3390
+ endpoint: this.endpoint,
3391
+ session: this.session,
3392
+ language: this.language,
3393
+ };
3394
+ }
3395
+ render() {
3396
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
3397
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
3398
+ return (index.h("div", { key: 'a1ed46e501d24f84ea23958d2108a9ad36df3083', class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { key: 'e671bf40a9fa75dbf89e37ca9ca7668ddf1416cf', class: "PointsCard Outer ", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { key: '95d373644d93160714c04abe5056122491e846a4', clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl, mbSource: this.mbSource }), index.h("player-elevate-card-data", { key: '653c503f9689f3d4a99ad59f4c534785210ecd3c', params: this.paramProxy }), index.h("div", { key: '025c5a40e8e75450ac9463182bc3600002a29943', class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, index.h("div", { key: '93c05e87b54c7d05ad0fd4b4878e8e8e2aa25abc', class: 'Content Row' }, this.playerElevateLevel && (index.h(index.Fragment, { key: '3fbc0bb622e07f29f94ffe33c747047c1f709cff' }, index.h("div", { key: '7ab9253f7445bc7f4f2bb26bb52563a23d3ab73e', class: "PlayerImg" }, index.h(PlayerAvatar, { key: '5098ab36b2a33f35e10b3b9e1f2eabfe60e3002d', onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), index.h("div", { key: '2f8e012352460a67a28cdb997a7dc68dbbdaea0b', class: `LevelInfo ${this.playerElevateLevel.name}` }, index.h("div", { key: '679d8edbe69f1cff3f18fe1f6742a13942417876', class: "PointsTxt Label" }, this.cardTitle ? this.cardTitle : translate('spendablePoints', this.language)), index.h("div", { key: 'ca49127c96c3d048015f1687102d8e4da46a76b5', class: 'PointsTxt SPPoints' }, index.h(PlayerPoints, { key: '3a7b03cada8b9629924504972d32ce8c4d573a06', spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), index.h("a", { key: 'cb3bf9415204ef1ee7fe9653deb332d13d235e9b', class: "TC", onClick: () => {
3399
+ this.onDetailsClick();
3400
+ } }, translate('termAndConditions', this.language))), this.pointExpireString && (index.h("div", { key: '3fde19f5524ff6c5db9b23edfb1df6be112313e9', class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
3401
+ }
3402
+ static get watchers() { return {
3403
+ "session": ["onSessionOrEndpointChange"],
3404
+ "endpoint": ["onSessionOrEndpointChange"],
3405
+ "language": ["onSessionOrEndpointChange"]
3406
+ }; }
3407
+ };
3408
+ PlayerElevatePointcard.style = PlayerElevatePointcardStyle0;
3409
+
3410
+ const playerRakebackCardCss = ":host{display:block}@keyframes rotate{from{transform:rotate(360deg)}to{transform:rotate(0deg)}}.RakebackCard{border:2px solid var(--em-color-border-primary, #003E5C);padding:32px;border-radius:var(--emw--border-radius-medium, 12px);overflow:hidden;font-family:inherit}.RakebackCard .RakebackCardContent .RakebackTitle{font-size:var(--emw--font-size-small, 14px);font-weight:var(--emw--font-weight-semibold, 500);color:var(--em-color-text-secondary, #727672)}.RakebackCard .RakebackCardContent .RakebackDetails{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;margin-top:17px}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackInfo{display:flex;flex-wrap:wrap;align-items:center;gap:0 17px}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackInfo .RakebackRefresh{width:52px;height:52px;cursor:pointer}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackInfo .RakebackRefresh.RakebackLoading{animation:rotate 0.5s linear infinite}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackInfo .RakebackNumContainer{color:var(--em-color-text-primary, #fff);display:flex;align-items:center;gap:8px}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackInfo .RakebackNumContainer .RakebackNum{display:inline-block;font-weight:var(--emw--font-weight-bold, 700);font-size:var(--emw--font-size-2x-large, 36px)}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackInfo .RakebackNumContainer .RakebackCurrency{display:inline-block;font-weight:var(--emw--font-weight-semibold, 500);font-size:var(--emw--font-size-small, 14px);margin-top:14px}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackButton{font-family:inherit;cursor:pointer;width:90px;height:34px;border-radius:var(--emw--border-radius-large, 99px);border:2px solid var(--em-color-border-success, #083B17);display:flex;justify-content:center;align-items:center;color:var(--em-color-text-primary, #fff);background:linear-gradient(180deg, var(--em-color-gradient-1, #24B24E) 0%, var(--em-color-gradient-1, #24B24E) 100%)}.RakebackCard .RakebackCardContent .RakebackDetails .RakebackButton.disabled{cursor:not-allowed;opacity:0.4}.RakebackCard .RakebackCardContent .RakebackCoolOff,.RakebackCard .RakebackCardContent .RakebackError{margin-top:8px;font-weight:var(--emw--font-weight-semibold, 500);font-size:var(--emw--font-size-x-small, 12px);color:var(--em-color-text-error, #FF7A73);text-align:center}";
3411
+ const PlayerRakebackCardStyle0 = playerRakebackCardCss;
3412
+
3413
+ const PlayerRakebackCard = class {
3414
+ constructor(hostRef) {
3415
+ index.registerInstance(this, hostRef);
3416
+ /**
3417
+ * Truncate number to specified decimal places (without rounding)
3418
+ * @param num Number to be processed
3419
+ * @param digits Number of decimal places to keep
3420
+ */
3421
+ this.truncateNumber = (num, digits = 2) => {
3422
+ const str = num.toString();
3423
+ const [integer, decimal = ''] = str.split('.');
3424
+ return digits > 0 ? `${integer}.${decimal ? decimal.slice(0, digits) : '00'}` : `${integer}`;
3425
+ };
3426
+ this.sendRakebackClaimedEvent = () => {
3427
+ if (!this.endpoint || !this.session || !this.rakebackInfo.claimable || this.isLoading) {
3428
+ return;
3429
+ }
3430
+ window.postMessage({ type: 'RakebackClaimTrigger', points: this.rakebackInfo.points }, window.location.href);
3431
+ };
3432
+ this.endpoint = undefined;
3433
+ this.theme = 'Dark';
3434
+ this.session = undefined;
3435
+ this.language = 'en';
3436
+ this.mbSource = undefined;
3437
+ this.clientStyling = '';
3438
+ this.clientStylingUrl = '';
3439
+ this.translationUrl = '';
3440
+ this.show = true;
3441
+ this.rakebackInfo = {
3442
+ hasRakebackWallet: false,
3443
+ points: 0.0,
3444
+ currency: 'TRY',
3445
+ claimable: false,
3446
+ minutesCanClaim: 0,
3447
+ showCanClaim: false
3448
+ };
3449
+ this.isLoading = false;
3450
+ this.coolingOffPeriod = false;
3451
+ this.showTheWidget = false;
3452
+ }
3453
+ async onSessionOrEndpointChange() {
3454
+ await this.loadRakebackInfo();
3455
+ }
3456
+ async onShowOrHasRakebackWalletChange() {
3457
+ this.showTheWidget = this.show && this.rakebackInfo.hasRakebackWallet;
3458
+ }
3459
+ handleMessage(event) {
3460
+ const { type } = event === null || event === void 0 ? void 0 : event.data;
3461
+ if (type === 'RakebackClaimConfirmed') {
3462
+ this.claimRakeback();
3463
+ }
3464
+ }
3465
+ async loadRakebackInfo() {
3466
+ if (!this.endpoint || !this.session) {
3467
+ return;
3468
+ }
3469
+ this.isLoading = true;
3470
+ try {
3471
+ const url = new URL(`${this.endpoint}/v1/elevate/playerInfo?language=${this.language}`);
3472
+ const response = await fetch(url.href, {
3473
+ method: 'GET',
3474
+ headers: {
3475
+ 'X-Sessionid': this.session,
3476
+ 'Content-Type': 'application/json'
3477
+ }
3478
+ });
3479
+ if (!response.ok) {
3480
+ throw new Error(`HTTP error! status: ${response.status}`);
3481
+ }
3482
+ const data = await response.json();
3483
+ if (!data.success) {
3484
+ throw new Error(data.errorMessage || 'Failed to load rakeback info');
3485
+ }
3486
+ const { rakebackWallet } = data === null || data === void 0 ? void 0 : data.data;
3487
+ if (!rakebackWallet) {
3488
+ window.postMessage({ type: 'RakebackWalletMissing' }, window.location.href);
3489
+ return;
3490
+ }
3491
+ const { total, claimable, currency, minutesCanClaim } = rakebackWallet || {};
3492
+ this.rakebackInfo = {
3493
+ hasRakebackWallet: true,
3494
+ points: (total === null || total === void 0 ? void 0 : total.points) ? this.truncateNumber(total.points, 2) : `0.00`,
3495
+ currency: currency || '',
3496
+ claimable: claimable || false,
3497
+ showCanClaim: Boolean(minutesCanClaim && minutesCanClaim > 0),
3498
+ minutesCanClaim: minutesCanClaim
3499
+ ? minutesCanClaim <= 1 && minutesCanClaim > 0
3500
+ ? 1
3501
+ : this.truncateNumber(minutesCanClaim, 0)
3502
+ : 0
3503
+ };
3504
+ }
3505
+ catch (err) {
3506
+ console.error('Error loading rakeback info:', err);
3507
+ window.postMessage({ type: 'RakebackClaimError', message: err.message }, window.location.href);
3508
+ }
3509
+ finally {
3510
+ this.isLoading = false;
3511
+ }
3512
+ }
3513
+ async claimRakeback() {
3514
+ this.isLoading = true;
3515
+ try {
3516
+ const url = new URL(`${this.endpoint}/v1/elevate/rakeback/claim`);
3517
+ const response = await fetch(url.href, {
3518
+ method: 'PUT',
3519
+ headers: {
3520
+ 'X-Sessionid': this.session,
3521
+ 'Content-Type': 'application/json'
3522
+ },
3523
+ body: JSON.stringify({})
3524
+ });
3525
+ if (!response.ok) {
3526
+ throw new Error(`HTTP error! status: ${response.status}`);
3527
+ }
3528
+ const data = await response.json();
3529
+ if (!data.success) {
3530
+ throw new Error(data.errorMessage || 'Failed to claim rakeback');
3531
+ }
3532
+ // Refresh rakeback information
3533
+ await this.loadRakebackInfo();
3534
+ // Send event notification for successful redemption
3535
+ window.postMessage({ type: 'RakebackClaimed', points: this.rakebackInfo.points }, window.location.href);
3536
+ }
3537
+ catch (err) {
3538
+ console.error('Error claiming rakeback:', err);
3539
+ window.postMessage({ type: 'RakebackClaimError', message: err.message }, window.location.href);
3540
+ }
3541
+ finally {
3542
+ this.isLoading = false;
3543
+ }
3544
+ }
3545
+ async componentWillLoad() {
3546
+ await this.loadRakebackInfo();
3547
+ await this.onShowOrHasRakebackWalletChange();
3548
+ }
3549
+ render() {
3550
+ return this.showTheWidget ? (index.h("div", { class: "RakebackCard" }, index.h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl, mbSource: this.mbSource }), index.h("div", { class: "RakebackCardContent" }, index.h("div", { class: "RakebackTitle" }, translate('rakebackTitle', this.language)), index.h("div", { class: "RakebackDetails" }, index.h("div", { class: "RakebackInfo" }, index.h("div", { class: "RakebackNumContainer" }, index.h("span", { class: "RakebackNum" }, this.rakebackInfo.points), index.h("span", { class: "RakebackCurrency" }, this.rakebackInfo.currency))), index.h("div", { class: `RakebackButton ${this.isLoading || !this.rakebackInfo.claimable ? 'disabled' : ''}`, onClick: this.sendRakebackClaimedEvent }, translate('claim', this.language))), !this.rakebackInfo.claimable && this.rakebackInfo.showCanClaim && (index.h("div", { class: "RakebackCoolOff" }, translateWithParams('minutesCanClaim', {
3551
+ lang: this.language,
3552
+ minutes: this.rakebackInfo.minutesCanClaim
3553
+ })))))) : null;
3554
+ }
3555
+ static get watchers() { return {
3556
+ "session": ["onSessionOrEndpointChange"],
3557
+ "endpoint": ["onSessionOrEndpointChange"],
3558
+ "language": ["onSessionOrEndpointChange"],
3559
+ "show": ["onShowOrHasRakebackWalletChange"],
3560
+ "rakebackInfo": ["onShowOrHasRakebackWalletChange"]
3561
+ }; }
3562
+ };
3563
+ PlayerRakebackCard.style = PlayerRakebackCardStyle0;
3564
+
3565
+ exports.general_styling_wrapper = GeneralStylingWrapper;
3566
+ exports.player_elevate_card_data = PlayerElevateCardData;
3567
+ exports.player_elevate_card_jojogroup = PlayerElevateCardJojogroup;
3568
+ exports.player_elevate_loyaltycard_jojogroup = PlayerElevateLoyaltycardJojogroup;
3569
+ exports.player_elevate_pointcard = PlayerElevatePointcard;
3570
+ exports.player_rakeback_card = PlayerRakebackCard;