@everymatrix/user-transaction-history 1.75.0 → 1.75.1

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