@bereasoftware/time-guard 2.7.2 → 2.9.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.
Files changed (52) hide show
  1. package/README.en.md +5 -1
  2. package/README.md +5 -1
  3. package/dist/adapters/temporal.adapter.d.ts +6 -2
  4. package/dist/angular/index.cjs +1 -148
  5. package/dist/angular/index.es.js +63 -112
  6. package/dist/calendars/index.cjs +1 -357
  7. package/dist/calendars/index.es.js +66 -99
  8. package/dist/chunk-C6qsp3rV.cjs +1 -0
  9. package/dist/core-BDQnStek.cjs +1 -0
  10. package/dist/core-GHK7isoa.js +1200 -0
  11. package/dist/core.d.ts +27 -1
  12. package/dist/index.d.ts +4 -2
  13. package/dist/locales/index.cjs +1 -7
  14. package/dist/locales/index.d.ts +11 -0
  15. package/dist/locales/index.es.js +3 -3
  16. package/dist/{locales-CGdn0DJN.cjs → locales-Dwe5oGoy.js} +201 -82
  17. package/dist/locales-bc-5kDuZ.cjs +1 -0
  18. package/dist/native/index.cjs +1 -48
  19. package/dist/native/index.es.js +8 -18
  20. package/dist/plugins/advanced-format/index.d.ts +8 -0
  21. package/dist/plugins/advanced-format.cjs +1 -105
  22. package/dist/plugins/advanced-format.es.js +48 -63
  23. package/dist/plugins/duration/index.d.ts +6 -0
  24. package/dist/plugins/duration.cjs +1 -258
  25. package/dist/plugins/duration.es.js +63 -165
  26. package/dist/plugins/manager.d.ts +6 -2
  27. package/dist/plugins/relative-time/index.d.ts +6 -0
  28. package/dist/plugins/relative-time.cjs +1 -166
  29. package/dist/plugins/relative-time.es.js +39 -74
  30. package/dist/qwik/index.cjs +1 -104
  31. package/dist/qwik/index.es.js +36 -94
  32. package/dist/qwik.d.ts +5 -1
  33. package/dist/react/index.cjs +1 -112
  34. package/dist/react/index.es.js +57 -91
  35. package/dist/solid/index.cjs +1 -127
  36. package/dist/solid/index.es.js +36 -116
  37. package/dist/solid.d.ts +5 -2
  38. package/dist/svelte/index.cjs +1 -398
  39. package/dist/svelte/index.es.js +85 -344
  40. package/dist/time-guard.cjs +3 -7359
  41. package/dist/time-guard.es.js +3412 -3625
  42. package/dist/time-guard.iife.js +3 -13549
  43. package/dist/time-guard.umd.js +3 -13550
  44. package/dist/types/index.d.ts +10 -0
  45. package/dist/vue/index.cjs +1 -143
  46. package/dist/vue/index.es.js +62 -116
  47. package/dist/vue.d.ts +5 -3
  48. package/package.json +3 -4
  49. package/dist/chunk-S8Y6Ng9i.cjs +0 -36
  50. package/dist/core-BIDjudpO.cjs +0 -1892
  51. package/dist/core-DWPXk3rz.js +0 -1809
  52. package/dist/locales-BUE_aq8K.js +0 -3514
