@featherk/composables 0.6.5 → 0.6.7

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,119 +1,127 @@
1
- import { ref as _, onBeforeUnmount as Ie, nextTick as N, computed as h, watch as ve, onMounted as xe, readonly as K, getCurrentScope as Le, onScopeDispose as Pe, toValue as ce, unref as Te, shallowRef as Re } from "vue";
1
+ import { ref as _, onBeforeUnmount as Te, nextTick as j, computed as h, watch as ve, onMounted as xe, readonly as N, getCurrentScope as Le, onScopeDispose as Pe, toValue as ce, unref as Fe, shallowRef as Re } from "vue";
2
2
  import { useFocusTrap as qe } from "@vueuse/integrations/useFocusTrap";
3
- const We = (e) => {
4
- const t = _(null);
5
- let c = !1, P = null, T = null;
6
- const V = [], W = ".k-table-row[data-grid-row-index] [tabindex]", k = () => e?.value?.columns, b = (o) => {
7
- const m = o.key || o.code;
8
- [" ", "Spacebar", "Space", "Enter"].includes(m) && (o.preventDefault(), o.stopPropagation(), t.value = o.target, o.target.click());
9
- }, y = (o) => {
10
- if (!t.value) return;
3
+ const _e = (e, t) => {
4
+ const u = _(null);
5
+ let q = !1, I = null, L = null;
6
+ const V = [], A = ".k-table-row[data-grid-row-index] [tabindex]", k = () => e?.value?.columns, S = (o) => {
7
+ const p = o.key || o.code;
8
+ [" ", "Spacebar", "Space", "Enter"].includes(p) && (o.preventDefault(), o.stopPropagation(), u.value = o.target, o.target.click());
9
+ }, g = (o) => {
10
+ if (!u.value) return;
11
11
  if (o.code === "Escape") {
12
- o.preventDefault(), o.stopPropagation(), t.value && t.value.focus();
12
+ o.stopPropagation(), u.value && u.value.focus();
13
13
  return;
14
14
  }
15
- const m = Array.from(
15
+ const p = Array.from(
16
16
  document.querySelectorAll(
17
17
  ".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
18
18
  )
19
- ), l = document.querySelector(".k-filter-menu-container");
19
+ ), l = document.querySelector(
20
+ ".k-animation-container .k-popup .k-column-menu .k-filter-menu-container"
21
+ );
20
22
  if (l) {
21
23
  if (o.code === "Tab") {
22
- const i = [
24
+ const s = [
23
25
  ".k-filter-menu-container .k-dropdownlist[tabindex='0']",
24
26
  ".k-filter-menu-container input.k-input-inner:not([tabindex='-1']):not([disabled])",
25
- ".k-filter-menu-container button:not([tabindex='-1']):not([disabled])"
26
- ], p = Array.from(
27
- l.querySelectorAll(i.join(","))
27
+ ".k-filter-menu-container button:not([tabindex='-1']):not([disabled])",
28
+ ".k-checkbox"
29
+ ], v = t?.focusableMenuSelectors ?? s, b = Array.from(
30
+ l.querySelectorAll(v.join(","))
28
31
  );
29
- if (p.length === 0) return;
30
- const A = p.findIndex(
31
- (C) => C === document.activeElement
32
+ if (b.length === 0) return;
33
+ const D = b.findIndex(
34
+ (H) => H === document.activeElement
32
35
  );
33
- let S;
34
- A === -1 ? S = 0 : o.shiftKey ? S = (A - 1 + p.length) % p.length : S = (A + 1) % p.length, o.preventDefault(), o.stopPropagation(), p[S]?.focus();
35
- return;
36
+ let $;
37
+ D === -1 ? $ = 0 : o.shiftKey ? $ = (D - 1 + b.length) % b.length : $ = (D + 1) % b.length, o.preventDefault(), o.stopPropagation(), b[$]?.focus();
36
38
  }
37
39
  } else if (o.code === "ArrowUp" || o.code === "ArrowDown") {
38
40
  o.preventDefault(), o.stopPropagation();
39
- const i = m.findIndex(
40
- (A) => A === document.activeElement
41
+ const s = p.findIndex(
42
+ (b) => b === document.activeElement
41
43
  );
42
- let p = i;
43
- o.code === "ArrowUp" ? p = i > 0 ? i - 1 : m.length - 1 : o.code === "ArrowDown" && (p = i < m.length - 1 ? i + 1 : 0), m[p]?.focus();
44
+ let v = s;
45
+ o.code === "ArrowUp" ? v = s > 0 ? s - 1 : p.length - 1 : o.code === "ArrowDown" && (v = s < p.length - 1 ? s + 1 : 0), p[v]?.focus();
44
46
  return;
45
47
  }
46
- o.code === "Tab" && (o.preventDefault(), o.stopPropagation(), o.shiftKey ? (t.value?.previousElementSibling).focus() : (t.value?.nextElementSibling).focus());
47
- }, w = () => {
48
- P = new MutationObserver((o) => {
49
- o.forEach((m) => {
50
- m.addedNodes.forEach((l) => {
48
+ if (o.code === "Tab") {
49
+ o.preventDefault(), o.stopPropagation();
50
+ const s = u.value?.parentElement;
51
+ (o.shiftKey ? s?.previousElementSibling : s?.nextElementSibling)?.querySelector(
52
+ "button, [role='button'], .k-link"
53
+ )?.focus();
54
+ }
55
+ }, P = () => {
56
+ I = new MutationObserver((o) => {
57
+ o.forEach((p) => {
58
+ p.addedNodes.forEach((l) => {
51
59
  if (l.nodeType === Node.ELEMENT_NODE) {
52
- const i = l;
53
- if (i.classList.contains("k-animation-container")) {
54
- const A = t.value;
55
- A && (A.dataset.featherKSortable === "true" || N(() => {
56
- i.querySelectorAll(
60
+ const s = l;
61
+ if (s.classList.contains("k-animation-container")) {
62
+ const b = u.value;
63
+ b && (b.dataset.featherKSortable === "true" || j(() => {
64
+ s.querySelectorAll(
57
65
  ".k-columnmenu-item-wrapper"
58
- ).forEach((G) => {
59
- G.textContent?.toLowerCase().includes("sort") && G.remove();
66
+ ).forEach((H) => {
67
+ H.textContent?.toLowerCase().includes("sort") && H.remove();
60
68
  });
61
- })), i.addEventListener(
69
+ })), s.addEventListener(
62
70
  "keydown",
63
- y
64
- ), N(() => {
65
- const S = () => {
66
- const C = Array.from(
67
- i.querySelectorAll(
71
+ g
72
+ ), j(() => {
73
+ const D = () => {
74
+ const $ = Array.from(
75
+ s.querySelectorAll(
68
76
  ".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
69
77
  )
70
78
  );
71
- if (C.length === 1)
72
- C[0].focus(), C[0].click(), S.attempts = 0;
73
- else if (C.length > 1) {
74
- S.attempts = 0;
79
+ if ($.length === 1)
80
+ $[0].focus(), $[0].click(), D.attempts = 0;
81
+ else if ($.length > 1) {
82
+ D.attempts = 0;
75
83
  return;
76
84
  } else
77
- S.attempts === void 0 && (S.attempts = 0), S.attempts++ < 3 && setTimeout(S, 200);
85
+ D.attempts === void 0 && (D.attempts = 0), D.attempts++ < 3 && setTimeout(D, 200);
78
86
  };
79
- S();
87
+ D();
80
88
  });
81
89
  }
82
- i.querySelectorAll(
90
+ s.querySelectorAll(
83
91
  ".k-animation-container"
84
- ).forEach((A) => {
85
- A.addEventListener(
92
+ ).forEach((b) => {
93
+ b.addEventListener(
86
94
  "keydown",
87
- y
95
+ g
88
96
  );
89
97
  });
90
98
  }
91
- }), m.removedNodes.forEach((l) => {
99
+ }), p.removedNodes.forEach((l) => {
92
100
  if (l.nodeType === Node.ELEMENT_NODE) {
93
- const i = l;
94
- i.classList.contains("k-animation-container") && i.removeEventListener(
101
+ const s = l;
102
+ s.classList.contains("k-animation-container") && s.removeEventListener(
95
103
  "keydown",
96
- y
97
- ), i.querySelectorAll(
104
+ g
105
+ ), s.querySelectorAll(
98
106
  ".k-animation-container"
99
- ).forEach((A) => {
100
- A.removeEventListener(
107
+ ).forEach((b) => {
108
+ b.removeEventListener(
101
109
  "keydown",
102
- y
110
+ g
103
111
  );
104
112
  });
105
113
  }
106
114
  });
107
115
  });
108
- }), P.observe(document.body, {
116
+ }), I.observe(document.body, {
109
117
  childList: !0,
110
118
  subtree: !0
111
119
  });
112
- }, L = (o) => {
120
+ }, E = (o) => {
113
121
  if (!o.type || !o)
114
122
  return;
115
- const m = o.target;
116
- if (m) {
123
+ const p = o.target;
124
+ if (p) {
117
125
  if (o.code === "Escape") {
118
126
  const l = document.activeElement?.closest(".k-table-row[data-grid-row-index]");
119
127
  if (l) {
@@ -123,7 +131,7 @@ const We = (e) => {
123
131
  e?.value.$el.querySelectorAll(
124
132
  ".k-table-row[data-grid-row-index]"
125
133
  )
126
- ).forEach((p) => p.setAttribute("tabindex", "-1"));
134
+ ).forEach((v) => v.setAttribute("tabindex", "-1"));
127
135
  } catch {
128
136
  }
129
137
  l.setAttribute("tabindex", "0"), l.focus();
@@ -138,141 +146,141 @@ const We = (e) => {
138
146
  "Enter",
139
147
  "Space"
140
148
  ].includes(o.code)) {
141
- if (o.preventDefault(), m.classList.contains("k-grid-header-menu") && m.classList.contains("k-grid-column-menu")) {
142
- t.value = m;
149
+ if (o.preventDefault(), p.classList.contains("k-grid-header-menu") && p.classList.contains("k-grid-column-menu")) {
150
+ u.value = p;
143
151
  return;
144
152
  }
145
- const l = m.closest(
153
+ const l = p.closest(
146
154
  ".k-table-row[data-grid-row-index]"
147
155
  );
148
156
  if (l) {
149
157
  if (["ArrowDown", "ArrowUp"].includes(o.code)) {
150
- const i = (A, S) => {
151
- let C = S === "next" ? A.nextElementSibling : A.previousElementSibling;
152
- for (; C; ) {
153
- const G = C;
158
+ const s = (b, D) => {
159
+ let $ = D === "next" ? b.nextElementSibling : b.previousElementSibling;
160
+ for (; $; ) {
161
+ const H = $;
154
162
  try {
155
- if (G.hasAttribute && G.classList.contains("k-table-row"))
156
- return G;
163
+ if (H.hasAttribute && H.classList.contains("k-table-row"))
164
+ return H;
157
165
  } catch {
158
166
  }
159
- C = S === "next" ? C.nextElementSibling : C.previousElementSibling;
167
+ $ = D === "next" ? $.nextElementSibling : $.previousElementSibling;
160
168
  }
161
169
  return null;
162
- }, p = o.code === "ArrowDown" ? i(l, "next") : i(l, "previous");
163
- p && (l.setAttribute("tabindex", "-1"), p.setAttribute("tabindex", "0"), p.focus());
170
+ }, v = o.code === "ArrowDown" ? s(l, "next") : s(l, "previous");
171
+ v && (l.setAttribute("tabindex", "-1"), v.setAttribute("tabindex", "0"), v.focus());
164
172
  return;
165
173
  }
166
174
  if (["ArrowLeft", "ArrowRight"].includes(o.code)) {
167
175
  o.preventDefault();
168
- const i = l.querySelectorAll(
169
- W
176
+ const s = l.querySelectorAll(
177
+ A
170
178
  );
171
- if (i.length === 0) return;
172
- let p = Array.from(i).findIndex(
173
- (A) => A === document.activeElement
179
+ if (s.length === 0) return;
180
+ let v = Array.from(s).findIndex(
181
+ (b) => b === document.activeElement
174
182
  );
175
- if (p === -1 && document.activeElement === l) {
176
- i[0].focus();
183
+ if (v === -1 && document.activeElement === l) {
184
+ s[0].focus();
177
185
  return;
178
186
  }
179
- o.code === "ArrowRight" ? p = p === i.length - 1 ? 0 : p + 1 : o.code === "ArrowLeft" && (p = p === i.length - 1 ? p - 1 : i.length - 1), i[p].focus();
187
+ o.code === "ArrowRight" ? v = v === s.length - 1 ? 0 : v + 1 : o.code === "ArrowLeft" && (v = v === s.length - 1 ? v - 1 : s.length - 1), s[v].focus();
180
188
  return;
181
189
  }
182
190
  }
183
191
  }
184
192
  }
185
- }, D = () => {
186
- N(() => {
193
+ }, C = () => {
194
+ j(() => {
187
195
  const o = e.value.$el.closest(".k-grid");
188
196
  o && o.classList.add("fk-grid");
189
197
  });
190
- }, x = () => {
191
- if (!T)
198
+ }, T = () => {
199
+ if (!L)
192
200
  try {
193
201
  const o = () => {
194
202
  try {
195
- const i = Array.from(
203
+ const s = Array.from(
196
204
  e.value.$el.querySelectorAll(
197
205
  ".k-table-row[data-grid-row-index]"
198
206
  )
199
207
  );
200
- if (!i || i.length === 0 || i.filter(
201
- (S) => S.getAttribute("tabindex") === "0"
208
+ if (!s || s.length === 0 || s.filter(
209
+ (D) => D.getAttribute("tabindex") === "0"
202
210
  ).length === 1) return;
203
- const A = i.find(
204
- (S) => S === document.activeElement || S.contains(document.activeElement)
211
+ const b = s.find(
212
+ (D) => D === document.activeElement || D.contains(document.activeElement)
205
213
  );
206
- if (i.forEach((S) => S.setAttribute("tabindex", "-1")), A) {
207
- A.setAttribute("tabindex", "0");
214
+ if (s.forEach((D) => D.setAttribute("tabindex", "-1")), b) {
215
+ b.setAttribute("tabindex", "0");
208
216
  return;
209
217
  }
210
- i[0].setAttribute("tabindex", "0");
211
- } catch (i) {
212
- console.error("ensureSingleTabindex error:", i);
218
+ s[0].setAttribute("tabindex", "0");
219
+ } catch (s) {
220
+ console.error("ensureSingleTabindex error:", s);
213
221
  }
214
- }, m = Array.from(
222
+ }, p = Array.from(
215
223
  e.value.$el.querySelectorAll(
216
224
  ".k-table-row[data-grid-row-index]"
217
225
  )
218
226
  );
219
- m.length > 0 && m.forEach((i, p) => {
220
- i.setAttribute("tabindex", p === 0 ? "0" : "-1");
227
+ p.length > 0 && p.forEach((s, v) => {
228
+ s.setAttribute("tabindex", v === 0 ? "0" : "-1");
221
229
  });
222
230
  const l = e.value.$el.querySelector(".k-table-tbody");
223
- l && (T = new MutationObserver(() => {
231
+ l && (L = new MutationObserver(() => {
224
232
  o();
225
- }), T.observe(l, { childList: !0, subtree: !0 }));
233
+ }), L.observe(l, { childList: !0, subtree: !0 }));
226
234
  } catch (o) {
227
235
  console.error("Error setting up row navigation:", o);
228
236
  }
229
- }, $ = () => {
230
- N(() => {
231
- const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
232
- m && m.forEach((l) => {
237
+ }, U = () => {
238
+ j(() => {
239
+ const p = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
240
+ p && p.forEach((l) => {
233
241
  l.setAttribute("role", "button"), l.addEventListener(
234
242
  "keydown",
235
- b
243
+ S
236
244
  );
237
- }), w(), f();
245
+ }), P(), y();
238
246
  });
239
- }, R = () => {
240
- const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
241
- m && m.forEach((l) => {
247
+ }, f = () => {
248
+ const p = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
249
+ p && p.forEach((l) => {
242
250
  l.removeEventListener(
243
251
  "keydown",
244
- b
252
+ S
245
253
  );
246
- }), P && (P.disconnect(), P = null), T && (T.disconnect(), T = null), V.forEach((l) => l()), V.length = 0;
247
- }, f = () => {
254
+ }), I && (I.disconnect(), I = null), L && (L.disconnect(), L = null), V.forEach((l) => l()), V.length = 0;
255
+ }, y = () => {
248
256
  document.querySelectorAll(
249
257
  ".k-grid-header .k-table-thead th"
250
- ).forEach((l, i) => {
251
- const p = l.querySelector(
258
+ ).forEach((l, s) => {
259
+ const v = l.querySelector(
252
260
  ".k-grid-header-menu.k-grid-column-menu"
253
261
  );
254
- if (!p) return;
255
- const A = k();
256
- if (A && A[i]) {
257
- const H = A[i].field ?? "";
258
- l.setAttribute("data-feather-k-field", H), l.setAttribute(
262
+ if (!v) return;
263
+ const b = k();
264
+ if (b && b[s]) {
265
+ const F = b[s].field ?? "";
266
+ l.setAttribute("data-feather-k-field", F), l.setAttribute(
259
267
  "data-feather-k-filterable",
260
- A[i].filterable === !1 ? "false" : "true"
268
+ b[s].filterable === !1 ? "false" : "true"
261
269
  ), l.setAttribute(
262
270
  "data-feather-k-sortable",
263
- A[i].sortable === !1 ? "false" : "true"
271
+ b[s].sortable === !1 ? "false" : "true"
264
272
  );
265
273
  }
266
- const S = l.dataset.featherKFilterable !== "false", C = l.dataset.featherKSortable !== "false";
267
- p.setAttribute("tabindex", "-1"), S || C ? l.style.cursor = "pointer" : l.style.cursor = "default", S ? (l.setAttribute("tabindex", "0"), l.setAttribute("role", "button"), l.setAttribute("aria-haspopup", "menu")) : (l.setAttribute("tabindex", "0"), l.setAttribute("role", "columnheader"), l.removeAttribute("aria-haspopup"));
268
- const G = (H) => {
269
- H.target?.closest(".k-column-resizer") || (t.value = l, p.click());
270
- }, oe = (H) => {
271
- if (S)
272
- t.value = l, H.preventDefault(), H.stopPropagation(), G(H);
273
- else if (C) {
274
- t.value = l;
275
- const J = new KeyboardEvent("keydown", {
274
+ const D = l.dataset.featherKFilterable !== "false", $ = l.dataset.featherKSortable !== "false";
275
+ v.setAttribute("tabindex", "-1"), D || $ ? l.style.cursor = "pointer" : l.style.cursor = "default", D ? (l.setAttribute("tabindex", "0"), l.setAttribute("role", "button"), l.setAttribute("aria-haspopup", "menu")) : (l.setAttribute("tabindex", "0"), l.setAttribute("role", "columnheader"), l.removeAttribute("aria-haspopup"));
276
+ const H = (F) => {
277
+ F.target?.closest(".k-column-resizer") || (u.value = l, v.click());
278
+ }, J = (F) => {
279
+ if (D)
280
+ u.value = l, F.preventDefault(), F.stopPropagation(), H(F);
281
+ else if ($) {
282
+ u.value = l;
283
+ const ne = new KeyboardEvent("keydown", {
276
284
  key: "Enter",
277
285
  code: "Enter",
278
286
  keyCode: 13,
@@ -280,193 +288,206 @@ const We = (e) => {
280
288
  bubbles: !0,
281
289
  cancelable: !0
282
290
  });
283
- l.dispatchEvent(J);
291
+ l.dispatchEvent(ne);
284
292
  }
285
293
  };
286
- l.addEventListener("click", oe), V.push(() => {
287
- l.removeEventListener("click", oe);
294
+ l.addEventListener("click", J), V.push(() => {
295
+ l.removeEventListener("click", J);
288
296
  });
289
- const Q = (H) => {
290
- if ((H.code === "Enter" || H.code === "Space") && (S || C)) {
291
- if (t.value = l, t.value.focus(), S)
292
- H.preventDefault(), H.stopPropagation(), G(H);
293
- else if (C) {
294
- const J = l.querySelector(".k-link");
295
- J && J.click();
297
+ const oe = (F) => {
298
+ if ((F.code === "Enter" || F.code === "Space") && (D || $)) {
299
+ if (u.value = l, u.value.focus(), D)
300
+ F.preventDefault(), F.stopPropagation(), H(F);
301
+ else if ($) {
302
+ const ne = l.querySelector(".k-link");
303
+ ne && ne.click();
296
304
  }
297
305
  }
298
306
  };
299
- l.addEventListener("keydown", Q, !0), V.push(() => {
300
- l.removeEventListener("keydown", Q, !0);
307
+ l.addEventListener("keydown", oe, !0), V.push(() => {
308
+ l.removeEventListener("keydown", oe, !0);
301
309
  });
302
310
  });
303
- const m = document.querySelector(".k-grid-header .k-table-thead");
304
- if (m) {
305
- const l = (i) => {
306
- const p = i.target.closest("th");
307
- p && (i.code === "Enter" || i.code === "Space") && p.dataset.featherKFilterable === "false" && p.dataset.featherKSortable === "false" && (i.preventDefault(), i.stopImmediatePropagation());
311
+ const p = document.querySelector(".k-grid-header .k-table-thead");
312
+ if (p) {
313
+ const l = (s) => {
314
+ const v = s.target.closest("th");
315
+ v && (s.code === "Enter" || s.code === "Space") && v.dataset.featherKFilterable === "false" && v.dataset.featherKSortable === "false" && (s.preventDefault(), s.stopImmediatePropagation());
308
316
  };
309
- m.addEventListener(
317
+ p.addEventListener(
310
318
  "keydown",
311
319
  l,
312
320
  !0
313
321
  // NOTE: capture phase
314
322
  ), V.push(() => {
315
- m.removeEventListener(
323
+ p.removeEventListener(
316
324
  "keydown",
317
325
  l,
318
326
  !0
319
327
  );
320
328
  });
321
329
  }
322
- }, g = function(o, m) {
323
- const l = o?.event.event.target, i = k();
324
- if (!l || !i) return;
325
- const p = l.classList.contains("k-link"), A = l.classList.contains("k-columnmenu-item"), S = i.find((C) => C.field === o.event.field)?.sortable && !0;
326
- if (!p) {
327
- if (A && !S) {
330
+ }, O = function(o, p) {
331
+ const l = o?.event.event.target, s = k();
332
+ if (!l || !s) return;
333
+ const v = l.classList.contains("k-link"), b = l.classList.contains("k-columnmenu-item"), D = s.find(($) => $.field === o.event.field)?.sortable && !0;
334
+ if (!v) {
335
+ if (b && !D) {
328
336
  (o.event.sort && void 0)?.filter(
329
- (G) => G.field !== o.event.field
337
+ (H) => H.field !== o.event.field
330
338
  );
331
339
  return;
332
340
  }
333
- typeof m == "function" && N(() => {
334
- t.value && t.value.focus(), m(o);
341
+ typeof p == "function" && j(() => {
342
+ u.value && u.value.focus(), p(o);
335
343
  });
336
344
  }
337
- }, F = () => {
338
- if (!c)
345
+ }, G = () => {
346
+ if (!q)
339
347
  try {
340
- D(), x(), $(), c = !0;
348
+ C(), T(), U(), q = !0;
341
349
  } catch (o) {
342
- console.error("initA11y failed:", o), R();
350
+ console.error("initA11y failed:", o), f();
343
351
  }
344
352
  };
345
- return Ie(() => {
346
- R();
353
+ return Te(() => {
354
+ f();
347
355
  }), {
348
- activeFilterButton: t,
349
- handleGridKeyDown: L,
350
- handleSortChange: g,
351
- initA11y: F
356
+ activeFilterButton: u,
357
+ handleGridKeyDown: E,
358
+ handleSortChange: O,
359
+ initA11y: G
352
360
  };
353
361
  };
354
- function _e(e) {
355
- const t = _(""), c = _(void 0), P = _(!!e.debug), T = _(e.dateFormat ?? "mm/dd/yyyy"), V = h(() => !!e.required), W = _(!1), k = ["ArrowUp", "ArrowDown"], b = ["ArrowLeft", "ArrowRight"], y = h(() => (t.value ?? "").replace(/\D/g, "")), w = (a) => a <= 2 ? "mm" : a <= 5 ? "dd" : y.value.length <= 10 ? "yyyy" : "mm", L = h(() => {
362
+ function ze(e) {
363
+ const t = _(""), u = _(void 0), q = _(!!e.debug), I = _(e.dateFormat ?? "mm/dd/yyyy"), L = h(() => !!e.required), V = _(!1), A = ["ArrowUp", "ArrowDown"], k = ["ArrowLeft", "ArrowRight"], S = h(() => (t.value ?? "").replace(/\D/g, "")), g = (a) => a <= 2 ? "mm" : a <= 5 ? "dd" : S.value.length <= 10 ? "yyyy" : "mm", P = h(() => {
356
364
  const a = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0";
357
365
  return parseInt(a).toString().padStart(2, "0");
358
- }), D = h(() => {
366
+ }), E = h(() => {
359
367
  const a = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0";
360
368
  return parseInt(a).toString().padStart(2, "0");
361
- }), x = h(() => {
369
+ }), C = h(() => {
362
370
  const a = t.value && t.value.substring(6, 10).replace(/\D/g, "0") || "0";
363
371
  return parseInt(a).toString().padStart(4, "0");
364
- }), $ = (a) => {
365
- if (y.value.length === 0) {
372
+ }), T = (a) => {
373
+ if (S.value.length === 0) {
366
374
  e.onChange({ value: null, event: a });
367
375
  return;
368
376
  }
369
- if (y.value.length < 8) {
377
+ if (S.value.length < 8) {
370
378
  e.onChange({ value: null, event: a });
371
379
  return;
372
380
  }
373
- if ((t.value ?? "").length === 10 && y.value.length === 8) {
374
- const [d, I, te] = t.value.split("/"), r = parseInt(d), u = parseInt(I), v = parseInt(te);
375
- if (o(v, r, u)) {
376
- const M = new Date(v, r - 1, u);
377
- R(M) ? e.onChange({ value: M, event: a }) : e.onChange({ value: null, event: a });
381
+ if ((t.value ?? "").length === 10 && S.value.length === 8) {
382
+ const [d, M, r] = t.value.split("/"), i = parseInt(d), m = parseInt(M), w = parseInt(r);
383
+ if (G(w, i, m)) {
384
+ const B = new Date(w, i - 1, m);
385
+ U(B) ? e.onChange({ value: B, event: a }) : e.onChange({ value: null, event: a });
378
386
  } else
379
387
  e.onChange({ value: null, event: a });
380
388
  }
381
- }, R = (a) => {
382
- const d = e.min ?? void 0, I = e.max ?? void 0;
383
- return !(d && a < d || I && a > I);
389
+ }, U = (a) => {
390
+ const d = e.min ?? void 0, M = e.max ?? void 0;
391
+ return !(d && a < d || M && a > M);
384
392
  }, f = h(() => {
385
- if ((t.value ?? "").length === 10 && y.value.length === 8) {
386
- const [a, d, I] = (t.value ?? "").split("/"), te = parseInt(a), r = parseInt(d), u = parseInt(I);
387
- if (o(u, te, r))
388
- return new Date(u, te - 1, r);
393
+ if ((t.value ?? "").length === 10 && S.value.length === 8) {
394
+ const [a, d, M] = (t.value ?? "").split("/"), r = parseInt(a), i = parseInt(d), m = parseInt(M);
395
+ if (G(m, r, i))
396
+ return new Date(m, r - 1, i);
389
397
  }
390
398
  return null;
391
- }), g = h(() => (t.value ?? "").length === 10 && y.value.length === 8), F = (a, d) => new Date(a, d, 0).getDate(), o = (a, d, I) => d >= 1 && d <= 12 && a >= 1900 && I >= 1 && I <= F(a, d), m = (a) => {
399
+ }), y = h(() => (t.value ?? "").length === 10 && S.value.length === 8), O = (a, d) => new Date(a, d, 0).getDate(), G = (a, d, M) => d >= 1 && d <= 12 && a >= 1900 && M >= 1 && M <= O(a, d), o = (a) => {
392
400
  t.value = a.value;
393
401
  const d = a.event?.target;
394
- c.value = d?.selectionStart ?? 0, $(a);
395
- }, l = (a) => {
396
- c.value = a.target.selectionStart ?? 0;
397
- }, i = (a, d, I) => {
398
- const te = d?.selectionStart ?? c.value ?? 0;
399
- c.value = te;
400
- let r = parseInt(L.value), u = parseInt(D.value), v = parseInt(x.value);
401
- if (!(y.value.length >= 8) || !o(v, r, u)) {
402
- const z = e.defaultValue ?? /* @__PURE__ */ new Date();
403
- r = z.getMonth() + 1, u = z.getDate(), v = z.getFullYear(), t.value = `${String(r).padStart(2, "0")}/${String(u).padStart(
402
+ u.value = d?.selectionStart ?? 0, T(a);
403
+ }, p = (a) => {
404
+ u.value = a.target.selectionStart ?? 0;
405
+ }, l = (a, d, M) => {
406
+ const r = d?.selectionStart ?? u.value ?? 0;
407
+ u.value = r;
408
+ let i = parseInt(P.value), m = parseInt(E.value), w = parseInt(C.value);
409
+ if (!(S.value.length >= 8) || !G(w, i, m)) {
410
+ const K = e.defaultValue ?? /* @__PURE__ */ new Date();
411
+ i = K.getMonth() + 1, m = K.getDate(), w = K.getFullYear(), t.value = `${String(i).padStart(2, "0")}/${String(m).padStart(
404
412
  2,
405
413
  "0"
406
- )}/${String(v)}`;
407
- const O = new Date(v, r - 1, u);
408
- e.onChange({ value: R(O) ? O : null, event: I }), N(() => {
409
- requestAnimationFrame(() => {
410
- const X = document.getElementById(
411
- e.id
412
- ), Z = c.value ?? 0;
413
- X && (X.focus(), X.setSelectionRange(Z, Z));
414
- });
415
- });
414
+ )}/${String(w)}`;
415
+ const X = new Date(w, i - 1, m);
416
+ e.onChange({ value: U(X) ? X : null, event: M }), $({ useRAF: !0 });
416
417
  return;
417
418
  }
418
- const U = w(te);
419
- if (U === "mm")
420
- r = a === "ArrowUp" ? r < 12 ? r + 1 : 1 : r > 1 ? r - 1 : 12;
421
- else if (U === "dd") {
422
- const z = new Date(v, r, 0).getDate();
423
- u = a === "ArrowUp" ? u < z ? u + 1 : 1 : u > 1 ? u - 1 : z;
424
- } else U === "yyyy" && (v = a === "ArrowUp" ? v + 1 : Math.max(1, v - 1));
425
- t.value = `${String(r).padStart(2, "0")}/${String(u).padStart(
419
+ const Q = g(r);
420
+ if (Q === "mm")
421
+ i = a === "ArrowUp" ? i < 12 ? i + 1 : 1 : i > 1 ? i - 1 : 12;
422
+ else if (Q === "dd") {
423
+ const K = new Date(w, i, 0).getDate();
424
+ m = a === "ArrowUp" ? m < K ? m + 1 : 1 : m > 1 ? m - 1 : K;
425
+ } else Q === "yyyy" && (w = a === "ArrowUp" ? w + 1 : Math.max(1, w - 1));
426
+ t.value = `${String(i).padStart(2, "0")}/${String(m).padStart(
426
427
  2,
427
428
  "0"
428
- )}/${String(v)}`;
429
- const [ae, j, Y] = t.value.split("/"), ie = new Date(
430
- parseInt(Y),
431
- parseInt(ae) - 1,
432
- parseInt(j)
429
+ )}/${String(w)}`;
430
+ const [z, W, ie] = t.value.split("/"), le = new Date(
431
+ parseInt(ie),
432
+ parseInt(z) - 1,
433
+ parseInt(W)
433
434
  );
434
- ie.toString() !== "Invalid Date" && parseInt(Y) >= 1e3 ? e.onChange({
435
- value: R(ie) ? ie : null,
436
- event: I
437
- }) : e.onChange({ value: null, event: I }), N(() => {
438
- requestAnimationFrame(() => {
439
- const z = document.getElementById(
440
- e.id
441
- ), O = c.value ?? 0;
442
- z && (z.focus(), z.setSelectionRange(O, O));
443
- });
444
- });
445
- }, p = (a) => {
435
+ le.toString() !== "Invalid Date" && parseInt(ie) >= 1e3 ? e.onChange({
436
+ value: U(le) ? le : null,
437
+ event: M
438
+ }) : e.onChange({ value: null, event: M }), $({ useRAF: !0 });
439
+ }, s = (a) => {
446
440
  if (a.code === "Space" || a.key === " ") {
447
441
  e.onShowCalendar(a);
448
442
  return;
449
443
  }
450
- if (k.includes(a.key)) {
444
+ if (A.includes(a.key)) {
445
+ if (a.altKey) return;
451
446
  a.preventDefault();
452
447
  const d = a.target;
453
- i(a.key, d, a);
448
+ l(a.key, d, a);
454
449
  }
455
- }, A = (a) => {
450
+ }, v = (a) => {
456
451
  a.preventDefault();
457
452
  const d = a.deltaY < 0 ? "ArrowUp" : "ArrowDown";
458
- i(d, a.target, a);
459
- }, S = (a) => {
453
+ l(d, a.target, a);
454
+ }, b = (a) => {
460
455
  const d = a.target;
461
- if (b.includes(a.key)) {
462
- c.value = d?.selectionStart ?? 0;
456
+ if (k.includes(a.key)) {
457
+ u.value = d?.selectionStart ?? 0;
463
458
  return;
464
459
  }
465
- k.includes(a.key) && (a.preventDefault(), c.value = d?.selectionStart ?? 0);
466
- }, C = (a) => {
467
- W.value = !0, V.value && !e.defaultValue && e.externalValue && e.externalValue.value === void 0 && y.value.length === 0 && (e.externalValue.value = "");
460
+ if (A.includes(a.key)) {
461
+ if (a.altKey) return;
462
+ a.preventDefault(), u.value = d?.selectionStart ?? 0;
463
+ }
464
+ }, D = (a) => {
465
+ V.value = !0, L.value && !e.defaultValue && e.externalValue && e.externalValue.value === void 0 && S.value.length === 0 && (e.externalValue.value = "");
468
466
  const d = a.target;
469
- d && (c.value = d.selectionStart ?? 0);
467
+ d && (u.value = d.selectionStart ?? 0);
468
+ }, $ = (a) => {
469
+ const d = () => {
470
+ const M = document.getElementById(
471
+ e.id
472
+ );
473
+ if (!M) return;
474
+ const r = a?.pos ?? u.value ?? M.value.length;
475
+ try {
476
+ M.focus(), M.setSelectionRange(r, r);
477
+ } catch {
478
+ }
479
+ };
480
+ j(() => {
481
+ if (a?.delay && a.delay > 0) {
482
+ setTimeout(d, a.delay);
483
+ return;
484
+ }
485
+ if (a?.useRAF) {
486
+ requestAnimationFrame(d);
487
+ return;
488
+ }
489
+ d();
490
+ });
470
491
  };
471
492
  e.externalValue && ve(
472
493
  e.externalValue,
@@ -474,17 +495,17 @@ function _e(e) {
474
495
  if (a) {
475
496
  const d = new Date(a);
476
497
  if (d.toString() !== "Invalid Date") {
477
- const I = (d.getMonth() + 1).toString().padStart(2, "0"), te = d.getDate().toString().padStart(2, "0"), r = d.getFullYear().toString();
478
- t.value = `${I}/${te}/${r}`;
498
+ const M = (d.getMonth() + 1).toString().padStart(2, "0"), r = d.getDate().toString().padStart(2, "0"), i = d.getFullYear().toString();
499
+ t.value = `${M}/${r}/${i}`, $({ delay: 50 });
479
500
  return;
480
501
  }
481
502
  }
482
503
  },
483
504
  { immediate: !0 }
484
505
  );
485
- const G = h(() => [
486
- ["Date", `${L.value} / ${D.value} / ${x.value}`],
487
- ["Digits only", y.value],
506
+ const H = h(() => [
507
+ ["Date", `${P.value} / ${E.value} / ${C.value}`],
508
+ ["Digits only", S.value],
488
509
  [
489
510
  "min",
490
511
  e.min?.toLocaleDateString("en-US", {
@@ -501,50 +522,50 @@ function _e(e) {
501
522
  day: "2-digit"
502
523
  }) ?? null
503
524
  ]
504
- ]), oe = h(() => {
505
- if (!V.value) {
506
- if (!g.value) return !0;
525
+ ]), J = h(() => {
526
+ if (!L.value) {
527
+ if (!y.value) return !0;
507
528
  const d = f.value;
508
- return d ? R(d) : !1;
529
+ return d ? U(d) : !1;
509
530
  }
510
- if (!W.value) return !0;
531
+ if (!V.value) return !0;
511
532
  const a = f.value;
512
- return !g.value || !a ? !1 : R(a);
513
- }), Q = h(() => {
514
- if (!V.value) {
515
- if (!g.value) return;
533
+ return !y.value || !a ? !1 : U(a);
534
+ }), oe = h(() => {
535
+ if (!L.value) {
536
+ if (!y.value) return;
516
537
  const d = f.value;
517
- return d ? R(d) ? "valid" : "out-of-bounds" : "invalid-date";
538
+ return d ? U(d) ? "valid" : "out-of-bounds" : "invalid-date";
518
539
  }
519
- if (!W.value) return;
520
- if (y.value.length === 0 || !g.value)
540
+ if (!V.value) return;
541
+ if (S.value.length === 0 || !y.value)
521
542
  return "incomplete";
522
543
  const a = f.value;
523
- return a ? R(a) ? "valid" : "out-of-bounds" : "invalid-date";
524
- }), H = h(() => {
525
- const a = Q.value;
544
+ return a ? U(a) ? "valid" : "out-of-bounds" : "invalid-date";
545
+ }), F = h(() => {
546
+ const a = oe.value;
526
547
  if (!a || a === "valid") return "";
527
548
  if (a === "incomplete")
528
549
  return "Required";
529
550
  if (a === "invalid-date")
530
- return `Must be in ${T.value} format.`;
551
+ return `Must be in ${I.value} format.`;
531
552
  const d = e.min ? e.min.toLocaleDateString("en-US", {
532
553
  year: "numeric",
533
554
  month: "2-digit",
534
555
  day: "2-digit"
535
- }) : null, I = e.max ? e.max.toLocaleDateString("en-US", {
556
+ }) : null, M = e.max ? e.max.toLocaleDateString("en-US", {
536
557
  year: "numeric",
537
558
  month: "2-digit",
538
559
  day: "2-digit"
539
560
  }) : null;
540
561
  if (a === "out-of-bounds") {
541
- if (d && I) return `Must be between ${d} and ${I}.`;
562
+ if (d && M) return `Must be between ${d} and ${M}.`;
542
563
  if (d) return `Must be on or after ${d}.`;
543
- if (I) return `Must be on or before ${I}.`;
564
+ if (M) return `Must be on or before ${M}.`;
544
565
  }
545
566
  return "";
546
- }), J = () => {
547
- N(() => {
567
+ }), ne = () => {
568
+ j(() => {
548
569
  const a = document.getElementById(
549
570
  e.id
550
571
  );
@@ -553,80 +574,86 @@ function _e(e) {
553
574
  return;
554
575
  }
555
576
  const d = a.closest(".k-datepicker");
556
- if (d) {
557
- const I = d.parentElement;
558
- I ? I.classList.add("fk-datepicker") : console.warn(
559
- `Parent of .k-datepicker not found for #${e.id} styling.`
560
- );
561
- } else {
577
+ if (!d) {
562
578
  console.warn(`.k-datepicker parent not found for #${e.id} styling.`);
563
579
  return;
564
580
  }
581
+ const M = d.parentElement;
582
+ if (M) {
583
+ if (M.classList.contains("fk-datepicker"))
584
+ return;
585
+ M.classList.add("fk-datepicker");
586
+ } else
587
+ console.warn(
588
+ `Parent of .k-datepicker not found for #${e.id} styling.`
589
+ );
565
590
  });
566
591
  };
567
592
  return xe(() => {
568
- J();
593
+ ne();
569
594
  }), {
570
595
  raw: t,
571
- cursorPos: c,
572
- debugEnabled: P,
573
- debugLines: G,
574
- placeholder: T,
575
- isValid: oe,
576
- reason: K(Q),
577
- validationMessage: H,
578
- digitsOnly: y,
579
- month: K(L),
580
- day: K(D),
581
- year: K(x),
582
- datePart: w,
583
- handleChange: m,
584
- handleKeyDown: p,
585
- handleWheel: A,
586
- handleKeyUp: S,
587
- handleClick: l,
588
- handleBlur: C
596
+ cursorPos: u,
597
+ debugEnabled: q,
598
+ debugLines: H,
599
+ placeholder: I,
600
+ isValid: J,
601
+ reason: N(oe),
602
+ validationMessage: F,
603
+ digitsOnly: S,
604
+ month: N(P),
605
+ day: N(E),
606
+ year: N(C),
607
+ datePart: g,
608
+ handleChange: o,
609
+ handleKeyDown: s,
610
+ handleWheel: v,
611
+ handleKeyUp: b,
612
+ handleClick: p,
613
+ handleBlur: D,
614
+ // Expose so consumers can re-run styling when needed
615
+ initStyling: ne
589
616
  };
590
617
  }
591
- function Ge(e) {
592
- const t = _(""), c = _(void 0), P = _(!!e.debug), T = _(!1), W = 365 * (1440 * 60 * 1e3), k = /* @__PURE__ */ new Date(), b = new Date(k.getTime() - W), y = new Date(k.getTime() + W);
593
- e.min = e.min ?? b, e.max = e.max ?? y;
594
- const w = h(() => (t.value ?? "").replace(/\D/g, "")), L = (n, s) => new Date(n, s, 0).getDate(), D = (n, s, E) => s >= 1 && s <= 12 && n >= 1e3 && E >= 1 && E <= L(n, s), x = (n) => Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()), $ = (n) => {
618
+ function Xe(e) {
619
+ const t = _(""), u = _(void 0), q = _(!!e.debug), I = _(!1), V = 365 * (1440 * 60 * 1e3), A = /* @__PURE__ */ new Date(), k = new Date(A.getTime() - V), S = new Date(A.getTime() + V);
620
+ e.min = e.min ?? k, e.max = e.max ?? S;
621
+ const g = h(() => (t.value ?? "").replace(/\D/g, "")), P = (n, c) => new Date(n, c, 0).getDate(), E = (n, c, x) => c >= 1 && c <= 12 && n >= 1e3 && x >= 1 && x <= P(n, c), C = (n) => Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()), T = (n) => {
595
622
  if (!n) return null;
596
- const s = e.min, E = e.max, q = x(n);
597
- return q < x(s) || q > x(E) ? null : n;
598
- }, R = (n, s) => e.allowReverse ?? !1 ? !0 : n <= s, f = h(() => (t.value?.length ?? 0) >= 23 && w.value.length >= 16), g = (n) => {
599
- if ((n ?? "").length < 23 || w.value.length < 16)
623
+ const c = e.min, x = e.max, R = C(n);
624
+ return R < C(c) || R > C(x) ? null : n;
625
+ }, U = (n, c) => e.allowReverse ?? !1 ? !0 : n <= c, f = h(() => (t.value?.length ?? 0) >= 23 && g.value.length >= 16), y = (n) => {
626
+ if ((n ?? "").length < 23 || g.value.length < 16)
600
627
  return { start: null, end: null };
601
- const s = n.substring(0, 10), E = n.substring(13, 23), [q, ne, le] = s.split("/").map((se) => parseInt(se || "0", 10)), [ye, de, fe] = E.split("/").map((se) => parseInt(se || "0", 10)), me = new Date(le, q - 1, ne), he = new Date(fe, ye - 1, de), we = D(le, q, ne) && me.toString() !== "Invalid Date", ke = D(fe, ye, de) && he.toString() !== "Invalid Date";
628
+ const c = n.substring(0, 10), x = n.substring(13, 23), [R, ee, ae] = c.split("/").map((se) => parseInt(se || "0", 10)), [ge, de, fe] = x.split("/").map((se) => parseInt(se || "0", 10)), me = new Date(ae, R - 1, ee), he = new Date(fe, ge - 1, de), we = E(ae, R, ee) && me.toString() !== "Invalid Date", ke = E(fe, ge, de) && he.toString() !== "Invalid Date";
602
629
  return { start: we ? me : null, end: ke ? he : null };
603
- }, F = e.externalValid ?? _(!0), o = h(() => g(t.value)), m = h(() => {
604
- const n = $(o.value.start), s = $(o.value.end);
605
- return { start: n, end: s };
606
- }), l = h(() => {
630
+ }, O = e.externalValid ?? _(!0), G = h(() => y(t.value)), o = h(() => {
631
+ const n = T(G.value.start), c = T(G.value.end);
632
+ return { start: n, end: c };
633
+ }), p = h(() => {
607
634
  if (!f.value) return;
608
- const n = m.value.start, s = m.value.end;
609
- if (!n || !s) return;
610
- const E = Math.abs(x(s) - x(n));
611
- return Math.round(E / 864e5 + 1);
612
- }), i = h(() => {
635
+ const n = o.value.start, c = o.value.end;
636
+ if (!n || !c) return;
637
+ const x = Math.abs(C(c) - C(n));
638
+ return Math.round(x / 864e5 + 1);
639
+ }), l = h(() => {
613
640
  if (!f.value) return !1;
614
- const { start: n, end: s } = o.value;
615
- if (!n || !s || !m.value.start || !m.value.end) return !1;
616
- const E = m.value.start, q = m.value.end;
617
- return !(!R(E, q) || typeof e.maxSpanDays == "number" && l.value !== void 0 && l.value > e.maxSpanDays);
618
- }), p = h(() => {
619
- const { start: n, end: s } = o.value;
641
+ const { start: n, end: c } = G.value;
642
+ if (!n || !c || !o.value.start || !o.value.end) return !1;
643
+ const x = o.value.start, R = o.value.end;
644
+ return !(!U(x, R) || typeof e.maxSpanDays == "number" && p.value !== void 0 && p.value > e.maxSpanDays);
645
+ }), s = h(() => {
646
+ const { start: n, end: c } = G.value;
620
647
  if (!f.value) return "incomplete";
621
- if (!n || !s) return "invalid-date";
622
- if (!m.value.start || !m.value.end) return "out-of-bounds";
623
- const E = m.value.start, q = m.value.end;
624
- return R(E, q) ? typeof e.maxSpanDays == "number" && l.value !== void 0 && l.value > e.maxSpanDays ? "span-exceeds-limit" : "valid" : "reversed-range";
625
- }), A = _(void 0), S = h(() => {
626
- if (F.value !== !1) return "";
627
- const { min: n, max: s } = e, E = A.value;
628
- if (!E) return "";
629
- switch (E) {
648
+ if (!n || !c) return "invalid-date";
649
+ if (!o.value.start || !o.value.end) return "out-of-bounds";
650
+ const x = o.value.start, R = o.value.end;
651
+ return U(x, R) ? typeof e.maxSpanDays == "number" && p.value !== void 0 && p.value > e.maxSpanDays ? "span-exceeds-limit" : "valid" : "reversed-range";
652
+ }), v = _(void 0), b = h(() => {
653
+ if (O.value !== !1) return "";
654
+ const { min: n, max: c } = e, x = v.value;
655
+ if (!x) return "";
656
+ switch (x) {
630
657
  case "incomplete":
631
658
  return "Required";
632
659
  case "invalid-date":
@@ -634,90 +661,90 @@ function Ge(e) {
634
661
  case "reversed-range":
635
662
  return "End Date must be on or after Start Date.";
636
663
  case "out-of-bounds":
637
- return n && s ? `Dates must be between ${Q(n)} and ${Q(s)}.` : "Dates must be within the allowed range.";
664
+ return n && c ? `Dates must be between ${J(n)} and ${J(c)}.` : "Dates must be within the allowed range.";
638
665
  case "span-exceeds-limit":
639
666
  return typeof e.maxSpanDays == "number" ? `Date range exceeds ${e.maxSpanDays} days.` : "Date range exceeds maximum allowed span.";
640
667
  case "valid":
641
668
  default:
642
669
  return "";
643
670
  }
644
- }), C = ["ArrowUp", "ArrowDown"], G = ["ArrowLeft", "ArrowRight"], oe = (n, s) => String(n).padStart(s, "0"), Q = (n) => `${oe(n.getMonth() + 1, 2)}/${oe(n.getDate(), 2)}/${oe(
671
+ }), D = ["ArrowUp", "ArrowDown"], $ = ["ArrowLeft", "ArrowRight"], H = (n, c) => String(n).padStart(c, "0"), J = (n) => `${H(n.getMonth() + 1, 2)}/${H(n.getDate(), 2)}/${H(
645
672
  n.getFullYear(),
646
673
  4
647
- )}`, H = (n) => n <= 2 ? { side: "start", part: "mm" } : n <= 5 ? { side: "start", part: (n <= 3, "dd") } : n <= 11 ? { side: "start", part: "yyyy" } : n <= 15 ? { side: "end", part: "mm" } : n <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" }, J = (n, s, E) => {
648
- const q = s?.selectionStart ?? c.value ?? 0;
649
- c.value = q;
650
- const { start: ne, end: le } = g(t.value);
651
- if (!ne && !le) {
652
- const B = /* @__PURE__ */ new Date(), ue = Q(B);
653
- t.value = `${ue} - ${ue}`, e.onChange({ value: { start: B, end: B }, event: E }), N(() => {
674
+ )}`, oe = (n) => n <= 2 ? { side: "start", part: "mm" } : n <= 5 ? { side: "start", part: (n <= 3, "dd") } : n <= 11 ? { side: "start", part: "yyyy" } : n <= 15 ? { side: "end", part: "mm" } : n <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" }, F = (n, c, x) => {
675
+ const R = c?.selectionStart ?? u.value ?? 0;
676
+ u.value = R;
677
+ const { start: ee, end: ae } = y(t.value);
678
+ if (!ee && !ae) {
679
+ const Y = /* @__PURE__ */ new Date(), ue = J(Y);
680
+ t.value = `${ue} - ${ue}`, e.onChange({ value: { start: Y, end: Y }, event: x }), j(() => {
654
681
  requestAnimationFrame(() => {
655
- const ee = document.getElementById(
682
+ const Z = document.getElementById(
656
683
  e.id
657
- ), re = c.value ?? 0;
658
- ee && (ee.focus(), ee.setSelectionRange(re, re));
684
+ ), te = u.value ?? 0;
685
+ Z && (Z.focus(), Z.setSelectionRange(te, te));
659
686
  });
660
687
  });
661
688
  return;
662
689
  }
663
- const ye = /* @__PURE__ */ new Date(), de = H(q);
664
- let fe = ne ? new Date(ne) : new Date(ye), me = le ? new Date(le) : new Date(ye);
665
- const he = (B, ue) => {
690
+ const ge = /* @__PURE__ */ new Date(), de = oe(R);
691
+ let fe = ee ? new Date(ee) : new Date(ge), me = ae ? new Date(ae) : new Date(ge);
692
+ const he = (Y, ue) => {
666
693
  if (ue === "mm") {
667
- const ee = B.getMonth() + 1, re = n === "ArrowUp" ? ee < 12 ? ee + 1 : 1 : ee > 1 ? ee - 1 : 12;
668
- B.setMonth(re - 1);
669
- const be = L(B.getFullYear(), re);
670
- B.getDate() > be && B.setDate(be);
694
+ const Z = Y.getMonth() + 1, te = n === "ArrowUp" ? Z < 12 ? Z + 1 : 1 : Z > 1 ? Z - 1 : 12;
695
+ Y.setMonth(te - 1);
696
+ const Se = P(Y.getFullYear(), te);
697
+ Y.getDate() > Se && Y.setDate(Se);
671
698
  } else if (ue === "dd") {
672
- const ee = L(B.getFullYear(), B.getMonth() + 1), re = B.getDate(), be = n === "ArrowUp" ? re < ee ? re + 1 : 1 : re > 1 ? re - 1 : ee;
673
- B.setDate(be);
699
+ const Z = P(Y.getFullYear(), Y.getMonth() + 1), te = Y.getDate(), Se = n === "ArrowUp" ? te < Z ? te + 1 : 1 : te > 1 ? te - 1 : Z;
700
+ Y.setDate(Se);
674
701
  } else if (ue === "yyyy") {
675
- const ee = B.getFullYear();
676
- B.setFullYear(n === "ArrowUp" ? ee + 1 : Math.max(1, ee - 1));
677
- const re = L(B.getFullYear(), B.getMonth() + 1);
678
- B.getDate() > re && B.setDate(re);
702
+ const Z = Y.getFullYear();
703
+ Y.setFullYear(n === "ArrowUp" ? Z + 1 : Math.max(1, Z - 1));
704
+ const te = P(Y.getFullYear(), Y.getMonth() + 1);
705
+ Y.getDate() > te && Y.setDate(te);
679
706
  }
680
707
  };
681
708
  de.side === "start" ? he(fe, de.part) : he(me, de.part);
682
- const we = Q(fe), ke = Q(me);
709
+ const we = J(fe), ke = J(me);
683
710
  t.value = `${we} - ${ke}`;
684
- const se = $(fe), De = $(me);
685
- se && De && R(se, De) ? e.onChange({ value: { start: se, end: De }, event: E }) : e.onChange({ value: null, event: E }), N(() => {
711
+ const se = T(fe), De = T(me);
712
+ se && De && U(se, De) ? e.onChange({ value: { start: se, end: De }, event: x }) : e.onChange({ value: null, event: x }), j(() => {
686
713
  requestAnimationFrame(() => {
687
- const B = document.getElementById(
714
+ const Y = document.getElementById(
688
715
  e.id
689
- ), ue = c.value ?? 0;
690
- B && (B.focus(), B.setSelectionRange(ue, ue));
716
+ ), ue = u.value ?? 0;
717
+ Y && (Y.focus(), Y.setSelectionRange(ue, ue));
691
718
  });
692
719
  });
693
- }, a = (n) => {
694
- const { start: s, end: E } = g(t.value);
695
- if (!s || !E) {
720
+ }, ne = (n) => {
721
+ const { start: c, end: x } = y(t.value);
722
+ if (!c || !x) {
696
723
  e.onChange({ value: null, event: n });
697
724
  return;
698
725
  }
699
- const q = $(s), ne = $(E);
700
- if (!q || !ne) {
726
+ const R = T(c), ee = T(x);
727
+ if (!R || !ee) {
701
728
  e.onChange({ value: null, event: n });
702
729
  return;
703
730
  }
704
- if (!R(q, ne)) {
731
+ if (!U(R, ee)) {
705
732
  e.onChange({ value: null, event: n });
706
733
  return;
707
734
  }
708
- e.onChange({ value: { start: q, end: ne }, event: n });
709
- }, d = (n) => {
710
- const s = n.value ?? "", E = n.event;
711
- if (!s && E && E.type === "click") {
712
- U(E);
735
+ e.onChange({ value: { start: R, end: ee }, event: n });
736
+ }, a = (n) => {
737
+ const c = n.value ?? "", x = n.event;
738
+ if (!c && x && x.type === "click") {
739
+ B(x);
713
740
  return;
714
741
  }
715
- t.value = s;
716
- const q = E?.target;
717
- c.value = q?.selectionStart ?? 0, a(n);
718
- }, I = (n) => {
719
- c.value = n.target.selectionStart ?? 0;
720
- }, te = (n) => {
742
+ t.value = c;
743
+ const R = x?.target;
744
+ u.value = R?.selectionStart ?? 0, ne(n);
745
+ }, d = (n) => {
746
+ u.value = n.target.selectionStart ?? 0;
747
+ }, M = (n) => {
721
748
  if (n.code === "Space" || n.key === " ") {
722
749
  n.preventDefault(), e.onShowCalendar(n);
723
750
  return;
@@ -726,63 +753,63 @@ function Ge(e) {
726
753
  n.preventDefault(), e.onShowCalendar(n);
727
754
  return;
728
755
  }
729
- if (C.includes(n.key)) {
756
+ if (D.includes(n.key)) {
730
757
  n.preventDefault();
731
- const s = n.target;
732
- J(n.key, s, n);
758
+ const c = n.target;
759
+ F(n.key, c, n);
733
760
  }
734
761
  }, r = (n) => {
735
762
  n.preventDefault();
736
- const s = n.deltaY < 0 ? "ArrowUp" : "ArrowDown";
737
- J(s, n.target, n);
738
- }, u = (n) => {
739
- if (G.includes(n.key) || C.includes(n.key)) {
763
+ const c = n.deltaY < 0 ? "ArrowUp" : "ArrowDown";
764
+ F(c, n.target, n);
765
+ }, i = (n) => {
766
+ if ($.includes(n.key) || D.includes(n.key)) {
740
767
  n.preventDefault();
741
- const s = n.target;
742
- c.value = s?.selectionStart ?? 0;
768
+ const c = n.target;
769
+ u.value = c?.selectionStart ?? 0;
743
770
  }
744
- }, v = () => {
745
- A.value = p.value, (e.manageValid ?? !0) && (F.value = i.value);
746
- }, M = (n) => {
747
- v();
748
- }, U = (n) => {
749
- console.log("Clear event:", n), t.value = "", c.value = 0, e.onChange({ value: null, event: n }), v(), N(() => {
750
- const s = document.getElementById(
771
+ }, m = () => {
772
+ v.value = s.value, (e.manageValid ?? !0) && (O.value = l.value);
773
+ }, w = (n) => {
774
+ m();
775
+ }, B = (n) => {
776
+ console.log("Clear event:", n), t.value = "", u.value = 0, e.onChange({ value: null, event: n }), m(), j(() => {
777
+ const c = document.getElementById(
751
778
  e.id
752
779
  );
753
- s && (s.focus(), s.setSelectionRange(0, 0));
780
+ c && (c.focus(), c.setSelectionRange(0, 0));
754
781
  });
755
782
  };
756
783
  e.externalValue && ve(
757
784
  e.externalValue,
758
785
  (n) => {
759
- const s = n?.start ?? null, E = n?.end ?? null;
760
- if (s && E) {
761
- if (t.value = `${Q(s)} - ${Q(E)}`, e.isOpen?.value && T.value && e.onRequestClose) {
762
- const q = typeof e.closeDelay == "number" ? e.closeDelay : e.closeDelay?.value ?? 0;
786
+ const c = n?.start ?? null, x = n?.end ?? null;
787
+ if (c && x) {
788
+ if (t.value = `${J(c)} - ${J(x)}`, e.isOpen?.value && I.value && e.onRequestClose) {
789
+ const R = typeof e.closeDelay == "number" ? e.closeDelay : e.closeDelay?.value ?? 0;
763
790
  setTimeout(() => {
764
- e.onRequestClose?.(), T.value = !1, v();
765
- }, q);
791
+ e.onRequestClose?.(), I.value = !1, m();
792
+ }, R);
766
793
  }
767
794
  return;
768
795
  }
769
796
  },
770
797
  { immediate: !0 }
771
798
  );
772
- const ae = h(
799
+ const Q = h(
773
800
  () => t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0"
774
- ), j = h(
801
+ ), z = h(
775
802
  () => t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0"
776
- ), Y = h(
803
+ ), W = h(
777
804
  () => t.value && t.value.substring(6, 10).replace(/\D/g, "0") || "0"
778
805
  ), ie = h(
779
806
  () => t.value && t.value.substring(13, 15).replace(/\D/g, "0") || "0"
780
- ), z = h(
807
+ ), le = h(
781
808
  () => t.value && t.value.substring(16, 18).replace(/\D/g, "0") || "0"
782
- ), O = h(
809
+ ), K = h(
783
810
  () => t.value && t.value.substring(19, 23).replace(/\D/g, "0") || "0"
784
811
  ), X = h(() => {
785
- const { start: n, end: s } = g(t.value);
812
+ const { start: n, end: c } = y(t.value);
786
813
  return [
787
814
  {
788
815
  label: "Raw",
@@ -798,70 +825,74 @@ function Ge(e) {
798
825
  },
799
826
  {
800
827
  label: "Start",
801
- value: `${String(ae.value).padStart(2, "0")} / ${String(
802
- j.value
803
- ).padStart(2, "0")} / ${String(Y.value).padStart(4, "0")}`
828
+ value: `${String(Q.value).padStart(2, "0")} / ${String(
829
+ z.value
830
+ ).padStart(2, "0")} / ${String(W.value).padStart(4, "0")}`
804
831
  },
805
832
  {
806
833
  label: "End",
807
834
  value: `${String(ie.value).padStart(2, "0")} / ${String(
808
- z.value
809
- ).padStart(2, "0")} / ${String(O.value).padStart(4, "0")}`
835
+ le.value
836
+ ).padStart(2, "0")} / ${String(K.value).padStart(4, "0")}`
810
837
  },
811
- { label: "Digits only", value: w.value },
838
+ { label: "Digits only", value: g.value },
812
839
  { label: "Mask complete", value: `${f.value}` },
813
840
  {
814
841
  label: "Parsed",
815
- value: `${n ? n.toDateString() : "-"} | ${s ? s.toDateString() : "-"}`
842
+ value: `${n ? n.toDateString() : "-"} | ${c ? c.toDateString() : "-"}`
816
843
  },
817
844
  {
818
845
  label: "Valid (managed)",
819
- value: `${F.value ?? "-"}`
846
+ value: `${O.value ?? "-"}`
820
847
  },
821
- { label: "Span (days)", value: `${l.value ?? "-"}` },
848
+ { label: "Span (days)", value: `${p.value ?? "-"}` },
822
849
  {
823
850
  label: "Reason",
824
- value: `${p.value ?? "-"}`
851
+ value: `${s.value ?? "-"}`
825
852
  },
826
853
  {
827
854
  label: "Cursor in",
828
- value: `${c.value ?? "-"} (${(() => {
829
- const E = c.value ?? 0, q = H(E);
830
- return `${q.side}.${q.part}`;
855
+ value: `${u.value ?? "-"} (${(() => {
856
+ const x = u.value ?? 0, R = oe(x);
857
+ return `${R.side}.${R.part}`;
831
858
  })()})`
832
859
  }
833
860
  ];
834
- }), Z = () => {
835
- N(() => {
861
+ }), re = () => {
862
+ j(() => {
836
863
  const n = document.getElementById(e.id);
837
864
  if (!n) {
838
865
  console.warn(`#${e.id} not found for styling.`);
839
866
  return;
840
867
  }
841
- const s = n.closest("div");
842
- s ? s.classList.add("fk-daterangepicker") : console.warn(`Parent div of #${e.id} not found for styling.`);
868
+ const c = n.closest("div");
869
+ if (!c) {
870
+ console.warn(`Parent div of #${e.id} not found for styling.`);
871
+ return;
872
+ }
873
+ c.classList.contains("fk-daterangepicker") || c.classList.add("fk-daterangepicker");
843
874
  });
844
875
  };
845
876
  xe(() => {
846
- Z();
877
+ re();
847
878
  });
848
- const ge = () => {
849
- N(() => {
879
+ const ye = () => {
880
+ j(() => {
850
881
  try {
851
882
  const n = Array.from(
852
883
  document.querySelectorAll(".k-animation-container")
853
884
  );
854
885
  if (!n.length) return;
855
- const E = [...n].reverse().find((le) => le.querySelector(".k-calendar"))?.querySelector(
886
+ const x = [...n].reverse().find((ae) => ae.querySelector(".k-calendar"))?.querySelector(
856
887
  ".k-calendar"
857
888
  );
858
- if (!E) return;
859
- const q = E.querySelectorAll(
889
+ if (!x) return;
890
+ const R = x.querySelectorAll(
860
891
  ".k-calendar-table"
861
892
  );
862
- let ne = !1;
863
- q.forEach((le) => {
864
- le.tabIndex === 0 && (ne ? le.tabIndex = -1 : ne = !0);
893
+ let ee = !1;
894
+ R.forEach((ae) => {
895
+ ae.tabIndex === 0 && (ee ? ae.tabIndex = -1 : ee = !0);
865
896
  });
866
897
  } catch (n) {
867
898
  console.warn(n);
@@ -871,224 +902,225 @@ function Ge(e) {
871
902
  return e.isOpen && ve(
872
903
  e.isOpen,
873
904
  (n) => {
874
- n && setTimeout(() => ge(), 0);
905
+ n && setTimeout(() => ye(), 0);
875
906
  },
876
907
  { immediate: !1 }
877
908
  ), {
878
909
  raw: t,
879
- cursorPos: c,
880
- debugEnabled: P,
910
+ cursorPos: u,
911
+ debugEnabled: q,
881
912
  debugLines: X,
882
- digitsOnly: w,
883
- valid: F,
884
- validComputed: K(i),
885
- reason: K(p),
886
- validationMessage: K(S),
887
- spanDays: K(l),
888
- month1: K(ae),
889
- day1: K(j),
890
- year1: K(Y),
891
- month2: K(ie),
892
- day2: K(z),
893
- year2: K(O),
894
- handleChange: d,
895
- handleKeyDown: te,
913
+ digitsOnly: g,
914
+ valid: O,
915
+ validComputed: N(l),
916
+ reason: N(s),
917
+ validationMessage: N(b),
918
+ spanDays: N(p),
919
+ month1: N(Q),
920
+ day1: N(z),
921
+ year1: N(W),
922
+ month2: N(ie),
923
+ day2: N(le),
924
+ year2: N(K),
925
+ handleChange: a,
926
+ handleKeyDown: M,
896
927
  handleWheel: r,
897
- handleKeyUp: u,
898
- handleClick: I,
899
- handleBlur: M,
900
- handleClear: U,
928
+ handleKeyUp: i,
929
+ handleClick: d,
930
+ handleBlur: w,
931
+ handleClear: B,
901
932
  onCalendarChange: () => {
902
- T.value = !0;
903
- }
933
+ I.value = !0;
934
+ },
935
+ initStyling: re
904
936
  };
905
937
  }
906
- function je(e) {
907
- const t = _(""), c = _(void 0), P = _(!!e.debug), T = _(e.timeFormat ?? "hh:mm AM"), V = h(() => !!e.required), W = _(!1), k = ["ArrowUp", "ArrowDown"], b = ["ArrowLeft", "ArrowRight"], y = h(() => (t.value ?? "").replace(/\D/g, "")), w = {
938
+ function Je(e) {
939
+ const t = _(""), u = _(void 0), q = _(!!e.debug), I = _(e.timeFormat ?? "hh:mm AM"), L = h(() => !!e.required), V = _(!1), A = ["ArrowUp", "ArrowDown"], k = ["ArrowLeft", "ArrowRight"], S = h(() => (t.value ?? "").replace(/\D/g, "")), g = {
908
940
  H: /[0-9]/,
909
941
  h: /[0-9]/,
910
942
  M: /[0-9]/,
911
943
  m: /[0-9]/,
912
944
  A: /[AaPp]/,
913
945
  a: /[Mm]/
914
- }, L = (r) => r <= 2 ? "hh" : r <= 5 ? "mm" : "ampm", D = h(() => {
915
- const r = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0", u = parseInt(r);
916
- return Math.min(Math.max(u, 0), 23);
917
- }), x = h(() => {
918
- const r = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0", u = parseInt(r);
919
- return Math.min(Math.max(u, 0), 59);
920
- }), $ = h(() => (t.value?.substring(6, 8) || "AM").toUpperCase().startsWith("P") ? "PM" : "AM"), R = h(() => {
921
- const r = parseInt(t.value?.substring(0, 2).replace(/\D/g, "0") || "0"), u = $.value;
922
- return r === 12 ? u === "AM" ? 0 : 12 : u === "PM" ? r + 12 : r;
923
- }), f = h(() => g.value ? `${String(R.value).padStart(2, "0")}:${String(x.value).padStart(2, "0")}:00` : null), g = h(
946
+ }, P = (r) => r <= 2 ? "hh" : r <= 5 ? "mm" : "ampm", E = h(() => {
947
+ const r = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0", i = parseInt(r);
948
+ return Math.min(Math.max(i, 0), 23);
949
+ }), C = h(() => {
950
+ const r = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0", i = parseInt(r);
951
+ return Math.min(Math.max(i, 0), 59);
952
+ }), T = h(() => (t.value?.substring(6, 8) || "AM").toUpperCase().startsWith("P") ? "PM" : "AM"), U = h(() => {
953
+ const r = parseInt(t.value?.substring(0, 2).replace(/\D/g, "0") || "0"), i = T.value;
954
+ return r === 12 ? i === "AM" ? 0 : 12 : i === "PM" ? r + 12 : r;
955
+ }), f = h(() => y.value ? `${String(U.value).padStart(2, "0")}:${String(C.value).padStart(2, "0")}:00` : null), y = h(
924
956
  () => /^(\d{2}):(\d{2})\s([AP]M)$/i.test(t.value ?? "")
925
- ), F = (r, u, v) => {
926
- let M = r % 12;
927
- return M === 0 && (M = 12), `${String(M).padStart(2, "0")}:${String(u).padStart(
957
+ ), O = (r, i, m) => {
958
+ let w = r % 12;
959
+ return w === 0 && (w = 12), `${String(w).padStart(2, "0")}:${String(i).padStart(
928
960
  2,
929
961
  "0"
930
- )} ${v}`;
962
+ )} ${m}`;
963
+ }, G = (r) => {
964
+ const i = r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
965
+ if (!i) return null;
966
+ const m = parseInt(i[1]), w = parseInt(i[2]), B = i[3].toUpperCase();
967
+ if (m < 1 || m > 12 || w < 0 || w > 59) return null;
968
+ let Q = m % 12;
969
+ B === "PM" && (Q += 12);
970
+ const z = /* @__PURE__ */ new Date();
971
+ return z.setSeconds(0, 0), z.setHours(Q), z.setMinutes(w), z;
931
972
  }, o = (r) => {
932
- const u = r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
933
- if (!u) return null;
934
- const v = parseInt(u[1]), M = parseInt(u[2]), U = u[3].toUpperCase();
935
- if (v < 1 || v > 12 || M < 0 || M > 59) return null;
936
- let ae = v % 12;
937
- U === "PM" && (ae += 12);
938
- const j = /* @__PURE__ */ new Date();
939
- return j.setSeconds(0, 0), j.setHours(ae), j.setMinutes(M), j;
940
- }, m = (r) => {
941
- if (y.value.length === 0) {
973
+ if (S.value.length === 0) {
942
974
  e.onChange({ value: null, event: r });
943
975
  return;
944
976
  }
945
- if (!g.value) {
977
+ if (!y.value) {
946
978
  e.onChange({ value: null, event: r });
947
979
  return;
948
980
  }
949
- const u = o(t.value);
950
- u && i(u) ? e.onChange({ value: u, event: r }) : e.onChange({ value: null, event: r });
951
- }, l = (r) => r.getHours() * 60 + r.getMinutes(), i = (r) => {
952
- const u = e.min ?? void 0, v = e.max ?? void 0, M = l(r);
953
- if (u) {
954
- const U = l(u);
955
- if (M < U) return !1;
981
+ const i = G(t.value);
982
+ i && l(i) ? e.onChange({ value: i, event: r }) : e.onChange({ value: null, event: r });
983
+ }, p = (r) => r.getHours() * 60 + r.getMinutes(), l = (r) => {
984
+ const i = e.min ?? void 0, m = e.max ?? void 0, w = p(r);
985
+ if (i) {
986
+ const B = p(i);
987
+ if (w < B) return !1;
956
988
  }
957
- if (v) {
958
- const U = l(v);
959
- if (M > U) return !1;
989
+ if (m) {
990
+ const B = p(m);
991
+ if (w > B) return !1;
960
992
  }
961
993
  return !0;
962
- }, p = (r) => {
994
+ }, s = (r) => {
963
995
  t.value = r.value;
964
- const u = r.event?.target;
965
- c.value = u?.selectionStart ?? 0;
996
+ const i = r.event?.target;
997
+ u.value = i?.selectionStart ?? 0;
966
998
  try {
967
- const v = c.value ?? 0;
968
- if (L(v) === "ampm" && (t.value ?? "").length >= 8) {
969
- const M = t.value.charAt(6);
970
- /[Aa]/.test(M) ? (t.value = `${t.value.slice(0, 6)}AM${t.value.slice(8)}`, N(() => {
999
+ const m = u.value ?? 0;
1000
+ if (P(m) === "ampm" && (t.value ?? "").length >= 8) {
1001
+ const w = t.value.charAt(6);
1002
+ /[Aa]/.test(w) ? (t.value = `${t.value.slice(0, 6)}AM${t.value.slice(8)}`, j(() => {
971
1003
  requestAnimationFrame(() => {
972
- const U = document.getElementById(
1004
+ const B = document.getElementById(
973
1005
  e.id
974
1006
  );
975
- U && (U.focus(), U.setSelectionRange(8, 8));
1007
+ B && (B.focus(), B.setSelectionRange(8, 8));
976
1008
  });
977
- })) : /[Pp]/.test(M) && (t.value = `${t.value.slice(0, 6)}PM${t.value.slice(8)}`, N(() => {
1009
+ })) : /[Pp]/.test(w) && (t.value = `${t.value.slice(0, 6)}PM${t.value.slice(8)}`, j(() => {
978
1010
  requestAnimationFrame(() => {
979
- const U = document.getElementById(
1011
+ const B = document.getElementById(
980
1012
  e.id
981
1013
  );
982
- U && (U.focus(), U.setSelectionRange(8, 8));
1014
+ B && (B.focus(), B.setSelectionRange(8, 8));
983
1015
  });
984
1016
  }));
985
1017
  }
986
1018
  } catch {
987
1019
  }
988
- m(r);
989
- }, A = (r) => {
990
- c.value = r.target.selectionStart ?? 0;
991
- }, S = (r, u, v) => {
992
- const M = u?.selectionStart ?? c.value ?? 0;
993
- c.value = M;
994
- const U = L(M), ae = (t.value ?? "").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
995
- if (!ae) {
996
- if ((t.value ?? "").length === 0 || y.value.length === 0) {
997
- const O = /* @__PURE__ */ new Date(), X = O.getHours(), Z = X >= 12 ? "PM" : "AM";
998
- t.value = F(X, O.getMinutes(), Z);
999
- const ge = o(t.value);
1000
- ge && i(ge) ? e.onChange({ value: ge, event: v }) : e.onChange({ value: null, event: v }), N(() => {
1020
+ o(r);
1021
+ }, v = (r) => {
1022
+ u.value = r.target.selectionStart ?? 0;
1023
+ }, b = (r, i, m) => {
1024
+ const w = i?.selectionStart ?? u.value ?? 0;
1025
+ u.value = w;
1026
+ const B = P(w), Q = (t.value ?? "").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
1027
+ if (!Q) {
1028
+ if ((t.value ?? "").length === 0 || S.value.length === 0) {
1029
+ const K = /* @__PURE__ */ new Date(), X = K.getHours(), re = X >= 12 ? "PM" : "AM";
1030
+ t.value = O(X, K.getMinutes(), re);
1031
+ const ye = G(t.value);
1032
+ ye && l(ye) ? e.onChange({ value: ye, event: m }) : e.onChange({ value: null, event: m }), j(() => {
1001
1033
  requestAnimationFrame(() => {
1002
1034
  const n = document.getElementById(
1003
1035
  e.id
1004
- ), s = c.value ?? 0;
1005
- n && (n.focus(), n.setSelectionRange(s, s));
1036
+ ), c = u.value ?? 0;
1037
+ n && (n.focus(), n.setSelectionRange(c, c));
1006
1038
  });
1007
1039
  });
1008
1040
  }
1009
1041
  return;
1010
1042
  }
1011
- let j = parseInt(ae[1]), Y = parseInt(ae[2]), ie = ae[3].toUpperCase();
1012
- if (U === "hh")
1013
- r === "ArrowUp" ? j = j < 12 ? j + 1 : 1 : j = j > 1 ? j - 1 : 12;
1014
- else if (U === "mm") {
1015
- const O = e.minuteStepRef?.value ?? e.minuteStep ?? 1;
1016
- if (O === 1)
1017
- r === "ArrowUp" ? Y = Y < 59 ? Y + 1 : 0 : Y = Y > 0 ? Y - 1 : 59;
1043
+ let z = parseInt(Q[1]), W = parseInt(Q[2]), ie = Q[3].toUpperCase();
1044
+ if (B === "hh")
1045
+ r === "ArrowUp" ? z = z < 12 ? z + 1 : 1 : z = z > 1 ? z - 1 : 12;
1046
+ else if (B === "mm") {
1047
+ const K = e.minuteStepRef?.value ?? e.minuteStep ?? 1;
1048
+ if (K === 1)
1049
+ r === "ArrowUp" ? W = W < 59 ? W + 1 : 0 : W = W > 0 ? W - 1 : 59;
1018
1050
  else if (r === "ArrowUp") {
1019
- const X = Y % O;
1020
- let Z = X === 0 ? Y + O : Y + (O - X);
1021
- Z >= 60 && (Z = 0), Y = Z;
1051
+ const X = W % K;
1052
+ let re = X === 0 ? W + K : W + (K - X);
1053
+ re >= 60 && (re = 0), W = re;
1022
1054
  } else {
1023
- const X = Y % O;
1024
- let Z = X === 0 ? Y - O : Y - X;
1025
- Z < 0 && (Z = 60 - O), Y = Z;
1055
+ const X = W % K;
1056
+ let re = X === 0 ? W - K : W - X;
1057
+ re < 0 && (re = 60 - K), W = re;
1026
1058
  }
1027
- } else U === "ampm" && (ie = ie === "AM" ? "PM" : "AM");
1028
- t.value = `${String(j).padStart(2, "0")}:${String(Y).padStart(
1059
+ } else B === "ampm" && (ie = ie === "AM" ? "PM" : "AM");
1060
+ t.value = `${String(z).padStart(2, "0")}:${String(W).padStart(
1029
1061
  2,
1030
1062
  "0"
1031
1063
  )} ${ie}`;
1032
- const z = o(t.value);
1033
- z && i(z) ? e.onChange({ value: z, event: v }) : e.onChange({ value: null, event: v }), N(() => {
1064
+ const le = G(t.value);
1065
+ le && l(le) ? e.onChange({ value: le, event: m }) : e.onChange({ value: null, event: m }), j(() => {
1034
1066
  requestAnimationFrame(() => {
1035
- const O = document.getElementById(
1067
+ const K = document.getElementById(
1036
1068
  e.id
1037
- ), X = c.value ?? 0;
1038
- O && (O.focus(), O.setSelectionRange(X, X));
1069
+ ), X = u.value ?? 0;
1070
+ K && (K.focus(), K.setSelectionRange(X, X));
1039
1071
  });
1040
1072
  });
1041
- }, C = (r) => {
1073
+ }, D = (r) => {
1042
1074
  if (r.code === "Space" || r.key === " ") {
1043
1075
  e.onShowPicker(r);
1044
1076
  return;
1045
1077
  }
1046
- if (k.includes(r.key)) {
1078
+ if (A.includes(r.key)) {
1047
1079
  r.preventDefault();
1048
- const u = r.target;
1049
- S(r.key, u, r);
1080
+ const i = r.target;
1081
+ b(r.key, i, r);
1050
1082
  }
1051
- }, G = (r) => {
1083
+ }, $ = (r) => {
1052
1084
  r.preventDefault();
1053
- const u = r.deltaY < 0 ? "ArrowUp" : "ArrowDown";
1054
- S(u, r.target, r);
1055
- }, oe = (r) => {
1056
- const u = r.target;
1057
- if (b.includes(r.key)) {
1058
- c.value = u?.selectionStart ?? 0;
1085
+ const i = r.deltaY < 0 ? "ArrowUp" : "ArrowDown";
1086
+ b(i, r.target, r);
1087
+ }, H = (r) => {
1088
+ const i = r.target;
1089
+ if (k.includes(r.key)) {
1090
+ u.value = i?.selectionStart ?? 0;
1059
1091
  return;
1060
1092
  }
1061
- k.includes(r.key) && (r.preventDefault(), c.value = u?.selectionStart ?? 0);
1062
- }, Q = (r) => {
1063
- W.value = !0, V.value && e.externalValue && e.externalValue.value === void 0 && y.value.length === 0 && (e.externalValue.value = "");
1064
- const u = r.target;
1065
- u && (c.value = u.selectionStart ?? 0);
1093
+ A.includes(r.key) && (r.preventDefault(), u.value = i?.selectionStart ?? 0);
1094
+ }, J = (r) => {
1095
+ V.value = !0, L.value && e.externalValue && e.externalValue.value === void 0 && S.value.length === 0 && (e.externalValue.value = "");
1096
+ const i = r.target;
1097
+ i && (u.value = i.selectionStart ?? 0);
1066
1098
  };
1067
1099
  e.externalValue && ve(
1068
1100
  e.externalValue,
1069
1101
  (r) => {
1070
1102
  if (r) {
1071
- const u = new Date(r);
1072
- if (u.toString() !== "Invalid Date") {
1073
- const v = u.getHours(), M = v >= 12 ? "PM" : "AM";
1074
- t.value = F(v, u.getMinutes(), M);
1103
+ const i = new Date(r);
1104
+ if (i.toString() !== "Invalid Date") {
1105
+ const m = i.getHours(), w = m >= 12 ? "PM" : "AM";
1106
+ t.value = O(m, i.getMinutes(), w);
1075
1107
  return;
1076
1108
  }
1077
1109
  }
1078
1110
  },
1079
1111
  { immediate: !0 }
1080
1112
  );
1081
- const H = h(() => [
1113
+ const oe = h(() => [
1082
1114
  ["Time", t.value || "--:-- --"],
1083
- ["Hour (12h)", D.value],
1084
- ["Hour (24h)", R.value],
1085
- ["Minute", x.value],
1086
- ["Period", $.value],
1115
+ ["Hour (12h)", E.value],
1116
+ ["Hour (24h)", U.value],
1117
+ ["Minute", C.value],
1118
+ ["Period", T.value],
1087
1119
  ["Time (24h)", f.value ?? "--:--:--"],
1088
- ["Digits only", y.value],
1120
+ ["Digits only", S.value],
1089
1121
  [
1090
1122
  "Parsed Date",
1091
- J.value?.toLocaleDateString("en-US", {
1123
+ F.value?.toLocaleDateString("en-US", {
1092
1124
  hour: "2-digit",
1093
1125
  minute: "2-digit"
1094
1126
  }) ?? null
@@ -1107,303 +1139,325 @@ function je(e) {
1107
1139
  minute: "2-digit"
1108
1140
  }) ?? null
1109
1141
  ],
1110
- ["valid", a.value],
1111
- ["reason", d.value],
1112
- ["validationMessage", I.value]
1113
- ]), J = h(
1114
- () => o(t.value) ?? null
1115
- ), a = h(() => {
1116
- if (!V.value) {
1117
- if (!g.value) return !0;
1118
- const u = J.value;
1119
- return u ? i(u) : !1;
1142
+ ["valid", ne.value],
1143
+ ["reason", a.value],
1144
+ ["validationMessage", d.value]
1145
+ ]), F = h(
1146
+ () => G(t.value) ?? null
1147
+ ), ne = h(() => {
1148
+ if (!L.value) {
1149
+ if (!y.value) return !0;
1150
+ const i = F.value;
1151
+ return i ? l(i) : !1;
1120
1152
  }
1121
- if (!W.value) return !0;
1122
- const r = J.value;
1123
- return !g.value || !r ? !1 : i(r);
1124
- }), d = h(() => {
1125
- if (!V.value) {
1126
- if (!g.value) return;
1127
- const u = J.value;
1128
- return u ? i(u) ? "valid" : "out-of-bounds" : "invalid-time";
1153
+ if (!V.value) return !0;
1154
+ const r = F.value;
1155
+ return !y.value || !r ? !1 : l(r);
1156
+ }), a = h(() => {
1157
+ if (!L.value) {
1158
+ if (!y.value) return;
1159
+ const i = F.value;
1160
+ return i ? l(i) ? "valid" : "out-of-bounds" : "invalid-time";
1129
1161
  }
1130
- if (!W.value) return;
1131
- if (y.value.length === 0 || !g.value)
1162
+ if (!V.value) return;
1163
+ if (S.value.length === 0 || !y.value)
1132
1164
  return "incomplete";
1133
- const r = J.value;
1134
- return r ? i(r) ? "valid" : "out-of-bounds" : "invalid-time";
1135
- }), I = h(() => {
1136
- const r = d.value;
1165
+ const r = F.value;
1166
+ return r ? l(r) ? "valid" : "out-of-bounds" : "invalid-time";
1167
+ }), d = h(() => {
1168
+ const r = a.value;
1137
1169
  if (!r || r === "valid") return "";
1138
1170
  if (r === "incomplete")
1139
1171
  return "Required";
1140
1172
  if (r === "invalid-time")
1141
- return `Must be in ${T.value} format.`;
1142
- const u = {
1173
+ return `Must be in ${I.value} format.`;
1174
+ const i = {
1143
1175
  hour: "2-digit",
1144
1176
  minute: "2-digit"
1145
- }, v = e.min ? e.min.toLocaleTimeString("en-US", u) : null, M = e.max ? e.max.toLocaleTimeString("en-US", u) : null;
1177
+ }, m = e.min ? e.min.toLocaleTimeString("en-US", i) : null, w = e.max ? e.max.toLocaleTimeString("en-US", i) : null;
1146
1178
  if (r === "out-of-bounds") {
1147
- if (v && M) return `Must be between ${v} and ${M}.`;
1148
- if (v) return `Must be ${v} or later.`;
1149
- if (M) return `Must be ${M} or earlier.`;
1179
+ if (m && w) return `Must be between ${m} and ${w}.`;
1180
+ if (m) return `Must be ${m} or later.`;
1181
+ if (w) return `Must be ${w} or earlier.`;
1150
1182
  }
1151
1183
  return "";
1152
- }), te = () => {
1153
- N(() => {
1184
+ }), M = () => {
1185
+ j(() => {
1154
1186
  const r = document.getElementById(e.id);
1155
1187
  if (!r) {
1156
1188
  console.warn(`#${e.id} not found for styling.`);
1157
1189
  return;
1158
1190
  }
1159
- const u = r.closest(".k-timepicker");
1160
- if (!u)
1191
+ const i = r.closest(".k-timepicker");
1192
+ if (!i) {
1161
1193
  console.warn(
1162
1194
  `.k-timepicker parent of #${e.id} not found for styling.`
1163
1195
  );
1164
- else {
1165
- const v = u.parentElement;
1166
- v ? v.classList.add("fk-timepicker") : console.warn(
1196
+ return;
1197
+ }
1198
+ const m = i.parentElement;
1199
+ if (!m) {
1200
+ console.warn(
1167
1201
  `Parent of .k-timepicker not found for #${e.id} styling.`
1168
1202
  );
1203
+ return;
1169
1204
  }
1205
+ m.classList.contains("fk-timepicker") || m.classList.add("fk-timepicker");
1170
1206
  });
1171
1207
  };
1172
1208
  return xe(() => {
1173
- te();
1209
+ M();
1174
1210
  }), {
1175
1211
  raw: t,
1176
- rules: w,
1177
- debugEnabled: P,
1178
- debugLines: H,
1179
- placeholder: T,
1180
- isValid: a,
1181
- reason: K(d),
1182
- validationMessage: I,
1183
- isComplete: g,
1184
- inRangeTime: i,
1185
- cursorPos: c,
1186
- hour: K(D),
1187
- hour24: K(R),
1188
- minute: K(x),
1189
- period: K($),
1190
- time24: K(f),
1191
- parsedRawTime: K(J),
1192
- handleChange: p,
1193
- handleKeyDown: C,
1194
- handleKeyUp: oe,
1195
- handleClick: A,
1196
- handleWheel: G,
1197
- handleBlur: Q
1212
+ rules: g,
1213
+ debugEnabled: q,
1214
+ debugLines: oe,
1215
+ placeholder: I,
1216
+ isValid: ne,
1217
+ reason: N(a),
1218
+ validationMessage: d,
1219
+ isComplete: y,
1220
+ inRangeTime: l,
1221
+ cursorPos: u,
1222
+ hour: N(E),
1223
+ hour24: N(U),
1224
+ minute: N(C),
1225
+ period: N(T),
1226
+ time24: N(f),
1227
+ parsedRawTime: N(F),
1228
+ handleChange: s,
1229
+ handleKeyDown: D,
1230
+ handleKeyUp: H,
1231
+ handleClick: v,
1232
+ handleWheel: $,
1233
+ handleBlur: J,
1234
+ // Expose so consumers can reapply theming when Kendo updates DOM
1235
+ initStyling: M
1198
1236
  };
1199
1237
  }
1200
- function Fe(e) {
1238
+ function Ue(e) {
1201
1239
  return Le() ? (Pe(e), !0) : !1;
1202
1240
  }
1203
- const $e = typeof window < "u" && typeof document < "u";
1241
+ const Ce = typeof window < "u" && typeof document < "u";
1204
1242
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
1205
- const Ue = Object.prototype.toString, Oe = (e) => Ue.call(e) === "[object Object]", pe = () => {
1206
- }, Be = /* @__PURE__ */ Ke();
1207
- function Ke() {
1243
+ const Oe = Object.prototype.toString, Be = (e) => Oe.call(e) === "[object Object]", pe = () => {
1244
+ }, Ke = /* @__PURE__ */ Ve();
1245
+ function Ve() {
1208
1246
  var e, t;
1209
- return $e && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
1247
+ return Ce && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
1210
1248
  }
1211
1249
  function Ae(e) {
1212
1250
  return Array.isArray(e) ? e : [e];
1213
1251
  }
1214
- function Ve(e, t, c) {
1252
+ function Ye(e, t, u) {
1215
1253
  return ve(
1216
1254
  e,
1217
1255
  t,
1218
1256
  {
1219
- ...c,
1257
+ ...u,
1220
1258
  immediate: !0
1221
1259
  }
1222
1260
  );
1223
1261
  }
1224
- const Ce = $e ? window : void 0;
1225
- function Se(e) {
1262
+ const $e = Ce ? window : void 0;
1263
+ function be(e) {
1226
1264
  var t;
1227
- const c = ce(e);
1228
- return (t = c?.$el) != null ? t : c;
1265
+ const u = ce(e);
1266
+ return (t = u?.$el) != null ? t : u;
1229
1267
  }
1230
1268
  function Ee(...e) {
1231
- const t = [], c = () => {
1232
- t.forEach((k) => k()), t.length = 0;
1233
- }, P = (k, b, y, w) => (k.addEventListener(b, y, w), () => k.removeEventListener(b, y, w)), T = h(() => {
1234
- const k = Ae(ce(e[0])).filter((b) => b != null);
1235
- return k.every((b) => typeof b != "string") ? k : void 0;
1236
- }), V = Ve(
1269
+ const t = [], u = () => {
1270
+ t.forEach((A) => A()), t.length = 0;
1271
+ }, q = (A, k, S, g) => (A.addEventListener(k, S, g), () => A.removeEventListener(k, S, g)), I = h(() => {
1272
+ const A = Ae(ce(e[0])).filter((k) => k != null);
1273
+ return A.every((k) => typeof k != "string") ? A : void 0;
1274
+ }), L = Ye(
1237
1275
  () => {
1238
- var k, b;
1276
+ var A, k;
1239
1277
  return [
1240
- (b = (k = T.value) == null ? void 0 : k.map((y) => Se(y))) != null ? b : [Ce].filter((y) => y != null),
1241
- Ae(ce(T.value ? e[1] : e[0])),
1242
- Ae(Te(T.value ? e[2] : e[1])),
1278
+ (k = (A = I.value) == null ? void 0 : A.map((S) => be(S))) != null ? k : [$e].filter((S) => S != null),
1279
+ Ae(ce(I.value ? e[1] : e[0])),
1280
+ Ae(Fe(I.value ? e[2] : e[1])),
1243
1281
  // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
1244
- ce(T.value ? e[3] : e[2])
1282
+ ce(I.value ? e[3] : e[2])
1245
1283
  ];
1246
1284
  },
1247
- ([k, b, y, w]) => {
1248
- if (c(), !k?.length || !b?.length || !y?.length)
1285
+ ([A, k, S, g]) => {
1286
+ if (u(), !A?.length || !k?.length || !S?.length)
1249
1287
  return;
1250
- const L = Oe(w) ? { ...w } : w;
1288
+ const P = Be(g) ? { ...g } : g;
1251
1289
  t.push(
1252
- ...k.flatMap(
1253
- (D) => b.flatMap(
1254
- (x) => y.map(($) => P(D, x, $, L))
1290
+ ...A.flatMap(
1291
+ (E) => k.flatMap(
1292
+ (C) => S.map((T) => q(E, C, T, P))
1255
1293
  )
1256
1294
  )
1257
1295
  );
1258
1296
  },
1259
1297
  { flush: "post" }
1260
- ), W = () => {
1261
- V(), c();
1298
+ ), V = () => {
1299
+ L(), u();
1262
1300
  };
1263
- return Fe(c), W;
1301
+ return Ue(u), V;
1264
1302
  }
1265
1303
  let Me = !1;
1266
- function Ye(e, t, c = {}) {
1267
- const { window: P = Ce, ignore: T = [], capture: V = !0, detectIframe: W = !1, controls: k = !1 } = c;
1268
- if (!P)
1269
- return k ? { stop: pe, cancel: pe, trigger: pe } : pe;
1270
- if (Be && !Me) {
1304
+ function Ne(e, t, u = {}) {
1305
+ const { window: q = $e, ignore: I = [], capture: L = !0, detectIframe: V = !1, controls: A = !1 } = u;
1306
+ if (!q)
1307
+ return A ? { stop: pe, cancel: pe, trigger: pe } : pe;
1308
+ if (Ke && !Me) {
1271
1309
  Me = !0;
1272
1310
  const f = { passive: !0 };
1273
- Array.from(P.document.body.children).forEach((g) => g.addEventListener("click", pe, f)), P.document.documentElement.addEventListener("click", pe, f);
1311
+ Array.from(q.document.body.children).forEach((y) => y.addEventListener("click", pe, f)), q.document.documentElement.addEventListener("click", pe, f);
1274
1312
  }
1275
- let b = !0;
1276
- const y = (f) => ce(T).some((g) => {
1277
- if (typeof g == "string")
1278
- return Array.from(P.document.querySelectorAll(g)).some((F) => F === f.target || f.composedPath().includes(F));
1313
+ let k = !0;
1314
+ const S = (f) => ce(I).some((y) => {
1315
+ if (typeof y == "string")
1316
+ return Array.from(q.document.querySelectorAll(y)).some((O) => O === f.target || f.composedPath().includes(O));
1279
1317
  {
1280
- const F = Se(g);
1281
- return F && (f.target === F || f.composedPath().includes(F));
1318
+ const O = be(y);
1319
+ return O && (f.target === O || f.composedPath().includes(O));
1282
1320
  }
1283
1321
  });
1284
- function w(f) {
1285
- const g = ce(f);
1286
- return g && g.$.subTree.shapeFlag === 16;
1322
+ function g(f) {
1323
+ const y = ce(f);
1324
+ return y && y.$.subTree.shapeFlag === 16;
1287
1325
  }
1288
- function L(f, g) {
1289
- const F = ce(f), o = F.$.subTree && F.$.subTree.children;
1290
- return o == null || !Array.isArray(o) ? !1 : o.some((m) => m.el === g.target || g.composedPath().includes(m.el));
1326
+ function P(f, y) {
1327
+ const O = ce(f), G = O.$.subTree && O.$.subTree.children;
1328
+ return G == null || !Array.isArray(G) ? !1 : G.some((o) => o.el === y.target || y.composedPath().includes(o.el));
1291
1329
  }
1292
- const D = (f) => {
1293
- const g = Se(e);
1294
- if (f.target != null && !(!(g instanceof Element) && w(e) && L(e, f)) && !(!g || g === f.target || f.composedPath().includes(g))) {
1295
- if ("detail" in f && f.detail === 0 && (b = !y(f)), !b) {
1296
- b = !0;
1330
+ const E = (f) => {
1331
+ const y = be(e);
1332
+ if (f.target != null && !(!(y instanceof Element) && g(e) && P(e, f)) && !(!y || y === f.target || f.composedPath().includes(y))) {
1333
+ if ("detail" in f && f.detail === 0 && (k = !S(f)), !k) {
1334
+ k = !0;
1297
1335
  return;
1298
1336
  }
1299
1337
  t(f);
1300
1338
  }
1301
1339
  };
1302
- let x = !1;
1303
- const $ = [
1304
- Ee(P, "click", (f) => {
1305
- x || (x = !0, setTimeout(() => {
1306
- x = !1;
1307
- }, 0), D(f));
1308
- }, { passive: !0, capture: V }),
1309
- Ee(P, "pointerdown", (f) => {
1310
- const g = Se(e);
1311
- b = !y(f) && !!(g && !f.composedPath().includes(g));
1340
+ let C = !1;
1341
+ const T = [
1342
+ Ee(q, "click", (f) => {
1343
+ C || (C = !0, setTimeout(() => {
1344
+ C = !1;
1345
+ }, 0), E(f));
1346
+ }, { passive: !0, capture: L }),
1347
+ Ee(q, "pointerdown", (f) => {
1348
+ const y = be(e);
1349
+ k = !S(f) && !!(y && !f.composedPath().includes(y));
1312
1350
  }, { passive: !0 }),
1313
- W && Ee(P, "blur", (f) => {
1351
+ V && Ee(q, "blur", (f) => {
1314
1352
  setTimeout(() => {
1315
- var g;
1316
- const F = Se(e);
1317
- ((g = P.document.activeElement) == null ? void 0 : g.tagName) === "IFRAME" && !F?.contains(P.document.activeElement) && t(f);
1353
+ var y;
1354
+ const O = be(e);
1355
+ ((y = q.document.activeElement) == null ? void 0 : y.tagName) === "IFRAME" && !O?.contains(q.document.activeElement) && t(f);
1318
1356
  }, 0);
1319
1357
  }, { passive: !0 })
1320
- ].filter(Boolean), R = () => $.forEach((f) => f());
1321
- return k ? {
1322
- stop: R,
1358
+ ].filter(Boolean), U = () => T.forEach((f) => f());
1359
+ return A ? {
1360
+ stop: U,
1323
1361
  cancel: () => {
1324
- b = !1;
1362
+ k = !1;
1325
1363
  },
1326
1364
  trigger: (f) => {
1327
- b = !0, D(f), b = !1;
1365
+ k = !0, E(f), k = !1;
1328
1366
  }
1329
- } : R;
1367
+ } : U;
1330
1368
  }
1331
- function ze(e) {
1332
- const t = Re(null), c = [
1369
+ function Qe(e) {
1370
+ const t = Re(null), u = [
1333
1371
  ".k-animation-container .k-popup",
1334
1372
  ".k-popup",
1335
1373
  ".k-timepicker-popup",
1336
1374
  ".k-menu-popup"
1337
- ], P = Array.isArray(e.popupSelector) ? e.popupSelector : [e.popupSelector ?? c].flat(), T = (w) => w ? typeof e.initialFocus == "string" ? w.querySelector(e.initialFocus) ?? w : typeof e.initialFocus == "function" ? e.initialFocus(w) ?? w : w.querySelector(
1375
+ ], q = Array.isArray(e.popupSelector) ? e.popupSelector : [e.popupSelector ?? u].flat(), I = (g) => g ? typeof e.initialFocus == "string" ? g.querySelector(e.initialFocus) ?? g : typeof e.initialFocus == "function" ? e.initialFocus(g) ?? g : g.querySelector(
1338
1376
  'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
1339
- ) ?? w : null, { activate: V, deactivate: W } = qe(t, {
1377
+ ) ?? g : null, { activate: L, deactivate: V } = qe(t, {
1340
1378
  escapeDeactivates: !1,
1341
1379
  clickOutsideDeactivates: !1,
1342
1380
  fallbackFocus: () => t.value,
1343
- initialFocus: () => T(t.value),
1381
+ initialFocus: () => I(t.value),
1344
1382
  ...e.focusTrapOptions ?? {}
1345
1383
  });
1346
- let k = null, b = _(null);
1347
- const y = () => {
1384
+ let A = null, k = _(null);
1385
+ const S = () => {
1348
1386
  if (e.resolvePopupEl) return e.resolvePopupEl();
1349
- const w = (D, x) => {
1350
- const $ = Array.from(D.querySelectorAll(x));
1351
- if (!$.length) return null;
1352
- const R = $.filter(
1387
+ const g = (E, C) => {
1388
+ const T = Array.from(E.querySelectorAll(C));
1389
+ if (!T.length) return null;
1390
+ const U = T.filter(
1353
1391
  (f) => f.offsetParent !== null || f.getClientRects().length > 0
1354
1392
  );
1355
- return R[R.length - 1] ?? $[$.length - 1] ?? null;
1356
- }, L = e.triggerEl?.value?.closest?.(".k-animation-container") ?? document.body;
1357
- for (const D of P) {
1358
- const x = w(L, D);
1359
- if (x) return x;
1393
+ return U[U.length - 1] ?? T[T.length - 1] ?? null;
1394
+ }, P = e.triggerEl?.value?.closest?.(".k-animation-container") ?? document.body;
1395
+ for (const E of q) {
1396
+ const C = g(P, E);
1397
+ if (C) return C;
1360
1398
  }
1361
- for (const D of P) {
1362
- const x = w(document, D);
1363
- if (x) return x;
1399
+ for (const E of q) {
1400
+ const C = g(document, E);
1401
+ if (C) return C;
1364
1402
  }
1365
1403
  return null;
1366
1404
  };
1367
- return Ye(t, (w) => {
1368
- b.value = "outside", e.isOpen.value && e.onRequestClose?.("outside", w);
1405
+ return Ne(t, (g) => {
1406
+ k.value = "outside", e.isOpen.value && e.onRequestClose?.("outside", g);
1369
1407
  }), ve(
1370
1408
  () => e.isOpen.value,
1371
- (w) => {
1372
- w ? (b.value = null, N(() => {
1373
- const L = y();
1374
- L && (t.value = L, setTimeout(() => V(), 0), k || (k = (D) => {
1375
- D.key === "Escape" && (b.value = "escape", e.isOpen.value && e.onRequestClose?.("escape", D));
1376
- }, document.addEventListener("keydown", k, !0)));
1377
- })) : (W(), k && (document.removeEventListener("keydown", k, !0), k = null), t.value = null, b.value === "outside" && N(() => {
1378
- const L = () => {
1379
- const D = e.triggerEl?.value, x = D?.querySelector("input"), $ = document.activeElement;
1380
- $ && ($ === x || D && D.contains($)) && (x ?? D)?.blur?.();
1409
+ (g) => {
1410
+ g ? (k.value = null, j(() => {
1411
+ const P = S();
1412
+ P && (t.value = P, setTimeout(() => L(), 0), A || (A = (E) => {
1413
+ E.key === "Escape" && (k.value = "escape", e.isOpen.value && e.onRequestClose?.("escape", E));
1414
+ }, document.addEventListener("keydown", A, !0)));
1415
+ })) : (V(), A && (document.removeEventListener("keydown", A, !0), A = null), t.value = null, k.value === "outside" && j(() => {
1416
+ const P = () => {
1417
+ const E = e.triggerEl?.value, C = E?.querySelector("input"), T = document.activeElement;
1418
+ T && (T === C || E && E.contains(T)) && (C ?? E)?.blur?.();
1381
1419
  };
1382
- requestAnimationFrame(() => setTimeout(L, 0));
1383
- }), e.returnFocusToTrigger !== !1 && b.value === "escape" && e.triggerEl?.value && (console.log(
1420
+ requestAnimationFrame(() => setTimeout(P, 0));
1421
+ }), e.returnFocusToTrigger !== !1 && k.value === "escape" && e.triggerEl?.value && (console.log(
1384
1422
  "Returning focus to trigger element:",
1385
1423
  e.triggerEl.value
1386
- ), N(() => {
1387
- const L = () => {
1388
- const D = e.triggerEl?.value;
1389
- if (!D) return;
1390
- (D.querySelector("input") ?? D)?.focus?.();
1424
+ ), j(() => {
1425
+ const P = () => {
1426
+ const E = e.triggerEl?.value;
1427
+ if (!E) return;
1428
+ (E.querySelector("input") ?? E)?.focus?.();
1391
1429
  };
1392
- requestAnimationFrame(() => setTimeout(L, 0));
1430
+ requestAnimationFrame(() => setTimeout(P, 0));
1393
1431
  })));
1394
1432
  }
1395
1433
  ), {
1396
1434
  popupRef: t,
1397
- activate: V,
1398
- deactivate: W,
1399
- lastCloseReason: K(b),
1400
- setPopupEl: (w) => t.value = w
1435
+ activate: L,
1436
+ deactivate: V,
1437
+ lastCloseReason: N(k),
1438
+ setPopupEl: (g) => t.value = g
1401
1439
  };
1402
1440
  }
1441
+ const He = (e) => !!e && typeof e == "object" && "filters" in e && Array.isArray(e.filters), We = (e) => !!e && typeof e == "object" && "field" in e, Ie = (e, t) => !e || typeof e != "object" ? !1 : He(e) ? e.filters.some(
1442
+ (u) => Ie(u, t)
1443
+ ) : We(e) ? e.field === t : !1, Ze = (e) => {
1444
+ const t = _({}), u = (I) => !e.value || !e.value.filters ? !1 : e.value.filters.some(
1445
+ (L) => Ie(L, I)
1446
+ );
1447
+ return {
1448
+ activeClasses: t,
1449
+ hasFieldFilter: u,
1450
+ updateActiveClass: (I) => {
1451
+ const L = u(I);
1452
+ console.log("updateActiveClass for", I, "hasFilter:", L), t.value[I] = L ? "active" : "", console.log("activeClasses after update", t.value);
1453
+ }
1454
+ };
1455
+ };
1403
1456
  export {
1404
- We as useGridA11y,
1405
- _e as useMaskedDateInput,
1406
- Ge as useMaskedDateRangeInput,
1407
- je as useMaskedTimeInput,
1408
- ze as usePopupTrap
1457
+ _e as useGridA11y,
1458
+ Ze as useGridFilter,
1459
+ ze as useMaskedDateInput,
1460
+ Xe as useMaskedDateRangeInput,
1461
+ Je as useMaskedTimeInput,
1462
+ Qe as usePopupTrap
1409
1463
  };