@featherk/composables 0.6.4 → 0.6.5

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