@everymatrix/casino-engagement-suite-challenges-list 1.39.2 → 1.40.0

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