@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
1,713 lines • 93.3 kB
JavaScript
import { jsx as Be } from "react/jsx-runtime";
import l, { createContext as fn, useContext as dn, useCallback as H, useRef as De, useLayoutEffect as ln, useState as Oe, useEffect as hn, useMemo as ve } from "react";
import { cn as fe } from "../../utils/index.js";
import { datePickerVariants as mn } from "./DatePicker.variants.js";
import { C as yn, a as gn } from "../../chevron-left-C4LEg1fH.js";
import '../../DatePicker.css';function bn(e, t, r = "long") {
return new Intl.DateTimeFormat("en-US", {
// Enforces engine to render the time. Without the option JavaScriptCore omits it.
hour: "numeric",
timeZone: e,
timeZoneName: r
}).format(t).split(/\s/g).slice(2).join(" ");
}
const wn = {}, he = {};
function se(e, t) {
try {
const n = (wn[e] ||= new Intl.DateTimeFormat("en-US", {
timeZone: e,
timeZoneName: "longOffset"
}).format)(t).split("GMT")[1];
return n in he ? he[n] : Je(n, n.split(":"));
} catch {
if (e in he) return he[e];
const r = e?.match(pn);
return r ? Je(e, r.slice(1)) : NaN;
}
}
const pn = /([+-]\d\d):?(\d\d)?/;
function Je(e, t) {
const r = +(t[0] || 0), n = +(t[1] || 0), o = +(t[2] || 0) / 60;
return he[e] = r * 60 + n > 0 ? r * 60 + n + o : r * 60 - n - o;
}
class U extends Date {
//#region static
constructor(...t) {
super(), t.length > 1 && typeof t[t.length - 1] == "string" && (this.timeZone = t.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(se(this.timeZone, this)) ? this.setTime(NaN) : t.length ? typeof t[0] == "number" && (t.length === 1 || t.length === 2 && typeof t[1] != "number") ? this.setTime(t[0]) : typeof t[0] == "string" ? this.setTime(+new Date(t[0])) : t[0] instanceof Date ? this.setTime(+t[0]) : (this.setTime(+new Date(...t)), lt(this), Re(this)) : this.setTime(Date.now());
}
static tz(t, ...r) {
return r.length ? new U(...r, t) : new U(Date.now(), t);
}
//#endregion
//#region time zone
withTimeZone(t) {
return new U(+this, t);
}
getTimezoneOffset() {
const t = -se(this.timeZone, this);
return t > 0 ? Math.floor(t) : Math.ceil(t);
}
//#endregion
//#region time
setTime(t) {
return Date.prototype.setTime.apply(this, arguments), Re(this), +this;
}
//#endregion
//#region date-fns integration
[Symbol.for("constructDateFrom")](t) {
return new U(+new Date(t), this.timeZone);
}
//#endregion
}
const et = /^(get|set)(?!UTC)/;
Object.getOwnPropertyNames(Date.prototype).forEach((e) => {
if (!et.test(e)) return;
const t = e.replace(et, "$1UTC");
U.prototype[t] && (e.startsWith("get") ? U.prototype[e] = function() {
return this.internal[t]();
} : (U.prototype[e] = function() {
return Date.prototype[t].apply(this.internal, arguments), Mn(this), +this;
}, U.prototype[t] = function() {
return Date.prototype[t].apply(this, arguments), Re(this), +this;
}));
});
function Re(e) {
e.internal.setTime(+e), e.internal.setUTCSeconds(e.internal.getUTCSeconds() - Math.round(-se(e.timeZone, e) * 60));
}
function Mn(e) {
Date.prototype.setFullYear.call(e, e.internal.getUTCFullYear(), e.internal.getUTCMonth(), e.internal.getUTCDate()), Date.prototype.setHours.call(e, e.internal.getUTCHours(), e.internal.getUTCMinutes(), e.internal.getUTCSeconds(), e.internal.getUTCMilliseconds()), lt(e);
}
function lt(e) {
const t = se(e.timeZone, e), r = t > 0 ? Math.floor(t) : Math.ceil(t), n = /* @__PURE__ */ new Date(+e);
n.setUTCHours(n.getUTCHours() - 1);
const o = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset(), a = -(/* @__PURE__ */ new Date(+n)).getTimezoneOffset(), s = o - a, i = Date.prototype.getHours.apply(e) !== e.internal.getUTCHours();
s && i && e.internal.setUTCMinutes(e.internal.getUTCMinutes() + s);
const c = o - r;
c && Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + c);
const f = /* @__PURE__ */ new Date(+e);
f.setUTCSeconds(0);
const d = o > 0 ? f.getSeconds() : (f.getSeconds() - 60) % 60, u = Math.round(-(se(e.timeZone, e) * 60)) % 60;
(u || d) && (e.internal.setUTCSeconds(e.internal.getUTCSeconds() + u), Date.prototype.setUTCSeconds.call(e, Date.prototype.getUTCSeconds.call(e) + u + d));
const h = se(e.timeZone, e), b = h > 0 ? Math.floor(h) : Math.ceil(h), C = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset() - b, M = b !== r, O = C - c;
if (M && O) {
Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + O);
const N = se(e.timeZone, e), p = N > 0 ? Math.floor(N) : Math.ceil(N), D = b - p;
D && (e.internal.setUTCMinutes(e.internal.getUTCMinutes() + D), Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + D));
}
}
class J extends U {
//#region static
static tz(t, ...r) {
return r.length ? new J(...r, t) : new J(Date.now(), t);
}
//#endregion
//#region representation
toISOString() {
const [t, r, n] = this.tzComponents(), o = `${t}${r}:${n}`;
return this.internal.toISOString().slice(0, -1) + o;
}
toString() {
return `${this.toDateString()} ${this.toTimeString()}`;
}
toDateString() {
const [t, r, n, o] = this.internal.toUTCString().split(" ");
return `${t?.slice(0, -1)} ${n} ${r} ${o}`;
}
toTimeString() {
const t = this.internal.toUTCString().split(" ")[4], [r, n, o] = this.tzComponents();
return `${t} GMT${r}${n}${o} (${bn(this.timeZone, this)})`;
}
toLocaleString(t, r) {
return Date.prototype.toLocaleString.call(this, t, {
...r,
timeZone: r?.timeZone || this.timeZone
});
}
toLocaleDateString(t, r) {
return Date.prototype.toLocaleDateString.call(this, t, {
...r,
timeZone: r?.timeZone || this.timeZone
});
}
toLocaleTimeString(t, r) {
return Date.prototype.toLocaleTimeString.call(this, t, {
...r,
timeZone: r?.timeZone || this.timeZone
});
}
//#endregion
//#region private
tzComponents() {
const t = this.getTimezoneOffset(), r = t > 0 ? "-" : "+", n = String(Math.floor(Math.abs(t) / 60)).padStart(2, "0"), o = String(Math.abs(t) % 60).padStart(2, "0");
return [r, n, o];
}
//#endregion
withTimeZone(t) {
return new J(+this, t);
}
//#region date-fns integration
[Symbol.for("constructDateFrom")](t) {
return new J(+new Date(t), this.timeZone);
}
//#endregion
}
const ht = 6048e5, kn = 864e5, tt = Symbol.for("constructDateFrom");
function B(e, t) {
return typeof e == "function" ? e(t) : e && typeof e == "object" && tt in e ? e[tt](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
}
function E(e, t) {
return B(t || e, e);
}
function mt(e, t, r) {
const n = E(e, r?.in);
return isNaN(t) ? B(e, NaN) : (t && n.setDate(n.getDate() + t), n);
}
function yt(e, t, r) {
const n = E(e, r?.in);
if (isNaN(t)) return B(e, NaN);
if (!t)
return n;
const o = n.getDate(), a = B(e, n.getTime());
a.setMonth(n.getMonth() + t + 1, 0);
const s = a.getDate();
return o >= s ? a : (n.setFullYear(
a.getFullYear(),
a.getMonth(),
o
), n);
}
let Dn = {};
function ge() {
return Dn;
}
function ce(e, t) {
const r = ge(), n = t?.weekStartsOn ?? t?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, o = E(e, t?.in), a = o.getDay(), s = (a < n ? 7 : 0) + a - n;
return o.setDate(o.getDate() - s), o.setHours(0, 0, 0, 0), o;
}
function me(e, t) {
return ce(e, { ...t, weekStartsOn: 1 });
}
function gt(e, t) {
const r = E(e, t?.in), n = r.getFullYear(), o = B(r, 0);
o.setFullYear(n + 1, 0, 4), o.setHours(0, 0, 0, 0);
const a = me(o), s = B(r, 0);
s.setFullYear(n, 0, 4), s.setHours(0, 0, 0, 0);
const i = me(s);
return r.getTime() >= a.getTime() ? n + 1 : r.getTime() >= i.getTime() ? n : n - 1;
}
function nt(e) {
const t = E(e), r = new Date(
Date.UTC(
t.getFullYear(),
t.getMonth(),
t.getDate(),
t.getHours(),
t.getMinutes(),
t.getSeconds(),
t.getMilliseconds()
)
);
return r.setUTCFullYear(t.getFullYear()), +e - +r;
}
function ue(e, ...t) {
const r = B.bind(
null,
t.find((n) => typeof n == "object")
);
return t.map(r);
}
function ye(e, t) {
const r = E(e, t?.in);
return r.setHours(0, 0, 0, 0), r;
}
function bt(e, t, r) {
const [n, o] = ue(
r?.in,
e,
t
), a = ye(n), s = ye(o), i = +a - nt(a), c = +s - nt(s);
return Math.round((i - c) / kn);
}
function vn(e, t) {
const r = gt(e, t), n = B(e, 0);
return n.setFullYear(r, 0, 4), n.setHours(0, 0, 0, 0), me(n);
}
function On(e, t, r) {
return mt(e, t * 7, r);
}
function Wn(e, t, r) {
return yt(e, t * 12, r);
}
function Sn(e, t) {
let r, n = t?.in;
return e.forEach((o) => {
!n && typeof o == "object" && (n = B.bind(null, o));
const a = E(o, n);
(!r || r < a || isNaN(+a)) && (r = a);
}), B(n, r || NaN);
}
function Cn(e, t) {
let r, n = t?.in;
return e.forEach((o) => {
!n && typeof o == "object" && (n = B.bind(null, o));
const a = E(o, n);
(!r || r > a || isNaN(+a)) && (r = a);
}), B(n, r || NaN);
}
function Nn(e, t, r) {
const [n, o] = ue(
r?.in,
e,
t
);
return +ye(n) == +ye(o);
}
function wt(e) {
return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]";
}
function xn(e) {
return !(!wt(e) && typeof e != "number" || isNaN(+E(e)));
}
function Tn(e, t, r) {
const [n, o] = ue(
r?.in,
e,
t
), a = n.getFullYear() - o.getFullYear(), s = n.getMonth() - o.getMonth();
return a * 12 + s;
}
function Yn(e, t) {
const r = E(e, t?.in), n = r.getMonth();
return r.setFullYear(r.getFullYear(), n + 1, 0), r.setHours(23, 59, 59, 999), r;
}
function pt(e, t) {
const [r, n] = ue(e, t.start, t.end);
return { start: r, end: n };
}
function En(e, t) {
const { start: r, end: n } = pt(t?.in, e);
let o = +r > +n;
const a = o ? +r : +n, s = o ? n : r;
s.setHours(0, 0, 0, 0), s.setDate(1);
let i = 1;
const c = [];
for (; +s <= a; )
c.push(B(r, s)), s.setMonth(s.getMonth() + i);
return o ? c.reverse() : c;
}
function Pn(e, t) {
const r = E(e, t?.in);
return r.setDate(1), r.setHours(0, 0, 0, 0), r;
}
function _n(e, t) {
const r = E(e, t?.in), n = r.getFullYear();
return r.setFullYear(n + 1, 0, 0), r.setHours(23, 59, 59, 999), r;
}
function Mt(e, t) {
const r = E(e, t?.in);
return r.setFullYear(r.getFullYear(), 0, 1), r.setHours(0, 0, 0, 0), r;
}
function Fn(e, t) {
const { start: r, end: n } = pt(t?.in, e);
let o = +r > +n;
const a = o ? +r : +n, s = o ? n : r;
s.setHours(0, 0, 0, 0), s.setMonth(0, 1);
let i = 1;
const c = [];
for (; +s <= a; )
c.push(B(r, s)), s.setFullYear(s.getFullYear() + i);
return o ? c.reverse() : c;
}
function kt(e, t) {
const r = ge(), n = t?.weekStartsOn ?? t?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, o = E(e, t?.in), a = o.getDay(), s = (a < n ? -7 : 0) + 6 - (a - n);
return o.setDate(o.getDate() + s), o.setHours(23, 59, 59, 999), o;
}
function Bn(e, t) {
return kt(e, { ...t, weekStartsOn: 1 });
}
const In = {
lessThanXSeconds: {
one: "less than a second",
other: "less than {{count}} seconds"
},
xSeconds: {
one: "1 second",
other: "{{count}} seconds"
},
halfAMinute: "half a minute",
lessThanXMinutes: {
one: "less than a minute",
other: "less than {{count}} minutes"
},
xMinutes: {
one: "1 minute",
other: "{{count}} minutes"
},
aboutXHours: {
one: "about 1 hour",
other: "about {{count}} hours"
},
xHours: {
one: "1 hour",
other: "{{count}} hours"
},
xDays: {
one: "1 day",
other: "{{count}} days"
},
aboutXWeeks: {
one: "about 1 week",
other: "about {{count}} weeks"
},
xWeeks: {
one: "1 week",
other: "{{count}} weeks"
},
aboutXMonths: {
one: "about 1 month",
other: "about {{count}} months"
},
xMonths: {
one: "1 month",
other: "{{count}} months"
},
aboutXYears: {
one: "about 1 year",
other: "about {{count}} years"
},
xYears: {
one: "1 year",
other: "{{count}} years"
},
overXYears: {
one: "over 1 year",
other: "over {{count}} years"
},
almostXYears: {
one: "almost 1 year",
other: "almost {{count}} years"
}
}, An = (e, t, r) => {
let n;
const o = In[e];
return typeof o == "string" ? n = o : t === 1 ? n = o.one : n = o.other.replace("{{count}}", t.toString()), r?.addSuffix ? r.comparison && r.comparison > 0 ? "in " + n : n + " ago" : n;
};
function Ie(e) {
return (t = {}) => {
const r = t.width ? String(t.width) : e.defaultWidth;
return e.formats[r] || e.formats[e.defaultWidth];
};
}
const Hn = {
full: "EEEE, MMMM do, y",
long: "MMMM do, y",
medium: "MMM d, y",
short: "MM/dd/yyyy"
}, qn = {
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
}, jn = {
full: "{{date}} 'at' {{time}}",
long: "{{date}} 'at' {{time}}",
medium: "{{date}}, {{time}}",
short: "{{date}}, {{time}}"
}, Rn = {
date: Ie({
formats: Hn,
defaultWidth: "full"
}),
time: Ie({
formats: qn,
defaultWidth: "full"
}),
dateTime: Ie({
formats: jn,
defaultWidth: "full"
})
}, $n = {
lastWeek: "'last' eeee 'at' p",
yesterday: "'yesterday at' p",
today: "'today at' p",
tomorrow: "'tomorrow at' p",
nextWeek: "eeee 'at' p",
other: "P"
}, Gn = (e, t, r, n) => $n[e];
function de(e) {
return (t, r) => {
const n = r?.context ? String(r.context) : "standalone";
let o;
if (n === "formatting" && e.formattingValues) {
const s = e.defaultFormattingWidth || e.defaultWidth, i = r?.width ? String(r.width) : s;
o = e.formattingValues[i] || e.formattingValues[s];
} else {
const s = e.defaultWidth, i = r?.width ? String(r.width) : e.defaultWidth;
o = e.values[i] || e.values[s];
}
const a = e.argumentCallback ? e.argumentCallback(t) : t;
return o[a];
};
}
const zn = {
narrow: ["B", "A"],
abbreviated: ["BC", "AD"],
wide: ["Before Christ", "Anno Domini"]
}, Qn = {
narrow: ["1", "2", "3", "4"],
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
}, Xn = {
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
abbreviated: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
wide: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
}, Zn = {
narrow: ["S", "M", "T", "W", "T", "F", "S"],
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
wide: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
}, Un = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}
}, Vn = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
}
}, Ln = (e, t) => {
const r = Number(e), n = r % 100;
if (n > 20 || n < 10)
switch (n % 10) {
case 1:
return r + "st";
case 2:
return r + "nd";
case 3:
return r + "rd";
}
return r + "th";
}, Kn = {
ordinalNumber: Ln,
era: de({
values: zn,
defaultWidth: "wide"
}),
quarter: de({
values: Qn,
defaultWidth: "wide",
argumentCallback: (e) => e - 1
}),
month: de({
values: Xn,
defaultWidth: "wide"
}),
day: de({
values: Zn,
defaultWidth: "wide"
}),
dayPeriod: de({
values: Un,
defaultWidth: "wide",
formattingValues: Vn,
defaultFormattingWidth: "wide"
})
};
function le(e) {
return (t, r = {}) => {
const n = r.width, o = n && e.matchPatterns[n] || e.matchPatterns[e.defaultMatchWidth], a = t.match(o);
if (!a)
return null;
const s = a[0], i = n && e.parsePatterns[n] || e.parsePatterns[e.defaultParseWidth], c = Array.isArray(i) ? er(i, (u) => u.test(s)) : (
// [TODO] -- I challenge you to fix the type
Jn(i, (u) => u.test(s))
);
let f;
f = e.valueCallback ? e.valueCallback(c) : c, f = r.valueCallback ? (
// [TODO] -- I challenge you to fix the type
r.valueCallback(f)
) : f;
const d = t.slice(s.length);
return { value: f, rest: d };
};
}
function Jn(e, t) {
for (const r in e)
if (Object.prototype.hasOwnProperty.call(e, r) && t(e[r]))
return r;
}
function er(e, t) {
for (let r = 0; r < e.length; r++)
if (t(e[r]))
return r;
}
function tr(e) {
return (t, r = {}) => {
const n = t.match(e.matchPattern);
if (!n) return null;
const o = n[0], a = t.match(e.parsePattern);
if (!a) return null;
let s = e.valueCallback ? e.valueCallback(a[0]) : a[0];
s = r.valueCallback ? r.valueCallback(s) : s;
const i = t.slice(o.length);
return { value: s, rest: i };
};
}
const nr = /^(\d+)(th|st|nd|rd)?/i, rr = /\d+/i, or = {
narrow: /^(b|a)/i,
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
wide: /^(before christ|before common era|anno domini|common era)/i
}, sr = {
any: [/^b/i, /^(a|c)/i]
}, ar = {
narrow: /^[1234]/i,
abbreviated: /^q[1234]/i,
wide: /^[1234](th|st|nd|rd)? quarter/i
}, ir = {
any: [/1/i, /2/i, /3/i, /4/i]
}, cr = {
narrow: /^[jfmasond]/i,
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
}, ur = {
narrow: [
/^j/i,
/^f/i,
/^m/i,
/^a/i,
/^m/i,
/^j/i,
/^j/i,
/^a/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
],
any: [
/^ja/i,
/^f/i,
/^mar/i,
/^ap/i,
/^may/i,
/^jun/i,
/^jul/i,
/^au/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
]
}, fr = {
narrow: /^[smtwf]/i,
short: /^(su|mo|tu|we|th|fr|sa)/i,
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
}, dr = {
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
}, lr = {
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
}, hr = {
any: {
am: /^a/i,
pm: /^p/i,
midnight: /^mi/i,
noon: /^no/i,
morning: /morning/i,
afternoon: /afternoon/i,
evening: /evening/i,
night: /night/i
}
}, mr = {
ordinalNumber: tr({
matchPattern: nr,
parsePattern: rr,
valueCallback: (e) => parseInt(e, 10)
}),
era: le({
matchPatterns: or,
defaultMatchWidth: "wide",
parsePatterns: sr,
defaultParseWidth: "any"
}),
quarter: le({
matchPatterns: ar,
defaultMatchWidth: "wide",
parsePatterns: ir,
defaultParseWidth: "any",
valueCallback: (e) => e + 1
}),
month: le({
matchPatterns: cr,
defaultMatchWidth: "wide",
parsePatterns: ur,
defaultParseWidth: "any"
}),
day: le({
matchPatterns: fr,
defaultMatchWidth: "wide",
parsePatterns: dr,
defaultParseWidth: "any"
}),
dayPeriod: le({
matchPatterns: lr,
defaultMatchWidth: "any",
parsePatterns: hr,
defaultParseWidth: "any"
})
}, $e = {
code: "en-US",
formatDistance: An,
formatLong: Rn,
formatRelative: Gn,
localize: Kn,
match: mr,
options: {
weekStartsOn: 0,
firstWeekContainsDate: 1
}
};
function yr(e, t) {
const r = E(e, t?.in);
return bt(r, Mt(r)) + 1;
}
function Dt(e, t) {
const r = E(e, t?.in), n = +me(r) - +vn(r);
return Math.round(n / ht) + 1;
}
function vt(e, t) {
const r = E(e, t?.in), n = r.getFullYear(), o = ge(), a = t?.firstWeekContainsDate ?? t?.locale?.options?.firstWeekContainsDate ?? o.firstWeekContainsDate ?? o.locale?.options?.firstWeekContainsDate ?? 1, s = B(t?.in || e, 0);
s.setFullYear(n + 1, 0, a), s.setHours(0, 0, 0, 0);
const i = ce(s, t), c = B(t?.in || e, 0);
c.setFullYear(n, 0, a), c.setHours(0, 0, 0, 0);
const f = ce(c, t);
return +r >= +i ? n + 1 : +r >= +f ? n : n - 1;
}
function gr(e, t) {
const r = ge(), n = t?.firstWeekContainsDate ?? t?.locale?.options?.firstWeekContainsDate ?? r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = vt(e, t), a = B(t?.in || e, 0);
return a.setFullYear(o, 0, n), a.setHours(0, 0, 0, 0), ce(a, t);
}
function Ot(e, t) {
const r = E(e, t?.in), n = +ce(r, t) - +gr(r, t);
return Math.round(n / ht) + 1;
}
function T(e, t) {
const r = e < 0 ? "-" : "", n = Math.abs(e).toString().padStart(t, "0");
return r + n;
}
const re = {
// Year
y(e, t) {
const r = e.getFullYear(), n = r > 0 ? r : 1 - r;
return T(t === "yy" ? n % 100 : n, t.length);
},
// Month
M(e, t) {
const r = e.getMonth();
return t === "M" ? String(r + 1) : T(r + 1, 2);
},
// Day of the month
d(e, t) {
return T(e.getDate(), t.length);
},
// AM or PM
a(e, t) {
const r = e.getHours() / 12 >= 1 ? "pm" : "am";
switch (t) {
case "a":
case "aa":
return r.toUpperCase();
case "aaa":
return r;
case "aaaaa":
return r[0];
case "aaaa":
default:
return r === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h(e, t) {
return T(e.getHours() % 12 || 12, t.length);
},
// Hour [0-23]
H(e, t) {
return T(e.getHours(), t.length);
},
// Minute
m(e, t) {
return T(e.getMinutes(), t.length);
},
// Second
s(e, t) {
return T(e.getSeconds(), t.length);
},
// Fraction of second
S(e, t) {
const r = t.length, n = e.getMilliseconds(), o = Math.trunc(
n * Math.pow(10, r - 3)
);
return T(o, t.length);
}
}, ie = {
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}, rt = {
// Era
G: function(e, t, r) {
const n = e.getFullYear() > 0 ? 1 : 0;
switch (t) {
// AD, BC
case "G":
case "GG":
case "GGG":
return r.era(n, { width: "abbreviated" });
// A, B
case "GGGGG":
return r.era(n, { width: "narrow" });
// Anno Domini, Before Christ
case "GGGG":
default:
return r.era(n, { width: "wide" });
}
},
// Year
y: function(e, t, r) {
if (t === "yo") {
const n = e.getFullYear(), o = n > 0 ? n : 1 - n;
return r.ordinalNumber(o, { unit: "year" });
}
return re.y(e, t);
},
// Local week-numbering year
Y: function(e, t, r, n) {
const o = vt(e, n), a = o > 0 ? o : 1 - o;
if (t === "YY") {
const s = a % 100;
return T(s, 2);
}
return t === "Yo" ? r.ordinalNumber(a, { unit: "year" }) : T(a, t.length);
},
// ISO week-numbering year
R: function(e, t) {
const r = gt(e);
return T(r, t.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function(e, t) {
const r = e.getFullYear();
return T(r, t.length);
},
// Quarter
Q: function(e, t, r) {
const n = Math.ceil((e.getMonth() + 1) / 3);
switch (t) {
// 1, 2, 3, 4
case "Q":
return String(n);
// 01, 02, 03, 04
case "QQ":
return T(n, 2);
// 1st, 2nd, 3rd, 4th
case "Qo":
return r.ordinalNumber(n, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "QQQ":
return r.quarter(n, {
width: "abbreviated",
context: "formatting"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "QQQQQ":
return r.quarter(n, {
width: "narrow",
context: "formatting"
});
// 1st quarter, 2nd quarter, ...
case "QQQQ":
default:
return r.quarter(n, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone quarter
q: function(e, t, r) {
const n = Math.ceil((e.getMonth() + 1) / 3);
switch (t) {
// 1, 2, 3, 4
case "q":
return String(n);
// 01, 02, 03, 04
case "qq":
return T(n, 2);
// 1st, 2nd, 3rd, 4th
case "qo":
return r.ordinalNumber(n, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "qqq":
return r.quarter(n, {
width: "abbreviated",
context: "standalone"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "qqqqq":
return r.quarter(n, {
width: "narrow",
context: "standalone"
});
// 1st quarter, 2nd quarter, ...
case "qqqq":
default:
return r.quarter(n, {
width: "wide",
context: "standalone"
});
}
},
// Month
M: function(e, t, r) {
const n = e.getMonth();
switch (t) {
case "M":
case "MM":
return re.M(e, t);
// 1st, 2nd, ..., 12th
case "Mo":
return r.ordinalNumber(n + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "MMM":
return r.month(n, {
width: "abbreviated",
context: "formatting"
});
// J, F, ..., D
case "MMMMM":
return r.month(n, {
width: "narrow",
context: "formatting"
});
// January, February, ..., December
case "MMMM":
default:
return r.month(n, { width: "wide", context: "formatting" });
}
},
// Stand-alone month
L: function(e, t, r) {
const n = e.getMonth();
switch (t) {
// 1, 2, ..., 12
case "L":
return String(n + 1);
// 01, 02, ..., 12
case "LL":
return T(n + 1, 2);
// 1st, 2nd, ..., 12th
case "Lo":
return r.ordinalNumber(n + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "LLL":
return r.month(n, {
width: "abbreviated",
context: "standalone"
});
// J, F, ..., D
case "LLLLL":
return r.month(n, {
width: "narrow",
context: "standalone"
});
// January, February, ..., December
case "LLLL":
default:
return r.month(n, { width: "wide", context: "standalone" });
}
},
// Local week of year
w: function(e, t, r, n) {
const o = Ot(e, n);
return t === "wo" ? r.ordinalNumber(o, { unit: "week" }) : T(o, t.length);
},
// ISO week of year
I: function(e, t, r) {
const n = Dt(e);
return t === "Io" ? r.ordinalNumber(n, { unit: "week" }) : T(n, t.length);
},
// Day of the month
d: function(e, t, r) {
return t === "do" ? r.ordinalNumber(e.getDate(), { unit: "date" }) : re.d(e, t);
},
// Day of year
D: function(e, t, r) {
const n = yr(e);
return t === "Do" ? r.ordinalNumber(n, { unit: "dayOfYear" }) : T(n, t.length);
},
// Day of week
E: function(e, t, r) {
const n = e.getDay();
switch (t) {
// Tue
case "E":
case "EE":
case "EEE":
return r.day(n, {
width: "abbreviated",
context: "formatting"
});
// T
case "EEEEE":
return r.day(n, {
width: "narrow",
context: "formatting"
});
// Tu
case "EEEEEE":
return r.day(n, {
width: "short",
context: "formatting"
});
// Tuesday
case "EEEE":
default:
return r.day(n, {
width: "wide",
context: "formatting"
});
}
},
// Local day of week
e: function(e, t, r, n) {
const o = e.getDay(), a = (o - n.weekStartsOn + 8) % 7 || 7;
switch (t) {
// Numerical value (Nth day of week with current locale or weekStartsOn)
case "e":
return String(a);
// Padded numerical value
case "ee":
return T(a, 2);
// 1st, 2nd, ..., 7th
case "eo":
return r.ordinalNumber(a, { unit: "day" });
case "eee":
return r.day(o, {
width: "abbreviated",
context: "formatting"
});
// T
case "eeeee":
return r.day(o, {
width: "narrow",
context: "formatting"
});
// Tu
case "eeeeee":
return r.day(o, {
width: "short",
context: "formatting"
});
// Tuesday
case "eeee":
default:
return r.day(o, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone local day of week
c: function(e, t, r, n) {
const o = e.getDay(), a = (o - n.weekStartsOn + 8) % 7 || 7;
switch (t) {
// Numerical value (same as in `e`)
case "c":
return String(a);
// Padded numerical value
case "cc":
return T(a, t.length);
// 1st, 2nd, ..., 7th
case "co":
return r.ordinalNumber(a, { unit: "day" });
case "ccc":
return r.day(o, {
width: "abbreviated",
context: "standalone"
});
// T
case "ccccc":
return r.day(o, {
width: "narrow",
context: "standalone"
});
// Tu
case "cccccc":
return r.day(o, {
width: "short",
context: "standalone"
});
// Tuesday
case "cccc":
default:
return r.day(o, {
width: "wide",
context: "standalone"
});
}
},
// ISO day of week
i: function(e, t, r) {
const n = e.getDay(), o = n === 0 ? 7 : n;
switch (t) {
// 2
case "i":
return String(o);
// 02
case "ii":
return T(o, t.length);
// 2nd
case "io":
return r.ordinalNumber(o, { unit: "day" });
// Tue
case "iii":
return r.day(n, {
width: "abbreviated",
context: "formatting"
});
// T
case "iiiii":
return r.day(n, {
width: "narrow",
context: "formatting"
});
// Tu
case "iiiiii":
return r.day(n, {
width: "short",
context: "formatting"
});
// Tuesday
case "iiii":
default:
return r.day(n, {
width: "wide",
context: "formatting"
});
}
},
// AM or PM
a: function(e, t, r) {
const o = e.getHours() / 12 >= 1 ? "pm" : "am";
switch (t) {
case "a":
case "aa":
return r.dayPeriod(o, {
width: "abbreviated",
context: "formatting"
});
case "aaa":
return r.dayPeriod(o, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "aaaaa":
return r.dayPeriod(o, {
width: "narrow",
context: "formatting"
});
case "aaaa":
default:
return r.dayPeriod(o, {
width: "wide",
context: "formatting"
});
}
},
// AM, PM, midnight, noon
b: function(e, t, r) {
const n = e.getHours();
let o;
switch (n === 12 ? o = ie.noon : n === 0 ? o = ie.midnight : o = n / 12 >= 1 ? "pm" : "am", t) {
case "b":
case "bb":
return r.dayPeriod(o, {
width: "abbreviated",
context: "formatting"
});
case "bbb":
return r.dayPeriod(o, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "bbbbb":
return r.dayPeriod(o, {
width: "narrow",
context: "formatting"
});
case "bbbb":
default:
return r.dayPeriod(o, {
width: "wide",
context: "formatting"
});
}
},
// in the morning, in the afternoon, in the evening, at night
B: function(e, t, r) {
const n = e.getHours();
let o;
switch (n >= 17 ? o = ie.evening : n >= 12 ? o = ie.afternoon : n >= 4 ? o = ie.morning : o = ie.night, t) {
case "B":
case "BB":
case "BBB":
return r.dayPeriod(o, {
width: "abbreviated",
context: "formatting"
});
case "BBBBB":
return r.dayPeriod(o, {
width: "narrow",
context: "formatting"
});
case "BBBB":
default:
return r.dayPeriod(o, {
width: "wide",
context: "formatting"
});
}
},
// Hour [1-12]
h: function(e, t, r) {
if (t === "ho") {
let n = e.getHours() % 12;
return n === 0 && (n = 12), r.ordinalNumber(n, { unit: "hour" });
}
return re.h(e, t);
},
// Hour [0-23]
H: function(e, t, r) {
return t === "Ho" ? r.ordinalNumber(e.getHours(), { unit: "hour" }) : re.H(e, t);
},
// Hour [0-11]
K: function(e, t, r) {
const n = e.getHours() % 12;
return t === "Ko" ? r.ordinalNumber(n, { unit: "hour" }) : T(n, t.length);
},
// Hour [1-24]
k: function(e, t, r) {
let n = e.getHours();
return n === 0 && (n = 24), t === "ko" ? r.ordinalNumber(n, { unit: "hour" }) : T(n, t.length);
},
// Minute
m: function(e, t, r) {
return t === "mo" ? r.ordinalNumber(e.getMinutes(), { unit: "minute" }) : re.m(e, t);
},
// Second
s: function(e, t, r) {
return t === "so" ? r.ordinalNumber(e.getSeconds(), { unit: "second" }) : re.s(e, t);
},
// Fraction of second
S: function(e, t) {
return re.S(e, t);
},
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function(e, t, r) {
const n = e.getTimezoneOffset();
if (n === 0)
return "Z";
switch (t) {
// Hours and optional minutes
case "X":
return st(n);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX":
return oe(n);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX":
// Hours and minutes with `:` delimiter
default:
return oe(n, ":");
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function(e, t, r) {
const n = e.getTimezoneOffset();
switch (t) {
// Hours and optional minutes
case "x":
return st(n);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx":
return oe(n);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx":
// Hours and minutes with `:` delimiter
default:
return oe(n, ":");
}
},
// Timezone (GMT)
O: function(e, t, r) {
const n = e.getTimezoneOffset();
switch (t) {
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + ot(n, ":");
// Long
case "OOOO":
default:
return "GMT" + oe(n, ":");
}
},
// Timezone (specific non-location)
z: function(e, t, r) {
const n = e.getTimezoneOffset();
switch (t) {
// Short
case "z":
case "zz":
case "zzz":
return "GMT" + ot(n, ":");
// Long
case "zzzz":
default:
return "GMT" + oe(n, ":");
}
},
// Seconds timestamp
t: function(e, t, r) {
const n = Math.trunc(+e / 1e3);
return T(n, t.length);
},
// Milliseconds timestamp
T: function(e, t, r) {
return T(+e, t.length);
}
};
function ot(e, t = "") {
const r = e > 0 ? "-" : "+", n = Math.abs(e), o = Math.trunc(n / 60), a = n % 60;
return a === 0 ? r + String(o) : r + String(o) + t + T(a, 2);
}
function st(e, t) {
return e % 60 === 0 ? (e > 0 ? "-" : "+") + T(Math.abs(e) / 60, 2) : oe(e, t);
}
function oe(e, t = "") {
const r = e > 0 ? "-" : "+", n = Math.abs(e), o = T(Math.trunc(n / 60), 2), a = T(n % 60, 2);
return r + o + t + a;
}
const at = (e, t) => {
switch (e) {
case "P":
return t.date({ width: "short" });
case "PP":
return t.date({ width: "medium" });
case "PPP":
return t.date({ width: "long" });
case "PPPP":
default:
return t.date({ width: "full" });
}
}, Wt = (e, t) => {
switch (e) {
case "p":
return t.time({ width: "short" });
case "pp":
return t.time({ width: "medium" });
case "ppp":
return t.time({ width: "long" });
case "pppp":
default:
return t.time({ width: "full" });
}
}, br = (e, t) => {
const r = e.match(/(P+)(p+)?/) || [], n = r[1], o = r[2];
if (!o)
return at(e, t);
let a;
switch (n) {
case "P":
a = t.dateTime({ width: "short" });
break;
case "PP":
a = t.dateTime({ width: "medium" });
break;
case "PPP":
a = t.dateTime({ width: "long" });
break;
case "PPPP":
default:
a = t.dateTime({ width: "full" });
break;
}
return a.replace("{{date}}", at(n, t)).replace("{{time}}", Wt(o, t));
}, wr = {
p: Wt,
P: br
}, pr = /^D+$/, Mr = /^Y+$/, kr = ["D", "DD", "YY", "YYYY"];
function Dr(e) {
return pr.test(e);
}
function vr(e) {
return Mr.test(e);
}
function Or(e, t, r) {
const n = Wr(e, t, r);
if (console.warn(n), kr.includes(e)) throw new RangeError(n);
}
function Wr(e, t, r) {
const n = e[0] === "Y" ? "years" : "days of the month";
return `Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}
const Sr = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Cr = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Nr = /^'([^]*?)'?$/, xr = /''/g, Tr = /[a-zA-Z]/;
function Yr(e, t, r) {
const n = ge(), o = r?.locale ?? n.locale ?? $e, a = r?.firstWeekContainsDate ?? r?.locale?.options?.firstWeekContainsDate ?? n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, s = r?.weekStartsOn ?? r?.locale?.options?.weekStartsOn ?? n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, i = E(e, r?.in);
if (!xn(i))
throw new RangeError("Invalid time value");
let c = t.match(Cr).map((d) => {
const u = d[0];
if (u === "p" || u === "P") {
const h = wr[u];
return h(d, o.formatLong);
}
return d;
}).join("").match(Sr).map((d) => {
if (d === "''")
return { isToken: !1, value: "'" };
const u = d[0];
if (u === "'")
return { isToken: !1, value: Er(d) };
if (rt[u])
return { isToken: !0, value: d };
if (u.match(Tr))
throw new RangeError(
"Format string contains an unescaped latin alphabet character `" + u + "`"
);
return { isToken: !1, value: d };
});
o.localize.preprocessor && (c = o.localize.preprocessor(i, c));
const f = {
firstWeekContainsDate: a,
weekStartsOn: s,
locale: o
};
return c.map((d) => {
if (!d.isToken) return d.value;
const u = d.value;
(!r?.useAdditionalWeekYearTokens && vr(u) || !r?.useAdditionalDayOfYearTokens && Dr(u)) && Or(u, t, String(e));
const h = rt[u[0]];
return h(i, u, o.localize, f);
}).join("");
}
function Er(e) {
const t = e.match(Nr);
return t ? t[1].replace(xr, "'") : e;
}
function Pr(e, t) {
const r = E(e, t?.in), n = r.getFullYear(), o = r.getMonth(), a = B(r, 0);
return a.setFullYear(n, o + 1, 0), a.setHours(0, 0, 0, 0), a.getDate();
}
function _r(e, t) {
return E(e, t?.in).getMonth();
}
function Fr(e, t) {
return E(e, t?.in).getFullYear();
}
function Br(e, t) {
return +E(e) > +E(t);
}
function Ir(e, t) {
return +E(e) < +E(t);
}
function Ar(e, t, r) {
const [n, o] = ue(
r?.in,
e,
t
);
return n.getFullYear() === o.getFullYear() && n.getMonth() === o.getMonth();
}
function Hr(e, t, r) {
const [n, o] = ue(
r?.in,
e,
t
);
return n.getFullYear() === o.getFullYear();
}
function qr(e, t, r) {
const n = E(e, r?.in), o = n.getFullYear(), a = n.getDate(), s = B(e, 0);
s.setFullYear(o, t, 15), s.setHours(0, 0, 0, 0);
const i = Pr(s);
return n.setMonth(t, Math.min(a, i)), n;
}
function jr(e, t, r) {
const n = E(e, r?.in);
return isNaN(+n) ? B(e, NaN) : (n.setFullYear(t), n);
}
const it = 5, Rr = 4;
function $r(e, t) {
const r = t.startOfMonth(e), n = r.getDay() > 0 ? r.getDay() : 7, o = t.addDays(e, -n + 1), a = t.addDays(o, it * 7 - 1);
return t.getMonth(e) === t.getMonth(a) ? it : Rr;
}
function St(e, t) {
const r = t.startOfMonth(e), n = r.getDay();
return n === 1 ? r : n === 0 ? t.addDays(r, -1 * 6) : t.addDays(r, -1 * (n - 1));
}
function Gr(e, t) {
const r = St(e, t), n = $r(e, t);
return t.addDays(r, n * 7 - 1);
}
class j {
/**
* Creates an instance of `DateLib`.
*
* @param options Configuration options for the date library.
* @param overrides Custom overrides for the date library functions.
*/
constructor(t, r) {
this.Date = Date, this.today = () => this.overrides?.today ? this.overrides.today() : this.options.timeZone ? J.tz(this.options.timeZone) : new this.Date(), this.newDate = (n, o, a) => this.overrides?.newDate ? this.overrides.newDate(n, o, a) : this.options.timeZone ? new J(n, o, a, this.options.timeZone) : new Date(n, o, a), this.addDays = (n, o) => this.overrides?.addDays ? this.overrides.addDays(n, o) : mt(n, o), this.addMonths = (n, o) => this.overrides?.addMonths ? this.overrides.addMonths(n, o) : yt(n, o), this.addWeeks = (n, o) => this.overrides?.addWeeks ? this.overrides.addWeeks(n, o) : On(n, o), this.addYears = (n, o) => this.overrides?.addYears ? this.overrides.addYears(n, o) : Wn(n, o), this.differenceInCalendarDays = (n, o) => this.overrides?.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(n, o) : bt(n, o), this.differenceInCalendarMonths = (n, o) => this.overrides?.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(n, o) : Tn(n, o), this.eachMonthOfInterval = (n) => this.overrides?.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(n) : En(n), this.eachYearOfInterval = (n) => {
const o = this.overrides?.eachYearOfInterval ? this.overrides.eachYearOfInterval(n) : Fn(n), a = new Set(o.map((i) => this.getYear(i)));
if (a.size === o.length)
return o;
const s = [];
return a.forEach((i) => {
s.push(new Date(i, 0, 1));
}), s;
}, this.endOfBroadcastWeek = (n) => this.overrides?.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(n) : Gr(n, this), this.endOfISOWeek = (n) => this.overrides?.endOfISOWeek ? this.overrides.endOfISOWeek(n) : Bn(n), this.endOfMonth = (n) => this.overrides?.endOfMonth ? this.overrides.endOfMonth(n) : Yn(n), this.endOfWeek = (n, o) => this.overrides?.endOfWeek ? this.overrides.endOfWeek(n, o) : kt(n, this.options), this.endOfYear = (n) => this.overrides?.endOfYear ? this.overrides.endOfYear(n) : _n(n), this.format = (n, o, a) => {
const s = this.overrides?.format ? this.overrides.format(n, o, this.options) : Yr(n, o, this.options);
return this.options.numerals && this.options.numerals !== "latn" ? this.replaceDigits(s) : s;
}, this.getISOWeek = (n) => this.overrides?.getISOWeek ? this.overrides.getISOWeek(n) : Dt(n), this.getMonth = (n, o) => this.overrides?.getMonth ? this.overrides.getMonth(n, this.options) : _r(n, this.options), this.getYear = (n, o) => this.overrides?.getYear ? this.overrides.getYear(n, this.options) : Fr(n, this.options), this.getWeek = (n, o) => this.overrides?.getWeek ? this.overrides.getWeek(n, this.options) : Ot(n, this.options), this.isAfter = (n, o) => this.overrides?.isAfter ? this.overrides.isAfter(n, o) : Br(n, o), this.isBefore = (n, o) => this.overrides?.isBefore ? this.overrides.isBefore(n, o) : Ir(n, o), this.isDate = (n) => this.overrides?.isDate ? this.overrides.isDate(n) : wt(n), this.isSameDay = (n, o) => this.overrides?.isSameDay ? this.overrides.isSameDay(n, o) : Nn(n, o), this.isSameMonth = (n, o) => this.overrides?.isSameMonth ? this.overrides.isSameMonth(n, o) : Ar(n, o), this.isSameYear = (n, o) => this.overrides?.isSameYear ? this.overrides.isSameYear(n, o) : Hr(n, o), this.max = (n) => this.overrides?.max ? this.overrides.max(n) : Sn(n), this.min = (n) => this.overrides?.min ? this.overrides.min(n) : Cn(n), this.setMonth = (n, o) => this.overrides?.setMonth ? this.overrides.setMonth(n, o) : qr(n, o), this.setYear = (n, o) => this.overrides?.setYear ? this.overrides.setYear(n, o) : jr(n, o), this.startOfBroadcastWeek = (n, o) => this.overrides?.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(n, this) : St(n, this), this.startOfDay = (n) => this.overrides?.startOfDay ? this.overrides.startOfDay(n) : ye(n), this.startOfISOWeek = (n) => this.overrides?.startOfISOWeek ? this.overrides.startOfISOWeek(n) : me(n), this.startOfMonth = (n) => this.overrides?.startOfMonth ? this.overrides.startOfMonth(n) : Pn(n), this.startOfWeek = (n, o) => this.overrides?.startOfWeek ? this.overrides.startOfWeek(n, this.options) : ce(n, this.options), this.startOfYear = (n) => this.overrides?.startOfYear ? this.overrides.startOfYear(n) : Mt(n), this.options = { locale: $e, ...t }, this.overrides = r;
}
/**
* Generates a mapping of Arabic digits (0-9) to the target numbering system
* digits.
*
* @since 9.5.0
* @returns A record mapping Arabic digits to the target numerals.
*/
getDigitMap() {
const { numerals: t = "latn" } = this.options, r = new Intl.NumberFormat("en-US", {
numberingSystem: t
}), n = {};
for (let o = 0; o < 10; o++)
n[o.toString()] = r.format(o);
return n;
}
/**
* Replaces Arabic digits in a string with the target numbering system digits.
*
* @since 9.5.0
* @param input The string containing Arabic digits.
* @returns The string with digits replaced.
*/
replaceDigits(t) {
const r = this.getDigitMap();
return t.replace(/\d/g, (n) => r[n] || n);
}
/**
* Formats a number using the configured numbering system.
*
* @since 9.5.0
* @param value The number to format.
* @returns The formatted number as a string.
*/
formatNumber(t) {
return this.replaceDigits(t.toString());
}
/**
* Returns the preferred ordering for month and year labels for the current
* locale.
*/
getMonthYearOrder() {
const t = this.options.locale?.code;
return t && j.yearFirstLocales.has(t) ? "year-first" : "month-first";
}
/**
* Formats the month/year pair respecting locale conventions.
*
* @since 9.11.0
*/
formatMonthYear(t) {
const { locale: r, timeZone: n, numerals: o } = this.options, a = r?.code;
if (a && j.yearFirstLocales.has(a))
try {
return new Intl.DateTimeFormat(a, {
month: "long",
year: "numeric",
timeZone: n,
numberingSystem: o
}).format(t);
} catch {
}
const s = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y";
return this.format(t, s);
}
}
j.yearFirstLocales = /* @__PURE__ */ new Set([
"eu",
"hu",
"ja",
"ja-Hira",
"ja-JP",
"ko",
"ko-KR",
"lt",
"lt-LT",
"lv",
"lv-LV",
"mn",
"mn-MN",
"zh",
"zh-CN",
"zh-HK",
"zh-TW"
]);
const V = new j();
class Ct {
constructor(t, r, n = V) {
this.date = t, this.displayMonth = r, this.outside = !!(r && !n.isSameMonth(t, r)), this.dateLib = n, this.isoDate = n.format(t, "yyyy-MM-dd"), this.displayMonthId = n.format(r, "yyyy-MM"), this.dateMonthId = n.format(t, "yyyy-MM");
}
/**
* Checks if this day is equal to another `CalendarDay`, considering both the
* date and the displayed month.
*
* @param day The `CalendarDay` to compare with.
* @returns `true` if the days are equal, otherwise `false`.
*/
isEqualTo(t) {
return this.dateLib.isSameDay(t.date, this.date) && this.dateLib.isSameMonth(t.displayMonth, this.displayMonth);
}
}
class zr {
constructor(t, r) {
this.date = t, this.weeks = r;
}
}
class Qr {
constructor(t, r) {
this.days = r, this.weekNumber = t;
}
}
function Xr(e) {
return l.createElement("button", { ...e });
}
function Zr(e) {
return l.createElement("span", { ...e });
}
function Ur(