@@ -0,0 +1,1200 @@
1
+ /*! time-guard v2.9.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ import { c as e } from "./locales-Dwe5oGoy.js";
3
+ //#region src/adapters/temporal.adapter.ts
4
+ var t = null;
5
+ function n() {
6
+ if (t) return t;
7
+ let e = globalThis.Temporal;
8
+ if (!e) throw Error("Temporal API not loaded. Make sure @js-temporal/polyfill is imported in your app.");
9
+ return t = e, e;
10
+ }
11
+ var r = class {
12
+ static parseToPlainDateTime(e) {
13
+ let t = n();
14
+ return this.isPlainDateTime(e) ? e : this.isZonedDateTime(e) ? e.toPlainDateTime() : this.isPlainDate(e) ? e.toPlainDateTime({
15
+ hour: 0,
16
+ minute: 0,
17
+ second: 0,
18
+ millisecond: 0
19
+ }) : this.isPlainTime(e) ? t.Now.plainDateTimeISO().withPlainTime(e) : typeof e == "object" && e && "getTime" in e && typeof e.getTime == "function" ? this.fromDate(e) : typeof e == "number" ? this.fromUnix(e) : typeof e == "string" ? this.parseISOString(e) : typeof e == "object" && e ? this.fromObject(e) : t.Now.plainDateTimeISO();
20
+ }
21
+ static fromDate(e) {
22
+ let t = n(), [r, i] = e.toISOString().split("T");
23
+ return t.PlainDateTime.from(r + "T" + i.slice(0, -1));
24
+ }
25
+ static fromUnix(e) {
26
+ return this.fromDate(new Date(e));
27
+ }
28
+ static parseISOString(e) {
29
+ let t = n();
30
+ try {
31
+ if (e.includes("T") || / \d{2}:\d{2}/.test(e)) {
32
+ let n = e.replace(" ", "T").replace(/(?:Z|[+-]\d{2}:\d{2})$/i, "");
33
+ return t.PlainDateTime.from(n);
34
+ }
35
+ return t.PlainDate.from(e).toPlainDateTime({ hour: 0 });
36
+ } catch {
37
+ return t.Now.plainDateTimeISO();
38
+ }
39
+ }
40
+ static fromObject(e) {
41
+ let t = n(), r = e.year || t.Now.plainDateISO().year, i = e.month || 1, a = e.day || 1, o = e.hour || 0, s = e.minute || 0, c = e.second || 0, l = e.millisecond || 0;
42
+ return t.PlainDateTime.from({
43
+ year: this.toFiniteInteger(r),
44
+ month: this.toFiniteInteger(i),
45
+ day: this.toFiniteInteger(a),
46
+ hour: this.toFiniteInteger(o),
47
+ minute: this.toFiniteInteger(s),
48
+ second: this.toFiniteInteger(c),
49
+ millisecond: this.toFiniteInteger(l)
50
+ });
51
+ }
52
+ static toDate(e) {
53
+ let t = this.toPlainDateTime(e);
54
+ return new Date(t.toString());
55
+ }
56
+ static toUnix(e) {
57
+ let t = this.toPlainDateTime(e);
58
+ return Date.UTC(t.year, t.month - 1, t.day, t.hour, t.minute, t.second, t.millisecond);
59
+ }
60
+ static toISOString(e) {
61
+ return this.isZonedDateTime(e) ? e.toInstant().toString({ smallestUnit: "millisecond" }) : this.toPlainDateTime(e).toString({ smallestUnit: "millisecond" }) + "Z";
62
+ }
63
+ static toPlainDateTime(e) {
64
+ return this.isPlainDateTime(e) ? e : e.toPlainDateTime();
65
+ }
66
+ static isPlainDateTime(e) {
67
+ return typeof e == "object" && !!e && "year" in e && "month" in e && "day" in e && "hour" in e && !("timeZoneId" in e);
68
+ }
69
+ static isZonedDateTime(e) {
70
+ return typeof e == "object" && !!e && "timeZoneId" in e;
71
+ }
72
+ static isPlainDate(e) {
73
+ return typeof e == "object" && !!e && "year" in e && "month" in e && "day" in e && !("hour" in e) && "toPlainDateTime" in e;
74
+ }
75
+ static isPlainTime(e) {
76
+ return typeof e == "object" && !!e && "hour" in e && !("year" in e);
77
+ }
78
+ static toFiniteInteger(e) {
79
+ let t = Number(e);
80
+ if (!Number.isFinite(t)) throw Error(`Temporal error: Expected finite integer, got ${e}`);
81
+ return Math.trunc(t);
82
+ }
83
+ static validatePlainDateTime(e) {
84
+ for (let t of [
85
+ "year",
86
+ "month",
87
+ "day",
88
+ "hour",
89
+ "minute",
90
+ "second",
91
+ "millisecond"
92
+ ]) {
93
+ let n = e[t];
94
+ if (typeof n != "number" || !Number.isFinite(n) || !Number.isInteger(n)) throw typeof console < "u" && typeof console.error == "function" && console.error("TemporalAdapter.validatePlainDateTime: campo inválido", t, n, e), Error(`Temporal error: Expected finite integer for ${t}, got ${n}`);
95
+ }
96
+ }
97
+ static now() {
98
+ return n().Now.plainDateTimeISO();
99
+ }
100
+ static nowInTimezone(e) {
101
+ return n().Now.zonedDateTimeISO(e);
102
+ }
103
+ static compare(e, t) {
104
+ let r = n();
105
+ if (this.validatePlainDateTime(e), this.validatePlainDateTime(t), r.PlainDateTime && typeof r.PlainDateTime.compare == "function") return r.PlainDateTime.compare(e, t);
106
+ let i = e.toString(), a = t.toString();
107
+ return i < a ? -1 : +(i > a);
108
+ }
109
+ }, i = class {
110
+ localeManager;
111
+ constructor() {
112
+ this.localeManager = e.getInstance();
113
+ }
114
+ format(e, t, n) {
115
+ let r = this.localeManager.getLocale(n), i = [], a = t.replace(/\[([^\]]+)\]/g, (e, t) => (i.push(t), `~${i.length - 1}~`));
116
+ a = a.replace(/"([^"]*)"/g, (e, t) => (i.push(t), `~${i.length - 1}~`));
117
+ let o = a.replace(/Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|SSS/g, (t) => {
118
+ switch (t) {
119
+ case "YYYY": return String(e.year).padStart(4, "0");
120
+ case "YY": return String(e.year).slice(-2);
121
+ case "Y": return String(e.year);
122
+ case "MMMM": return r.months[e.month - 1];
123
+ case "MMM": return r.monthsShort[e.month - 1];
124
+ case "MM": return String(e.month).padStart(2, "0");
125
+ case "M": return String(e.month);
126
+ case "DD": return String(e.day).padStart(2, "0");
127
+ case "D": return String(e.day);
128
+ case "dddd": return r.weekdays[e.dayOfWeek % 7];
129
+ case "ddd": return r.weekdaysShort[e.dayOfWeek % 7];
130
+ case "dd": return r.weekdaysMin[e.dayOfWeek % 7];
131
+ case "d": return String(e.dayOfWeek);
132
+ case "HH": return String(e.hour).padStart(2, "0");
133
+ case "H": return String(e.hour);
134
+ case "hh": return String(e.hour % 12 || 12).padStart(2, "0");
135
+ case "h": return String(e.hour % 12 || 12);
136
+ case "mm": return String(e.minute).padStart(2, "0");
137
+ case "m": return String(e.minute);
138
+ case "ss": return String(e.second).padStart(2, "0");
139
+ case "s": return String(e.second);
140
+ case "SSS": return String(e.millisecond).padStart(3, "0");
141
+ case "a":
142
+ case "A":
143
+ let n = r.meridiem || {
144
+ am: "am",
145
+ pm: "pm"
146
+ }, i = e.hour >= 12 ? n.pm : n.am;
147
+ return t === "a" ? i.toLowerCase() : i.toUpperCase();
148
+ default: return t;
149
+ }
150
+ });
151
+ return i.forEach((e, t) => {
152
+ o = o.replace(`~${t}~`, e);
153
+ }), o;
154
+ }
155
+ getPreset(e) {
156
+ let t = {
157
+ iso: "YYYY-MM-DDTHH:mm:ss.SSSZ",
158
+ date: "YYYY-MM-DD",
159
+ time: "HH:mm:ss",
160
+ datetime: "YYYY-MM-DD HH:mm:ss",
161
+ rfc2822: "ddd, DD MMM YYYY HH:mm:ss Z",
162
+ rfc3339: "YYYY-MM-DDTHH:mm:ssZ",
163
+ utc: "YYYY-MM-DDTHH:mm:ss[Z]"
164
+ };
165
+ return t[e] || t.iso;
166
+ }
167
+ formatPreset(e, t, n) {
168
+ let r = this.getPreset(t);
169
+ return this.format(e, r, n);
170
+ }
171
+ }, a = {
172
+ en: {
173
+ year: ["year", "years"],
174
+ month: ["month", "months"],
175
+ week: ["week", "weeks"],
176
+ day: ["day", "days"],
177
+ hour: ["hour", "hours"],
178
+ minute: ["minute", "minutes"],
179
+ second: ["second", "seconds"],
180
+ millisecond: ["millisecond", "milliseconds"]
181
+ },
182
+ es: {
183
+ year: ["año", "años"],
184
+ month: ["mes", "meses"],
185
+ week: ["semana", "semanas"],
186
+ day: ["día", "días"],
187
+ hour: ["hora", "horas"],
188
+ minute: ["minuto", "minutos"],
189
+ second: ["segundo", "segundos"],
190
+ millisecond: ["milisegundo", "milisegundos"]
191
+ },
192
+ fr: {
193
+ year: ["année", "années"],
194
+ month: ["mois", "mois"],
195
+ week: ["semaine", "semaines"],
196
+ day: ["jour", "jours"],
197
+ hour: ["heure", "heures"],
198
+ minute: ["minute", "minutes"],
199
+ second: ["seconde", "secondes"],
200
+ millisecond: ["milliseconde", "millisecondes"]
201
+ }
202
+ }, o = {
203
+ en: "and",
204
+ es: "y",
205
+ fr: "et",
206
+ de: "und",
207
+ it: "e",
208
+ pt: "e"
209
+ };
210
+ function s(e, t, n) {
211
+ return ((a[t] || a.en)[e] || [e, e + "s"])[n === 1 ? 0 : 1];
212
+ }
213
+ function c(e) {
214
+ return o[e] || "and";
215
+ }
216
+ function l(e, t) {
217
+ if (e.length === 0) return "";
218
+ if (e.length === 1) return e[0];
219
+ let n = c(t);
220
+ return e.length === 2 ? `${e[0]} ${n} ${e[1]}` : e.slice(0, -1).join(", ") + ` ${n} ${e[e.length - 1]}`;
221
+ }
222
+ function u(e) {
223
+ return {
224
+ en: "0 seconds",
225
+ es: "0 segundos",
226
+ fr: "0 secondes"
227
+ }[e] || "0 seconds";
228
+ }
229
+ //#endregion
230
+ //#region src/calendars/calendar.manager.ts
231
+ var d = class {
232
+ id = "gregory";
233
+ name = "Gregorian Calendar";
234
+ locale = "en";
235
+ monthNames = [
236
+ "January",
237
+ "February",
238
+ "March",
239
+ "April",
240
+ "May",
241
+ "June",
242
+ "July",
243
+ "August",
244
+ "September",
245
+ "October",
246
+ "November",
247
+ "December"
248
+ ];
249
+ monthNamesShort = [
250
+ "Jan",
251
+ "Feb",
252
+ "Mar",
253
+ "Apr",
254
+ "May",
255
+ "Jun",
256
+ "Jul",
257
+ "Aug",
258
+ "Sep",
259
+ "Oct",
260
+ "Nov",
261
+ "Dec"
262
+ ];
263
+ weekdayNames = [
264
+ "Sunday",
265
+ "Monday",
266
+ "Tuesday",
267
+ "Wednesday",
268
+ "Thursday",
269
+ "Friday",
270
+ "Saturday"
271
+ ];
272
+ weekdayNamesShort = [
273
+ "Sun",
274
+ "Mon",
275
+ "Tue",
276
+ "Wed",
277
+ "Thu",
278
+ "Fri",
279
+ "Sat"
280
+ ];
281
+ getMonthName(e, t = !1) {
282
+ return (t ? this.monthNamesShort : this.monthNames)[Math.max(0, Math.min(11, e - 1))];
283
+ }
284
+ getWeekdayName(e, t = !1) {
285
+ return (t ? this.weekdayNamesShort : this.weekdayNames)[Math.max(0, Math.min(6, e - 1))];
286
+ }
287
+ isLeapYear(e) {
288
+ return e % 4 == 0 && e % 100 != 0 || e % 400 == 0;
289
+ }
290
+ daysInMonth(e, t) {
291
+ return t === 2 && this.isLeapYear(e) ? 29 : [
292
+ 31,
293
+ 28,
294
+ 31,
295
+ 30,
296
+ 31,
297
+ 30,
298
+ 31,
299
+ 31,
300
+ 30,
301
+ 31,
302
+ 30,
303
+ 31
304
+ ][Math.max(0, Math.min(11, t - 1))];
305
+ }
306
+ daysInYear(e) {
307
+ return this.isLeapYear(e) ? 366 : 365;
308
+ }
309
+ }, f = class e {
310
+ static instance;
311
+ calendars = /* @__PURE__ */ new Map();
312
+ defaultCalendar = "gregory";
313
+ constructor() {
314
+ this.register(new d());
315
+ }
316
+ static getInstance() {
317
+ return e.instance ||= new e(), e.instance;
318
+ }
319
+ register(e) {
320
+ this.calendars.has(e.id) && console.warn(`Calendar "${e.id}" is already registered. Overwriting...`), this.calendars.set(e.id, e);
321
+ }
322
+ get(e) {
323
+ return this.calendars.get(e);
324
+ }
325
+ list() {
326
+ return Array.from(this.calendars.keys());
327
+ }
328
+ setDefault(e) {
329
+ if (!this.calendars.has(e)) {
330
+ console.warn(`Calendar "${e}" is not registered. Keeping "${this.defaultCalendar}" as default.`);
331
+ return;
332
+ }
333
+ this.defaultCalendar = e;
334
+ }
335
+ getDefault() {
336
+ let e = this.calendars.get(this.defaultCalendar);
337
+ if (!e) throw Error(`Default calendar '${this.defaultCalendar}' not found`);
338
+ return e;
339
+ }
340
+ }, p = f.getInstance(), m = class e {
341
+ static instance;
342
+ plugins = /* @__PURE__ */ new Map();
343
+ static getInstance() {
344
+ return e.instance ||= new e(), e.instance;
345
+ }
346
+ static use(t, n, r) {
347
+ e.getInstance().register(t, n, r);
348
+ }
349
+ static useMultiple(t, n, r) {
350
+ let i = e.getInstance();
351
+ t.forEach((e) => i.register(e, n, r));
352
+ }
353
+ static getPlugin(t) {
354
+ return e.getInstance().plugins.get(t)?.plugin;
355
+ }
356
+ static hasPlugin(t) {
357
+ return e.getInstance().plugins.has(t);
358
+ }
359
+ static listPlugins() {
360
+ let t = e.getInstance();
361
+ return Array.from(t.plugins.keys());
362
+ }
363
+ static unuse(t) {
364
+ let n = e.getInstance(), r = n.plugins.get(t);
365
+ return r ? (r.plugin.uninstall?.(r.timeGuardClass), n.plugins.delete(t)) : !1;
366
+ }
367
+ static clear() {
368
+ let t = e.getInstance();
369
+ for (let e of t.plugins.values()) e.plugin.uninstall?.(e.timeGuardClass);
370
+ t.plugins.clear();
371
+ }
372
+ register(e, t, n) {
373
+ if (this.plugins.has(e.name)) {
374
+ console.warn(`Plugin "${e.name}" is already registered. Skipping...`);
375
+ return;
376
+ }
377
+ try {
378
+ e.install(t, n), this.plugins.set(e.name, {
379
+ plugin: e,
380
+ timeGuardClass: t
381
+ }), process.env.NODE_ENV !== "production" && console.warn(`Plugin "${e.name}" v${e.version} registered successfully`);
382
+ } catch (t) {
383
+ throw console.error(`Failed to register plugin "${e.name}":`, t), Error(`Failed to register plugin "${e.name}": ${t instanceof Error ? t.message : String(t)}`);
384
+ }
385
+ }
386
+ }, h = 1e3, g = h * 60, _ = g * 60, v = _ * 24, y = v * 7, b = 365.25, x = b / 12 * v, S = b * v, C = " days";
387
+ function w(e) {
388
+ return (e.years || 0) * S + (e.months || 0) * x + (e.weeks || 0) * y + (e.days || 0) * v + (e.hours || 0) * _ + (e.minutes || 0) * g + (e.seconds || 0) * h + (e.milliseconds || 0);
389
+ }
390
+ var T = class {
391
+ _value;
392
+ _tg1;
393
+ _tg2;
394
+ _mode;
395
+ _breakdownData;
396
+ _locale;
397
+ constructor(e, t, n, r = "exact", i, a) {
398
+ this._value = e, this._tg1 = t, this._tg2 = n, this._mode = r, this._breakdownData = i || null, this._locale = a || "en";
399
+ }
400
+ as(e) {
401
+ return this._tg1.diff(this._tg2, e);
402
+ }
403
+ breakdown() {
404
+ return this._breakdownData;
405
+ }
406
+ format(e) {
407
+ let t = e || this._locale;
408
+ if (!this._breakdownData) return `${Math.abs(this._tg1.diff(this._tg2, "day"))}${C}`;
409
+ let n = [], r = this._breakdownData;
410
+ return r.years !== 0 && n.push(`${r.years} ${s("year", t, r.years)}`), r.months !== 0 && n.push(`${r.months} ${s("month", t, r.months)}`), r.weeks !== 0 && n.push(`${r.weeks} ${s("week", t, r.weeks)}`), r.days !== 0 && n.push(`${r.days} ${s("day", t, r.days)}`), r.hours !== 0 && n.push(`${r.hours} ${s("hour", t, r.hours)}`), r.minutes !== 0 && n.push(`${r.minutes} ${s("minute", t, r.minutes)}`), r.seconds !== 0 && n.push(`${r.seconds} ${s("second", t, r.seconds)}`), n.length === 0 ? u(t) : l(n, t);
411
+ }
412
+ getMode() {
413
+ return this._mode;
414
+ }
415
+ valueOf() {
416
+ return this._value;
417
+ }
418
+ toString() {
419
+ return this._mode === "calendar" && this._breakdownData ? this.format() : this._value.toString();
420
+ }
421
+ toJSON() {
422
+ return this._value;
423
+ }
424
+ }, E = class {
425
+ years;
426
+ months;
427
+ weeks;
428
+ days;
429
+ hours;
430
+ minutes;
431
+ seconds;
432
+ milliseconds;
433
+ _locale;
434
+ _startDate;
435
+ _endDate;
436
+ _steps = [];
437
+ _mode = "exact";
438
+ _leapYearFlags = [];
439
+ _calculationTimeMs = 0;
440
+ constructor(e, t = "en", n) {
441
+ this.years = e.years, this.months = e.months, this.weeks = e.weeks, this.days = e.days, this.hours = e.hours, this.minutes = e.minutes, this.seconds = e.seconds, this.milliseconds = e.milliseconds, this._locale = t, n && (this._startDate = n.startDate, this._endDate = n.endDate, this._steps = n.steps || [], this._mode = n.mode || "exact", this._leapYearFlags = n.leapYearFlags || [], this._calculationTimeMs = n.calculationTimeMs || 0);
442
+ }
443
+ humanize(e) {
444
+ let t = e?.locale || this._locale, n = e?.fullBreakdown ?? !1, r = e?.numeric ?? "always", i = [
445
+ {
446
+ unit: "year",
447
+ value: this.years
448
+ },
449
+ {
450
+ unit: "month",
451
+ value: this.months
452
+ },
453
+ {
454
+ unit: "week",
455
+ value: this.weeks
456
+ },
457
+ {
458
+ unit: "day",
459
+ value: this.days
460
+ },
461
+ {
462
+ unit: "hour",
463
+ value: this.hours
464
+ },
465
+ {
466
+ unit: "minute",
467
+ value: this.minutes
468
+ },
469
+ {
470
+ unit: "second",
471
+ value: this.seconds
472
+ },
473
+ {
474
+ unit: "millisecond",
475
+ value: this.milliseconds
476
+ }
477
+ ].filter((e) => e.value !== 0);
478
+ if (i.length === 0) return "0 seconds";
479
+ if (!n || i.length === 1) {
480
+ let e = i[0];
481
+ try {
482
+ return new Intl.RelativeTimeFormat(t, {
483
+ numeric: r,
484
+ style: "long"
485
+ }).format(e.value, e.unit);
486
+ } catch {
487
+ let n = Math.abs(e.value);
488
+ return `${n} ${this.pluralizeUnit(e.unit, n, t)}`;
489
+ }
490
+ }
491
+ return l(i.map((e) => {
492
+ let n = Math.abs(e.value);
493
+ return `${n} ${s(e.unit, t, n)}`;
494
+ }), t);
495
+ }
496
+ total(e) {
497
+ let t = 0;
498
+ switch (t += this.years * S, t += this.months * x, t += this.weeks * y, t += this.days * v, t += this.hours * _, t += this.minutes * g, t += this.seconds * h, t += this.milliseconds, e) {
499
+ case "millisecond": return t;
500
+ case "second": return t / h;
501
+ case "minute": return t / g;
502
+ case "hour": return t / _;
503
+ case "day": return t / v;
504
+ case "week": return t / y;
505
+ case "month": return t / x;
506
+ case "year": return t / S;
507
+ case "microsecond": return t * 1e3;
508
+ case "nanosecond": return t * 1e6;
509
+ default: throw Error(`Unsupported unit: ${e}`);
510
+ }
511
+ }
512
+ toString() {
513
+ return this.humanize({ fullBreakdown: !0 });
514
+ }
515
+ toJSON() {
516
+ return {
517
+ years: this.years,
518
+ months: this.months,
519
+ weeks: this.weeks,
520
+ days: this.days,
521
+ hours: this.hours,
522
+ minutes: this.minutes,
523
+ seconds: this.seconds,
524
+ milliseconds: this.milliseconds
525
+ };
526
+ }
527
+ explain() {
528
+ let e = [...this._steps];
529
+ e.length === 0 && (e = this.generateExplanationSteps());
530
+ let t = [];
531
+ if (this._startDate && this._endDate && t.push(`Calculated duration from ${this._startDate} to ${this._endDate}`), this._leapYearFlags && this._leapYearFlags.length > 0) {
532
+ let e = this._leapYearFlags.filter((e) => e.isLeap).map((e) => e.year);
533
+ e.length > 0 && t.push(`Leap year(s) detected: ${e.join(", ")}`);
534
+ }
535
+ return t.push(`Breakdown: ${this.years} year(s), ${this.months} month(s), ${this.days} day(s)`), t.push(`Mode: ${this._mode} calculation`), {
536
+ input: this._startDate && this._endDate ? [this._startDate, this._endDate] : [],
537
+ steps: e,
538
+ breakdown: {
539
+ years: this.years,
540
+ months: this.months,
541
+ weeks: this.weeks,
542
+ days: this.days,
543
+ hours: this.hours,
544
+ minutes: this.minutes,
545
+ seconds: this.seconds,
546
+ milliseconds: this.milliseconds
547
+ },
548
+ mode: this._mode,
549
+ explanation: t.join(". "),
550
+ locale: this._locale,
551
+ leapYearFlags: this._leapYearFlags.length > 0 ? this._leapYearFlags : void 0,
552
+ metadata: {
553
+ calculationTimeMs: this._calculationTimeMs,
554
+ precision: "day"
555
+ }
556
+ };
557
+ }
558
+ generateExplanationSteps() {
559
+ let e = [];
560
+ if (this._startDate && this._endDate ? e.push(`Input: ${this._startDate} to ${this._endDate}`) : e.push("Duration calculation started"), this.years > 0 && e.push(`Years: ${this.years}`), this.months > 0 && e.push(`Months: ${this.months}`), this.weeks > 0 && e.push(`Weeks: ${this.weeks}`), this.days > 0 && e.push(`Days: ${this.days}`), this.hours > 0 && e.push(`Hours: ${this.hours}`), this.minutes > 0 && e.push(`Minutes: ${this.minutes}`), this.seconds > 0 && e.push(`Seconds: ${this.seconds}`), this.milliseconds > 0 && e.push(`Milliseconds: ${this.milliseconds}`), this._leapYearFlags && this._leapYearFlags.length > 0) for (let t of this._leapYearFlags) t.isLeap && e.push(`${t.year} is a leap year (February has ${t.daysInFebruary} days)`);
561
+ let t = [
562
+ this.years > 0 ? `${this.years}y` : "",
563
+ this.months > 0 ? `${this.months}m` : "",
564
+ this.days > 0 ? `${this.days}d` : "",
565
+ this.hours > 0 ? `${this.hours}h` : "",
566
+ this.minutes > 0 ? `${this.minutes}min` : "",
567
+ this.seconds > 0 ? `${this.seconds}s` : ""
568
+ ].filter((e) => e.length > 0).join(" ");
569
+ return e.push(`Total: ${t || "0"}`), e;
570
+ }
571
+ pluralizeUnit(e, t, n) {
572
+ return s(e, n, t);
573
+ }
574
+ }, D = class e {
575
+ _start;
576
+ _end;
577
+ _ordered;
578
+ constructor(e, t) {
579
+ this._start = e, this._end = t;
580
+ }
581
+ get start() {
582
+ return this._start;
583
+ }
584
+ get end() {
585
+ return this._end;
586
+ }
587
+ getOrdered() {
588
+ if (!this._ordered) {
589
+ let e = r.toPlainDateTime(this._start.toTemporal()), t = r.toPlainDateTime(this._end.toTemporal());
590
+ this._ordered = r.compare(e, t) <= 0 ? [e, t] : [t, e];
591
+ }
592
+ return this._ordered;
593
+ }
594
+ toDuration() {
595
+ return O.between(this._start, this._end);
596
+ }
597
+ inMonths() {
598
+ return this.toDuration().total("month");
599
+ }
600
+ humanize(e) {
601
+ return this.toDuration().humanize(e);
602
+ }
603
+ in(e) {
604
+ return this.toDuration().total(e);
605
+ }
606
+ contains(e) {
607
+ let t = e instanceof O ? e : new O(e), n = r.toPlainDateTime(t.toTemporal()), [i, a] = this.getOrdered();
608
+ return r.compare(n, i) >= 0 && r.compare(n, a) <= 0;
609
+ }
610
+ overlaps(e) {
611
+ let [t, n] = this.getOrdered(), [i, a] = e.getOrdered();
612
+ return r.compare(t, a) <= 0 && r.compare(i, n) <= 0;
613
+ }
614
+ intersect(t) {
615
+ if (!this.overlaps(t)) return null;
616
+ let [n, i] = this.getOrdered(), [a, o] = t.getOrdered(), s = r.compare(n, a) >= 0 ? n : a, c = r.compare(i, o) <= 0 ? i : o;
617
+ return new e(O.fromTemporal(s, { locale: this._start.locale() }), O.fromTemporal(c, { locale: this._end.locale() }));
618
+ }
619
+ union(t) {
620
+ let [n, i] = this.getOrdered(), [a, o] = t.getOrdered(), s = r.compare(n, a) <= 0 ? n : a, c = r.compare(i, o) >= 0 ? i : o;
621
+ return new e(O.fromTemporal(s, { locale: this._start.locale() }), O.fromTemporal(c, { locale: this._end.locale() }));
622
+ }
623
+ }, O = class e {
624
+ temporal;
625
+ config;
626
+ formatterInstance;
627
+ static holidays = /* @__PURE__ */ new Set();
628
+ static registerHolidays(t) {
629
+ t.forEach((t) => {
630
+ try {
631
+ let n = new e(t);
632
+ this.holidays.add(n.format("YYYY-MM-DD"));
633
+ } catch {}
634
+ });
635
+ }
636
+ static clearHolidays() {
637
+ this.holidays.clear();
638
+ }
639
+ static getRegisteredHolidays() {
640
+ return Array.from(this.holidays).sort();
641
+ }
642
+ static ZERO_DURATION = {
643
+ years: 0,
644
+ months: 0,
645
+ weeks: 0,
646
+ days: 0,
647
+ hours: 0,
648
+ minutes: 0,
649
+ seconds: 0,
650
+ milliseconds: 0
651
+ };
652
+ static isLeapYearValue(e) {
653
+ return e % 4 == 0 && e % 100 != 0 || e % 400 == 0;
654
+ }
655
+ static toDurationParts(e) {
656
+ return {
657
+ years: Math.floor(e.years || 0),
658
+ months: Math.floor(e.months || 0),
659
+ weeks: Math.floor(e.weeks || 0),
660
+ days: Math.floor(e.days || 0),
661
+ hours: Math.floor(e.hours || 0),
662
+ minutes: Math.floor(e.minutes || 0),
663
+ seconds: Math.floor(e.seconds || 0),
664
+ milliseconds: Math.floor(e.milliseconds || 0)
665
+ };
666
+ }
667
+ constructor(t, n) {
668
+ if (this.formatterInstance = new i(), this.config = {
669
+ locale: n?.locale || "en",
670
+ timezone: n?.timezone || "UTC",
671
+ strict: n?.strict ?? !1
672
+ }, t === void 0) {
673
+ this.temporal = r.nowInTimezone(n?.timezone);
674
+ return;
675
+ }
676
+ let a = t instanceof e ? t.toTemporal() : t;
677
+ if (this.temporal = r.parseToPlainDateTime(a), this.config.timezone && this.config.timezone !== "UTC") try {
678
+ let e = this.temporal.toZonedDateTime(this.config.timezone);
679
+ this.temporal = e;
680
+ } catch {}
681
+ }
682
+ static now(t) {
683
+ return new e(void 0, t);
684
+ }
685
+ static from(t, n) {
686
+ return new e(t, n);
687
+ }
688
+ static fromTemporal(t, n) {
689
+ let r = new e(void 0, n);
690
+ return r.temporal = t, r;
691
+ }
692
+ static between(e, t) {
693
+ let n = r.toPlainDateTime(e.temporal), i = r.toPlainDateTime(t.temporal), [a, o] = r.compare(n, i) <= 0 ? [e, t] : [t, e];
694
+ return a.until(o);
695
+ }
696
+ static range(t, n) {
697
+ return new D(t instanceof e ? t : new e(t), n instanceof e ? n : new e(n));
698
+ }
699
+ toTemporal() {
700
+ return this.temporal;
701
+ }
702
+ toDate() {
703
+ return r.toDate(this.temporal);
704
+ }
705
+ toISOString() {
706
+ return r.toISOString(this.temporal);
707
+ }
708
+ valueOf() {
709
+ return r.toUnix(this.temporal);
710
+ }
711
+ unix() {
712
+ return Math.floor(this.valueOf() / 1e3);
713
+ }
714
+ toJSON() {
715
+ return this.toISOString();
716
+ }
717
+ [Symbol.toPrimitive](e) {
718
+ return e === "number" ? this.valueOf() : this.toISOString();
719
+ }
720
+ toString() {
721
+ return this.format("YYYY-MM-DD HH:mm:ss");
722
+ }
723
+ locale(e) {
724
+ if (e === void 0) return this.config.locale;
725
+ let t = this.clone();
726
+ return t.config.locale = e, t;
727
+ }
728
+ timezone(e) {
729
+ if (e === void 0) return this.config.timezone;
730
+ let t = this.clone();
731
+ t.config.timezone = e;
732
+ try {
733
+ t.temporal = r.toPlainDateTime(t.temporal).toZonedDateTime(e);
734
+ } catch {}
735
+ return t;
736
+ }
737
+ format(e) {
738
+ let t = [
739
+ "iso",
740
+ "date",
741
+ "time",
742
+ "datetime",
743
+ "rfc2822",
744
+ "rfc3339",
745
+ "utc"
746
+ ], n = [
747
+ "iso",
748
+ "rfc2822",
749
+ "rfc3339",
750
+ "utc"
751
+ ].includes(e) && r.isZonedDateTime(this.temporal) ? this.temporal.toInstant().toZonedDateTimeISO("UTC").toPlainDateTime() : r.toPlainDateTime(this.temporal), i = t.includes(e) ? this.formatterInstance.getPreset(e) : e;
752
+ return this.formatterInstance.format(n, i, this.config.locale);
753
+ }
754
+ get(e) {
755
+ let t = r.toPlainDateTime(this.temporal);
756
+ return e === "week" ? t.weekOfYear : t[{
757
+ year: "year",
758
+ month: "month",
759
+ day: "day",
760
+ hour: "hour",
761
+ minute: "minute",
762
+ second: "second",
763
+ millisecond: "millisecond",
764
+ microsecond: "microsecond",
765
+ nanosecond: "nanosecond"
766
+ }[e]];
767
+ }
768
+ static UNIT_TO_PLURAL = {
769
+ year: "years",
770
+ month: "months",
771
+ week: "weeks",
772
+ day: "days",
773
+ hour: "hours",
774
+ minute: "minutes",
775
+ second: "seconds",
776
+ millisecond: "milliseconds",
777
+ microsecond: "microseconds",
778
+ nanosecond: "nanoseconds",
779
+ years: "years",
780
+ months: "months",
781
+ weeks: "weeks",
782
+ days: "days",
783
+ hours: "hours",
784
+ minutes: "minutes",
785
+ seconds: "seconds",
786
+ milliseconds: "milliseconds",
787
+ microseconds: "microseconds",
788
+ nanoseconds: "nanoseconds"
789
+ };
790
+ add(t) {
791
+ let n = r.toPlainDateTime(this.temporal), i = {
792
+ years: 0,
793
+ months: 0,
794
+ weeks: 0,
795
+ days: 0,
796
+ hours: 0,
797
+ minutes: 0,
798
+ seconds: 0,
799
+ milliseconds: 0,
800
+ microseconds: 0,
801
+ nanoseconds: 0
802
+ }, a = !1;
803
+ return Object.entries(t).forEach(([t, n]) => {
804
+ if (n !== void 0 && n !== 0) {
805
+ let r = Number(n);
806
+ if (Number.isFinite(r)) {
807
+ let n = e.UNIT_TO_PLURAL[t] || t;
808
+ i[n] = Math.trunc(r), a = !0;
809
+ }
810
+ }
811
+ }), a ? (n = n.add(i), e.fromTemporal(n, this.config)) : this;
812
+ }
813
+ subtract(e) {
814
+ let t = {};
815
+ return Object.entries(e).forEach(([e, n]) => {
816
+ t[e] = n ? -n : 0;
817
+ }), this.add(t);
818
+ }
819
+ diff(e, t) {
820
+ let n = r.toPlainDateTime(this.temporal), i = r.toPlainDateTime(e.temporal), a = {
821
+ year: "years",
822
+ month: "months",
823
+ week: "weeks",
824
+ day: "days",
825
+ hour: "hours",
826
+ minute: "minutes",
827
+ second: "seconds",
828
+ millisecond: "milliseconds",
829
+ microsecond: "microseconds",
830
+ nanosecond: "nanoseconds"
831
+ };
832
+ if (typeof t == "string") {
833
+ let e = t, r = a[e], o = n.since(i, {
834
+ largestUnit: e,
835
+ smallestUnit: e
836
+ });
837
+ return Math.round(o[r] || 0);
838
+ }
839
+ let o = t || {}, s = o.mode || "exact", c = o.unit || "millisecond", l = o.locale || this.config.locale;
840
+ if (s === "exact") {
841
+ let r = a[c], o = n.since(i, { smallestUnit: c }), u = Math.round(o[r] || 0);
842
+ if (t === void 0 || typeof t == "object") {
843
+ let t = w(o);
844
+ return new T(Math.round(t), this, e, s, void 0, l);
845
+ }
846
+ return u;
847
+ }
848
+ if (s === "calendar") {
849
+ let t = r.compare(n, i) < 0, a = t ? i : n, o = t ? n : i, c = a.since(o, {
850
+ largestUnit: "month",
851
+ smallestUnit: "millisecond"
852
+ }), u = {
853
+ years: Math.floor(c.years || 0),
854
+ months: Math.floor(c.months || 0),
855
+ weeks: Math.floor(c.weeks || 0),
856
+ days: Math.floor(c.days || 0),
857
+ hours: Math.floor(c.hours || 0),
858
+ minutes: Math.floor(c.minutes || 0),
859
+ seconds: Math.floor(c.seconds || 0),
860
+ milliseconds: Math.floor(c.milliseconds || 0)
861
+ }, d = w(c);
862
+ return new T(Math.round(d), this, e, s, u, l);
863
+ }
864
+ let u = w(n.since(i, { smallestUnit: "millisecond" }));
865
+ return new T(Math.round(u), this, e, s, void 0, l);
866
+ }
867
+ isBefore(e) {
868
+ let t = r.toPlainDateTime(this.temporal), n = r.toPlainDateTime(e.temporal);
869
+ return r.compare(t, n) < 0;
870
+ }
871
+ isAfter(e) {
872
+ let t = r.toPlainDateTime(this.temporal), n = r.toPlainDateTime(e.temporal);
873
+ return r.compare(t, n) > 0;
874
+ }
875
+ isSame(e, t) {
876
+ if (!t) return r.compare(r.toPlainDateTime(this.temporal), r.toPlainDateTime(e.temporal)) === 0;
877
+ let n = r.toPlainDateTime(this.temporal), i = r.toPlainDateTime(e.temporal);
878
+ switch (t) {
879
+ case "year": return n.year === i.year;
880
+ case "month": return n.year === i.year && n.month === i.month;
881
+ case "day": return n.year === i.year && n.month === i.month && n.day === i.day;
882
+ case "hour": return n.year === i.year && n.month === i.month && n.day === i.day && n.hour === i.hour;
883
+ case "minute": return n.year === i.year && n.month === i.month && n.day === i.day && n.hour === i.hour && n.minute === i.minute;
884
+ case "second": return n.year === i.year && n.month === i.month && n.day === i.day && n.hour === i.hour && n.minute === i.minute && n.second === i.second;
885
+ default: return !1;
886
+ }
887
+ }
888
+ isBetween(e, t, n, i = "[]") {
889
+ let a = r.toPlainDateTime(this.temporal), o = r.toPlainDateTime(e.temporal), s = r.toPlainDateTime(t.temporal), c = !0, l = !0;
890
+ if (n) {
891
+ let e = this.clone().startOf(n), t = this.clone().endOf(n), i = r.toPlainDateTime(e.temporal), a = r.toPlainDateTime(t.temporal);
892
+ c = r.compare(i, o) >= 0, l = r.compare(a, s) <= 0;
893
+ } else c = r.compare(a, o) >= 0, l = r.compare(a, s) <= 0;
894
+ let u = i[0] === "[", d = i[1] === "]";
895
+ return (u ? c : r.compare(a, o) > 0) && (d ? l : r.compare(a, s) < 0);
896
+ }
897
+ clone() {
898
+ return e.fromTemporal(this.temporal, this.config);
899
+ }
900
+ startOf(t) {
901
+ let n = r.toPlainDateTime(this.temporal), i = {};
902
+ switch (t) {
903
+ case "year":
904
+ i.month = 1, i.day = 1, i.hour = 0, i.minute = 0, i.second = 0, i.millisecond = 0;
905
+ break;
906
+ case "month":
907
+ i.day = 1, i.hour = 0, i.minute = 0, i.second = 0, i.millisecond = 0;
908
+ break;
909
+ case "week":
910
+ case "day":
911
+ i.hour = 0, i.minute = 0, i.second = 0, i.millisecond = 0;
912
+ break;
913
+ case "hour":
914
+ i.minute = 0, i.second = 0, i.millisecond = 0;
915
+ break;
916
+ case "minute":
917
+ i.second = 0, i.millisecond = 0;
918
+ break;
919
+ case "second":
920
+ i.millisecond = 0;
921
+ break;
922
+ }
923
+ let a = n.with(i);
924
+ return e.fromTemporal(a, this.config);
925
+ }
926
+ endOf(e) {
927
+ return this.startOf(e).add({ [e]: 1 }).subtract({ millisecond: 1 });
928
+ }
929
+ set(t) {
930
+ let n = r.toPlainDateTime(this.temporal).with(t);
931
+ return e.fromTemporal(n, this.config);
932
+ }
933
+ year() {
934
+ return r.toPlainDateTime(this.temporal).year;
935
+ }
936
+ month() {
937
+ return r.toPlainDateTime(this.temporal).month;
938
+ }
939
+ day() {
940
+ return r.toPlainDateTime(this.temporal).day;
941
+ }
942
+ hour() {
943
+ return r.toPlainDateTime(this.temporal).hour;
944
+ }
945
+ minute() {
946
+ return r.toPlainDateTime(this.temporal).minute;
947
+ }
948
+ second() {
949
+ return r.toPlainDateTime(this.temporal).second;
950
+ }
951
+ millisecond() {
952
+ return r.toPlainDateTime(this.temporal).millisecond;
953
+ }
954
+ dayOfWeek() {
955
+ return r.toPlainDateTime(this.temporal).dayOfWeek;
956
+ }
957
+ dayOfYear() {
958
+ return r.toPlainDateTime(this.temporal).dayOfYear;
959
+ }
960
+ weekOfYear() {
961
+ return r.toPlainDateTime(this.temporal).weekOfYear;
962
+ }
963
+ daysInMonth() {
964
+ return r.toPlainDateTime(this.temporal).add({ months: 1 }).with({ day: 1 }).subtract({ days: 1 }).day;
965
+ }
966
+ daysInYear() {
967
+ let t = this.year();
968
+ return e.isLeapYearValue(t) ? 366 : 365;
969
+ }
970
+ inLeapYear() {
971
+ let t = r.toPlainDateTime(this.temporal);
972
+ return e.isLeapYearValue(t.year);
973
+ }
974
+ until(t, n) {
975
+ let i = r.toPlainDateTime(this.temporal), a = r.toPlainDateTime(t.temporal), o = performance.now();
976
+ try {
977
+ let t = { largestUnit: n?.largestUnit || "year" };
978
+ n?.smallestUnit && (t.smallestUnit = n.smallestUnit);
979
+ let r = a.since(i, t), s = e.toDurationParts(r), c = i.year, l = a.year, u = [];
980
+ for (let t = c; t <= l; t++) {
981
+ let n = e.isLeapYearValue(t);
982
+ u.push({
983
+ year: t,
984
+ isLeap: n,
985
+ daysInFebruary: n ? 29 : 28
986
+ });
987
+ }
988
+ let d = this.generateUntilSteps(i, a, s, u), f = performance.now() - o;
989
+ return new E(s, this.config.locale, {
990
+ startDate: i.toString(),
991
+ endDate: a.toString(),
992
+ steps: d,
993
+ mode: "exact",
994
+ leapYearFlags: u.filter((e) => e.isLeap),
995
+ calculationTimeMs: f
996
+ });
997
+ } catch {
998
+ return new E(e.ZERO_DURATION, this.config.locale, {
999
+ startDate: i.toString(),
1000
+ endDate: a.toString(),
1001
+ steps: ["Calculation failed, returning zero duration"],
1002
+ mode: "estimated"
1003
+ });
1004
+ }
1005
+ }
1006
+ generateUntilSteps(t, n, r, i) {
1007
+ let a = [];
1008
+ a.push(`Parsed dates: ${t.year}-${String(t.month).padStart(2, "0")}-${String(t.day).padStart(2, "0")} (day ${t.dayOfYear} of ${e.isLeapYearValue(t.year) ? 366 : 365})`), a.push(`to ${n.year}-${String(n.month).padStart(2, "0")}-${String(n.day).padStart(2, "0")} (day ${n.dayOfYear} of ${e.isLeapYearValue(n.year) ? 366 : 365})`);
1009
+ let o = i.filter((e) => e.isLeap);
1010
+ if (o.length > 0) for (let e of o) a.push(`${e.year} is a leap year (February has ${e.daysInFebruary} days)`);
1011
+ if (r.years > 0 && a.push(`Years: ${r.years}`), r.months > 0 && a.push(`Months: ${r.months}`), r.days > 0 && a.push(`Days: ${r.days}`), r.hours > 0 || r.minutes > 0 || r.seconds > 0) {
1012
+ let e = [];
1013
+ r.hours > 0 && e.push(`${r.hours}h`), r.minutes > 0 && e.push(`${r.minutes}m`), r.seconds > 0 && e.push(`${r.seconds}s`), a.push(`Time: ${e.join(" ")}`);
1014
+ }
1015
+ let s = r.years * 365.25 + r.months * 30.4375 + r.days + r.hours / 24;
1016
+ return a.push(`Total: approximately ${s.toFixed(2)} days`), a;
1017
+ }
1018
+ round(e = {}) {
1019
+ let { smallestUnit: t = "millisecond", roundingMode: n = "halfExpand" } = e, i = r.toPlainDateTime(this.temporal), a = {
1020
+ year: i.year,
1021
+ month: i.month,
1022
+ day: i.day,
1023
+ hour: i.hour,
1024
+ minute: i.minute,
1025
+ second: i.second,
1026
+ millisecond: i.millisecond,
1027
+ microsecond: i.microsecond || 0,
1028
+ nanosecond: i.nanosecond || 0,
1029
+ week: 0
1030
+ }, o = [
1031
+ "year",
1032
+ "month",
1033
+ "day",
1034
+ "hour",
1035
+ "minute",
1036
+ "second",
1037
+ "millisecond",
1038
+ "microsecond",
1039
+ "nanosecond"
1040
+ ], s = o.indexOf(t);
1041
+ if (s === -1) return this.clone();
1042
+ let c = {};
1043
+ for (let e = 0; e < s; e++) {
1044
+ let t = o[e];
1045
+ c[t] = a[t];
1046
+ }
1047
+ let l = o[s], u = a[l];
1048
+ s + 1 < o.length && ((e, t) => {
1049
+ switch (e) {
1050
+ case "ceil": return t > 0;
1051
+ case "floor":
1052
+ case "trunc": return !1;
1053
+ case "halfExpand":
1054
+ case "halfFloor":
1055
+ case "halfCeil": return t >= 5;
1056
+ case "expand": return t > 0;
1057
+ default: return t >= 5;
1058
+ }
1059
+ })(n, a[o[s + 1]]) && (u += 1), c[l] = u;
1060
+ for (let e = s + 1; e < o.length; e++) c[o[e]] = 0;
1061
+ return this.set(c);
1062
+ }
1063
+ toPlainDate() {
1064
+ let e = r.toPlainDateTime(this.temporal);
1065
+ return {
1066
+ year: e.year,
1067
+ month: e.month,
1068
+ day: e.day,
1069
+ dayOfWeek: e.dayOfWeek
1070
+ };
1071
+ }
1072
+ toPlainTime() {
1073
+ let e = r.toPlainDateTime(this.temporal);
1074
+ return {
1075
+ hour: e.hour,
1076
+ minute: e.minute,
1077
+ second: e.second,
1078
+ millisecond: e.millisecond
1079
+ };
1080
+ }
1081
+ withDate(e, t, n) {
1082
+ return this.set({
1083
+ year: e,
1084
+ month: t,
1085
+ day: n
1086
+ });
1087
+ }
1088
+ withTime(e, t = 0, n = 0, r = 0) {
1089
+ return this.set({
1090
+ hour: e,
1091
+ minute: t,
1092
+ second: n,
1093
+ millisecond: r
1094
+ });
1095
+ }
1096
+ getOffset() {
1097
+ return this.temporal?.offset || "Z";
1098
+ }
1099
+ getOffsetNanoseconds() {
1100
+ return this.temporal?.offsetNanoseconds || 0;
1101
+ }
1102
+ getTimeZoneId() {
1103
+ return this.temporal?.timeZoneId || null;
1104
+ }
1105
+ startOfDay() {
1106
+ return this.startOf("day");
1107
+ }
1108
+ endOfDay() {
1109
+ return this.endOf("day");
1110
+ }
1111
+ since(t, n) {
1112
+ let i = r.toPlainDateTime(this.temporal), a = r.toPlainDateTime(t.temporal), o = performance.now();
1113
+ try {
1114
+ let t = { largestUnit: n?.largestUnit || "year" };
1115
+ n?.smallestUnit && (t.smallestUnit = n.smallestUnit);
1116
+ let r = i.since(a, t), s = e.toDurationParts(r), c = a.year, l = i.year, u = [];
1117
+ for (let t = c; t <= l; t++) {
1118
+ let n = e.isLeapYearValue(t);
1119
+ u.push({
1120
+ year: t,
1121
+ isLeap: n,
1122
+ daysInFebruary: n ? 29 : 28
1123
+ });
1124
+ }
1125
+ let d = this.generateUntilSteps(a, i, s, u), f = performance.now() - o;
1126
+ return new E(s, this.config.locale, {
1127
+ startDate: a.toString(),
1128
+ endDate: i.toString(),
1129
+ steps: d,
1130
+ mode: "exact",
1131
+ leapYearFlags: u.filter((e) => e.isLeap),
1132
+ calculationTimeMs: f
1133
+ });
1134
+ } catch {
1135
+ return new E(e.ZERO_DURATION, this.config.locale, {
1136
+ startDate: a.toString(),
1137
+ endDate: i.toString(),
1138
+ steps: ["Calculation failed, returning zero duration"],
1139
+ mode: "estimated"
1140
+ });
1141
+ }
1142
+ }
1143
+ toDurationString(t) {
1144
+ let n = t ? this.until(t) : this.until(e.now()), r = [];
1145
+ n.years && r.push(`${n.years}Y`), n.months && r.push(`${n.months}M`), n.days && r.push(`${n.days}D`);
1146
+ let i = [];
1147
+ n.hours && i.push(`${n.hours}H`), n.minutes && i.push(`${n.minutes}M`), n.seconds && i.push(`${n.seconds}S`);
1148
+ let a = `P${r.join("")}${i.length > 0 ? "T" + i.join("") : ""}`;
1149
+ return a === "P" ? "PT0S" : a;
1150
+ }
1151
+ isPast() {
1152
+ return this.isBefore(e.now());
1153
+ }
1154
+ isFuture() {
1155
+ return this.isAfter(e.now());
1156
+ }
1157
+ isToday() {
1158
+ return this.isSame(e.now(), "day");
1159
+ }
1160
+ isTomorrow() {
1161
+ return this.isSame(e.now().add({ day: 1 }), "day");
1162
+ }
1163
+ isYesterday() {
1164
+ return this.isSame(e.now().subtract({ day: 1 }), "day");
1165
+ }
1166
+ isWeekend() {
1167
+ let e = r.toPlainDateTime(this.temporal);
1168
+ return e.dayOfWeek === 6 || e.dayOfWeek === 7;
1169
+ }
1170
+ isHoliday() {
1171
+ let t = String(this.get("year")).padStart(4, "0"), n = String(this.get("month")).padStart(2, "0"), r = String(this.get("day")).padStart(2, "0");
1172
+ return e.holidays.has(`${t}-${n}-${r}`);
1173
+ }
1174
+ isBusinessDay() {
1175
+ return !this.isWeekend() && !this.isHoliday();
1176
+ }
1177
+ addBusinessDays(e) {
1178
+ let t = Math.trunc(e);
1179
+ if (!Number.isFinite(t) || t === 0) return this;
1180
+ let n = this.clone(), r = Math.abs(t), i = t > 0 ? 1 : -1;
1181
+ for (; r > 0;) n = n.add({ day: i }), n.isBusinessDay() && r--;
1182
+ return n;
1183
+ }
1184
+ subtractBusinessDays(e) {
1185
+ return this.addBusinessDays(-e);
1186
+ }
1187
+ }, k = 1e3, A = 6e4;
1188
+ function j(e, t) {
1189
+ let n = O.from(e), r = O.now();
1190
+ return n.since(r).humanize(t);
1191
+ }
1192
+ function M(e, t, n) {
1193
+ return new D(O.from(e, n), O.from(t, n));
1194
+ }
1195
+ function N(e, t) {
1196
+ return new O(e, t);
1197
+ }
1198
+ var P = "2.9.0";
1199
+ //#endregion
1200
+ export { D as a, N as c, f as d, d as f, r as h, O as i, P as l, i as m, k as n, j as o, p, E as r, M as s, A as t, m as u };