@internationalized/date 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js ADDED
@@ -0,0 +1,2637 @@
1
+ import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
2
+ import _babelRuntimeHelpersEsmClassPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+ // Data from https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
16
+ // Locales starting on Sunday have been removed for compression.
17
+ const $a895780b391a18bdc653c6a504739e8$export$weekStartData = {
18
+ '001': 1,
19
+ AD: 1,
20
+ AE: 6,
21
+ AF: 6,
22
+ AI: 1,
23
+ AL: 1,
24
+ AM: 1,
25
+ AN: 1,
26
+ AT: 1,
27
+ AX: 1,
28
+ AZ: 1,
29
+ BA: 1,
30
+ BE: 1,
31
+ BG: 1,
32
+ BH: 6,
33
+ BM: 1,
34
+ BN: 1,
35
+ BY: 1,
36
+ CH: 1,
37
+ CL: 1,
38
+ CM: 1,
39
+ CR: 1,
40
+ CY: 1,
41
+ CZ: 1,
42
+ DE: 1,
43
+ DJ: 6,
44
+ DK: 1,
45
+ DZ: 6,
46
+ EC: 1,
47
+ EE: 1,
48
+ EG: 6,
49
+ ES: 1,
50
+ FI: 1,
51
+ FJ: 1,
52
+ FO: 1,
53
+ FR: 1,
54
+ GB: 1,
55
+ GE: 1,
56
+ GF: 1,
57
+ GP: 1,
58
+ GR: 1,
59
+ HR: 1,
60
+ HU: 1,
61
+ IE: 1,
62
+ IQ: 6,
63
+ IR: 6,
64
+ IS: 1,
65
+ IT: 1,
66
+ JO: 6,
67
+ KG: 1,
68
+ KW: 6,
69
+ KZ: 1,
70
+ LB: 1,
71
+ LI: 1,
72
+ LK: 1,
73
+ LT: 1,
74
+ LU: 1,
75
+ LV: 1,
76
+ LY: 6,
77
+ MC: 1,
78
+ MD: 1,
79
+ ME: 1,
80
+ MK: 1,
81
+ MN: 1,
82
+ MQ: 1,
83
+ MV: 5,
84
+ MY: 1,
85
+ NL: 1,
86
+ NO: 1,
87
+ NZ: 1,
88
+ OM: 6,
89
+ PL: 1,
90
+ QA: 6,
91
+ RE: 1,
92
+ RO: 1,
93
+ RS: 1,
94
+ RU: 1,
95
+ SD: 6,
96
+ SE: 1,
97
+ SI: 1,
98
+ SK: 1,
99
+ SM: 1,
100
+ SY: 6,
101
+ TJ: 1,
102
+ TM: 1,
103
+ TR: 1,
104
+ UA: 1,
105
+ UY: 1,
106
+ UZ: 1,
107
+ VA: 1,
108
+ VN: 1,
109
+ XK: 1
110
+ };
111
+ export function isSameDay(a, b) {
112
+ b = toCalendar(b, a.calendar);
113
+ return a.era === b.era && a.year === b.year && a.month === b.month && a.day === b.day;
114
+ }
115
+ export function isSameMonth(a, b) {
116
+ b = toCalendar(b, a.calendar); // In the Japanese calendar, months can span multiple eras/years, so only compare the first of the month.
117
+
118
+ a = startOfMonth(a);
119
+ b = startOfMonth(b);
120
+ return a.era === b.era && a.year === b.year && a.month === b.month;
121
+ }
122
+ export function isSameYear(a, b) {
123
+ b = toCalendar(b, a.calendar);
124
+ a = startOfYear(a);
125
+ b = startOfYear(b);
126
+ return a.era === b.era && a.year === b.year;
127
+ }
128
+ export function isEqualDay(a, b) {
129
+ return a.calendar.identifier === b.calendar.identifier && a.era === b.era && a.year === b.year && a.month === b.month && a.day === b.day;
130
+ }
131
+ export function isEqualMonth(a, b) {
132
+ a = startOfMonth(a);
133
+ b = startOfMonth(b);
134
+ return a.calendar.identifier === b.calendar.identifier && a.era === b.era && a.year === b.year && a.month === b.month;
135
+ }
136
+ export function isEqualYear(a, b) {
137
+ a = startOfYear(a);
138
+ b = startOfYear(b);
139
+ return a.calendar.identifier === b.calendar.identifier && a.era === b.era && a.year === b.year;
140
+ }
141
+ export function isToday(date, timeZone) {
142
+ return isSameDay(date, today(timeZone));
143
+ }
144
+ export function getDayOfWeek(date, locale) {
145
+ let julian = date.calendar.toJulianDay(date); // If julian is negative, then julian % 7 will be negative, so we adjust
146
+ // accordingly. Julian day 0 is Monday.
147
+
148
+ let dayOfWeek = Math.ceil(julian + 1 - $e027b4c65f8a8a64bf868330c10585e$var$getWeekStart(locale)) % 7;
149
+
150
+ if (dayOfWeek < 0) {
151
+ dayOfWeek += 7;
152
+ }
153
+
154
+ return dayOfWeek;
155
+ }
156
+ export function now(timeZone) {
157
+ return fromAbsolute(Date.now(), timeZone);
158
+ }
159
+ export function today(timeZone) {
160
+ return toCalendarDate(now(timeZone));
161
+ }
162
+ export function compareDate(a, b) {
163
+ return a.calendar.toJulianDay(a) - b.calendar.toJulianDay(b);
164
+ }
165
+ export function compareTime(a, b) {
166
+ return $e027b4c65f8a8a64bf868330c10585e$var$timeToMs(a) - $e027b4c65f8a8a64bf868330c10585e$var$timeToMs(b);
167
+ }
168
+
169
+ function $e027b4c65f8a8a64bf868330c10585e$var$timeToMs(a) {
170
+ return a.hour * 60 * 60 * 1000 + a.minute * 60 * 1000 + a.second * 1000 + a.millisecond;
171
+ }
172
+
173
+ export function getHoursInDay(a, timeZone) {
174
+ let ms = toAbsolute(a, timeZone);
175
+ let tomorrow = a.add({
176
+ days: 1
177
+ });
178
+ let tomorrowMs = toAbsolute(tomorrow, timeZone);
179
+ return (tomorrowMs - ms) / 3600000;
180
+ }
181
+ let $e027b4c65f8a8a64bf868330c10585e$var$localTimeZone = null;
182
+ export function getLocalTimeZone() {
183
+ // TODO: invalidate this somehow?
184
+ if ($e027b4c65f8a8a64bf868330c10585e$var$localTimeZone == null) {
185
+ $e027b4c65f8a8a64bf868330c10585e$var$localTimeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
186
+ }
187
+
188
+ return $e027b4c65f8a8a64bf868330c10585e$var$localTimeZone;
189
+ }
190
+ export function startOfMonth(date) {
191
+ // Use `subtract` instead of `set` so we don't get constrained in an era.
192
+ return date.subtract({
193
+ days: date.day - 1
194
+ });
195
+ }
196
+ export function endOfMonth(date) {
197
+ return date.add({
198
+ days: date.calendar.getDaysInMonth(date) - date.day
199
+ });
200
+ }
201
+ export function startOfYear(date) {
202
+ return startOfMonth(date.subtract({
203
+ months: date.month - 1
204
+ }));
205
+ }
206
+ export function endOfYear(date) {
207
+ return endOfMonth(date.add({
208
+ months: date.calendar.getMonthsInYear(date) - date.month
209
+ }));
210
+ }
211
+ export function getMinimumMonthInYear(date) {
212
+ if (date.calendar.getMinimumMonthInYear) {
213
+ return date.calendar.getMinimumMonthInYear(date);
214
+ }
215
+
216
+ return 1;
217
+ }
218
+ export function getMinimumDayInMonth(date) {
219
+ if (date.calendar.getMinimumDayInMonth) {
220
+ return date.calendar.getMinimumDayInMonth(date);
221
+ }
222
+
223
+ return 1;
224
+ }
225
+ export function startOfWeek(date, locale) {
226
+ let dayOfWeek = getDayOfWeek(date, locale);
227
+ return date.subtract({
228
+ days: dayOfWeek
229
+ });
230
+ }
231
+ export function endOfWeek(date, locale) {
232
+ return startOfWeek(date, locale).add({
233
+ days: 6
234
+ });
235
+ }
236
+ const $e027b4c65f8a8a64bf868330c10585e$var$cachedRegions = new Map();
237
+
238
+ function $e027b4c65f8a8a64bf868330c10585e$var$getRegion(locale) {
239
+ // If the Intl.Locale API is available, use it to get the region for the locale.
240
+ // @ts-ignore
241
+ if (Intl.Locale) {
242
+ // Constructing an Intl.Locale is expensive, so cache the result.
243
+ let region = $e027b4c65f8a8a64bf868330c10585e$var$cachedRegions.get(locale);
244
+
245
+ if (!region) {
246
+ // @ts-ignore
247
+ region = new Intl.Locale(locale).maximize().region;
248
+ $e027b4c65f8a8a64bf868330c10585e$var$cachedRegions.set(locale, region);
249
+ }
250
+
251
+ return region;
252
+ } // If not, just try splitting the string.
253
+ // If the second part of the locale string is 'u',
254
+ // then this is a unicode extension, so ignore it.
255
+ // Otherwise, it should be the region.
256
+
257
+
258
+ let part = locale.split('-')[1];
259
+ return part === 'u' ? null : part;
260
+ }
261
+
262
+ function $e027b4c65f8a8a64bf868330c10585e$var$getWeekStart(locale) {
263
+ // TODO: use Intl.Locale for this once browsers support the weekInfo property
264
+ // https://github.com/tc39/proposal-intl-locale-info
265
+ let region = $e027b4c65f8a8a64bf868330c10585e$var$getRegion(locale);
266
+ return $a895780b391a18bdc653c6a504739e8$export$weekStartData[region] || 0;
267
+ }
268
+
269
+ export function getWeeksInMonth(date, locale) {
270
+ let days = date.calendar.getDaysInMonth(date);
271
+ return Math.ceil((getDayOfWeek(startOfMonth(date), locale) + days) / 7);
272
+ }
273
+ export function minDate(a, b) {
274
+ return a.compare(b) <= 0 ? a : b;
275
+ }
276
+ export function maxDate(a, b) {
277
+ return a.compare(b) >= 0 ? a : b;
278
+ }
279
+
280
+ function $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(amount, numerator) {
281
+ return amount - numerator * Math.floor(amount / numerator);
282
+ }
283
+
284
+ const $d9ab185420a4ffb38f7504d41a330b3a$var$EPOCH = 1721426; // 001/01/03 Julian C.E.
285
+
286
+ function $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(year, month, day) {
287
+ let y1 = year - 1;
288
+ let monthOffset = -2;
289
+
290
+ if (month <= 2) {
291
+ monthOffset = 0;
292
+ } else if ($d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(year)) {
293
+ monthOffset = -1;
294
+ }
295
+
296
+ return $d9ab185420a4ffb38f7504d41a330b3a$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day);
297
+ }
298
+
299
+ function $d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(year) {
300
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
301
+ }
302
+
303
+ const $d9ab185420a4ffb38f7504d41a330b3a$var$daysInMonth = {
304
+ standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
305
+ leapyear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
306
+ };
307
+ export class GregorianCalendar {
308
+ constructor() {
309
+ this.identifier = 'gregory';
310
+ }
311
+
312
+ fromJulianDay(jd) {
313
+ let jd0 = jd;
314
+ let depoch = jd0 - $d9ab185420a4ffb38f7504d41a330b3a$var$EPOCH;
315
+ let quadricent = Math.floor(depoch / 146097);
316
+ let dqc = $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(depoch, 146097);
317
+ let cent = Math.floor(dqc / 36524);
318
+ let dcent = $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(dqc, 36524);
319
+ let quad = Math.floor(dcent / 1461);
320
+ let dquad = $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(dcent, 1461);
321
+ let yindex = Math.floor(dquad / 365);
322
+ let year = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);
323
+ let yearDay = jd0 - $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(year, 1, 1);
324
+ let leapAdj = 2;
325
+
326
+ if (jd0 < $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(year, 3, 1)) {
327
+ leapAdj = 0;
328
+ } else if ($d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(year)) {
329
+ leapAdj = 1;
330
+ }
331
+
332
+ let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);
333
+ let day = jd0 - $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(year, month, 1) + 1;
334
+ return new CalendarDate(this, year, month, day);
335
+ }
336
+
337
+ toJulianDay(date) {
338
+ return $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(date.year, date.month, date.day);
339
+ }
340
+
341
+ getDaysInMonth(date) {
342
+ return $d9ab185420a4ffb38f7504d41a330b3a$var$daysInMonth[$d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(date.year) ? 'leapyear' : 'standard'][date.month - 1];
343
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
344
+
345
+
346
+ getMonthsInYear(date) {
347
+ return 12;
348
+ }
349
+
350
+ getDaysInYear(date) {
351
+ return $d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(date.year) ? 366 : 365;
352
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
353
+
354
+
355
+ getYearsInEra(date) {
356
+ return 9999;
357
+ }
358
+
359
+ getEras() {
360
+ return ['BC', 'AD'];
361
+ }
362
+
363
+ getYearsToAdd(date, years) {
364
+ return date.era === 'BC' ? -years : years;
365
+ }
366
+
367
+ balanceDate(date) {
368
+ if (date.year <= 0) {
369
+ date.era = date.era === 'BC' ? 'AD' : 'BC';
370
+ date.year = 1 - date.year;
371
+ }
372
+ }
373
+
374
+ }
375
+ export function epochFromDate(date) {
376
+ date = toCalendar(date, new GregorianCalendar());
377
+ return $a44339c76f31b4f380c2753cbb9f3$var$epochFromParts(date.year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);
378
+ }
379
+
380
+ function $a44339c76f31b4f380c2753cbb9f3$var$epochFromParts(year, month, day, hour, minute, second, millisecond) {
381
+ // Note: Date.UTC() interprets one and two-digit years as being in the
382
+ // 20th century, so don't use it
383
+ let date = new Date();
384
+ date.setUTCHours(hour, minute, second, millisecond);
385
+ date.setUTCFullYear(year, month - 1, day);
386
+ return date.getTime();
387
+ }
388
+
389
+ export function getTimeZoneOffset(ms, timeZone) {
390
+ // Fast path: for local timezone, use native Date.
391
+ if (timeZone === getLocalTimeZone()) {
392
+ return new Date(ms).getTimezoneOffset() * -60 * 1000;
393
+ }
394
+
395
+ let {
396
+ year,
397
+ month,
398
+ day,
399
+ hour,
400
+ minute,
401
+ second
402
+ } = $a44339c76f31b4f380c2753cbb9f3$var$getTimeZoneParts(ms, timeZone);
403
+ let utc = $a44339c76f31b4f380c2753cbb9f3$var$epochFromParts(year, month, day, hour, minute, second, 0);
404
+ return utc - Math.floor(ms / 1000) * 1000;
405
+ }
406
+ const $a44339c76f31b4f380c2753cbb9f3$var$formattersByTimeZone = new Map();
407
+
408
+ function $a44339c76f31b4f380c2753cbb9f3$var$getTimeZoneParts(ms, timeZone) {
409
+ let formatter = $a44339c76f31b4f380c2753cbb9f3$var$formattersByTimeZone.get(timeZone);
410
+
411
+ if (!formatter) {
412
+ formatter = new Intl.DateTimeFormat('en-US', {
413
+ timeZone,
414
+ hour12: false,
415
+ era: 'short',
416
+ year: 'numeric',
417
+ month: 'numeric',
418
+ day: 'numeric',
419
+ hour: 'numeric',
420
+ minute: 'numeric',
421
+ second: 'numeric'
422
+ });
423
+ $a44339c76f31b4f380c2753cbb9f3$var$formattersByTimeZone.set(timeZone, formatter);
424
+ }
425
+
426
+ let parts = formatter.formatToParts(new Date(ms));
427
+ let namedParts = {};
428
+
429
+ for (let part of parts) {
430
+ if (part.type !== 'literal') {
431
+ namedParts[part.type] = part.value;
432
+ }
433
+ }
434
+
435
+ return {
436
+ year: namedParts.era === 'BC' ? -namedParts.year + 1 : +namedParts.year,
437
+ month: +namedParts.month,
438
+ day: +namedParts.day,
439
+ hour: namedParts.hour === '24' ? 0 : +namedParts.hour,
440
+ // bugs.chromium.org/p/chromium/issues/detail?id=1045791
441
+ minute: +namedParts.minute,
442
+ second: +namedParts.second
443
+ };
444
+ }
445
+
446
+ const $a44339c76f31b4f380c2753cbb9f3$var$DAYMILLIS = 86400000;
447
+ export function possibleAbsolutes(date, timeZone) {
448
+ let ms = epochFromDate(date);
449
+ let earlier = ms - getTimeZoneOffset(ms - $a44339c76f31b4f380c2753cbb9f3$var$DAYMILLIS, timeZone);
450
+ let later = ms - getTimeZoneOffset(ms + $a44339c76f31b4f380c2753cbb9f3$var$DAYMILLIS, timeZone);
451
+ return $a44339c76f31b4f380c2753cbb9f3$var$getValidWallTimes(date, timeZone, earlier, later);
452
+ }
453
+
454
+ function $a44339c76f31b4f380c2753cbb9f3$var$getValidWallTimes(date, timeZone, earlier, later) {
455
+ let found = earlier === later ? [earlier] : [earlier, later];
456
+ return found.filter(absolute => $a44339c76f31b4f380c2753cbb9f3$var$isValidWallTime(date, timeZone, absolute));
457
+ }
458
+
459
+ function $a44339c76f31b4f380c2753cbb9f3$var$isValidWallTime(date, timeZone, absolute) {
460
+ let parts = $a44339c76f31b4f380c2753cbb9f3$var$getTimeZoneParts(absolute, timeZone);
461
+ return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second;
462
+ }
463
+
464
+ export function toAbsolute(date, timeZone, disambiguation) {
465
+ if (disambiguation === void 0) {
466
+ disambiguation = 'compatible';
467
+ }
468
+
469
+ let dateTime = toCalendarDateTime(date); // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.
470
+
471
+ if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {
472
+ dateTime = toCalendar(dateTime, new GregorianCalendar()); // Don't use Date constructor here because two-digit years are interpreted in the 20th century.
473
+
474
+ let date = new Date();
475
+ date.setFullYear(dateTime.year, dateTime.month - 1, dateTime.day);
476
+ date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
477
+ return date.getTime();
478
+ }
479
+
480
+ let ms = epochFromDate(dateTime);
481
+ let offsetBefore = getTimeZoneOffset(ms - $a44339c76f31b4f380c2753cbb9f3$var$DAYMILLIS, timeZone);
482
+ let offsetAfter = getTimeZoneOffset(ms + $a44339c76f31b4f380c2753cbb9f3$var$DAYMILLIS, timeZone);
483
+ let valid = $a44339c76f31b4f380c2753cbb9f3$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);
484
+
485
+ if (valid.length === 1) {
486
+ return valid[0];
487
+ }
488
+
489
+ if (valid.length > 1) {
490
+ switch (disambiguation) {
491
+ // 'compatible' means 'earlier' for "fall back" transitions
492
+ case 'compatible':
493
+ case 'earlier':
494
+ return valid[0];
495
+
496
+ case 'later':
497
+ return valid[valid.length - 1];
498
+
499
+ case 'reject':
500
+ throw new RangeError('Multiple possible absolute times found');
501
+ }
502
+ }
503
+
504
+ switch (disambiguation) {
505
+ case 'earlier':
506
+ return Math.min(ms - offsetBefore, ms - offsetAfter);
507
+ // 'compatible' means 'later' for "spring forward" transitions
508
+
509
+ case 'compatible':
510
+ case 'later':
511
+ return Math.max(ms - offsetBefore, ms - offsetAfter);
512
+
513
+ case 'reject':
514
+ throw new RangeError('No such absolute time found');
515
+ }
516
+ }
517
+ export function toDate(dateTime, timeZone, disambiguation) {
518
+ if (disambiguation === void 0) {
519
+ disambiguation = 'compatible';
520
+ }
521
+
522
+ return new Date(toAbsolute(dateTime, timeZone, disambiguation));
523
+ }
524
+ export function fromAbsolute(ms, timeZone) {
525
+ let offset = getTimeZoneOffset(ms, timeZone);
526
+ let date = new Date(ms + offset);
527
+ let year = date.getUTCFullYear();
528
+ let month = date.getUTCMonth() + 1;
529
+ let day = date.getUTCDate();
530
+ let hour = date.getUTCHours();
531
+ let minute = date.getUTCMinutes();
532
+ let second = date.getUTCSeconds();
533
+ let millisecond = date.getUTCMilliseconds();
534
+ return new ZonedDateTime(year, month, day, timeZone, offset, hour, minute, second, millisecond);
535
+ }
536
+ export function fromDate(date, timeZone) {
537
+ return fromAbsolute(date.getTime(), timeZone);
538
+ }
539
+ export function fromDateToLocal(date) {
540
+ return fromDate(date, getLocalTimeZone());
541
+ }
542
+ export function toCalendarDate(dateTime) {
543
+ return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);
544
+ }
545
+ export function toDateFields(date) {
546
+ return {
547
+ era: date.era,
548
+ year: date.year,
549
+ month: date.month,
550
+ day: date.day
551
+ };
552
+ }
553
+ export function toTimeFields(date) {
554
+ return {
555
+ hour: date.hour,
556
+ minute: date.minute,
557
+ second: date.second,
558
+ millisecond: date.millisecond
559
+ };
560
+ }
561
+ export function toCalendarDateTime(date, time) {
562
+ let hour = 0,
563
+ minute = 0,
564
+ second = 0,
565
+ millisecond = 0;
566
+
567
+ if ('timeZone' in date) {
568
+ ({
569
+ hour,
570
+ minute,
571
+ second,
572
+ millisecond
573
+ } = date);
574
+ } else if ('hour' in date && !time) {
575
+ return date;
576
+ }
577
+
578
+ if (time) {
579
+ ({
580
+ hour,
581
+ minute,
582
+ second,
583
+ millisecond
584
+ } = time);
585
+ }
586
+
587
+ return new CalendarDateTime(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond);
588
+ }
589
+ export function toTime(dateTime) {
590
+ return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
591
+ }
592
+ export function toCalendar(date, calendar) {
593
+ if (date.calendar.identifier === calendar.identifier) {
594
+ return date;
595
+ }
596
+
597
+ let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
598
+ let copy = date.copy();
599
+ copy.calendar = calendar;
600
+ copy.era = calendarDate.era;
601
+ copy.year = calendarDate.year;
602
+ copy.month = calendarDate.month;
603
+ copy.day = calendarDate.day;
604
+ return copy;
605
+ }
606
+ export function toZoned(date, timeZone, disambiguation) {
607
+ if (date instanceof ZonedDateTime) {
608
+ if (date.timeZone === timeZone) {
609
+ return date;
610
+ }
611
+
612
+ return toTimeZone(date, timeZone);
613
+ }
614
+
615
+ let ms = toAbsolute(date, timeZone, disambiguation);
616
+ return fromAbsolute(ms, timeZone);
617
+ }
618
+ export function zonedToDate(date) {
619
+ let ms = epochFromDate(date) - date.offset;
620
+ return new Date(ms);
621
+ }
622
+ export function toTimeZone(date, timeZone) {
623
+ let ms = epochFromDate(date) - date.offset;
624
+ return toCalendar(fromAbsolute(ms, timeZone), date.calendar);
625
+ }
626
+ export function toLocalTimeZone(date) {
627
+ return toTimeZone(date, getLocalTimeZone());
628
+ }
629
+ const $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$ONE_HOUR = 3600000;
630
+
631
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$add(date, duration) {
632
+ let mutableDate = date.copy();
633
+ let days = 'hour' in date ? $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addTimeFields(date, duration) : 0;
634
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addYears(mutableDate, duration.years || 0);
635
+
636
+ if (mutableDate.calendar.balanceYearMonth) {
637
+ mutableDate.calendar.balanceYearMonth(mutableDate, date);
638
+ }
639
+
640
+ mutableDate.month += duration.months || 0;
641
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceYearMonth(mutableDate);
642
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$constrainMonthDay(mutableDate);
643
+ mutableDate.day += (duration.weeks || 0) * 7;
644
+ mutableDate.day += duration.days || 0;
645
+ mutableDate.day += days;
646
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceDay(mutableDate);
647
+
648
+ if (mutableDate.calendar.balanceDate) {
649
+ mutableDate.calendar.balanceDate(mutableDate);
650
+ }
651
+
652
+ return mutableDate;
653
+ }
654
+
655
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addYears(date, years) {
656
+ if (date.calendar.getYearsToAdd) {
657
+ years = date.calendar.getYearsToAdd(date, years);
658
+ }
659
+
660
+ date.year += years;
661
+ }
662
+
663
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceYearMonth(date) {
664
+ while (date.month < 1) {
665
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addYears(date, -1);
666
+ date.month += date.calendar.getMonthsInYear(date);
667
+ }
668
+
669
+ let monthsInYear = 0;
670
+
671
+ while (date.month > (monthsInYear = date.calendar.getMonthsInYear(date))) {
672
+ date.month -= monthsInYear;
673
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addYears(date, 1);
674
+ }
675
+ }
676
+
677
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceDay(date) {
678
+ while (date.day < 1) {
679
+ date.month--;
680
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceYearMonth(date);
681
+ date.day += date.calendar.getDaysInMonth(date);
682
+ }
683
+
684
+ while (date.day > date.calendar.getDaysInMonth(date)) {
685
+ date.day -= date.calendar.getDaysInMonth(date);
686
+ date.month++;
687
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceYearMonth(date);
688
+ }
689
+ }
690
+
691
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$constrainMonthDay(date) {
692
+ date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));
693
+ date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));
694
+ }
695
+
696
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(date) {
697
+ if (date.calendar.constrainDate) {
698
+ date.calendar.constrainDate(date);
699
+ }
700
+
701
+ date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));
702
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$constrainMonthDay(date);
703
+ }
704
+
705
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$invertDuration(duration) {
706
+ let inverseDuration = {};
707
+
708
+ for (let key in duration) {
709
+ if (typeof duration[key] === 'number') {
710
+ inverseDuration[key] = -duration[key];
711
+ }
712
+ }
713
+
714
+ return inverseDuration;
715
+ }
716
+
717
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtract(date, duration) {
718
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$add(date, $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$invertDuration(duration));
719
+ }
720
+
721
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$set(date, fields) {
722
+ let mutableDate = date.copy();
723
+
724
+ if (fields.era != null) {
725
+ mutableDate.era = fields.era;
726
+ }
727
+
728
+ if (fields.year != null) {
729
+ mutableDate.year = fields.year;
730
+ }
731
+
732
+ if (fields.month != null) {
733
+ mutableDate.month = fields.month;
734
+ }
735
+
736
+ if (fields.day != null) {
737
+ mutableDate.day = fields.day;
738
+ }
739
+
740
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(mutableDate);
741
+ return mutableDate;
742
+ }
743
+
744
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setTime(value, fields) {
745
+ let mutableValue = value.copy();
746
+
747
+ if (fields.hour != null) {
748
+ mutableValue.hour = fields.hour;
749
+ }
750
+
751
+ if (fields.minute != null) {
752
+ mutableValue.minute = fields.minute;
753
+ }
754
+
755
+ if (fields.second != null) {
756
+ mutableValue.second = fields.second;
757
+ }
758
+
759
+ if (fields.millisecond != null) {
760
+ mutableValue.millisecond = fields.millisecond;
761
+ }
762
+
763
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrainTime(mutableValue);
764
+ return mutableValue;
765
+ }
766
+
767
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceTime(time) {
768
+ time.second += Math.floor(time.millisecond / 1000);
769
+ time.millisecond = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$nonNegativeMod(time.millisecond, 1000);
770
+ time.minute += Math.floor(time.second / 60);
771
+ time.second = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$nonNegativeMod(time.second, 60);
772
+ time.hour += Math.floor(time.minute / 60);
773
+ time.minute = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$nonNegativeMod(time.minute, 60);
774
+ let days = Math.floor(time.hour / 24);
775
+ time.hour = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$nonNegativeMod(time.hour, 24);
776
+ return days;
777
+ }
778
+
779
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrainTime(time) {
780
+ time.millisecond = Math.max(0, Math.min(time.millisecond, 1000));
781
+ time.second = Math.max(0, Math.min(time.second, 59));
782
+ time.minute = Math.max(0, Math.min(time.minute, 59));
783
+ time.hour = Math.max(0, Math.min(time.hour, 23));
784
+ }
785
+
786
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$nonNegativeMod(a, b) {
787
+ let result = a % b;
788
+
789
+ if (result < 0) {
790
+ result += b;
791
+ }
792
+
793
+ return result;
794
+ }
795
+
796
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addTimeFields(time, duration) {
797
+ time.hour += duration.hours || 0;
798
+ time.minute += duration.minutes || 0;
799
+ time.second += duration.seconds || 0;
800
+ time.millisecond += duration.milliseconds || 0;
801
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$balanceTime(time);
802
+ }
803
+
804
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$addTime(time, duration) {
805
+ let res = time.copy();
806
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$addTimeFields(res, duration);
807
+ return res;
808
+ }
809
+
810
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtractTime(time, duration) {
811
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$addTime(time, $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$invertDuration(duration));
812
+ }
813
+
814
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleDate(value, field, amount, options) {
815
+ let mutable = value.copy();
816
+
817
+ switch (field) {
818
+ case 'era':
819
+ {
820
+ let eras = value.calendar.getEras();
821
+ let eraIndex = eras.indexOf(value.era);
822
+
823
+ if (eraIndex < 0) {
824
+ throw new Error('Invalid era: ' + value.era);
825
+ }
826
+
827
+ eraIndex = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options == null ? void 0 : options.round);
828
+ mutable.era = eras[eraIndex]; // Constrain the year and other fields within the era, so the era doesn't change when we balance below.
829
+
830
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(mutable);
831
+ break;
832
+ }
833
+
834
+ case 'year':
835
+ {
836
+ if (mutable.calendar.getYearsToAdd) {
837
+ amount = mutable.calendar.getYearsToAdd(mutable, amount);
838
+ } // The year field should not cycle within the era as that can cause weird behavior affecting other fields.
839
+ // We need to also allow values < 1 so that decrementing goes to the previous era. If we get -Infinity back
840
+ // we know we wrapped around after reaching 9999 (the maximum), so set the year back to 1.
841
+
842
+
843
+ mutable.year = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value.year, amount, -Infinity, 9999, options == null ? void 0 : options.round);
844
+
845
+ if (mutable.year === -Infinity) {
846
+ mutable.year = 1;
847
+ }
848
+
849
+ if (mutable.calendar.balanceYearMonth) {
850
+ mutable.calendar.balanceYearMonth(mutable, value);
851
+ }
852
+
853
+ break;
854
+ }
855
+
856
+ case 'month':
857
+ mutable.month = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options == null ? void 0 : options.round);
858
+ break;
859
+
860
+ case 'day':
861
+ mutable.day = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options == null ? void 0 : options.round);
862
+ break;
863
+
864
+ default:
865
+ throw new Error('Unsupported field ' + field);
866
+ }
867
+
868
+ if (value.calendar.balanceDate) {
869
+ value.calendar.balanceDate(mutable);
870
+ }
871
+
872
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(mutable);
873
+ return mutable;
874
+ }
875
+
876
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleTime(value, field, amount, options) {
877
+ let mutable = value.copy();
878
+
879
+ switch (field) {
880
+ case 'hour':
881
+ {
882
+ let hours = value.hour;
883
+ let min = 0;
884
+ let max = 23;
885
+
886
+ if ((options == null ? void 0 : options.hourCycle) === 12) {
887
+ let isPM = hours >= 12;
888
+ min = isPM ? 12 : 0;
889
+ max = isPM ? 23 : 11;
890
+ }
891
+
892
+ mutable.hour = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(hours, amount, min, max, options == null ? void 0 : options.round);
893
+ break;
894
+ }
895
+
896
+ case 'minute':
897
+ mutable.minute = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value.minute, amount, 0, 59, options == null ? void 0 : options.round);
898
+ break;
899
+
900
+ case 'second':
901
+ mutable.second = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value.second, amount, 0, 59, options == null ? void 0 : options.round);
902
+ break;
903
+
904
+ case 'millisecond':
905
+ mutable.millisecond = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value.millisecond, amount, 0, 999, options == null ? void 0 : options.round);
906
+ break;
907
+
908
+ default:
909
+ throw new Error('Unsupported field ' + field);
910
+ }
911
+
912
+ return mutable;
913
+ }
914
+
915
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(value, amount, min, max, round) {
916
+ if (round === void 0) {
917
+ round = false;
918
+ }
919
+
920
+ if (round) {
921
+ value += Math.sign(amount);
922
+
923
+ if (value < min) {
924
+ value = max;
925
+ }
926
+
927
+ let div = Math.abs(amount);
928
+
929
+ if (amount > 0) {
930
+ value = Math.ceil(value / div) * div;
931
+ } else {
932
+ value = Math.floor(value / div) * div;
933
+ }
934
+
935
+ if (value > max) {
936
+ value = min;
937
+ }
938
+ } else {
939
+ value += amount;
940
+
941
+ if (value < min) {
942
+ value = max - (min - value - 1);
943
+ } else if (value > max) {
944
+ value = min + (value - max - 1);
945
+ }
946
+ }
947
+
948
+ return value;
949
+ }
950
+
951
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$addZoned(dateTime, duration) {
952
+ let ms;
953
+
954
+ if (duration.years != null && duration.years !== 0 || duration.months != null && duration.months !== 0 || duration.days != null && duration.days !== 0) {
955
+ let res = $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$add(toCalendarDateTime(dateTime), {
956
+ years: duration.years,
957
+ months: duration.months,
958
+ days: duration.days
959
+ }); // Changing the date may change the timezone offset, so we need to recompute
960
+ // using the 'compatible' disambiguation.
961
+
962
+ ms = toAbsolute(res, dateTime.timeZone);
963
+ } else {
964
+ // Otherwise, preserve the offset of the original date.
965
+ ms = epochFromDate(dateTime) - dateTime.offset;
966
+ } // Perform time manipulation in milliseconds rather than on the original time fields to account for DST.
967
+ // For example, adding one hour during a DST transition may result in the hour field staying the same or
968
+ // skipping an hour. This results in the offset field changing value instead of the specified field.
969
+
970
+
971
+ ms += duration.milliseconds || 0;
972
+ ms += (duration.seconds || 0) * 1000;
973
+ ms += (duration.minutes || 0) * 60 * 1000;
974
+ ms += (duration.hours || 0) * 60 * 60 * 1000;
975
+ let res = fromAbsolute(ms, dateTime.timeZone);
976
+ return toCalendar(res, dateTime.calendar);
977
+ }
978
+
979
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtractZoned(dateTime, duration) {
980
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$addZoned(dateTime, $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$invertDuration(duration));
981
+ }
982
+
983
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleZoned(dateTime, field, amount, options) {
984
+ // For date fields, we want the time to remain consistent and the UTC offset to potentially change to account for DST changes.
985
+ // For time fields, we want the time to change by the amount given. This may result in the hour field staying the same, but the UTC
986
+ // offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition.
987
+ switch (field) {
988
+ case 'hour':
989
+ {
990
+ let min = 0;
991
+ let max = 23;
992
+
993
+ if ((options == null ? void 0 : options.hourCycle) === 12) {
994
+ let isPM = dateTime.hour >= 12;
995
+ min = isPM ? 12 : 0;
996
+ max = isPM ? 23 : 11;
997
+ } // The minimum and maximum hour may be affected by daylight saving time.
998
+ // For example, it might jump forward at midnight, and skip 1am.
999
+ // Or it might end at midnight and repeat the 11pm hour. To handle this, we get
1000
+ // the possible absolute times for the min and max, and find the maximum range
1001
+ // that is within the current day.
1002
+
1003
+
1004
+ let plainDateTime = toCalendarDateTime(dateTime);
1005
+ let minDate = toCalendar($bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setTime(plainDateTime, {
1006
+ hour: min
1007
+ }), new GregorianCalendar());
1008
+ let minAbsolute = [toAbsolute(minDate, dateTime.timeZone, 'earlier'), toAbsolute(minDate, dateTime.timeZone, 'later')].filter(ms => fromAbsolute(ms, dateTime.timeZone).day === minDate.day)[0];
1009
+ let maxDate = toCalendar($bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setTime(plainDateTime, {
1010
+ hour: max
1011
+ }), new GregorianCalendar());
1012
+ let maxAbsolute = [toAbsolute(maxDate, dateTime.timeZone, 'earlier'), toAbsolute(maxDate, dateTime.timeZone, 'later')].filter(ms => fromAbsolute(ms, dateTime.timeZone).day === maxDate.day).pop(); // Since hours may repeat, we need to operate on the absolute time in milliseconds.
1013
+ // This is done in hours from the Unix epoch so that cycleValue works correctly,
1014
+ // and then converted back to milliseconds.
1015
+
1016
+ let ms = epochFromDate(dateTime) - dateTime.offset;
1017
+ let hours = Math.floor(ms / $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$ONE_HOUR);
1018
+ let remainder = ms % $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$ONE_HOUR;
1019
+ ms = $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$cycleValue(hours, amount, Math.floor(minAbsolute / $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$ONE_HOUR), Math.floor(maxAbsolute / $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$ONE_HOUR), options == null ? void 0 : options.round) * $bacf9a69bf9753afe9f94cd9dd8aa2ad$var$ONE_HOUR + remainder; // Now compute the new timezone offset, and convert the absolute time back to local time.
1020
+
1021
+ return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
1022
+ }
1023
+
1024
+ case 'minute':
1025
+ case 'second':
1026
+ case 'millisecond':
1027
+ // @ts-ignore
1028
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleTime(dateTime, field, amount, options);
1029
+
1030
+ case 'era':
1031
+ case 'year':
1032
+ case 'month':
1033
+ case 'day':
1034
+ {
1035
+ let res = $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleDate(toCalendarDateTime(dateTime), field, amount, options);
1036
+ let ms = toAbsolute(res, dateTime.timeZone);
1037
+ return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
1038
+ }
1039
+
1040
+ default:
1041
+ throw new Error('Unsupported field ' + field);
1042
+ }
1043
+ }
1044
+
1045
+ function $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setZoned(dateTime, fields, disambiguation) {
1046
+ // Set the date/time fields, and recompute the UTC offset to account for DST changes.
1047
+ // We also need to validate by converting back to a local time in case hours are skipped during forward DST transitions.
1048
+ let plainDateTime = toCalendarDateTime(dateTime);
1049
+ let res = $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setTime($bacf9a69bf9753afe9f94cd9dd8aa2ad$export$set(plainDateTime, fields), fields); // If the resulting plain date time values are equal, return the original time.
1050
+ // We don't want to change the offset when setting the time to the same value.
1051
+
1052
+ if (res.compare(plainDateTime) === 0) {
1053
+ return dateTime;
1054
+ }
1055
+
1056
+ let ms = toAbsolute(res, dateTime.timeZone, disambiguation);
1057
+ return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
1058
+ }
1059
+
1060
+ const $c02c03a25b07d7f5b716aff41996250f$var$TIME_RE = /^(\d{2})(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/;
1061
+ const $c02c03a25b07d7f5b716aff41996250f$var$DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
1062
+ const $c02c03a25b07d7f5b716aff41996250f$var$DATE_TIME_RE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/;
1063
+ const $c02c03a25b07d7f5b716aff41996250f$var$ZONED_DATE_TIME_RE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:([+-]\d{2})(?::(\d{2}))?)?\[(.*?)\]$/;
1064
+ const $c02c03a25b07d7f5b716aff41996250f$var$ABSOLUTE_RE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::(\d{2}))?)|Z)$/;
1065
+ export function parseTime(value) {
1066
+ let m = value.match($c02c03a25b07d7f5b716aff41996250f$var$TIME_RE);
1067
+
1068
+ if (!m) {
1069
+ throw new Error('Invalid ISO 8601 time string: ' + value);
1070
+ }
1071
+
1072
+ return new Time($c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[1], 0, 23), m[2] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[2], 0, 59) : 0, m[3] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[3], 0, 59) : 0, m[4] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[4], 0, Infinity) * 1000 : 0);
1073
+ }
1074
+ export function parseDate(value) {
1075
+ let m = value.match($c02c03a25b07d7f5b716aff41996250f$var$DATE_RE);
1076
+
1077
+ if (!m) {
1078
+ throw new Error('Invalid ISO 8601 date string: ' + value);
1079
+ }
1080
+
1081
+ let date = new CalendarDate($c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[1], 0, 9999), $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[2], 1, 12), 1);
1082
+ date.day = $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
1083
+ return date;
1084
+ }
1085
+ export function parseDateTime(value) {
1086
+ let m = value.match($c02c03a25b07d7f5b716aff41996250f$var$DATE_TIME_RE);
1087
+
1088
+ if (!m) {
1089
+ throw new Error('Invalid ISO 8601 date time string: ' + value);
1090
+ }
1091
+
1092
+ let date = new CalendarDateTime($c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[1], 1, 9999), $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[2], 1, 12), 1, m[4] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[4], 0, 23) : 0, m[5] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[5], 0, 59) : 0, m[6] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[6], 0, 59) : 0, m[7] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[7], 0, Infinity) * 1000 : 0);
1093
+ date.day = $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
1094
+ return date;
1095
+ }
1096
+ export function parseZonedDateTime(value, disambiguation) {
1097
+ let m = value.match($c02c03a25b07d7f5b716aff41996250f$var$ZONED_DATE_TIME_RE);
1098
+
1099
+ if (!m) {
1100
+ throw new Error('Invalid ISO 8601 date time string: ' + value);
1101
+ }
1102
+
1103
+ let date = new ZonedDateTime($c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[1], 1, 9999), $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[2], 1, 12), 1, m[10], 0, m[4] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[4], 0, 23) : 0, m[5] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[5], 0, 59) : 0, m[6] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[6], 0, 59) : 0, m[7] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[7], 0, Infinity) * 1000 : 0);
1104
+ date.day = $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
1105
+ let plainDateTime = toCalendarDateTime(date);
1106
+ let ms;
1107
+
1108
+ if (m[8]) {
1109
+ var _m$;
1110
+
1111
+ date.offset = $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[8], -23, 23) * 60 * 60 * 1000 + $c02c03a25b07d7f5b716aff41996250f$var$parseNumber((_m$ = m[9]) != null ? _m$ : '0', 0, 59) * 60 * 1000;
1112
+ ms = epochFromDate(date) - date.offset; // Validate offset against parsed date.
1113
+
1114
+ let absolutes = possibleAbsolutes(plainDateTime, date.timeZone);
1115
+
1116
+ if (!absolutes.includes(ms)) {
1117
+ throw new Error("Offset " + $c02c03a25b07d7f5b716aff41996250f$var$offsetToString(date.offset) + " is invalid for " + dateTimeToString(date) + " in " + date.timeZone);
1118
+ }
1119
+ } else {
1120
+ // Convert to absolute and back to fix invalid times due to DST.
1121
+ ms = toAbsolute(toCalendarDateTime(plainDateTime), date.timeZone, disambiguation);
1122
+ }
1123
+
1124
+ return fromAbsolute(ms, date.timeZone);
1125
+ }
1126
+ export function parseAbsolute(value, timeZone) {
1127
+ let m = value.match($c02c03a25b07d7f5b716aff41996250f$var$ABSOLUTE_RE);
1128
+
1129
+ if (!m) {
1130
+ throw new Error('Invalid ISO 8601 date time string: ' + value);
1131
+ }
1132
+
1133
+ let date = new ZonedDateTime($c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[1], 1, 9999), $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[2], 1, 12), 1, timeZone, 0, m[4] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[4], 0, 23) : 0, m[5] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[5], 0, 59) : 0, m[6] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[6], 0, 59) : 0, m[7] ? $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[7], 0, Infinity) * 1000 : 0);
1134
+ date.day = $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[3], 0, date.calendar.getDaysInMonth(date));
1135
+
1136
+ if (m[8]) {
1137
+ var _m$2;
1138
+
1139
+ date.offset = $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(m[8], -23, 23) * 60 * 60 * 1000 + $c02c03a25b07d7f5b716aff41996250f$var$parseNumber((_m$2 = m[9]) != null ? _m$2 : '0', 0, 59) * 60 * 1000;
1140
+ }
1141
+
1142
+ return toTimeZone(date, timeZone);
1143
+ }
1144
+ export function parseAbsoluteToLocal(value) {
1145
+ return parseAbsolute(value, getLocalTimeZone());
1146
+ }
1147
+
1148
+ function $c02c03a25b07d7f5b716aff41996250f$var$parseNumber(value, min, max) {
1149
+ let val = Number(value);
1150
+
1151
+ if (val < min || val > max) {
1152
+ throw new RangeError("Value out of range: " + min + " <= " + val + " <= " + max);
1153
+ }
1154
+
1155
+ return val;
1156
+ }
1157
+
1158
+ export function timeToString(time) {
1159
+ return String(time.hour).padStart(2, '0') + ":" + String(time.minute).padStart(2, '0') + ":" + String(time.second).padStart(2, '0') + (time.millisecond ? String(time.millisecond / 1000).slice(1) : '');
1160
+ }
1161
+ export function dateToString(date) {
1162
+ let gregorianDate = toCalendar(date, new GregorianCalendar());
1163
+ return String(gregorianDate.year).padStart(4, '0') + "-" + String(gregorianDate.month).padStart(2, '0') + "-" + String(gregorianDate.day).padStart(2, '0');
1164
+ }
1165
+ export function dateTimeToString(date) {
1166
+ // @ts-ignore
1167
+ return dateToString(date) + "T" + timeToString(date);
1168
+ }
1169
+
1170
+ function $c02c03a25b07d7f5b716aff41996250f$var$offsetToString(offset) {
1171
+ let sign = Math.sign(offset) < 0 ? '-' : '+';
1172
+ offset = Math.abs(offset);
1173
+ let offsetHours = Math.floor(offset / (60 * 60 * 1000));
1174
+ let offsetMinutes = offset % (60 * 60 * 1000) / (60 * 1000);
1175
+ return "" + sign + String(offsetHours).padStart(2, '0') + ":" + String(offsetMinutes).padStart(2, '0');
1176
+ }
1177
+
1178
+ export function zonedDateTimeToString(date) {
1179
+ return "" + dateTimeToString(date) + $c02c03a25b07d7f5b716aff41996250f$var$offsetToString(date.offset) + "[" + date.timeZone + "]";
1180
+ }
1181
+
1182
+ function $a390250d74cf918aad5b3b22927402a$var$shiftArgs(args) {
1183
+ let calendar = typeof args[0] === 'object' ? args.shift() : new GregorianCalendar();
1184
+ let era;
1185
+
1186
+ if (typeof args[0] === 'string') {
1187
+ era = args.shift();
1188
+ } else {
1189
+ let eras = calendar.getEras();
1190
+ era = eras[eras.length - 1];
1191
+ }
1192
+
1193
+ let year = args.shift();
1194
+ let month = args.shift();
1195
+ let day = args.shift();
1196
+ return [calendar, era, year, month, day];
1197
+ }
1198
+
1199
+ var $a390250d74cf918aad5b3b22927402a$var$_type = _babelRuntimeHelpersEsmClassPrivateFieldLooseKey("type");
1200
+
1201
+ export class CalendarDate {
1202
+ // This prevents TypeScript from allowing other types with the same fields to match.
1203
+ // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.
1204
+ // If that behavior is desired, use the AnyCalendarDate interface instead.
1205
+ constructor() {
1206
+ Object.defineProperty(this, $a390250d74cf918aad5b3b22927402a$var$_type, {
1207
+ writable: true,
1208
+ value: void 0
1209
+ });
1210
+ this.calendar = void 0;
1211
+ this.era = void 0;
1212
+ this.year = void 0;
1213
+ this.month = void 0;
1214
+ this.day = void 0;
1215
+
1216
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1217
+ args[_key] = arguments[_key];
1218
+ }
1219
+
1220
+ let [calendar, era, year, month, day] = $a390250d74cf918aad5b3b22927402a$var$shiftArgs(args);
1221
+ this.calendar = calendar;
1222
+ this.era = era;
1223
+ this.year = year;
1224
+ this.month = month;
1225
+ this.day = day;
1226
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(this);
1227
+ }
1228
+
1229
+ copy() {
1230
+ if (this.era) {
1231
+ return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);
1232
+ } else {
1233
+ return new CalendarDate(this.calendar, this.year, this.month, this.day);
1234
+ }
1235
+ }
1236
+
1237
+ add(duration) {
1238
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$add(this, duration);
1239
+ }
1240
+
1241
+ subtract(duration) {
1242
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtract(this, duration);
1243
+ }
1244
+
1245
+ set(fields) {
1246
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$set(this, fields);
1247
+ }
1248
+
1249
+ cycle(field, amount, options) {
1250
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleDate(this, field, amount, options);
1251
+ }
1252
+
1253
+ toDate(timeZone) {
1254
+ return toDate(this, timeZone);
1255
+ }
1256
+
1257
+ toString() {
1258
+ return dateToString(this);
1259
+ }
1260
+
1261
+ compare(b) {
1262
+ return compareDate(this, b);
1263
+ }
1264
+
1265
+ }
1266
+
1267
+ var $a390250d74cf918aad5b3b22927402a$var$_type2 = _babelRuntimeHelpersEsmClassPrivateFieldLooseKey("type");
1268
+
1269
+ export class Time {
1270
+ // This prevents TypeScript from allowing other types with the same fields to match.
1271
+ constructor(hour = 0, minute = 0, second = 0, millisecond = 0) {
1272
+ this.hour = hour;
1273
+ this.minute = minute;
1274
+ this.second = second;
1275
+ this.millisecond = millisecond;
1276
+ Object.defineProperty(this, $a390250d74cf918aad5b3b22927402a$var$_type2, {
1277
+ writable: true,
1278
+ value: void 0
1279
+ });
1280
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrainTime(this);
1281
+ }
1282
+
1283
+ copy() {
1284
+ return new Time(this.hour, this.minute, this.second, this.millisecond);
1285
+ }
1286
+
1287
+ add(duration) {
1288
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$addTime(this, duration);
1289
+ }
1290
+
1291
+ subtract(duration) {
1292
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtractTime(this, duration);
1293
+ }
1294
+
1295
+ set(fields) {
1296
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setTime(this, fields);
1297
+ }
1298
+
1299
+ cycle(field, amount, options) {
1300
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleTime(this, field, amount, options);
1301
+ }
1302
+
1303
+ toString() {
1304
+ return timeToString(this);
1305
+ }
1306
+
1307
+ compare(b) {
1308
+ return compareTime(this, b);
1309
+ }
1310
+
1311
+ }
1312
+
1313
+ var $a390250d74cf918aad5b3b22927402a$var$_type3 = _babelRuntimeHelpersEsmClassPrivateFieldLooseKey("type");
1314
+
1315
+ export class CalendarDateTime {
1316
+ // This prevents TypeScript from allowing other types with the same fields to match.
1317
+ constructor() {
1318
+ Object.defineProperty(this, $a390250d74cf918aad5b3b22927402a$var$_type3, {
1319
+ writable: true,
1320
+ value: void 0
1321
+ });
1322
+ this.calendar = void 0;
1323
+ this.era = void 0;
1324
+ this.year = void 0;
1325
+ this.month = void 0;
1326
+ this.day = void 0;
1327
+ this.hour = void 0;
1328
+ this.minute = void 0;
1329
+ this.second = void 0;
1330
+ this.millisecond = void 0;
1331
+
1332
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1333
+ args[_key2] = arguments[_key2];
1334
+ }
1335
+
1336
+ let [calendar, era, year, month, day] = $a390250d74cf918aad5b3b22927402a$var$shiftArgs(args);
1337
+ this.calendar = calendar;
1338
+ this.era = era;
1339
+ this.year = year;
1340
+ this.month = month;
1341
+ this.day = day;
1342
+ this.hour = args.shift() || 0;
1343
+ this.minute = args.shift() || 0;
1344
+ this.second = args.shift() || 0;
1345
+ this.millisecond = args.shift() || 0;
1346
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(this);
1347
+ }
1348
+
1349
+ copy() {
1350
+ if (this.era) {
1351
+ return new CalendarDateTime(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
1352
+ } else {
1353
+ return new CalendarDateTime(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
1354
+ }
1355
+ }
1356
+
1357
+ add(duration) {
1358
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$add(this, duration);
1359
+ }
1360
+
1361
+ subtract(duration) {
1362
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtract(this, duration);
1363
+ }
1364
+
1365
+ set(fields) {
1366
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$set($bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setTime(this, fields), fields);
1367
+ }
1368
+
1369
+ cycle(field, amount, options) {
1370
+ switch (field) {
1371
+ case 'era':
1372
+ case 'year':
1373
+ case 'month':
1374
+ case 'day':
1375
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleDate(this, field, amount, options);
1376
+
1377
+ default:
1378
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleTime(this, field, amount, options);
1379
+ }
1380
+ }
1381
+
1382
+ toDate(timeZone) {
1383
+ return toDate(this, timeZone);
1384
+ }
1385
+
1386
+ toString() {
1387
+ return dateTimeToString(this);
1388
+ }
1389
+
1390
+ compare(b) {
1391
+ let res = compareDate(this, b);
1392
+
1393
+ if (res === 0) {
1394
+ return compareTime(this, toCalendarDateTime(b));
1395
+ }
1396
+
1397
+ return res;
1398
+ }
1399
+
1400
+ }
1401
+
1402
+ var $a390250d74cf918aad5b3b22927402a$var$_type4 = _babelRuntimeHelpersEsmClassPrivateFieldLooseKey("type");
1403
+
1404
+ export class ZonedDateTime {
1405
+ // This prevents TypeScript from allowing other types with the same fields to match.
1406
+ constructor() {
1407
+ Object.defineProperty(this, $a390250d74cf918aad5b3b22927402a$var$_type4, {
1408
+ writable: true,
1409
+ value: void 0
1410
+ });
1411
+ this.calendar = void 0;
1412
+ this.era = void 0;
1413
+ this.year = void 0;
1414
+ this.month = void 0;
1415
+ this.day = void 0;
1416
+ this.hour = void 0;
1417
+ this.minute = void 0;
1418
+ this.second = void 0;
1419
+ this.millisecond = void 0;
1420
+ this.timeZone = void 0;
1421
+ this.offset = void 0;
1422
+
1423
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1424
+ args[_key3] = arguments[_key3];
1425
+ }
1426
+
1427
+ let [calendar, era, year, month, day] = $a390250d74cf918aad5b3b22927402a$var$shiftArgs(args);
1428
+ let timeZone = args.shift();
1429
+ let offset = args.shift();
1430
+ this.calendar = calendar;
1431
+ this.era = era;
1432
+ this.year = year;
1433
+ this.month = month;
1434
+ this.day = day;
1435
+ this.timeZone = timeZone;
1436
+ this.offset = offset;
1437
+ this.hour = args.shift() || 0;
1438
+ this.minute = args.shift() || 0;
1439
+ this.second = args.shift() || 0;
1440
+ this.millisecond = args.shift() || 0;
1441
+ $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$constrain(this);
1442
+ }
1443
+
1444
+ copy() {
1445
+ if (this.era) {
1446
+ return new ZonedDateTime(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
1447
+ } else {
1448
+ return new ZonedDateTime(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
1449
+ }
1450
+ }
1451
+
1452
+ add(duration) {
1453
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$addZoned(this, duration);
1454
+ }
1455
+
1456
+ subtract(duration) {
1457
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$subtractZoned(this, duration);
1458
+ }
1459
+
1460
+ set(fields, disambiguation) {
1461
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$setZoned(this, fields, disambiguation);
1462
+ }
1463
+
1464
+ cycle(field, amount, options) {
1465
+ return $bacf9a69bf9753afe9f94cd9dd8aa2ad$export$cycleZoned(this, field, amount, options);
1466
+ }
1467
+
1468
+ toDate() {
1469
+ return zonedToDate(this);
1470
+ }
1471
+
1472
+ toString() {
1473
+ return zonedDateTimeToString(this);
1474
+ }
1475
+
1476
+ toAbsoluteString() {
1477
+ return this.toDate().toISOString();
1478
+ }
1479
+
1480
+ compare(b) {
1481
+ // TODO: Is this a bad idea??
1482
+ return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();
1483
+ }
1484
+
1485
+ }
1486
+ const $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8], [2019, 5, 1]];
1487
+ const $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_END_DATES = [[1912, 7, 29], [1926, 12, 24], [1989, 1, 7], [2019, 4, 30]];
1488
+ const $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];
1489
+ const $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];
1490
+
1491
+ function $f8ec25d0a093dcb9c8555fe0814edf2c$var$findEraFromGregorianDate(date) {
1492
+ const idx = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES.findIndex((_ref) => {
1493
+ let [year, month, day] = _ref;
1494
+
1495
+ if (date.year < year) {
1496
+ return true;
1497
+ }
1498
+
1499
+ if (date.year === year && date.month < month) {
1500
+ return true;
1501
+ }
1502
+
1503
+ if (date.year === year && date.month === month && date.day < day) {
1504
+ return true;
1505
+ }
1506
+
1507
+ return false;
1508
+ });
1509
+
1510
+ if (idx === -1) {
1511
+ return $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES.length - 1;
1512
+ }
1513
+
1514
+ if (idx === 0) {
1515
+ return 0;
1516
+ }
1517
+
1518
+ return idx - 1;
1519
+ }
1520
+
1521
+ function $f8ec25d0a093dcb9c8555fe0814edf2c$var$toGregorian(date) {
1522
+ let eraAddend = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_ADDENDS[$f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES.indexOf(date.era)];
1523
+
1524
+ if (!eraAddend) {
1525
+ throw new Error('Unknown era: ' + date.era);
1526
+ }
1527
+
1528
+ return new CalendarDate(date.year + eraAddend, date.month, date.day);
1529
+ }
1530
+
1531
+ export class JapaneseCalendar extends GregorianCalendar {
1532
+ constructor() {
1533
+ super(...arguments);
1534
+ this.identifier = 'japanese';
1535
+ }
1536
+
1537
+ fromJulianDay(jd) {
1538
+ let date = super.fromJulianDay(jd);
1539
+ let era = $f8ec25d0a093dcb9c8555fe0814edf2c$var$findEraFromGregorianDate(date);
1540
+ date.era = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES[era];
1541
+ date.year -= $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_ADDENDS[era];
1542
+ return date;
1543
+ }
1544
+
1545
+ toJulianDay(date) {
1546
+ return super.toJulianDay($f8ec25d0a093dcb9c8555fe0814edf2c$var$toGregorian(date));
1547
+ }
1548
+
1549
+ balanceDate(date) {
1550
+ let gregorianDate = $f8ec25d0a093dcb9c8555fe0814edf2c$var$toGregorian(date);
1551
+ let era = $f8ec25d0a093dcb9c8555fe0814edf2c$var$findEraFromGregorianDate(gregorianDate);
1552
+
1553
+ if ($f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES[era] !== date.era) {
1554
+ date.era = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES[era];
1555
+ date.year = gregorianDate.year - $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_ADDENDS[era];
1556
+ }
1557
+ }
1558
+
1559
+ constrainDate(date) {
1560
+ let idx = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES.indexOf(date.era);
1561
+ let end = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_END_DATES[idx];
1562
+
1563
+ if (end != null) {
1564
+ let [endYear, endMonth, endDay] = end; // Constrain the year to the maximum possible value in the era.
1565
+ // Then constrain the month and day fields within that.
1566
+
1567
+ let maxYear = endYear - $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_ADDENDS[idx];
1568
+ date.year = Math.min(maxYear, date.year);
1569
+
1570
+ if (date.year === maxYear) {
1571
+ date.month = Math.min(endMonth, date.month);
1572
+
1573
+ if (date.month === endMonth) {
1574
+ date.day = Math.min(endDay, date.day);
1575
+ }
1576
+ }
1577
+
1578
+ if (date.year === 1) {
1579
+ let [, startMonth, startDay] = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES[idx];
1580
+ date.month = Math.max(startMonth, date.month);
1581
+
1582
+ if (date.month === startMonth) {
1583
+ date.day = Math.max(startDay, date.day);
1584
+ }
1585
+ }
1586
+ }
1587
+ }
1588
+
1589
+ getEras() {
1590
+ return $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES;
1591
+ }
1592
+
1593
+ getYearsInEra(date) {
1594
+ // Get the number of years in the era, taking into account the date's month and day fields.
1595
+ let era = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES.indexOf(date.era);
1596
+ let next = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES[era + 1];
1597
+
1598
+ if (next == null) {
1599
+ return 9999;
1600
+ }
1601
+
1602
+ let cur = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES[era];
1603
+ let years = next[0] - cur[0];
1604
+
1605
+ if (date.month < next[1] || date.month === next[1] && date.day < next[2]) {
1606
+ years++;
1607
+ }
1608
+
1609
+ return years;
1610
+ }
1611
+
1612
+ getMinimumMonthInYear(date) {
1613
+ let start = $f8ec25d0a093dcb9c8555fe0814edf2c$var$getMinimums(date);
1614
+ return start ? start[1] : 1;
1615
+ }
1616
+
1617
+ getMinimumDayInMonth(date) {
1618
+ let start = $f8ec25d0a093dcb9c8555fe0814edf2c$var$getMinimums(date);
1619
+ return start && date.month === start[1] ? start[2] : 1;
1620
+ }
1621
+
1622
+ }
1623
+
1624
+ function $f8ec25d0a093dcb9c8555fe0814edf2c$var$getMinimums(date) {
1625
+ if (date.year === 1) {
1626
+ let idx = $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_NAMES.indexOf(date.era);
1627
+ return $f8ec25d0a093dcb9c8555fe0814edf2c$var$ERA_START_DATES[idx];
1628
+ }
1629
+ }
1630
+
1631
+ const $c3ac3d7d08bcbe41bf4ee53f1885ac37$var$BUDDHIST_ERA_START = -543;
1632
+ export class BuddhistCalendar extends GregorianCalendar {
1633
+ constructor() {
1634
+ super(...arguments);
1635
+ this.identifier = 'buddhist';
1636
+ }
1637
+
1638
+ fromJulianDay(jd) {
1639
+ let date = super.fromJulianDay(jd);
1640
+ date.year -= $c3ac3d7d08bcbe41bf4ee53f1885ac37$var$BUDDHIST_ERA_START;
1641
+ return date;
1642
+ }
1643
+
1644
+ toJulianDay(date) {
1645
+ return super.toJulianDay(new CalendarDate(date.year + $c3ac3d7d08bcbe41bf4ee53f1885ac37$var$BUDDHIST_ERA_START, date.month, date.day));
1646
+ }
1647
+
1648
+ getEras() {
1649
+ return ['BE'];
1650
+ }
1651
+
1652
+ }
1653
+ const $a1f87b3cef47dd44f95e400d2f520895$var$TAIWAN_ERA_START = 1911;
1654
+
1655
+ function $a1f87b3cef47dd44f95e400d2f520895$var$gregorianYear(date) {
1656
+ return date.era === 'minguo' ? date.year + $a1f87b3cef47dd44f95e400d2f520895$var$TAIWAN_ERA_START : 1 - date.year + $a1f87b3cef47dd44f95e400d2f520895$var$TAIWAN_ERA_START;
1657
+ }
1658
+
1659
+ function $a1f87b3cef47dd44f95e400d2f520895$var$gregorianToTaiwan(year, date) {
1660
+ let y = year - $a1f87b3cef47dd44f95e400d2f520895$var$TAIWAN_ERA_START;
1661
+
1662
+ if (y > 0) {
1663
+ date.era = 'minguo';
1664
+ date.year = y;
1665
+ } else {
1666
+ date.era = 'before_minguo';
1667
+ date.year = 1 - y;
1668
+ }
1669
+ }
1670
+
1671
+ export class TaiwanCalendar extends GregorianCalendar {
1672
+ constructor() {
1673
+ super(...arguments);
1674
+ this.identifier = 'roc';
1675
+ }
1676
+
1677
+ // Republic of China
1678
+ fromJulianDay(jd) {
1679
+ let date = super.fromJulianDay(jd);
1680
+ $a1f87b3cef47dd44f95e400d2f520895$var$gregorianToTaiwan(date.year, date);
1681
+ return date;
1682
+ }
1683
+
1684
+ toJulianDay(date) {
1685
+ return super.toJulianDay(new CalendarDate($a1f87b3cef47dd44f95e400d2f520895$var$gregorianYear(date), date.month, date.day));
1686
+ }
1687
+
1688
+ getEras() {
1689
+ return ['before_minguo', 'minguo'];
1690
+ }
1691
+
1692
+ balanceDate(date) {
1693
+ $a1f87b3cef47dd44f95e400d2f520895$var$gregorianToTaiwan($a1f87b3cef47dd44f95e400d2f520895$var$gregorianYear(date), date);
1694
+ }
1695
+
1696
+ getYearsToAdd(date, years) {
1697
+ return date.era === 'before_minguo' ? -years : years;
1698
+ }
1699
+
1700
+ }
1701
+ const $aa128395b22a5a8486d031f5e52cc5$var$PERSIAN_EPOCH = 1948321; // 622/03/19 Julian C.E.
1702
+
1703
+ function $aa128395b22a5a8486d031f5e52cc5$var$isLeapYear(year) {
1704
+ let y0 = year > 0 ? year - 474 : year - 473;
1705
+ let y1 = $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(y0, 2820) + 474;
1706
+ return $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod((y1 + 38) * 31, 128) < 31;
1707
+ }
1708
+
1709
+ function $aa128395b22a5a8486d031f5e52cc5$var$persianToJulianDay(year, month, day) {
1710
+ let y0 = year > 0 ? year - 474 : year - 473;
1711
+ let y1 = $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(y0, 2820) + 474;
1712
+ let offset = month <= 7 ? 31 * (month - 1) : 30 * (month - 1) + 6;
1713
+ return $aa128395b22a5a8486d031f5e52cc5$var$PERSIAN_EPOCH - 1 + 1029983 * Math.floor(y0 / 2820) + 365 * (y1 - 1) + Math.floor((31 * y1 - 5) / 128) + offset + day;
1714
+ }
1715
+
1716
+ export class PersianCalendar {
1717
+ constructor() {
1718
+ this.identifier = 'persian';
1719
+ }
1720
+
1721
+ fromJulianDay(jd) {
1722
+ let d0 = jd - $aa128395b22a5a8486d031f5e52cc5$var$persianToJulianDay(475, 1, 1);
1723
+ let n2820 = Math.floor(d0 / 1029983);
1724
+ let d1 = $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(d0, 1029983);
1725
+ let y2820 = d1 === 1029982 ? 2820 : Math.floor((128 * d1 + 46878) / 46751);
1726
+ let year = 474 + 2820 * n2820 + y2820;
1727
+
1728
+ if (year <= 0) {
1729
+ year--;
1730
+ }
1731
+
1732
+ let yDay = jd - $aa128395b22a5a8486d031f5e52cc5$var$persianToJulianDay(year, 1, 1) + 1;
1733
+ let month = yDay <= 186 ? Math.ceil(yDay / 31) : Math.ceil((yDay - 6) / 31);
1734
+ let day = jd - $aa128395b22a5a8486d031f5e52cc5$var$persianToJulianDay(year, month, 1) + 1;
1735
+ return new CalendarDate(this, year, month, day);
1736
+ }
1737
+
1738
+ toJulianDay(date) {
1739
+ return $aa128395b22a5a8486d031f5e52cc5$var$persianToJulianDay(date.year, date.month, date.day);
1740
+ }
1741
+
1742
+ getMonthsInYear() {
1743
+ return 12;
1744
+ }
1745
+
1746
+ getDaysInMonth(date) {
1747
+ if (date.month <= 6) {
1748
+ return 31;
1749
+ }
1750
+
1751
+ if (date.month <= 11) {
1752
+ return 30;
1753
+ }
1754
+
1755
+ return $aa128395b22a5a8486d031f5e52cc5$var$isLeapYear(date.year) ? 30 : 29;
1756
+ }
1757
+
1758
+ getEras() {
1759
+ return ['AP'];
1760
+ }
1761
+
1762
+ getYearsInEra() {
1763
+ return 9999;
1764
+ }
1765
+
1766
+ }
1767
+ // Starts in 78 AD,
1768
+ const $a42213da061f74ad7729814d491de388$var$INDIAN_ERA_START = 78; // The Indian year starts 80 days later than the Gregorian year.
1769
+
1770
+ const $a42213da061f74ad7729814d491de388$var$INDIAN_YEAR_START = 80;
1771
+ export class IndianCalendar extends GregorianCalendar {
1772
+ constructor() {
1773
+ super(...arguments);
1774
+ this.identifier = 'indian';
1775
+ }
1776
+
1777
+ fromJulianDay(jd) {
1778
+ // Gregorian date for Julian day
1779
+ let date = super.fromJulianDay(jd); // Year in Saka era
1780
+
1781
+ let indianYear = date.year - $a42213da061f74ad7729814d491de388$var$INDIAN_ERA_START; // Day number in Gregorian year (starting from 0)
1782
+
1783
+ let yDay = jd - $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(date.year, 1, 1);
1784
+ let leapMonth;
1785
+
1786
+ if (yDay < $a42213da061f74ad7729814d491de388$var$INDIAN_YEAR_START) {
1787
+ // Day is at the end of the preceding Saka year
1788
+ indianYear--; // Days in leapMonth this year, previous Gregorian year
1789
+
1790
+ leapMonth = $d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(date.year - 1) ? 31 : 30;
1791
+ yDay += leapMonth + 31 * 5 + 30 * 3 + 10;
1792
+ } else {
1793
+ // Days in leapMonth this year
1794
+ leapMonth = $d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(date.year) ? 31 : 30;
1795
+ yDay -= $a42213da061f74ad7729814d491de388$var$INDIAN_YEAR_START;
1796
+ }
1797
+
1798
+ let indianMonth;
1799
+ let indianDay;
1800
+
1801
+ if (yDay < leapMonth) {
1802
+ indianMonth = 1;
1803
+ indianDay = yDay + 1;
1804
+ } else {
1805
+ let mDay = yDay - leapMonth;
1806
+
1807
+ if (mDay < 31 * 5) {
1808
+ indianMonth = Math.floor(mDay / 31) + 2;
1809
+ indianDay = mDay % 31 + 1;
1810
+ } else {
1811
+ mDay -= 31 * 5;
1812
+ indianMonth = Math.floor(mDay / 30) + 7;
1813
+ indianDay = mDay % 30 + 1;
1814
+ }
1815
+ }
1816
+
1817
+ return new CalendarDate(this, indianYear, indianMonth, indianDay);
1818
+ }
1819
+
1820
+ toJulianDay(date) {
1821
+ let year = date.year + $a42213da061f74ad7729814d491de388$var$INDIAN_ERA_START;
1822
+ let leapMonth;
1823
+ let jd;
1824
+
1825
+ if ($d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(year)) {
1826
+ leapMonth = 31;
1827
+ jd = $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(year, 3, 21);
1828
+ } else {
1829
+ leapMonth = 30;
1830
+ jd = $d9ab185420a4ffb38f7504d41a330b3a$export$gregorianToJulianDay(year, 3, 22);
1831
+ }
1832
+
1833
+ if (date.month === 1) {
1834
+ return jd + date.day - 1;
1835
+ }
1836
+
1837
+ jd += leapMonth + Math.min(date.month - 2, 5) * 31;
1838
+
1839
+ if (date.month >= 8) {
1840
+ jd += (date.month - 7) * 30;
1841
+ }
1842
+
1843
+ jd += date.day - 1;
1844
+ return jd;
1845
+ }
1846
+
1847
+ getDaysInMonth(date) {
1848
+ if (date.month === 1 && $d9ab185420a4ffb38f7504d41a330b3a$export$isLeapYear(date.year + $a42213da061f74ad7729814d491de388$var$INDIAN_ERA_START)) {
1849
+ return 31;
1850
+ }
1851
+
1852
+ if (date.month >= 2 && date.month <= 6) {
1853
+ return 31;
1854
+ }
1855
+
1856
+ return 30;
1857
+ }
1858
+
1859
+ getYearsInEra() {
1860
+ return 9999;
1861
+ }
1862
+
1863
+ getEras() {
1864
+ return ['saka'];
1865
+ }
1866
+
1867
+ }
1868
+ const $ab59ff19176390aebd417f116829f2f$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)
1869
+
1870
+ const $ab59ff19176390aebd417f116829f2f$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)
1871
+
1872
+ const $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START = 1300;
1873
+ const $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END = 1600;
1874
+ const $ab59ff19176390aebd417f116829f2f$var$UMALQURA_START_DAYS = 460322;
1875
+
1876
+ function $ab59ff19176390aebd417f116829f2f$var$islamicToJulianDay(epoch, year, month, day) {
1877
+ return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1;
1878
+ }
1879
+
1880
+ function $ab59ff19176390aebd417f116829f2f$var$julianDayToIslamic(calendar, epoch, jd) {
1881
+ let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);
1882
+ let month = Math.min(12, Math.ceil((jd - (29 + $ab59ff19176390aebd417f116829f2f$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1);
1883
+ let day = jd - $ab59ff19176390aebd417f116829f2f$var$islamicToJulianDay(epoch, year, month, 1) + 1;
1884
+ return new CalendarDate(calendar, year, month, day);
1885
+ }
1886
+
1887
+ function $ab59ff19176390aebd417f116829f2f$var$isLeapYear(year) {
1888
+ return (14 + 11 * year) % 30 < 11;
1889
+ }
1890
+
1891
+ export class IslamicCivilCalendar {
1892
+ constructor() {
1893
+ this.identifier = 'islamic-civil';
1894
+ }
1895
+
1896
+ fromJulianDay(jd) {
1897
+ return $ab59ff19176390aebd417f116829f2f$var$julianDayToIslamic(this, $ab59ff19176390aebd417f116829f2f$var$CIVIL_EPOC, jd);
1898
+ }
1899
+
1900
+ toJulianDay(date) {
1901
+ return $ab59ff19176390aebd417f116829f2f$var$islamicToJulianDay($ab59ff19176390aebd417f116829f2f$var$CIVIL_EPOC, date.year, date.month, date.day);
1902
+ }
1903
+
1904
+ getDaysInMonth(date) {
1905
+ let length = 29 + date.month % 2;
1906
+
1907
+ if (date.month === 12 && $ab59ff19176390aebd417f116829f2f$var$isLeapYear(date.year)) {
1908
+ length++;
1909
+ }
1910
+
1911
+ return length;
1912
+ }
1913
+
1914
+ getMonthsInYear() {
1915
+ return 12;
1916
+ }
1917
+
1918
+ getDaysInYear(date) {
1919
+ return $ab59ff19176390aebd417f116829f2f$var$isLeapYear(date.year) ? 355 : 354;
1920
+ }
1921
+
1922
+ getYearsInEra() {
1923
+ return 9999;
1924
+ }
1925
+
1926
+ getEras() {
1927
+ return ['AH'];
1928
+ }
1929
+
1930
+ }
1931
+ export class IslamicTabularCalendar extends IslamicCivilCalendar {
1932
+ constructor() {
1933
+ super(...arguments);
1934
+ this.identifier = 'islamic-tbla';
1935
+ }
1936
+
1937
+ fromJulianDay(jd) {
1938
+ return $ab59ff19176390aebd417f116829f2f$var$julianDayToIslamic(this, $ab59ff19176390aebd417f116829f2f$var$ASTRONOMICAL_EPOC, jd);
1939
+ }
1940
+
1941
+ toJulianDay(date) {
1942
+ return $ab59ff19176390aebd417f116829f2f$var$islamicToJulianDay($ab59ff19176390aebd417f116829f2f$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day);
1943
+ }
1944
+
1945
+ } // Generated by scripts/generate-umalqura.js
1946
+
1947
+ const $ab59ff19176390aebd417f116829f2f$var$UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';
1948
+ let $ab59ff19176390aebd417f116829f2f$var$UMALQURA_MONTHLENGTH;
1949
+ let $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE;
1950
+
1951
+ function $ab59ff19176390aebd417f116829f2f$var$umalquraYearStart(year) {
1952
+ return $ab59ff19176390aebd417f116829f2f$var$UMALQURA_START_DAYS + $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE[year - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START];
1953
+ }
1954
+
1955
+ function $ab59ff19176390aebd417f116829f2f$var$umalquraMonthLength(year, month) {
1956
+ let idx = year - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START;
1957
+ let mask = 0x01 << 11 - (month - 1);
1958
+
1959
+ if (($ab59ff19176390aebd417f116829f2f$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) {
1960
+ return 29;
1961
+ } else {
1962
+ return 30;
1963
+ }
1964
+ }
1965
+
1966
+ function $ab59ff19176390aebd417f116829f2f$var$umalquraMonthStart(year, month) {
1967
+ let day = $ab59ff19176390aebd417f116829f2f$var$umalquraYearStart(year);
1968
+
1969
+ for (let i = 1; i < month; i++) {
1970
+ day += $ab59ff19176390aebd417f116829f2f$var$umalquraMonthLength(year, i);
1971
+ }
1972
+
1973
+ return day;
1974
+ }
1975
+
1976
+ function $ab59ff19176390aebd417f116829f2f$var$umalquraYearLength(year) {
1977
+ return $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE[year + 1 - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START] - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE[year - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START];
1978
+ }
1979
+
1980
+ export class IslamicUmalquraCalendar extends IslamicCivilCalendar {
1981
+ constructor() {
1982
+ super();
1983
+ this.identifier = 'islamic-umalqura';
1984
+
1985
+ if (!$ab59ff19176390aebd417f116829f2f$var$UMALQURA_MONTHLENGTH) {
1986
+ $ab59ff19176390aebd417f116829f2f$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($ab59ff19176390aebd417f116829f2f$var$UMALQURA_DATA), c => c.charCodeAt(0)).buffer);
1987
+ }
1988
+
1989
+ if (!$ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE) {
1990
+ $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START + 1);
1991
+ let yearStart = 0;
1992
+
1993
+ for (let year = $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START; year <= $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END; year++) {
1994
+ $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START_TABLE[year - $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START] = yearStart;
1995
+
1996
+ for (let i = 1; i <= 12; i++) {
1997
+ yearStart += $ab59ff19176390aebd417f116829f2f$var$umalquraMonthLength(year, i);
1998
+ }
1999
+ }
2000
+ }
2001
+ }
2002
+
2003
+ fromJulianDay(jd) {
2004
+ let days = jd - $ab59ff19176390aebd417f116829f2f$var$CIVIL_EPOC;
2005
+ let startDays = $ab59ff19176390aebd417f116829f2f$var$umalquraYearStart($ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START);
2006
+ let endDays = $ab59ff19176390aebd417f116829f2f$var$umalquraYearStart($ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END);
2007
+
2008
+ if (days < startDays || days > endDays) {
2009
+ return super.fromJulianDay(jd);
2010
+ } else {
2011
+ let y = $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START - 1;
2012
+ let m = 1;
2013
+ let d = 1;
2014
+
2015
+ while (d > 0) {
2016
+ y++;
2017
+ d = days - $ab59ff19176390aebd417f116829f2f$var$umalquraYearStart(y) + 1;
2018
+ let yearLength = $ab59ff19176390aebd417f116829f2f$var$umalquraYearLength(y);
2019
+
2020
+ if (d === yearLength) {
2021
+ m = 12;
2022
+ break;
2023
+ } else if (d < yearLength) {
2024
+ let monthLength = $ab59ff19176390aebd417f116829f2f$var$umalquraMonthLength(y, m);
2025
+ m = 1;
2026
+
2027
+ while (d > monthLength) {
2028
+ d -= monthLength;
2029
+ m++;
2030
+ monthLength = $ab59ff19176390aebd417f116829f2f$var$umalquraMonthLength(y, m);
2031
+ }
2032
+
2033
+ break;
2034
+ }
2035
+ }
2036
+
2037
+ return new CalendarDate(this, y, m, days - $ab59ff19176390aebd417f116829f2f$var$umalquraMonthStart(y, m) + 1);
2038
+ }
2039
+ }
2040
+
2041
+ toJulianDay(date) {
2042
+ if (date.year < $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START || date.year > $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END) {
2043
+ return super.toJulianDay(date);
2044
+ }
2045
+
2046
+ return $ab59ff19176390aebd417f116829f2f$var$CIVIL_EPOC + $ab59ff19176390aebd417f116829f2f$var$umalquraMonthStart(date.year, date.month) + (date.day - 1);
2047
+ }
2048
+
2049
+ getDaysInMonth(date) {
2050
+ if (date.year < $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START || date.year > $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END) {
2051
+ return super.getDaysInMonth(date);
2052
+ }
2053
+
2054
+ return $ab59ff19176390aebd417f116829f2f$var$umalquraMonthLength(date.year, date.month);
2055
+ }
2056
+
2057
+ getDaysInYear(date) {
2058
+ if (date.year < $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_START || date.year > $ab59ff19176390aebd417f116829f2f$var$UMALQURA_YEAR_END) {
2059
+ return super.getDaysInYear(date);
2060
+ }
2061
+
2062
+ return $ab59ff19176390aebd417f116829f2f$var$umalquraYearLength(date.year);
2063
+ }
2064
+
2065
+ }
2066
+ const $e017065a6c5d591a525e617a0d3748f$var$HEBREW_EPOCH = 347997; // Hebrew date calculations are performed in terms of days, hours, and
2067
+ // "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.
2068
+
2069
+ const $e017065a6c5d591a525e617a0d3748f$var$HOUR_PARTS = 1080;
2070
+ const $e017065a6c5d591a525e617a0d3748f$var$DAY_PARTS = 24 * $e017065a6c5d591a525e617a0d3748f$var$HOUR_PARTS; // An approximate value for the length of a lunar month.
2071
+ // It is used to calculate the approximate year and month of a given
2072
+ // absolute date.
2073
+
2074
+ const $e017065a6c5d591a525e617a0d3748f$var$MONTH_DAYS = 29;
2075
+ const $e017065a6c5d591a525e617a0d3748f$var$MONTH_FRACT = 12 * $e017065a6c5d591a525e617a0d3748f$var$HOUR_PARTS + 793;
2076
+ const $e017065a6c5d591a525e617a0d3748f$var$MONTH_PARTS = $e017065a6c5d591a525e617a0d3748f$var$MONTH_DAYS * $e017065a6c5d591a525e617a0d3748f$var$DAY_PARTS + $e017065a6c5d591a525e617a0d3748f$var$MONTH_FRACT;
2077
+
2078
+ function $e017065a6c5d591a525e617a0d3748f$var$isLeapYear(year) {
2079
+ return $e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(year * 7 + 1, 19) < 7;
2080
+ } // Test for delay of start of new year and to avoid
2081
+ // Sunday, Wednesday, and Friday as start of the new year.
2082
+
2083
+
2084
+ function $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay1(year) {
2085
+ let months = Math.floor((235 * year - 234) / 19);
2086
+ let parts = 12084 + 13753 * months;
2087
+ let day = months * 29 + Math.floor(parts / 25920);
2088
+
2089
+ if ($e69ae7432d03ee6ff5aa642daa3d5d3$export$mod(3 * (day + 1), 7) < 3) {
2090
+ day += 1;
2091
+ }
2092
+
2093
+ return day;
2094
+ } // Check for delay in start of new year due to length of adjacent years
2095
+
2096
+
2097
+ function $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay2(year) {
2098
+ let last = $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay1(year - 1);
2099
+ let present = $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay1(year);
2100
+ let next = $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay1(year + 1);
2101
+
2102
+ if (next - present === 356) {
2103
+ return 2;
2104
+ }
2105
+
2106
+ if (present - last === 382) {
2107
+ return 1;
2108
+ }
2109
+
2110
+ return 0;
2111
+ }
2112
+
2113
+ function $e017065a6c5d591a525e617a0d3748f$var$startOfYear(year) {
2114
+ return $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay1(year) + $e017065a6c5d591a525e617a0d3748f$var$hebrewDelay2(year);
2115
+ }
2116
+
2117
+ function $e017065a6c5d591a525e617a0d3748f$var$getDaysInYear(year) {
2118
+ return $e017065a6c5d591a525e617a0d3748f$var$startOfYear(year + 1) - $e017065a6c5d591a525e617a0d3748f$var$startOfYear(year);
2119
+ }
2120
+
2121
+ function $e017065a6c5d591a525e617a0d3748f$var$getYearType(year) {
2122
+ let yearLength = $e017065a6c5d591a525e617a0d3748f$var$getDaysInYear(year);
2123
+
2124
+ if (yearLength > 380) {
2125
+ yearLength -= 30; // Subtract length of leap month.
2126
+ }
2127
+
2128
+ switch (yearLength) {
2129
+ case 353:
2130
+ return 0;
2131
+ // deficient
2132
+
2133
+ case 354:
2134
+ return 1;
2135
+ // normal
2136
+
2137
+ case 355:
2138
+ return 2;
2139
+ // complete
2140
+ }
2141
+ }
2142
+
2143
+ function $e017065a6c5d591a525e617a0d3748f$var$getDaysInMonth(year, month) {
2144
+ // Normalize month numbers from 1 - 13, even on non-leap years
2145
+ if (month >= 6 && !$e017065a6c5d591a525e617a0d3748f$var$isLeapYear(year)) {
2146
+ month++;
2147
+ } // First of all, dispose of fixed-length 29 day months
2148
+
2149
+
2150
+ if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {
2151
+ return 29;
2152
+ }
2153
+
2154
+ let yearType = $e017065a6c5d591a525e617a0d3748f$var$getYearType(year); // If it's Heshvan, days depend on length of year
2155
+
2156
+ if (month === 2) {
2157
+ return yearType === 2 ? 30 : 29;
2158
+ } // Similarly, Kislev varies with the length of year
2159
+
2160
+
2161
+ if (month === 3) {
2162
+ return yearType === 0 ? 29 : 30;
2163
+ } // Adar I only exists in leap years
2164
+
2165
+
2166
+ if (month === 6) {
2167
+ return $e017065a6c5d591a525e617a0d3748f$var$isLeapYear(year) ? 30 : 0;
2168
+ }
2169
+
2170
+ return 30;
2171
+ }
2172
+
2173
+ export class HebrewCalendar {
2174
+ constructor() {
2175
+ this.identifier = 'hebrew';
2176
+ }
2177
+
2178
+ fromJulianDay(jd) {
2179
+ let d = jd - $e017065a6c5d591a525e617a0d3748f$var$HEBREW_EPOCH;
2180
+ let m = d * $e017065a6c5d591a525e617a0d3748f$var$DAY_PARTS / $e017065a6c5d591a525e617a0d3748f$var$MONTH_PARTS; // Months (approx)
2181
+
2182
+ let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)
2183
+
2184
+ let ys = $e017065a6c5d591a525e617a0d3748f$var$startOfYear(year); // 1st day of year
2185
+
2186
+ let dayOfYear = Math.floor(d - ys); // Because of the postponement rules, it's possible to guess wrong. Fix it.
2187
+
2188
+ while (dayOfYear < 1) {
2189
+ year--;
2190
+ ys = $e017065a6c5d591a525e617a0d3748f$var$startOfYear(year);
2191
+ dayOfYear = Math.floor(d - ys);
2192
+ } // Now figure out which month we're in, and the date within that month
2193
+
2194
+
2195
+ let month = 1;
2196
+ let monthStart = 0;
2197
+
2198
+ while (monthStart < dayOfYear) {
2199
+ monthStart += $e017065a6c5d591a525e617a0d3748f$var$getDaysInMonth(year, month);
2200
+ month++;
2201
+ }
2202
+
2203
+ month--;
2204
+ monthStart -= $e017065a6c5d591a525e617a0d3748f$var$getDaysInMonth(year, month);
2205
+ let day = dayOfYear - monthStart;
2206
+ return new CalendarDate(this, year, month, day);
2207
+ }
2208
+
2209
+ toJulianDay(date) {
2210
+ let jd = $e017065a6c5d591a525e617a0d3748f$var$startOfYear(date.year);
2211
+
2212
+ for (let month = 1; month < date.month; month++) {
2213
+ jd += $e017065a6c5d591a525e617a0d3748f$var$getDaysInMonth(date.year, month);
2214
+ }
2215
+
2216
+ return jd + date.day + $e017065a6c5d591a525e617a0d3748f$var$HEBREW_EPOCH;
2217
+ }
2218
+
2219
+ getDaysInMonth(date) {
2220
+ return $e017065a6c5d591a525e617a0d3748f$var$getDaysInMonth(date.year, date.month);
2221
+ }
2222
+
2223
+ getMonthsInYear(date) {
2224
+ return $e017065a6c5d591a525e617a0d3748f$var$isLeapYear(date.year) ? 13 : 12;
2225
+ }
2226
+
2227
+ getDaysInYear(date) {
2228
+ return $e017065a6c5d591a525e617a0d3748f$var$getDaysInYear(date.year);
2229
+ }
2230
+
2231
+ getYearsInEra() {
2232
+ return 9999;
2233
+ }
2234
+
2235
+ getEras() {
2236
+ return ['AM'];
2237
+ }
2238
+
2239
+ balanceYearMonth(date, previousDate) {
2240
+ // Keep date in the same month when switching between leap years and non leap years
2241
+ if (previousDate.year !== date.year) {
2242
+ if ($e017065a6c5d591a525e617a0d3748f$var$isLeapYear(previousDate.year) && !$e017065a6c5d591a525e617a0d3748f$var$isLeapYear(date.year) && previousDate.month > 6) {
2243
+ date.month--;
2244
+ } else if (!$e017065a6c5d591a525e617a0d3748f$var$isLeapYear(previousDate.year) && $e017065a6c5d591a525e617a0d3748f$var$isLeapYear(date.year) && previousDate.month > 6) {
2245
+ date.month++;
2246
+ }
2247
+ }
2248
+ }
2249
+
2250
+ }
2251
+ const $c1dd3545d4e7040e53a01795c65c0c3$var$ETHIOPIC_EPOCH = 1723856;
2252
+ const $c1dd3545d4e7040e53a01795c65c0c3$var$COPTIC_EPOCH = 1824665; // The delta between Amete Alem 1 and Amete Mihret 1
2253
+ // AA 5501 = AM 1
2254
+
2255
+ const $c1dd3545d4e7040e53a01795c65c0c3$var$AMETE_MIHRET_DELTA = 5500;
2256
+
2257
+ function $c1dd3545d4e7040e53a01795c65c0c3$var$ceToJulianDay(epoch, year, month, day) {
2258
+ return epoch + 365 * year + Math.floor(year / 4) // extra day of leap year
2259
+ + 30 * (month - 1) // number of days from months (1 based)
2260
+ + day - 1 // number of days for present month (1 based)
2261
+ ;
2262
+ }
2263
+
2264
+ function $c1dd3545d4e7040e53a01795c65c0c3$var$julianDayToCE(calendar, epoch, jd) {
2265
+ let year = Math.floor(4 * (jd - epoch) / 1461);
2266
+ let month = 1 + Math.floor((jd - $c1dd3545d4e7040e53a01795c65c0c3$var$ceToJulianDay(epoch, year, 1, 1)) / 30);
2267
+ let day = jd + 1 - $c1dd3545d4e7040e53a01795c65c0c3$var$ceToJulianDay(epoch, year, month, 1);
2268
+ return new CalendarDate(calendar, year, month, day);
2269
+ }
2270
+
2271
+ function $c1dd3545d4e7040e53a01795c65c0c3$var$getLeapDay(year) {
2272
+ return Math.floor(year % 4 / 3);
2273
+ }
2274
+
2275
+ function $c1dd3545d4e7040e53a01795c65c0c3$var$getDaysInMonth(year, month) {
2276
+ // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and
2277
+ // an intercalary month at the end of the year of 5 or 6 days, depending whether
2278
+ // the year is a leap year or not. The Leap Year follows the same rules as the
2279
+ // Julian Calendar so that the extra month always has six days in the year before
2280
+ // a Julian Leap Year.
2281
+ if (month % 13 !== 0) {
2282
+ // not intercalary month
2283
+ return 30;
2284
+ } else {
2285
+ // intercalary month 5 days + possible leap day
2286
+ return $c1dd3545d4e7040e53a01795c65c0c3$var$getLeapDay(year) + 5;
2287
+ }
2288
+ }
2289
+
2290
+ export class EthiopicCalendar {
2291
+ constructor() {
2292
+ this.identifier = 'ethiopic';
2293
+ }
2294
+
2295
+ fromJulianDay(jd) {
2296
+ let date = $c1dd3545d4e7040e53a01795c65c0c3$var$julianDayToCE(this, $c1dd3545d4e7040e53a01795c65c0c3$var$ETHIOPIC_EPOCH, jd);
2297
+
2298
+ if (date.year > 0) {
2299
+ date.era = 'AM';
2300
+ } else {
2301
+ date.era = 'AA';
2302
+ date.year += $c1dd3545d4e7040e53a01795c65c0c3$var$AMETE_MIHRET_DELTA;
2303
+ }
2304
+
2305
+ return date;
2306
+ }
2307
+
2308
+ toJulianDay(date) {
2309
+ let year = date.year;
2310
+
2311
+ if (date.era === 'AA') {
2312
+ year -= $c1dd3545d4e7040e53a01795c65c0c3$var$AMETE_MIHRET_DELTA;
2313
+ }
2314
+
2315
+ return $c1dd3545d4e7040e53a01795c65c0c3$var$ceToJulianDay($c1dd3545d4e7040e53a01795c65c0c3$var$ETHIOPIC_EPOCH, year, date.month, date.day);
2316
+ }
2317
+
2318
+ getDaysInMonth(date) {
2319
+ let year = date.year;
2320
+
2321
+ if (date.era === 'AA') {
2322
+ year -= $c1dd3545d4e7040e53a01795c65c0c3$var$AMETE_MIHRET_DELTA;
2323
+ }
2324
+
2325
+ return $c1dd3545d4e7040e53a01795c65c0c3$var$getDaysInMonth(year, date.month);
2326
+ }
2327
+
2328
+ getMonthsInYear() {
2329
+ return 13;
2330
+ }
2331
+
2332
+ getDaysInYear(date) {
2333
+ return 365 + $c1dd3545d4e7040e53a01795c65c0c3$var$getLeapDay(date.year);
2334
+ }
2335
+
2336
+ getYearsInEra() {
2337
+ return 9999;
2338
+ }
2339
+
2340
+ getEras() {
2341
+ return ['AA', 'AM'];
2342
+ }
2343
+
2344
+ }
2345
+ export class EthiopicAmeteAlemCalendar extends EthiopicCalendar {
2346
+ constructor() {
2347
+ super(...arguments);
2348
+ this.identifier = 'ethioaa';
2349
+ }
2350
+
2351
+ // also known as 'ethiopic-amete-alem' in ICU
2352
+ fromJulianDay(jd) {
2353
+ let date = $c1dd3545d4e7040e53a01795c65c0c3$var$julianDayToCE(this, $c1dd3545d4e7040e53a01795c65c0c3$var$ETHIOPIC_EPOCH, jd);
2354
+ date.era = 'AA';
2355
+ date.year += $c1dd3545d4e7040e53a01795c65c0c3$var$AMETE_MIHRET_DELTA;
2356
+ return date;
2357
+ }
2358
+
2359
+ getEras() {
2360
+ return ['AA'];
2361
+ }
2362
+
2363
+ }
2364
+ export class CopticCalendar extends EthiopicCalendar {
2365
+ constructor() {
2366
+ super(...arguments);
2367
+ this.identifier = 'coptic';
2368
+ }
2369
+
2370
+ fromJulianDay(jd) {
2371
+ let date = $c1dd3545d4e7040e53a01795c65c0c3$var$julianDayToCE(this, $c1dd3545d4e7040e53a01795c65c0c3$var$COPTIC_EPOCH, jd);
2372
+
2373
+ if (date.year <= 0) {
2374
+ date.era = 'BCE';
2375
+ date.year = 1 - date.year;
2376
+ } else {
2377
+ date.era = 'CE';
2378
+ }
2379
+
2380
+ return date;
2381
+ }
2382
+
2383
+ toJulianDay(date) {
2384
+ let year = date.year;
2385
+
2386
+ if (date.era === 'BCE') {
2387
+ year = 1 - year;
2388
+ }
2389
+
2390
+ return $c1dd3545d4e7040e53a01795c65c0c3$var$ceToJulianDay($c1dd3545d4e7040e53a01795c65c0c3$var$COPTIC_EPOCH, year, date.month, date.day);
2391
+ }
2392
+
2393
+ getDaysInMonth(date) {
2394
+ let year = date.year;
2395
+
2396
+ if (date.era === 'BCE') {
2397
+ year = 1 - year;
2398
+ }
2399
+
2400
+ return $c1dd3545d4e7040e53a01795c65c0c3$var$getDaysInMonth(year, date.month);
2401
+ }
2402
+
2403
+ getYearsToAdd(date, years) {
2404
+ return date.era === 'BCE' ? -years : years;
2405
+ }
2406
+
2407
+ getEras() {
2408
+ return ['BCE', 'CE'];
2409
+ }
2410
+
2411
+ }
2412
+ export function createCalendar(name) {
2413
+ switch (name) {
2414
+ case 'buddhist':
2415
+ return new BuddhistCalendar();
2416
+
2417
+ case 'ethiopic':
2418
+ return new EthiopicCalendar();
2419
+
2420
+ case 'ethioaa':
2421
+ return new EthiopicAmeteAlemCalendar();
2422
+
2423
+ case 'coptic':
2424
+ return new CopticCalendar();
2425
+
2426
+ case 'hebrew':
2427
+ return new HebrewCalendar();
2428
+
2429
+ case 'indian':
2430
+ return new IndianCalendar();
2431
+
2432
+ case 'islamic-civil':
2433
+ return new IslamicCivilCalendar();
2434
+
2435
+ case 'islamic-tbla':
2436
+ return new IslamicTabularCalendar();
2437
+
2438
+ case 'islamic-umalqura':
2439
+ return new IslamicUmalquraCalendar();
2440
+
2441
+ case 'japanese':
2442
+ return new JapaneseCalendar();
2443
+
2444
+ case 'persian':
2445
+ return new PersianCalendar();
2446
+
2447
+ case 'roc':
2448
+ return new TaiwanCalendar();
2449
+
2450
+ case 'gregory':
2451
+ default:
2452
+ return new GregorianCalendar();
2453
+ }
2454
+ }
2455
+ let $b2616a3826de9be957a1356a9a0$var$formatterCache = new Map();
2456
+ export class DateFormatter {
2457
+ constructor(locale, options) {
2458
+ if (options === void 0) {
2459
+ options = {};
2460
+ }
2461
+
2462
+ this.formatter = void 0;
2463
+ this.options = void 0;
2464
+ this.resolvedHourCycle = void 0;
2465
+ this.formatter = $b2616a3826de9be957a1356a9a0$var$getCachedDateFormatter(locale, options);
2466
+ this.options = options;
2467
+ }
2468
+
2469
+ format(value) {
2470
+ return this.formatter.format(value);
2471
+ }
2472
+
2473
+ formatToParts(value) {
2474
+ return this.formatter.formatToParts(value);
2475
+ }
2476
+
2477
+ formatRange(start, end) {
2478
+ // @ts-ignore
2479
+ if (typeof this.formatter.formatRange === 'function') {
2480
+ // @ts-ignore
2481
+ return this.formatter.formatRange(start, end);
2482
+ }
2483
+
2484
+ if (end < start) {
2485
+ throw new RangeError('End date must be >= start date');
2486
+ } // Very basic fallback for old browsers.
2487
+
2488
+
2489
+ return this.formatter.format(start) + " \u2013 " + this.formatter.format(end);
2490
+ }
2491
+
2492
+ formatRangeToParts(start, end) {
2493
+ // @ts-ignore
2494
+ if (typeof this.formatter.formatRangeToParts === 'function') {
2495
+ // @ts-ignore
2496
+ return this.formatter.formatRangeToParts(start, end);
2497
+ }
2498
+
2499
+ if (end < start) {
2500
+ throw new RangeError('End date must be >= start date');
2501
+ }
2502
+
2503
+ let startParts = this.formatter.formatToParts(start);
2504
+ let endParts = this.formatter.formatToParts(end);
2505
+ return [...startParts.map(p => _babelRuntimeHelpersEsmExtends({}, p, {
2506
+ source: 'startRange'
2507
+ })), {
2508
+ type: 'literal',
2509
+ value: ' – ',
2510
+ source: 'shared'
2511
+ }, ...endParts.map(p => _babelRuntimeHelpersEsmExtends({}, p, {
2512
+ source: 'endRange'
2513
+ }))];
2514
+ }
2515
+
2516
+ resolvedOptions() {
2517
+ let resolvedOptions = this.formatter.resolvedOptions();
2518
+
2519
+ if ($b2616a3826de9be957a1356a9a0$var$hasBuggyResolvedHourCycle()) {
2520
+ if (!this.resolvedHourCycle) {
2521
+ this.resolvedHourCycle = $b2616a3826de9be957a1356a9a0$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
2522
+ }
2523
+
2524
+ resolvedOptions.hourCycle = this.resolvedHourCycle;
2525
+ resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';
2526
+ }
2527
+
2528
+ return resolvedOptions;
2529
+ }
2530
+
2531
+ } // There are multiple bugs involving the hour12 and hourCycle options in various browser engines.
2532
+ // - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)
2533
+ // rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)
2534
+ // rather than h12 (12:00 - 11:59).
2535
+ // - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal
2536
+ // in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]
2537
+ // [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791
2538
+ // [2] https://github.com/tc39/ecma402/issues/402
2539
+ // [3] https://bugs.webkit.org/show_bug.cgi?id=229313
2540
+ // https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802
2541
+
2542
+ const $b2616a3826de9be957a1356a9a0$var$hour12Preferences = {
2543
+ true: {
2544
+ // Only Japanese uses the h11 style for 12 hour time. All others use h12.
2545
+ ja: 'h11'
2546
+ },
2547
+ false: {// All locales use h23 for 24 hour time. None use h24.
2548
+ }
2549
+ };
2550
+
2551
+ function $b2616a3826de9be957a1356a9a0$var$getCachedDateFormatter(locale, options) {
2552
+ if (options === void 0) {
2553
+ options = {};
2554
+ }
2555
+
2556
+ // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
2557
+ // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
2558
+ if (typeof options.hour12 === 'boolean' && $b2616a3826de9be957a1356a9a0$var$hasBuggyHour12Behavior()) {
2559
+ options = _babelRuntimeHelpersEsmExtends({}, options);
2560
+ let pref = $b2616a3826de9be957a1356a9a0$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]];
2561
+ let defaultHourCycle = options.hour12 ? 'h12' : 'h23';
2562
+ options.hourCycle = pref != null ? pref : defaultHourCycle;
2563
+ delete options.hour12;
2564
+ }
2565
+
2566
+ let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');
2567
+
2568
+ if ($b2616a3826de9be957a1356a9a0$var$formatterCache.has(cacheKey)) {
2569
+ return $b2616a3826de9be957a1356a9a0$var$formatterCache.get(cacheKey);
2570
+ }
2571
+
2572
+ let numberFormatter = new Intl.DateTimeFormat(locale, options);
2573
+ $b2616a3826de9be957a1356a9a0$var$formatterCache.set(cacheKey, numberFormatter);
2574
+ return numberFormatter;
2575
+ }
2576
+
2577
+ let $b2616a3826de9be957a1356a9a0$var$_hasBuggyHour12Behavior = null;
2578
+
2579
+ function $b2616a3826de9be957a1356a9a0$var$hasBuggyHour12Behavior() {
2580
+ if ($b2616a3826de9be957a1356a9a0$var$_hasBuggyHour12Behavior == null) {
2581
+ $b2616a3826de9be957a1356a9a0$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {
2582
+ hour: 'numeric',
2583
+ hour12: false
2584
+ }).format(new Date(2020, 2, 3, 0)) === '24';
2585
+ }
2586
+
2587
+ return $b2616a3826de9be957a1356a9a0$var$_hasBuggyHour12Behavior;
2588
+ }
2589
+
2590
+ let $b2616a3826de9be957a1356a9a0$var$_hasBuggyResolvedHourCycle = null;
2591
+
2592
+ function $b2616a3826de9be957a1356a9a0$var$hasBuggyResolvedHourCycle() {
2593
+ if ($b2616a3826de9be957a1356a9a0$var$_hasBuggyResolvedHourCycle == null) {
2594
+ $b2616a3826de9be957a1356a9a0$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {
2595
+ hour: 'numeric',
2596
+ hour12: false
2597
+ }).resolvedOptions().hourCycle === 'h12';
2598
+ }
2599
+
2600
+ return $b2616a3826de9be957a1356a9a0$var$_hasBuggyResolvedHourCycle;
2601
+ }
2602
+
2603
+ function $b2616a3826de9be957a1356a9a0$var$getResolvedHourCycle(locale, options) {
2604
+ if (!options.timeStyle && !options.hour) {
2605
+ return undefined;
2606
+ } // Work around buggy results in resolved hourCycle and hour12 options in WebKit.
2607
+ // Format the minimum possible hour and maximum possible hour in a day and parse the results.
2608
+
2609
+
2610
+ locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');
2611
+ locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';
2612
+ let formatter = $b2616a3826de9be957a1356a9a0$var$getCachedDateFormatter(locale, _babelRuntimeHelpersEsmExtends({}, options, {
2613
+ timeZone: undefined // use local timezone
2614
+
2615
+ }));
2616
+ let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour').value, 10);
2617
+ let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour').value, 10);
2618
+
2619
+ if (min === 0 && max === 23) {
2620
+ return 'h23';
2621
+ }
2622
+
2623
+ if (min === 24 && max === 23) {
2624
+ return 'h24';
2625
+ }
2626
+
2627
+ if (min === 0 && max === 11) {
2628
+ return 'h11';
2629
+ }
2630
+
2631
+ if (min === 12 && max === 11) {
2632
+ return 'h12';
2633
+ }
2634
+
2635
+ throw new Error('Unexpected hour cycle result');
2636
+ }
2637
+ //# sourceMappingURL=module.js.map