@everymatrix/lottery-tipping-ticket-controller 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/general-tooltip_6.cjs.entry.js +8888 -0
  3. package/dist/cjs/index-db2858c7.js +1376 -0
  4. package/dist/cjs/index.cjs.js +10 -0
  5. package/dist/cjs/loader.cjs.js +15 -0
  6. package/dist/cjs/lottery-tipping-ticket-controller-0f34247f.js +3081 -0
  7. package/dist/cjs/lottery-tipping-ticket-controller.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +28 -0
  9. package/dist/collection/components/lottery-tipping-ticket-banner/index.js +1 -0
  10. package/dist/collection/components/lottery-tipping-ticket-banner/locale.utils.js +35 -0
  11. package/dist/collection/components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.css +68 -0
  12. package/dist/collection/components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.js +224 -0
  13. package/dist/collection/components/lottery-tipping-ticket-controller/index.js +1 -0
  14. package/dist/collection/components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.css +198 -0
  15. package/dist/collection/components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.js +570 -0
  16. package/dist/collection/components/static/loading.svg +10 -0
  17. package/dist/collection/components/static/tipping-full-color.svg +15 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/models/index.js +11 -0
  20. package/dist/collection/utils/locale.utils.js +105 -0
  21. package/dist/collection/utils/utils.js +130 -0
  22. package/dist/esm/app-globals-0f993ce5.js +3 -0
  23. package/dist/esm/general-tooltip_6.entry.js +8880 -0
  24. package/dist/esm/index-f0e9db16.js +1347 -0
  25. package/dist/esm/index.js +2 -0
  26. package/dist/esm/loader.js +11 -0
  27. package/dist/esm/lottery-tipping-ticket-controller-f0dd1981.js +3070 -0
  28. package/dist/esm/lottery-tipping-ticket-controller.js +20 -0
  29. package/dist/index.cjs.js +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/lottery-tipping-ticket-controller/app-globals-0f993ce5.js +1 -0
  32. package/dist/lottery-tipping-ticket-controller/general-tooltip_6.entry.js +7975 -0
  33. package/dist/lottery-tipping-ticket-controller/index-f0e9db16.js +2 -0
  34. package/dist/lottery-tipping-ticket-controller/index.esm.js +1 -0
  35. package/dist/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller-f0dd1981.js +1 -0
  36. package/dist/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.esm.js +1 -0
  37. package/dist/static/add.svg +8 -0
  38. package/dist/static/delete.svg +37 -0
  39. package/dist/static/info.svg +6 -0
  40. package/dist/static/left-arrow.svg +15 -0
  41. package/dist/static/loading.svg +10 -0
  42. package/dist/static/right-arrow.svg +15 -0
  43. package/dist/static/tipping-full-color.svg +15 -0
  44. package/dist/stencil.config.dev.js +19 -0
  45. package/dist/stencil.config.js +19 -0
  46. package/dist/storybook/main.js +43 -0
  47. package/dist/storybook/preview.js +9 -0
  48. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  49. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/packages/stencil/lottery-tipping-ticket-controller/stencil.config.d.ts +2 -0
  50. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/packages/stencil/lottery-tipping-ticket-controller/stencil.config.dev.d.ts +2 -0
  51. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/packages/stencil/lottery-tipping-ticket-controller/storybook/main.d.ts +3 -0
  52. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/packages/stencil/lottery-tipping-ticket-controller/storybook/preview.d.ts +70 -0
  53. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/tools/plugins/index.d.ts +3 -0
  54. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  55. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  56. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/lottery-tipping-ticket-controller/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  57. package/dist/types/components/lottery-tipping-ticket-banner/index.d.ts +1 -0
  58. package/dist/types/components/lottery-tipping-ticket-banner/locale.utils.d.ts +2 -0
  59. package/dist/types/components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.d.ts +22 -0
  60. package/dist/types/components/lottery-tipping-ticket-controller/index.d.ts +1 -0
  61. package/dist/types/components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.d.ts +113 -0
  62. package/dist/types/components.d.ts +180 -0
  63. package/dist/types/index.d.ts +1 -0
  64. package/dist/types/models/index.d.ts +14 -0
  65. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  66. package/dist/types/utils/locale.utils.d.ts +3 -0
  67. package/dist/types/utils/utils.d.ts +50 -0
  68. package/loader/cdn.js +1 -0
  69. package/loader/index.cjs.js +1 -0
  70. package/loader/index.d.ts +24 -0
  71. package/loader/index.es2017.js +1 -0
  72. package/loader/index.js +2 -0
  73. package/loader/package.json +11 -0
  74. package/package.json +27 -0
