@everymatrix/casino-engagement-suite-challenges-list 1.0.69

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 (48) hide show
  1. package/dist/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.esm.js +1 -0
  2. package/dist/casino-engagement-suite-challenges-list/index.esm.js +0 -0
  3. package/dist/casino-engagement-suite-challenges-list/p-7fd72b22.js +2 -0
  4. package/dist/casino-engagement-suite-challenges-list/p-e1255160.js +1 -0
  5. package/dist/casino-engagement-suite-challenges-list/p-e2e9e05e.entry.js +1 -0
  6. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  7. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.js +25 -0
  8. package/dist/cjs/casino-engagement-suite-challenges-list_2.cjs.entry.js +2659 -0
  9. package/dist/cjs/index-97488095.js +1316 -0
  10. package/dist/cjs/index.cjs.js +2 -0
  11. package/dist/cjs/loader.cjs.js +15 -0
  12. package/dist/collection/collection-manifest.json +19 -0
  13. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.css +260 -0
  14. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.js +497 -0
  15. package/dist/collection/components/casino-engagement-suite-challenges-list/index.js +1 -0
  16. package/dist/collection/index.js +1 -0
  17. package/dist/collection/models/challenge.js +30 -0
  18. package/dist/collection/renders/ChallengesHistory.js +48 -0
  19. package/dist/collection/utils/locale.utils.js +17 -0
  20. package/dist/collection/utils/utils.js +3 -0
  21. package/dist/esm/app-globals-0f993ce5.js +3 -0
  22. package/dist/esm/casino-engagement-suite-challenges-list.js +20 -0
  23. package/dist/esm/casino-engagement-suite-challenges-list_2.entry.js +2654 -0
  24. package/dist/esm/index-00eb432b.js +1288 -0
  25. package/dist/esm/index.js +1 -0
  26. package/dist/esm/loader.js +11 -0
  27. package/dist/index.cjs.js +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/stencil.config.dev.js +17 -0
  30. package/dist/stencil.config.js +17 -0
  31. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/casino-engagement-suite-challenges-list/.stencil/packages/stencil/casino-engagement-suite-challenges-list/stencil.config.d.ts +2 -0
  32. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/casino-engagement-suite-challenges-list/.stencil/packages/stencil/casino-engagement-suite-challenges-list/stencil.config.dev.d.ts +2 -0
  33. package/dist/types/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.d.ts +85 -0
  34. package/dist/types/components/casino-engagement-suite-challenges-list/index.d.ts +1 -0
  35. package/dist/types/components.d.ts +121 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/models/challenge.d.ts +91 -0
  38. package/dist/types/renders/ChallengesHistory.d.ts +6 -0
  39. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  40. package/dist/types/utils/locale.utils.d.ts +1 -0
  41. package/dist/types/utils/utils.d.ts +1 -0
  42. package/loader/cdn.js +1 -0
  43. package/loader/index.cjs.js +1 -0
  44. package/loader/index.d.ts +24 -0
  45. package/loader/index.es2017.js +1 -0
  46. package/loader/index.js +2 -0
  47. package/loader/package.json +11 -0
  48. package/package.json +29 -0
