impact-nova 1.7.33 → 1.7.36

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.
@@ -1,193 +1,194 @@
1
1
  import { jsxs as Y, jsx as c } from "react/jsx-runtime";
2
- import * as d from "react";
3
- import { ChevronLeftIcon as ye, ChevronRightIcon as Ne } from "lucide-react";
4
- import { getDefaultClassNames as Be, DayPicker as Fe } from "react-day-picker";
5
- import { cn as u } from "../../lib/utils.js";
6
- import { Button as I } from "./button.js";
2
+ import * as u from "react";
3
+ import { ChevronLeftIcon as Ne, ChevronRightIcon as Se } from "lucide-react";
4
+ import { getDefaultClassNames as Te, DayPicker as We } from "react-day-picker";
5
+ import { cn as d } from "../../lib/utils.js";
6
+ import { Button as R } from "./button.js";
7
7
  import "./button-variants.js";
8
- import ue from "./select/select.js";
9
- import { FISCAL_PATTERNS as Ke, resolveWeekSelection as We } from "../../lib/fiscal-calendar.js";
10
- import { getIntlLocale as qe, getDateFnsLocale as Ge } from "../../i18n/getDateFnsLocale.js";
11
- import { useImpactNovaI18n as Je } from "../../i18n/ImpactNovaI18nContext.js";
12
- const de = d.createContext(0);
13
- function ot({
14
- className: le,
15
- classNames: J,
8
+ import de from "./select/select.js";
9
+ import { FISCAL_PATTERNS as qe, resolveWeekSelection as Ge } from "../../lib/fiscal-calendar.js";
10
+ import { getIntlLocale as Je, getDateFnsLocale as Qe } from "../../i18n/getDateFnsLocale.js";
11
+ import { useImpactNovaI18n as Xe } from "../../i18n/ImpactNovaI18nContext.js";
12
+ const me = u.createContext(0);
13
+ function ct({
14
+ className: oe,
15
+ classNames: Q,
16
16
  showOutsideDays: y = !1,
17
- captionLayout: Q = "dropdown",
18
- buttonVariant: B = "ghost",
19
- formatters: X,
17
+ captionLayout: X = "dropdown",
18
+ buttonVariant: T = "ghost",
19
+ formatters: Z,
20
20
  components: Ce,
21
- showFooter: b = !0,
22
- onApply: Z,
23
- onCancel: me,
24
- onClear: ge,
25
- mode: F = "single",
26
- selected: D,
21
+ showFooter: x = !0,
22
+ disableApply: _e = !1,
23
+ onApply: V,
24
+ onCancel: ge,
25
+ onClear: he,
26
+ mode: W = "single",
27
+ selected: p,
27
28
  onSelect: U,
28
29
  // Week picker props
29
30
  pickerType: m = "date",
30
- weekMode: p = "single",
31
- selectedWeeks: C,
32
- onWeekSelect: k,
31
+ weekMode: v = "single",
32
+ selectedWeeks: S,
33
+ onWeekSelect: M,
33
34
  calendarType: P = "calendar",
34
- fiscalMode: V = "basic",
35
- selectionMode: oe = "week",
35
+ fiscalMode: ee = "basic",
36
+ selectionMode: le = "week",
36
37
  fiscalMonthPattern: ie,
37
- fiscalYearStartMonth: he = 1,
38
- weekStartsOn: K = 1,
38
+ fiscalYearStartMonth: xe = 1,
39
+ weekStartsOn: q = 1,
39
40
  // Default Monday
40
41
  // Month picker props
41
42
  monthMode: w = "single",
42
43
  selectedMonths: N,
43
44
  onMonthSelect: _,
44
- month: T,
45
- defaultMonth: xe,
46
- onMonthChange: Se,
47
- startMonth: _e,
48
- endMonth: Ye,
49
- ...ee
45
+ month: B,
46
+ defaultMonth: be,
47
+ onMonthChange: Ae,
48
+ startMonth: Ye,
49
+ endMonth: Me,
50
+ ...K
50
51
  }) {
51
- const { locale: te, t: x } = Je(), W = d.useMemo(() => qe(te), [te]), ke = d.useMemo(() => Ge(te), [te]), be = d.useMemo(
52
+ const { locale: te, t: b } = Xe(), G = u.useMemo(() => Je(te), [te]), ke = u.useMemo(() => Qe(te), [te]), De = u.useMemo(
52
53
  () => Array.from(
53
54
  { length: 12 },
54
- (e, n) => new Date(2024, n, 1).toLocaleString(W, { month: "long" })
55
+ (e, r) => new Date(2024, r, 1).toLocaleString(G, { month: "long" })
55
56
  ),
56
- [W]
57
- ), Ae = d.useMemo(
57
+ [G]
58
+ ), je = u.useMemo(
58
59
  () => Array.from(
59
60
  { length: 12 },
60
- (e, n) => new Date(2024, n, 1).toLocaleString(W, { month: "short" })
61
+ (e, r) => new Date(2024, r, 1).toLocaleString(G, { month: "short" })
61
62
  ),
62
- [W]
63
- ), ne = d.useMemo(() => {
63
+ [G]
64
+ ), ne = u.useMemo(() => {
64
65
  if (P === "fiscal") {
65
66
  if (ie) return ie;
66
- if (V === "advanced") return Ke["4-4-5"];
67
+ if (ee === "advanced") return qe["4-4-5"];
67
68
  }
68
- }, [P, V, ie]), v = Be(), Me = d.useMemo(() => new Date(1900, 0, 1), []), je = d.useMemo(() => new Date(2100, 11, 31), []), R = _e || Me, L = Ye || je, [q, re] = d.useState(D), [A, ve] = d.useState(() => {
69
- if (T) return T;
70
- if (xe) return xe;
71
- if (D) {
72
- if (Array.isArray(D))
73
- return D[0] || /* @__PURE__ */ new Date();
74
- if (D instanceof Date)
75
- return D;
76
- if ("from" in D && D.from)
77
- return D.from;
69
+ }, [P, ee, ie]), D = Te(), ze = u.useMemo(() => new Date(1900, 0, 1), []), Ee = u.useMemo(() => new Date(2100, 11, 31), []), O = Ye || ze, L = Me || Ee, [H, re] = u.useState(p), [k, ve] = u.useState(() => {
70
+ if (B) return B;
71
+ if (be) return be;
72
+ if (p) {
73
+ if (Array.isArray(p))
74
+ return p[0] || /* @__PURE__ */ new Date();
75
+ if (p instanceof Date)
76
+ return p;
77
+ if ("from" in p && p.from)
78
+ return p.from;
78
79
  }
79
80
  return /* @__PURE__ */ new Date();
80
81
  });
81
- d.useEffect(() => {
82
- T && (ve(T), pe(T.getFullYear()));
83
- }, [T]);
84
- const [$, ae] = d.useState(C), [M, se] = d.useState(N), [ze, pe] = d.useState(A.getFullYear());
85
- d.useEffect(() => {
86
- re(D), ae(C), se(N);
87
- }, [D, C, N]);
88
- const O = (e) => {
89
- ve(e), pe(e.getFullYear()), Se?.(e);
90
- }, ce = d.useCallback((e) => {
91
- let n;
92
- return e instanceof Date ? n = e : n = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), We(n, {
82
+ u.useEffect(() => {
83
+ B && (ve(B), pe(B.getFullYear()));
84
+ }, [B]);
85
+ const [j, ae] = u.useState(S), [A, se] = u.useState(N), [Ie, pe] = u.useState(k.getFullYear());
86
+ u.useEffect(() => {
87
+ re(p), ae(S), se(N);
88
+ }, [p, S, N]);
89
+ const $ = (e) => {
90
+ ve(e), pe(e.getFullYear()), Ae?.(e);
91
+ }, ce = u.useCallback((e) => {
92
+ let r;
93
+ return e instanceof Date ? r = e : r = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), Ge(r, {
93
94
  calendarType: P,
94
- fiscalMode: V,
95
- selectionMode: oe,
95
+ fiscalMode: ee,
96
+ selectionMode: le,
96
97
  fiscalMonthPattern: ne,
97
- fiscalYearStartMonth: he,
98
- weekStartsOn: K
98
+ fiscalYearStartMonth: xe,
99
+ weekStartsOn: q
99
100
  });
100
- }, [P, V, oe, ne, he, K]), fe = d.useCallback((e) => {
101
- const n = (t, a) => t.year === a.year && t.month === a.month && t.weekOfMonth === a.weekOfMonth;
102
- if (b)
101
+ }, [P, ee, le, ne, xe, q]), fe = u.useCallback((e) => {
102
+ const r = (t, s) => t.year === s.year && t.month === s.month && t.weekOfMonth === s.weekOfMonth;
103
+ if (x)
103
104
  ae((t) => {
104
- let a;
105
- if (p === "single")
106
- a = e;
107
- else if (p === "multiple") {
108
- const r = t || [];
109
- a = r.some((l) => n(l, e)) ? r.filter((l) => !n(l, e)) : [...r, e];
110
- } else if (p === "range") {
111
- const r = t;
112
- if (!r?.from || r.to)
113
- a = { from: e };
105
+ let s;
106
+ if (v === "single")
107
+ s = e;
108
+ else if (v === "multiple") {
109
+ const n = t || [];
110
+ s = n.some((o) => r(o, e)) ? n.filter((o) => !r(o, e)) : [...n, e];
111
+ } else if (v === "range") {
112
+ const n = t;
113
+ if (!n?.from || n.to)
114
+ s = { from: e };
114
115
  else {
115
- const s = { from: r.from, to: e };
116
- e.startDate < r.from.startDate && (s.from = e, s.to = r.from), a = s;
116
+ const a = { from: n.from, to: e };
117
+ e.startDate < n.from.startDate && (a.from = e, a.to = n.from), s = a;
117
118
  }
118
119
  }
119
- return k?.(a), a;
120
+ return M?.(s), s;
120
121
  });
121
- else if (p === "single")
122
- k?.(e);
123
- else if (p === "multiple") {
124
- const t = C || [], r = t.some((s) => n(s, e)) ? t.filter((s) => !n(s, e)) : [...t, e];
125
- k?.(r.length > 0 ? r : void 0);
126
- } else if (p === "range") {
127
- const t = C;
122
+ else if (v === "single")
123
+ M?.(e);
124
+ else if (v === "multiple") {
125
+ const t = S || [], n = t.some((a) => r(a, e)) ? t.filter((a) => !r(a, e)) : [...t, e];
126
+ M?.(n.length > 0 ? n : void 0);
127
+ } else if (v === "range") {
128
+ const t = S;
128
129
  if (!t?.from || t.to)
129
- k?.({ from: e });
130
+ M?.({ from: e });
130
131
  else {
131
- const a = { from: t.from, to: e };
132
- e.startDate < t.from.startDate && (a.from = e, a.to = t.from), k?.(a);
132
+ const s = { from: t.from, to: e };
133
+ e.startDate < t.from.startDate && (s.from = e, s.to = t.from), M?.(s);
133
134
  }
134
135
  }
135
- }, [p, b, C, k]), Ee = d.useCallback((e, n) => {
136
- const t = { year: e, month: n }, a = (r, s) => r.year === s.year && r.month === s.month;
137
- if (b)
138
- se((r) => {
139
- let s;
136
+ }, [v, x, S, M]), Re = u.useCallback((e, r) => {
137
+ const t = { year: e, month: r }, s = (n, a) => n.year === a.year && n.month === a.month;
138
+ if (x)
139
+ se((n) => {
140
+ let a;
140
141
  if (w === "single")
141
- s = t;
142
+ a = t;
142
143
  else if (w === "multiple") {
143
- const l = r || [];
144
- s = l.some((f) => a(f, t)) ? l.filter((f) => !a(f, t)) : [...l, t];
144
+ const o = n || [];
145
+ a = o.some((f) => s(f, t)) ? o.filter((f) => !s(f, t)) : [...o, t];
145
146
  } else if (w === "range") {
146
- const l = r;
147
- if (!l?.from || l.to)
148
- s = { from: t };
147
+ const o = n;
148
+ if (!o?.from || o.to)
149
+ a = { from: t };
149
150
  else {
150
- const o = new Date(l.from.year, l.from.month, 1);
151
- new Date(t.year, t.month, 1) < o ? s = { from: t, to: l.from } : s = { from: l.from, to: t };
151
+ const l = new Date(o.from.year, o.from.month, 1);
152
+ new Date(t.year, t.month, 1) < l ? a = { from: t, to: o.from } : a = { from: o.from, to: t };
152
153
  }
153
154
  }
154
- return _?.(s), s;
155
+ return _?.(a), a;
155
156
  });
156
157
  else if (w === "single")
157
158
  _?.(t);
158
159
  else if (w === "multiple") {
159
- const r = N || [], l = r.some((o) => a(o, t)) ? r.filter((o) => !a(o, t)) : [...r, t];
160
- _?.(l.length > 0 ? l : void 0);
160
+ const n = N || [], o = n.some((l) => s(l, t)) ? n.filter((l) => !s(l, t)) : [...n, t];
161
+ _?.(o.length > 0 ? o : void 0);
161
162
  } else if (w === "range") {
162
- const r = N;
163
- if (!r?.from || r.to)
163
+ const n = N;
164
+ if (!n?.from || n.to)
164
165
  _?.({ from: t });
165
166
  else {
166
- const s = new Date(r.from.year, r.from.month, 1);
167
- new Date(t.year, t.month, 1) < s ? _?.({ from: t, to: r.from }) : _?.({ from: r.from, to: t });
167
+ const a = new Date(n.from.year, n.from.month, 1);
168
+ new Date(t.year, t.month, 1) < a ? _?.({ from: t, to: n.from }) : _?.({ from: n.from, to: t });
168
169
  }
169
170
  }
170
- }, [w, b, N, _]), De = d.useCallback(() => {
171
- const e = R.getFullYear(), n = L.getFullYear(), t = [];
172
- for (let a = e; a <= n; a++)
173
- t.push({ label: a.toString(), value: a.toString() });
171
+ }, [w, x, N, _]), we = u.useCallback(() => {
172
+ const e = O.getFullYear(), r = L.getFullYear(), t = [];
173
+ for (let s = e; s <= r; s++)
174
+ t.push({ label: s.toString(), value: s.toString() });
174
175
  return t;
175
- }, [R, L]), Ie = d.useCallback((e) => be.map((t, a) => ({
176
+ }, [O, L]), Pe = u.useCallback((e) => De.map((t, s) => ({
176
177
  label: t,
177
- value: a.toString()
178
- })).filter((t, a) => {
179
- const r = new Date(e, a, 1);
180
- return !(R && r < new Date(R.getFullYear(), R.getMonth(), 1) || L && r > new Date(L.getFullYear(), L.getMonth(), 1));
181
- }), [R, L, be]), G = d.useMemo(() => {
178
+ value: s.toString()
179
+ })).filter((t, s) => {
180
+ const n = new Date(e, s, 1);
181
+ return !(O && n < new Date(O.getFullYear(), O.getMonth(), 1) || L && n > new Date(L.getFullYear(), L.getMonth(), 1));
182
+ }), [O, L, De]), J = u.useMemo(() => {
182
183
  if (m !== "week") return;
183
- const e = b ? $ : C;
184
+ const e = x ? j : S;
184
185
  if (!e) return;
185
- const n = [], t = (a) => {
186
- let r = new Date(a.startDate);
187
- r.setHours(0, 0, 0, 0);
188
- const s = new Date(a.endDate);
189
- for (s.setHours(0, 0, 0, 0); r <= s; )
190
- n.push(new Date(r)), r.setDate(r.getDate() + 1);
186
+ const r = [], t = (s) => {
187
+ let n = new Date(s.startDate);
188
+ n.setHours(0, 0, 0, 0);
189
+ const a = new Date(s.endDate);
190
+ for (a.setHours(0, 0, 0, 0); n <= a; )
191
+ r.push(new Date(n)), n.setDate(n.getDate() + 1);
191
192
  };
192
193
  if (Array.isArray(e))
193
194
  e.forEach(t);
@@ -196,168 +197,221 @@ function ot({
196
197
  if (!e.to)
197
198
  t(e.from);
198
199
  else {
199
- let a = new Date(e.from.startDate);
200
- a.setHours(0, 0, 0, 0);
201
- const r = new Date(e.to.endDate);
202
- for (r.setHours(0, 0, 0, 0); a <= r; )
203
- n.push(new Date(a)), a.setDate(a.getDate() + 1);
200
+ let s = new Date(e.from.startDate);
201
+ s.setHours(0, 0, 0, 0);
202
+ const n = new Date(e.to.endDate);
203
+ for (n.setHours(0, 0, 0, 0); s <= n; )
204
+ r.push(new Date(s)), s.setDate(s.getDate() + 1);
204
205
  }
205
206
  } else
206
207
  t(e);
207
- return n;
208
- }, [m, b, $, C]), Pe = d.useMemo(() => {
209
- if (m !== "week" || !G || G.length === 0)
208
+ return r;
209
+ }, [m, x, j, S]), Oe = u.useMemo(() => {
210
+ if (m !== "week" || !J || J.length === 0)
210
211
  return { range_start: [], range_middle: [], range_end: [] };
211
- const e = [...G].sort((i, g) => i.getTime() - g.getTime()), n = [], t = [], a = [], r = b ? $ : C, s = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
212
- p === "multiple" && Array.isArray(r) && r.forEach((i) => {
212
+ const e = [...J].sort((i, g) => i.getTime() - g.getTime()), r = [], t = [], s = [], n = x ? j : S, a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
213
+ v === "multiple" && Array.isArray(n) && n.forEach((i) => {
213
214
  const g = i.startDate.toISOString().split("T")[0], h = i.endDate.toISOString().split("T")[0];
214
- s.add(g), l.add(h);
215
+ a.add(g), o.add(h);
215
216
  });
216
- const o = (i, g) => {
217
+ const l = (i, g) => {
217
218
  if (g === 0) return !1;
218
219
  const h = e[g - 1];
219
220
  return i.getTime() - h.getTime() <= 1440 * 60 * 1e3;
220
221
  }, f = (i, g) => g === e.length - 1 ? !1 : e[g + 1].getTime() - i.getTime() <= 1440 * 60 * 1e3;
221
222
  return e.forEach((i, g) => {
222
- const h = i.toISOString().split("T")[0], j = s.has(h), S = l.has(h), z = o(i, g), E = f(i, g);
223
- p === "multiple" ? j ? n.push(i) : S ? a.push(i) : t.push(i) : !z && !E ? (n.push(i), a.push(i)) : z ? E ? t.push(i) : a.push(i) : n.push(i);
223
+ const h = i.toISOString().split("T")[0], z = a.has(h), C = o.has(h), E = l(i, g), I = f(i, g);
224
+ v === "multiple" ? z ? r.push(i) : C ? s.push(i) : t.push(i) : !E && !I ? (r.push(i), s.push(i)) : E ? I ? t.push(i) : s.push(i) : r.push(i);
224
225
  }), {
225
- range_start: n,
226
+ range_start: r,
226
227
  range_middle: t,
227
- range_end: a
228
+ range_end: s
228
229
  };
229
- }, [m, G, p, b, $, C]), Re = d.useCallback((e) => {
230
+ }, [m, J, v, x, j, S]), Le = u.useCallback((e) => {
230
231
  if (m === "week" && e) {
231
- const n = Array.isArray(e) ? e[e.length - 1] : e instanceof Date ? e : void 0;
232
- if (n) {
233
- const t = ce(n);
232
+ const r = Array.isArray(e) ? e[e.length - 1] : e instanceof Date ? e : void 0;
233
+ if (r) {
234
+ const t = ce(r);
234
235
  fe(t);
235
236
  return;
236
237
  }
237
238
  }
238
- b && re(e), U?.(e);
239
- }, [b, U, m, ce, fe]), Le = d.useCallback(() => {
240
- m === "week" ? (k?.($), Z?.($)) : m === "month" ? (_?.(M), Z?.(M)) : (U?.(q), Z?.(q));
241
- }, [q, $, M, U, k, _, Z, m]), $e = d.useCallback(() => {
242
- m === "week" ? ae(C) : m === "month" ? se(N) : re(D), me?.();
243
- }, [D, C, N, me, m]), Oe = d.useCallback(() => {
244
- m === "week" ? (ae(void 0), b || k?.(void 0)) : m === "month" ? (se(void 0), b || _?.(void 0)) : (re(void 0), b || U?.(void 0)), ge?.();
245
- }, [b, U, k, _, ge, m]), Ue = d.useCallback((e, n) => {
246
- const t = b ? M : N;
239
+ x && re(e), U?.(e);
240
+ }, [x, U, m, ce, fe]), $e = u.useCallback(() => {
241
+ m === "week" ? (M?.(j), V?.(j)) : m === "month" ? (_?.(A), V?.(A)) : (U?.(H), V?.(H));
242
+ }, [H, j, A, U, M, _, V, m]), Ue = u.useCallback(() => {
243
+ m === "week" ? ae(S) : m === "month" ? se(N) : re(p), ge?.();
244
+ }, [p, S, N, ge, m]), He = u.useCallback(() => {
245
+ m === "week" ? (ae(void 0), x || M?.(void 0)) : m === "month" ? (se(void 0), x || _?.(void 0)) : (re(void 0), x || U?.(void 0)), he?.();
246
+ }, [x, U, M, _, he, m]), Fe = u.useCallback((e, r) => {
247
+ const t = x ? A : N;
247
248
  if (!t) return !1;
248
249
  if (Array.isArray(t))
249
- return t.some((a) => a.year === e && a.month === n);
250
+ return t.some((s) => s.year === e && s.month === r);
250
251
  if ("from" in t) {
251
- const a = t, r = a.from, s = a.to;
252
- if (!r && !s) return !1;
253
- const l = new Date(e, n, 1).getTime();
254
- if (!r) return s ? l === new Date(s.year, s.month, 1).getTime() : !1;
255
- const o = new Date(r.year, r.month, 1).getTime();
256
- if (!s) return l === o;
257
- const f = new Date(s.year, s.month, 1).getTime();
258
- return l >= o && l <= f;
252
+ const s = t, n = s.from, a = s.to;
253
+ if (!n && !a) return !1;
254
+ const o = new Date(e, r, 1).getTime();
255
+ if (!n) return a ? o === new Date(a.year, a.month, 1).getTime() : !1;
256
+ const l = new Date(n.year, n.month, 1).getTime();
257
+ if (!a) return o === l;
258
+ const f = new Date(a.year, a.month, 1).getTime();
259
+ return o >= l && o <= f;
259
260
  } else {
260
- const a = t;
261
- return a.year === e && a.month === n;
261
+ const s = t;
262
+ return s.year === e && s.month === r;
262
263
  }
263
- }, [b, M, N]), He = d.useCallback((e, n) => {
264
- const t = b ? M : N;
264
+ }, [x, A, N]), Be = u.useCallback((e, r) => {
265
+ const t = x ? A : N;
265
266
  if (!t || !("from" in t)) return { isStart: !1, isEnd: !1, isMiddle: !1 };
266
- const a = t, r = a.from, s = a.to;
267
- if (!r && !s) return { isStart: !1, isEnd: !1, isMiddle: !1 };
268
- const l = new Date(e, n, 1).getTime();
269
- if (!r) return { isStart: !1, isEnd: s ? l === new Date(s.year, s.month, 1).getTime() : !1, isMiddle: !1 };
270
- const o = new Date(r.year, r.month, 1).getTime();
271
- if (!s) return { isStart: l === o, isEnd: !1, isMiddle: !1 };
272
- const f = new Date(s.year, s.month, 1).getTime();
267
+ const s = t, n = s.from, a = s.to;
268
+ if (!n && !a) return { isStart: !1, isEnd: !1, isMiddle: !1 };
269
+ const o = new Date(e, r, 1).getTime();
270
+ if (!n) return { isStart: !1, isEnd: a ? o === new Date(a.year, a.month, 1).getTime() : !1, isMiddle: !1 };
271
+ const l = new Date(n.year, n.month, 1).getTime();
272
+ if (!a) return { isStart: o === l, isEnd: !1, isMiddle: !1 };
273
+ const f = new Date(a.year, a.month, 1).getTime();
273
274
  return {
274
- isStart: l === o,
275
- isEnd: l === f,
276
- isMiddle: l > o && l < f
275
+ isStart: o === l,
276
+ isEnd: o === f,
277
+ isMiddle: o > l && o < f
277
278
  };
278
- }, [b, M, N]), Te = d.useCallback((e, n) => {
279
- const t = ee.disabled;
279
+ }, [x, A, N]), ue = u.useCallback((e, r) => {
280
+ const t = K.disabled;
280
281
  if (!t) return !1;
281
- const a = new Date(e, n, 1, 0, 0, 0, 0), r = new Date(e, n + 1, 0, 23, 59, 59, 999);
282
+ const s = new Date(e, r, 1, 0, 0, 0, 0), n = new Date(e, r + 1, 0, 23, 59, 59, 999);
282
283
  if (t.before) {
283
- const s = new Date(t.before);
284
- if (s.setHours(0, 0, 0, 0), r < s) return !0;
284
+ const a = new Date(t.before);
285
+ if (a.setHours(0, 0, 0, 0), n < a) return !0;
285
286
  }
286
287
  if (t.after) {
287
- const s = new Date(t.after);
288
- if (s.setHours(23, 59, 59, 999), a > s) return !0;
288
+ const a = new Date(t.after);
289
+ if (a.setHours(23, 59, 59, 999), s > a) return !0;
290
+ }
291
+ return !1;
292
+ }, [K.disabled]), Ke = u.useMemo(() => {
293
+ if (!x) return !1;
294
+ const e = K.disabled;
295
+ if (!e) return !1;
296
+ const r = e.before, t = e.after, s = (n) => {
297
+ const a = new Date(n.getFullYear(), n.getMonth(), n.getDate());
298
+ if (r) {
299
+ const o = new Date(r.getFullYear(), r.getMonth(), r.getDate());
300
+ if (a < o) return !0;
301
+ }
302
+ if (t) {
303
+ const o = new Date(t.getFullYear(), t.getMonth(), t.getDate());
304
+ if (a > o) return !0;
305
+ }
306
+ return !1;
307
+ };
308
+ if (m === "month") {
309
+ const n = A;
310
+ if (!n) return !1;
311
+ const a = (o) => ue(o.year, o.month);
312
+ if (Array.isArray(n))
313
+ return n.some(a);
314
+ if ("from" in n) {
315
+ const o = n;
316
+ return !!(o.from && a(o.from) || o.to && a(o.to));
317
+ } else
318
+ return a(n);
319
+ }
320
+ if (m === "week") {
321
+ const n = j;
322
+ if (!n) return !1;
323
+ const a = (o) => s(o.startDate) || s(o.endDate);
324
+ if (Array.isArray(n))
325
+ return n.some(a);
326
+ if ("from" in n) {
327
+ const o = n;
328
+ return !!(o.from && a(o.from) || o.to && a(o.to));
329
+ } else
330
+ return a(n);
331
+ }
332
+ if (m === "date") {
333
+ const n = H;
334
+ if (!n) return !1;
335
+ if (Array.isArray(n))
336
+ return n.some(s);
337
+ if (n instanceof Date)
338
+ return s(n);
339
+ if ("from" in n) {
340
+ const a = n;
341
+ return !!(a.from && s(a.from) || a.to && s(a.to));
342
+ }
289
343
  }
290
344
  return !1;
291
- }, [ee.disabled]), we = ({ yearOffset: e = 0 }) => {
292
- const n = ze + e;
345
+ }, [m, x, K.disabled, H, j, A, ue]), ye = ({ yearOffset: e = 0 }) => {
346
+ const r = Ie + e;
293
347
  return /* @__PURE__ */ Y("div", { className: "flex flex-col gap-4 p-3 min-w-[280px]", children: [
294
348
  /* @__PURE__ */ Y("div", { className: "flex items-center justify-between", children: [
295
349
  e === 0 && /* @__PURE__ */ c(
296
- I,
350
+ R,
297
351
  {
298
352
  variant: "ghost",
299
353
  size: "icon",
300
354
  className: "h-7 w-7",
301
- "aria-label": x("calendar.previousYear"),
302
- title: x("calendar.previousYear"),
303
- disabled: n <= R.getFullYear(),
304
- onClick: () => O(new Date(n - 1, A.getMonth(), 1)),
305
- children: /* @__PURE__ */ c(ye, { className: "h-4 w-4" })
355
+ "aria-label": b("calendar.previousYear"),
356
+ title: b("calendar.previousYear"),
357
+ disabled: r <= O.getFullYear(),
358
+ onClick: () => $(new Date(r - 1, k.getMonth(), 1)),
359
+ children: /* @__PURE__ */ c(Ne, { className: "h-4 w-4" })
306
360
  }
307
361
  ),
308
362
  /* @__PURE__ */ c("div", { className: "flex-1 flex justify-center items-center", children: /* @__PURE__ */ c(
309
- ue,
363
+ de,
310
364
  {
311
- value: { label: n.toString(), value: n.toString() },
365
+ value: { label: r.toString(), value: r.toString() },
312
366
  onChange: (t) => {
313
367
  if (t && "value" in t) {
314
- const a = parseInt(t.value) - e;
315
- O(new Date(a, A.getMonth(), 1));
368
+ const s = parseInt(t.value) - e;
369
+ $(new Date(s, k.getMonth(), 1));
316
370
  }
317
371
  },
318
372
  scrollToSelectedOnOpen: !0,
319
- options: De(),
373
+ options: we(),
320
374
  parentClassName: "flex justify-center items-center",
321
375
  className: "w-[200px]",
322
376
  menuWidth: "140px"
323
377
  }
324
378
  ) }),
325
379
  (w === "single" || e === 1) && /* @__PURE__ */ c(
326
- I,
380
+ R,
327
381
  {
328
382
  variant: "ghost",
329
383
  size: "icon",
330
384
  className: "h-7 w-7",
331
- "aria-label": x("calendar.nextYear"),
332
- title: x("calendar.nextYear"),
333
- disabled: n >= L.getFullYear(),
334
- onClick: () => O(new Date(n + 1, A.getMonth(), 1)),
335
- children: /* @__PURE__ */ c(Ne, { className: "h-4 w-4" })
385
+ "aria-label": b("calendar.nextYear"),
386
+ title: b("calendar.nextYear"),
387
+ disabled: r >= L.getFullYear(),
388
+ onClick: () => $(new Date(r + 1, k.getMonth(), 1)),
389
+ children: /* @__PURE__ */ c(Se, { className: "h-4 w-4" })
336
390
  }
337
391
  )
338
392
  ] }),
339
- /* @__PURE__ */ c("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: Ae.map((t, a) => {
340
- const r = Ue(n, a), { isStart: s, isEnd: l, isMiddle: o } = He(n, a), f = w === "range", i = b ? M : N, g = i && "to" in i && !!i.to, h = Te(n, a);
393
+ /* @__PURE__ */ c("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: je.map((t, s) => {
394
+ const n = Fe(r, s), { isStart: a, isEnd: o, isMiddle: l } = Be(r, s), f = w === "range", i = x ? A : N, g = i && "to" in i && !!i.to, h = ue(r, s);
341
395
  return /* @__PURE__ */ Y("div", { className: "relative flex items-center justify-center h-10 w-full group", children: [
342
- f && g && (o || s || l) && !h && /* @__PURE__ */ c("div", { className: u(
396
+ f && g && (l || a || o) && !h && /* @__PURE__ */ c("div", { className: d(
343
397
  "absolute inset-y-0 inset-x-0 bg-accent",
344
- s && "rounded-l-full left-1/2 -ml-5",
345
- l && "rounded-r-full right-1/2 -mr-5",
346
- o && "inset-x-0",
347
- s && l && "rounded-full inset-x-2"
398
+ a && "rounded-l-full left-1/2 -ml-5",
399
+ o && "rounded-r-full right-1/2 -mr-5",
400
+ l && "inset-x-0",
401
+ a && o && "rounded-full inset-x-2"
348
402
  ) }),
349
403
  /* @__PURE__ */ c(
350
- I,
404
+ R,
351
405
  {
352
406
  variant: "ghost",
353
- onClick: () => Ee(n, a),
407
+ onClick: () => Re(r, s),
354
408
  disabled: h,
355
- className: u(
409
+ className: d(
356
410
  "relative z-10 w-10 h-10 p-0 text-sm font-normal rounded-lg transition-all",
357
- r && !f && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground",
358
- f && (s || l) && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground rounded-lg",
359
- !r && !h && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-brand",
360
- o && !h && "text-accent-foreground",
411
+ n && !f && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground",
412
+ f && (a || o) && !h && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground rounded-lg",
413
+ !n && !h && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-brand",
414
+ l && !h && "text-accent-foreground",
361
415
  h && "text-content-muted opacity-50 cursor-not-allowed"
362
416
  ),
363
417
  children: t
@@ -369,423 +423,424 @@ function ot({
369
423
  };
370
424
  return /* @__PURE__ */ Y("div", { className: "flex flex-col ", "data-component": "calendar", children: [
371
425
  m === "month" ? /* @__PURE__ */ Y("div", { className: "flex flex-col md:flex-row", children: [
372
- /* @__PURE__ */ c(we, { yearOffset: 0 }),
426
+ /* @__PURE__ */ c(ye, { yearOffset: 0 }),
373
427
  (w === "range" || w === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row gap-0", children: [
374
428
  /* @__PURE__ */ c("div", { className: "w-[1px] bg-stroke-hairline my-4" }),
375
- /* @__PURE__ */ c(we, { yearOffset: 1 })
429
+ /* @__PURE__ */ c(ye, { yearOffset: 1 })
376
430
  ] })
377
431
  ] }) : (
378
432
  // @ts-ignore: TS mismatch due to dynamic union types.
379
433
  // FIX: Split rendering into separate `DayPicker` calls for 'single' | 'multiple' | 'range' to strictly match discriminated unions.
380
434
  /* @__PURE__ */ c(
381
- Fe,
435
+ We,
382
436
  {
383
- mode: m === "week" ? "multiple" : F,
384
- selected: m === "week" ? G : b ? q : D,
385
- onSelect: Re,
386
- month: A,
387
- onMonthChange: O,
437
+ mode: m === "week" ? "multiple" : W,
438
+ selected: m === "week" ? J : x ? H : p,
439
+ onSelect: Le,
440
+ month: k,
441
+ onMonthChange: $,
388
442
  showOutsideDays: P === "fiscal" ? !0 : y,
389
- weekStartsOn: K,
390
- modifiers: m === "week" ? Pe : void 0,
443
+ weekStartsOn: q,
444
+ modifiers: m === "week" ? Oe : void 0,
391
445
  locale: ke,
392
- className: u(
446
+ className: d(
393
447
  "bg-canvas group/calendar p-2 [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
394
448
  String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
395
449
  String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
396
- le
450
+ oe
397
451
  ),
398
- captionLayout: Q,
399
- startMonth: R,
452
+ captionLayout: X,
453
+ startMonth: O,
400
454
  endMonth: L,
401
- disabled: ee.disabled,
402
- numberOfMonths: F === "range" || F === "multiple" || p === "range" || p === "multiple" ? 2 : 1,
455
+ disabled: K.disabled,
456
+ numberOfMonths: W === "range" || W === "multiple" || v === "range" || v === "multiple" ? 2 : 1,
403
457
  showWeekNumber: !0,
404
458
  formatters: {
405
- formatMonthDropdown: (e) => e.toLocaleString(W, { month: "short" }),
406
- formatWeekNumber: (e) => x("calendar.weekNumber", { number: e }),
407
- ...X
459
+ formatMonthDropdown: (e) => e.toLocaleString(G, { month: "short" }),
460
+ formatWeekNumber: (e) => b("calendar.weekNumber", { number: e }),
461
+ ...Z
408
462
  },
409
463
  classNames: {
410
- root: u("w-fit", v.root),
411
- months: u(
464
+ root: d("w-fit", D.root),
465
+ months: d(
412
466
  "relative flex flex-col gap-2 md:flex-row",
413
- v.months
467
+ D.months
414
468
  ),
415
- month: u(
469
+ month: d(
416
470
  "flex flex-1 min-w-[252px] flex-col gap-2 relative after:absolute after:top-[5.5rem] after:bottom-0 after:left-[30px] after:w-[1px] after:bg-stroke-hairline",
417
- v.month
471
+ D.month
418
472
  ),
419
- nav: u(
473
+ nav: d(
420
474
  "absolute inset-x-0 top-[2px] h-[--cell-size] flex w-full items-center justify-between px-2 gap-1",
421
- v.nav
475
+ D.nav
422
476
  ),
423
- button_previous: u(
477
+ button_previous: d(
424
478
  "h-7 w-7 select-none p-0 z-10 aria-disabled:opacity-50 flex items-center justify-center relative",
425
- v.button_previous
479
+ D.button_previous
426
480
  ),
427
- button_next: u(
481
+ button_next: d(
428
482
  "h-7 w-7 select-none p-0 z-10 aria-disabled:opacity-50 flex items-center justify-center relative",
429
- v.button_next
483
+ D.button_next
430
484
  ),
431
- month_caption: u(
485
+ month_caption: d(
432
486
  "flex h-[--cell-size] w-full items-center justify-center px-[--cell-size] relative ",
433
- v.month_caption
487
+ D.month_caption
434
488
  ),
435
- dropdowns: u(
489
+ dropdowns: d(
436
490
  "flex h-[--cell-size] gap-1 items-center justify-center text-sm font-medium relative ",
437
- v.dropdowns
491
+ D.dropdowns
438
492
  ),
439
- caption_label: u(
493
+ caption_label: d(
440
494
  "select-none font-medium text-sm",
441
- v.caption_label
495
+ D.caption_label
442
496
  ),
443
497
  table: "w-full border-collapse",
444
- weekdays: u("flex w-full relative after:absolute after:bottom-0 after:right-0 after:h-[1px] after:bg-stroke-hairline after:left-[30px]", v.weekdays),
445
- weekday: u(
498
+ weekdays: d("flex w-full relative after:absolute after:bottom-0 after:right-0 after:h-[1px] after:bg-stroke-hairline after:left-[30px]", D.weekdays),
499
+ weekday: d(
446
500
  "flex-1 select-none rounded-md font-normal text-center",
447
501
  "text-[11px] text-content-muted pb-2",
448
502
  "[&:nth-child(2)]:pl-2",
449
- v.weekday
503
+ D.weekday
450
504
  ),
451
- week: u("mt-1 flex w-full items-stretch group/week", v.week),
452
- week_number_header: u(
505
+ week: d("mt-1 flex w-full items-stretch group/week", D.week),
506
+ week_number_header: d(
453
507
  "select-none font-normal text-center h-[30px] flex items-center justify-center",
454
508
  "text-[11px] text-content-muted w-[30px] flex-shrink-0",
455
- v.week_number_header
509
+ D.week_number_header
456
510
  ),
457
- week_number: u(
511
+ week_number: d(
458
512
  "select-none flex items-center justify-center h-[30px]",
459
513
  "text-[11px] text-content-muted w-[30px] flex-shrink-0 transition-colors",
460
514
  m === "week" && "group-hover/week:bg-accent group-hover/week:rounded-l-lg",
461
- v.week_number
515
+ D.week_number
462
516
  ),
463
- day: u(
517
+ day: d(
464
518
  "group/day relative select-none p-0 text-center flex-1 h-[30px] flex items-center justify-center [&:nth-child(2)]:pl-2 rdp-day",
465
519
  m === "week" && "group-hover/week:bg-accent [&:nth-child(2)]:group-hover/week:rounded-l-full [&:nth-child(8)]:group-hover/week:rounded-r-full",
466
520
  m === "week" && "[&.rdp-selected:nth-child(2)]:rounded-l-full [&.rdp-selected:nth-child(8)]:rounded-r-full",
467
- J?.day
521
+ Q?.day
468
522
  ),
469
- range_start: u(
523
+ range_start: d(
470
524
  "bg-accent rounded-l-full",
471
- v.range_start
525
+ D.range_start
472
526
  ),
473
- range_middle: u("bg-accent rounded-none", v.range_middle),
474
- range_end: u("bg-accent rounded-r-full", v.range_end),
475
- today: u(
527
+ range_middle: d("bg-accent rounded-none", D.range_middle),
528
+ range_end: d("bg-accent rounded-r-full", D.range_end),
529
+ today: d(
476
530
  "text-brand",
477
- v.today
531
+ D.today
478
532
  ),
479
- outside: u(
533
+ outside: d(
480
534
  P === "fiscal" || y ? "text-content-muted opacity-50" : "invisible",
481
- v.outside
535
+ D.outside
482
536
  ),
483
- disabled: u(
537
+ disabled: d(
484
538
  "text-content-muted opacity-50",
485
- v.disabled
539
+ D.disabled
486
540
  ),
487
- hidden: u("invisible", v.hidden),
488
- ...J
541
+ hidden: d("invisible", D.hidden),
542
+ ...Q
489
543
  },
490
544
  components: {
491
- Root: ({ className: e, rootRef: n, ...t }) => /* @__PURE__ */ c(
545
+ Root: ({ className: e, rootRef: r, ...t }) => /* @__PURE__ */ c(
492
546
  "div",
493
547
  {
494
548
  "data-slot": "calendar",
495
- ref: n,
496
- className: u(e),
549
+ ref: r,
550
+ className: d(e),
497
551
  ...t
498
552
  }
499
553
  ),
500
- Chevron: ({ className: e, orientation: n, ...t }) => n === "left" ? /* @__PURE__ */ c(ye, { className: u("size-4 text-content", e), ...t }) : n === "right" ? /* @__PURE__ */ c(
501
- Ne,
554
+ Chevron: ({ className: e, orientation: r, ...t }) => r === "left" ? /* @__PURE__ */ c(Ne, { className: d("size-4 text-content", e), ...t }) : r === "right" ? /* @__PURE__ */ c(
555
+ Se,
502
556
  {
503
- className: u("size-4 text-content", e),
557
+ className: d("size-4 text-content", e),
504
558
  ...t
505
559
  }
506
560
  ) : /* @__PURE__ */ c("span", {}),
507
561
  PreviousMonthButton: (e) => /* @__PURE__ */ c(
508
- I,
562
+ R,
509
563
  {
510
- variant: B,
564
+ variant: T,
511
565
  size: "icon",
512
566
  className: "h-7 w-7",
513
- "aria-label": x("calendar.previousMonth"),
514
- title: x("calendar.previousMonth"),
567
+ "aria-label": b("calendar.previousMonth"),
568
+ title: b("calendar.previousMonth"),
515
569
  ...e
516
570
  }
517
571
  ),
518
572
  NextMonthButton: (e) => /* @__PURE__ */ c(
519
- I,
573
+ R,
520
574
  {
521
- variant: B,
575
+ variant: T,
522
576
  size: "icon",
523
577
  className: "h-7 w-7",
524
- "aria-label": x("calendar.nextMonth"),
525
- title: x("calendar.nextMonth"),
578
+ "aria-label": b("calendar.nextMonth"),
579
+ title: b("calendar.nextMonth"),
526
580
  ...e
527
581
  }
528
582
  ),
529
- MonthCaption: ({ displayIndex: e, ...n }) => /* @__PURE__ */ c(de.Provider, { value: e, children: /* @__PURE__ */ c("div", { ...n }) }),
583
+ MonthCaption: ({ displayIndex: e, ...r }) => /* @__PURE__ */ c(me.Provider, { value: e, children: /* @__PURE__ */ c("div", { ...r }) }),
530
584
  MonthsDropdown: ({ value: e }) => {
531
- const n = d.useContext(de), t = n > 0, r = new Date(A.getFullYear(), A.getMonth() + n, 1).getFullYear(), s = Ie(r);
585
+ const r = u.useContext(me), t = r > 0, n = new Date(k.getFullYear(), k.getMonth() + r, 1).getFullYear(), a = Pe(n);
532
586
  return /* @__PURE__ */ c(
533
- ue,
587
+ de,
534
588
  {
535
- value: s.find((l) => l.value === e?.toString()),
536
- onChange: (l) => {
537
- if (l && "value" in l) {
538
- const o = parseInt(l.value);
589
+ value: a.find((o) => o.value === e?.toString()),
590
+ onChange: (o) => {
591
+ if (o && "value" in o) {
592
+ const l = parseInt(o.value);
539
593
  if (t) {
540
- const f = new Date(r, o - 1, 1);
541
- O(f);
594
+ const f = new Date(n, l - 1, 1);
595
+ $(f);
542
596
  } else {
543
- const f = new Date(r, o, 1);
544
- O(f);
597
+ const f = new Date(n, l, 1);
598
+ $(f);
545
599
  }
546
600
  }
547
601
  },
548
602
  scrollToSelectedOnOpen: !0,
549
- options: s,
603
+ options: a,
550
604
  className: "w-[95px]",
551
605
  menuWidth: "140px",
552
606
  isSearchable: !0,
553
607
  isClearable: !1,
554
- placeholder: x("calendar.monthPlaceholder")
608
+ placeholder: b("calendar.monthPlaceholder")
555
609
  }
556
610
  );
557
611
  },
558
612
  YearsDropdown: ({ value: e }) => {
559
- const t = d.useContext(de) > 0, a = De();
613
+ const t = u.useContext(me) > 0, s = we();
560
614
  return /* @__PURE__ */ c(
561
- ue,
615
+ de,
562
616
  {
563
- value: a.find((r) => r.value === e?.toString()),
564
- onChange: (r) => {
565
- if (r && "value" in r) {
566
- const s = parseInt(r.value);
617
+ value: s.find((n) => n.value === e?.toString()),
618
+ onChange: (n) => {
619
+ if (n && "value" in n) {
620
+ const a = parseInt(n.value);
567
621
  if (t) {
568
- const l = new Date(A.getFullYear(), A.getMonth() + 1, 1).getMonth(), o = new Date(s, l - 1, 1);
569
- O(o);
622
+ const o = new Date(k.getFullYear(), k.getMonth() + 1, 1).getMonth(), l = new Date(a, o - 1, 1);
623
+ $(l);
570
624
  } else {
571
- const l = new Date(s, A.getMonth(), 1);
572
- O(l);
625
+ const o = new Date(a, k.getMonth(), 1);
626
+ $(o);
573
627
  }
574
628
  }
575
629
  },
576
630
  scrollToSelectedOnOpen: !0,
577
- options: a,
631
+ options: s,
578
632
  className: "w-[76px]",
579
633
  menuWidth: "140px",
580
634
  isSearchable: !0,
581
635
  isClearable: !1,
582
- placeholder: x("calendar.yearPlaceholder")
636
+ placeholder: b("calendar.yearPlaceholder")
583
637
  }
584
638
  );
585
639
  },
586
640
  DayButton: (e) => /* @__PURE__ */ c(
587
- Qe,
641
+ Ze,
588
642
  {
589
643
  ...e,
590
644
  pickerType: m
591
645
  }
592
646
  ),
593
- WeekNumber: ({ week: e, ...n }) => {
594
- const t = e.days.find((E) => !E.outside)?.date;
647
+ WeekNumber: ({ week: e, ...r }) => {
648
+ const t = e.days.find((I) => !I.outside)?.date;
595
649
  if (!t)
596
- return /* @__PURE__ */ c("td", { ...n, className: u("select-none flex items-center justify-center h-8 text-[11px] text-content-muted w-8 flex-shrink-0 rdp-week_number", n.className), children: /* @__PURE__ */ c("div", { className: "flex size-[--cell-size] items-center justify-center text-center" }) });
597
- const a = t.getFullYear(), r = t.getMonth(), o = (new Date(a, r, 1).getDay() + 7 - K) % 7, f = new Date(a, r, 1 - o), i = new Date(t), h = (t.getDay() + 7 - K) % 7;
650
+ return /* @__PURE__ */ c("td", { ...r, className: d("select-none flex items-center justify-center h-8 text-[11px] text-content-muted w-8 flex-shrink-0 rdp-week_number", r.className), children: /* @__PURE__ */ c("div", { className: "flex size-[--cell-size] items-center justify-center text-center" }) });
651
+ const s = t.getFullYear(), n = t.getMonth(), l = (new Date(s, n, 1).getDay() + 7 - q) % 7, f = new Date(s, n, 1 - l), i = new Date(t), h = (t.getDay() + 7 - q) % 7;
598
652
  i.setDate(t.getDate() - h);
599
- const S = Math.round((i.getTime() - f.getTime()) / (10080 * 60 * 1e3)) + 1, z = x("calendar.weekLabel", { number: S });
653
+ const C = Math.round((i.getTime() - f.getTime()) / (10080 * 60 * 1e3)) + 1, E = b("calendar.weekLabel", { number: C });
600
654
  if (m === "week") {
601
- const E = () => {
655
+ const I = () => {
602
656
  t && fe(ce(t));
603
657
  };
604
658
  return /* @__PURE__ */ c(
605
659
  "td",
606
660
  {
607
- "aria-label": z,
608
- "data-week-index": S,
609
- "data-week-number": S,
661
+ "aria-label": E,
662
+ "data-week-index": C,
663
+ "data-week-number": C,
610
664
  tabIndex: 0,
611
665
  role: "button",
612
- className: u(
666
+ className: d(
613
667
  "select-none flex items-center justify-center h-[30px] w-[30px] flex-shrink-0 rdp-week_number cursor-pointer hover:bg-accent hover:text-accent-foreground group-hover/week:bg-accent group-hover/week:rounded-l-lg rounded-lg transition-colors"
614
668
  ),
615
- onClick: (H) => {
616
- H.preventDefault(), H.stopPropagation(), E();
669
+ onClick: (F) => {
670
+ F.preventDefault(), F.stopPropagation(), I();
617
671
  },
618
- onKeyDown: (H) => {
619
- (H.key === "Enter" || H.key === " ") && (H.preventDefault(), H.stopPropagation(), E());
672
+ onKeyDown: (F) => {
673
+ (F.key === "Enter" || F.key === " ") && (F.preventDefault(), F.stopPropagation(), I());
620
674
  },
621
- children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-content-muted", children: x("calendar.weekNumber", { number: S }) })
675
+ children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-content-muted", children: b("calendar.weekNumber", { number: C }) })
622
676
  }
623
677
  );
624
678
  }
625
679
  return /* @__PURE__ */ c(
626
680
  "td",
627
681
  {
628
- ...n,
629
- "aria-label": z,
630
- className: u(
682
+ ...r,
683
+ "aria-label": E,
684
+ className: d(
631
685
  "select-none flex items-center justify-center h-[30px] text-[11px] text-content-muted w-[30px] flex-shrink-0 rdp-week_number",
632
- n.className
686
+ r.className
633
687
  ),
634
688
  scope: "row",
635
689
  role: "rowheader",
636
- children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center", children: x("calendar.weekNumber", { number: S }) })
690
+ children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center", children: b("calendar.weekNumber", { number: C }) })
637
691
  }
638
692
  );
639
693
  },
640
694
  ...Ce
641
695
  },
642
- ...ee
696
+ ...K
643
697
  }
644
698
  )
645
699
  ),
646
- b && /* @__PURE__ */ Y("div", { className: u("flex items-center gap-2 border-t pt-3 p-3", m === "month" && w !== "single" || F === "range" || p === "range" || p === "multiple" ? "justify-between" : "justify-end"), children: [
647
- F === "range" && m === "date" && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
700
+ x && /* @__PURE__ */ Y("div", { className: d("flex items-center gap-2 border-t pt-3 p-3", m === "month" && w !== "single" || W === "range" || v === "range" || v === "multiple" ? "justify-between" : "justify-end"), children: [
701
+ W === "range" && m === "date" && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
648
702
  "Selected:",
649
703
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
650
- const e = q;
704
+ const e = H;
651
705
  if (e?.from && e?.to) {
652
- const n = Math.abs(e.to.getTime() - e.from.getTime()), t = Math.ceil(n / (1e3 * 60 * 60 * 24)) + 1;
706
+ const r = Math.abs(e.to.getTime() - e.from.getTime()), t = Math.ceil(r / (1e3 * 60 * 60 * 24)) + 1;
653
707
  return `${t} day${t !== 1 ? "s" : ""}`;
654
708
  }
655
709
  return "0 days";
656
710
  })() })
657
711
  ] }),
658
- m === "week" && (p === "range" || p === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
712
+ m === "week" && (v === "range" || v === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
659
713
  "Selected:",
660
714
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
661
- const e = $;
715
+ const e = j;
662
716
  if (!e) return "0 weeks";
663
- const n = (o) => Date.UTC(o.getFullYear(), o.getMonth(), o.getDate()), t = (o) => {
664
- const f = Math.floor(o / 7), i = o % 7, g = [];
717
+ const r = (l) => Date.UTC(l.getFullYear(), l.getMonth(), l.getDate()), t = (l) => {
718
+ const f = Math.floor(l / 7), i = l % 7, g = [];
665
719
  return f > 0 && g.push(`${f} week${f !== 1 ? "s" : ""}`), (i > 0 || f === 0) && g.push(`${i} day${i !== 1 ? "s" : ""}`), g.join(" ");
666
- }, a = P === "fiscal" && oe === "fiscalMonth", r = P === "fiscal", s = a ? "fiscal month" : r ? "fiscal week" : "week", l = a ? "fiscal months" : r ? "fiscal weeks" : "weeks";
720
+ }, s = P === "fiscal" && le === "fiscalMonth", n = P === "fiscal", a = s ? "fiscal month" : n ? "fiscal week" : "week", o = s ? "fiscal months" : n ? "fiscal weeks" : "weeks";
667
721
  if (Array.isArray(e))
668
- if (r || a) {
669
- const o = e.length;
670
- return `${o} ${o !== 1 ? l : s}`;
722
+ if (n || s) {
723
+ const l = e.length;
724
+ return `${l} ${l !== 1 ? o : a}`;
671
725
  } else {
672
- let o = 0;
726
+ let l = 0;
673
727
  return e.forEach((f) => {
674
- const i = n(f.startDate), g = n(f.endDate);
675
- o += Math.round((g - i) / (1e3 * 60 * 60 * 24)) + 1;
676
- }), t(o);
728
+ const i = r(f.startDate), g = r(f.endDate);
729
+ l += Math.round((g - i) / (1e3 * 60 * 60 * 24)) + 1;
730
+ }), t(l);
677
731
  }
678
732
  else if ("from" in e) {
679
- const { from: o, to: f } = e;
680
- if (a) {
681
- if (!f) return `1 ${s}`;
682
- const i = n(o.startDate), g = n(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1, j = ne ? ne.reduce((z, E) => z + E, 0) / 12 : 4.33, S = Math.max(1, Math.round(h / (j * 7)));
683
- return `${S} ${S !== 1 ? l : s}`;
684
- } else if (r) {
685
- if (!f) return `1 ${s}`;
686
- const i = n(o.startDate), g = n(f.endDate), h = Math.round((g - i) / (10080 * 60 * 1e3)), j = h > 0 ? h : 1;
687
- return `${j} ${j !== 1 ? l : s}`;
733
+ const { from: l, to: f } = e;
734
+ if (s) {
735
+ if (!f) return `1 ${a}`;
736
+ const i = r(l.startDate), g = r(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1, z = ne ? ne.reduce((E, I) => E + I, 0) / 12 : 4.33, C = Math.max(1, Math.round(h / (z * 7)));
737
+ return `${C} ${C !== 1 ? o : a}`;
738
+ } else if (n) {
739
+ if (!f) return `1 ${a}`;
740
+ const i = r(l.startDate), g = r(f.endDate), h = Math.round((g - i) / (10080 * 60 * 1e3)), z = h > 0 ? h : 1;
741
+ return `${z} ${z !== 1 ? o : a}`;
688
742
  } else {
689
743
  if (!f) {
690
- const j = n(o.startDate), S = n(o.endDate), z = Math.round((S - j) / (1e3 * 60 * 60 * 24)) + 1;
691
- return t(z);
744
+ const z = r(l.startDate), C = r(l.endDate), E = Math.round((C - z) / (1e3 * 60 * 60 * 24)) + 1;
745
+ return t(E);
692
746
  }
693
- const i = n(o.startDate), g = n(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1;
747
+ const i = r(l.startDate), g = r(f.endDate), h = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1;
694
748
  return t(h);
695
749
  }
696
750
  } else
697
- return `1 ${s}`;
751
+ return `1 ${a}`;
698
752
  })() })
699
753
  ] }),
700
754
  m === "month" && (w === "range" || w === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
701
755
  "Selected:",
702
756
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
703
- const e = M;
757
+ const e = A;
704
758
  if (!e) return "0 months";
705
759
  if (Array.isArray(e)) {
706
- const n = e.length;
707
- return n === 1 ? x("calendar.monthRange") : x("calendar.monthRangePlural", { count: n });
760
+ const r = e.length;
761
+ return r === 1 ? b("calendar.monthRange") : b("calendar.monthRangePlural", { count: r });
708
762
  } else if ("from" in e) {
709
- const n = e;
710
- if (!n.from || !n.to) return x("calendar.monthRange");
711
- const t = new Date(n.from.year, n.from.month, 1), a = new Date(n.to.year, n.to.month, 1), r = (a.getFullYear() - t.getFullYear()) * 12 + (a.getMonth() - t.getMonth()) + 1;
712
- return r === 1 ? x("calendar.monthRange") : x("calendar.monthRangePlural", { count: r });
763
+ const r = e;
764
+ if (!r.from || !r.to) return b("calendar.monthRange");
765
+ const t = new Date(r.from.year, r.from.month, 1), s = new Date(r.to.year, r.to.month, 1), n = (s.getFullYear() - t.getFullYear()) * 12 + (s.getMonth() - t.getMonth()) + 1;
766
+ return n === 1 ? b("calendar.monthRange") : b("calendar.monthRangePlural", { count: n });
713
767
  } else
714
- return x("calendar.monthRange");
768
+ return b("calendar.monthRange");
715
769
  })() })
716
770
  ] }),
717
771
  /* @__PURE__ */ Y("div", { className: "flex items-center gap-2", children: [
718
772
  /* @__PURE__ */ c(
719
- I,
773
+ R,
720
774
  {
721
775
  variant: "link",
722
776
  size: "sm",
723
- onClick: Oe,
724
- children: x("calendar.clear")
777
+ onClick: He,
778
+ children: b("calendar.clear")
725
779
  }
726
780
  ),
727
781
  /* @__PURE__ */ c(
728
- I,
782
+ R,
729
783
  {
730
784
  variant: "outline",
731
785
  size: "sm",
732
- onClick: $e,
733
- children: x("calendar.cancel")
786
+ onClick: Ue,
787
+ children: b("calendar.cancel")
734
788
  }
735
789
  ),
736
790
  /* @__PURE__ */ c(
737
- I,
791
+ R,
738
792
  {
739
793
  variant: "default",
740
794
  size: "sm",
741
- onClick: Le,
742
- children: x("calendar.apply")
795
+ onClick: $e,
796
+ disabled: _e || Ke,
797
+ children: b("calendar.apply")
743
798
  }
744
799
  )
745
800
  ] })
746
801
  ] })
747
802
  ] });
748
803
  }
749
- function Qe({
750
- className: le,
751
- day: J,
804
+ function Ze({
805
+ className: oe,
806
+ day: Q,
752
807
  modifiers: y,
753
- pickerType: Q,
754
- ...B
808
+ pickerType: X,
809
+ ...T
755
810
  }) {
756
- const X = d.useRef(null);
757
- return d.useEffect(() => {
758
- y.focused && X.current?.focus();
811
+ const Z = u.useRef(null);
812
+ return u.useEffect(() => {
813
+ y.focused && Z.current?.focus();
759
814
  }, [y.focused]), /* @__PURE__ */ c(
760
- I,
815
+ R,
761
816
  {
762
- ref: X,
817
+ ref: Z,
763
818
  variant: "ghost",
764
819
  size: "sm",
765
- "data-day": J.date.toLocaleDateString(),
820
+ "data-day": Q.date.toLocaleDateString(),
766
821
  "data-selected-single": y.selected && !y.range_start && !y.range_end && !y.range_middle,
767
822
  "data-range-start": y.range_start,
768
823
  "data-range-end": y.range_end,
769
824
  "data-range-middle": y.range_middle,
770
- className: u(
825
+ className: d(
771
826
  "gap-2 whitespace-nowrap focus-visible:ring-1 focus-visible:ring-focus-ring disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 px-3 rounded-lg flex items-center justify-center font-normal transition-colors w-5 h-5 border border-transparent focus-visible:outline-none text-sm rdp-day rdp-day_button",
772
827
  // Hover styling
773
- Q !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-brand",
774
- Q === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
828
+ X !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-brand",
829
+ X === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
775
830
  // Selection state
776
831
  "data-[selected-single=true]:bg-brand data-[selected-single=true]:text-brand-foreground data-[selected-single=true]:rounded-lg data-[selected-single=true]:border-transparent",
777
832
  "data-[range-start=true]:bg-brand data-[range-start=true]:text-brand-foreground data-[range-start=true]:rounded-lg data-[range-start=true]:border-transparent",
778
833
  "data-[range-end=true]:bg-brand data-[range-end=true]:text-brand-foreground data-[range-end=true]:rounded-lg data-[range-end=true]:border-transparent",
779
834
  "data-[range-middle=true]:text-accent-foreground data-[range-middle=true]:rounded-none",
780
- le
835
+ oe
781
836
  ),
782
837
  "data-component": "calendar-day",
783
- ...B,
784
- disabled: B.disabled || y.disabled
838
+ ...T,
839
+ disabled: T.disabled || y.disabled
785
840
  }
786
841
  );
787
842
  }
788
843
  export {
789
- ot as Calendar,
790
- Qe as CalendarDayButton
844
+ ct as Calendar,
845
+ Ze as CalendarDayButton
791
846
  };