@everymatrix/lottery-hakuna-ticket-history 0.0.1

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