@everymatrix/lottery-tipping-ticket-history 1.87.26 → 1.87.28

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