@@ -0,0 +1,2659 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-97488095.js');
6
+
7
+ var ChallengeRewardType;
8
+ (function (ChallengeRewardType) {
9
+ ChallengeRewardType[ChallengeRewardType["FreeSpins"] = 0] = "FreeSpins";
10
+ ChallengeRewardType[ChallengeRewardType["LuckyWheel"] = 1] = "LuckyWheel";
11
+ ChallengeRewardType[ChallengeRewardType["Leaderboard"] = 2] = "Leaderboard";
12
+ ChallengeRewardType[ChallengeRewardType["Challenge"] = 3] = "Challenge";
13
+ ChallengeRewardType[ChallengeRewardType["Custom"] = 4] = "Custom";
14
+ })(ChallengeRewardType || (ChallengeRewardType = {}));
15
+ var ChallengeHistoryLevelStatus;
16
+ (function (ChallengeHistoryLevelStatus) {
17
+ ChallengeHistoryLevelStatus[ChallengeHistoryLevelStatus["Completed"] = 0] = "Completed";
18
+ ChallengeHistoryLevelStatus[ChallengeHistoryLevelStatus["Expired"] = 1] = "Expired";
19
+ ChallengeHistoryLevelStatus[ChallengeHistoryLevelStatus["Forfeited"] = 2] = "Forfeited";
20
+ })(ChallengeHistoryLevelStatus || (ChallengeHistoryLevelStatus = {}));
21
+ var ChallengeLevelProgressStatus;
22
+ (function (ChallengeLevelProgressStatus) {
23
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Closed"] = 0] = "Closed";
24
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["InProgress"] = 1] = "InProgress";
25
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Fillup"] = 2] = "Fillup";
26
+ ChallengeLevelProgressStatus[ChallengeLevelProgressStatus["Completed"] = 3] = "Completed";
27
+ })(ChallengeLevelProgressStatus || (ChallengeLevelProgressStatus = {}));
28
+ var ChallengeProgressStatus;
29
+ (function (ChallengeProgressStatus) {
30
+ ChallengeProgressStatus[ChallengeProgressStatus["Started"] = 0] = "Started";
31
+ ChallengeProgressStatus[ChallengeProgressStatus["InProgress"] = 1] = "InProgress";
32
+ ChallengeProgressStatus[ChallengeProgressStatus["PendingLevelReward"] = 2] = "PendingLevelReward";
33
+ ChallengeProgressStatus[ChallengeProgressStatus["Completed"] = 3] = "Completed";
34
+ ChallengeProgressStatus[ChallengeProgressStatus["Expired"] = 4] = "Expired";
35
+ ChallengeProgressStatus[ChallengeProgressStatus["Forfeited"] = 5] = "Forfeited";
36
+ })(ChallengeProgressStatus || (ChallengeProgressStatus = {}));
37
+
38
+ const DEFAULT_LANGUAGE = 'en';
39
+ const SUPPORTED_LANGUAGES = ['en'];
40
+ const TRANSLATIONS = {
41
+ en: {
42
+ challenges: 'Challenges',
43
+ join: 'Join',
44
+ unjoin: 'Unjoin',
45
+ new: 'new',
46
+ noChallenges: 'No Challenges yet',
47
+ tryOtherGames: 'Try winning Challenges as rewards or launching other booster games',
48
+ tooltip: 'Competition where your real money bets contribute towards the level progress to achieve the level reward'
49
+ }
50
+ };
51
+ const translate = (key, customLang) => {
52
+ const lang = customLang;
53
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
54
+ };
55
+
56
+ function _typeof(o) {
57
+ "@babel/helpers - typeof";
58
+
59
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
60
+ return typeof o;
61
+ } : function (o) {
62
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
63
+ }, _typeof(o);
64
+ }
65
+
66
+ function toInteger(dirtyNumber) {
67
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
68
+ return NaN;
69
+ }
70
+ var number = Number(dirtyNumber);
71
+ if (isNaN(number)) {
72
+ return number;
73
+ }
74
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
75
+ }
76
+
77
+ function requiredArgs(required, args) {
78
+ if (args.length < required) {
79
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
80
+ }
81
+ }
82
+
83
+ /**
84
+ * @name toDate
85
+ * @category Common Helpers
86
+ * @summary Convert the given argument to an instance of Date.
87
+ *
88
+ * @description
89
+ * Convert the given argument to an instance of Date.
90
+ *
91
+ * If the argument is an instance of Date, the function returns its clone.
92
+ *
93
+ * If the argument is a number, it is treated as a timestamp.
94
+ *
95
+ * If the argument is none of the above, the function returns Invalid Date.
96
+ *
97
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
98
+ *
99
+ * @param {Date|Number} argument - the value to convert
100
+ * @returns {Date} the parsed date in the local time zone
101
+ * @throws {TypeError} 1 argument required
102
+ *
103
+ * @example
104
+ * // Clone the date:
105
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
106
+ * //=> Tue Feb 11 2014 11:30:30
107
+ *
108
+ * @example
109
+ * // Convert the timestamp to date:
110
+ * const result = toDate(1392098430000)
111
+ * //=> Tue Feb 11 2014 11:30:30
112
+ */
113
+ function toDate(argument) {
114
+ requiredArgs(1, arguments);
115
+ var argStr = Object.prototype.toString.call(argument);
116
+
117
+ // Clone the date
118
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
119
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
120
+ return new Date(argument.getTime());
121
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
122
+ return new Date(argument);
123
+ } else {
124
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
125
+ // eslint-disable-next-line no-console
126
+ 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");
127
+ // eslint-disable-next-line no-console
128
+ console.warn(new Error().stack);
129
+ }
130
+ return new Date(NaN);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @name addMilliseconds
136
+ * @category Millisecond Helpers
137
+ * @summary Add the specified number of milliseconds to the given date.
138
+ *
139
+ * @description
140
+ * Add the specified number of milliseconds to the given date.
141
+ *
142
+ * @param {Date|Number} date - the date to be changed
143
+ * @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`.
144
+ * @returns {Date} the new date with the milliseconds added
145
+ * @throws {TypeError} 2 arguments required
146
+ *
147
+ * @example
148
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
149
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
150
+ * //=> Thu Jul 10 2014 12:45:30.750
151
+ */
152
+ function addMilliseconds(dirtyDate, dirtyAmount) {
153
+ requiredArgs(2, arguments);
154
+ var timestamp = toDate(dirtyDate).getTime();
155
+ var amount = toInteger(dirtyAmount);
156
+ return new Date(timestamp + amount);
157
+ }
158
+
159
+ var defaultOptions = {};
160
+ function getDefaultOptions() {
161
+ return defaultOptions;
162
+ }
163
+
164
+ /**
165
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
166
+ * They usually appear for dates that denote time before the timezones were introduced
167
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
168
+ * and GMT+01:00:00 after that date)
169
+ *
170
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
171
+ * which would lead to incorrect calculations.
172
+ *
173
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
174
+ */
175
+ function getTimezoneOffsetInMilliseconds(date) {
176
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
177
+ utcDate.setUTCFullYear(date.getFullYear());
178
+ return date.getTime() - utcDate.getTime();
179
+ }
180
+
181
+ /**
182
+ * @name isDate
183
+ * @category Common Helpers
184
+ * @summary Is the given value a date?
185
+ *
186
+ * @description
187
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
188
+ *
189
+ * @param {*} value - the value to check
190
+ * @returns {boolean} true if the given value is a date
191
+ * @throws {TypeError} 1 arguments required
192
+ *
193
+ * @example
194
+ * // For a valid date:
195
+ * const result = isDate(new Date())
196
+ * //=> true
197
+ *
198
+ * @example
199
+ * // For an invalid date:
200
+ * const result = isDate(new Date(NaN))
201
+ * //=> true
202
+ *
203
+ * @example
204
+ * // For some value:
205
+ * const result = isDate('2014-02-31')
206
+ * //=> false
207
+ *
208
+ * @example
209
+ * // For an object:
210
+ * const result = isDate({})
211
+ * //=> false
212
+ */
213
+ function isDate(value) {
214
+ requiredArgs(1, arguments);
215
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
216
+ }
217
+
218
+ /**
219
+ * @name isValid
220
+ * @category Common Helpers
221
+ * @summary Is the given date valid?
222
+ *
223
+ * @description
224
+ * Returns false if argument is Invalid Date and true otherwise.
225
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
226
+ * Invalid Date is a Date, whose time value is NaN.
227
+ *
228
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
229
+ *
230
+ * @param {*} date - the date to check
231
+ * @returns {Boolean} the date is valid
232
+ * @throws {TypeError} 1 argument required
233
+ *
234
+ * @example
235
+ * // For the valid date:
236
+ * const result = isValid(new Date(2014, 1, 31))
237
+ * //=> true
238
+ *
239
+ * @example
240
+ * // For the value, convertable into a date:
241
+ * const result = isValid(1393804800000)
242
+ * //=> true
243
+ *
244
+ * @example
245
+ * // For the invalid date:
246
+ * const result = isValid(new Date(''))
247
+ * //=> false
248
+ */
249
+ function isValid(dirtyDate) {
250
+ requiredArgs(1, arguments);
251
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
252
+ return false;
253
+ }
254
+ var date = toDate(dirtyDate);
255
+ return !isNaN(Number(date));
256
+ }
257
+
258
+ /**
259
+ * @name subMilliseconds
260
+ * @category Millisecond Helpers
261
+ * @summary Subtract the specified number of milliseconds from the given date.
262
+ *
263
+ * @description
264
+ * Subtract the specified number of milliseconds from the given date.
265
+ *
266
+ * @param {Date|Number} date - the date to be changed
267
+ * @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`.
268
+ * @returns {Date} the new date with the milliseconds subtracted
269
+ * @throws {TypeError} 2 arguments required
270
+ *
271
+ * @example
272
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
273
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
274
+ * //=> Thu Jul 10 2014 12:45:29.250
275
+ */
276
+ function subMilliseconds(dirtyDate, dirtyAmount) {
277
+ requiredArgs(2, arguments);
278
+ var amount = toInteger(dirtyAmount);
279
+ return addMilliseconds(dirtyDate, -amount);
280
+ }
281
+
282
+ var MILLISECONDS_IN_DAY = 86400000;
283
+ function getUTCDayOfYear(dirtyDate) {
284
+ requiredArgs(1, arguments);
285
+ var date = toDate(dirtyDate);
286
+ var timestamp = date.getTime();
287
+ date.setUTCMonth(0, 1);
288
+ date.setUTCHours(0, 0, 0, 0);
289
+ var startOfYearTimestamp = date.getTime();
290
+ var difference = timestamp - startOfYearTimestamp;
291
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
292
+ }
293
+
294
+ function startOfUTCISOWeek(dirtyDate) {
295
+ requiredArgs(1, arguments);
296
+ var weekStartsOn = 1;
297
+ var date = toDate(dirtyDate);
298
+ var day = date.getUTCDay();
299
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
300
+ date.setUTCDate(date.getUTCDate() - diff);
301
+ date.setUTCHours(0, 0, 0, 0);
302
+ return date;
303
+ }
304
+
305
+ function getUTCISOWeekYear(dirtyDate) {
306
+ requiredArgs(1, arguments);
307
+ var date = toDate(dirtyDate);
308
+ var year = date.getUTCFullYear();
309
+ var fourthOfJanuaryOfNextYear = new Date(0);
310
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
311
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
312
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
313
+ var fourthOfJanuaryOfThisYear = new Date(0);
314
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
315
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
316
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
317
+ if (date.getTime() >= startOfNextYear.getTime()) {
318
+ return year + 1;
319
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
320
+ return year;
321
+ } else {
322
+ return year - 1;
323
+ }
324
+ }
325
+
326
+ function startOfUTCISOWeekYear(dirtyDate) {
327
+ requiredArgs(1, arguments);
328
+ var year = getUTCISOWeekYear(dirtyDate);
329
+ var fourthOfJanuary = new Date(0);
330
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
331
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
332
+ var date = startOfUTCISOWeek(fourthOfJanuary);
333
+ return date;
334
+ }
335
+
336
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
337
+ function getUTCISOWeek(dirtyDate) {
338
+ requiredArgs(1, arguments);
339
+ var date = toDate(dirtyDate);
340
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
341
+
342
+ // Round the number of days to the nearest integer
343
+ // because the number of milliseconds in a week is not constant
344
+ // (e.g. it's different in the week of the daylight saving time clock shift)
345
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
346
+ }
347
+
348
+ function startOfUTCWeek(dirtyDate, options) {
349
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
350
+ requiredArgs(1, arguments);
351
+ var defaultOptions = getDefaultOptions();
352
+ 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);
353
+
354
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
355
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
356
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
357
+ }
358
+ var date = toDate(dirtyDate);
359
+ var day = date.getUTCDay();
360
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
361
+ date.setUTCDate(date.getUTCDate() - diff);
362
+ date.setUTCHours(0, 0, 0, 0);
363
+ return date;
364
+ }
365
+
366
+ function getUTCWeekYear(dirtyDate, options) {
367
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
368
+ requiredArgs(1, arguments);
369
+ var date = toDate(dirtyDate);
370
+ var year = date.getUTCFullYear();
371
+ var defaultOptions = getDefaultOptions();
372
+ 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);
373
+
374
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
375
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
376
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
377
+ }
378
+ var firstWeekOfNextYear = new Date(0);
379
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
380
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
381
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
382
+ var firstWeekOfThisYear = new Date(0);
383
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
384
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
385
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
386
+ if (date.getTime() >= startOfNextYear.getTime()) {
387
+ return year + 1;
388
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
389
+ return year;
390
+ } else {
391
+ return year - 1;
392
+ }
393
+ }
394
+
395
+ function startOfUTCWeekYear(dirtyDate, options) {
396
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
397
+ requiredArgs(1, arguments);
398
+ var defaultOptions = getDefaultOptions();
399
+ 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);
400
+ var year = getUTCWeekYear(dirtyDate, options);
401
+ var firstWeek = new Date(0);
402
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
403
+ firstWeek.setUTCHours(0, 0, 0, 0);
404
+ var date = startOfUTCWeek(firstWeek, options);
405
+ return date;
406
+ }
407
+
408
+ var MILLISECONDS_IN_WEEK = 604800000;
409
+ function getUTCWeek(dirtyDate, options) {
410
+ requiredArgs(1, arguments);
411
+ var date = toDate(dirtyDate);
412
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
413
+
414
+ // Round the number of days to the nearest integer
415
+ // because the number of milliseconds in a week is not constant
416
+ // (e.g. it's different in the week of the daylight saving time clock shift)
417
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
418
+ }
419
+
420
+ function addLeadingZeros(number, targetLength) {
421
+ var sign = number < 0 ? '-' : '';
422
+ var output = Math.abs(number).toString();
423
+ while (output.length < targetLength) {
424
+ output = '0' + output;
425
+ }
426
+ return sign + output;
427
+ }
428
+
429
+ /*
430
+ * | | Unit | | Unit |
431
+ * |-----|--------------------------------|-----|--------------------------------|
432
+ * | a | AM, PM | A* | |
433
+ * | d | Day of month | D | |
434
+ * | h | Hour [1-12] | H | Hour [0-23] |
435
+ * | m | Minute | M | Month |
436
+ * | s | Second | S | Fraction of second |
437
+ * | y | Year (abs) | Y | |
438
+ *
439
+ * Letters marked by * are not implemented but reserved by Unicode standard.
440
+ */
441
+ var formatters$2 = {
442
+ // Year
443
+ y: function y(date, token) {
444
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
445
+ // | Year | y | yy | yyy | yyyy | yyyyy |
446
+ // |----------|-------|----|-------|-------|-------|
447
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
448
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
449
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
450
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
451
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
452
+
453
+ var signedYear = date.getUTCFullYear();
454
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
455
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
456
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
457
+ },
458
+ // Month
459
+ M: function M(date, token) {
460
+ var month = date.getUTCMonth();
461
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
462
+ },
463
+ // Day of the month
464
+ d: function d(date, token) {
465
+ return addLeadingZeros(date.getUTCDate(), token.length);
466
+ },
467
+ // AM or PM
468
+ a: function a(date, token) {
469
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
470
+ switch (token) {
471
+ case 'a':
472
+ case 'aa':
473
+ return dayPeriodEnumValue.toUpperCase();
474
+ case 'aaa':
475
+ return dayPeriodEnumValue;
476
+ case 'aaaaa':
477
+ return dayPeriodEnumValue[0];
478
+ case 'aaaa':
479
+ default:
480
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
481
+ }
482
+ },
483
+ // Hour [1-12]
484
+ h: function h(date, token) {
485
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
486
+ },
487
+ // Hour [0-23]
488
+ H: function H(date, token) {
489
+ return addLeadingZeros(date.getUTCHours(), token.length);
490
+ },
491
+ // Minute
492
+ m: function m(date, token) {
493
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
494
+ },
495
+ // Second
496
+ s: function s(date, token) {
497
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
498
+ },
499
+ // Fraction of second
500
+ S: function S(date, token) {
501
+ var numberOfDigits = token.length;
502
+ var milliseconds = date.getUTCMilliseconds();
503
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
504
+ return addLeadingZeros(fractionalSeconds, token.length);
505
+ }
506
+ };
507
+ const formatters$3 = formatters$2;
508
+
509
+ var dayPeriodEnum = {
510
+ am: 'am',
511
+ pm: 'pm',
512
+ midnight: 'midnight',
513
+ noon: 'noon',
514
+ morning: 'morning',
515
+ afternoon: 'afternoon',
516
+ evening: 'evening',
517
+ night: 'night'
518
+ };
519
+ /*
520
+ * | | Unit | | Unit |
521
+ * |-----|--------------------------------|-----|--------------------------------|
522
+ * | a | AM, PM | A* | Milliseconds in day |
523
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
524
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
525
+ * | d | Day of month | D | Day of year |
526
+ * | e | Local day of week | E | Day of week |
527
+ * | f | | F* | Day of week in month |
528
+ * | g* | Modified Julian day | G | Era |
529
+ * | h | Hour [1-12] | H | Hour [0-23] |
530
+ * | i! | ISO day of week | I! | ISO week of year |
531
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
532
+ * | k | Hour [1-24] | K | Hour [0-11] |
533
+ * | l* | (deprecated) | L | Stand-alone month |
534
+ * | m | Minute | M | Month |
535
+ * | n | | N | |
536
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
537
+ * | p! | Long localized time | P! | Long localized date |
538
+ * | q | Stand-alone quarter | Q | Quarter |
539
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
540
+ * | s | Second | S | Fraction of second |
541
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
542
+ * | u | Extended year | U* | Cyclic year |
543
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
544
+ * | w | Local week of year | W* | Week of month |
545
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
546
+ * | y | Year (abs) | Y | Local week-numbering year |
547
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
548
+ *
549
+ * Letters marked by * are not implemented but reserved by Unicode standard.
550
+ *
551
+ * Letters marked by ! are non-standard, but implemented by date-fns:
552
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
553
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
554
+ * i.e. 7 for Sunday, 1 for Monday, etc.
555
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
556
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
557
+ * `R` is supposed to be used in conjunction with `I` and `i`
558
+ * for universal ISO week-numbering date, whereas
559
+ * `Y` is supposed to be used in conjunction with `w` and `e`
560
+ * for week-numbering date specific to the locale.
561
+ * - `P` is long localized date format
562
+ * - `p` is long localized time format
563
+ */
564
+
565
+ var formatters = {
566
+ // Era
567
+ G: function G(date, token, localize) {
568
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
569
+ switch (token) {
570
+ // AD, BC
571
+ case 'G':
572
+ case 'GG':
573
+ case 'GGG':
574
+ return localize.era(era, {
575
+ width: 'abbreviated'
576
+ });
577
+ // A, B
578
+ case 'GGGGG':
579
+ return localize.era(era, {
580
+ width: 'narrow'
581
+ });
582
+ // Anno Domini, Before Christ
583
+ case 'GGGG':
584
+ default:
585
+ return localize.era(era, {
586
+ width: 'wide'
587
+ });
588
+ }
589
+ },
590
+ // Year
591
+ y: function y(date, token, localize) {
592
+ // Ordinal number
593
+ if (token === 'yo') {
594
+ var signedYear = date.getUTCFullYear();
595
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
596
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
597
+ return localize.ordinalNumber(year, {
598
+ unit: 'year'
599
+ });
600
+ }
601
+ return formatters$3.y(date, token);
602
+ },
603
+ // Local week-numbering year
604
+ Y: function Y(date, token, localize, options) {
605
+ var signedWeekYear = getUTCWeekYear(date, options);
606
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
607
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
608
+
609
+ // Two digit year
610
+ if (token === 'YY') {
611
+ var twoDigitYear = weekYear % 100;
612
+ return addLeadingZeros(twoDigitYear, 2);
613
+ }
614
+
615
+ // Ordinal number
616
+ if (token === 'Yo') {
617
+ return localize.ordinalNumber(weekYear, {
618
+ unit: 'year'
619
+ });
620
+ }
621
+
622
+ // Padding
623
+ return addLeadingZeros(weekYear, token.length);
624
+ },
625
+ // ISO week-numbering year
626
+ R: function R(date, token) {
627
+ var isoWeekYear = getUTCISOWeekYear(date);
628
+
629
+ // Padding
630
+ return addLeadingZeros(isoWeekYear, token.length);
631
+ },
632
+ // Extended year. This is a single number designating the year of this calendar system.
633
+ // The main difference between `y` and `u` localizers are B.C. years:
634
+ // | Year | `y` | `u` |
635
+ // |------|-----|-----|
636
+ // | AC 1 | 1 | 1 |
637
+ // | BC 1 | 1 | 0 |
638
+ // | BC 2 | 2 | -1 |
639
+ // Also `yy` always returns the last two digits of a year,
640
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
641
+ u: function u(date, token) {
642
+ var year = date.getUTCFullYear();
643
+ return addLeadingZeros(year, token.length);
644
+ },
645
+ // Quarter
646
+ Q: function Q(date, token, localize) {
647
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
648
+ switch (token) {
649
+ // 1, 2, 3, 4
650
+ case 'Q':
651
+ return String(quarter);
652
+ // 01, 02, 03, 04
653
+ case 'QQ':
654
+ return addLeadingZeros(quarter, 2);
655
+ // 1st, 2nd, 3rd, 4th
656
+ case 'Qo':
657
+ return localize.ordinalNumber(quarter, {
658
+ unit: 'quarter'
659
+ });
660
+ // Q1, Q2, Q3, Q4
661
+ case 'QQQ':
662
+ return localize.quarter(quarter, {
663
+ width: 'abbreviated',
664
+ context: 'formatting'
665
+ });
666
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
667
+ case 'QQQQQ':
668
+ return localize.quarter(quarter, {
669
+ width: 'narrow',
670
+ context: 'formatting'
671
+ });
672
+ // 1st quarter, 2nd quarter, ...
673
+ case 'QQQQ':
674
+ default:
675
+ return localize.quarter(quarter, {
676
+ width: 'wide',
677
+ context: 'formatting'
678
+ });
679
+ }
680
+ },
681
+ // Stand-alone quarter
682
+ q: function q(date, token, localize) {
683
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
684
+ switch (token) {
685
+ // 1, 2, 3, 4
686
+ case 'q':
687
+ return String(quarter);
688
+ // 01, 02, 03, 04
689
+ case 'qq':
690
+ return addLeadingZeros(quarter, 2);
691
+ // 1st, 2nd, 3rd, 4th
692
+ case 'qo':
693
+ return localize.ordinalNumber(quarter, {
694
+ unit: 'quarter'
695
+ });
696
+ // Q1, Q2, Q3, Q4
697
+ case 'qqq':
698
+ return localize.quarter(quarter, {
699
+ width: 'abbreviated',
700
+ context: 'standalone'
701
+ });
702
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
703
+ case 'qqqqq':
704
+ return localize.quarter(quarter, {
705
+ width: 'narrow',
706
+ context: 'standalone'
707
+ });
708
+ // 1st quarter, 2nd quarter, ...
709
+ case 'qqqq':
710
+ default:
711
+ return localize.quarter(quarter, {
712
+ width: 'wide',
713
+ context: 'standalone'
714
+ });
715
+ }
716
+ },
717
+ // Month
718
+ M: function M(date, token, localize) {
719
+ var month = date.getUTCMonth();
720
+ switch (token) {
721
+ case 'M':
722
+ case 'MM':
723
+ return formatters$3.M(date, token);
724
+ // 1st, 2nd, ..., 12th
725
+ case 'Mo':
726
+ return localize.ordinalNumber(month + 1, {
727
+ unit: 'month'
728
+ });
729
+ // Jan, Feb, ..., Dec
730
+ case 'MMM':
731
+ return localize.month(month, {
732
+ width: 'abbreviated',
733
+ context: 'formatting'
734
+ });
735
+ // J, F, ..., D
736
+ case 'MMMMM':
737
+ return localize.month(month, {
738
+ width: 'narrow',
739
+ context: 'formatting'
740
+ });
741
+ // January, February, ..., December
742
+ case 'MMMM':
743
+ default:
744
+ return localize.month(month, {
745
+ width: 'wide',
746
+ context: 'formatting'
747
+ });
748
+ }
749
+ },
750
+ // Stand-alone month
751
+ L: function L(date, token, localize) {
752
+ var month = date.getUTCMonth();
753
+ switch (token) {
754
+ // 1, 2, ..., 12
755
+ case 'L':
756
+ return String(month + 1);
757
+ // 01, 02, ..., 12
758
+ case 'LL':
759
+ return addLeadingZeros(month + 1, 2);
760
+ // 1st, 2nd, ..., 12th
761
+ case 'Lo':
762
+ return localize.ordinalNumber(month + 1, {
763
+ unit: 'month'
764
+ });
765
+ // Jan, Feb, ..., Dec
766
+ case 'LLL':
767
+ return localize.month(month, {
768
+ width: 'abbreviated',
769
+ context: 'standalone'
770
+ });
771
+ // J, F, ..., D
772
+ case 'LLLLL':
773
+ return localize.month(month, {
774
+ width: 'narrow',
775
+ context: 'standalone'
776
+ });
777
+ // January, February, ..., December
778
+ case 'LLLL':
779
+ default:
780
+ return localize.month(month, {
781
+ width: 'wide',
782
+ context: 'standalone'
783
+ });
784
+ }
785
+ },
786
+ // Local week of year
787
+ w: function w(date, token, localize, options) {
788
+ var week = getUTCWeek(date, options);
789
+ if (token === 'wo') {
790
+ return localize.ordinalNumber(week, {
791
+ unit: 'week'
792
+ });
793
+ }
794
+ return addLeadingZeros(week, token.length);
795
+ },
796
+ // ISO week of year
797
+ I: function I(date, token, localize) {
798
+ var isoWeek = getUTCISOWeek(date);
799
+ if (token === 'Io') {
800
+ return localize.ordinalNumber(isoWeek, {
801
+ unit: 'week'
802
+ });
803
+ }
804
+ return addLeadingZeros(isoWeek, token.length);
805
+ },
806
+ // Day of the month
807
+ d: function d(date, token, localize) {
808
+ if (token === 'do') {
809
+ return localize.ordinalNumber(date.getUTCDate(), {
810
+ unit: 'date'
811
+ });
812
+ }
813
+ return formatters$3.d(date, token);
814
+ },
815
+ // Day of year
816
+ D: function D(date, token, localize) {
817
+ var dayOfYear = getUTCDayOfYear(date);
818
+ if (token === 'Do') {
819
+ return localize.ordinalNumber(dayOfYear, {
820
+ unit: 'dayOfYear'
821
+ });
822
+ }
823
+ return addLeadingZeros(dayOfYear, token.length);
824
+ },
825
+ // Day of week
826
+ E: function E(date, token, localize) {
827
+ var dayOfWeek = date.getUTCDay();
828
+ switch (token) {
829
+ // Tue
830
+ case 'E':
831
+ case 'EE':
832
+ case 'EEE':
833
+ return localize.day(dayOfWeek, {
834
+ width: 'abbreviated',
835
+ context: 'formatting'
836
+ });
837
+ // T
838
+ case 'EEEEE':
839
+ return localize.day(dayOfWeek, {
840
+ width: 'narrow',
841
+ context: 'formatting'
842
+ });
843
+ // Tu
844
+ case 'EEEEEE':
845
+ return localize.day(dayOfWeek, {
846
+ width: 'short',
847
+ context: 'formatting'
848
+ });
849
+ // Tuesday
850
+ case 'EEEE':
851
+ default:
852
+ return localize.day(dayOfWeek, {
853
+ width: 'wide',
854
+ context: 'formatting'
855
+ });
856
+ }
857
+ },
858
+ // Local day of week
859
+ e: function e(date, token, localize, options) {
860
+ var dayOfWeek = date.getUTCDay();
861
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
862
+ switch (token) {
863
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
864
+ case 'e':
865
+ return String(localDayOfWeek);
866
+ // Padded numerical value
867
+ case 'ee':
868
+ return addLeadingZeros(localDayOfWeek, 2);
869
+ // 1st, 2nd, ..., 7th
870
+ case 'eo':
871
+ return localize.ordinalNumber(localDayOfWeek, {
872
+ unit: 'day'
873
+ });
874
+ case 'eee':
875
+ return localize.day(dayOfWeek, {
876
+ width: 'abbreviated',
877
+ context: 'formatting'
878
+ });
879
+ // T
880
+ case 'eeeee':
881
+ return localize.day(dayOfWeek, {
882
+ width: 'narrow',
883
+ context: 'formatting'
884
+ });
885
+ // Tu
886
+ case 'eeeeee':
887
+ return localize.day(dayOfWeek, {
888
+ width: 'short',
889
+ context: 'formatting'
890
+ });
891
+ // Tuesday
892
+ case 'eeee':
893
+ default:
894
+ return localize.day(dayOfWeek, {
895
+ width: 'wide',
896
+ context: 'formatting'
897
+ });
898
+ }
899
+ },
900
+ // Stand-alone local day of week
901
+ c: function c(date, token, localize, options) {
902
+ var dayOfWeek = date.getUTCDay();
903
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
904
+ switch (token) {
905
+ // Numerical value (same as in `e`)
906
+ case 'c':
907
+ return String(localDayOfWeek);
908
+ // Padded numerical value
909
+ case 'cc':
910
+ return addLeadingZeros(localDayOfWeek, token.length);
911
+ // 1st, 2nd, ..., 7th
912
+ case 'co':
913
+ return localize.ordinalNumber(localDayOfWeek, {
914
+ unit: 'day'
915
+ });
916
+ case 'ccc':
917
+ return localize.day(dayOfWeek, {
918
+ width: 'abbreviated',
919
+ context: 'standalone'
920
+ });
921
+ // T
922
+ case 'ccccc':
923
+ return localize.day(dayOfWeek, {
924
+ width: 'narrow',
925
+ context: 'standalone'
926
+ });
927
+ // Tu
928
+ case 'cccccc':
929
+ return localize.day(dayOfWeek, {
930
+ width: 'short',
931
+ context: 'standalone'
932
+ });
933
+ // Tuesday
934
+ case 'cccc':
935
+ default:
936
+ return localize.day(dayOfWeek, {
937
+ width: 'wide',
938
+ context: 'standalone'
939
+ });
940
+ }
941
+ },
942
+ // ISO day of week
943
+ i: function i(date, token, localize) {
944
+ var dayOfWeek = date.getUTCDay();
945
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
946
+ switch (token) {
947
+ // 2
948
+ case 'i':
949
+ return String(isoDayOfWeek);
950
+ // 02
951
+ case 'ii':
952
+ return addLeadingZeros(isoDayOfWeek, token.length);
953
+ // 2nd
954
+ case 'io':
955
+ return localize.ordinalNumber(isoDayOfWeek, {
956
+ unit: 'day'
957
+ });
958
+ // Tue
959
+ case 'iii':
960
+ return localize.day(dayOfWeek, {
961
+ width: 'abbreviated',
962
+ context: 'formatting'
963
+ });
964
+ // T
965
+ case 'iiiii':
966
+ return localize.day(dayOfWeek, {
967
+ width: 'narrow',
968
+ context: 'formatting'
969
+ });
970
+ // Tu
971
+ case 'iiiiii':
972
+ return localize.day(dayOfWeek, {
973
+ width: 'short',
974
+ context: 'formatting'
975
+ });
976
+ // Tuesday
977
+ case 'iiii':
978
+ default:
979
+ return localize.day(dayOfWeek, {
980
+ width: 'wide',
981
+ context: 'formatting'
982
+ });
983
+ }
984
+ },
985
+ // AM or PM
986
+ a: function a(date, token, localize) {
987
+ var hours = date.getUTCHours();
988
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
989
+ switch (token) {
990
+ case 'a':
991
+ case 'aa':
992
+ return localize.dayPeriod(dayPeriodEnumValue, {
993
+ width: 'abbreviated',
994
+ context: 'formatting'
995
+ });
996
+ case 'aaa':
997
+ return localize.dayPeriod(dayPeriodEnumValue, {
998
+ width: 'abbreviated',
999
+ context: 'formatting'
1000
+ }).toLowerCase();
1001
+ case 'aaaaa':
1002
+ return localize.dayPeriod(dayPeriodEnumValue, {
1003
+ width: 'narrow',
1004
+ context: 'formatting'
1005
+ });
1006
+ case 'aaaa':
1007
+ default:
1008
+ return localize.dayPeriod(dayPeriodEnumValue, {
1009
+ width: 'wide',
1010
+ context: 'formatting'
1011
+ });
1012
+ }
1013
+ },
1014
+ // AM, PM, midnight, noon
1015
+ b: function b(date, token, localize) {
1016
+ var hours = date.getUTCHours();
1017
+ var dayPeriodEnumValue;
1018
+ if (hours === 12) {
1019
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1020
+ } else if (hours === 0) {
1021
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1022
+ } else {
1023
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1024
+ }
1025
+ switch (token) {
1026
+ case 'b':
1027
+ case 'bb':
1028
+ return localize.dayPeriod(dayPeriodEnumValue, {
1029
+ width: 'abbreviated',
1030
+ context: 'formatting'
1031
+ });
1032
+ case 'bbb':
1033
+ return localize.dayPeriod(dayPeriodEnumValue, {
1034
+ width: 'abbreviated',
1035
+ context: 'formatting'
1036
+ }).toLowerCase();
1037
+ case 'bbbbb':
1038
+ return localize.dayPeriod(dayPeriodEnumValue, {
1039
+ width: 'narrow',
1040
+ context: 'formatting'
1041
+ });
1042
+ case 'bbbb':
1043
+ default:
1044
+ return localize.dayPeriod(dayPeriodEnumValue, {
1045
+ width: 'wide',
1046
+ context: 'formatting'
1047
+ });
1048
+ }
1049
+ },
1050
+ // in the morning, in the afternoon, in the evening, at night
1051
+ B: function B(date, token, localize) {
1052
+ var hours = date.getUTCHours();
1053
+ var dayPeriodEnumValue;
1054
+ if (hours >= 17) {
1055
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1056
+ } else if (hours >= 12) {
1057
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1058
+ } else if (hours >= 4) {
1059
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1060
+ } else {
1061
+ dayPeriodEnumValue = dayPeriodEnum.night;
1062
+ }
1063
+ switch (token) {
1064
+ case 'B':
1065
+ case 'BB':
1066
+ case 'BBB':
1067
+ return localize.dayPeriod(dayPeriodEnumValue, {
1068
+ width: 'abbreviated',
1069
+ context: 'formatting'
1070
+ });
1071
+ case 'BBBBB':
1072
+ return localize.dayPeriod(dayPeriodEnumValue, {
1073
+ width: 'narrow',
1074
+ context: 'formatting'
1075
+ });
1076
+ case 'BBBB':
1077
+ default:
1078
+ return localize.dayPeriod(dayPeriodEnumValue, {
1079
+ width: 'wide',
1080
+ context: 'formatting'
1081
+ });
1082
+ }
1083
+ },
1084
+ // Hour [1-12]
1085
+ h: function h(date, token, localize) {
1086
+ if (token === 'ho') {
1087
+ var hours = date.getUTCHours() % 12;
1088
+ if (hours === 0) hours = 12;
1089
+ return localize.ordinalNumber(hours, {
1090
+ unit: 'hour'
1091
+ });
1092
+ }
1093
+ return formatters$3.h(date, token);
1094
+ },
1095
+ // Hour [0-23]
1096
+ H: function H(date, token, localize) {
1097
+ if (token === 'Ho') {
1098
+ return localize.ordinalNumber(date.getUTCHours(), {
1099
+ unit: 'hour'
1100
+ });
1101
+ }
1102
+ return formatters$3.H(date, token);
1103
+ },
1104
+ // Hour [0-11]
1105
+ K: function K(date, token, localize) {
1106
+ var hours = date.getUTCHours() % 12;
1107
+ if (token === 'Ko') {
1108
+ return localize.ordinalNumber(hours, {
1109
+ unit: 'hour'
1110
+ });
1111
+ }
1112
+ return addLeadingZeros(hours, token.length);
1113
+ },
1114
+ // Hour [1-24]
1115
+ k: function k(date, token, localize) {
1116
+ var hours = date.getUTCHours();
1117
+ if (hours === 0) hours = 24;
1118
+ if (token === 'ko') {
1119
+ return localize.ordinalNumber(hours, {
1120
+ unit: 'hour'
1121
+ });
1122
+ }
1123
+ return addLeadingZeros(hours, token.length);
1124
+ },
1125
+ // Minute
1126
+ m: function m(date, token, localize) {
1127
+ if (token === 'mo') {
1128
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1129
+ unit: 'minute'
1130
+ });
1131
+ }
1132
+ return formatters$3.m(date, token);
1133
+ },
1134
+ // Second
1135
+ s: function s(date, token, localize) {
1136
+ if (token === 'so') {
1137
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1138
+ unit: 'second'
1139
+ });
1140
+ }
1141
+ return formatters$3.s(date, token);
1142
+ },
1143
+ // Fraction of second
1144
+ S: function S(date, token) {
1145
+ return formatters$3.S(date, token);
1146
+ },
1147
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1148
+ X: function X(date, token, _localize, options) {
1149
+ var originalDate = options._originalDate || date;
1150
+ var timezoneOffset = originalDate.getTimezoneOffset();
1151
+ if (timezoneOffset === 0) {
1152
+ return 'Z';
1153
+ }
1154
+ switch (token) {
1155
+ // Hours and optional minutes
1156
+ case 'X':
1157
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1158
+
1159
+ // Hours, minutes and optional seconds without `:` delimiter
1160
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1161
+ // so this token always has the same output as `XX`
1162
+ case 'XXXX':
1163
+ case 'XX':
1164
+ // Hours and minutes without `:` delimiter
1165
+ return formatTimezone(timezoneOffset);
1166
+
1167
+ // Hours, minutes and optional seconds with `:` delimiter
1168
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1169
+ // so this token always has the same output as `XXX`
1170
+ case 'XXXXX':
1171
+ case 'XXX': // Hours and minutes with `:` delimiter
1172
+ default:
1173
+ return formatTimezone(timezoneOffset, ':');
1174
+ }
1175
+ },
1176
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1177
+ x: function x(date, token, _localize, options) {
1178
+ var originalDate = options._originalDate || date;
1179
+ var timezoneOffset = originalDate.getTimezoneOffset();
1180
+ switch (token) {
1181
+ // Hours and optional minutes
1182
+ case 'x':
1183
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1184
+
1185
+ // Hours, minutes and optional seconds without `:` delimiter
1186
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1187
+ // so this token always has the same output as `xx`
1188
+ case 'xxxx':
1189
+ case 'xx':
1190
+ // Hours and minutes without `:` delimiter
1191
+ return formatTimezone(timezoneOffset);
1192
+
1193
+ // Hours, minutes and optional seconds with `:` delimiter
1194
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1195
+ // so this token always has the same output as `xxx`
1196
+ case 'xxxxx':
1197
+ case 'xxx': // Hours and minutes with `:` delimiter
1198
+ default:
1199
+ return formatTimezone(timezoneOffset, ':');
1200
+ }
1201
+ },
1202
+ // Timezone (GMT)
1203
+ O: function O(date, token, _localize, options) {
1204
+ var originalDate = options._originalDate || date;
1205
+ var timezoneOffset = originalDate.getTimezoneOffset();
1206
+ switch (token) {
1207
+ // Short
1208
+ case 'O':
1209
+ case 'OO':
1210
+ case 'OOO':
1211
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1212
+ // Long
1213
+ case 'OOOO':
1214
+ default:
1215
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1216
+ }
1217
+ },
1218
+ // Timezone (specific non-location)
1219
+ z: function z(date, token, _localize, options) {
1220
+ var originalDate = options._originalDate || date;
1221
+ var timezoneOffset = originalDate.getTimezoneOffset();
1222
+ switch (token) {
1223
+ // Short
1224
+ case 'z':
1225
+ case 'zz':
1226
+ case 'zzz':
1227
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1228
+ // Long
1229
+ case 'zzzz':
1230
+ default:
1231
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1232
+ }
1233
+ },
1234
+ // Seconds timestamp
1235
+ t: function t(date, token, _localize, options) {
1236
+ var originalDate = options._originalDate || date;
1237
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1238
+ return addLeadingZeros(timestamp, token.length);
1239
+ },
1240
+ // Milliseconds timestamp
1241
+ T: function T(date, token, _localize, options) {
1242
+ var originalDate = options._originalDate || date;
1243
+ var timestamp = originalDate.getTime();
1244
+ return addLeadingZeros(timestamp, token.length);
1245
+ }
1246
+ };
1247
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1248
+ var sign = offset > 0 ? '-' : '+';
1249
+ var absOffset = Math.abs(offset);
1250
+ var hours = Math.floor(absOffset / 60);
1251
+ var minutes = absOffset % 60;
1252
+ if (minutes === 0) {
1253
+ return sign + String(hours);
1254
+ }
1255
+ var delimiter = dirtyDelimiter || '';
1256
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1257
+ }
1258
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1259
+ if (offset % 60 === 0) {
1260
+ var sign = offset > 0 ? '-' : '+';
1261
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1262
+ }
1263
+ return formatTimezone(offset, dirtyDelimiter);
1264
+ }
1265
+ function formatTimezone(offset, dirtyDelimiter) {
1266
+ var delimiter = dirtyDelimiter || '';
1267
+ var sign = offset > 0 ? '-' : '+';
1268
+ var absOffset = Math.abs(offset);
1269
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1270
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1271
+ return sign + hours + delimiter + minutes;
1272
+ }
1273
+ const formatters$1 = formatters;
1274
+
1275
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1276
+ switch (pattern) {
1277
+ case 'P':
1278
+ return formatLong.date({
1279
+ width: 'short'
1280
+ });
1281
+ case 'PP':
1282
+ return formatLong.date({
1283
+ width: 'medium'
1284
+ });
1285
+ case 'PPP':
1286
+ return formatLong.date({
1287
+ width: 'long'
1288
+ });
1289
+ case 'PPPP':
1290
+ default:
1291
+ return formatLong.date({
1292
+ width: 'full'
1293
+ });
1294
+ }
1295
+ };
1296
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1297
+ switch (pattern) {
1298
+ case 'p':
1299
+ return formatLong.time({
1300
+ width: 'short'
1301
+ });
1302
+ case 'pp':
1303
+ return formatLong.time({
1304
+ width: 'medium'
1305
+ });
1306
+ case 'ppp':
1307
+ return formatLong.time({
1308
+ width: 'long'
1309
+ });
1310
+ case 'pppp':
1311
+ default:
1312
+ return formatLong.time({
1313
+ width: 'full'
1314
+ });
1315
+ }
1316
+ };
1317
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1318
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1319
+ var datePattern = matchResult[1];
1320
+ var timePattern = matchResult[2];
1321
+ if (!timePattern) {
1322
+ return dateLongFormatter(pattern, formatLong);
1323
+ }
1324
+ var dateTimeFormat;
1325
+ switch (datePattern) {
1326
+ case 'P':
1327
+ dateTimeFormat = formatLong.dateTime({
1328
+ width: 'short'
1329
+ });
1330
+ break;
1331
+ case 'PP':
1332
+ dateTimeFormat = formatLong.dateTime({
1333
+ width: 'medium'
1334
+ });
1335
+ break;
1336
+ case 'PPP':
1337
+ dateTimeFormat = formatLong.dateTime({
1338
+ width: 'long'
1339
+ });
1340
+ break;
1341
+ case 'PPPP':
1342
+ default:
1343
+ dateTimeFormat = formatLong.dateTime({
1344
+ width: 'full'
1345
+ });
1346
+ break;
1347
+ }
1348
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1349
+ };
1350
+ var longFormatters = {
1351
+ p: timeLongFormatter,
1352
+ P: dateTimeLongFormatter
1353
+ };
1354
+ const longFormatters$1 = longFormatters;
1355
+
1356
+ var protectedDayOfYearTokens = ['D', 'DD'];
1357
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1358
+ function isProtectedDayOfYearToken(token) {
1359
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1360
+ }
1361
+ function isProtectedWeekYearToken(token) {
1362
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1363
+ }
1364
+ function throwProtectedError(token, format, input) {
1365
+ if (token === 'YYYY') {
1366
+ 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"));
1367
+ } else if (token === 'YY') {
1368
+ 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"));
1369
+ } else if (token === 'D') {
1370
+ 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"));
1371
+ } else if (token === 'DD') {
1372
+ 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"));
1373
+ }
1374
+ }
1375
+
1376
+ var formatDistanceLocale = {
1377
+ lessThanXSeconds: {
1378
+ one: 'less than a second',
1379
+ other: 'less than {{count}} seconds'
1380
+ },
1381
+ xSeconds: {
1382
+ one: '1 second',
1383
+ other: '{{count}} seconds'
1384
+ },
1385
+ halfAMinute: 'half a minute',
1386
+ lessThanXMinutes: {
1387
+ one: 'less than a minute',
1388
+ other: 'less than {{count}} minutes'
1389
+ },
1390
+ xMinutes: {
1391
+ one: '1 minute',
1392
+ other: '{{count}} minutes'
1393
+ },
1394
+ aboutXHours: {
1395
+ one: 'about 1 hour',
1396
+ other: 'about {{count}} hours'
1397
+ },
1398
+ xHours: {
1399
+ one: '1 hour',
1400
+ other: '{{count}} hours'
1401
+ },
1402
+ xDays: {
1403
+ one: '1 day',
1404
+ other: '{{count}} days'
1405
+ },
1406
+ aboutXWeeks: {
1407
+ one: 'about 1 week',
1408
+ other: 'about {{count}} weeks'
1409
+ },
1410
+ xWeeks: {
1411
+ one: '1 week',
1412
+ other: '{{count}} weeks'
1413
+ },
1414
+ aboutXMonths: {
1415
+ one: 'about 1 month',
1416
+ other: 'about {{count}} months'
1417
+ },
1418
+ xMonths: {
1419
+ one: '1 month',
1420
+ other: '{{count}} months'
1421
+ },
1422
+ aboutXYears: {
1423
+ one: 'about 1 year',
1424
+ other: 'about {{count}} years'
1425
+ },
1426
+ xYears: {
1427
+ one: '1 year',
1428
+ other: '{{count}} years'
1429
+ },
1430
+ overXYears: {
1431
+ one: 'over 1 year',
1432
+ other: 'over {{count}} years'
1433
+ },
1434
+ almostXYears: {
1435
+ one: 'almost 1 year',
1436
+ other: 'almost {{count}} years'
1437
+ }
1438
+ };
1439
+ var formatDistance = function formatDistance(token, count, options) {
1440
+ var result;
1441
+ var tokenValue = formatDistanceLocale[token];
1442
+ if (typeof tokenValue === 'string') {
1443
+ result = tokenValue;
1444
+ } else if (count === 1) {
1445
+ result = tokenValue.one;
1446
+ } else {
1447
+ result = tokenValue.other.replace('{{count}}', count.toString());
1448
+ }
1449
+ if (options !== null && options !== void 0 && options.addSuffix) {
1450
+ if (options.comparison && options.comparison > 0) {
1451
+ return 'in ' + result;
1452
+ } else {
1453
+ return result + ' ago';
1454
+ }
1455
+ }
1456
+ return result;
1457
+ };
1458
+ const formatDistance$1 = formatDistance;
1459
+
1460
+ function buildFormatLongFn(args) {
1461
+ return function () {
1462
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1463
+ // TODO: Remove String()
1464
+ var width = options.width ? String(options.width) : args.defaultWidth;
1465
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1466
+ return format;
1467
+ };
1468
+ }
1469
+
1470
+ var dateFormats = {
1471
+ full: 'EEEE, MMMM do, y',
1472
+ long: 'MMMM do, y',
1473
+ medium: 'MMM d, y',
1474
+ short: 'MM/dd/yyyy'
1475
+ };
1476
+ var timeFormats = {
1477
+ full: 'h:mm:ss a zzzz',
1478
+ long: 'h:mm:ss a z',
1479
+ medium: 'h:mm:ss a',
1480
+ short: 'h:mm a'
1481
+ };
1482
+ var dateTimeFormats = {
1483
+ full: "{{date}} 'at' {{time}}",
1484
+ long: "{{date}} 'at' {{time}}",
1485
+ medium: '{{date}}, {{time}}',
1486
+ short: '{{date}}, {{time}}'
1487
+ };
1488
+ var formatLong = {
1489
+ date: buildFormatLongFn({
1490
+ formats: dateFormats,
1491
+ defaultWidth: 'full'
1492
+ }),
1493
+ time: buildFormatLongFn({
1494
+ formats: timeFormats,
1495
+ defaultWidth: 'full'
1496
+ }),
1497
+ dateTime: buildFormatLongFn({
1498
+ formats: dateTimeFormats,
1499
+ defaultWidth: 'full'
1500
+ })
1501
+ };
1502
+ const formatLong$1 = formatLong;
1503
+
1504
+ var formatRelativeLocale = {
1505
+ lastWeek: "'last' eeee 'at' p",
1506
+ yesterday: "'yesterday at' p",
1507
+ today: "'today at' p",
1508
+ tomorrow: "'tomorrow at' p",
1509
+ nextWeek: "eeee 'at' p",
1510
+ other: 'P'
1511
+ };
1512
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1513
+ return formatRelativeLocale[token];
1514
+ };
1515
+ const formatRelative$1 = formatRelative;
1516
+
1517
+ function buildLocalizeFn(args) {
1518
+ return function (dirtyIndex, options) {
1519
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1520
+ var valuesArray;
1521
+ if (context === 'formatting' && args.formattingValues) {
1522
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1523
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1524
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1525
+ } else {
1526
+ var _defaultWidth = args.defaultWidth;
1527
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1528
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1529
+ }
1530
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1531
+ // @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!
1532
+ return valuesArray[index];
1533
+ };
1534
+ }
1535
+
1536
+ var eraValues = {
1537
+ narrow: ['B', 'A'],
1538
+ abbreviated: ['BC', 'AD'],
1539
+ wide: ['Before Christ', 'Anno Domini']
1540
+ };
1541
+ var quarterValues = {
1542
+ narrow: ['1', '2', '3', '4'],
1543
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1544
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1545
+ };
1546
+
1547
+ // Note: in English, the names of days of the week and months are capitalized.
1548
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1549
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1550
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1551
+ var monthValues = {
1552
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1553
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1554
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1555
+ };
1556
+ var dayValues = {
1557
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1558
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1559
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1560
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1561
+ };
1562
+ var dayPeriodValues = {
1563
+ narrow: {
1564
+ am: 'a',
1565
+ pm: 'p',
1566
+ midnight: 'mi',
1567
+ noon: 'n',
1568
+ morning: 'morning',
1569
+ afternoon: 'afternoon',
1570
+ evening: 'evening',
1571
+ night: 'night'
1572
+ },
1573
+ abbreviated: {
1574
+ am: 'AM',
1575
+ pm: 'PM',
1576
+ midnight: 'midnight',
1577
+ noon: 'noon',
1578
+ morning: 'morning',
1579
+ afternoon: 'afternoon',
1580
+ evening: 'evening',
1581
+ night: 'night'
1582
+ },
1583
+ wide: {
1584
+ am: 'a.m.',
1585
+ pm: 'p.m.',
1586
+ midnight: 'midnight',
1587
+ noon: 'noon',
1588
+ morning: 'morning',
1589
+ afternoon: 'afternoon',
1590
+ evening: 'evening',
1591
+ night: 'night'
1592
+ }
1593
+ };
1594
+ var formattingDayPeriodValues = {
1595
+ narrow: {
1596
+ am: 'a',
1597
+ pm: 'p',
1598
+ midnight: 'mi',
1599
+ noon: 'n',
1600
+ morning: 'in the morning',
1601
+ afternoon: 'in the afternoon',
1602
+ evening: 'in the evening',
1603
+ night: 'at night'
1604
+ },
1605
+ abbreviated: {
1606
+ am: 'AM',
1607
+ pm: 'PM',
1608
+ midnight: 'midnight',
1609
+ noon: 'noon',
1610
+ morning: 'in the morning',
1611
+ afternoon: 'in the afternoon',
1612
+ evening: 'in the evening',
1613
+ night: 'at night'
1614
+ },
1615
+ wide: {
1616
+ am: 'a.m.',
1617
+ pm: 'p.m.',
1618
+ midnight: 'midnight',
1619
+ noon: 'noon',
1620
+ morning: 'in the morning',
1621
+ afternoon: 'in the afternoon',
1622
+ evening: 'in the evening',
1623
+ night: 'at night'
1624
+ }
1625
+ };
1626
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1627
+ var number = Number(dirtyNumber);
1628
+
1629
+ // If ordinal numbers depend on context, for example,
1630
+ // if they are different for different grammatical genders,
1631
+ // use `options.unit`.
1632
+ //
1633
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1634
+ // 'day', 'hour', 'minute', 'second'.
1635
+
1636
+ var rem100 = number % 100;
1637
+ if (rem100 > 20 || rem100 < 10) {
1638
+ switch (rem100 % 10) {
1639
+ case 1:
1640
+ return number + 'st';
1641
+ case 2:
1642
+ return number + 'nd';
1643
+ case 3:
1644
+ return number + 'rd';
1645
+ }
1646
+ }
1647
+ return number + 'th';
1648
+ };
1649
+ var localize = {
1650
+ ordinalNumber: ordinalNumber,
1651
+ era: buildLocalizeFn({
1652
+ values: eraValues,
1653
+ defaultWidth: 'wide'
1654
+ }),
1655
+ quarter: buildLocalizeFn({
1656
+ values: quarterValues,
1657
+ defaultWidth: 'wide',
1658
+ argumentCallback: function argumentCallback(quarter) {
1659
+ return quarter - 1;
1660
+ }
1661
+ }),
1662
+ month: buildLocalizeFn({
1663
+ values: monthValues,
1664
+ defaultWidth: 'wide'
1665
+ }),
1666
+ day: buildLocalizeFn({
1667
+ values: dayValues,
1668
+ defaultWidth: 'wide'
1669
+ }),
1670
+ dayPeriod: buildLocalizeFn({
1671
+ values: dayPeriodValues,
1672
+ defaultWidth: 'wide',
1673
+ formattingValues: formattingDayPeriodValues,
1674
+ defaultFormattingWidth: 'wide'
1675
+ })
1676
+ };
1677
+ const localize$1 = localize;
1678
+
1679
+ function buildMatchFn(args) {
1680
+ return function (string) {
1681
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1682
+ var width = options.width;
1683
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1684
+ var matchResult = string.match(matchPattern);
1685
+ if (!matchResult) {
1686
+ return null;
1687
+ }
1688
+ var matchedString = matchResult[0];
1689
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1690
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1691
+ return pattern.test(matchedString);
1692
+ }) : findKey(parsePatterns, function (pattern) {
1693
+ return pattern.test(matchedString);
1694
+ });
1695
+ var value;
1696
+ value = args.valueCallback ? args.valueCallback(key) : key;
1697
+ value = options.valueCallback ? options.valueCallback(value) : value;
1698
+ var rest = string.slice(matchedString.length);
1699
+ return {
1700
+ value: value,
1701
+ rest: rest
1702
+ };
1703
+ };
1704
+ }
1705
+ function findKey(object, predicate) {
1706
+ for (var key in object) {
1707
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1708
+ return key;
1709
+ }
1710
+ }
1711
+ return undefined;
1712
+ }
1713
+ function findIndex(array, predicate) {
1714
+ for (var key = 0; key < array.length; key++) {
1715
+ if (predicate(array[key])) {
1716
+ return key;
1717
+ }
1718
+ }
1719
+ return undefined;
1720
+ }
1721
+
1722
+ function buildMatchPatternFn(args) {
1723
+ return function (string) {
1724
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1725
+ var matchResult = string.match(args.matchPattern);
1726
+ if (!matchResult) return null;
1727
+ var matchedString = matchResult[0];
1728
+ var parseResult = string.match(args.parsePattern);
1729
+ if (!parseResult) return null;
1730
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1731
+ value = options.valueCallback ? options.valueCallback(value) : value;
1732
+ var rest = string.slice(matchedString.length);
1733
+ return {
1734
+ value: value,
1735
+ rest: rest
1736
+ };
1737
+ };
1738
+ }
1739
+
1740
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1741
+ var parseOrdinalNumberPattern = /\d+/i;
1742
+ var matchEraPatterns = {
1743
+ narrow: /^(b|a)/i,
1744
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1745
+ wide: /^(before christ|before common era|anno domini|common era)/i
1746
+ };
1747
+ var parseEraPatterns = {
1748
+ any: [/^b/i, /^(a|c)/i]
1749
+ };
1750
+ var matchQuarterPatterns = {
1751
+ narrow: /^[1234]/i,
1752
+ abbreviated: /^q[1234]/i,
1753
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1754
+ };
1755
+ var parseQuarterPatterns = {
1756
+ any: [/1/i, /2/i, /3/i, /4/i]
1757
+ };
1758
+ var matchMonthPatterns = {
1759
+ narrow: /^[jfmasond]/i,
1760
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1761
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1762
+ };
1763
+ var parseMonthPatterns = {
1764
+ 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],
1765
+ 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]
1766
+ };
1767
+ var matchDayPatterns = {
1768
+ narrow: /^[smtwf]/i,
1769
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1770
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1771
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1772
+ };
1773
+ var parseDayPatterns = {
1774
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1775
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1776
+ };
1777
+ var matchDayPeriodPatterns = {
1778
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1779
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1780
+ };
1781
+ var parseDayPeriodPatterns = {
1782
+ any: {
1783
+ am: /^a/i,
1784
+ pm: /^p/i,
1785
+ midnight: /^mi/i,
1786
+ noon: /^no/i,
1787
+ morning: /morning/i,
1788
+ afternoon: /afternoon/i,
1789
+ evening: /evening/i,
1790
+ night: /night/i
1791
+ }
1792
+ };
1793
+ var match = {
1794
+ ordinalNumber: buildMatchPatternFn({
1795
+ matchPattern: matchOrdinalNumberPattern,
1796
+ parsePattern: parseOrdinalNumberPattern,
1797
+ valueCallback: function valueCallback(value) {
1798
+ return parseInt(value, 10);
1799
+ }
1800
+ }),
1801
+ era: buildMatchFn({
1802
+ matchPatterns: matchEraPatterns,
1803
+ defaultMatchWidth: 'wide',
1804
+ parsePatterns: parseEraPatterns,
1805
+ defaultParseWidth: 'any'
1806
+ }),
1807
+ quarter: buildMatchFn({
1808
+ matchPatterns: matchQuarterPatterns,
1809
+ defaultMatchWidth: 'wide',
1810
+ parsePatterns: parseQuarterPatterns,
1811
+ defaultParseWidth: 'any',
1812
+ valueCallback: function valueCallback(index) {
1813
+ return index + 1;
1814
+ }
1815
+ }),
1816
+ month: buildMatchFn({
1817
+ matchPatterns: matchMonthPatterns,
1818
+ defaultMatchWidth: 'wide',
1819
+ parsePatterns: parseMonthPatterns,
1820
+ defaultParseWidth: 'any'
1821
+ }),
1822
+ day: buildMatchFn({
1823
+ matchPatterns: matchDayPatterns,
1824
+ defaultMatchWidth: 'wide',
1825
+ parsePatterns: parseDayPatterns,
1826
+ defaultParseWidth: 'any'
1827
+ }),
1828
+ dayPeriod: buildMatchFn({
1829
+ matchPatterns: matchDayPeriodPatterns,
1830
+ defaultMatchWidth: 'any',
1831
+ parsePatterns: parseDayPeriodPatterns,
1832
+ defaultParseWidth: 'any'
1833
+ })
1834
+ };
1835
+ const match$1 = match;
1836
+
1837
+ /**
1838
+ * @type {Locale}
1839
+ * @category Locales
1840
+ * @summary English locale (United States).
1841
+ * @language English
1842
+ * @iso-639-2 eng
1843
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1844
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1845
+ */
1846
+ var locale = {
1847
+ code: 'en-US',
1848
+ formatDistance: formatDistance$1,
1849
+ formatLong: formatLong$1,
1850
+ formatRelative: formatRelative$1,
1851
+ localize: localize$1,
1852
+ match: match$1,
1853
+ options: {
1854
+ weekStartsOn: 0 /* Sunday */,
1855
+ firstWeekContainsDate: 1
1856
+ }
1857
+ };
1858
+ const defaultLocale = locale;
1859
+
1860
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1861
+ // (one of the certain letters followed by `o`)
1862
+ // - (\w)\1* matches any sequences of the same letter
1863
+ // - '' matches two quote characters in a row
1864
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1865
+ // except a single quote symbol, which ends the sequence.
1866
+ // Two quote characters do not end the sequence.
1867
+ // If there is no matching single quote
1868
+ // then the sequence will continue until the end of the string.
1869
+ // - . matches any single character unmatched by previous parts of the RegExps
1870
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1871
+
1872
+ // This RegExp catches symbols escaped by quotes, and also
1873
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1874
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1875
+ var escapedStringRegExp = /^'([^]*?)'?$/;
1876
+ var doubleQuoteRegExp = /''/g;
1877
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1878
+
1879
+ /**
1880
+ * @name format
1881
+ * @category Common Helpers
1882
+ * @summary Format the date.
1883
+ *
1884
+ * @description
1885
+ * Return the formatted date string in the given format. The result may vary by locale.
1886
+ *
1887
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1888
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1889
+ *
1890
+ * The characters wrapped between two single quotes characters (') are escaped.
1891
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1892
+ * (see the last example)
1893
+ *
1894
+ * Format of the string is based on Unicode Technical Standard #35:
1895
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1896
+ * with a few additions (see note 7 below the table).
1897
+ *
1898
+ * Accepted patterns:
1899
+ * | Unit | Pattern | Result examples | Notes |
1900
+ * |---------------------------------|---------|-----------------------------------|-------|
1901
+ * | Era | G..GGG | AD, BC | |
1902
+ * | | GGGG | Anno Domini, Before Christ | 2 |
1903
+ * | | GGGGG | A, B | |
1904
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1905
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1906
+ * | | yy | 44, 01, 00, 17 | 5 |
1907
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
1908
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1909
+ * | | yyyyy | ... | 3,5 |
1910
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1911
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1912
+ * | | YY | 44, 01, 00, 17 | 5,8 |
1913
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
1914
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1915
+ * | | YYYYY | ... | 3,5 |
1916
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1917
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1918
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1919
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1920
+ * | | RRRRR | ... | 3,5,7 |
1921
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1922
+ * | | uu | -43, 01, 1900, 2017 | 5 |
1923
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
1924
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1925
+ * | | uuuuu | ... | 3,5 |
1926
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1927
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1928
+ * | | QQ | 01, 02, 03, 04 | |
1929
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
1930
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1931
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
1932
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1933
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1934
+ * | | qq | 01, 02, 03, 04 | |
1935
+ * | | qqq | Q1, Q2, Q3, Q4 | |
1936
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1937
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
1938
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
1939
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
1940
+ * | | MM | 01, 02, ..., 12 | |
1941
+ * | | MMM | Jan, Feb, ..., Dec | |
1942
+ * | | MMMM | January, February, ..., December | 2 |
1943
+ * | | MMMMM | J, F, ..., D | |
1944
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1945
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
1946
+ * | | LL | 01, 02, ..., 12 | |
1947
+ * | | LLL | Jan, Feb, ..., Dec | |
1948
+ * | | LLLL | January, February, ..., December | 2 |
1949
+ * | | LLLLL | J, F, ..., D | |
1950
+ * | Local week of year | w | 1, 2, ..., 53 | |
1951
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
1952
+ * | | ww | 01, 02, ..., 53 | |
1953
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1954
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
1955
+ * | | II | 01, 02, ..., 53 | 7 |
1956
+ * | Day of month | d | 1, 2, ..., 31 | |
1957
+ * | | do | 1st, 2nd, ..., 31st | 7 |
1958
+ * | | dd | 01, 02, ..., 31 | |
1959
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1960
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1961
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
1962
+ * | | DDD | 001, 002, ..., 365, 366 | |
1963
+ * | | DDDD | ... | 3 |
1964
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
1965
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
1966
+ * | | EEEEE | M, T, W, T, F, S, S | |
1967
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
1968
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
1969
+ * | | io | 1st, 2nd, ..., 7th | 7 |
1970
+ * | | ii | 01, 02, ..., 07 | 7 |
1971
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
1972
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
1973
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
1974
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
1975
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
1976
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
1977
+ * | | ee | 02, 03, ..., 01 | |
1978
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
1979
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
1980
+ * | | eeeee | M, T, W, T, F, S, S | |
1981
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
1982
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
1983
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
1984
+ * | | cc | 02, 03, ..., 01 | |
1985
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
1986
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
1987
+ * | | ccccc | M, T, W, T, F, S, S | |
1988
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
1989
+ * | AM, PM | a..aa | AM, PM | |
1990
+ * | | aaa | am, pm | |
1991
+ * | | aaaa | a.m., p.m. | 2 |
1992
+ * | | aaaaa | a, p | |
1993
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
1994
+ * | | bbb | am, pm, noon, midnight | |
1995
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
1996
+ * | | bbbbb | a, p, n, mi | |
1997
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
1998
+ * | | BBBB | at night, in the morning, ... | 2 |
1999
+ * | | BBBBB | at night, in the morning, ... | |
2000
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2001
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2002
+ * | | hh | 01, 02, ..., 11, 12 | |
2003
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2004
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2005
+ * | | HH | 00, 01, 02, ..., 23 | |
2006
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2007
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2008
+ * | | KK | 01, 02, ..., 11, 00 | |
2009
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2010
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2011
+ * | | kk | 24, 01, 02, ..., 23 | |
2012
+ * | Minute | m | 0, 1, ..., 59 | |
2013
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2014
+ * | | mm | 00, 01, ..., 59 | |
2015
+ * | Second | s | 0, 1, ..., 59 | |
2016
+ * | | so | 0th, 1st, ..., 59th | 7 |
2017
+ * | | ss | 00, 01, ..., 59 | |
2018
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2019
+ * | | SS | 00, 01, ..., 99 | |
2020
+ * | | SSS | 000, 001, ..., 999 | |
2021
+ * | | SSSS | ... | 3 |
2022
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2023
+ * | | XX | -0800, +0530, Z | |
2024
+ * | | XXX | -08:00, +05:30, Z | |
2025
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2026
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2027
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2028
+ * | | xx | -0800, +0530, +0000 | |
2029
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2030
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2031
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2032
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2033
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2034
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2035
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2036
+ * | Seconds timestamp | t | 512969520 | 7 |
2037
+ * | | tt | ... | 3,7 |
2038
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2039
+ * | | TT | ... | 3,7 |
2040
+ * | Long localized date | P | 04/29/1453 | 7 |
2041
+ * | | PP | Apr 29, 1453 | 7 |
2042
+ * | | PPP | April 29th, 1453 | 7 |
2043
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2044
+ * | Long localized time | p | 12:00 AM | 7 |
2045
+ * | | pp | 12:00:00 AM | 7 |
2046
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2047
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2048
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2049
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2050
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2051
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2052
+ * Notes:
2053
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2054
+ * are the same as "stand-alone" units, but are different in some languages.
2055
+ * "Formatting" units are declined according to the rules of the language
2056
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2057
+ *
2058
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2059
+ *
2060
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2061
+ *
2062
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2063
+ * the single quote characters (see below).
2064
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2065
+ * the output will be the same as default pattern for this unit, usually
2066
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2067
+ * are marked with "2" in the last column of the table.
2068
+ *
2069
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2070
+ *
2071
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2072
+ *
2073
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2074
+ *
2075
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2076
+ *
2077
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2078
+ *
2079
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2080
+ * The output will be padded with zeros to match the length of the pattern.
2081
+ *
2082
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2083
+ *
2084
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2085
+ * These tokens represent the shortest form of the quarter.
2086
+ *
2087
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2088
+ *
2089
+ * | Year | `y` | `u` |
2090
+ * |------|-----|-----|
2091
+ * | AC 1 | 1 | 1 |
2092
+ * | BC 1 | 1 | 0 |
2093
+ * | BC 2 | 2 | -1 |
2094
+ *
2095
+ * Also `yy` always returns the last two digits of a year,
2096
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2097
+ *
2098
+ * | Year | `yy` | `uu` |
2099
+ * |------|------|------|
2100
+ * | 1 | 01 | 01 |
2101
+ * | 14 | 14 | 14 |
2102
+ * | 376 | 76 | 376 |
2103
+ * | 1453 | 53 | 1453 |
2104
+ *
2105
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2106
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2107
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2108
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2109
+ *
2110
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2111
+ * so right now these tokens fall back to GMT timezones.
2112
+ *
2113
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2114
+ * - `i`: ISO day of week
2115
+ * - `I`: ISO week of year
2116
+ * - `R`: ISO week-numbering year
2117
+ * - `t`: seconds timestamp
2118
+ * - `T`: milliseconds timestamp
2119
+ * - `o`: ordinal number modifier
2120
+ * - `P`: long localized date
2121
+ * - `p`: long localized time
2122
+ *
2123
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2124
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2125
+ *
2126
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2127
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2128
+ *
2129
+ * @param {Date|Number} date - the original date
2130
+ * @param {String} format - the string of tokens
2131
+ * @param {Object} [options] - an object with options.
2132
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2133
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2134
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2135
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2136
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2137
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2138
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2139
+ * @returns {String} the formatted date string
2140
+ * @throws {TypeError} 2 arguments required
2141
+ * @throws {RangeError} `date` must not be Invalid Date
2142
+ * @throws {RangeError} `options.locale` must contain `localize` property
2143
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2144
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2145
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2146
+ * @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
2147
+ * @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
2148
+ * @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
2149
+ * @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
2150
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2151
+ *
2152
+ * @example
2153
+ * // Represent 11 February 2014 in middle-endian format:
2154
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2155
+ * //=> '02/11/2014'
2156
+ *
2157
+ * @example
2158
+ * // Represent 2 July 2014 in Esperanto:
2159
+ * import { eoLocale } from 'date-fns/locale/eo'
2160
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2161
+ * locale: eoLocale
2162
+ * })
2163
+ * //=> '2-a de julio 2014'
2164
+ *
2165
+ * @example
2166
+ * // Escape string by single quote characters:
2167
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2168
+ * //=> "3 o'clock"
2169
+ */
2170
+
2171
+ function format(dirtyDate, dirtyFormatStr, options) {
2172
+ 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;
2173
+ requiredArgs(2, arguments);
2174
+ var formatStr = String(dirtyFormatStr);
2175
+ var defaultOptions = getDefaultOptions();
2176
+ 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;
2177
+ 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);
2178
+
2179
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2180
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2181
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2182
+ }
2183
+ 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);
2184
+
2185
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2186
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2187
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2188
+ }
2189
+ if (!locale.localize) {
2190
+ throw new RangeError('locale must contain localize property');
2191
+ }
2192
+ if (!locale.formatLong) {
2193
+ throw new RangeError('locale must contain formatLong property');
2194
+ }
2195
+ var originalDate = toDate(dirtyDate);
2196
+ if (!isValid(originalDate)) {
2197
+ throw new RangeError('Invalid time value');
2198
+ }
2199
+
2200
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2201
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2202
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2203
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2204
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2205
+ var formatterOptions = {
2206
+ firstWeekContainsDate: firstWeekContainsDate,
2207
+ weekStartsOn: weekStartsOn,
2208
+ locale: locale,
2209
+ _originalDate: originalDate
2210
+ };
2211
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2212
+ var firstCharacter = substring[0];
2213
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2214
+ var longFormatter = longFormatters$1[firstCharacter];
2215
+ return longFormatter(substring, locale.formatLong);
2216
+ }
2217
+ return substring;
2218
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2219
+ // Replace two single quote characters with one single quote character
2220
+ if (substring === "''") {
2221
+ return "'";
2222
+ }
2223
+ var firstCharacter = substring[0];
2224
+ if (firstCharacter === "'") {
2225
+ return cleanEscapedString(substring);
2226
+ }
2227
+ var formatter = formatters$1[firstCharacter];
2228
+ if (formatter) {
2229
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2230
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2231
+ }
2232
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2233
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2234
+ }
2235
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2236
+ }
2237
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2238
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2239
+ }
2240
+ return substring;
2241
+ }).join('');
2242
+ return result;
2243
+ }
2244
+ function cleanEscapedString(input) {
2245
+ var matched = input.match(escapedStringRegExp);
2246
+ if (!matched) {
2247
+ return input;
2248
+ }
2249
+ return matched[1].replace(doubleQuoteRegExp, "'");
2250
+ }
2251
+
2252
+ const getHistoryLoaderTemplate = (lang) => {
2253
+ return index.h("div", { class: "HistoryLoader" },
2254
+ index.h("casino-engagement-suite-progress-bar", { indeterminate: true }),
2255
+ index.h("span", null, translate('loading', lang)));
2256
+ };
2257
+ const getRewardNameByType = (type, lang) => {
2258
+ switch (type) {
2259
+ case 0: return translate('freeSpins', lang);
2260
+ case 1: return translate('luckyWheel', lang);
2261
+ case 2: return translate('leaderboard', lang);
2262
+ case 3: return translate('mission', lang);
2263
+ }
2264
+ };
2265
+ const getLevelStatusString = (status, lang) => {
2266
+ switch (status) {
2267
+ case ChallengeHistoryLevelStatus.Completed: return translate('completed', lang);
2268
+ case ChallengeHistoryLevelStatus.Expired: return translate('expired', lang);
2269
+ case ChallengeHistoryLevelStatus.Forfeited: return translate('forfeited', lang);
2270
+ default: return status;
2271
+ }
2272
+ };
2273
+ const showRewards = (level) => {
2274
+ return !!level.Rewards && level.Status === ChallengeHistoryLevelStatus.Completed;
2275
+ };
2276
+ const getRewardTemplate = (reward, lang) => {
2277
+ const isCustom = reward.Type === ChallengeRewardType.Custom;
2278
+ const rewardName = isCustom ? reward.RewardDescription : getRewardNameByType(reward.Type, lang);
2279
+ const isRewarded = isCustom || reward.IsRewarded;
2280
+ return index.h("div", { class: `HistoryRewardsItem ${isRewarded || isCustom ? 'IsRewarded' : 'IsNotRewarded'}` },
2281
+ index.h("span", { class: "HistoryRewardsItemName" }, rewardName),
2282
+ !isCustom && index.h("div", { class: "HistoryRewardStatusIcon" }));
2283
+ };
2284
+ const getHistoryLevelRewardsTemplate = (level, lang) => {
2285
+ return index.h("div", { class: "HistoryRewardsList" },
2286
+ index.h("img", { class: "HistoryRewardsIcon", src: "https://static.everymatrix.com/gic/img/engagement-suite/cup-reward-list.svg", alt: "Reward" }),
2287
+ Object.values(level.Rewards).map(reward => getRewardTemplate(reward, lang)));
2288
+ };
2289
+ const getHistoryLevelTemplate = (level, index$1, lang) => {
2290
+ return index.h("div", { class: "HistoryLevelInfo" },
2291
+ index.h("span", { class: "Level" }, `${translate('level', lang)} ${index$1 + 1}`),
2292
+ index.h("span", { class: "Status" }, getLevelStatusString(level.Status, lang)),
2293
+ index.h("span", { class: "Time" }, format(new Date(level.Time), 'LLL d, yyyy HH:mm:ss')));
2294
+ };
2295
+ const getChallengesHistoryTemplate = (histories, openedHistoryIds, toggleChallengeHistory, lang) => {
2296
+ if (histories.length === 0) {
2297
+ return index.h("p", { class: "HistoryEmptyMessage" }, translate('noHistory', lang));
2298
+ }
2299
+ return index.h("div", { class: "HistoryList" }, histories.map((history) => {
2300
+ return index.h("div", { key: history.ProgressId, class: `HistoryListItem ${openedHistoryIds.includes(history.ProgressId) ? 'Opened' : 'Closed'}` },
2301
+ index.h("header", { class: "HistoryListItemHeader", "data-id": history.ProgressId, onClick: toggleChallengeHistory },
2302
+ history.Name,
2303
+ index.h("button", { class: "HistoryListItemButton" })),
2304
+ index.h("div", { class: "HistoryListItemBody" },
2305
+ index.h("div", null, history.Levels.map((level, index$1) => {
2306
+ return index.h("div", { class: "HistoryListItemLevelCard" },
2307
+ getHistoryLevelTemplate(level, index$1, lang),
2308
+ showRewards(level) && getHistoryLevelRewardsTemplate(level, lang));
2309
+ }))));
2310
+ }));
2311
+ };
2312
+
2313
+ const casinoEngagementSuiteChallengesListCss = "@import url(\"https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap\");:host{display:block;font-family:inherit}*{box-sizing:border-box;margin:0;padding:0}button{border:none;background:none;cursor:pointer}button:focus{outline:none}.ChallengesListPopup{display:flex;height:100%;background-color:var(--emw--color-background, #1E1638);border-radius:8px;overflow:hidden;flex-direction:column;position:relative;padding-bottom:20px}.ChallengesListPopupHeader{display:flex;justify-content:space-between;align-items:center;padding:12px 8px 8px}.ChallengesIconButton{width:16px;height:16px;cursor:pointer}.ChallengesListPopupHeaderName{color:var(--emw--color-gray-100, #BBB9C3);font-size:14px;font-weight:500;line-height:14px}.ChallengesListWrapper{overflow-y:auto;-ms-overflow-style:none;scrollbar-width:none}.ChallengesListWrapper::-webkit-scrollbar{display:none}.ChallengesList{display:flex;flex-direction:column;row-gap:12px;padding:8px 19px 0}.ChallengeCard{padding:15px 15px 19px;border:1px solid var(--emw--button-border-color, #403956);border-radius:6px;position:relative;cursor:pointer}.ChallengeJoinButton.Joined::before,.ChallengeCard.InProgress::before{content:\"\";position:absolute;inset:0;border-radius:var(--emw--button-border-radius, 4px);padding:1px;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-mask:linear-gradient(#FFF 0 0) content-box, linear-gradient(#FFF 0 0);-webkit-mask-composite:xor;mask-composite:exclude}.ChallengeCardHeader{display:flex;justify-content:space-between;gap:24px;margin-bottom:12px}.ChallengeName{color:var(--emw--color-typography, #FFFFFF);font-family:\"Montserrat\", sans-serif;line-height:22px;font-weight:700;font-size:18px;word-break:break-word}.ChallengeJoinButton{transition:all 0.5s ease-out;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);color:var(--emw--color-typography, #1E1638);border-radius:99px;min-width:88px;height:32px;font-size:14px;font-weight:700;position:relative;font-family:\"Montserrat\", sans-serif}.ChallengeJoinButton.Joined{background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ChallengeJoinButton.Joined::before{border-radius:99px}.Disabled{opacity:0.5;pointer-events:none;cursor:auto}.ChallengesListEmpty{padding:20px 32px}.ChallengesListEmpty h2{margin:0 0 16px 0;text-align:center;font-weight:600;font-size:20px;line-height:24px;font-family:\"Montserrat\", sans-serif;color:var(--emw--color-typography, #FFFFFF)}.ChallengesListEmpty p{font-size:14px;line-height:17px;color:var(--emw--color-gray-100, #BBB9C3)}.ChallengeCountdown{color:var(--emw--color-gray-100, #BBB9C3);font-size:12px;line-height:12px}.ChallengeLabel{min-width:35px;height:18px;background:linear-gradient(180deg, #FFB801 15.86%, #FEF746 31.36%, #FBFFE0 36.86%, #FFFA60 47.86%, #FF9400 87.36%);border-radius:2px;display:none;position:absolute;top:-11px;right:11px;padding:0 2px;align-items:center;justify-content:center}.ChallengeLabel span{display:inline-block;text-transform:uppercase;font-size:10px;line-height:10px;font-weight:700;font-family:\"Montserrat\", sans-serif;color:var(--emw--color-typography, #1E1638)}.ShowChallengeLabel{display:inline-flex}.ChallengesTooltipBackdrop{padding:48px 30px 0;position:absolute;width:100%;height:100%;inset:0;background-color:rgba(0, 0, 0, 0.5)}.ChallengesTooltipBackdrop .ChallengesTooltip{border:1px solid var(--emw--button-border-color, #403956);background-color:var(--emw--color-background, #1E1638);border-radius:8px;padding:32px;font-size:14px;line-height:17px;color:var(--emw--color-gray-100, #BBB9C3);position:relative}.ChallengesTooltipBackdrop .ChallengesTooltip .ChallengesIconButton{top:12px;right:6px;position:absolute}.ChallengesListPopup.Tablet .ChallengesListPopupHeader,.ChallengesListPopup.Desktop .ChallengesListPopupHeader{padding-top:16px}.ChallengesListPopup.Tablet .ChallengesListPopupHeaderName,.ChallengesListPopup.Desktop .ChallengesListPopupHeaderName{font-size:16px;line-height:16px}.ChallengesListPopup.Tablet .ChallengesIconButton,.ChallengesListPopup.Desktop .ChallengesIconButton{width:24px;height:24px}.ChallengesListPopup.Tablet .ChallengesList,.ChallengesListPopup.Desktop .ChallengesList{padding:20px 24px 0;row-gap:20px}.ChallengesListPopup.Tablet .ChallengeCardHeader,.ChallengesListPopup.Desktop .ChallengeCardHeader{margin-bottom:16px}.ChallengesListPopup.Tablet .ChallengeName,.ChallengesListPopup.Desktop .ChallengeName{line-height:27px;font-size:22px}.ChallengesListPopup.Tablet .ChallengeJoinButton,.ChallengesListPopup.Desktop .ChallengeJoinButton{min-width:100px;height:36px;font-size:16px}.ChallengesListPopup.Tablet .ChallengeCountdown,.ChallengesListPopup.Desktop .ChallengeCountdown{font-size:14px;line-height:14px}.ChallengesListPopup.Tablet .ChallengesTooltip,.ChallengesListPopup.Desktop .ChallengesTooltip{padding:60px 65px;font-size:16px;line-height:20px}.ChallengesListPopup.Tablet .ChallengesTooltip .ChallengesIconButton,.ChallengesListPopup.Desktop .ChallengesTooltip .ChallengesIconButton{top:24px;right:24px}";
2314
+ const CasinoEngagementSuiteChallengesListStyle0 = casinoEngagementSuiteChallengesListCss;
2315
+
2316
+ const CasinoEngagementSuiteChallengesList = class {
2317
+ constructor(hostRef) {
2318
+ index.registerInstance(this, hostRef);
2319
+ this.close = index.createEvent(this, "close", 7);
2320
+ this.resetNewChallengeLabel = index.createEvent(this, "resetNewChallengeLabel", 7);
2321
+ this.setClientStyling = () => {
2322
+ let sheet = document.createElement('style');
2323
+ sheet.innerHTML = this.clientStyling;
2324
+ this.host.prepend(sheet);
2325
+ };
2326
+ this.setClientStylingURL = () => {
2327
+ let url = new URL(this.clientStylingUrl);
2328
+ let cssFile = document.createElement('style');
2329
+ fetch(url.href)
2330
+ .then((res) => res.text())
2331
+ .then((data) => {
2332
+ cssFile.innerHTML = data;
2333
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
2334
+ })
2335
+ .catch((err) => {
2336
+ console.log('Error ', err);
2337
+ });
2338
+ };
2339
+ this.handleTabChange = (e) => {
2340
+ this.activeTab = +(e.target.getAttribute('data-index'));
2341
+ if (this.activeTab === 2) {
2342
+ this.sendHistoryRequest();
2343
+ }
2344
+ };
2345
+ this.toggleChallengeHistory = (ev) => {
2346
+ const id = ev.currentTarget.getAttribute('data-id');
2347
+ const index = this.openedHistoryIds.findIndex(historyId => historyId === id);
2348
+ if (index > -1) {
2349
+ this.openedHistoryIds.splice(index, 1);
2350
+ }
2351
+ else {
2352
+ this.openedHistoryIds.push(id);
2353
+ }
2354
+ this.openedHistoryIds = [...this.openedHistoryIds];
2355
+ };
2356
+ this.handleCloseClick = () => {
2357
+ this.close.emit();
2358
+ this.tooltip = false;
2359
+ this.resetNewChallengeLabel.emit('list');
2360
+ };
2361
+ this.handleChallengeClick = (ev) => {
2362
+ const id = ev.currentTarget.getAttribute('data-id');
2363
+ window.postMessage({ type: 'ChallengeClick', id });
2364
+ };
2365
+ this.showTooltip = () => {
2366
+ this.tooltip = true;
2367
+ };
2368
+ this.hideTooltip = () => {
2369
+ this.tooltip = false;
2370
+ };
2371
+ this.changeChallengeStatus = (e) => {
2372
+ var _a, _b;
2373
+ e.stopPropagation();
2374
+ const id = e.currentTarget.getAttribute('data-id');
2375
+ if ((_a = this.inProgressChallenges) === null || _a === void 0 ? void 0 : _a.includes(id)) {
2376
+ window.postMessage({
2377
+ type: 'ShowConfirmationModal',
2378
+ ProgressToDeactivate: id,
2379
+ });
2380
+ return;
2381
+ }
2382
+ if (((_b = this.inProgressChallenges) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2383
+ window.postMessage({
2384
+ type: 'ShowConfirmationModal',
2385
+ ProgressToActivate: id,
2386
+ ProgressToDeactivate: this.inProgressChallenges[0],
2387
+ });
2388
+ return;
2389
+ }
2390
+ window.postMessage({
2391
+ type: 'ChallengeJoinRequest',
2392
+ data: {
2393
+ ProgressToActivate: id,
2394
+ },
2395
+ });
2396
+ };
2397
+ this.clientStyling = '';
2398
+ this.clientStylingUrl = '';
2399
+ this.language = 'en';
2400
+ this.device = 'Mobile';
2401
+ this.challenges = [];
2402
+ this.isJoiningToChallenge = undefined;
2403
+ this.inProgressChallenges = undefined;
2404
+ this.pausedChallengeIds = [];
2405
+ this.tooltip = false;
2406
+ this.timers = {};
2407
+ this.limitStylingAppends = false;
2408
+ this.activeTab = 1;
2409
+ this.historyLoading = false;
2410
+ this.challengesHistory = undefined;
2411
+ this.openedHistoryIds = [];
2412
+ }
2413
+ handleEvent(e) {
2414
+ const { type } = e === null || e === void 0 ? void 0 : e.data;
2415
+ if (type === 'ChallengesHistoryResponse') {
2416
+ this.openedHistoryIds = [];
2417
+ this.challengesHistory = e.data.data || [];
2418
+ this.historyLoading = false;
2419
+ }
2420
+ if (type === 'BarChallengesClick') {
2421
+ this.activeTab = 1;
2422
+ this.openedHistoryIds = [];
2423
+ }
2424
+ }
2425
+ challengesPropHandler(value) {
2426
+ if (!this.interval && value.length) {
2427
+ this.updateTimers();
2428
+ this.startCountdown();
2429
+ }
2430
+ if (this.interval && !value.length) {
2431
+ clearInterval(this.interval);
2432
+ }
2433
+ }
2434
+ componentWillLoad() {
2435
+ this.challengesPropHandler(this.challenges);
2436
+ }
2437
+ componentDidRender() {
2438
+ if (!this.limitStylingAppends && this.host) {
2439
+ if (this.clientStyling)
2440
+ this.setClientStyling();
2441
+ if (this.clientStylingUrl)
2442
+ this.setClientStylingURL();
2443
+ this.limitStylingAppends = true;
2444
+ }
2445
+ }
2446
+ disconnectedCallback() {
2447
+ this.interval && clearInterval(this.interval);
2448
+ }
2449
+ sendHistoryRequest() {
2450
+ this.historyLoading = true;
2451
+ window.postMessage({
2452
+ type: 'ChallengesHistoryRequest'
2453
+ });
2454
+ }
2455
+ startCountdown() {
2456
+ this.interval = setInterval(() => {
2457
+ this.updateTimers();
2458
+ }, 1000);
2459
+ }
2460
+ updateTimers() {
2461
+ const now = new Date().getTime();
2462
+ this.timers = this.challenges.filter(challenge => challenge.Status !== ChallengeProgressStatus.Expired).reduce((acc, challenge) => {
2463
+ const expirationDate = new Date(challenge.ExpirationTime).getTime();
2464
+ const diff = expirationDate - now;
2465
+ let countdown = '00h:00m:00s';
2466
+ if (diff < 1) {
2467
+ this.removeChallenge(challenge.Id);
2468
+ }
2469
+ else {
2470
+ const { days, hours, minutes, seconds } = {
2471
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
2472
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
2473
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
2474
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
2475
+ };
2476
+ countdown = days === '00'
2477
+ ? `${hours}h:${minutes}m:${seconds}s`
2478
+ : `${days}d:${hours}h:${minutes}m`;
2479
+ }
2480
+ return Object.assign(Object.assign({}, acc), { [challenge.Id]: countdown });
2481
+ }, {});
2482
+ }
2483
+ removeChallenge(id) {
2484
+ const index = this.challenges.findIndex(challenge => challenge.Id === id);
2485
+ if (index > -1) {
2486
+ this.challenges.splice(index, 1);
2487
+ window.postMessage({ type: 'ChallengeHasExpired', id });
2488
+ }
2489
+ }
2490
+ getChallengeClasses(challenge) {
2491
+ return {
2492
+ ChallengeCard: true,
2493
+ InProgress: challenge.Status === ChallengeProgressStatus.InProgress
2494
+ && !this.pausedChallengeIds.includes(challenge.ChallengeId),
2495
+ Completed: this.isChallengeCompleted(challenge),
2496
+ Paused: this.isChallengePaused(challenge)
2497
+ };
2498
+ }
2499
+ isChallengePaused(challenge) {
2500
+ return (challenge.Status === ChallengeProgressStatus.Started
2501
+ && challenge.LevelProgresses[0].ProgressPercentage > 0)
2502
+ || this.pausedChallengeIds.includes(challenge.ChallengeId);
2503
+ }
2504
+ isChallengeCompleted(challenge) {
2505
+ return challenge.Status === ChallengeProgressStatus.Completed
2506
+ || (challenge.Status === ChallengeProgressStatus.PendingLevelReward
2507
+ && challenge.LevelProgresses.every(progress => progress.ProgressPercentage === 100));
2508
+ }
2509
+ getChallengeProgress(challenge) {
2510
+ if (challenge.Status === ChallengeProgressStatus.Completed) {
2511
+ return 100;
2512
+ }
2513
+ if (this.isChallengePaused(challenge)
2514
+ || challenge.Status === ChallengeProgressStatus.PendingLevelReward
2515
+ || challenge.Status === ChallengeProgressStatus.InProgress) {
2516
+ const activeLevel = challenge.LevelProgresses
2517
+ .find(level => level.ProgressStatus === ChallengeLevelProgressStatus.InProgress);
2518
+ const completedLevel = challenge.LevelProgresses
2519
+ .filter(level => level.ProgressStatus === ChallengeLevelProgressStatus.Fillup ||
2520
+ level.ProgressStatus === ChallengeLevelProgressStatus.Completed).slice(-1)[0];
2521
+ /**
2522
+ * It is possible that Paused/InProgress challenge
2523
+ * doesn't have InProgress, Fillup or Completed level
2524
+ * because level becomes InProgress after user's bet.
2525
+ * In this case should be displayed progress of the next level (0%)
2526
+ */
2527
+ return activeLevel ? activeLevel.ProgressPercentage
2528
+ : (completedLevel ? completedLevel.ProgressPercentage : 0);
2529
+ }
2530
+ return -1;
2531
+ }
2532
+ getChallengeHeaderTemplate(challenge) {
2533
+ const { Id } = challenge;
2534
+ const inProgressChallenge = challenge.Status === ChallengeProgressStatus.InProgress
2535
+ || challenge.Status === ChallengeProgressStatus.PendingLevelReward;
2536
+ return index.h("div", { class: "ChallengeCardHeader" }, index.h("div", { class: "ChallengeName" }, challenge.ChallengePresentation.PresentationName), challenge.Status !== ChallengeProgressStatus.Completed ? (index.h("button", { class: `${inProgressChallenge ?
2537
+ 'ChallengeJoinButton Joined' : 'ChallengeJoinButton'} ${this.isJoiningToChallenge ||
2538
+ this.pausedChallengeIds.includes(challenge.ChallengeId) ?
2539
+ 'Disabled' : ''}`, onClick: this.changeChallengeStatus, "data-id": Id }, inProgressChallenge
2540
+ ? translate('unjoin', this.language)
2541
+ : translate('join', this.language))) : null);
2542
+ }
2543
+ getChallengeTemplate(challenge) {
2544
+ const isForfeitedChallenge = challenge.Status === ChallengeProgressStatus.Forfeited;
2545
+ const challengeProgress = this.getChallengeProgress(challenge);
2546
+ const countdown = this.timers[challenge.Id];
2547
+ const progressTemplate = challengeProgress > -1
2548
+ ? index.h("casino-engagement-suite-progress-bar", { class: this.device, value: challengeProgress, disabled: this.isChallengePaused(challenge) }, index.h("span", { slot: "Title", class: "ChallengeCountdown" }, countdown))
2549
+ : index.h("span", { class: "ChallengeCountdown" }, countdown);
2550
+ return isForfeitedChallenge ? (this.getForfeitedChallengeTemplate(challenge)) : (index.h("div", { class: this.getChallengeClasses(challenge), onClick: this.handleChallengeClick, key: challenge.Id, "data-id": challenge.Id }, this.getChallengeHeaderTemplate(challenge), progressTemplate, index.h("div", { class: `ChallengeLabel ${challenge.IsNew ? 'ShowChallengeLabel' : ''}` }, index.h("span", null, translate('new', this.language)))));
2551
+ }
2552
+ getForfeitedChallengeTemplate(challenge) {
2553
+ return index.h("div", { class: "ChallengeCard ForfeitedChallengeCard" }, index.h("div", { class: "ForfeitedChallengeName" }, challenge.ChallengePresentation.PresentationName), index.h("div", { class: "ForfeitedChallengeInfo" }, index.h("div", null, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/alert-circle.svg", alt: "Forfeited" })), index.h("div", { class: "ForfeitedChallengeMessage" }, index.h("div", null, translate('missionHasBeenForfeited', this.language)), index.h("div", null, translate('support', this.language)))));
2554
+ }
2555
+ getHeaderTemplate() {
2556
+ return index.h("header", { class: "ChallengesListPopupHeader" }, index.h("button", { onClick: this.showTooltip, class: "ChallengesIconButton" }, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg", alt: "Show tooltip" })), index.h("div", { class: "ChallengesListPopupHeaderName" }, translate('missions', this.language)), index.h("button", { class: "ChallengesIconButton", onClick: this.handleCloseClick }, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close missions list" })));
2557
+ }
2558
+ getListTabTemplate() {
2559
+ if (this.challenges.length) {
2560
+ return index.h("div", { class: "ChallengesListWrapper" }, index.h("div", { class: "ChallengesList" }, [...this.challenges]
2561
+ .sort(challenge => challenge.Status === ChallengeProgressStatus.InProgress ? -1 : 0)
2562
+ .map(challenge => this.getChallengeTemplate(challenge))));
2563
+ }
2564
+ else {
2565
+ return index.h("div", { class: "ChallengesListEmpty" }, index.h("h2", null, translate('noMissions', this.language)), index.h("p", null, translate('tryOtherGames', this.language)));
2566
+ }
2567
+ }
2568
+ getTooltipTemplate() {
2569
+ return index.h("div", { class: "ChallengesTooltipBackdrop" }, index.h("div", { class: "ChallengesTooltip" }, index.h("button", { class: "ChallengesIconButton", onClick: this.hideTooltip }, index.h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close tooltip" })), translate('tooltip', this.language)));
2570
+ }
2571
+ getHistoryTabTemplate() {
2572
+ return index.h("div", { class: "HistoryWrapper" }, index.h("div", { class: "HistoryCols" }, index.h("div", { class: "HistoryColName Level" }, translate('level', this.language)), index.h("div", { class: "HistoryColName Status" }, translate('status', this.language)), index.h("div", { class: "HistoryColName Time" }, translate('time', this.language))), this.historyLoading
2573
+ ? getHistoryLoaderTemplate(this.language)
2574
+ : getChallengesHistoryTemplate(this.challengesHistory, this.openedHistoryIds, this.toggleChallengeHistory, this.language));
2575
+ }
2576
+ getTabsTemplate() {
2577
+ return index.h("div", { class: "TabsWrapper" }, index.h("div", { class: "Tabs" }, index.h("div", { "data-index": "1", onClick: this.handleTabChange, class: `Tab ${this.activeTab === 1 ? 'Active' : ''}` }, translate('missions', this.language)), index.h("div", { "data-index": "2", onClick: this.handleTabChange, class: `Tab ${this.activeTab === 2 ? 'Active' : ''}` }, translate('history', this.language))));
2578
+ }
2579
+ getTabsContentTemplate() {
2580
+ return this.activeTab === 1
2581
+ ? this.getListTabTemplate()
2582
+ : this.getHistoryTabTemplate();
2583
+ }
2584
+ render() {
2585
+ return index.h("div", { key: 'c97094033153bc81185e96ab77da5f3bd7618d36', class: `ChallengesListPopup ${this.device}` }, this.getHeaderTemplate(), this.getTabsTemplate(), this.getTabsContentTemplate(), this.tooltip && this.getTooltipTemplate());
2586
+ }
2587
+ get host() { return index.getElement(this); }
2588
+ static get watchers() { return {
2589
+ "challenges": ["challengesPropHandler"]
2590
+ }; }
2591
+ };
2592
+ CasinoEngagementSuiteChallengesList.style = CasinoEngagementSuiteChallengesListStyle0;
2593
+
2594
+ const casinoEngagementSuiteProgressBarCss = ":host{display:block;font-family:inherit}:host(.Desktop) .ProgressBarPercent{font-size:14px;line-height:14px}.ProgressBarBackground{height:8px;background-color:var(--emw--color-background, #666178);border-radius:4px;position:relative}.ProgressBarLine{position:absolute;left:0;top:0;bottom:0;border-radius:4px;background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);transition:width ease-out 0.3s}.ProgressBarInfo{margin-bottom:8px;display:flex;justify-content:space-between;align-items:center}.ProgressBarPercent{font-weight:700;font-size:12px;line-height:12px}.HidePercent .ProgressBarPercent{display:none}.ProgressBar:not(.Disabled) .ProgressBarPercent{background:linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ProgressBar.Disabled .ProgressBarPercent{color:var(--emw--color-background, #666178)}.ProgressBar.Disabled .ProgressBarLine{background:var(--emw--color-background-secondary, #474668)}";
2595
+ const CasinoEngagementSuiteProgressBarStyle0 = casinoEngagementSuiteProgressBarCss;
2596
+
2597
+ const CasinoEngagementSuiteProgressBar = class {
2598
+ constructor(hostRef) {
2599
+ index.registerInstance(this, hostRef);
2600
+ this.setClientStyling = () => {
2601
+ let sheet = document.createElement('style');
2602
+ sheet.innerHTML = this.clientStyling;
2603
+ this.host.prepend(sheet);
2604
+ };
2605
+ this.setClientStylingURL = () => {
2606
+ let url = new URL(this.clientStylingUrl);
2607
+ let cssFile = document.createElement('style');
2608
+ fetch(url.href)
2609
+ .then((res) => res.text())
2610
+ .then((data) => {
2611
+ cssFile.innerHTML = data;
2612
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
2613
+ })
2614
+ .catch((err) => {
2615
+ console.log('Error ', err);
2616
+ });
2617
+ };
2618
+ this.value = 0;
2619
+ this.disabled = false;
2620
+ this.hidePercent = false;
2621
+ this.indeterminate = false;
2622
+ this.clientStyling = '';
2623
+ this.clientStylingUrl = '';
2624
+ this.limitStylingAppends = false;
2625
+ }
2626
+ componentDidRender() {
2627
+ if (!this.limitStylingAppends && this.host) {
2628
+ if (this.clientStyling)
2629
+ this.setClientStyling();
2630
+ if (this.clientStylingUrl)
2631
+ this.setClientStylingURL();
2632
+ this.limitStylingAppends = true;
2633
+ }
2634
+ }
2635
+ getProgressBarClasses() {
2636
+ return {
2637
+ ProgressBar: true,
2638
+ Completed: this.value === 100,
2639
+ Disabled: this.disabled,
2640
+ HidePercent: this.hidePercent || this.indeterminate
2641
+ };
2642
+ }
2643
+ getProgressBarLineTemplate() {
2644
+ if (this.indeterminate) {
2645
+ return index.h("div", { class: "ProgressBarLine Indeterminate", part: "ProgressBarLine Indeterminate" });
2646
+ }
2647
+ else {
2648
+ return index.h("div", { class: "ProgressBarLine", part: "ProgressBarLine", style: { width: this.value + '%' } });
2649
+ }
2650
+ }
2651
+ render() {
2652
+ return index.h("div", { key: 'ecce3a26a92d2e090c1db84bdc1bdbeb505080ed', class: this.getProgressBarClasses(), part: "ProgressBar" }, index.h("div", { key: '649fe1103d222200f2a1ad3b5967e37da1f1ab3d', class: "ProgressBarInfo", part: "ProgressBarInfo" }, index.h("slot", { key: '49dc180eedd823f0027f75099813fb9d91bcd938', name: "Title" }, index.h("div", { key: 'e6e59da3fe7bbcb37e118e7fd23a8ff35587aca5' })), index.h("slot", { key: '3dc8e5fd1dbc8c268b9c76e393b751cb53605e7e', name: "Percent" }, index.h("div", { key: '6a9e880f3ee3c4f26e8577c69be5db5f8e2d10ad', class: "ProgressBarPercent", part: "ProgressBarPercent" }, this.value, "%"))), index.h("div", { key: '141106e77caad7b04bb199f911e87c0c6f0adc2d', class: "ProgressBarBackground", part: "ProgressBarBackground" }, this.getProgressBarLineTemplate()));
2653
+ }
2654
+ get host() { return index.getElement(this); }
2655
+ };
2656
+ CasinoEngagementSuiteProgressBar.style = CasinoEngagementSuiteProgressBarStyle0;
2657
+
2658
+ exports.casino_engagement_suite_challenges_list = CasinoEngagementSuiteChallengesList;
2659
+ exports.casino_engagement_suite_progress_bar = CasinoEngagementSuiteProgressBar;