@featherk/composables 0.6.3 → 0.6.4

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