@@ -0,0 +1,3081 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-db2858c7.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
+ const url = new URL(clientStylingUrl);
27
+
28
+ fetch(url.href)
29
+ .then((res) => res.text())
30
+ .then((data) => {
31
+ const cssFile = document.createElement('style');
32
+ cssFile.innerHTML = data;
33
+ if (stylingContainer) {
34
+ stylingContainer.appendChild(cssFile);
35
+ }
36
+ })
37
+ .catch((err) => {
38
+ console.error('There was an error while trying to load client styling from URL', err);
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @name setStreamLibrary
44
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
45
+ * @param {HTMLElement} stylingContainer The highest element of the widget
46
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
48
+ */
49
+ function setStreamStyling(stylingContainer, domain, subscription) {
50
+ if (window.emMessageBus) {
51
+ const sheet = document.createElement('style');
52
+
53
+ window.emMessageBus.subscribe(domain, (data) => {
54
+ sheet.innerHTML = data;
55
+ if (stylingContainer) {
56
+ stylingContainer.appendChild(sheet);
57
+ }
58
+ });
59
+ }
60
+ }
61
+
62
+ var PlayModeEnum;
63
+ (function (PlayModeEnum) {
64
+ PlayModeEnum["SingleBet"] = "SingleBet";
65
+ PlayModeEnum["SystemBet"] = "SystemBet";
66
+ })(PlayModeEnum || (PlayModeEnum = {}));
67
+ var BettingTypeEnum;
68
+ (function (BettingTypeEnum) {
69
+ BettingTypeEnum["FullTime"] = "FullTime";
70
+ BettingTypeEnum["HalfTime"] = "HalfTime";
71
+ BettingTypeEnum["Both"] = "Both";
72
+ })(BettingTypeEnum || (BettingTypeEnum = {}));
73
+
74
+ const DEFAULT_LANGUAGE = 'en';
75
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
76
+ const TRANSLATIONS = {
77
+ en: {
78
+ selectionCleared: 'Your selection will be cleared.',
79
+ ticketSubmitted: 'Ticket submitted successfully.',
80
+ ticketFailed: 'Failed to purchase the ticket. Please try again.',
81
+ lines: 'Lines',
82
+ line: 'Line',
83
+ bettingType: 'Betting Type',
84
+ playingMode: 'Playing Mode',
85
+ orderSummaryTitle: 'Order Summary',
86
+ orderSummaryTickets: 'Tickets',
87
+ orderSummaryTotal: 'Total',
88
+ orderSummarySubmit: 'Submit',
89
+ cancel: 'Cancel',
90
+ confirm: 'Confirm'
91
+ },
92
+ ro: {
93
+ selectionCleared: 'Selecția dvs. va fi ștearsă.',
94
+ ticketSubmitted: 'Bilet trimis cu succes.',
95
+ ticketFailed: 'Nu s-a putut achiziționa biletul. Vă rugăm să încercați din nou.',
96
+ lines: 'Linii',
97
+ line: 'Linie',
98
+ bettingType: 'Tip de pariu',
99
+ playingMode: 'Mod de joc',
100
+ orderSummaryTitle: 'Sumar comandă',
101
+ orderSummaryTickets: 'Bilete',
102
+ orderSummaryTotal: 'Total',
103
+ orderSummarySubmit: 'Trimite',
104
+ cancel: 'Anulează',
105
+ confirm: 'Confirmă'
106
+ },
107
+ fr: {
108
+ selectionCleared: 'Votre sélection sera effacée.',
109
+ ticketSubmitted: 'Billet soumis avec succès.',
110
+ ticketFailed: "Échec de l'achat du billet. Veuillez réessayer.",
111
+ lines: 'Lignes',
112
+ line: 'Ligne',
113
+ bettingType: 'Type de pari',
114
+ playingMode: 'Mode de jeu',
115
+ orderSummaryTitle: 'Résumé de la commande',
116
+ orderSummaryTickets: 'Billets',
117
+ orderSummaryTotal: 'Total',
118
+ orderSummarySubmit: 'Soumettre',
119
+ cancel: 'Annuler',
120
+ confirm: 'Confirmer'
121
+ },
122
+ ar: {
123
+ selectionCleared: 'سيتم مسح اختيارك.',
124
+ ticketSubmitted: 'تم إرسال التذكرة بنجاح.',
125
+ ticketFailed: 'فشل شراء التذكرة. يرجى المحاولة مرة أخرى.',
126
+ lines: 'خطوط',
127
+ line: 'خط',
128
+ bettingType: 'نوع الرهان',
129
+ playingMode: 'وضع اللعب',
130
+ orderSummaryTitle: 'ملخص الطلب',
131
+ orderSummaryTickets: 'التذاكر',
132
+ orderSummaryTotal: 'المجموع',
133
+ orderSummarySubmit: 'إرسال',
134
+ cancel: 'إلغاء',
135
+ confirm: 'تأكيد'
136
+ },
137
+ hr: {
138
+ selectionCleared: 'Vaš odabir bit će obrisan.',
139
+ ticketSubmitted: 'Listić je uspješno predan.',
140
+ ticketFailed: 'Kupnja listića nije uspjela. Molimo pokušajte ponovo.',
141
+ lines: 'Linije',
142
+ line: 'Linija',
143
+ bettingType: 'Vrsta oklade',
144
+ playingMode: 'Način igranja',
145
+ orderSummaryTitle: 'Sažetak narudžbe',
146
+ orderSummaryTickets: 'Listići',
147
+ orderSummaryTotal: 'Ukupno',
148
+ orderSummarySubmit: 'Pošalji',
149
+ cancel: 'Odustani',
150
+ confirm: 'Potvrdi'
151
+ }
152
+ };
153
+ const translate = (key, customLang) => {
154
+ const lang = customLang;
155
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
156
+ };
157
+ const getTranslations = (data) => {
158
+ Object.keys(data).forEach((item) => {
159
+ for (let key in data[item]) {
160
+ TRANSLATIONS[item][key] = data[item][key];
161
+ }
162
+ });
163
+ };
164
+ const resolveTranslationUrl = async (translationUrl) => {
165
+ if (translationUrl) {
166
+ try {
167
+ const response = await fetch(translationUrl);
168
+ if (!response.ok) {
169
+ throw new Error(`HTTP error! status: ${response.status}`);
170
+ }
171
+ const translations = await response.json();
172
+ getTranslations(translations);
173
+ }
174
+ catch (error) {
175
+ console.error('Failed to fetch or parse translations from URL:', error);
176
+ }
177
+ }
178
+ };
179
+
180
+ function _typeof(o) {
181
+ "@babel/helpers - typeof";
182
+
183
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
184
+ return typeof o;
185
+ } : function (o) {
186
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
187
+ }, _typeof(o);
188
+ }
189
+
190
+ function toInteger(dirtyNumber) {
191
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
192
+ return NaN;
193
+ }
194
+ var number = Number(dirtyNumber);
195
+ if (isNaN(number)) {
196
+ return number;
197
+ }
198
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
199
+ }
200
+
201
+ function requiredArgs(required, args) {
202
+ if (args.length < required) {
203
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
204
+ }
205
+ }
206
+
207
+ /**
208
+ * @name toDate
209
+ * @category Common Helpers
210
+ * @summary Convert the given argument to an instance of Date.
211
+ *
212
+ * @description
213
+ * Convert the given argument to an instance of Date.
214
+ *
215
+ * If the argument is an instance of Date, the function returns its clone.
216
+ *
217
+ * If the argument is a number, it is treated as a timestamp.
218
+ *
219
+ * If the argument is none of the above, the function returns Invalid Date.
220
+ *
221
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
222
+ *
223
+ * @param {Date|Number} argument - the value to convert
224
+ * @returns {Date} the parsed date in the local time zone
225
+ * @throws {TypeError} 1 argument required
226
+ *
227
+ * @example
228
+ * // Clone the date:
229
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
230
+ * //=> Tue Feb 11 2014 11:30:30
231
+ *
232
+ * @example
233
+ * // Convert the timestamp to date:
234
+ * const result = toDate(1392098430000)
235
+ * //=> Tue Feb 11 2014 11:30:30
236
+ */
237
+ function toDate(argument) {
238
+ requiredArgs(1, arguments);
239
+ var argStr = Object.prototype.toString.call(argument);
240
+
241
+ // Clone the date
242
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
243
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
244
+ return new Date(argument.getTime());
245
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
246
+ return new Date(argument);
247
+ } else {
248
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
249
+ // eslint-disable-next-line no-console
250
+ 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");
251
+ // eslint-disable-next-line no-console
252
+ console.warn(new Error().stack);
253
+ }
254
+ return new Date(NaN);
255
+ }
256
+ }
257
+
258
+ /**
259
+ * @name addMilliseconds
260
+ * @category Millisecond Helpers
261
+ * @summary Add the specified number of milliseconds to the given date.
262
+ *
263
+ * @description
264
+ * Add the specified number of milliseconds to the given date.
265
+ *
266
+ * @param {Date|Number} date - the date to be changed
267
+ * @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`.
268
+ * @returns {Date} the new date with the milliseconds added
269
+ * @throws {TypeError} 2 arguments required
270
+ *
271
+ * @example
272
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
273
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
274
+ * //=> Thu Jul 10 2014 12:45:30.750
275
+ */
276
+ function addMilliseconds(dirtyDate, dirtyAmount) {
277
+ requiredArgs(2, arguments);
278
+ var timestamp = toDate(dirtyDate).getTime();
279
+ var amount = toInteger(dirtyAmount);
280
+ return new Date(timestamp + amount);
281
+ }
282
+
283
+ var defaultOptions = {};
284
+ function getDefaultOptions() {
285
+ return defaultOptions;
286
+ }
287
+
288
+ /**
289
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
290
+ * They usually appear for dates that denote time before the timezones were introduced
291
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
292
+ * and GMT+01:00:00 after that date)
293
+ *
294
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
295
+ * which would lead to incorrect calculations.
296
+ *
297
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
298
+ */
299
+ function getTimezoneOffsetInMilliseconds(date) {
300
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
301
+ utcDate.setUTCFullYear(date.getFullYear());
302
+ return date.getTime() - utcDate.getTime();
303
+ }
304
+
305
+ /**
306
+ * Days in 1 week.
307
+ *
308
+ * @name daysInWeek
309
+ * @constant
310
+ * @type {number}
311
+ * @default
312
+ */
313
+
314
+ /**
315
+ * Milliseconds in 1 minute
316
+ *
317
+ * @name millisecondsInMinute
318
+ * @constant
319
+ * @type {number}
320
+ * @default
321
+ */
322
+ var millisecondsInMinute = 60000;
323
+
324
+ /**
325
+ * Milliseconds in 1 hour
326
+ *
327
+ * @name millisecondsInHour
328
+ * @constant
329
+ * @type {number}
330
+ * @default
331
+ */
332
+ var millisecondsInHour = 3600000;
333
+
334
+ /**
335
+ * @name isDate
336
+ * @category Common Helpers
337
+ * @summary Is the given value a date?
338
+ *
339
+ * @description
340
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
341
+ *
342
+ * @param {*} value - the value to check
343
+ * @returns {boolean} true if the given value is a date
344
+ * @throws {TypeError} 1 arguments required
345
+ *
346
+ * @example
347
+ * // For a valid date:
348
+ * const result = isDate(new Date())
349
+ * //=> true
350
+ *
351
+ * @example
352
+ * // For an invalid date:
353
+ * const result = isDate(new Date(NaN))
354
+ * //=> true
355
+ *
356
+ * @example
357
+ * // For some value:
358
+ * const result = isDate('2014-02-31')
359
+ * //=> false
360
+ *
361
+ * @example
362
+ * // For an object:
363
+ * const result = isDate({})
364
+ * //=> false
365
+ */
366
+ function isDate(value) {
367
+ requiredArgs(1, arguments);
368
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
369
+ }
370
+
371
+ /**
372
+ * @name isValid
373
+ * @category Common Helpers
374
+ * @summary Is the given date valid?
375
+ *
376
+ * @description
377
+ * Returns false if argument is Invalid Date and true otherwise.
378
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
379
+ * Invalid Date is a Date, whose time value is NaN.
380
+ *
381
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
382
+ *
383
+ * @param {*} date - the date to check
384
+ * @returns {Boolean} the date is valid
385
+ * @throws {TypeError} 1 argument required
386
+ *
387
+ * @example
388
+ * // For the valid date:
389
+ * const result = isValid(new Date(2014, 1, 31))
390
+ * //=> true
391
+ *
392
+ * @example
393
+ * // For the value, convertable into a date:
394
+ * const result = isValid(1393804800000)
395
+ * //=> true
396
+ *
397
+ * @example
398
+ * // For the invalid date:
399
+ * const result = isValid(new Date(''))
400
+ * //=> false
401
+ */
402
+ function isValid(dirtyDate) {
403
+ requiredArgs(1, arguments);
404
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
405
+ return false;
406
+ }
407
+ var date = toDate(dirtyDate);
408
+ return !isNaN(Number(date));
409
+ }
410
+
411
+ /**
412
+ * @name subMilliseconds
413
+ * @category Millisecond Helpers
414
+ * @summary Subtract the specified number of milliseconds from the given date.
415
+ *
416
+ * @description
417
+ * Subtract the specified number of milliseconds from the given date.
418
+ *
419
+ * @param {Date|Number} date - the date to be changed
420
+ * @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`.
421
+ * @returns {Date} the new date with the milliseconds subtracted
422
+ * @throws {TypeError} 2 arguments required
423
+ *
424
+ * @example
425
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
426
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
427
+ * //=> Thu Jul 10 2014 12:45:29.250
428
+ */
429
+ function subMilliseconds(dirtyDate, dirtyAmount) {
430
+ requiredArgs(2, arguments);
431
+ var amount = toInteger(dirtyAmount);
432
+ return addMilliseconds(dirtyDate, -amount);
433
+ }
434
+
435
+ var MILLISECONDS_IN_DAY = 86400000;
436
+ function getUTCDayOfYear(dirtyDate) {
437
+ requiredArgs(1, arguments);
438
+ var date = toDate(dirtyDate);
439
+ var timestamp = date.getTime();
440
+ date.setUTCMonth(0, 1);
441
+ date.setUTCHours(0, 0, 0, 0);
442
+ var startOfYearTimestamp = date.getTime();
443
+ var difference = timestamp - startOfYearTimestamp;
444
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
445
+ }
446
+
447
+ function startOfUTCISOWeek(dirtyDate) {
448
+ requiredArgs(1, arguments);
449
+ var weekStartsOn = 1;
450
+ var date = toDate(dirtyDate);
451
+ var day = date.getUTCDay();
452
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
453
+ date.setUTCDate(date.getUTCDate() - diff);
454
+ date.setUTCHours(0, 0, 0, 0);
455
+ return date;
456
+ }
457
+
458
+ function getUTCISOWeekYear(dirtyDate) {
459
+ requiredArgs(1, arguments);
460
+ var date = toDate(dirtyDate);
461
+ var year = date.getUTCFullYear();
462
+ var fourthOfJanuaryOfNextYear = new Date(0);
463
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
464
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
465
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
466
+ var fourthOfJanuaryOfThisYear = new Date(0);
467
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
468
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
469
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
470
+ if (date.getTime() >= startOfNextYear.getTime()) {
471
+ return year + 1;
472
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
473
+ return year;
474
+ } else {
475
+ return year - 1;
476
+ }
477
+ }
478
+
479
+ function startOfUTCISOWeekYear(dirtyDate) {
480
+ requiredArgs(1, arguments);
481
+ var year = getUTCISOWeekYear(dirtyDate);
482
+ var fourthOfJanuary = new Date(0);
483
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
484
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
485
+ var date = startOfUTCISOWeek(fourthOfJanuary);
486
+ return date;
487
+ }
488
+
489
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
490
+ function getUTCISOWeek(dirtyDate) {
491
+ requiredArgs(1, arguments);
492
+ var date = toDate(dirtyDate);
493
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
494
+
495
+ // Round the number of days to the nearest integer
496
+ // because the number of milliseconds in a week is not constant
497
+ // (e.g. it's different in the week of the daylight saving time clock shift)
498
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
499
+ }
500
+
501
+ function startOfUTCWeek(dirtyDate, options) {
502
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
503
+ requiredArgs(1, arguments);
504
+ var defaultOptions = getDefaultOptions();
505
+ 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);
506
+
507
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
508
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
509
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
510
+ }
511
+ var date = toDate(dirtyDate);
512
+ var day = date.getUTCDay();
513
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
514
+ date.setUTCDate(date.getUTCDate() - diff);
515
+ date.setUTCHours(0, 0, 0, 0);
516
+ return date;
517
+ }
518
+
519
+ function getUTCWeekYear(dirtyDate, options) {
520
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
521
+ requiredArgs(1, arguments);
522
+ var date = toDate(dirtyDate);
523
+ var year = date.getUTCFullYear();
524
+ var defaultOptions = getDefaultOptions();
525
+ 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);
526
+
527
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
528
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
529
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
530
+ }
531
+ var firstWeekOfNextYear = new Date(0);
532
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
533
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
534
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
535
+ var firstWeekOfThisYear = new Date(0);
536
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
537
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
538
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
539
+ if (date.getTime() >= startOfNextYear.getTime()) {
540
+ return year + 1;
541
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
542
+ return year;
543
+ } else {
544
+ return year - 1;
545
+ }
546
+ }
547
+
548
+ function startOfUTCWeekYear(dirtyDate, options) {
549
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
550
+ requiredArgs(1, arguments);
551
+ var defaultOptions = getDefaultOptions();
552
+ 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);
553
+ var year = getUTCWeekYear(dirtyDate, options);
554
+ var firstWeek = new Date(0);
555
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
556
+ firstWeek.setUTCHours(0, 0, 0, 0);
557
+ var date = startOfUTCWeek(firstWeek, options);
558
+ return date;
559
+ }
560
+
561
+ var MILLISECONDS_IN_WEEK = 604800000;
562
+ function getUTCWeek(dirtyDate, options) {
563
+ requiredArgs(1, arguments);
564
+ var date = toDate(dirtyDate);
565
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
566
+
567
+ // Round the number of days to the nearest integer
568
+ // because the number of milliseconds in a week is not constant
569
+ // (e.g. it's different in the week of the daylight saving time clock shift)
570
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
571
+ }
572
+
573
+ function addLeadingZeros(number, targetLength) {
574
+ var sign = number < 0 ? '-' : '';
575
+ var output = Math.abs(number).toString();
576
+ while (output.length < targetLength) {
577
+ output = '0' + output;
578
+ }
579
+ return sign + output;
580
+ }
581
+
582
+ /*
583
+ * | | Unit | | Unit |
584
+ * |-----|--------------------------------|-----|--------------------------------|
585
+ * | a | AM, PM | A* | |
586
+ * | d | Day of month | D | |
587
+ * | h | Hour [1-12] | H | Hour [0-23] |
588
+ * | m | Minute | M | Month |
589
+ * | s | Second | S | Fraction of second |
590
+ * | y | Year (abs) | Y | |
591
+ *
592
+ * Letters marked by * are not implemented but reserved by Unicode standard.
593
+ */
594
+ var formatters$2 = {
595
+ // Year
596
+ y: function y(date, token) {
597
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
598
+ // | Year | y | yy | yyy | yyyy | yyyyy |
599
+ // |----------|-------|----|-------|-------|-------|
600
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
601
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
602
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
603
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
604
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
605
+
606
+ var signedYear = date.getUTCFullYear();
607
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
608
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
609
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
610
+ },
611
+ // Month
612
+ M: function M(date, token) {
613
+ var month = date.getUTCMonth();
614
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
615
+ },
616
+ // Day of the month
617
+ d: function d(date, token) {
618
+ return addLeadingZeros(date.getUTCDate(), token.length);
619
+ },
620
+ // AM or PM
621
+ a: function a(date, token) {
622
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
623
+ switch (token) {
624
+ case 'a':
625
+ case 'aa':
626
+ return dayPeriodEnumValue.toUpperCase();
627
+ case 'aaa':
628
+ return dayPeriodEnumValue;
629
+ case 'aaaaa':
630
+ return dayPeriodEnumValue[0];
631
+ case 'aaaa':
632
+ default:
633
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
634
+ }
635
+ },
636
+ // Hour [1-12]
637
+ h: function h(date, token) {
638
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
639
+ },
640
+ // Hour [0-23]
641
+ H: function H(date, token) {
642
+ return addLeadingZeros(date.getUTCHours(), token.length);
643
+ },
644
+ // Minute
645
+ m: function m(date, token) {
646
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
647
+ },
648
+ // Second
649
+ s: function s(date, token) {
650
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
651
+ },
652
+ // Fraction of second
653
+ S: function S(date, token) {
654
+ var numberOfDigits = token.length;
655
+ var milliseconds = date.getUTCMilliseconds();
656
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
657
+ return addLeadingZeros(fractionalSeconds, token.length);
658
+ }
659
+ };
660
+ const formatters$3 = formatters$2;
661
+
662
+ var dayPeriodEnum = {
663
+ am: 'am',
664
+ pm: 'pm',
665
+ midnight: 'midnight',
666
+ noon: 'noon',
667
+ morning: 'morning',
668
+ afternoon: 'afternoon',
669
+ evening: 'evening',
670
+ night: 'night'
671
+ };
672
+ /*
673
+ * | | Unit | | Unit |
674
+ * |-----|--------------------------------|-----|--------------------------------|
675
+ * | a | AM, PM | A* | Milliseconds in day |
676
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
677
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
678
+ * | d | Day of month | D | Day of year |
679
+ * | e | Local day of week | E | Day of week |
680
+ * | f | | F* | Day of week in month |
681
+ * | g* | Modified Julian day | G | Era |
682
+ * | h | Hour [1-12] | H | Hour [0-23] |
683
+ * | i! | ISO day of week | I! | ISO week of year |
684
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
685
+ * | k | Hour [1-24] | K | Hour [0-11] |
686
+ * | l* | (deprecated) | L | Stand-alone month |
687
+ * | m | Minute | M | Month |
688
+ * | n | | N | |
689
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
690
+ * | p! | Long localized time | P! | Long localized date |
691
+ * | q | Stand-alone quarter | Q | Quarter |
692
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
693
+ * | s | Second | S | Fraction of second |
694
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
695
+ * | u | Extended year | U* | Cyclic year |
696
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
697
+ * | w | Local week of year | W* | Week of month |
698
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
699
+ * | y | Year (abs) | Y | Local week-numbering year |
700
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
701
+ *
702
+ * Letters marked by * are not implemented but reserved by Unicode standard.
703
+ *
704
+ * Letters marked by ! are non-standard, but implemented by date-fns:
705
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
706
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
707
+ * i.e. 7 for Sunday, 1 for Monday, etc.
708
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
709
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
710
+ * `R` is supposed to be used in conjunction with `I` and `i`
711
+ * for universal ISO week-numbering date, whereas
712
+ * `Y` is supposed to be used in conjunction with `w` and `e`
713
+ * for week-numbering date specific to the locale.
714
+ * - `P` is long localized date format
715
+ * - `p` is long localized time format
716
+ */
717
+
718
+ var formatters = {
719
+ // Era
720
+ G: function G(date, token, localize) {
721
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
722
+ switch (token) {
723
+ // AD, BC
724
+ case 'G':
725
+ case 'GG':
726
+ case 'GGG':
727
+ return localize.era(era, {
728
+ width: 'abbreviated'
729
+ });
730
+ // A, B
731
+ case 'GGGGG':
732
+ return localize.era(era, {
733
+ width: 'narrow'
734
+ });
735
+ // Anno Domini, Before Christ
736
+ case 'GGGG':
737
+ default:
738
+ return localize.era(era, {
739
+ width: 'wide'
740
+ });
741
+ }
742
+ },
743
+ // Year
744
+ y: function y(date, token, localize) {
745
+ // Ordinal number
746
+ if (token === 'yo') {
747
+ var signedYear = date.getUTCFullYear();
748
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
749
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
750
+ return localize.ordinalNumber(year, {
751
+ unit: 'year'
752
+ });
753
+ }
754
+ return formatters$3.y(date, token);
755
+ },
756
+ // Local week-numbering year
757
+ Y: function Y(date, token, localize, options) {
758
+ var signedWeekYear = getUTCWeekYear(date, options);
759
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
760
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
761
+
762
+ // Two digit year
763
+ if (token === 'YY') {
764
+ var twoDigitYear = weekYear % 100;
765
+ return addLeadingZeros(twoDigitYear, 2);
766
+ }
767
+
768
+ // Ordinal number
769
+ if (token === 'Yo') {
770
+ return localize.ordinalNumber(weekYear, {
771
+ unit: 'year'
772
+ });
773
+ }
774
+
775
+ // Padding
776
+ return addLeadingZeros(weekYear, token.length);
777
+ },
778
+ // ISO week-numbering year
779
+ R: function R(date, token) {
780
+ var isoWeekYear = getUTCISOWeekYear(date);
781
+
782
+ // Padding
783
+ return addLeadingZeros(isoWeekYear, token.length);
784
+ },
785
+ // Extended year. This is a single number designating the year of this calendar system.
786
+ // The main difference between `y` and `u` localizers are B.C. years:
787
+ // | Year | `y` | `u` |
788
+ // |------|-----|-----|
789
+ // | AC 1 | 1 | 1 |
790
+ // | BC 1 | 1 | 0 |
791
+ // | BC 2 | 2 | -1 |
792
+ // Also `yy` always returns the last two digits of a year,
793
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
794
+ u: function u(date, token) {
795
+ var year = date.getUTCFullYear();
796
+ return addLeadingZeros(year, token.length);
797
+ },
798
+ // Quarter
799
+ Q: function Q(date, token, localize) {
800
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
801
+ switch (token) {
802
+ // 1, 2, 3, 4
803
+ case 'Q':
804
+ return String(quarter);
805
+ // 01, 02, 03, 04
806
+ case 'QQ':
807
+ return addLeadingZeros(quarter, 2);
808
+ // 1st, 2nd, 3rd, 4th
809
+ case 'Qo':
810
+ return localize.ordinalNumber(quarter, {
811
+ unit: 'quarter'
812
+ });
813
+ // Q1, Q2, Q3, Q4
814
+ case 'QQQ':
815
+ return localize.quarter(quarter, {
816
+ width: 'abbreviated',
817
+ context: 'formatting'
818
+ });
819
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
820
+ case 'QQQQQ':
821
+ return localize.quarter(quarter, {
822
+ width: 'narrow',
823
+ context: 'formatting'
824
+ });
825
+ // 1st quarter, 2nd quarter, ...
826
+ case 'QQQQ':
827
+ default:
828
+ return localize.quarter(quarter, {
829
+ width: 'wide',
830
+ context: 'formatting'
831
+ });
832
+ }
833
+ },
834
+ // Stand-alone quarter
835
+ q: function q(date, token, localize) {
836
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
837
+ switch (token) {
838
+ // 1, 2, 3, 4
839
+ case 'q':
840
+ return String(quarter);
841
+ // 01, 02, 03, 04
842
+ case 'qq':
843
+ return addLeadingZeros(quarter, 2);
844
+ // 1st, 2nd, 3rd, 4th
845
+ case 'qo':
846
+ return localize.ordinalNumber(quarter, {
847
+ unit: 'quarter'
848
+ });
849
+ // Q1, Q2, Q3, Q4
850
+ case 'qqq':
851
+ return localize.quarter(quarter, {
852
+ width: 'abbreviated',
853
+ context: 'standalone'
854
+ });
855
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
856
+ case 'qqqqq':
857
+ return localize.quarter(quarter, {
858
+ width: 'narrow',
859
+ context: 'standalone'
860
+ });
861
+ // 1st quarter, 2nd quarter, ...
862
+ case 'qqqq':
863
+ default:
864
+ return localize.quarter(quarter, {
865
+ width: 'wide',
866
+ context: 'standalone'
867
+ });
868
+ }
869
+ },
870
+ // Month
871
+ M: function M(date, token, localize) {
872
+ var month = date.getUTCMonth();
873
+ switch (token) {
874
+ case 'M':
875
+ case 'MM':
876
+ return formatters$3.M(date, token);
877
+ // 1st, 2nd, ..., 12th
878
+ case 'Mo':
879
+ return localize.ordinalNumber(month + 1, {
880
+ unit: 'month'
881
+ });
882
+ // Jan, Feb, ..., Dec
883
+ case 'MMM':
884
+ return localize.month(month, {
885
+ width: 'abbreviated',
886
+ context: 'formatting'
887
+ });
888
+ // J, F, ..., D
889
+ case 'MMMMM':
890
+ return localize.month(month, {
891
+ width: 'narrow',
892
+ context: 'formatting'
893
+ });
894
+ // January, February, ..., December
895
+ case 'MMMM':
896
+ default:
897
+ return localize.month(month, {
898
+ width: 'wide',
899
+ context: 'formatting'
900
+ });
901
+ }
902
+ },
903
+ // Stand-alone month
904
+ L: function L(date, token, localize) {
905
+ var month = date.getUTCMonth();
906
+ switch (token) {
907
+ // 1, 2, ..., 12
908
+ case 'L':
909
+ return String(month + 1);
910
+ // 01, 02, ..., 12
911
+ case 'LL':
912
+ return addLeadingZeros(month + 1, 2);
913
+ // 1st, 2nd, ..., 12th
914
+ case 'Lo':
915
+ return localize.ordinalNumber(month + 1, {
916
+ unit: 'month'
917
+ });
918
+ // Jan, Feb, ..., Dec
919
+ case 'LLL':
920
+ return localize.month(month, {
921
+ width: 'abbreviated',
922
+ context: 'standalone'
923
+ });
924
+ // J, F, ..., D
925
+ case 'LLLLL':
926
+ return localize.month(month, {
927
+ width: 'narrow',
928
+ context: 'standalone'
929
+ });
930
+ // January, February, ..., December
931
+ case 'LLLL':
932
+ default:
933
+ return localize.month(month, {
934
+ width: 'wide',
935
+ context: 'standalone'
936
+ });
937
+ }
938
+ },
939
+ // Local week of year
940
+ w: function w(date, token, localize, options) {
941
+ var week = getUTCWeek(date, options);
942
+ if (token === 'wo') {
943
+ return localize.ordinalNumber(week, {
944
+ unit: 'week'
945
+ });
946
+ }
947
+ return addLeadingZeros(week, token.length);
948
+ },
949
+ // ISO week of year
950
+ I: function I(date, token, localize) {
951
+ var isoWeek = getUTCISOWeek(date);
952
+ if (token === 'Io') {
953
+ return localize.ordinalNumber(isoWeek, {
954
+ unit: 'week'
955
+ });
956
+ }
957
+ return addLeadingZeros(isoWeek, token.length);
958
+ },
959
+ // Day of the month
960
+ d: function d(date, token, localize) {
961
+ if (token === 'do') {
962
+ return localize.ordinalNumber(date.getUTCDate(), {
963
+ unit: 'date'
964
+ });
965
+ }
966
+ return formatters$3.d(date, token);
967
+ },
968
+ // Day of year
969
+ D: function D(date, token, localize) {
970
+ var dayOfYear = getUTCDayOfYear(date);
971
+ if (token === 'Do') {
972
+ return localize.ordinalNumber(dayOfYear, {
973
+ unit: 'dayOfYear'
974
+ });
975
+ }
976
+ return addLeadingZeros(dayOfYear, token.length);
977
+ },
978
+ // Day of week
979
+ E: function E(date, token, localize) {
980
+ var dayOfWeek = date.getUTCDay();
981
+ switch (token) {
982
+ // Tue
983
+ case 'E':
984
+ case 'EE':
985
+ case 'EEE':
986
+ return localize.day(dayOfWeek, {
987
+ width: 'abbreviated',
988
+ context: 'formatting'
989
+ });
990
+ // T
991
+ case 'EEEEE':
992
+ return localize.day(dayOfWeek, {
993
+ width: 'narrow',
994
+ context: 'formatting'
995
+ });
996
+ // Tu
997
+ case 'EEEEEE':
998
+ return localize.day(dayOfWeek, {
999
+ width: 'short',
1000
+ context: 'formatting'
1001
+ });
1002
+ // Tuesday
1003
+ case 'EEEE':
1004
+ default:
1005
+ return localize.day(dayOfWeek, {
1006
+ width: 'wide',
1007
+ context: 'formatting'
1008
+ });
1009
+ }
1010
+ },
1011
+ // Local day of week
1012
+ e: function e(date, token, localize, options) {
1013
+ var dayOfWeek = date.getUTCDay();
1014
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1015
+ switch (token) {
1016
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
1017
+ case 'e':
1018
+ return String(localDayOfWeek);
1019
+ // Padded numerical value
1020
+ case 'ee':
1021
+ return addLeadingZeros(localDayOfWeek, 2);
1022
+ // 1st, 2nd, ..., 7th
1023
+ case 'eo':
1024
+ return localize.ordinalNumber(localDayOfWeek, {
1025
+ unit: 'day'
1026
+ });
1027
+ case 'eee':
1028
+ return localize.day(dayOfWeek, {
1029
+ width: 'abbreviated',
1030
+ context: 'formatting'
1031
+ });
1032
+ // T
1033
+ case 'eeeee':
1034
+ return localize.day(dayOfWeek, {
1035
+ width: 'narrow',
1036
+ context: 'formatting'
1037
+ });
1038
+ // Tu
1039
+ case 'eeeeee':
1040
+ return localize.day(dayOfWeek, {
1041
+ width: 'short',
1042
+ context: 'formatting'
1043
+ });
1044
+ // Tuesday
1045
+ case 'eeee':
1046
+ default:
1047
+ return localize.day(dayOfWeek, {
1048
+ width: 'wide',
1049
+ context: 'formatting'
1050
+ });
1051
+ }
1052
+ },
1053
+ // Stand-alone local day of week
1054
+ c: function c(date, token, localize, options) {
1055
+ var dayOfWeek = date.getUTCDay();
1056
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1057
+ switch (token) {
1058
+ // Numerical value (same as in `e`)
1059
+ case 'c':
1060
+ return String(localDayOfWeek);
1061
+ // Padded numerical value
1062
+ case 'cc':
1063
+ return addLeadingZeros(localDayOfWeek, token.length);
1064
+ // 1st, 2nd, ..., 7th
1065
+ case 'co':
1066
+ return localize.ordinalNumber(localDayOfWeek, {
1067
+ unit: 'day'
1068
+ });
1069
+ case 'ccc':
1070
+ return localize.day(dayOfWeek, {
1071
+ width: 'abbreviated',
1072
+ context: 'standalone'
1073
+ });
1074
+ // T
1075
+ case 'ccccc':
1076
+ return localize.day(dayOfWeek, {
1077
+ width: 'narrow',
1078
+ context: 'standalone'
1079
+ });
1080
+ // Tu
1081
+ case 'cccccc':
1082
+ return localize.day(dayOfWeek, {
1083
+ width: 'short',
1084
+ context: 'standalone'
1085
+ });
1086
+ // Tuesday
1087
+ case 'cccc':
1088
+ default:
1089
+ return localize.day(dayOfWeek, {
1090
+ width: 'wide',
1091
+ context: 'standalone'
1092
+ });
1093
+ }
1094
+ },
1095
+ // ISO day of week
1096
+ i: function i(date, token, localize) {
1097
+ var dayOfWeek = date.getUTCDay();
1098
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1099
+ switch (token) {
1100
+ // 2
1101
+ case 'i':
1102
+ return String(isoDayOfWeek);
1103
+ // 02
1104
+ case 'ii':
1105
+ return addLeadingZeros(isoDayOfWeek, token.length);
1106
+ // 2nd
1107
+ case 'io':
1108
+ return localize.ordinalNumber(isoDayOfWeek, {
1109
+ unit: 'day'
1110
+ });
1111
+ // Tue
1112
+ case 'iii':
1113
+ return localize.day(dayOfWeek, {
1114
+ width: 'abbreviated',
1115
+ context: 'formatting'
1116
+ });
1117
+ // T
1118
+ case 'iiiii':
1119
+ return localize.day(dayOfWeek, {
1120
+ width: 'narrow',
1121
+ context: 'formatting'
1122
+ });
1123
+ // Tu
1124
+ case 'iiiiii':
1125
+ return localize.day(dayOfWeek, {
1126
+ width: 'short',
1127
+ context: 'formatting'
1128
+ });
1129
+ // Tuesday
1130
+ case 'iiii':
1131
+ default:
1132
+ return localize.day(dayOfWeek, {
1133
+ width: 'wide',
1134
+ context: 'formatting'
1135
+ });
1136
+ }
1137
+ },
1138
+ // AM or PM
1139
+ a: function a(date, token, localize) {
1140
+ var hours = date.getUTCHours();
1141
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1142
+ switch (token) {
1143
+ case 'a':
1144
+ case 'aa':
1145
+ return localize.dayPeriod(dayPeriodEnumValue, {
1146
+ width: 'abbreviated',
1147
+ context: 'formatting'
1148
+ });
1149
+ case 'aaa':
1150
+ return localize.dayPeriod(dayPeriodEnumValue, {
1151
+ width: 'abbreviated',
1152
+ context: 'formatting'
1153
+ }).toLowerCase();
1154
+ case 'aaaaa':
1155
+ return localize.dayPeriod(dayPeriodEnumValue, {
1156
+ width: 'narrow',
1157
+ context: 'formatting'
1158
+ });
1159
+ case 'aaaa':
1160
+ default:
1161
+ return localize.dayPeriod(dayPeriodEnumValue, {
1162
+ width: 'wide',
1163
+ context: 'formatting'
1164
+ });
1165
+ }
1166
+ },
1167
+ // AM, PM, midnight, noon
1168
+ b: function b(date, token, localize) {
1169
+ var hours = date.getUTCHours();
1170
+ var dayPeriodEnumValue;
1171
+ if (hours === 12) {
1172
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1173
+ } else if (hours === 0) {
1174
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1175
+ } else {
1176
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1177
+ }
1178
+ switch (token) {
1179
+ case 'b':
1180
+ case 'bb':
1181
+ return localize.dayPeriod(dayPeriodEnumValue, {
1182
+ width: 'abbreviated',
1183
+ context: 'formatting'
1184
+ });
1185
+ case 'bbb':
1186
+ return localize.dayPeriod(dayPeriodEnumValue, {
1187
+ width: 'abbreviated',
1188
+ context: 'formatting'
1189
+ }).toLowerCase();
1190
+ case 'bbbbb':
1191
+ return localize.dayPeriod(dayPeriodEnumValue, {
1192
+ width: 'narrow',
1193
+ context: 'formatting'
1194
+ });
1195
+ case 'bbbb':
1196
+ default:
1197
+ return localize.dayPeriod(dayPeriodEnumValue, {
1198
+ width: 'wide',
1199
+ context: 'formatting'
1200
+ });
1201
+ }
1202
+ },
1203
+ // in the morning, in the afternoon, in the evening, at night
1204
+ B: function B(date, token, localize) {
1205
+ var hours = date.getUTCHours();
1206
+ var dayPeriodEnumValue;
1207
+ if (hours >= 17) {
1208
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1209
+ } else if (hours >= 12) {
1210
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1211
+ } else if (hours >= 4) {
1212
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1213
+ } else {
1214
+ dayPeriodEnumValue = dayPeriodEnum.night;
1215
+ }
1216
+ switch (token) {
1217
+ case 'B':
1218
+ case 'BB':
1219
+ case 'BBB':
1220
+ return localize.dayPeriod(dayPeriodEnumValue, {
1221
+ width: 'abbreviated',
1222
+ context: 'formatting'
1223
+ });
1224
+ case 'BBBBB':
1225
+ return localize.dayPeriod(dayPeriodEnumValue, {
1226
+ width: 'narrow',
1227
+ context: 'formatting'
1228
+ });
1229
+ case 'BBBB':
1230
+ default:
1231
+ return localize.dayPeriod(dayPeriodEnumValue, {
1232
+ width: 'wide',
1233
+ context: 'formatting'
1234
+ });
1235
+ }
1236
+ },
1237
+ // Hour [1-12]
1238
+ h: function h(date, token, localize) {
1239
+ if (token === 'ho') {
1240
+ var hours = date.getUTCHours() % 12;
1241
+ if (hours === 0) hours = 12;
1242
+ return localize.ordinalNumber(hours, {
1243
+ unit: 'hour'
1244
+ });
1245
+ }
1246
+ return formatters$3.h(date, token);
1247
+ },
1248
+ // Hour [0-23]
1249
+ H: function H(date, token, localize) {
1250
+ if (token === 'Ho') {
1251
+ return localize.ordinalNumber(date.getUTCHours(), {
1252
+ unit: 'hour'
1253
+ });
1254
+ }
1255
+ return formatters$3.H(date, token);
1256
+ },
1257
+ // Hour [0-11]
1258
+ K: function K(date, token, localize) {
1259
+ var hours = date.getUTCHours() % 12;
1260
+ if (token === 'Ko') {
1261
+ return localize.ordinalNumber(hours, {
1262
+ unit: 'hour'
1263
+ });
1264
+ }
1265
+ return addLeadingZeros(hours, token.length);
1266
+ },
1267
+ // Hour [1-24]
1268
+ k: function k(date, token, localize) {
1269
+ var hours = date.getUTCHours();
1270
+ if (hours === 0) hours = 24;
1271
+ if (token === 'ko') {
1272
+ return localize.ordinalNumber(hours, {
1273
+ unit: 'hour'
1274
+ });
1275
+ }
1276
+ return addLeadingZeros(hours, token.length);
1277
+ },
1278
+ // Minute
1279
+ m: function m(date, token, localize) {
1280
+ if (token === 'mo') {
1281
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1282
+ unit: 'minute'
1283
+ });
1284
+ }
1285
+ return formatters$3.m(date, token);
1286
+ },
1287
+ // Second
1288
+ s: function s(date, token, localize) {
1289
+ if (token === 'so') {
1290
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1291
+ unit: 'second'
1292
+ });
1293
+ }
1294
+ return formatters$3.s(date, token);
1295
+ },
1296
+ // Fraction of second
1297
+ S: function S(date, token) {
1298
+ return formatters$3.S(date, token);
1299
+ },
1300
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1301
+ X: function X(date, token, _localize, options) {
1302
+ var originalDate = options._originalDate || date;
1303
+ var timezoneOffset = originalDate.getTimezoneOffset();
1304
+ if (timezoneOffset === 0) {
1305
+ return 'Z';
1306
+ }
1307
+ switch (token) {
1308
+ // Hours and optional minutes
1309
+ case 'X':
1310
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1311
+
1312
+ // Hours, minutes and optional seconds without `:` delimiter
1313
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1314
+ // so this token always has the same output as `XX`
1315
+ case 'XXXX':
1316
+ case 'XX':
1317
+ // Hours and minutes without `:` delimiter
1318
+ return formatTimezone(timezoneOffset);
1319
+
1320
+ // Hours, minutes and optional seconds with `:` delimiter
1321
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1322
+ // so this token always has the same output as `XXX`
1323
+ case 'XXXXX':
1324
+ case 'XXX': // Hours and minutes with `:` delimiter
1325
+ default:
1326
+ return formatTimezone(timezoneOffset, ':');
1327
+ }
1328
+ },
1329
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1330
+ x: function x(date, token, _localize, options) {
1331
+ var originalDate = options._originalDate || date;
1332
+ var timezoneOffset = originalDate.getTimezoneOffset();
1333
+ switch (token) {
1334
+ // Hours and optional minutes
1335
+ case 'x':
1336
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1337
+
1338
+ // Hours, minutes and optional seconds without `:` delimiter
1339
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1340
+ // so this token always has the same output as `xx`
1341
+ case 'xxxx':
1342
+ case 'xx':
1343
+ // Hours and minutes without `:` delimiter
1344
+ return formatTimezone(timezoneOffset);
1345
+
1346
+ // Hours, minutes and optional seconds with `:` delimiter
1347
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1348
+ // so this token always has the same output as `xxx`
1349
+ case 'xxxxx':
1350
+ case 'xxx': // Hours and minutes with `:` delimiter
1351
+ default:
1352
+ return formatTimezone(timezoneOffset, ':');
1353
+ }
1354
+ },
1355
+ // Timezone (GMT)
1356
+ O: function O(date, token, _localize, options) {
1357
+ var originalDate = options._originalDate || date;
1358
+ var timezoneOffset = originalDate.getTimezoneOffset();
1359
+ switch (token) {
1360
+ // Short
1361
+ case 'O':
1362
+ case 'OO':
1363
+ case 'OOO':
1364
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1365
+ // Long
1366
+ case 'OOOO':
1367
+ default:
1368
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1369
+ }
1370
+ },
1371
+ // Timezone (specific non-location)
1372
+ z: function z(date, token, _localize, options) {
1373
+ var originalDate = options._originalDate || date;
1374
+ var timezoneOffset = originalDate.getTimezoneOffset();
1375
+ switch (token) {
1376
+ // Short
1377
+ case 'z':
1378
+ case 'zz':
1379
+ case 'zzz':
1380
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1381
+ // Long
1382
+ case 'zzzz':
1383
+ default:
1384
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1385
+ }
1386
+ },
1387
+ // Seconds timestamp
1388
+ t: function t(date, token, _localize, options) {
1389
+ var originalDate = options._originalDate || date;
1390
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1391
+ return addLeadingZeros(timestamp, token.length);
1392
+ },
1393
+ // Milliseconds timestamp
1394
+ T: function T(date, token, _localize, options) {
1395
+ var originalDate = options._originalDate || date;
1396
+ var timestamp = originalDate.getTime();
1397
+ return addLeadingZeros(timestamp, token.length);
1398
+ }
1399
+ };
1400
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1401
+ var sign = offset > 0 ? '-' : '+';
1402
+ var absOffset = Math.abs(offset);
1403
+ var hours = Math.floor(absOffset / 60);
1404
+ var minutes = absOffset % 60;
1405
+ if (minutes === 0) {
1406
+ return sign + String(hours);
1407
+ }
1408
+ var delimiter = dirtyDelimiter || '';
1409
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1410
+ }
1411
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1412
+ if (offset % 60 === 0) {
1413
+ var sign = offset > 0 ? '-' : '+';
1414
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1415
+ }
1416
+ return formatTimezone(offset, dirtyDelimiter);
1417
+ }
1418
+ function formatTimezone(offset, dirtyDelimiter) {
1419
+ var delimiter = dirtyDelimiter || '';
1420
+ var sign = offset > 0 ? '-' : '+';
1421
+ var absOffset = Math.abs(offset);
1422
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1423
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1424
+ return sign + hours + delimiter + minutes;
1425
+ }
1426
+ const formatters$1 = formatters;
1427
+
1428
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1429
+ switch (pattern) {
1430
+ case 'P':
1431
+ return formatLong.date({
1432
+ width: 'short'
1433
+ });
1434
+ case 'PP':
1435
+ return formatLong.date({
1436
+ width: 'medium'
1437
+ });
1438
+ case 'PPP':
1439
+ return formatLong.date({
1440
+ width: 'long'
1441
+ });
1442
+ case 'PPPP':
1443
+ default:
1444
+ return formatLong.date({
1445
+ width: 'full'
1446
+ });
1447
+ }
1448
+ };
1449
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1450
+ switch (pattern) {
1451
+ case 'p':
1452
+ return formatLong.time({
1453
+ width: 'short'
1454
+ });
1455
+ case 'pp':
1456
+ return formatLong.time({
1457
+ width: 'medium'
1458
+ });
1459
+ case 'ppp':
1460
+ return formatLong.time({
1461
+ width: 'long'
1462
+ });
1463
+ case 'pppp':
1464
+ default:
1465
+ return formatLong.time({
1466
+ width: 'full'
1467
+ });
1468
+ }
1469
+ };
1470
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1471
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1472
+ var datePattern = matchResult[1];
1473
+ var timePattern = matchResult[2];
1474
+ if (!timePattern) {
1475
+ return dateLongFormatter(pattern, formatLong);
1476
+ }
1477
+ var dateTimeFormat;
1478
+ switch (datePattern) {
1479
+ case 'P':
1480
+ dateTimeFormat = formatLong.dateTime({
1481
+ width: 'short'
1482
+ });
1483
+ break;
1484
+ case 'PP':
1485
+ dateTimeFormat = formatLong.dateTime({
1486
+ width: 'medium'
1487
+ });
1488
+ break;
1489
+ case 'PPP':
1490
+ dateTimeFormat = formatLong.dateTime({
1491
+ width: 'long'
1492
+ });
1493
+ break;
1494
+ case 'PPPP':
1495
+ default:
1496
+ dateTimeFormat = formatLong.dateTime({
1497
+ width: 'full'
1498
+ });
1499
+ break;
1500
+ }
1501
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1502
+ };
1503
+ var longFormatters = {
1504
+ p: timeLongFormatter,
1505
+ P: dateTimeLongFormatter
1506
+ };
1507
+ const longFormatters$1 = longFormatters;
1508
+
1509
+ var protectedDayOfYearTokens = ['D', 'DD'];
1510
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1511
+ function isProtectedDayOfYearToken(token) {
1512
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1513
+ }
1514
+ function isProtectedWeekYearToken(token) {
1515
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1516
+ }
1517
+ function throwProtectedError(token, format, input) {
1518
+ if (token === 'YYYY') {
1519
+ 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"));
1520
+ } else if (token === 'YY') {
1521
+ 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"));
1522
+ } else if (token === 'D') {
1523
+ 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"));
1524
+ } else if (token === 'DD') {
1525
+ 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"));
1526
+ }
1527
+ }
1528
+
1529
+ var formatDistanceLocale = {
1530
+ lessThanXSeconds: {
1531
+ one: 'less than a second',
1532
+ other: 'less than {{count}} seconds'
1533
+ },
1534
+ xSeconds: {
1535
+ one: '1 second',
1536
+ other: '{{count}} seconds'
1537
+ },
1538
+ halfAMinute: 'half a minute',
1539
+ lessThanXMinutes: {
1540
+ one: 'less than a minute',
1541
+ other: 'less than {{count}} minutes'
1542
+ },
1543
+ xMinutes: {
1544
+ one: '1 minute',
1545
+ other: '{{count}} minutes'
1546
+ },
1547
+ aboutXHours: {
1548
+ one: 'about 1 hour',
1549
+ other: 'about {{count}} hours'
1550
+ },
1551
+ xHours: {
1552
+ one: '1 hour',
1553
+ other: '{{count}} hours'
1554
+ },
1555
+ xDays: {
1556
+ one: '1 day',
1557
+ other: '{{count}} days'
1558
+ },
1559
+ aboutXWeeks: {
1560
+ one: 'about 1 week',
1561
+ other: 'about {{count}} weeks'
1562
+ },
1563
+ xWeeks: {
1564
+ one: '1 week',
1565
+ other: '{{count}} weeks'
1566
+ },
1567
+ aboutXMonths: {
1568
+ one: 'about 1 month',
1569
+ other: 'about {{count}} months'
1570
+ },
1571
+ xMonths: {
1572
+ one: '1 month',
1573
+ other: '{{count}} months'
1574
+ },
1575
+ aboutXYears: {
1576
+ one: 'about 1 year',
1577
+ other: 'about {{count}} years'
1578
+ },
1579
+ xYears: {
1580
+ one: '1 year',
1581
+ other: '{{count}} years'
1582
+ },
1583
+ overXYears: {
1584
+ one: 'over 1 year',
1585
+ other: 'over {{count}} years'
1586
+ },
1587
+ almostXYears: {
1588
+ one: 'almost 1 year',
1589
+ other: 'almost {{count}} years'
1590
+ }
1591
+ };
1592
+ var formatDistance = function formatDistance(token, count, options) {
1593
+ var result;
1594
+ var tokenValue = formatDistanceLocale[token];
1595
+ if (typeof tokenValue === 'string') {
1596
+ result = tokenValue;
1597
+ } else if (count === 1) {
1598
+ result = tokenValue.one;
1599
+ } else {
1600
+ result = tokenValue.other.replace('{{count}}', count.toString());
1601
+ }
1602
+ if (options !== null && options !== void 0 && options.addSuffix) {
1603
+ if (options.comparison && options.comparison > 0) {
1604
+ return 'in ' + result;
1605
+ } else {
1606
+ return result + ' ago';
1607
+ }
1608
+ }
1609
+ return result;
1610
+ };
1611
+ const formatDistance$1 = formatDistance;
1612
+
1613
+ function buildFormatLongFn(args) {
1614
+ return function () {
1615
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1616
+ // TODO: Remove String()
1617
+ var width = options.width ? String(options.width) : args.defaultWidth;
1618
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1619
+ return format;
1620
+ };
1621
+ }
1622
+
1623
+ var dateFormats = {
1624
+ full: 'EEEE, MMMM do, y',
1625
+ long: 'MMMM do, y',
1626
+ medium: 'MMM d, y',
1627
+ short: 'MM/dd/yyyy'
1628
+ };
1629
+ var timeFormats = {
1630
+ full: 'h:mm:ss a zzzz',
1631
+ long: 'h:mm:ss a z',
1632
+ medium: 'h:mm:ss a',
1633
+ short: 'h:mm a'
1634
+ };
1635
+ var dateTimeFormats = {
1636
+ full: "{{date}} 'at' {{time}}",
1637
+ long: "{{date}} 'at' {{time}}",
1638
+ medium: '{{date}}, {{time}}',
1639
+ short: '{{date}}, {{time}}'
1640
+ };
1641
+ var formatLong = {
1642
+ date: buildFormatLongFn({
1643
+ formats: dateFormats,
1644
+ defaultWidth: 'full'
1645
+ }),
1646
+ time: buildFormatLongFn({
1647
+ formats: timeFormats,
1648
+ defaultWidth: 'full'
1649
+ }),
1650
+ dateTime: buildFormatLongFn({
1651
+ formats: dateTimeFormats,
1652
+ defaultWidth: 'full'
1653
+ })
1654
+ };
1655
+ const formatLong$1 = formatLong;
1656
+
1657
+ var formatRelativeLocale = {
1658
+ lastWeek: "'last' eeee 'at' p",
1659
+ yesterday: "'yesterday at' p",
1660
+ today: "'today at' p",
1661
+ tomorrow: "'tomorrow at' p",
1662
+ nextWeek: "eeee 'at' p",
1663
+ other: 'P'
1664
+ };
1665
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1666
+ return formatRelativeLocale[token];
1667
+ };
1668
+ const formatRelative$1 = formatRelative;
1669
+
1670
+ function buildLocalizeFn(args) {
1671
+ return function (dirtyIndex, options) {
1672
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1673
+ var valuesArray;
1674
+ if (context === 'formatting' && args.formattingValues) {
1675
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1676
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1677
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1678
+ } else {
1679
+ var _defaultWidth = args.defaultWidth;
1680
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1681
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1682
+ }
1683
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1684
+ // @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!
1685
+ return valuesArray[index];
1686
+ };
1687
+ }
1688
+
1689
+ var eraValues = {
1690
+ narrow: ['B', 'A'],
1691
+ abbreviated: ['BC', 'AD'],
1692
+ wide: ['Before Christ', 'Anno Domini']
1693
+ };
1694
+ var quarterValues = {
1695
+ narrow: ['1', '2', '3', '4'],
1696
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1697
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1698
+ };
1699
+
1700
+ // Note: in English, the names of days of the week and months are capitalized.
1701
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1702
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1703
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1704
+ var monthValues = {
1705
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1706
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1707
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1708
+ };
1709
+ var dayValues = {
1710
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1711
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1712
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1713
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1714
+ };
1715
+ var dayPeriodValues = {
1716
+ narrow: {
1717
+ am: 'a',
1718
+ pm: 'p',
1719
+ midnight: 'mi',
1720
+ noon: 'n',
1721
+ morning: 'morning',
1722
+ afternoon: 'afternoon',
1723
+ evening: 'evening',
1724
+ night: 'night'
1725
+ },
1726
+ abbreviated: {
1727
+ am: 'AM',
1728
+ pm: 'PM',
1729
+ midnight: 'midnight',
1730
+ noon: 'noon',
1731
+ morning: 'morning',
1732
+ afternoon: 'afternoon',
1733
+ evening: 'evening',
1734
+ night: 'night'
1735
+ },
1736
+ wide: {
1737
+ am: 'a.m.',
1738
+ pm: 'p.m.',
1739
+ midnight: 'midnight',
1740
+ noon: 'noon',
1741
+ morning: 'morning',
1742
+ afternoon: 'afternoon',
1743
+ evening: 'evening',
1744
+ night: 'night'
1745
+ }
1746
+ };
1747
+ var formattingDayPeriodValues = {
1748
+ narrow: {
1749
+ am: 'a',
1750
+ pm: 'p',
1751
+ midnight: 'mi',
1752
+ noon: 'n',
1753
+ morning: 'in the morning',
1754
+ afternoon: 'in the afternoon',
1755
+ evening: 'in the evening',
1756
+ night: 'at night'
1757
+ },
1758
+ abbreviated: {
1759
+ am: 'AM',
1760
+ pm: 'PM',
1761
+ midnight: 'midnight',
1762
+ noon: 'noon',
1763
+ morning: 'in the morning',
1764
+ afternoon: 'in the afternoon',
1765
+ evening: 'in the evening',
1766
+ night: 'at night'
1767
+ },
1768
+ wide: {
1769
+ am: 'a.m.',
1770
+ pm: 'p.m.',
1771
+ midnight: 'midnight',
1772
+ noon: 'noon',
1773
+ morning: 'in the morning',
1774
+ afternoon: 'in the afternoon',
1775
+ evening: 'in the evening',
1776
+ night: 'at night'
1777
+ }
1778
+ };
1779
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1780
+ var number = Number(dirtyNumber);
1781
+
1782
+ // If ordinal numbers depend on context, for example,
1783
+ // if they are different for different grammatical genders,
1784
+ // use `options.unit`.
1785
+ //
1786
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1787
+ // 'day', 'hour', 'minute', 'second'.
1788
+
1789
+ var rem100 = number % 100;
1790
+ if (rem100 > 20 || rem100 < 10) {
1791
+ switch (rem100 % 10) {
1792
+ case 1:
1793
+ return number + 'st';
1794
+ case 2:
1795
+ return number + 'nd';
1796
+ case 3:
1797
+ return number + 'rd';
1798
+ }
1799
+ }
1800
+ return number + 'th';
1801
+ };
1802
+ var localize = {
1803
+ ordinalNumber: ordinalNumber,
1804
+ era: buildLocalizeFn({
1805
+ values: eraValues,
1806
+ defaultWidth: 'wide'
1807
+ }),
1808
+ quarter: buildLocalizeFn({
1809
+ values: quarterValues,
1810
+ defaultWidth: 'wide',
1811
+ argumentCallback: function argumentCallback(quarter) {
1812
+ return quarter - 1;
1813
+ }
1814
+ }),
1815
+ month: buildLocalizeFn({
1816
+ values: monthValues,
1817
+ defaultWidth: 'wide'
1818
+ }),
1819
+ day: buildLocalizeFn({
1820
+ values: dayValues,
1821
+ defaultWidth: 'wide'
1822
+ }),
1823
+ dayPeriod: buildLocalizeFn({
1824
+ values: dayPeriodValues,
1825
+ defaultWidth: 'wide',
1826
+ formattingValues: formattingDayPeriodValues,
1827
+ defaultFormattingWidth: 'wide'
1828
+ })
1829
+ };
1830
+ const localize$1 = localize;
1831
+
1832
+ function buildMatchFn(args) {
1833
+ return function (string) {
1834
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1835
+ var width = options.width;
1836
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1837
+ var matchResult = string.match(matchPattern);
1838
+ if (!matchResult) {
1839
+ return null;
1840
+ }
1841
+ var matchedString = matchResult[0];
1842
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1843
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1844
+ return pattern.test(matchedString);
1845
+ }) : findKey(parsePatterns, function (pattern) {
1846
+ return pattern.test(matchedString);
1847
+ });
1848
+ var value;
1849
+ value = args.valueCallback ? args.valueCallback(key) : key;
1850
+ value = options.valueCallback ? options.valueCallback(value) : value;
1851
+ var rest = string.slice(matchedString.length);
1852
+ return {
1853
+ value: value,
1854
+ rest: rest
1855
+ };
1856
+ };
1857
+ }
1858
+ function findKey(object, predicate) {
1859
+ for (var key in object) {
1860
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1861
+ return key;
1862
+ }
1863
+ }
1864
+ return undefined;
1865
+ }
1866
+ function findIndex(array, predicate) {
1867
+ for (var key = 0; key < array.length; key++) {
1868
+ if (predicate(array[key])) {
1869
+ return key;
1870
+ }
1871
+ }
1872
+ return undefined;
1873
+ }
1874
+
1875
+ function buildMatchPatternFn(args) {
1876
+ return function (string) {
1877
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1878
+ var matchResult = string.match(args.matchPattern);
1879
+ if (!matchResult) return null;
1880
+ var matchedString = matchResult[0];
1881
+ var parseResult = string.match(args.parsePattern);
1882
+ if (!parseResult) return null;
1883
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1884
+ value = options.valueCallback ? options.valueCallback(value) : value;
1885
+ var rest = string.slice(matchedString.length);
1886
+ return {
1887
+ value: value,
1888
+ rest: rest
1889
+ };
1890
+ };
1891
+ }
1892
+
1893
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1894
+ var parseOrdinalNumberPattern = /\d+/i;
1895
+ var matchEraPatterns = {
1896
+ narrow: /^(b|a)/i,
1897
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1898
+ wide: /^(before christ|before common era|anno domini|common era)/i
1899
+ };
1900
+ var parseEraPatterns = {
1901
+ any: [/^b/i, /^(a|c)/i]
1902
+ };
1903
+ var matchQuarterPatterns = {
1904
+ narrow: /^[1234]/i,
1905
+ abbreviated: /^q[1234]/i,
1906
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1907
+ };
1908
+ var parseQuarterPatterns = {
1909
+ any: [/1/i, /2/i, /3/i, /4/i]
1910
+ };
1911
+ var matchMonthPatterns = {
1912
+ narrow: /^[jfmasond]/i,
1913
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1914
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1915
+ };
1916
+ var parseMonthPatterns = {
1917
+ 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],
1918
+ 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]
1919
+ };
1920
+ var matchDayPatterns = {
1921
+ narrow: /^[smtwf]/i,
1922
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1923
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1924
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1925
+ };
1926
+ var parseDayPatterns = {
1927
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1928
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1929
+ };
1930
+ var matchDayPeriodPatterns = {
1931
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1932
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1933
+ };
1934
+ var parseDayPeriodPatterns = {
1935
+ any: {
1936
+ am: /^a/i,
1937
+ pm: /^p/i,
1938
+ midnight: /^mi/i,
1939
+ noon: /^no/i,
1940
+ morning: /morning/i,
1941
+ afternoon: /afternoon/i,
1942
+ evening: /evening/i,
1943
+ night: /night/i
1944
+ }
1945
+ };
1946
+ var match = {
1947
+ ordinalNumber: buildMatchPatternFn({
1948
+ matchPattern: matchOrdinalNumberPattern,
1949
+ parsePattern: parseOrdinalNumberPattern,
1950
+ valueCallback: function valueCallback(value) {
1951
+ return parseInt(value, 10);
1952
+ }
1953
+ }),
1954
+ era: buildMatchFn({
1955
+ matchPatterns: matchEraPatterns,
1956
+ defaultMatchWidth: 'wide',
1957
+ parsePatterns: parseEraPatterns,
1958
+ defaultParseWidth: 'any'
1959
+ }),
1960
+ quarter: buildMatchFn({
1961
+ matchPatterns: matchQuarterPatterns,
1962
+ defaultMatchWidth: 'wide',
1963
+ parsePatterns: parseQuarterPatterns,
1964
+ defaultParseWidth: 'any',
1965
+ valueCallback: function valueCallback(index) {
1966
+ return index + 1;
1967
+ }
1968
+ }),
1969
+ month: buildMatchFn({
1970
+ matchPatterns: matchMonthPatterns,
1971
+ defaultMatchWidth: 'wide',
1972
+ parsePatterns: parseMonthPatterns,
1973
+ defaultParseWidth: 'any'
1974
+ }),
1975
+ day: buildMatchFn({
1976
+ matchPatterns: matchDayPatterns,
1977
+ defaultMatchWidth: 'wide',
1978
+ parsePatterns: parseDayPatterns,
1979
+ defaultParseWidth: 'any'
1980
+ }),
1981
+ dayPeriod: buildMatchFn({
1982
+ matchPatterns: matchDayPeriodPatterns,
1983
+ defaultMatchWidth: 'any',
1984
+ parsePatterns: parseDayPeriodPatterns,
1985
+ defaultParseWidth: 'any'
1986
+ })
1987
+ };
1988
+ const match$1 = match;
1989
+
1990
+ /**
1991
+ * @type {Locale}
1992
+ * @category Locales
1993
+ * @summary English locale (United States).
1994
+ * @language English
1995
+ * @iso-639-2 eng
1996
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1997
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1998
+ */
1999
+ var locale = {
2000
+ code: 'en-US',
2001
+ formatDistance: formatDistance$1,
2002
+ formatLong: formatLong$1,
2003
+ formatRelative: formatRelative$1,
2004
+ localize: localize$1,
2005
+ match: match$1,
2006
+ options: {
2007
+ weekStartsOn: 0 /* Sunday */,
2008
+ firstWeekContainsDate: 1
2009
+ }
2010
+ };
2011
+ const defaultLocale = locale;
2012
+
2013
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2014
+ // (one of the certain letters followed by `o`)
2015
+ // - (\w)\1* matches any sequences of the same letter
2016
+ // - '' matches two quote characters in a row
2017
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2018
+ // except a single quote symbol, which ends the sequence.
2019
+ // Two quote characters do not end the sequence.
2020
+ // If there is no matching single quote
2021
+ // then the sequence will continue until the end of the string.
2022
+ // - . matches any single character unmatched by previous parts of the RegExps
2023
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2024
+
2025
+ // This RegExp catches symbols escaped by quotes, and also
2026
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2027
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2028
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2029
+ var doubleQuoteRegExp = /''/g;
2030
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2031
+
2032
+ /**
2033
+ * @name format
2034
+ * @category Common Helpers
2035
+ * @summary Format the date.
2036
+ *
2037
+ * @description
2038
+ * Return the formatted date string in the given format. The result may vary by locale.
2039
+ *
2040
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2041
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2042
+ *
2043
+ * The characters wrapped between two single quotes characters (') are escaped.
2044
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2045
+ * (see the last example)
2046
+ *
2047
+ * Format of the string is based on Unicode Technical Standard #35:
2048
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2049
+ * with a few additions (see note 7 below the table).
2050
+ *
2051
+ * Accepted patterns:
2052
+ * | Unit | Pattern | Result examples | Notes |
2053
+ * |---------------------------------|---------|-----------------------------------|-------|
2054
+ * | Era | G..GGG | AD, BC | |
2055
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2056
+ * | | GGGGG | A, B | |
2057
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2058
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2059
+ * | | yy | 44, 01, 00, 17 | 5 |
2060
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2061
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2062
+ * | | yyyyy | ... | 3,5 |
2063
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2064
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2065
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2066
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2067
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2068
+ * | | YYYYY | ... | 3,5 |
2069
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2070
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2071
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2072
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2073
+ * | | RRRRR | ... | 3,5,7 |
2074
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2075
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2076
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2077
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2078
+ * | | uuuuu | ... | 3,5 |
2079
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2080
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2081
+ * | | QQ | 01, 02, 03, 04 | |
2082
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2083
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2084
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2085
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2086
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2087
+ * | | qq | 01, 02, 03, 04 | |
2088
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2089
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2090
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2091
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2092
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2093
+ * | | MM | 01, 02, ..., 12 | |
2094
+ * | | MMM | Jan, Feb, ..., Dec | |
2095
+ * | | MMMM | January, February, ..., December | 2 |
2096
+ * | | MMMMM | J, F, ..., D | |
2097
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2098
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2099
+ * | | LL | 01, 02, ..., 12 | |
2100
+ * | | LLL | Jan, Feb, ..., Dec | |
2101
+ * | | LLLL | January, February, ..., December | 2 |
2102
+ * | | LLLLL | J, F, ..., D | |
2103
+ * | Local week of year | w | 1, 2, ..., 53 | |
2104
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2105
+ * | | ww | 01, 02, ..., 53 | |
2106
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2107
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2108
+ * | | II | 01, 02, ..., 53 | 7 |
2109
+ * | Day of month | d | 1, 2, ..., 31 | |
2110
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2111
+ * | | dd | 01, 02, ..., 31 | |
2112
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2113
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2114
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2115
+ * | | DDD | 001, 002, ..., 365, 366 | |
2116
+ * | | DDDD | ... | 3 |
2117
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2118
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2119
+ * | | EEEEE | M, T, W, T, F, S, S | |
2120
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2121
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2122
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2123
+ * | | ii | 01, 02, ..., 07 | 7 |
2124
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2125
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2126
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2127
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2128
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2129
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2130
+ * | | ee | 02, 03, ..., 01 | |
2131
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2132
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2133
+ * | | eeeee | M, T, W, T, F, S, S | |
2134
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2135
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2136
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2137
+ * | | cc | 02, 03, ..., 01 | |
2138
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2139
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2140
+ * | | ccccc | M, T, W, T, F, S, S | |
2141
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2142
+ * | AM, PM | a..aa | AM, PM | |
2143
+ * | | aaa | am, pm | |
2144
+ * | | aaaa | a.m., p.m. | 2 |
2145
+ * | | aaaaa | a, p | |
2146
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2147
+ * | | bbb | am, pm, noon, midnight | |
2148
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2149
+ * | | bbbbb | a, p, n, mi | |
2150
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2151
+ * | | BBBB | at night, in the morning, ... | 2 |
2152
+ * | | BBBBB | at night, in the morning, ... | |
2153
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2154
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2155
+ * | | hh | 01, 02, ..., 11, 12 | |
2156
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2157
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2158
+ * | | HH | 00, 01, 02, ..., 23 | |
2159
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2160
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2161
+ * | | KK | 01, 02, ..., 11, 00 | |
2162
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2163
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2164
+ * | | kk | 24, 01, 02, ..., 23 | |
2165
+ * | Minute | m | 0, 1, ..., 59 | |
2166
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2167
+ * | | mm | 00, 01, ..., 59 | |
2168
+ * | Second | s | 0, 1, ..., 59 | |
2169
+ * | | so | 0th, 1st, ..., 59th | 7 |
2170
+ * | | ss | 00, 01, ..., 59 | |
2171
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2172
+ * | | SS | 00, 01, ..., 99 | |
2173
+ * | | SSS | 000, 001, ..., 999 | |
2174
+ * | | SSSS | ... | 3 |
2175
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2176
+ * | | XX | -0800, +0530, Z | |
2177
+ * | | XXX | -08:00, +05:30, Z | |
2178
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2179
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2180
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2181
+ * | | xx | -0800, +0530, +0000 | |
2182
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2183
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2184
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2185
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2186
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2187
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2188
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2189
+ * | Seconds timestamp | t | 512969520 | 7 |
2190
+ * | | tt | ... | 3,7 |
2191
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2192
+ * | | TT | ... | 3,7 |
2193
+ * | Long localized date | P | 04/29/1453 | 7 |
2194
+ * | | PP | Apr 29, 1453 | 7 |
2195
+ * | | PPP | April 29th, 1453 | 7 |
2196
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2197
+ * | Long localized time | p | 12:00 AM | 7 |
2198
+ * | | pp | 12:00:00 AM | 7 |
2199
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2200
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2201
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2202
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2203
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2204
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2205
+ * Notes:
2206
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2207
+ * are the same as "stand-alone" units, but are different in some languages.
2208
+ * "Formatting" units are declined according to the rules of the language
2209
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2210
+ *
2211
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2212
+ *
2213
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2214
+ *
2215
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2216
+ * the single quote characters (see below).
2217
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2218
+ * the output will be the same as default pattern for this unit, usually
2219
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2220
+ * are marked with "2" in the last column of the table.
2221
+ *
2222
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2223
+ *
2224
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2225
+ *
2226
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2227
+ *
2228
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2229
+ *
2230
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2231
+ *
2232
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2233
+ * The output will be padded with zeros to match the length of the pattern.
2234
+ *
2235
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2236
+ *
2237
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2238
+ * These tokens represent the shortest form of the quarter.
2239
+ *
2240
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2241
+ *
2242
+ * | Year | `y` | `u` |
2243
+ * |------|-----|-----|
2244
+ * | AC 1 | 1 | 1 |
2245
+ * | BC 1 | 1 | 0 |
2246
+ * | BC 2 | 2 | -1 |
2247
+ *
2248
+ * Also `yy` always returns the last two digits of a year,
2249
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2250
+ *
2251
+ * | Year | `yy` | `uu` |
2252
+ * |------|------|------|
2253
+ * | 1 | 01 | 01 |
2254
+ * | 14 | 14 | 14 |
2255
+ * | 376 | 76 | 376 |
2256
+ * | 1453 | 53 | 1453 |
2257
+ *
2258
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2259
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2260
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2261
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2262
+ *
2263
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2264
+ * so right now these tokens fall back to GMT timezones.
2265
+ *
2266
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2267
+ * - `i`: ISO day of week
2268
+ * - `I`: ISO week of year
2269
+ * - `R`: ISO week-numbering year
2270
+ * - `t`: seconds timestamp
2271
+ * - `T`: milliseconds timestamp
2272
+ * - `o`: ordinal number modifier
2273
+ * - `P`: long localized date
2274
+ * - `p`: long localized time
2275
+ *
2276
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2277
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2278
+ *
2279
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2280
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2281
+ *
2282
+ * @param {Date|Number} date - the original date
2283
+ * @param {String} format - the string of tokens
2284
+ * @param {Object} [options] - an object with options.
2285
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2286
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2287
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2288
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2289
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2290
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2291
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2292
+ * @returns {String} the formatted date string
2293
+ * @throws {TypeError} 2 arguments required
2294
+ * @throws {RangeError} `date` must not be Invalid Date
2295
+ * @throws {RangeError} `options.locale` must contain `localize` property
2296
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2297
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2298
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2299
+ * @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
2300
+ * @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
2301
+ * @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
2302
+ * @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
2303
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2304
+ *
2305
+ * @example
2306
+ * // Represent 11 February 2014 in middle-endian format:
2307
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2308
+ * //=> '02/11/2014'
2309
+ *
2310
+ * @example
2311
+ * // Represent 2 July 2014 in Esperanto:
2312
+ * import { eoLocale } from 'date-fns/locale/eo'
2313
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2314
+ * locale: eoLocale
2315
+ * })
2316
+ * //=> '2-a de julio 2014'
2317
+ *
2318
+ * @example
2319
+ * // Escape string by single quote characters:
2320
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2321
+ * //=> "3 o'clock"
2322
+ */
2323
+
2324
+ function format(dirtyDate, dirtyFormatStr, options) {
2325
+ 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;
2326
+ requiredArgs(2, arguments);
2327
+ var formatStr = String(dirtyFormatStr);
2328
+ var defaultOptions = getDefaultOptions();
2329
+ 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;
2330
+ 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);
2331
+
2332
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2333
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2334
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2335
+ }
2336
+ 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);
2337
+
2338
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2339
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2340
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2341
+ }
2342
+ if (!locale.localize) {
2343
+ throw new RangeError('locale must contain localize property');
2344
+ }
2345
+ if (!locale.formatLong) {
2346
+ throw new RangeError('locale must contain formatLong property');
2347
+ }
2348
+ var originalDate = toDate(dirtyDate);
2349
+ if (!isValid(originalDate)) {
2350
+ throw new RangeError('Invalid time value');
2351
+ }
2352
+
2353
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2354
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2355
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2356
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2357
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2358
+ var formatterOptions = {
2359
+ firstWeekContainsDate: firstWeekContainsDate,
2360
+ weekStartsOn: weekStartsOn,
2361
+ locale: locale,
2362
+ _originalDate: originalDate
2363
+ };
2364
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2365
+ var firstCharacter = substring[0];
2366
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2367
+ var longFormatter = longFormatters$1[firstCharacter];
2368
+ return longFormatter(substring, locale.formatLong);
2369
+ }
2370
+ return substring;
2371
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2372
+ // Replace two single quote characters with one single quote character
2373
+ if (substring === "''") {
2374
+ return "'";
2375
+ }
2376
+ var firstCharacter = substring[0];
2377
+ if (firstCharacter === "'") {
2378
+ return cleanEscapedString(substring);
2379
+ }
2380
+ var formatter = formatters$1[firstCharacter];
2381
+ if (formatter) {
2382
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2383
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2384
+ }
2385
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2386
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2387
+ }
2388
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2389
+ }
2390
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2391
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2392
+ }
2393
+ return substring;
2394
+ }).join('');
2395
+ return result;
2396
+ }
2397
+ function cleanEscapedString(input) {
2398
+ var matched = input.match(escapedStringRegExp);
2399
+ if (!matched) {
2400
+ return input;
2401
+ }
2402
+ return matched[1].replace(doubleQuoteRegExp, "'");
2403
+ }
2404
+
2405
+ /**
2406
+ * @name parseISO
2407
+ * @category Common Helpers
2408
+ * @summary Parse ISO string
2409
+ *
2410
+ * @description
2411
+ * Parse the given string in ISO 8601 format and return an instance of Date.
2412
+ *
2413
+ * Function accepts complete ISO 8601 formats as well as partial implementations.
2414
+ * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
2415
+ *
2416
+ * If the argument isn't a string, the function cannot parse the string or
2417
+ * the values are invalid, it returns Invalid Date.
2418
+ *
2419
+ * @param {String} argument - the value to convert
2420
+ * @param {Object} [options] - an object with options.
2421
+ * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
2422
+ * @returns {Date} the parsed date in the local time zone
2423
+ * @throws {TypeError} 1 argument required
2424
+ * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
2425
+ *
2426
+ * @example
2427
+ * // Convert string '2014-02-11T11:30:30' to date:
2428
+ * const result = parseISO('2014-02-11T11:30:30')
2429
+ * //=> Tue Feb 11 2014 11:30:30
2430
+ *
2431
+ * @example
2432
+ * // Convert string '+02014101' to date,
2433
+ * // if the additional number of digits in the extended year format is 1:
2434
+ * const result = parseISO('+02014101', { additionalDigits: 1 })
2435
+ * //=> Fri Apr 11 2014 00:00:00
2436
+ */
2437
+ function parseISO(argument, options) {
2438
+ var _options$additionalDi;
2439
+ requiredArgs(1, arguments);
2440
+ var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
2441
+ if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
2442
+ throw new RangeError('additionalDigits must be 0, 1 or 2');
2443
+ }
2444
+ if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
2445
+ return new Date(NaN);
2446
+ }
2447
+ var dateStrings = splitDateString(argument);
2448
+ var date;
2449
+ if (dateStrings.date) {
2450
+ var parseYearResult = parseYear(dateStrings.date, additionalDigits);
2451
+ date = parseDate(parseYearResult.restDateString, parseYearResult.year);
2452
+ }
2453
+ if (!date || isNaN(date.getTime())) {
2454
+ return new Date(NaN);
2455
+ }
2456
+ var timestamp = date.getTime();
2457
+ var time = 0;
2458
+ var offset;
2459
+ if (dateStrings.time) {
2460
+ time = parseTime(dateStrings.time);
2461
+ if (isNaN(time)) {
2462
+ return new Date(NaN);
2463
+ }
2464
+ }
2465
+ if (dateStrings.timezone) {
2466
+ offset = parseTimezone(dateStrings.timezone);
2467
+ if (isNaN(offset)) {
2468
+ return new Date(NaN);
2469
+ }
2470
+ } else {
2471
+ var dirtyDate = new Date(timestamp + time);
2472
+ // js parsed string assuming it's in UTC timezone
2473
+ // but we need it to be parsed in our timezone
2474
+ // so we use utc values to build date in our timezone.
2475
+ // Year values from 0 to 99 map to the years 1900 to 1999
2476
+ // so set year explicitly with setFullYear.
2477
+ var result = new Date(0);
2478
+ result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
2479
+ result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
2480
+ return result;
2481
+ }
2482
+ return new Date(timestamp + time + offset);
2483
+ }
2484
+ var patterns = {
2485
+ dateTimeDelimiter: /[T ]/,
2486
+ timeZoneDelimiter: /[Z ]/i,
2487
+ timezone: /([Z+-].*)$/
2488
+ };
2489
+ var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
2490
+ var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
2491
+ var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2492
+ function splitDateString(dateString) {
2493
+ var dateStrings = {};
2494
+ var array = dateString.split(patterns.dateTimeDelimiter);
2495
+ var timeString;
2496
+
2497
+ // The regex match should only return at maximum two array elements.
2498
+ // [date], [time], or [date, time].
2499
+ if (array.length > 2) {
2500
+ return dateStrings;
2501
+ }
2502
+ if (/:/.test(array[0])) {
2503
+ timeString = array[0];
2504
+ } else {
2505
+ dateStrings.date = array[0];
2506
+ timeString = array[1];
2507
+ if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
2508
+ dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
2509
+ timeString = dateString.substr(dateStrings.date.length, dateString.length);
2510
+ }
2511
+ }
2512
+ if (timeString) {
2513
+ var token = patterns.timezone.exec(timeString);
2514
+ if (token) {
2515
+ dateStrings.time = timeString.replace(token[1], '');
2516
+ dateStrings.timezone = token[1];
2517
+ } else {
2518
+ dateStrings.time = timeString;
2519
+ }
2520
+ }
2521
+ return dateStrings;
2522
+ }
2523
+ function parseYear(dateString, additionalDigits) {
2524
+ var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
2525
+ var captures = dateString.match(regex);
2526
+ // Invalid ISO-formatted year
2527
+ if (!captures) return {
2528
+ year: NaN,
2529
+ restDateString: ''
2530
+ };
2531
+ var year = captures[1] ? parseInt(captures[1]) : null;
2532
+ var century = captures[2] ? parseInt(captures[2]) : null;
2533
+
2534
+ // either year or century is null, not both
2535
+ return {
2536
+ year: century === null ? year : century * 100,
2537
+ restDateString: dateString.slice((captures[1] || captures[2]).length)
2538
+ };
2539
+ }
2540
+ function parseDate(dateString, year) {
2541
+ // Invalid ISO-formatted year
2542
+ if (year === null) return new Date(NaN);
2543
+ var captures = dateString.match(dateRegex);
2544
+ // Invalid ISO-formatted string
2545
+ if (!captures) return new Date(NaN);
2546
+ var isWeekDate = !!captures[4];
2547
+ var dayOfYear = parseDateUnit(captures[1]);
2548
+ var month = parseDateUnit(captures[2]) - 1;
2549
+ var day = parseDateUnit(captures[3]);
2550
+ var week = parseDateUnit(captures[4]);
2551
+ var dayOfWeek = parseDateUnit(captures[5]) - 1;
2552
+ if (isWeekDate) {
2553
+ if (!validateWeekDate(year, week, dayOfWeek)) {
2554
+ return new Date(NaN);
2555
+ }
2556
+ return dayOfISOWeekYear(year, week, dayOfWeek);
2557
+ } else {
2558
+ var date = new Date(0);
2559
+ if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
2560
+ return new Date(NaN);
2561
+ }
2562
+ date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
2563
+ return date;
2564
+ }
2565
+ }
2566
+ function parseDateUnit(value) {
2567
+ return value ? parseInt(value) : 1;
2568
+ }
2569
+ function parseTime(timeString) {
2570
+ var captures = timeString.match(timeRegex);
2571
+ if (!captures) return NaN; // Invalid ISO-formatted time
2572
+
2573
+ var hours = parseTimeUnit(captures[1]);
2574
+ var minutes = parseTimeUnit(captures[2]);
2575
+ var seconds = parseTimeUnit(captures[3]);
2576
+ if (!validateTime(hours, minutes, seconds)) {
2577
+ return NaN;
2578
+ }
2579
+ return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;
2580
+ }
2581
+ function parseTimeUnit(value) {
2582
+ return value && parseFloat(value.replace(',', '.')) || 0;
2583
+ }
2584
+ function parseTimezone(timezoneString) {
2585
+ if (timezoneString === 'Z') return 0;
2586
+ var captures = timezoneString.match(timezoneRegex);
2587
+ if (!captures) return 0;
2588
+ var sign = captures[1] === '+' ? -1 : 1;
2589
+ var hours = parseInt(captures[2]);
2590
+ var minutes = captures[3] && parseInt(captures[3]) || 0;
2591
+ if (!validateTimezone(hours, minutes)) {
2592
+ return NaN;
2593
+ }
2594
+ return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
2595
+ }
2596
+ function dayOfISOWeekYear(isoWeekYear, week, day) {
2597
+ var date = new Date(0);
2598
+ date.setUTCFullYear(isoWeekYear, 0, 4);
2599
+ var fourthOfJanuaryDay = date.getUTCDay() || 7;
2600
+ var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
2601
+ date.setUTCDate(date.getUTCDate() + diff);
2602
+ return date;
2603
+ }
2604
+
2605
+ // Validation functions
2606
+
2607
+ // February is null to handle the leap year (using ||)
2608
+ var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2609
+ function isLeapYearIndex(year) {
2610
+ return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
2611
+ }
2612
+ function validateDate(year, month, date) {
2613
+ return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
2614
+ }
2615
+ function validateDayOfYearDate(year, dayOfYear) {
2616
+ return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
2617
+ }
2618
+ function validateWeekDate(_year, week, day) {
2619
+ return week >= 1 && week <= 53 && day >= 0 && day <= 6;
2620
+ }
2621
+ function validateTime(hours, minutes, seconds) {
2622
+ if (hours === 24) {
2623
+ return minutes === 0 && seconds === 0;
2624
+ }
2625
+ return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
2626
+ }
2627
+ function validateTimezone(_hours, minutes) {
2628
+ return minutes >= 0 && minutes <= 59;
2629
+ }
2630
+
2631
+ const formatDate = ({ date, type = 'date', format: format$1 }) => {
2632
+ try {
2633
+ const parsedDate = parseISO(date);
2634
+ if (isNaN(parsedDate.getTime())) {
2635
+ throw new Error(`Invalid date: ${date}`);
2636
+ }
2637
+ if (format$1)
2638
+ return format(parsedDate, format$1);
2639
+ let formatStr = 'dd/MM/yyyy';
2640
+ if (type === 'time') {
2641
+ formatStr = 'dd/MM/yyyy HH:mm:ss';
2642
+ }
2643
+ else if (type === 'week') {
2644
+ formatStr = 'ccc dd/MM/yyyy HH:mm:ss';
2645
+ }
2646
+ return format(parsedDate, formatStr);
2647
+ }
2648
+ catch (error) {
2649
+ console.error('Error formatting date:', error.message);
2650
+ return '';
2651
+ }
2652
+ };
2653
+ const fetcher = (url) => fetch(url, {
2654
+ method: 'GET',
2655
+ headers: {
2656
+ 'x-scheme': 'application/json',
2657
+ Accept: 'application/json'
2658
+ }
2659
+ }).then((r) => r.json());
2660
+ const showNotification = ({ message, theme = 'success' }) => {
2661
+ window.postMessage({
2662
+ type: 'ShowNotificationToast',
2663
+ message,
2664
+ theme
2665
+ });
2666
+ };
2667
+ const thousandSeparator = (value) => {
2668
+ if (value === 0) {
2669
+ return '0';
2670
+ }
2671
+ if (!value) {
2672
+ return '';
2673
+ }
2674
+ value = value.toString();
2675
+ const parts = value.split('.');
2676
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
2677
+ return parts.join('.');
2678
+ };
2679
+ const generateUUID = () => {
2680
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
2681
+ var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
2682
+ return v.toString(16);
2683
+ });
2684
+ };
2685
+ const TICKET_INVALID_TOKEN = 'TICKET_INVALID_TOKEN';
2686
+ // format results to winning numbers
2687
+ const formatResultsToWinningNumbers = (rawResults) => {
2688
+ const formatMatchCheckRes = (matchRes) => matchRes.map((bulletItem) => (bulletItem.isSelected ? 1 : 0));
2689
+ const resultsForTotalLines = rawResults.map((lineRes) => lineRes.map(formatMatchCheckRes));
2690
+ const result = [];
2691
+ for (let i = 0; i < resultsForTotalLines.length; i++) {
2692
+ const resultsInLine = resultsForTotalLines[i];
2693
+ for (let j = 0; j < resultsInLine.length; j++) {
2694
+ const matchResult = resultsInLine[j];
2695
+ for (let k = 0; k < matchResult.length; k++) {
2696
+ if (!result[i])
2697
+ result[i] = [];
2698
+ if (matchResult[k])
2699
+ result[i].push(k, j);
2700
+ }
2701
+ }
2702
+ }
2703
+ return result;
2704
+ };
2705
+ const doSubmitTicket = ({ body, sessionId, url }) => {
2706
+ const options = {
2707
+ method: 'POST',
2708
+ headers: {
2709
+ 'Content-Type': 'application/json',
2710
+ Accept: 'application/json',
2711
+ Authorization: `Bearer ${sessionId}`,
2712
+ 'X-Idempotency-Key': generateUUID()
2713
+ },
2714
+ body: JSON.stringify(body)
2715
+ };
2716
+ return fetch(url, options).then((res) => {
2717
+ if (res.status === 401) {
2718
+ throw new Error(TICKET_INVALID_TOKEN);
2719
+ }
2720
+ if (res.status > 300) {
2721
+ throw new Error(res.statusText);
2722
+ }
2723
+ return res.json();
2724
+ });
2725
+ };
2726
+ // BettingTypes, playModes and playTypes
2727
+ const getEnableOptions = (raw = []) => raw.filter((i) => i.enabled);
2728
+ // the first one in bet type config that enabled = true, will be default choice
2729
+ const getDefaultType = ({ playTypeConfig = [], betTypeConfig = [], enabledBettingTypeOptions = [], enabledPlayingModeOptions = [] }) => {
2730
+ const enabledBetTypeConfig = betTypeConfig.filter((i) => i.enabled);
2731
+ for (const item of enabledBetTypeConfig) {
2732
+ const { bettingType, playMode } = playTypeConfig === null || playTypeConfig === void 0 ? void 0 : playTypeConfig.find((i) => i.betTypeId === item.id);
2733
+ if (enabledBettingTypeOptions.map((i) => i.code).includes(bettingType) &&
2734
+ enabledPlayingModeOptions.map((i) => i.code).includes(playMode))
2735
+ return { bettingType, playMode };
2736
+ }
2737
+ return {};
2738
+ };
2739
+ const calculatePlayingModeOptions = ({ bettingType, playTypeConfig, betTypeConfig, enabledPlayingModeOptions }) => {
2740
+ const enabledBetTypeIdConfig = betTypeConfig.filter((i) => i.enabled).map((i) => i.id);
2741
+ const filteredPlayTypesConfig = playTypeConfig.filter((i) => enabledBetTypeIdConfig.includes(i.betTypeId));
2742
+ const selectedBettingTypeFilteredPlayTypesConfig = filteredPlayTypesConfig.filter((i) => i.bettingType === bettingType);
2743
+ const _ = selectedBettingTypeFilteredPlayTypesConfig.map((i) => i.playMode);
2744
+ return enabledPlayingModeOptions.filter((i) => _.includes(i.code));
2745
+ };
2746
+ const getCheckedCountForEachLineAndEachMatch = ({ rawResults }) => {
2747
+ const getMatchCheckRes = (matchRes) => matchRes.filter((bulletItem) => bulletItem.isSelected).length;
2748
+ const checkedCountForEachLineAndEachMatch = rawResults.map((lineRes) => lineRes.length > 0 ? lineRes.map(getMatchCheckRes) : [0]);
2749
+ return checkedCountForEachLineAndEachMatch;
2750
+ };
2751
+ const getPlayTypeConfig = ({ rawData, selectedBettingType, selectedPlayingMode }) => {
2752
+ var _a, _b, _c, _d, _e, _f;
2753
+ const betTypeId = (_d = (_c = (_b = (_a = rawData === null || rawData === void 0 ? void 0 : rawData.rules) === null || _a === void 0 ? void 0 : _a.poolGame) === null || _b === void 0 ? void 0 : _b.playTypes) === null || _c === void 0 ? void 0 : _c.find((i) => i.bettingType === selectedBettingType && i.playMode === selectedPlayingMode)) === null || _d === void 0 ? void 0 : _d.betTypeId;
2754
+ const betType = (_f = (_e = rawData === null || rawData === void 0 ? void 0 : rawData.rules) === null || _e === void 0 ? void 0 : _e.betTypes) === null || _f === void 0 ? void 0 : _f.find((i) => i.id === betTypeId);
2755
+ return { betTypeId, betType };
2756
+ };
2757
+
2758
+ const lotteryTippingTicketControllerCss = ".lottery-tipping-ticket-controller__container {\n display: block;\n box-sizing: border-box;\n font-size: 14px;\n container-type: inline-size;\n}\n@container (max-width: 375px) {\n .lottery-tipping-ticket-controller__container {\n font-size: 12px;\n }\n}\n\n.LotteryTippingTicketController__top {\n padding: 1.8rem;\n display: flex;\n flex-direction: column;\n gap: 2rem;\n margin: 0 auto;\n max-width: 800px;\n}\n.LotteryTippingTicketController__row {\n display: flex;\n align-items: center;\n gap: 1rem;\n justify-content: space-between;\n flex-wrap: wrap;\n}\n.LotteryTippingTicketController__section {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.LotteryTippingTicketController__label {\n font-weight: 500;\n white-space: nowrap;\n width: 6rem;\n}\n.LotteryTippingTicketController__segmented-control {\n height: 2.2rem;\n display: inline-flex;\n background-color: var(--emw--color-gray-100, #e6e6e6);\n border-radius: 2rem;\n padding: 0.2rem;\n}\n.LotteryTippingTicketController__segment {\n background-color: transparent;\n border: none;\n padding: 0.3rem 0.8rem;\n cursor: pointer;\n font-weight: 500;\n border-radius: 2rem;\n outline: none;\n transition: background-color 0.25s ease, color 0.25s ease;\n white-space: nowrap;\n}\n.LotteryTippingTicketController__segment--active {\n background-color: var(--emw--color-background, #ffffff);\n color: var(--emw--color-gray-400, #000);\n font-weight: 600;\n}\n.LotteryTippingTicketController__segment--disabled:hover {\n cursor: not-allowed !important;\n}\n.LotteryTippingTicketController__segment:not(.LotteryTippingTicketController__segment--active):hover {\n background-color: var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));\n}\n\n.flex {\n display: flex;\n}\n\n.flex-wrap {\n flex-wrap: wrap;\n}\n\n.align-center {\n align-items: center;\n}\n\n.gap-1 {\n gap: 4px;\n}\n\n.LotteryTippingTicketController__main {\n align-items: flex-start;\n justify-content: center;\n gap: 2rem;\n max-width: 1200px;\n margin: 0 auto;\n padding: 0 20px;\n flex-wrap: wrap;\n}\n.LotteryTippingTicketController__main--left {\n border: 1px solid var(--emw--color-gray-50, #f5f5f5);\n padding: 1rem;\n border-radius: 1rem;\n flex: 1.5;\n}\n.LotteryTippingTicketController__main--right {\n padding: 1rem;\n border-radius: 1rem;\n flex: 1;\n}\n\n.order-summary {\n max-width: 360px;\n width: 100%;\n background: var(--emw--color-background, #fff);\n}\n\n.order-summary__title {\n margin-bottom: 16px;\n text-align: center;\n color: var(--emw--color-gray-400, #000);\n text-transform: uppercase;\n}\n\n.order-summary__ticket-info {\n display: flex;\n align-items: center;\n margin-bottom: 16px;\n gap: 10px;\n}\n\n.order-summary__ticket {\n font-weight: 500;\n width: 50px;\n text-align: right;\n}\n\n.order-summary__details {\n display: flex;\n align-items: center;\n}\n\n.order-summary__multiplier {\n color: var(--emw--color-gray-150, #6f6f6f);\n margin: 0 8px;\n}\n\n.order-summary__divider {\n border: none;\n border-top: 1px solid var(--emw--color-gray-100, #e6e6e6);\n margin: 20px 0;\n}\n\n.order-summary__button-wrapper {\n display: flex;\n justify-content: center;\n}\n\n.order-summary__button {\n cursor: pointer;\n padding: 0.5rem 4rem;\n background: var(--emw--color-primary, #fed275);\n color: var(--emw--color-gray-400, #000);\n border-radius: var(--emw--button-border-radius, 4px);\n border: 1px solid var(--emw--color-primary, #fed275);\n}\n\n.order-summary__button:not(.order-summary__button--disabled):not(.order-summary__button--loading):hover {\n transform: translateY(-1px);\n box-shadow: 0 4px 8px var(--emw--button-box-shadow-color-secondary, rgba(0, 0, 0, 0.15));\n background: var(--emw--color-primary-variant, #ffe66f);\n}\n\n.order-summary__button--disabled {\n background: var(--emw--color-gray-100, #e6e6e6);\n color: var(--emw--color-typography, #555);\n cursor: not-allowed;\n border: 1px solid var(--emw--color-gray-100, #e6e6e6);\n}\n\n.skeleton-content {\n display: flex;\n flex-direction: column;\n gap: 29px;\n align-items: center;\n}\n\n.skeleton-item {\n background: var(--emw--color-gray-50, #f5f5f5);\n border-radius: 4px;\n height: 40px;\n width: 200px;\n}\n\n.skeleton-animated {\n animation: skeleton-shimmer 1.5s infinite linear;\n background: linear-gradient(90deg, var(--emw--color-gray-100, #e6e6e6) 25%, var(--emw--color-gray-50, #f5f5f5) 37%, var(--emw--color-gray-100, #e6e6e6) 63%);\n background-size: 200% 100%;\n}\n\n@keyframes skeleton-shimmer {\n to {\n background-position: 100% 0;\n }\n}";
2759
+ const LotteryTippingTicketControllerStyle0 = lotteryTippingTicketControllerCss;
2760
+
2761
+ const LotteryTippingTicketController = class {
2762
+ constructor(hostRef) {
2763
+ index.registerInstance(this, hostRef);
2764
+ this.logoutEventHandler = index.createEvent(this, "logout", 7);
2765
+ this.loadingImagePath = index.getAssetPath('../static/loading.svg');
2766
+ this.mbSource = undefined;
2767
+ this.clientStyling = undefined;
2768
+ this.clientStylingUrl = undefined;
2769
+ this.translationUrl = '';
2770
+ this.language = 'en';
2771
+ this.endpoint = '';
2772
+ this.endpointTicket = undefined;
2773
+ this.sessionId = undefined;
2774
+ this.gameId = undefined;
2775
+ this.playerId = '';
2776
+ this.drawId = undefined;
2777
+ this.isLoading = true;
2778
+ this.bettingTypeOptions = [];
2779
+ this.playingModeOptions = [];
2780
+ this.selectedBettingType = undefined;
2781
+ this.selectedPlayingMode = undefined;
2782
+ this.hasSelectBullet = undefined;
2783
+ this.hasSelectAllBullet = undefined;
2784
+ this.totalLineCombination = 0;
2785
+ this.submitLoading = undefined;
2786
+ this.rawData = {};
2787
+ this.dialogConfig = { visible: false };
2788
+ }
2789
+ async getLotteryTippingBulletResults() {
2790
+ return await this.childRef.getData();
2791
+ }
2792
+ get lineNumberRange() {
2793
+ const { betType } = getPlayTypeConfig({
2794
+ rawData: this.rawData,
2795
+ selectedBettingType: this.selectedBettingType,
2796
+ selectedPlayingMode: this.selectedPlayingMode
2797
+ });
2798
+ const boardsAllowed = (betType === null || betType === void 0 ? void 0 : betType.boardsAllowed) || [0];
2799
+ const [minLineNumber, maxLineNumber] = [Math.min(...boardsAllowed), Math.max(...boardsAllowed)];
2800
+ const defaultBoards = (betType === null || betType === void 0 ? void 0 : betType.defaultBoards) || minLineNumber;
2801
+ return { minLineNumber, maxLineNumber, defaultBoards };
2802
+ }
2803
+ get playTypeConfig() {
2804
+ var _a, _b, _c;
2805
+ return (_c = (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.poolGame) === null || _c === void 0 ? void 0 : _c.playTypes;
2806
+ }
2807
+ get betTypeConfig() {
2808
+ var _a, _b;
2809
+ return (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.betTypes;
2810
+ }
2811
+ get isBothBettingType() {
2812
+ return this.selectedBettingType === BettingTypeEnum.Both;
2813
+ }
2814
+ get currentStake() {
2815
+ var _a, _b, _c;
2816
+ return (_c = (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.stakes) === null || _c === void 0 ? void 0 : _c[0];
2817
+ }
2818
+ handleBettingTypeChange(type) {
2819
+ var _a, _b, _c, _d;
2820
+ if (type === this.selectedBettingType)
2821
+ return;
2822
+ this.selectedBettingType = type;
2823
+ const calcPlayingModeOptions = calculatePlayingModeOptions({
2824
+ bettingType: this.selectedBettingType,
2825
+ playTypeConfig: this.playTypeConfig,
2826
+ betTypeConfig: this.betTypeConfig,
2827
+ enabledPlayingModeOptions: getEnableOptions(((_c = (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.poolGame) === null || _c === void 0 ? void 0 : _c.playModes) || [])
2828
+ });
2829
+ this.playingModeOptions = calcPlayingModeOptions;
2830
+ if (!calcPlayingModeOptions.length) {
2831
+ this.selectedPlayingMode = undefined;
2832
+ }
2833
+ else if (!calcPlayingModeOptions.map((i) => i.code).includes(this.selectedPlayingMode)) {
2834
+ this.hasSelectBullet = false;
2835
+ this.handlePlayingModeChange((_d = calcPlayingModeOptions[0]) === null || _d === void 0 ? void 0 : _d.code);
2836
+ }
2837
+ this.clearBulletConfig();
2838
+ }
2839
+ async clearBulletConfig() {
2840
+ return await this.childRef.resetBulletConfig(this.lineNumberRange);
2841
+ }
2842
+ handlePlayingModeChange(mode) {
2843
+ if (mode === this.selectedPlayingMode)
2844
+ return;
2845
+ const doChangeSelectedPlayingMod = (closeDialog) => {
2846
+ this.selectedPlayingMode = mode;
2847
+ this.clearBulletConfig().then(() => {
2848
+ closeDialog === null || closeDialog === void 0 ? void 0 : closeDialog();
2849
+ });
2850
+ };
2851
+ if (this.hasSelectBullet) {
2852
+ const closeDialog = () => {
2853
+ this.dialogConfig = { visible: false };
2854
+ };
2855
+ const onConfirm = () => {
2856
+ doChangeSelectedPlayingMod(closeDialog);
2857
+ };
2858
+ this.dialogConfig = {
2859
+ visible: true,
2860
+ content: translate('selectionCleared', this.language),
2861
+ onConfirm: onConfirm,
2862
+ onCancel: closeDialog
2863
+ };
2864
+ }
2865
+ else {
2866
+ doChangeSelectedPlayingMod();
2867
+ }
2868
+ }
2869
+ lotteryTippingBulletGroupSelectionHandler(event) {
2870
+ var _a;
2871
+ const hasSelectBullet = (_a = event.detail) === null || _a === void 0 ? void 0 : _a.hasSelectBullet;
2872
+ if (hasSelectBullet !== undefined)
2873
+ this.hasSelectBullet = hasSelectBullet;
2874
+ this.bulletBetSelectChecker();
2875
+ }
2876
+ calculateCombinationInLine(checkedNumberArr) {
2877
+ return checkedNumberArr.reduce((pre, cur) => pre * cur, 1);
2878
+ }
2879
+ calculateTotalAmount() {
2880
+ const stake = this.currentStake;
2881
+ if (!stake) {
2882
+ return 0;
2883
+ }
2884
+ let totalAmount = stake.value * this.totalLineCombination;
2885
+ return totalAmount;
2886
+ }
2887
+ get totalAmountFormatted() {
2888
+ var _a;
2889
+ const totalAmount = this.calculateTotalAmount();
2890
+ return thousandSeparator(totalAmount) + ' ' + ((_a = this.currentStake) === null || _a === void 0 ? void 0 : _a.currency) || '';
2891
+ }
2892
+ get currentStakeFormatted() {
2893
+ const { value = '', currency = '' } = this.currentStake || {};
2894
+ return `${value} ${currency}`;
2895
+ }
2896
+ bulletBetSelectChecker() {
2897
+ const validateSelectionsAndCalculateTotals = async () => {
2898
+ const doCheckIfNotCompleteSelect = ({ rawResults }) => {
2899
+ const checkedCountForEachLineAndEachMatch = getCheckedCountForEachLineAndEachMatch({ rawResults });
2900
+ // total line combination is sum of all the line's combination
2901
+ this.totalLineCombination = checkedCountForEachLineAndEachMatch.reduce((pre, cur) => pre + this.calculateCombinationInLine(cur), 0);
2902
+ // each line's combination should within in [combinations, maxCombinations]
2903
+ const { combinations = 1, maxCombinations = 1 } = getPlayTypeConfig({
2904
+ rawData: this.rawData,
2905
+ selectedBettingType: this.selectedBettingType,
2906
+ selectedPlayingMode: this.selectedPlayingMode
2907
+ }).betType || {};
2908
+ return checkedCountForEachLineAndEachMatch.some((checkedNumberArr) => {
2909
+ const curCombination = this.calculateCombinationInLine(checkedNumberArr);
2910
+ return curCombination < combinations || curCombination > maxCombinations;
2911
+ });
2912
+ };
2913
+ const rawResults = await this.getLotteryTippingBulletResults();
2914
+ this.hasSelectAllBullet = !doCheckIfNotCompleteSelect({ rawResults });
2915
+ };
2916
+ validateSelectionsAndCalculateTotals();
2917
+ }
2918
+ handleClientStylingChange(newValue, oldValue) {
2919
+ if (newValue != oldValue) {
2920
+ setClientStyling(this.stylingContainer, this.clientStyling);
2921
+ }
2922
+ }
2923
+ handleClientStylingUrlChange(newValue, oldValue) {
2924
+ if (newValue != oldValue) {
2925
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
2926
+ }
2927
+ }
2928
+ handleMbSourceChange(newValue, oldValue) {
2929
+ if (newValue != oldValue) {
2930
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
2931
+ }
2932
+ }
2933
+ componentWillLoad() {
2934
+ if (this.translationUrl) {
2935
+ resolveTranslationUrl(this.translationUrl);
2936
+ }
2937
+ }
2938
+ componentDidLoad() {
2939
+ if (this.stylingContainer) {
2940
+ if (this.mbSource)
2941
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
2942
+ if (this.clientStyling)
2943
+ setClientStyling(this.stylingContainer, this.clientStyling);
2944
+ if (this.clientStylingUrl)
2945
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
2946
+ }
2947
+ }
2948
+ disconnectedCallback() {
2949
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
2950
+ }
2951
+ connectedCallback() {
2952
+ const fetchData = () => {
2953
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
2954
+ this.isLoading = true;
2955
+ fetcher(url.href)
2956
+ .then((res) => {
2957
+ var _a, _b, _c, _d, _e, _f, _g;
2958
+ this.rawData = res;
2959
+ this.bettingTypeOptions = getEnableOptions(((_b = (_a = res === null || res === void 0 ? void 0 : res.rules) === null || _a === void 0 ? void 0 : _a.poolGame) === null || _b === void 0 ? void 0 : _b.bettingTypes) || []);
2960
+ this.playingModeOptions = getEnableOptions(((_d = (_c = res === null || res === void 0 ? void 0 : res.rules) === null || _c === void 0 ? void 0 : _c.poolGame) === null || _d === void 0 ? void 0 : _d.playModes) || []);
2961
+ // default: select the first one
2962
+ const { bettingType, playMode } = getDefaultType({
2963
+ playTypeConfig: (_f = (_e = res === null || res === void 0 ? void 0 : res.rules) === null || _e === void 0 ? void 0 : _e.poolGame) === null || _f === void 0 ? void 0 : _f.playTypes,
2964
+ betTypeConfig: (_g = res === null || res === void 0 ? void 0 : res.rules) === null || _g === void 0 ? void 0 : _g.betTypes,
2965
+ enabledBettingTypeOptions: this.bettingTypeOptions,
2966
+ enabledPlayingModeOptions: this.playingModeOptions
2967
+ });
2968
+ this.handleBettingTypeChange(bettingType);
2969
+ this.selectedPlayingMode = playMode;
2970
+ })
2971
+ .catch((err) => {
2972
+ console.error('Error!', err);
2973
+ })
2974
+ .finally(() => {
2975
+ this.isLoading = false;
2976
+ });
2977
+ };
2978
+ fetchData();
2979
+ }
2980
+ async handleSubmit() {
2981
+ const rawResults = await this.getLotteryTippingBulletResults();
2982
+ const { betTypeId, betType } = getPlayTypeConfig({
2983
+ rawData: this.rawData,
2984
+ selectedBettingType: this.selectedBettingType,
2985
+ selectedPlayingMode: this.selectedPlayingMode
2986
+ });
2987
+ const buildSubmitParam = () => {
2988
+ var _a, _b;
2989
+ const body = {
2990
+ playerId: this.playerId,
2991
+ tickets: []
2992
+ };
2993
+ const selections = formatResultsToWinningNumbers(rawResults);
2994
+ const stake = this.currentStake || {};
2995
+ body.tickets.push({
2996
+ startingDrawId: (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.id,
2997
+ amount: this.calculateTotalAmount().toString(),
2998
+ gameId: this.gameId,
2999
+ gameName: this.rawData.name,
3000
+ currency: stake.currency,
3001
+ selection: selections.map((i) => ({
3002
+ betType: betTypeId,
3003
+ stake: +stake.value,
3004
+ selections: i,
3005
+ quickPick: false,
3006
+ betName: betType.name
3007
+ })),
3008
+ multiplier: false,
3009
+ drawCount: 1,
3010
+ quickPick: false
3011
+ });
3012
+ return body;
3013
+ };
3014
+ const url = new URL(`${this.endpointTicket}/tickets`);
3015
+ const body = buildSubmitParam();
3016
+ this.submitLoading = true;
3017
+ doSubmitTicket({ body, sessionId: this.sessionId, url: url.href })
3018
+ .then(() => {
3019
+ showNotification({ message: translate('ticketSubmitted', this.language) });
3020
+ this.clearBulletConfig();
3021
+ })
3022
+ .catch((res) => {
3023
+ if (res.message === TICKET_INVALID_TOKEN) {
3024
+ this.logoutEventHandler.emit();
3025
+ showNotification({ message: TICKET_INVALID_TOKEN, theme: 'error' });
3026
+ return;
3027
+ }
3028
+ showNotification({ message: translate('ticketFailed', this.language), theme: 'error' });
3029
+ })
3030
+ .finally(() => {
3031
+ this.submitLoading = false;
3032
+ });
3033
+ }
3034
+ get lineCountRender() {
3035
+ const _ = thousandSeparator(this.totalLineCombination);
3036
+ let unit = translate('lines', this.language);
3037
+ if ([0, 1].includes(+_))
3038
+ unit = translate('line', this.language);
3039
+ return _ + ' ' + unit;
3040
+ }
3041
+ renderBettingControls() {
3042
+ const renderSkeleton = () => (index.h("div", { class: "skeleton-content" }, index.h("div", { class: "skeleton-item skeleton-animated" })));
3043
+ const renderBettingTypeOptions = () => (index.h("div", { class: "LotteryTippingTicketController__segmented-control" }, this.bettingTypeOptions.map((item) => (index.h("button", { class: {
3044
+ LotteryTippingTicketController__segment: true,
3045
+ 'LotteryTippingTicketController__segment--active': this.selectedBettingType === item.code
3046
+ }, onClick: this.handleBettingTypeChange.bind(this, item.code) }, item.name)))));
3047
+ const renderPlayingModeOptions = () => (index.h("div", { class: "LotteryTippingTicketController__segmented-control" }, this.playingModeOptions.map((item) => (index.h("button", { class: {
3048
+ LotteryTippingTicketController__segment: true,
3049
+ 'LotteryTippingTicketController__segment--active': this.selectedPlayingMode === item.code
3050
+ }, onClick: this.handlePlayingModeChange.bind(this, item.code) }, item.name)))));
3051
+ return (index.h("div", { class: "LotteryTippingTicketController__top" }, index.h("div", { class: "LotteryTippingTicketController__row" }, index.h("div", { class: "LotteryTippingTicketController__section" }, index.h("span", { class: "LotteryTippingTicketController__label" }, translate('bettingType', this.language)), !!this.bettingTypeOptions.length ? renderBettingTypeOptions() : renderSkeleton()), index.h("div", { class: "LotteryTippingTicketController__section" }, index.h("span", { class: "LotteryTippingTicketController__label" }, translate('playingMode', this.language)), !!this.playingModeOptions.length ? renderPlayingModeOptions() : renderSkeleton()))));
3052
+ }
3053
+ renderOrderSummary() {
3054
+ return (index.h("div", { class: "LotteryTippingTicketController__main--right order-summary" }, index.h("h3", { class: "order-summary__title" }, translate('orderSummaryTitle', this.language)), index.h("div", { class: "order-summary__ticket-info" }, index.h("div", { class: "order-summary__ticket" }, translate('orderSummaryTickets', this.language), ":"), index.h("div", { class: "order-summary__details" }, index.h("span", { class: "order-summary__line-count" }, this.lineCountRender), index.h("div", null, this.currentStake && index.h("span", { class: "order-summary__multiplier" }, "x"), index.h("span", { class: "order-summary__stake" }, this.currentStakeFormatted)), this.isBothBettingType && (index.h("div", null, index.h("span", { class: "order-summary__multiplier" }, "x"), index.h("span", { class: "order-summary__stake" }, "2"))))), index.h("hr", { class: "order-summary__divider" }), index.h("div", { class: "order-summary__ticket-info" }, index.h("div", { class: "order-summary__ticket" }, translate('orderSummaryTotal', this.language), ":"), index.h("span", { class: "order-summary__details" }, this.totalAmountFormatted)), index.h("div", { class: "order-summary__button-wrapper" }, index.h("button", { class: {
3055
+ 'order-summary__button': true,
3056
+ 'order-summary__button--disabled': !this.hasSelectAllBullet || this.submitLoading
3057
+ }, onClick: this.handleSubmit.bind(this), disabled: !this.hasSelectAllBullet || this.submitLoading }, index.h("div", { class: "flex align-center gap-1" }, translate('orderSummarySubmit', this.language), this.submitLoading && index.h("img", { src: this.loadingImagePath }))))));
3058
+ }
3059
+ render() {
3060
+ var _a, _b, _c, _d, _e, _f, _g;
3061
+ return (index.h("div", { key: '1220c944e6c4112ed4d2fa379f23d53f6778a4e6', class: "lottery-tipping-ticket-controller__container", ref: (el) => (this.stylingContainer = el) }, index.h("lottery-tipping-ticket-banner", { key: '9e8e96e16e5bcbae74388143395a73948323028d', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl, stopTime: (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.wagerCloseTime, period: (_d = (_c = this.rawData) === null || _c === void 0 ? void 0 : _c.currentDraw) === null || _d === void 0 ? void 0 : _d.date, language: this.language, "translation-url": this.translationUrl }), this.renderBettingControls(), index.h("div", { key: 'f83d2fba0d0c1ccb3abdf6352b494f95271b0228', class: "flex flex-wrap LotteryTippingTicketController__main" }, index.h("div", { key: 'd21c037aa6959881fad4eb0acf6965bb15e8d04a', class: "LotteryTippingTicketController__main--left" }, index.h("lottery-tipping-ticket-bet", { key: 'fe116242696925a3c3c7468f636fef01232aac4f', ref: (el) => (this.childRef = el), endpoint: this.endpoint, "session-id": this.sessionId, "game-id": (_e = this.rawData) === null || _e === void 0 ? void 0 : _e.type, "draw-id": this.drawId, language: this.language, "translation-url": this.translationUrl, "max-total-pages": this.lineNumberRange.maxLineNumber, "min-total-pages": this.lineNumberRange.minLineNumber, "total-pages": this.lineNumberRange.defaultBoards, mode: this.selectedPlayingMode === PlayModeEnum.SingleBet ? 'single' : 'multi', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })), this.renderOrderSummary()), this.dialogConfig.visible && (index.h("vaadin-confirm-dialog", { key: '6d4e6ba62d4393118eb2f7f505121d717cfe103d', rejectButtonVisible: true, rejectText: translate('cancel', this.language), confirmText: translate('confirm', this.language), opened: (_f = this.dialogConfig) === null || _f === void 0 ? void 0 : _f.visible, onConfirm: this.dialogConfig.onConfirm, onReject: this.dialogConfig.onCancel }, (_g = this.dialogConfig) === null || _g === void 0 ? void 0 : _g.content))));
3062
+ }
3063
+ static get assetsDirs() { return ["../static"]; }
3064
+ static get watchers() { return {
3065
+ "clientStyling": ["handleClientStylingChange"],
3066
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
3067
+ "mbSource": ["handleMbSourceChange"]
3068
+ }; }
3069
+ };
3070
+ LotteryTippingTicketController.style = LotteryTippingTicketControllerStyle0;
3071
+
3072
+ exports.LotteryTippingTicketController = LotteryTippingTicketController;
3073
+ exports.format = format;
3074
+ exports.formatDate = formatDate;
3075
+ exports.parseISO = parseISO;
3076
+ exports.requiredArgs = requiredArgs;
3077
+ exports.resolveTranslationUrl = resolveTranslationUrl;
3078
+ exports.setClientStyling = setClientStyling;
3079
+ exports.setClientStylingURL = setClientStylingURL;
3080
+ exports.setStreamStyling = setStreamStyling;
3081
+ exports.toDate = toDate;