@everymatrix/lottery-tipping-ticket-controller 1.85.14 → 1.85.16

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