@paperless/core 0.1.0-alpha.303 → 0.1.0-alpha.304

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