@agent-ui-kit/web-components 0.0.1

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.
package/dist/traits.js ADDED
@@ -0,0 +1,2453 @@
1
+ import { s as ne, r as T } from "./chunks/agent-ciCayeod.js";
2
+ import { d as qt, o as Ft, q as Bt, t as Kt, p as Wt, v as Ut } from "./chunks/agent-ciCayeod.js";
3
+ import { parseStoreAttr as fe, parseOptionsAttr as pe, createListStore as ce, isGrouped as Ae } from "./store.js";
4
+ const Te = {
5
+ name: "drag",
6
+ category: "gesture",
7
+ channel: "pointer",
8
+ defaults: {
9
+ selector: "",
10
+ "drop-zone-selector": "",
11
+ "zone-selector": "",
12
+ axis: "both",
13
+ mode: "drop",
14
+ animate: "true"
15
+ },
16
+ attach(e) {
17
+ const t = e.config("selector") ?? "", s = e.config("drop-zone-selector") ?? "", n = e.config("zone-selector") ?? "", r = e.config("axis") ?? "both", o = e.config("mode") ?? "drop", a = e.config("animate") !== "false", h = e.config("ignore") ?? "aui-button, aui-select, aui-textarea, aui-input, aui-segment, aui-radio, aui-checkbox, aui-switch, aui-tab, aui-option, aui-range, aui-calendar, [data-resize-handle], [contenteditable]", f = e.config("modifier");
18
+ if (!t || o === "free") {
19
+ let w = !1, m = 0, y = 0, S = 0, $ = 0;
20
+ getComputedStyle(e.host).position === "static" && (e.host.style.position = "relative");
21
+ const K = (D) => {
22
+ if (D.button !== 0 || h && D.target.closest(h) || f === "alt" && !D.altKey || f === "meta" && !D.metaKey || f === "ctrl" && !D.ctrlKey || f === "shift" && !D.shiftKey) return;
23
+ w = !0, m = D.clientX, y = D.clientY;
24
+ const F = e.host.style.transform.match(/translate\((-?[\d.]+)px,\s*(-?[\d.]+)px\)/);
25
+ S = F ? parseFloat(F[1]) : 0, $ = F ? parseFloat(F[2]) : 0, e.host.setPointerCapture(D.pointerId), e.host.style.cursor = "grabbing", e.host.style.zIndex = "10", e.expose("dragging", !0), e.emit("drag-start", { item: e.host });
26
+ }, V = (D) => {
27
+ if (!w) return;
28
+ const J = r === "vertical" ? 0 : D.clientX - m, F = r === "horizontal" ? 0 : D.clientY - y;
29
+ e.host.style.transform = `translate(${S + J}px, ${$ + F}px)`, e.emit("drag-move", { item: e.host, x: D.clientX, y: D.clientY });
30
+ }, G = () => {
31
+ w && (w = !1, e.host.style.cursor = "", e.host.style.zIndex = "", e.unexpose("dragging"), e.emit("drag-end", { item: e.host }));
32
+ };
33
+ return e.host.addEventListener("pointerdown", K), e.host.addEventListener("pointermove", V), e.host.addEventListener("pointerup", G), () => {
34
+ w && G(), e.host.removeEventListener("pointerdown", K), e.host.removeEventListener("pointermove", V), e.host.removeEventListener("pointerup", G);
35
+ };
36
+ }
37
+ let i = null, l = null, c = null, d = 0, u = 0, p = 0, g = 0, v = -1, P = -1, M = null, k = null, b = null, O = null, E = -1, _ = -1;
38
+ const U = () => [...e.host.querySelectorAll(t)].filter((w) => !w.hasAttribute("popover")), j = () => s ? [...e.host.querySelectorAll(s)].filter((w) => !w.hasAttribute("popover")) : U(), Q = () => n ? [...e.host.querySelectorAll(n)] : [], H = (w) => [...w.querySelectorAll(t)].filter((m) => !m.hasAttribute("popover")), L = (w, m) => {
39
+ let y = null, S = 1 / 0;
40
+ for (const $ of Q()) {
41
+ const z = $.getBoundingClientRect(), K = z.left + z.width / 2, V = z.top + z.height / 2, G = Math.hypot(w - K, m - V);
42
+ G < S && (S = G, y = $);
43
+ }
44
+ return y;
45
+ }, A = (w, m, y) => {
46
+ if (w.length === 0) return 0;
47
+ let S = 0, $ = 1 / 0;
48
+ for (let D = 0; D < w.length; D++) {
49
+ const J = w[D].getBoundingClientRect(), F = J.left + J.width / 2, te = J.top + J.height / 2, re = Math.hypot(m - F, y - te);
50
+ re < $ && ($ = re, S = D);
51
+ }
52
+ let z = r === "horizontal" ? "h" : "v";
53
+ if (w.length >= 2) {
54
+ const D = w[0].getBoundingClientRect(), J = w[1].getBoundingClientRect(), F = Math.abs(J.left + J.width / 2 - D.left - D.width / 2), te = Math.abs(J.top + J.height / 2 - D.top - D.height / 2);
55
+ z = F > te ? "h" : "v";
56
+ }
57
+ const K = w[S].getBoundingClientRect(), V = z === "h" ? K.left + K.width / 2 : K.top + K.height / 2;
58
+ return (z === "h" ? m : y) > V ? S + 1 : S;
59
+ }, I = (w) => {
60
+ if (!i) return;
61
+ const m = i.getBoundingClientRect(), y = i.cloneNode(!0);
62
+ y.setAttribute("popover", "manual"), y.setAttribute("aria-hidden", "true"), document.body.appendChild(y), y.showPopover(), y.style.position = "fixed", y.style.inset = "unset", y.style.left = `${m.left}px`, y.style.top = `${m.top}px`, y.style.width = `${m.width}px`, y.style.height = `${m.height}px`, y.style.margin = "0", y.style.pointerEvents = "none", y.style.opacity = "0.7", y.style.transform = "scale(0.85)", y.style.transformOrigin = "center center", y.style.border = "none", y.style.outline = "none", l = y, d = w.clientX, u = w.clientY;
63
+ }, Y = () => {
64
+ const w = U();
65
+ for (let m = 0; m < w.length; m++)
66
+ w[m].style.viewTransitionName = w[m] === i ? "none" : `drag-item-${m}`;
67
+ }, N = () => {
68
+ for (const w of U()) w.style.removeProperty("view-transition-name");
69
+ }, Z = () => {
70
+ if (o !== "preview" || !i || !b) return;
71
+ const w = i, m = O, y = b, S = () => {
72
+ m && m.isConnected ? m.before(w) : y.appendChild(w);
73
+ };
74
+ a && typeof document.startViewTransition == "function" ? document.startViewTransition(() => {
75
+ S(), Y();
76
+ }).finished.catch(() => {
77
+ }) : S();
78
+ }, q = (w) => {
79
+ for (const m of w)
80
+ m.removeAttribute("drag-slot-before"), m.removeAttribute("drag-slot-after");
81
+ }, C = (w, m, y) => {
82
+ if (m === -1 || m === P) return;
83
+ P = m, q(w);
84
+ const S = w.filter((K) => K !== i && K !== c), $ = Math.min(m, S.length);
85
+ r !== "both" && (!c && i && (c = i.cloneNode(!0), c.setAttribute("data-drag-placeholder", ""), c.setAttribute("aria-hidden", "true"), c.removeAttribute("dragging"), c.style.display = "", c.style.opacity = "0.5", c.style.pointerEvents = "none", c.style.outline = "2px dashed var(--aui-accent, highlight)", c.style.outlineOffset = "-2px"), c && ($ < S.length ? S[$].before(c) : S.length > 0 ? S[S.length - 1].after(c) : (y ?? e.host).appendChild(c))), $ < S.length && S[$].setAttribute("drag-slot-before", ""), $ > 0 && $ - 1 < S.length && S[$ - 1].setAttribute("drag-slot-after", "");
86
+ const z = $ < S.length ? S[$] : null;
87
+ e.emit("drag-over", { item: i, index: m, insertBefore: z });
88
+ }, X = (w, m, y, S) => {
89
+ const $ = w.filter((G) => G !== i);
90
+ if ($.length === 0) {
91
+ if (S && i && E !== 0) {
92
+ E = 0;
93
+ const G = () => S.appendChild(i);
94
+ a && typeof document.startViewTransition == "function" ? document.startViewTransition(() => {
95
+ G(), Y();
96
+ }).finished.catch(() => {
97
+ }) : G(), e.emit("drag-over", { item: i, index: 0, insertBefore: null });
98
+ }
99
+ return;
100
+ }
101
+ let z = A($, m, y);
102
+ if (z === E) return;
103
+ E = z;
104
+ const K = z < $.length ? $[z] : null, V = () => {
105
+ K ? K.before(i) : $[$.length - 1].after(i);
106
+ };
107
+ a && typeof document.startViewTransition == "function" ? document.startViewTransition(() => {
108
+ V(), Y();
109
+ }).finished.catch(() => {
110
+ }) : V(), e.emit("drag-over", { item: i, index: z, insertBefore: K });
111
+ }, R = (w, m, y) => {
112
+ for (const S of w)
113
+ S !== m && (S.removeAttribute("drag-over"), S.style.removeProperty("outline"), S.style.removeProperty("outline-offset"));
114
+ m && (m.setAttribute("drag-over", ""), m.style.outline = "2px solid var(--aui-focus, highlight)", m.style.outlineOffset = "2px", e.emit("drag-over", { item: i, target: m, index: y }));
115
+ }, B = () => {
116
+ if (l) {
117
+ if (l.isConnected) try {
118
+ l.hidePopover();
119
+ } catch {
120
+ }
121
+ l.remove(), l = null;
122
+ }
123
+ i && (i.removeAttribute("dragging"), i.style.removeProperty("display")), o === "preview" && a && N();
124
+ const w = j();
125
+ if (o === "slot")
126
+ q(w);
127
+ else
128
+ for (const m of w)
129
+ m.removeAttribute("drag-over"), m.style.removeProperty("outline"), m.style.removeProperty("outline-offset");
130
+ if (c && (c.remove(), c = null), n) for (const m of Q()) m.removeAttribute("drag-zone-active");
131
+ if (i && _ >= 0) {
132
+ i.removeEventListener("lostpointercapture", ie);
133
+ try {
134
+ i.releasePointerCapture(_);
135
+ } catch {
136
+ }
137
+ }
138
+ i = null, v = -1, P = -1, M = null, k = null, b = null, O = null, E = -1, _ = -1, document.removeEventListener("pointermove", ee), document.removeEventListener("pointerup", oe), document.removeEventListener("pointercancel", ae), document.removeEventListener("keydown", le);
139
+ }, W = (w) => {
140
+ if (l) return;
141
+ const y = w.target.closest?.(t);
142
+ !y || !e.host.contains(y) || (y.style.outline = "2px solid var(--aui-focus, highlight)", y.style.outlineOffset = "2px");
143
+ }, x = (w) => {
144
+ const y = w.target.closest?.(t);
145
+ !y || !e.host.contains(y) || (y.style.removeProperty("outline"), y.style.removeProperty("outline-offset"));
146
+ }, se = (w) => {
147
+ const m = w;
148
+ if (m.button !== 0 || f === "alt" && !m.altKey || f === "meta" && !m.metaKey || f === "ctrl" && !m.ctrlKey || f === "shift" && !m.shiftKey) return;
149
+ const y = m.target.closest?.(t);
150
+ if (!y || !e.host.contains(y)) return;
151
+ const $ = U().indexOf(y);
152
+ if ($ === -1) return;
153
+ m.preventDefault(), i = y, v = $, d = m.clientX, u = m.clientY;
154
+ const z = y.getBoundingClientRect();
155
+ p = z.left + z.width / 2 - m.clientX, g = z.top + z.height / 2 - m.clientY, n && (M = y.closest(n)), document.addEventListener("pointermove", ee), document.addEventListener("pointerup", oe), document.addEventListener("pointercancel", ae), document.addEventListener("keydown", le);
156
+ try {
157
+ y.setPointerCapture(m.pointerId);
158
+ } catch {
159
+ }
160
+ _ = m.pointerId, y.addEventListener("lostpointercapture", ie);
161
+ }, ee = (w) => {
162
+ if (!i) return;
163
+ const m = w;
164
+ if (!l) {
165
+ i.style.removeProperty("outline"), i.style.removeProperty("outline-offset");
166
+ try {
167
+ I(m);
168
+ } catch {
169
+ B();
170
+ return;
171
+ }
172
+ i.setAttribute("dragging", ""), o === "slot" && (i.style.display = "none"), o === "preview" && (b = i.parentElement, O = i.nextElementSibling, E = -1, a && Y()), e.emit("drag-start", { item: i, index: v });
173
+ }
174
+ const y = m.clientX - d, S = m.clientY - u;
175
+ l.style.transform = `translate(${y}px, ${S}px) scale(0.85)`, e.emit("drag-move", { item: i, x: m.clientX, y: m.clientY });
176
+ const $ = j().filter((z) => z !== l);
177
+ if (o === "slot") {
178
+ const z = m.clientX + p, K = m.clientY + g;
179
+ let V, G;
180
+ if (n) {
181
+ const F = L(z, K);
182
+ if (!F) return;
183
+ F !== k && (k && (q(H(k)), k.removeAttribute("drag-zone-active")), F.setAttribute("drag-zone-active", ""), k = F, P = -1), V = H(F).filter((te) => te !== l), G = F;
184
+ } else
185
+ V = $;
186
+ const D = V.filter((F) => F !== i && F !== c), J = A(D, z, K);
187
+ C(V, J, G);
188
+ } else if (o === "preview") {
189
+ const z = m.clientX + p, K = m.clientY + g;
190
+ if (n) {
191
+ const V = L(z, K);
192
+ if (!V) return;
193
+ V !== k && (k && k.removeAttribute("drag-zone-active"), V.setAttribute("drag-zone-active", ""), k = V, E = -1);
194
+ const G = H(V).filter((D) => D !== l);
195
+ X(G, z, K, V);
196
+ } else
197
+ X($, z, K);
198
+ } else {
199
+ const z = $.filter((J) => J !== i), K = m.clientX + p, V = m.clientY + g;
200
+ let G = null, D = -1;
201
+ if (z.length > 0) {
202
+ let J = 1 / 0;
203
+ for (let F = 0; F < z.length; F++) {
204
+ const te = z[F].getBoundingClientRect(), re = Math.hypot(K - te.left - te.width / 2, V - te.top - te.height / 2);
205
+ re < J && (J = re, G = z[F], D = F);
206
+ }
207
+ }
208
+ R($, G, D);
209
+ }
210
+ }, oe = (w) => {
211
+ if (i) {
212
+ if (i.removeEventListener("lostpointercapture", ie), _ >= 0) try {
213
+ i.releasePointerCapture(_);
214
+ } catch {
215
+ }
216
+ if (document.removeEventListener("pointermove", ee), document.removeEventListener("pointerup", oe), document.removeEventListener("pointercancel", ae), document.removeEventListener("keydown", le), l)
217
+ if (o === "slot") {
218
+ let m;
219
+ n && k ? m = H(k).filter((S) => S !== i) : m = U().filter((S) => S !== i);
220
+ const y = P >= 0 && P < m.length ? m[P] : null;
221
+ e.emit("drop", {
222
+ item: i,
223
+ fromIndex: v,
224
+ toIndex: P,
225
+ insertBefore: y,
226
+ sourceZone: M,
227
+ targetZone: k
228
+ });
229
+ } else if (o === "preview") {
230
+ let m;
231
+ n && k ? m = H(k) : m = U();
232
+ const y = i ? m.indexOf(i) : -1;
233
+ b = null, O = null, e.emit("drop", {
234
+ item: i,
235
+ fromIndex: v,
236
+ toIndex: y,
237
+ sourceZone: M,
238
+ targetZone: k
239
+ });
240
+ } else {
241
+ const m = j(), y = m.find(($) => $.hasAttribute("drag-over")) ?? null, S = y ? m.indexOf(y) : -1;
242
+ e.emit("drop", {
243
+ item: i,
244
+ target: y,
245
+ fromIndex: v,
246
+ toIndex: S,
247
+ sourceZone: M,
248
+ targetZone: k
249
+ });
250
+ }
251
+ B();
252
+ }
253
+ }, ie = () => {
254
+ i && oe();
255
+ }, ae = () => {
256
+ i && (Z(), l && e.emit("drag-cancel", { item: i }), B());
257
+ }, le = (w) => {
258
+ const m = w;
259
+ m.key === "Escape" && i && (m.preventDefault(), Z(), l && e.emit("drag-cancel", { item: i }), B());
260
+ };
261
+ return e.host.addEventListener("pointerdown", se), e.host.addEventListener("pointerenter", W, !0), e.host.addEventListener("pointerleave", x, !0), () => {
262
+ i && l && (Z(), e.emit("drag-cancel", { item: i })), B(), e.host.removeEventListener("pointerdown", se), e.host.removeEventListener("pointerenter", W, !0), e.host.removeEventListener("pointerleave", x, !0);
263
+ };
264
+ }
265
+ }, ke = {
266
+ name: "press-hold",
267
+ category: "gesture",
268
+ channel: "pointer",
269
+ defaults: {
270
+ delay: "500"
271
+ },
272
+ attach(e) {
273
+ const t = parseInt(e.config("delay") ?? "500", 10);
274
+ let s = null;
275
+ const n = () => {
276
+ s !== null && (clearTimeout(s), s = null);
277
+ }, r = (a) => {
278
+ a.button === 0 && (n(), s = setTimeout(() => {
279
+ s = null, e.emit("hold"), e.expose("held", !0);
280
+ }, t));
281
+ }, o = () => {
282
+ n(), e.unexpose("held");
283
+ };
284
+ return e.host.addEventListener("pointerdown", r), e.host.addEventListener("pointerup", o), e.host.addEventListener("pointerleave", o), e.host.addEventListener("pointercancel", o), () => {
285
+ n(), e.host.removeEventListener("pointerdown", r), e.host.removeEventListener("pointerup", o), e.host.removeEventListener("pointerleave", o), e.host.removeEventListener("pointercancel", o);
286
+ };
287
+ }
288
+ }, Ce = {
289
+ name: "swipe",
290
+ category: "gesture",
291
+ channel: "pointer",
292
+ defaults: {
293
+ threshold: "50",
294
+ timeout: "300"
295
+ },
296
+ attach(e) {
297
+ const t = parseInt(e.config("threshold") ?? "50", 10), s = parseInt(e.config("timeout") ?? "300", 10);
298
+ let n = 0, r = 0, o = 0, a = !1, h = -1, f = null;
299
+ const i = (u) => {
300
+ const p = u;
301
+ if (p.button === 0) {
302
+ p.preventDefault(), n = p.clientX, r = p.clientY, o = Date.now(), a = !0, h = p.pointerId;
303
+ try {
304
+ e.host.setPointerCapture(p.pointerId);
305
+ } catch {
306
+ }
307
+ e.host.style.touchAction = "none", e.expose("swiping", !0);
308
+ }
309
+ }, l = (u) => {
310
+ if (!a) return;
311
+ const p = u, g = p.clientX - n, v = p.clientY - r;
312
+ e.host.style.setProperty("--_swipe-x", `${g}px`), e.host.style.setProperty("--_swipe-y", `${v}px`), e.emit("swipe-move", { dx: g, dy: v });
313
+ }, c = (u) => {
314
+ if (!a) return;
315
+ a = !1;
316
+ const p = u;
317
+ if (h >= 0) {
318
+ try {
319
+ e.host.releasePointerCapture(h);
320
+ } catch {
321
+ }
322
+ h = -1;
323
+ }
324
+ e.host.style.touchAction = "", e.host.style.removeProperty("--_swipe-x"), e.host.style.removeProperty("--_swipe-y"), e.unexpose("swiping");
325
+ const g = p.clientX - n, v = p.clientY - r, P = Date.now() - o;
326
+ if (P > s) return;
327
+ const M = Math.abs(g), k = Math.abs(v), b = Math.sqrt(g * g + v * v);
328
+ if (b < t) return;
329
+ const O = M > k ? g > 0 ? "right" : "left" : v > 0 ? "down" : "up", E = b / P;
330
+ e.emit("swipe", { direction: O, distance: b, velocity: E, dx: g, dy: v }), f !== null && clearTimeout(f), e.expose("direction", O), f = setTimeout(() => {
331
+ e.unexpose("direction"), f = null;
332
+ }, 500);
333
+ }, d = () => {
334
+ if (a) {
335
+ if (a = !1, h >= 0) {
336
+ try {
337
+ e.host.releasePointerCapture(h);
338
+ } catch {
339
+ }
340
+ h = -1;
341
+ }
342
+ e.host.style.touchAction = "", e.host.style.removeProperty("--_swipe-x"), e.host.style.removeProperty("--_swipe-y"), e.unexpose("swiping");
343
+ }
344
+ };
345
+ return e.host.addEventListener("pointerdown", i), e.host.addEventListener("pointermove", l), e.host.addEventListener("pointerup", c), e.host.addEventListener("pointercancel", d), () => {
346
+ if (f !== null && clearTimeout(f), h >= 0)
347
+ try {
348
+ e.host.releasePointerCapture(h);
349
+ } catch {
350
+ }
351
+ e.host.style.touchAction = "", e.host.style.removeProperty("--_swipe-x"), e.host.style.removeProperty("--_swipe-y"), e.host.removeEventListener("pointerdown", i), e.host.removeEventListener("pointermove", l), e.host.removeEventListener("pointerup", c), e.host.removeEventListener("pointercancel", d);
352
+ };
353
+ }
354
+ }, Pe = {
355
+ name: "sort",
356
+ category: "gesture",
357
+ channel: "pointer",
358
+ defaults: {
359
+ selector: "> *",
360
+ handle: "",
361
+ axis: "vertical"
362
+ },
363
+ attach(e) {
364
+ const t = e.config("selector") ?? "> *", s = e.config("handle") ?? "", n = e.config("axis") ?? "vertical", r = t.startsWith("> ") ? `:scope ${t}` : t;
365
+ let o = null, a = null, h = null, f = 0, i = 0, l = 0, c = 0, d = -1, u = -1;
366
+ const p = () => [...e.host.querySelectorAll(r)].filter((L) => !L.hasAttribute("popover")), g = (L) => {
367
+ const A = L[0].getBoundingClientRect();
368
+ let I = 1;
369
+ for (let Z = 1; Z < L.length && Math.abs(L[Z].getBoundingClientRect().top - A.top) < A.height * 0.5; Z++)
370
+ I = Z + 1;
371
+ const Y = I > 1 ? L[1].getBoundingClientRect().left - A.left : A.width, N = I < L.length ? L[I].getBoundingClientRect().top - A.top : A.height;
372
+ return { cols: I, stepX: Y, stepY: N, firstRect: A };
373
+ }, v = (L, A, I, Y) => {
374
+ const { cols: N, stepX: Z, stepY: q, firstRect: C } = g(I), X = Math.round((L - (C.left + C.width / 2)) / Z), R = Math.round((A - (C.top + C.height / 2)) / q), B = Math.ceil(Y / N) - 1, W = Math.max(0, Math.min(X, N - 1)), x = Math.max(0, Math.min(R, Math.max(0, B)));
375
+ return Math.max(0, Math.min(x * N + W, Y));
376
+ }, P = (L) => {
377
+ if (!o) return;
378
+ const A = o.getBoundingClientRect(), I = o.cloneNode(!0);
379
+ I.setAttribute("popover", "manual"), I.setAttribute("aria-hidden", "true"), e.host.appendChild(I), I.showPopover(), I.style.position = "fixed", I.style.inset = "unset", I.style.left = `${A.left}px`, I.style.top = `${A.top}px`, I.style.width = `${A.width}px`, I.style.height = `${A.height}px`, I.style.margin = "0", I.style.pointerEvents = "none", I.style.opacity = "0.8", I.style.transformOrigin = "center center", I.style.border = "none", I.style.outline = "none", a = I, f = L.clientX, i = L.clientY;
380
+ }, M = (L) => {
381
+ for (const A of L)
382
+ A.removeAttribute("drag-slot-before"), A.removeAttribute("drag-slot-after");
383
+ }, k = () => {
384
+ if (a) {
385
+ if (a.isConnected) try {
386
+ a.hidePopover();
387
+ } catch {
388
+ }
389
+ a.remove(), a = null;
390
+ }
391
+ if (o && o.removeAttribute("dragging"), M(p()), h && (h.remove(), h = null), o && d >= 0) {
392
+ o.removeEventListener("lostpointercapture", _);
393
+ try {
394
+ o.releasePointerCapture(d);
395
+ } catch {
396
+ }
397
+ }
398
+ o = null, u = -1, d = -1, document.removeEventListener("pointermove", O), document.removeEventListener("pointerup", E), document.removeEventListener("pointercancel", U), document.removeEventListener("keydown", j);
399
+ }, b = (L) => {
400
+ const A = L;
401
+ if (A.button !== 0) return;
402
+ const I = A.target, Y = p();
403
+ let N = null;
404
+ for (const q of Y)
405
+ if (q.contains(I)) {
406
+ if (s) {
407
+ const C = q.querySelector(s);
408
+ if (!C || !C.contains(I)) continue;
409
+ }
410
+ N = q;
411
+ break;
412
+ }
413
+ if (!N) return;
414
+ A.preventDefault(), o = N, f = A.clientX, i = A.clientY;
415
+ const Z = N.getBoundingClientRect();
416
+ l = Z.left + Z.width / 2 - A.clientX, c = Z.top + Z.height / 2 - A.clientY, document.addEventListener("pointermove", O), document.addEventListener("pointerup", E), document.addEventListener("pointercancel", U), document.addEventListener("keydown", j);
417
+ try {
418
+ N.setPointerCapture(A.pointerId);
419
+ } catch {
420
+ }
421
+ d = A.pointerId, N.addEventListener("lostpointercapture", _);
422
+ }, O = (L) => {
423
+ if (!o) return;
424
+ const A = L;
425
+ if (!a) {
426
+ o.style.removeProperty("outline"), o.style.removeProperty("outline-offset");
427
+ try {
428
+ P(A);
429
+ } catch {
430
+ k();
431
+ return;
432
+ }
433
+ o.setAttribute("dragging", ""), e.expose("dragging", !0);
434
+ }
435
+ const I = A.clientX - f, Y = A.clientY - i;
436
+ a.style.transform = `translate(${I}px, ${Y}px) scale(0.9)`;
437
+ const N = A.clientX + l, Z = A.clientY + c, q = p().filter((W) => W !== a), C = q.filter((W) => W !== o);
438
+ let X = 0;
439
+ if (n === "both" && q.length >= 2)
440
+ X = v(N, Z, q, C.length);
441
+ else
442
+ for (let W = 0; W < C.length; W++) {
443
+ const x = C[W].getBoundingClientRect(), se = x.left + x.width / 2, ee = x.top + x.height / 2;
444
+ if (n === "horizontal" ? N > se : Z > ee) X = W + 1;
445
+ else break;
446
+ }
447
+ if (X === u) return;
448
+ u = X, M(q);
449
+ const R = q.filter((W) => W !== o), B = Math.min(X, R.length);
450
+ n !== "both" && (h || (h = document.createElement("div"), h.setAttribute("data-drag-placeholder", ""), h.setAttribute("aria-hidden", "true")), B < R.length ? R[B].before(h) : R.length > 0 ? R[R.length - 1].after(h) : e.host.appendChild(h)), B < R.length && R[B].setAttribute("drag-slot-before", ""), B > 0 && B - 1 < R.length && R[B - 1].setAttribute("drag-slot-after", "");
451
+ }, E = () => {
452
+ if (o) {
453
+ if (a) {
454
+ const A = p().filter((q) => q !== a).filter((q) => q !== o), I = Math.min(Math.max(u, 0), A.length), Y = I < A.length ? A[I] : null;
455
+ Y ? Y.before(o) : A.length > 0 && A[A.length - 1].after(o);
456
+ const Z = p().filter((q) => !q.hasAttribute("popover")).map((q, C) => q.dataset.sortKey ?? String(C));
457
+ e.emit("sort", { order: Z });
458
+ }
459
+ e.unexpose("dragging"), k();
460
+ }
461
+ }, _ = () => {
462
+ o && E();
463
+ }, U = () => {
464
+ o && (e.unexpose("dragging"), k());
465
+ }, j = (L) => {
466
+ const A = L;
467
+ A.key === "Escape" && o && (A.preventDefault(), e.unexpose("dragging"), k());
468
+ }, Q = (L) => {
469
+ if (a) return;
470
+ const A = L, I = p();
471
+ let Y = null;
472
+ for (const N of I)
473
+ if (N.contains(A.target)) {
474
+ Y = N;
475
+ break;
476
+ }
477
+ Y && (Y.style.outline = "2px solid var(--aui-focus, highlight)", Y.style.outlineOffset = "2px");
478
+ }, H = (L) => {
479
+ const A = L, I = p();
480
+ let Y = null;
481
+ for (const N of I)
482
+ if (N.contains(A.target)) {
483
+ Y = N;
484
+ break;
485
+ }
486
+ Y && (Y.style.removeProperty("outline"), Y.style.removeProperty("outline-offset"));
487
+ };
488
+ return e.host.addEventListener("pointerdown", b), e.host.addEventListener("pointerenter", Q, !0), e.host.addEventListener("pointerleave", H, !0), () => {
489
+ k(), e.host.removeEventListener("pointerdown", b), e.host.removeEventListener("pointerenter", Q, !0), e.host.removeEventListener("pointerleave", H, !0);
490
+ };
491
+ }
492
+ }, Se = {
493
+ n: "ns-resize",
494
+ s: "ns-resize",
495
+ e: "ew-resize",
496
+ w: "ew-resize",
497
+ ne: "nesw-resize",
498
+ sw: "nesw-resize",
499
+ nw: "nwse-resize",
500
+ se: "nwse-resize"
501
+ }, me = (e) => e.includes("e") || e.includes("w"), ve = (e) => e.includes("n") || e.includes("s"), Me = {
502
+ name: "resize",
503
+ category: "gesture",
504
+ channel: "pointer",
505
+ defaults: {
506
+ handles: "n,s,e,w,ne,nw,se,sw",
507
+ "min-width": "1",
508
+ "min-height": "1"
509
+ },
510
+ attach(e) {
511
+ const t = (e.config("handles") ?? "se").split(",").map((C) => C.trim()), s = parseInt(e.config("min-width") ?? "50", 10), n = parseInt(e.config("min-height") ?? "50", 10), r = e.config("modifier");
512
+ getComputedStyle(e.host).position === "static" && (e.host.style.position = "relative");
513
+ let a = !1, h = null, f = 0, i = 0, l = 0, c = 0, d = 0, u = 0;
514
+ const p = (C) => {
515
+ e.host.style.width = `${C}px`, e.host.style.overflowX = "hidden", e.host.setAttribute("data-resize-fixed-w", "");
516
+ }, g = (C) => {
517
+ e.host.style.height = `${C}px`, e.host.style.overflowY = "hidden", e.host.setAttribute("data-resize-fixed-h", "");
518
+ }, v = () => {
519
+ e.host.style.width = "", e.host.style.overflowX = "", e.host.removeAttribute("data-resize-fixed-w");
520
+ }, P = () => {
521
+ e.host.style.height = "", e.host.style.overflowY = "", e.host.removeAttribute("data-resize-fixed-h");
522
+ }, M = (C) => {
523
+ if (!a || !h) return;
524
+ const X = C.clientX - f, R = C.clientY - i;
525
+ let B = l, W = c, x = d, se = u;
526
+ if (h.includes("e") && (B = Math.max(s, l + X)), h.includes("w")) {
527
+ const ee = Math.max(s, l - X);
528
+ x = d + (l - ee), B = ee;
529
+ }
530
+ if (h.includes("s") && (W = Math.max(n, c + R)), h.includes("n")) {
531
+ const ee = Math.max(n, c - R);
532
+ se = u + (c - ee), W = ee;
533
+ }
534
+ me(h) && p(B), ve(h) && g(W), h.includes("w") && (e.host.style.left = `${x}px`), h.includes("n") && (e.host.style.top = `${se}px`), E(), e.emit("aui:resize-move", { width: B, height: W });
535
+ }, k = (C) => {
536
+ if (!a) return;
537
+ a = !1, h = null, O.removeAttribute("data-resize-label-visible"), C.target?.releasePointerCapture(C.pointerId), document.documentElement.style.cursor = "", e.unexpose("resizing");
538
+ const X = e.host.getBoundingClientRect();
539
+ e.emit("aui:resize-end", { width: X.width, height: X.height }), document.removeEventListener("pointermove", M), document.removeEventListener("pointerup", k);
540
+ }, b = document.createElement("div");
541
+ b.setAttribute("data-resize-overlay", "");
542
+ const O = document.createElement("div");
543
+ O.setAttribute("data-resize-label", ""), b.appendChild(O);
544
+ const E = () => {
545
+ b.style.left = `${e.host.offsetLeft}px`, b.style.top = `${e.host.offsetTop}px`, b.style.width = `${e.host.offsetWidth}px`, b.style.height = `${e.host.offsetHeight}px`, b.style.transform = e.host.style.transform || "none", b.style.transformOrigin = e.host.style.transformOrigin || "", O.textContent = `${Math.round(e.host.offsetWidth)} × ${Math.round(e.host.offsetHeight)}`;
546
+ }, _ = new MutationObserver(E);
547
+ _.observe(e.host, { attributes: !0, attributeFilter: ["style"] });
548
+ for (const C of t) {
549
+ const X = document.createElement("div");
550
+ X.setAttribute("data-resize-handle", C), X.addEventListener("dblclick", (R) => {
551
+ R.preventDefault(), R.stopPropagation();
552
+ const B = me(C) && e.host.hasAttribute("data-resize-fixed-w"), W = ve(C) && e.host.hasAttribute("data-resize-fixed-h");
553
+ if (B && v(), W && P(), B || W) {
554
+ E();
555
+ const x = B && W ? "both" : B ? "width" : "height";
556
+ e.emit("aui:resize-reset", { axis: x });
557
+ }
558
+ }), X.addEventListener("pointerdown", (R) => {
559
+ R.button === 0 && (r === "alt" && !R.altKey || r === "meta" && !R.metaKey || r === "ctrl" && !R.ctrlKey || r === "shift" && !R.shiftKey || (R.preventDefault(), R.stopPropagation(), a = !0, h = C, f = R.clientX, i = R.clientY, l = e.host.offsetWidth, c = e.host.offsetHeight, d = e.host.offsetLeft, u = e.host.offsetTop, X.setPointerCapture(R.pointerId), document.documentElement.style.cursor = Se[C], e.expose("resizing", !0), O.setAttribute("data-resize-label-visible", ""), e.emit("aui:resize-start", { width: l, height: c }), document.addEventListener("pointermove", M), document.addEventListener("pointerup", k)));
560
+ }), b.appendChild(X);
561
+ }
562
+ const U = e.host.closest("aui-editor, aui-graph-ui")?.querySelector('aui-editor-layer[name="chrome"], aui-graph-layer[name="chrome"]');
563
+ U ? U.appendChild(b) : e.host.after(b);
564
+ let j = 0, Q = "";
565
+ const H = () => {
566
+ const C = () => {
567
+ const X = `${e.host.offsetLeft},${e.host.offsetTop},${e.host.offsetWidth},${e.host.offsetHeight}`;
568
+ X !== Q && (Q = X, E()), j = requestAnimationFrame(C);
569
+ };
570
+ Q = "", j = requestAnimationFrame(C);
571
+ }, L = () => {
572
+ cancelAnimationFrame(j), j = 0;
573
+ }, A = () => {
574
+ b.setAttribute("data-resize-visible", ""), E(), H();
575
+ }, I = () => {
576
+ a || (b.removeAttribute("data-resize-visible"), O.removeAttribute("data-resize-label-visible"), L());
577
+ }, Y = 12;
578
+ let N = !1;
579
+ const Z = (C) => r ? r === "alt" ? C.altKey : r === "meta" ? C.metaKey : r === "ctrl" ? C.ctrlKey : r === "shift" ? C.shiftKey : !0 : !0, q = (C) => {
580
+ if (a) return;
581
+ if (!Z(C)) {
582
+ N && (N = !1, I());
583
+ return;
584
+ }
585
+ const X = e.host.getBoundingClientRect(), R = C.clientX >= X.left - Y && C.clientX <= X.right + Y && C.clientY >= X.top - Y && C.clientY <= X.bottom + Y;
586
+ R && !N ? (N = !0, A()) : !R && N && (N = !1, I());
587
+ };
588
+ return document.addEventListener("pointermove", q, { passive: !0 }), () => {
589
+ a && (document.documentElement.style.cursor = "", e.unexpose("resizing")), document.removeEventListener("pointermove", q), document.removeEventListener("pointermove", M), document.removeEventListener("pointerup", k), _.disconnect(), L(), b.remove();
590
+ };
591
+ }
592
+ }, Ie = {
593
+ name: "pan-zoom",
594
+ category: "gesture",
595
+ channel: "pointer",
596
+ defaults: {
597
+ "min-zoom": "0.1",
598
+ "max-zoom": "5",
599
+ "zoom-step": "0.1"
600
+ },
601
+ attach(e) {
602
+ const t = Number(e.config("min-zoom") ?? "0.1"), s = Number(e.config("max-zoom") ?? "5"), n = Number(e.config("zoom-step") ?? "0.1");
603
+ let r = 0, o = 0, a = 1, h = !1, f = !1, i = 0, l = 0, c = 0, d = 0;
604
+ const u = () => {
605
+ e.host.style.setProperty("--_pan-x", `${r}px`), e.host.style.setProperty("--_pan-y", `${o}px`), e.host.style.setProperty("--_pan-zoom", `${a}`), e.expose("scale", a.toFixed(2)), e.expose("x", Math.round(r).toString()), e.expose("y", Math.round(o).toString()), e.emit("pan-zoom-change", { x: r, y: o, scale: a });
606
+ }, p = (E) => Math.min(s, Math.max(t, E)), g = (E) => {
607
+ (E.button === 1 || E.button === 0 && f) && (E.preventDefault(), h = !0, i = E.clientX, l = E.clientY, c = r, d = o, e.host.setPointerCapture(E.pointerId));
608
+ }, v = (E) => {
609
+ h && (E.preventDefault(), r = c + (E.clientX - i), o = d + (E.clientY - l), u());
610
+ }, P = (E) => {
611
+ h && (h = !1, e.host.releasePointerCapture(E.pointerId));
612
+ }, M = (E) => {
613
+ if (!E.ctrlKey) return;
614
+ E.preventDefault();
615
+ const _ = e.host.getBoundingClientRect(), U = E.clientX - _.left, j = E.clientY - _.top, Q = a, H = E.deltaY > 0 ? -n : n;
616
+ a = p(a + H);
617
+ const L = a / Q;
618
+ r = U - L * (U - r), o = j - L * (j - o), u();
619
+ }, k = (E) => {
620
+ if (E.code === "Space" && !E.repeat && !f) {
621
+ const _ = E.target.tagName;
622
+ if (_ === "INPUT" || _ === "TEXTAREA") return;
623
+ f = !0, e.expose("panning", !0);
624
+ }
625
+ }, b = (E) => {
626
+ E.code === "Space" && (f = !1, e.unexpose("panning"));
627
+ }, O = (E) => {
628
+ E.button !== 1 && !E.ctrlKey || (r = 0, o = 0, a = 1, u());
629
+ };
630
+ return e.host.addEventListener("pointerdown", g), e.host.addEventListener("pointermove", v), e.host.addEventListener("pointerup", P), e.host.addEventListener("wheel", M, { passive: !1 }), e.host.addEventListener("dblclick", O), document.addEventListener("keydown", k), document.addEventListener("keyup", b), u(), () => {
631
+ e.host.removeEventListener("pointerdown", g), e.host.removeEventListener("pointermove", v), e.host.removeEventListener("pointerup", P), e.host.removeEventListener("wheel", M), e.host.removeEventListener("dblclick", O), document.removeEventListener("keydown", k), document.removeEventListener("keyup", b), e.host.style.removeProperty("--_pan-x"), e.host.style.removeProperty("--_pan-y"), e.host.style.removeProperty("--_pan-zoom");
632
+ };
633
+ }
634
+ }, $e = {
635
+ name: "hover",
636
+ category: "state",
637
+ targets: "self",
638
+ defaults: {
639
+ delay: "0",
640
+ "leave-delay": "0"
641
+ },
642
+ attach(e) {
643
+ const t = Number(e.config("delay") ?? "0"), s = Number(e.config("leave-delay") ?? "0");
644
+ let n, r;
645
+ const o = () => {
646
+ e.expose("active", !0), e.emit("hover-enter", {});
647
+ }, a = () => {
648
+ e.expose("active", !1), e.emit("hover-leave", {});
649
+ }, h = () => {
650
+ clearTimeout(r), t > 0 ? n = setTimeout(o, t) : o();
651
+ }, f = () => {
652
+ clearTimeout(n), s > 0 ? r = setTimeout(a, s) : a();
653
+ };
654
+ return e.host.addEventListener("mouseenter", h), e.host.addEventListener("mouseleave", f), () => {
655
+ e.host.removeEventListener("mouseenter", h), e.host.removeEventListener("mouseleave", f), clearTimeout(n), clearTimeout(r);
656
+ };
657
+ }
658
+ }, ze = {
659
+ name: "toggle-state",
660
+ category: "state",
661
+ targets: "self",
662
+ defaults: {
663
+ active: "false"
664
+ },
665
+ actions: ["press"],
666
+ attach(e) {
667
+ const t = ne(e.config("active") === "true"), s = () => {
668
+ t.value = !t.value, e.emit("toggle", { active: t.value });
669
+ };
670
+ return e.host.addEventListener("press", s), e.addEffect(() => {
671
+ e.expose("active", t.value), e.host.setAttribute("aria-pressed", String(t.value));
672
+ }), () => {
673
+ e.host.removeEventListener("press", s), e.host.removeAttribute("aria-pressed");
674
+ };
675
+ }
676
+ }, we = "aui-color-scheme", Re = {
677
+ system: "desktop",
678
+ light: "sun",
679
+ dark: "moon"
680
+ }, ue = () => matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", De = (e, t) => {
681
+ const n = (e === "system" ? ue() : e) === "dark" ? "light" : "dark", r = t.indexOf(e);
682
+ for (let o = 1; o < t.length; o++) {
683
+ const a = t[(r + o) % t.length];
684
+ if ((a === "system" ? ue() : a) === n) return a;
685
+ }
686
+ return t[(r + 1) % t.length];
687
+ }, He = (e) => e === "light" || e === "dark" || e === "system" ? e : "system", Ye = (e) => e ? e.split(",").map((t) => t.trim()).filter(
688
+ (t) => t === "system" || t === "light" || t === "dark"
689
+ ) : ["system", "light", "dark"], Ne = () => {
690
+ try {
691
+ const e = localStorage.getItem(we);
692
+ if (e === "light" || e === "dark" || e === "system") return e;
693
+ } catch {
694
+ }
695
+ return null;
696
+ }, Xe = (e) => {
697
+ try {
698
+ localStorage.setItem(we, e);
699
+ } catch {
700
+ }
701
+ }, Oe = (e, t, s) => {
702
+ const n = e === "document" ? document.documentElement : document.querySelector(e);
703
+ n && (t === "system" ? (n.style.removeProperty("color-scheme"), n.removeAttribute("data-color-scheme")) : (n.style.colorScheme = s, n.setAttribute("data-color-scheme", s)));
704
+ }, _e = {
705
+ name: "toggle-scheme",
706
+ category: "state",
707
+ targets: "external",
708
+ defaults: {
709
+ scheme: "system",
710
+ schemes: "system,light,dark",
711
+ target: "document",
712
+ persist: "false"
713
+ },
714
+ actions: ["press"],
715
+ attach(e) {
716
+ const t = e.config("persist") === "true", s = Ye(e.config("schemes")), n = e.config("target") ?? "document", r = t ? Ne() : null, o = ne(r ?? He(e.config("scheme"))), a = () => {
717
+ const i = De(o.value, s);
718
+ o.value = i, t && Xe(i), e.emit("scheme-change", { scheme: i });
719
+ };
720
+ e.host.addEventListener("press", a), e.addEffect(() => {
721
+ const i = o.value, l = i === "system" ? ue() : i;
722
+ e.host.setAttribute("icon", Re[i]), e.host.setAttribute("label", `Color scheme: ${i}`), e.expose("scheme", i), Oe(n, i, l);
723
+ });
724
+ const h = matchMedia("(prefers-color-scheme: dark)"), f = () => {
725
+ o.value === "system" && (o.value = "system");
726
+ };
727
+ return h.addEventListener("change", f), () => {
728
+ e.host.removeEventListener("press", a), h.removeEventListener("change", f);
729
+ };
730
+ }
731
+ }, qe = {
732
+ name: "copy",
733
+ category: "state",
734
+ targets: "self",
735
+ defaults: {
736
+ text: "",
737
+ feedback: "1500"
738
+ },
739
+ actions: ["press"],
740
+ attach(e) {
741
+ const t = parseInt(e.config("feedback") ?? "1500", 10);
742
+ let s = null, n = null;
743
+ const r = () => {
744
+ s !== null && (clearTimeout(s), s = null);
745
+ }, o = () => {
746
+ r(), e.unexpose("copied"), n !== null && (e.host.setAttribute("label", n), n = null);
747
+ }, a = () => {
748
+ const h = e.config("text") || e.host.textContent || "";
749
+ navigator.clipboard.writeText(h).then(() => {
750
+ o(), n = e.host.getAttribute("label"), e.expose("copied", !0), e.host.setAttribute("label", "Copied!"), e.emit("copy", { text: h }), s = setTimeout(o, t);
751
+ });
752
+ };
753
+ return e.host.addEventListener("press", a), () => {
754
+ o(), e.host.removeEventListener("press", a);
755
+ };
756
+ }
757
+ }, Fe = {
758
+ name: "clipboard",
759
+ category: "state",
760
+ targets: "self",
761
+ defaults: {
762
+ accept: "text/plain,text/html,image/*",
763
+ prevent: "true"
764
+ },
765
+ attach(e) {
766
+ const t = (s) => {
767
+ const n = s, r = e.config("prevent") !== "false", o = (e.config("accept") ?? "").split(",").map((d) => d.trim());
768
+ r && n.preventDefault();
769
+ const a = n.clipboardData;
770
+ if (!a) return;
771
+ const h = Array.from(a.types);
772
+ let f, i;
773
+ const l = [], c = (d) => o.some((u) => u.endsWith("/*") ? d.startsWith(u.slice(0, -1)) : d === u);
774
+ c("text/plain") && (f = a.getData("text/plain") || void 0), c("text/html") && (i = a.getData("text/html") || void 0);
775
+ for (let d = 0; d < a.files.length; d++) {
776
+ const u = a.files[d];
777
+ c(u.type) && l.push(u);
778
+ }
779
+ e.expose("has-data", !0), e.emit("paste", {
780
+ text: f ?? "",
781
+ html: i ?? "",
782
+ files: l,
783
+ types: h
784
+ });
785
+ };
786
+ return e.host.addEventListener("paste", t), () => {
787
+ e.host.removeEventListener("paste", t), e.unexpose("has-data");
788
+ };
789
+ }
790
+ }, Be = (e) => {
791
+ const t = e.toLowerCase().split("+").map((s) => s.trim());
792
+ return {
793
+ ctrl: t.includes("ctrl"),
794
+ alt: t.includes("alt"),
795
+ shift: t.includes("shift"),
796
+ meta: t.includes("meta"),
797
+ key: t.filter((s) => !["ctrl", "alt", "shift", "meta"].includes(s))[0] ?? ""
798
+ };
799
+ }, Ke = (e, t) => e.ctrlKey === t.ctrl && e.altKey === t.alt && e.shiftKey === t.shift && e.metaKey === t.meta && e.key.toLowerCase() === t.key, We = {
800
+ name: "shortcut",
801
+ category: "state",
802
+ defaults: {
803
+ key: "",
804
+ global: "false"
805
+ },
806
+ attach(e) {
807
+ const t = e.config("key") ?? "";
808
+ if (t === "") return;
809
+ const s = (e.config("global") ?? "false") === "true", n = Be(t), r = s ? document : e.host, o = (a) => {
810
+ const h = a;
811
+ Ke(h, n) && (h.preventDefault(), e.emit("shortcut", { key: t }), e.emit("press", {}));
812
+ };
813
+ return r.addEventListener("keydown", o), () => {
814
+ r.removeEventListener("keydown", o);
815
+ };
816
+ }
817
+ }, Ue = {
818
+ name: "search",
819
+ category: "state",
820
+ targets: "self",
821
+ defaults: {
822
+ selector: "> *",
823
+ attr: "textContent",
824
+ debounce: "150"
825
+ },
826
+ actions: ["search"],
827
+ attach(e) {
828
+ const t = e.config("selector") ?? "> *", s = e.config("attr") ?? "textContent", n = Number(e.config("debounce") ?? "150");
829
+ let r, o = "";
830
+ const a = t.startsWith("> ") ? `:scope ${t}` : t, h = () => [...e.host.querySelectorAll(a)].filter((u) => u.tagName !== "INPUT"), f = (u) => s === "textContent" ? (u.textContent ?? "").trim() : (u.getAttribute(s) ?? "").trim(), i = (u) => {
831
+ o = u;
832
+ const p = u.toLowerCase(), g = h();
833
+ let v = 0;
834
+ for (const P of g) {
835
+ const M = f(P).toLowerCase();
836
+ p === "" || M.includes(p) ? (P.removeAttribute("hidden"), v++) : P.setAttribute("hidden", "");
837
+ }
838
+ e.expose("count", String(v)), e.expose("query", o), e.emit("search-results", { count: v, query: o });
839
+ }, l = (u) => {
840
+ clearTimeout(r), r = setTimeout(() => i(u), n);
841
+ }, c = (u) => {
842
+ const g = u.detail?.query ?? "";
843
+ l(g);
844
+ }, d = (u) => {
845
+ const p = u.target;
846
+ p?.tagName === "INPUT" && l(p.value);
847
+ };
848
+ return e.host.addEventListener("search", c), e.host.addEventListener("input", d), () => {
849
+ e.host.removeEventListener("search", c), e.host.removeEventListener("input", d), clearTimeout(r);
850
+ };
851
+ }
852
+ };
853
+ function Ve(e, t) {
854
+ if (t === "*" || t === "*/*") return !0;
855
+ if (t.endsWith("/*")) {
856
+ const s = t.slice(0, t.indexOf("/"));
857
+ return e.startsWith(s + "/");
858
+ }
859
+ return e === t;
860
+ }
861
+ function de(e, t) {
862
+ if (t.length === 1 && (t[0] === "*" || t[0] === "*/*")) return !0;
863
+ for (let s = 0; s < e.items.length; s++) {
864
+ const n = e.items[s];
865
+ if (t.some((r) => Ve(n.type, r))) return !0;
866
+ }
867
+ return !1;
868
+ }
869
+ const Ze = {
870
+ name: "drop-zone",
871
+ category: "state",
872
+ defaults: {
873
+ accept: "*",
874
+ overlay: "true"
875
+ },
876
+ attach(e) {
877
+ const s = (e.config("accept") ?? "*").split(",").map((f) => f.trim());
878
+ let n = 0;
879
+ const r = (f) => {
880
+ const i = f;
881
+ i.dataTransfer && de(i.dataTransfer, s) && (i.preventDefault(), i.dataTransfer.dropEffect = "copy");
882
+ }, o = (f) => {
883
+ const i = f;
884
+ i.dataTransfer && de(i.dataTransfer, s) && (i.preventDefault(), n++, n === 1 && e.expose("over", !0));
885
+ }, a = (f) => {
886
+ n--, n <= 0 && (n = 0, e.expose("over", !1));
887
+ }, h = (f) => {
888
+ const i = f;
889
+ if (i.preventDefault(), n = 0, e.expose("over", !1), !i.dataTransfer || !de(i.dataTransfer, s)) return;
890
+ const l = i.dataTransfer.getData("text/plain");
891
+ e.emit("drop", {
892
+ files: i.dataTransfer.files,
893
+ items: i.dataTransfer.items,
894
+ text: l
895
+ });
896
+ };
897
+ return e.host.addEventListener("dragover", r), e.host.addEventListener("dragenter", o), e.host.addEventListener("dragleave", a), e.host.addEventListener("drop", h), () => {
898
+ e.host.removeEventListener("dragover", r), e.host.removeEventListener("dragenter", o), e.host.removeEventListener("dragleave", a), e.host.removeEventListener("drop", h);
899
+ };
900
+ }
901
+ }, Ge = {
902
+ name: "edit",
903
+ category: "state",
904
+ defaults: {
905
+ event: "dblclick",
906
+ commit: "blur"
907
+ },
908
+ attach(e) {
909
+ const t = e.config("event") ?? "dblclick", s = e.config("commit") ?? "blur";
910
+ let n = !1, r = "";
911
+ const o = () => {
912
+ const d = document.createRange();
913
+ d.selectNodeContents(e.host);
914
+ const u = window.getSelection();
915
+ u && (u.removeAllRanges(), u.addRange(d));
916
+ }, a = () => {
917
+ n || (n = !0, r = e.host.textContent ?? "", e.host.contentEditable = "true", e.host.focus(), o(), e.expose("editing", !0));
918
+ }, h = () => {
919
+ if (!n) return;
920
+ n = !1, e.host.contentEditable = "false", e.unexpose("editing");
921
+ const d = e.host.textContent ?? "";
922
+ e.emit("edit-commit", { value: d, previous: r });
923
+ }, f = () => {
924
+ n && (n = !1, e.host.textContent = r, e.host.contentEditable = "false", e.unexpose("editing"), e.emit("edit-cancel", {}));
925
+ }, i = () => {
926
+ a();
927
+ }, l = () => {
928
+ s === "blur" && h();
929
+ }, c = (d) => {
930
+ if (!n) return;
931
+ const u = d;
932
+ if (u.key === "Escape") {
933
+ u.preventDefault(), f();
934
+ return;
935
+ }
936
+ u.key === "Enter" && s === "enter" && (u.preventDefault(), h());
937
+ };
938
+ return e.host.addEventListener(t, i), e.host.addEventListener("blur", l), e.host.addEventListener("keydown", c), () => {
939
+ n && (e.host.contentEditable = "false", e.unexpose("editing")), e.host.removeEventListener(t, i), e.host.removeEventListener("blur", l), e.host.removeEventListener("keydown", c);
940
+ };
941
+ }
942
+ }, Je = {
943
+ name: "intersect",
944
+ category: "state",
945
+ targets: "self",
946
+ defaults: {
947
+ threshold: "0",
948
+ "root-margin": "0px",
949
+ once: "false"
950
+ },
951
+ attach(e) {
952
+ const t = Number(e.config("threshold") ?? "0"), s = e.config("root-margin") ?? "0px", n = (e.config("once") ?? "false") === "true", r = new IntersectionObserver(
953
+ (o) => {
954
+ for (const a of o) {
955
+ const h = a.isIntersecting;
956
+ e.expose("visible", h), e.emit("intersect", {
957
+ isIntersecting: h,
958
+ ratio: a.intersectionRatio
959
+ }), n && h && r.disconnect();
960
+ }
961
+ },
962
+ {
963
+ threshold: t,
964
+ rootMargin: s
965
+ }
966
+ );
967
+ return r.observe(e.host), () => {
968
+ r.disconnect();
969
+ };
970
+ }
971
+ }, je = /https?:\/\/[^\s<>"{}|\\^`[\]]+/, Qe = {
972
+ name: "link-paste",
973
+ category: "state",
974
+ targets: "self",
975
+ defaults: {
976
+ auto: "true"
977
+ },
978
+ attach(e) {
979
+ const t = (s) => {
980
+ const n = s;
981
+ if (!(e.config("auto") !== "false")) return;
982
+ const o = n.clipboardData;
983
+ if (!o) return;
984
+ const a = o.getData("text/plain");
985
+ if (!a) return;
986
+ const h = je.exec(a.trim());
987
+ if (!h) {
988
+ e.expose("url", "");
989
+ return;
990
+ }
991
+ const f = h[0];
992
+ e.expose("url", f), e.emit("link-paste", { url: f, text: a.trim() });
993
+ };
994
+ return e.host.addEventListener("paste", t), () => {
995
+ e.host.removeEventListener("paste", t), e.unexpose("url");
996
+ };
997
+ }
998
+ }, xe = {
999
+ name: "linked-scroll",
1000
+ category: "state",
1001
+ targets: "external",
1002
+ defaults: {
1003
+ target: "",
1004
+ axis: "both"
1005
+ },
1006
+ attach(e) {
1007
+ const t = e.config("target");
1008
+ if (!t) {
1009
+ console.warn('[agent-ui] linked-scroll trait: missing required "target" config.');
1010
+ return;
1011
+ }
1012
+ const s = e.config("axis") ?? "both";
1013
+ let n = !1;
1014
+ const r = document.querySelector(t);
1015
+ if (!r) {
1016
+ console.warn(`[agent-ui] linked-scroll trait: target "${t}" not found.`);
1017
+ return;
1018
+ }
1019
+ const o = (f, i) => {
1020
+ if (!n) {
1021
+ if (n = !0, e.expose("syncing", !0), s === "both" || s === "x") {
1022
+ const l = f.scrollWidth - f.clientWidth, c = l > 0 ? f.scrollLeft / l : 0, d = i.scrollWidth - i.clientWidth;
1023
+ i.scrollLeft = c * d;
1024
+ }
1025
+ if (s === "both" || s === "y") {
1026
+ const l = f.scrollHeight - f.clientHeight, c = l > 0 ? f.scrollTop / l : 0, d = i.scrollHeight - i.clientHeight;
1027
+ i.scrollTop = c * d;
1028
+ }
1029
+ requestAnimationFrame(() => {
1030
+ n = !1, e.expose("syncing", !1);
1031
+ });
1032
+ }
1033
+ }, a = () => o(e.host, r), h = () => o(r, e.host);
1034
+ return e.host.addEventListener("scroll", a, { passive: !0 }), r.addEventListener("scroll", h, { passive: !0 }), () => {
1035
+ e.host.removeEventListener("scroll", a), r.removeEventListener("scroll", h);
1036
+ };
1037
+ }
1038
+ }, et = {
1039
+ name: "mention",
1040
+ category: "state",
1041
+ targets: "self",
1042
+ defaults: {
1043
+ trigger: "@",
1044
+ "min-length": "1"
1045
+ },
1046
+ actions: ["mention-select"],
1047
+ attach(e) {
1048
+ const t = e.config("trigger") ?? "@", s = parseInt(e.config("min-length") ?? "1", 10), n = ne(!1);
1049
+ let r = -1;
1050
+ const o = () => {
1051
+ const i = e.host;
1052
+ return i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement ? i.value : i.textContent ?? "";
1053
+ }, a = () => {
1054
+ const i = e.host;
1055
+ if (i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement)
1056
+ return i.selectionStart ?? i.value.length;
1057
+ const l = window.getSelection();
1058
+ return l && l.rangeCount > 0 && i.contains(l.anchorNode) ? l.anchorOffset : (i.textContent ?? "").length;
1059
+ }, h = () => {
1060
+ const i = o(), l = a(), c = i.slice(0, l), d = c.lastIndexOf(t);
1061
+ if (d === -1) {
1062
+ n.value && (n.value = !1);
1063
+ return;
1064
+ }
1065
+ if (d > 0 && !/\s/.test(c[d - 1])) {
1066
+ n.value && (n.value = !1);
1067
+ return;
1068
+ }
1069
+ const u = c.slice(d + t.length);
1070
+ if (/\s/.test(u)) {
1071
+ n.value && (n.value = !1);
1072
+ return;
1073
+ }
1074
+ u.length >= s ? (r = d, n.value = !0, e.emit("mention-search", { query: u })) : n.value && (n.value = !1);
1075
+ }, f = (i) => {
1076
+ const l = i.detail, c = String(l?.text ?? "");
1077
+ if (!c || r === -1) return;
1078
+ const d = e.host, u = o(), p = a(), g = u.slice(0, r), v = u.slice(p), P = `${t}${c} `;
1079
+ if (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement) {
1080
+ d.value = g + P + v;
1081
+ const M = g.length + P.length;
1082
+ d.setSelectionRange(M, M);
1083
+ } else
1084
+ d.textContent = g + P + v;
1085
+ n.value = !1, r = -1;
1086
+ };
1087
+ return e.host.addEventListener("input", h), e.host.addEventListener("mention-select", f), e.addEffect(() => {
1088
+ e.expose("active", n.value);
1089
+ }), () => {
1090
+ e.host.removeEventListener("input", h), e.host.removeEventListener("mention-select", f);
1091
+ };
1092
+ }
1093
+ }, tt = {
1094
+ name: "persist",
1095
+ category: "state",
1096
+ targets: "self",
1097
+ defaults: {
1098
+ key: "",
1099
+ debounce: "300"
1100
+ },
1101
+ attach(e) {
1102
+ const t = e.config("key");
1103
+ if (!t) {
1104
+ console.warn('[agent-ui] persist trait: missing required "key" config.');
1105
+ return;
1106
+ }
1107
+ const s = parseInt(e.config("debounce") ?? "300", 10);
1108
+ let n = null;
1109
+ try {
1110
+ const o = localStorage.getItem(t);
1111
+ if (o !== null) {
1112
+ const a = JSON.parse(o);
1113
+ e.emit("persist-load", { state: a });
1114
+ }
1115
+ } catch {
1116
+ }
1117
+ e.expose("ready", !0);
1118
+ const r = (o) => {
1119
+ const a = o.detail;
1120
+ a?.state && (n !== null && clearTimeout(n), n = setTimeout(() => {
1121
+ n = null;
1122
+ try {
1123
+ localStorage.setItem(t, JSON.stringify(a.state));
1124
+ } catch {
1125
+ }
1126
+ }, s));
1127
+ };
1128
+ return e.host.addEventListener("persist-save", r), () => {
1129
+ e.host.removeEventListener("persist-save", r), n !== null && clearTimeout(n);
1130
+ };
1131
+ }
1132
+ }, st = {
1133
+ name: "range-select",
1134
+ category: "state",
1135
+ defaults: {
1136
+ selector: "> *",
1137
+ attr: "selected"
1138
+ },
1139
+ attach(e) {
1140
+ const t = e.config("selector") ?? "> *", s = e.config("attr") ?? "selected";
1141
+ let n = -1;
1142
+ const r = t.startsWith("> ") ? `:scope ${t}` : t, o = () => Array.from(e.host.querySelectorAll(r)), a = (l) => l.reduce((c, d, u) => (d.hasAttribute(s) && c.push(u), c), []), h = (l) => {
1143
+ const c = a(l);
1144
+ e.expose("count", String(c.length)), e.emit("selection-change", { selected: c, count: c.length });
1145
+ }, f = (l) => {
1146
+ for (const c of l)
1147
+ c.removeAttribute(s);
1148
+ }, i = (l) => {
1149
+ const c = l, d = c.target, u = o();
1150
+ let p = -1;
1151
+ for (let g = 0; g < u.length; g++)
1152
+ if (u[g].contains(d)) {
1153
+ p = g;
1154
+ break;
1155
+ }
1156
+ if (p !== -1) {
1157
+ if (c.shiftKey && n !== -1) {
1158
+ const g = Math.min(n, p), v = Math.max(n, p);
1159
+ f(u);
1160
+ for (let P = g; P <= v; P++)
1161
+ u[P].setAttribute(s, "");
1162
+ } else c.metaKey || c.ctrlKey ? (u[p].hasAttribute(s) ? u[p].removeAttribute(s) : u[p].setAttribute(s, ""), n = p) : (f(u), u[p].setAttribute(s, ""), n = p);
1163
+ h(u);
1164
+ }
1165
+ };
1166
+ return e.host.addEventListener("click", i), e.expose("count", "0"), () => {
1167
+ e.host.removeEventListener("click", i);
1168
+ };
1169
+ }
1170
+ }, nt = {
1171
+ name: "selection",
1172
+ category: "state",
1173
+ defaults: {
1174
+ mode: "single",
1175
+ selector: "> *"
1176
+ },
1177
+ actions: ["press"],
1178
+ attach(e) {
1179
+ const t = e.config("mode") ?? "single", s = e.config("selector") ?? "> *", n = "selected", r = s.startsWith("> ") ? `:scope ${s}` : s, o = () => Array.from(e.host.querySelectorAll(r)), a = (i) => i.filter((l) => l.hasAttribute(n)).map((l) => l.dataset.value ?? ""), h = (i) => {
1180
+ const l = i.filter((c) => c.hasAttribute(n)).length;
1181
+ e.expose("count", String(l));
1182
+ }, f = (i) => {
1183
+ const l = i.target, c = o();
1184
+ let d = null;
1185
+ for (const v of c)
1186
+ if (v === l || v.contains(l)) {
1187
+ d = v;
1188
+ break;
1189
+ }
1190
+ if (!d) return;
1191
+ const u = d.hasAttribute(n), p = d.dataset.value ?? "";
1192
+ if (t === "single") {
1193
+ for (const v of c)
1194
+ v.removeAttribute(n);
1195
+ u || d.setAttribute(n, "");
1196
+ } else
1197
+ u ? d.removeAttribute(n) : d.setAttribute(n, "");
1198
+ const g = a(c);
1199
+ h(c), e.emit("select", {
1200
+ value: p,
1201
+ selected: !u,
1202
+ all: g
1203
+ });
1204
+ };
1205
+ return e.host.addEventListener("press", f), e.expose("count", "0"), () => {
1206
+ e.host.removeEventListener("press", f);
1207
+ };
1208
+ }
1209
+ }, ot = {
1210
+ name: "slash-command",
1211
+ category: "state",
1212
+ targets: "self",
1213
+ defaults: {
1214
+ trigger: "/",
1215
+ commands: ""
1216
+ },
1217
+ attach(e) {
1218
+ const t = e.config("trigger") ?? "/", s = ne(!1);
1219
+ let n = "";
1220
+ const r = () => {
1221
+ const h = e.host;
1222
+ return h instanceof HTMLInputElement || h instanceof HTMLTextAreaElement ? h.value : h.textContent ?? "";
1223
+ }, o = () => {
1224
+ const h = r();
1225
+ if (h.startsWith(t)) {
1226
+ const f = h.slice(t.length);
1227
+ n = f, s.value = !0, e.emit("command-input", { partial: f });
1228
+ } else
1229
+ s.value && (s.value = !1, n = "");
1230
+ }, a = (h) => {
1231
+ const f = h;
1232
+ if (f.key !== "Enter" || !s.value) return;
1233
+ f.preventDefault();
1234
+ const i = n.split(/\s+/), l = i[0] ?? "", c = i.slice(1).join(" "), d = (e.config("commands") ?? "").split(",").map((u) => u.trim()).filter(Boolean);
1235
+ d.length > 0 && !d.includes(l) || (e.emit("command", { command: l, args: c }), s.value = !1, n = "");
1236
+ };
1237
+ return e.host.addEventListener("input", o), e.host.addEventListener("keydown", a), e.addEffect(() => {
1238
+ e.expose("active", s.value);
1239
+ }), () => {
1240
+ e.host.removeEventListener("input", o), e.host.removeEventListener("keydown", a);
1241
+ };
1242
+ }
1243
+ }, he = "data-stamped", rt = {
1244
+ name: "store",
1245
+ category: "state",
1246
+ defaults: {
1247
+ target: ":scope",
1248
+ "group-tag": "aui-group"
1249
+ },
1250
+ attach(e) {
1251
+ const t = e.host, s = e.config("target") ?? ":scope", n = e.config("group-tag") ?? "aui-group", r = () => s === ":scope" ? t : t.querySelector(s) ?? t, a = (() => {
1252
+ if (t.__listStore) return t.__listStore;
1253
+ const d = t.getAttribute("store");
1254
+ if (d) {
1255
+ const p = fe(d);
1256
+ if (p) return ce(p);
1257
+ }
1258
+ const u = t.getAttribute("options");
1259
+ if (u) {
1260
+ const p = pe(u);
1261
+ if (p) return ce(p);
1262
+ }
1263
+ return ce([]);
1264
+ })(), h = (d) => {
1265
+ const u = document.createElement("aui-option");
1266
+ return u.setAttribute("value", d.id), u.setAttribute("label", d.label), d.disabled && u.setAttribute("disabled", ""), d.icon && u.setAttribute("icon", d.icon), d.prefix && u.setAttribute("prefix", d.prefix), d.suffix && u.setAttribute("suffix", d.suffix), d.keywords && u.setAttribute("keywords", d.keywords), u.setAttribute(he, ""), u;
1267
+ }, f = (d) => {
1268
+ const u = document.createElement(n);
1269
+ u.setAttribute("heading", d.heading), u.setAttribute(he, "");
1270
+ for (const p of d.items)
1271
+ u.appendChild(h(p));
1272
+ return u;
1273
+ }, i = (d) => {
1274
+ const u = d.querySelectorAll(`[${he}]`);
1275
+ for (const p of u) p.remove();
1276
+ }, l = (d, u) => {
1277
+ i(u);
1278
+ const p = document.createDocumentFragment();
1279
+ let g = 0;
1280
+ if (Ae(d))
1281
+ for (const v of d)
1282
+ p.appendChild(f(v)), g += v.items.length;
1283
+ else
1284
+ for (const v of d)
1285
+ p.appendChild(h(v)), g++;
1286
+ u.appendChild(p), e.expose("count", String(g));
1287
+ };
1288
+ e.addEffect(() => {
1289
+ const d = a.data.value, u = r();
1290
+ l(d, u);
1291
+ });
1292
+ const c = new MutationObserver((d) => {
1293
+ for (const u of d)
1294
+ if (u.type === "attributes") {
1295
+ const p = u.attributeName;
1296
+ if (p === "store" || p === "options") {
1297
+ let g = null;
1298
+ if (p === "store") {
1299
+ const v = t.getAttribute("store");
1300
+ v && (g = fe(v));
1301
+ } else {
1302
+ const v = t.getAttribute("options");
1303
+ v && (g = pe(v));
1304
+ }
1305
+ g && (a.data.value = g);
1306
+ }
1307
+ }
1308
+ });
1309
+ return c.observe(t, {
1310
+ attributes: !0,
1311
+ attributeFilter: ["store", "options"]
1312
+ }), () => {
1313
+ c.disconnect(), i(r());
1314
+ };
1315
+ }
1316
+ }, it = {
1317
+ name: "text-trigger",
1318
+ category: "state",
1319
+ targets: "self",
1320
+ defaults: {
1321
+ pattern: "",
1322
+ trigger: ""
1323
+ },
1324
+ attach(e) {
1325
+ const t = e.config("pattern") ?? "";
1326
+ if (!t) return;
1327
+ const s = e.config("trigger") ?? "", n = ne(!1);
1328
+ let r;
1329
+ try {
1330
+ r = new RegExp(t);
1331
+ } catch {
1332
+ return;
1333
+ }
1334
+ const o = () => {
1335
+ const h = e.host;
1336
+ return h instanceof HTMLInputElement || h instanceof HTMLTextAreaElement ? h.value : h.textContent ?? "";
1337
+ }, a = () => {
1338
+ const h = o();
1339
+ if (s && !h.includes(s)) {
1340
+ n.value && (n.value = !1);
1341
+ return;
1342
+ }
1343
+ const f = r.exec(h);
1344
+ f ? (n.value = !0, e.emit("text-trigger", {
1345
+ match: f[0],
1346
+ groups: f.slice(1)
1347
+ })) : n.value && (n.value = !1);
1348
+ };
1349
+ return e.host.addEventListener("input", a), e.addEffect(() => {
1350
+ e.expose("matched", n.value);
1351
+ }), () => {
1352
+ e.host.removeEventListener("input", a);
1353
+ };
1354
+ }
1355
+ }, at = {
1356
+ name: "backtick-wrap",
1357
+ category: "state",
1358
+ targets: "self",
1359
+ attach(e) {
1360
+ const t = (s) => {
1361
+ const n = s;
1362
+ if (n.key !== "`") return;
1363
+ const r = e.host;
1364
+ let o = "", a = 0, h = 0;
1365
+ if (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement)
1366
+ a = r.selectionStart ?? 0, h = r.selectionEnd ?? 0, o = r.value.slice(a, h);
1367
+ else {
1368
+ const l = window.getSelection();
1369
+ l && l.rangeCount > 0 && (o = l.toString());
1370
+ }
1371
+ if (!o) return;
1372
+ n.preventDefault();
1373
+ const i = o.includes(`
1374
+ `) ? `\`\`\`
1375
+ ${o}
1376
+ \`\`\`` : `\`${o}\``;
1377
+ if (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) {
1378
+ const l = r.value.slice(0, a), c = r.value.slice(h);
1379
+ r.value = l + i + c;
1380
+ const d = a + i.length;
1381
+ r.setSelectionRange(d, d);
1382
+ } else {
1383
+ const l = window.getSelection();
1384
+ if (l && l.rangeCount > 0) {
1385
+ const c = l.getRangeAt(0);
1386
+ c.deleteContents(), c.insertNode(document.createTextNode(i)), l.collapseToEnd();
1387
+ }
1388
+ }
1389
+ e.emit("backtick-wrap", { text: o, wrapped: i });
1390
+ };
1391
+ return e.host.addEventListener("keydown", t), () => {
1392
+ e.host.removeEventListener("keydown", t);
1393
+ };
1394
+ }
1395
+ }, lt = {
1396
+ name: "validate",
1397
+ category: "state",
1398
+ targets: "self",
1399
+ defaults: {
1400
+ required: "false",
1401
+ pattern: "",
1402
+ "min-length": "",
1403
+ "max-length": "",
1404
+ message: ""
1405
+ },
1406
+ attach(e) {
1407
+ const t = ne(!0), s = ne(""), n = () => {
1408
+ const o = e.host;
1409
+ return o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement ? o.value : o.textContent ?? "";
1410
+ }, r = () => {
1411
+ const o = n(), a = e.config("required") === "true", h = e.config("pattern") ?? "", f = e.config("min-length") ?? "", i = e.config("max-length") ?? "", l = e.config("message") ?? "";
1412
+ let c = "";
1413
+ if (a && !o.trim() && (c = l || "This field is required"), !c && f) {
1414
+ const p = parseInt(f, 10);
1415
+ !isNaN(p) && o.length < p && (c = l || `Minimum ${p} characters`);
1416
+ }
1417
+ if (!c && i) {
1418
+ const p = parseInt(i, 10);
1419
+ !isNaN(p) && o.length > p && (c = l || `Maximum ${p} characters`);
1420
+ }
1421
+ if (!c && h)
1422
+ try {
1423
+ new RegExp(h).test(o) || (c = l || "Invalid format");
1424
+ } catch {
1425
+ }
1426
+ const d = !c;
1427
+ t.value = d, s.value = c;
1428
+ const u = e.host.internals;
1429
+ u?.setValidity && (d ? u.setValidity({}) : u.setValidity({ customError: !0 }, c)), e.emit("validate", { valid: d, message: c, value: o });
1430
+ };
1431
+ return e.host.addEventListener("blur", r), e.host.addEventListener("input", r), e.addEffect(() => {
1432
+ e.expose("valid", t.value), e.expose("message", s.value);
1433
+ }), () => {
1434
+ e.host.removeEventListener("blur", r), e.host.removeEventListener("input", r);
1435
+ };
1436
+ }
1437
+ }, ct = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])', dt = {
1438
+ name: "trap-focus",
1439
+ category: "focus",
1440
+ targets: "self",
1441
+ attach(e) {
1442
+ const t = () => [...e.host.querySelectorAll(ct)], s = (n) => {
1443
+ const r = n;
1444
+ if (r.key !== "Tab") return;
1445
+ const o = t();
1446
+ if (o.length === 0) return;
1447
+ const a = o[0], h = o[o.length - 1], f = document.activeElement;
1448
+ r.shiftKey && f === a ? (r.preventDefault(), h.focus()) : !r.shiftKey && f === h && (r.preventDefault(), a.focus());
1449
+ };
1450
+ return e.host.addEventListener("keydown", s), queueMicrotask(() => {
1451
+ const n = t();
1452
+ n.length > 0 && n[0].focus();
1453
+ }), () => {
1454
+ e.host.removeEventListener("keydown", s);
1455
+ };
1456
+ }
1457
+ }, ge = "[tabindex], button, a, input, select, textarea, aui-button", ht = {
1458
+ name: "roving-focus",
1459
+ category: "focus",
1460
+ targets: "self",
1461
+ defaults: {
1462
+ orientation: "both",
1463
+ wrap: "true",
1464
+ selector: ge
1465
+ },
1466
+ attach(e) {
1467
+ const t = e.config("orientation") ?? "both", s = (e.config("wrap") ?? "true") === "true", n = e.config("selector") ?? ge, r = n.startsWith("> ") ? `:scope ${n}` : n, o = () => [...e.host.querySelectorAll(r)], a = (l, c) => {
1468
+ for (let d = 0; d < l.length; d++)
1469
+ l[d].setAttribute("tabindex", d === c ? "0" : "-1");
1470
+ l[c].focus(), e.expose("active", String(c));
1471
+ };
1472
+ queueMicrotask(() => {
1473
+ const l = o();
1474
+ for (let c = 0; c < l.length; c++)
1475
+ l[c].setAttribute("tabindex", c === 0 ? "0" : "-1");
1476
+ l.length > 0 && e.expose("active", "0");
1477
+ });
1478
+ const h = (l) => t === "horizontal" ? l === "ArrowRight" : t === "vertical" ? l === "ArrowDown" : l === "ArrowRight" || l === "ArrowDown", f = (l) => t === "horizontal" ? l === "ArrowLeft" : t === "vertical" ? l === "ArrowUp" : l === "ArrowLeft" || l === "ArrowUp", i = (l) => {
1479
+ const c = l, d = o();
1480
+ if (d.length === 0) return;
1481
+ const u = d.indexOf(document.activeElement);
1482
+ if (u === -1) return;
1483
+ let p;
1484
+ h(c.key) ? (p = u + 1, p >= d.length && (p = s ? 0 : u)) : f(c.key) ? (p = u - 1, p < 0 && (p = s ? d.length - 1 : u)) : c.key === "Home" ? p = 0 : c.key === "End" && (p = d.length - 1), p !== void 0 && (c.preventDefault(), a(d, p));
1485
+ };
1486
+ return e.host.addEventListener("keydown", i), () => {
1487
+ e.host.removeEventListener("keydown", i);
1488
+ };
1489
+ }
1490
+ }, ut = {
1491
+ name: "list-navigate",
1492
+ category: "focus",
1493
+ targets: "self",
1494
+ defaults: {
1495
+ selector: "> *",
1496
+ typeahead: "true",
1497
+ timeout: "500"
1498
+ },
1499
+ attach(e) {
1500
+ const t = e.config("selector") ?? "> *", s = (e.config("typeahead") ?? "true") === "true", n = Number(e.config("timeout") ?? "500");
1501
+ let r = -1, o = "", a;
1502
+ const h = () => {
1503
+ const l = t.startsWith("> ") ? `:scope ${t}` : t;
1504
+ return [...e.host.querySelectorAll(l)];
1505
+ }, f = (l, c) => {
1506
+ for (let d = 0; d < l.length; d++)
1507
+ d === c ? l[d].setAttribute("data-list-navigate-highlighted", "") : l[d].removeAttribute("data-list-navigate-highlighted");
1508
+ r = c, e.expose("index", String(c)), l[c]?.scrollIntoView({ block: "nearest" });
1509
+ }, i = (l) => {
1510
+ const c = l, d = h();
1511
+ if (d.length === 0) return;
1512
+ let u;
1513
+ switch (c.key) {
1514
+ case "ArrowDown":
1515
+ u = r < d.length - 1 ? r + 1 : 0;
1516
+ break;
1517
+ case "ArrowUp":
1518
+ u = r > 0 ? r - 1 : d.length - 1;
1519
+ break;
1520
+ case "Home":
1521
+ u = 0;
1522
+ break;
1523
+ case "End":
1524
+ u = d.length - 1;
1525
+ break;
1526
+ case "Enter":
1527
+ r >= 0 && r < d.length && e.emit("activate", { index: r }), c.preventDefault();
1528
+ return;
1529
+ default:
1530
+ if (s && c.key.length === 1 && !c.ctrlKey && !c.metaKey && !c.altKey) {
1531
+ o += c.key.toLowerCase(), clearTimeout(a), a = setTimeout(() => {
1532
+ o = "";
1533
+ }, n);
1534
+ const p = d.findIndex(
1535
+ (g) => (g.textContent ?? "").trim().toLowerCase().startsWith(o)
1536
+ );
1537
+ p !== -1 && (u = p);
1538
+ }
1539
+ break;
1540
+ }
1541
+ u !== void 0 && (c.preventDefault(), f(d, u));
1542
+ };
1543
+ return queueMicrotask(() => {
1544
+ const l = h();
1545
+ l.length > 0 && f(l, 0);
1546
+ }), e.host.addEventListener("keydown", i), () => {
1547
+ e.host.removeEventListener("keydown", i), clearTimeout(a);
1548
+ };
1549
+ }
1550
+ }, ft = CSS.supports?.("position-anchor: --x") ?? !1, pt = {
1551
+ name: "tooltip",
1552
+ category: "present",
1553
+ targets: "self",
1554
+ defaults: {
1555
+ delay: "500",
1556
+ position: "top"
1557
+ },
1558
+ attach(e) {
1559
+ const t = e.config("text") ?? "", s = parseInt(e.config("delay") ?? "500", 10), n = e.config("position") ?? "top";
1560
+ let r, o;
1561
+ const a = 6, h = (l) => {
1562
+ const c = e.host.getBoundingClientRect(), d = l.getBoundingClientRect();
1563
+ let u = 0, p = 0;
1564
+ switch (n) {
1565
+ case "top":
1566
+ u = c.top - d.height - a, p = c.left + (c.width - d.width) / 2;
1567
+ break;
1568
+ case "bottom":
1569
+ u = c.bottom + a, p = c.left + (c.width - d.width) / 2;
1570
+ break;
1571
+ case "left":
1572
+ u = c.top + (c.height - d.height) / 2, p = c.left - d.width - a;
1573
+ break;
1574
+ case "right":
1575
+ u = c.top + (c.height - d.height) / 2, p = c.right + a;
1576
+ break;
1577
+ }
1578
+ u = Math.max(4, Math.min(u, window.innerHeight - d.height - 4)), p = Math.max(4, Math.min(p, window.innerWidth - d.width - 4)), l.style.top = `${u}px`, l.style.left = `${p}px`;
1579
+ }, f = () => {
1580
+ r = setTimeout(() => {
1581
+ if (o = document.createElement("div"), o.setAttribute("data-aui-tooltip", ""), o.setAttribute("popover", "manual"), o.setAttribute("role", "tooltip"), o.setAttribute("data-tooltip-position", n), o.textContent = t, document.body.appendChild(o), o.showPopover(), !ft)
1582
+ h(o);
1583
+ else {
1584
+ const l = `--aui-tt-${Date.now()}`;
1585
+ e.host.style.setProperty("anchor-name", l), o.style.setProperty("position-anchor", l);
1586
+ }
1587
+ e.expose("open", !0);
1588
+ }, s);
1589
+ }, i = () => {
1590
+ if (r !== void 0 && (clearTimeout(r), r = void 0), o) {
1591
+ try {
1592
+ o.hidePopover();
1593
+ } catch {
1594
+ }
1595
+ o.remove(), o = void 0;
1596
+ }
1597
+ e.host.style.removeProperty("anchor-name"), e.expose("open", !1);
1598
+ };
1599
+ return e.host.addEventListener("mouseenter", f), e.host.addEventListener("focusin", f), e.host.addEventListener("mouseleave", i), e.host.addEventListener("focusout", i), () => {
1600
+ i(), e.host.removeEventListener("mouseenter", f), e.host.removeEventListener("focusin", f), e.host.removeEventListener("mouseleave", i), e.host.removeEventListener("focusout", i);
1601
+ };
1602
+ }
1603
+ }, mt = {
1604
+ name: "collapsible",
1605
+ category: "present",
1606
+ targets: "self",
1607
+ defaults: {
1608
+ collapsed: "false",
1609
+ duration: "200"
1610
+ },
1611
+ actions: ["press"],
1612
+ attach(e) {
1613
+ const t = parseInt(e.config("duration") ?? "200", 10);
1614
+ let s = (e.config("collapsed") ?? "false") === "true";
1615
+ const n = () => {
1616
+ e.expose("collapsed", s), s ? (e.host.style.overflow = "hidden", e.host.style.maxHeight = "0px") : (e.host.style.overflow = "", e.host.style.maxHeight = "");
1617
+ };
1618
+ e.host.style.transition = `max-height ${t}ms ease`, n();
1619
+ const r = () => {
1620
+ if (s) {
1621
+ s = !1, e.expose("collapsed", !1), e.host.style.maxHeight = `${e.host.scrollHeight}px`, e.host.style.overflow = "hidden";
1622
+ const a = () => {
1623
+ e.host.removeEventListener("transitionend", a), s || (e.host.style.maxHeight = "", e.host.style.overflow = "");
1624
+ };
1625
+ e.host.addEventListener("transitionend", a);
1626
+ } else
1627
+ e.host.style.maxHeight = `${e.host.scrollHeight}px`, e.host.style.overflow = "hidden", e.host.offsetHeight, s = !0, e.expose("collapsed", !0), e.host.style.maxHeight = "0px";
1628
+ }, o = () => r();
1629
+ return e.host.addEventListener("press", o), () => {
1630
+ e.host.removeEventListener("press", o), e.host.style.transition = "", e.host.style.maxHeight = "", e.host.style.overflow = "";
1631
+ };
1632
+ }
1633
+ };
1634
+ let vt = 0;
1635
+ const Le = (e, t) => ({
1636
+ name: e,
1637
+ category: "present",
1638
+ targets: "self",
1639
+ defaults: {
1640
+ closable: "true",
1641
+ anchor: "",
1642
+ placement: "block-end center",
1643
+ type: t ? "manual" : "auto",
1644
+ matchWidth: "false",
1645
+ animation: "scale"
1646
+ },
1647
+ actions: ["open", "close", "dismiss"],
1648
+ attach(s) {
1649
+ const n = (s.config("closable") ?? "true") === "true", r = s.config("anchor") ?? "", o = s.config("placement") ?? "block-end span-inline-end", a = s.config("type") ?? (t ? "manual" : "auto"), h = (s.config("matchWidth") ?? "false") === "true", f = s.config("animation") ?? "scale";
1650
+ let i = !1, l = null;
1651
+ const c = [];
1652
+ s.host.setAttribute("popover", a), s.expose("open", !1), f !== "none" && (s.host.setAttribute("data-overlay-animation", f), r && s.host.setAttribute("data-overlay-direction", o.split(" ")[0] ?? "block-end"), requestAnimationFrame(() => {
1653
+ s.host.setAttribute("data-overlay-ready", "");
1654
+ }));
1655
+ let d = "", u = null;
1656
+ r && (s.host.setAttribute("data-overlay-anchored", ""), d = `--aui-overlay-${++vt}`, s.host.style.setProperty("position-anchor", d), s.host.style.setProperty("position-area", o), h && s.host.setAttribute("data-overlay-match-width", ""), u = document.querySelector(r), u && u.style.setProperty("anchor-name", d));
1657
+ const p = () => {
1658
+ if (!r) return;
1659
+ const H = document.querySelector(r);
1660
+ H && H.style.removeProperty("anchor-name");
1661
+ }, g = () => {
1662
+ if (!t) return;
1663
+ l = document.activeElement;
1664
+ const H = s.host.parentElement;
1665
+ if (H)
1666
+ for (const L of Array.from(H.children))
1667
+ L !== s.host && (c.push({
1668
+ el: L,
1669
+ prev: L.inert ?? !1
1670
+ }), L.inert = !0);
1671
+ }, v = () => {
1672
+ for (const { el: H, prev: L } of c)
1673
+ H.inert = L;
1674
+ c.length = 0;
1675
+ }, P = () => {
1676
+ t && (l?.focus && l.focus(), l = null);
1677
+ }, M = (H) => {
1678
+ u && (H ? u.setAttribute("data-overlay-anchor-open", "") : requestAnimationFrame(() => u?.removeAttribute("data-overlay-anchor-open")));
1679
+ }, k = () => {
1680
+ i || (i = !0, s.host.showPopover(), s.expose("open", !0), M(!0), g(), s.emit("overlay-open"));
1681
+ }, b = () => {
1682
+ if (i) {
1683
+ i = !1;
1684
+ try {
1685
+ s.host.hidePopover();
1686
+ } catch {
1687
+ }
1688
+ s.expose("open", !1), M(!1), v(), P(), s.emit("overlay-close");
1689
+ }
1690
+ }, O = () => k(), E = () => b(), _ = () => b(), U = (H) => {
1691
+ const L = H;
1692
+ L.key === "Escape" && i && n && (L.preventDefault(), b());
1693
+ }, j = (H) => {
1694
+ const L = H;
1695
+ L.newState === "open" && !i ? (i = !0, s.expose("open", !0), M(!0), g(), s.emit("overlay-open")) : L.newState === "closed" && i && (i = !1, s.expose("open", !1), M(!1), v(), P(), s.emit("overlay-close"));
1696
+ }, Q = (H) => {
1697
+ if (!i || !n || a === "auto") return;
1698
+ const L = s.host.getBoundingClientRect();
1699
+ H.clientX >= L.left && H.clientX <= L.right && H.clientY >= L.top && H.clientY <= L.bottom || b();
1700
+ };
1701
+ return s.host.addEventListener("open", O), s.host.addEventListener("close", E), s.host.addEventListener("dismiss", _), s.host.addEventListener("toggle", j), document.addEventListener("keydown", U), a === "manual" && document.addEventListener("click", Q), () => {
1702
+ if (s.host.removeEventListener("open", O), s.host.removeEventListener("close", E), s.host.removeEventListener("dismiss", _), s.host.removeEventListener("toggle", j), document.removeEventListener("keydown", U), document.removeEventListener("click", Q), v(), P(), M(!1), p(), i)
1703
+ try {
1704
+ s.host.hidePopover();
1705
+ } catch {
1706
+ }
1707
+ s.host.removeAttribute("popover"), s.host.removeAttribute("data-overlay-anchored"), s.host.removeAttribute("data-overlay-match-width"), s.host.removeAttribute("data-overlay-animation"), s.host.removeAttribute("data-overlay-ready"), s.host.removeAttribute("data-overlay-direction"), s.host.style.removeProperty("position-anchor"), s.host.style.removeProperty("position-area");
1708
+ };
1709
+ }
1710
+ }), gt = Le("popover", !1), yt = Le("modal", !0), bt = {
1711
+ name: "dismiss",
1712
+ category: "present",
1713
+ targets: "self",
1714
+ defaults: {
1715
+ escape: "true",
1716
+ outside: "true",
1717
+ event: "dismiss"
1718
+ },
1719
+ attach(e) {
1720
+ const t = (e.config("escape") ?? "true") === "true", s = (e.config("outside") ?? "true") === "true", n = e.config("event") ?? "dismiss", r = (a) => {
1721
+ const h = a;
1722
+ h.key === "Escape" && (h.preventDefault(), e.emit(n));
1723
+ }, o = (a) => {
1724
+ const h = a;
1725
+ e.host.contains(h.target) || e.emit(n);
1726
+ };
1727
+ return t && document.addEventListener("keydown", r), s && document.addEventListener("pointerdown", o), () => {
1728
+ t && document.removeEventListener("keydown", r), s && document.removeEventListener("pointerdown", o);
1729
+ };
1730
+ }
1731
+ }, Et = {
1732
+ name: "auto-dismiss",
1733
+ category: "present",
1734
+ targets: "self",
1735
+ defaults: {
1736
+ delay: "3000"
1737
+ },
1738
+ attach(e) {
1739
+ const t = parseInt(e.config("delay") ?? "3000", 10);
1740
+ let s = t;
1741
+ e.expose("remaining", String(s));
1742
+ const n = setInterval(() => {
1743
+ s = Math.max(0, s - 1e3), e.expose("remaining", String(s));
1744
+ }, 1e3), r = setTimeout(() => {
1745
+ clearInterval(n), e.host.setAttribute("hidden", ""), e.expose("dismissed", !0), e.emit("dismiss");
1746
+ }, t), o = () => clearTimeout(r), a = () => {
1747
+ };
1748
+ return e.host.addEventListener("pointerenter", o), e.host.addEventListener("pointerleave", a), () => {
1749
+ clearTimeout(r), clearInterval(n), e.host.removeEventListener("pointerenter", o), e.host.removeEventListener("pointerleave", a);
1750
+ };
1751
+ }
1752
+ }, wt = {
1753
+ name: "gateway",
1754
+ category: "present",
1755
+ targets: "external",
1756
+ defaults: {
1757
+ target: "body"
1758
+ },
1759
+ attach(e) {
1760
+ const t = e.config("target") ?? "body", s = document.querySelector(t);
1761
+ if (!s) {
1762
+ console.warn(`[gateway] target "${t}" not found`);
1763
+ return;
1764
+ }
1765
+ const n = document.createComment("aui-gateway");
1766
+ e.host.parentNode?.insertBefore(n, e.host.nextSibling);
1767
+ const r = document.createElement("div");
1768
+ for (r.setAttribute("data-gateway-wrapper", ""); e.host.firstChild; )
1769
+ r.appendChild(e.host.firstChild);
1770
+ return s.appendChild(r), e.expose("active", !0), () => {
1771
+ for (; r.firstChild; )
1772
+ e.host.appendChild(r.firstChild);
1773
+ r.remove(), n.remove();
1774
+ };
1775
+ }
1776
+ }, Lt = {
1777
+ name: "present",
1778
+ category: "present",
1779
+ targets: "self",
1780
+ defaults: {
1781
+ visible: "true",
1782
+ transition: "200"
1783
+ },
1784
+ actions: ["toggle", "show", "hide"],
1785
+ attach(e) {
1786
+ const t = parseInt(e.config("transition") ?? "200", 10);
1787
+ let s = (e.config("visible") ?? "true") === "true", n = null;
1788
+ const r = () => {
1789
+ n !== null && (clearTimeout(n), n = null);
1790
+ };
1791
+ s || e.host.setAttribute("data-present-hidden", ""), e.expose("visible", s);
1792
+ const o = () => {
1793
+ s || (r(), s = !0, e.expose("visible", !0), e.host.removeAttribute("data-present-hidden"), e.host.setAttribute("data-present-entering", ""), e.host.offsetHeight, n = setTimeout(() => {
1794
+ e.host.removeAttribute("data-present-entering"), n = null;
1795
+ }, t));
1796
+ }, a = () => {
1797
+ s && (r(), s = !1, e.expose("visible", !1), e.host.setAttribute("data-present-leaving", ""), n = setTimeout(() => {
1798
+ e.host.removeAttribute("data-present-leaving"), e.host.setAttribute("data-present-hidden", ""), n = null;
1799
+ }, t));
1800
+ }, h = () => {
1801
+ s ? a() : o();
1802
+ }, f = () => h(), i = () => o(), l = () => a();
1803
+ return e.host.addEventListener("toggle", f), e.host.addEventListener("show", i), e.host.addEventListener("hide", l), () => {
1804
+ r(), e.host.removeEventListener("toggle", f), e.host.removeEventListener("show", i), e.host.removeEventListener("hide", l), e.host.removeAttribute("data-present-entering"), e.host.removeAttribute("data-present-leaving"), e.host.removeAttribute("data-present-hidden");
1805
+ };
1806
+ }
1807
+ }, ye = {
1808
+ "top-right": { top: "1rem", right: "1rem", left: "", bottom: "" },
1809
+ "top-left": { top: "1rem", left: "1rem", right: "", bottom: "" },
1810
+ "bottom-right": { bottom: "1rem", right: "1rem", top: "", left: "" },
1811
+ "bottom-left": { bottom: "1rem", left: "1rem", top: "", right: "" },
1812
+ "top-center": { top: "1rem", left: "50%", right: "", bottom: "", translate: "-50% 0" },
1813
+ "bottom-center": { bottom: "1rem", left: "50%", right: "", top: "", translate: "-50% 0" }
1814
+ }, At = (e, t) => {
1815
+ const s = document.querySelectorAll("[data-toast-visible]");
1816
+ let n = 0;
1817
+ for (const r of s) {
1818
+ if (r === t) break;
1819
+ const o = r.getBoundingClientRect();
1820
+ n += o.height + 8;
1821
+ }
1822
+ return n;
1823
+ }, Tt = {
1824
+ name: "toast",
1825
+ category: "present",
1826
+ targets: "self",
1827
+ defaults: {
1828
+ duration: "3000",
1829
+ position: "bottom-right",
1830
+ stack: "true"
1831
+ },
1832
+ attach(e) {
1833
+ const t = parseInt(e.config("duration") ?? "3000", 10), s = e.config("position") ?? "bottom-right", n = e.config("stack") !== "false", r = ye[s] ?? ye["bottom-right"];
1834
+ for (const [h, f] of Object.entries(r))
1835
+ e.host.style.setProperty(h, f);
1836
+ if (n) {
1837
+ const h = At(s, e.host);
1838
+ if (s.startsWith("top")) {
1839
+ const i = parseFloat(r.top ?? "16");
1840
+ e.host.style.top = `calc(${i}rem + ${h}px)`;
1841
+ } else {
1842
+ const i = parseFloat(r.bottom ?? "16");
1843
+ e.host.style.bottom = `calc(${i}rem + ${h}px)`;
1844
+ }
1845
+ }
1846
+ e.expose("visible", !0);
1847
+ let o;
1848
+ const a = () => {
1849
+ e.host.setAttribute("data-toast-dismissing", "");
1850
+ const h = () => {
1851
+ e.host.removeEventListener("transitionend", h), e.expose("visible", !1), e.host.removeAttribute("data-toast-dismissing"), e.host.setAttribute("data-toast-hidden", ""), e.emit("toast-dismiss");
1852
+ };
1853
+ e.host.addEventListener("transitionend", h);
1854
+ };
1855
+ return t > 0 && (o = setTimeout(a, t)), () => {
1856
+ o !== void 0 && clearTimeout(o), e.host.removeAttribute("data-toast-dismissing"), e.host.removeAttribute("data-toast-hidden"), e.host.style.top = "", e.host.style.right = "", e.host.style.bottom = "", e.host.style.left = "", e.host.style.translate = "", e.unexpose("visible");
1857
+ };
1858
+ }
1859
+ }, kt = {
1860
+ name: "virtual-scroll",
1861
+ category: "present",
1862
+ targets: "self",
1863
+ defaults: {
1864
+ "item-height": "40",
1865
+ overscan: "3",
1866
+ total: "0"
1867
+ },
1868
+ attach(e) {
1869
+ const t = Number(e.config("item-height") ?? "40"), s = Number(e.config("overscan") ?? "3"), n = Number(e.config("total") ?? "0");
1870
+ if (t <= 0 || n <= 0) return;
1871
+ const r = document.createElement("div");
1872
+ r.style.height = `${n * t}px`, r.setAttribute("aria-hidden", "true"), r.setAttribute("data-virtual-spacer", ""), e.host.prepend(r);
1873
+ const o = () => {
1874
+ const a = e.host.scrollTop, h = e.host.clientHeight, f = Math.floor(a / t), i = Math.ceil((a + h) / t), l = Math.max(0, f - s), c = Math.min(n - 1, i + s);
1875
+ e.expose("start", String(l)), e.expose("end", String(c)), e.emit("virtual-range", { start: l, end: c });
1876
+ const d = [...e.host.children].filter(
1877
+ (u) => !u.hasAttribute("data-virtual-spacer")
1878
+ );
1879
+ for (let u = 0; u < d.length; u++) {
1880
+ const p = l + u;
1881
+ p <= c && (d[u].style.height = `${t}px`, d[u].style.transform = `translateY(${p * t}px)`);
1882
+ }
1883
+ };
1884
+ return queueMicrotask(o), e.host.addEventListener("scroll", o, { passive: !0 }), () => {
1885
+ e.host.removeEventListener("scroll", o), r.remove();
1886
+ };
1887
+ }
1888
+ }, Ct = {
1889
+ name: "ripple",
1890
+ category: "effect",
1891
+ targets: "self",
1892
+ attach(e) {
1893
+ const t = (n) => {
1894
+ const r = n, o = e.host, a = o.getBoundingClientRect(), h = Math.max(a.width, a.height) * 2;
1895
+ o.style.setProperty("--ripple-x", `${r.clientX - a.left}px`), o.style.setProperty("--ripple-y", `${r.clientY - a.top}px`), o.style.setProperty("--ripple-size", `${h}px`), o.removeAttribute("data-ripple-active"), o.offsetWidth, o.setAttribute("data-ripple-active", "");
1896
+ }, s = (n) => {
1897
+ n.animationName === "aui-ripple" && e.host.removeAttribute("data-ripple-active");
1898
+ };
1899
+ return e.host.addEventListener("pointerdown", t), e.host.addEventListener("animationend", s), () => {
1900
+ e.host.removeEventListener("pointerdown", t), e.host.removeEventListener("animationend", s), e.host.removeAttribute("data-ripple-active"), e.host.style.removeProperty("--ripple-x"), e.host.style.removeProperty("--ripple-y"), e.host.style.removeProperty("--ripple-size");
1901
+ };
1902
+ }
1903
+ }, be = ["#ff577f", "#ff884b", "#ffd384", "#fff9b0", "#3ec1d3", "#7c5cbf", "#ff6b6b", "#48dbfb"], Pt = {
1904
+ name: "confetti",
1905
+ category: "effect",
1906
+ targets: "self",
1907
+ defaults: {
1908
+ count: "30",
1909
+ spread: "90",
1910
+ velocity: "12",
1911
+ gravity: "0.5",
1912
+ duration: "2000"
1913
+ },
1914
+ actions: ["press"],
1915
+ attach(e) {
1916
+ const t = parseInt(e.config("count") ?? "30", 10), s = parseInt(e.config("spread") ?? "90", 10), n = parseFloat(e.config("velocity") ?? "12"), r = parseFloat(e.config("gravity") ?? "0.5"), o = parseInt(e.config("duration") ?? "2000", 10), a = /* @__PURE__ */ new Set(), h = () => {
1917
+ const f = e.host.getBoundingClientRect(), i = f.left + f.width / 2, l = f.top + f.height / 2, c = document.createElement("div");
1918
+ c.style.cssText = "position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:9999;", document.body.appendChild(c), a.add(c);
1919
+ const d = [], u = s / 2 * (Math.PI / 180), p = -Math.PI / 2;
1920
+ for (let M = 0; M < t; M++) {
1921
+ const k = document.createElement("div"), b = 6 + Math.random() * 5, O = be[M % be.length], E = Math.random() > 0.5;
1922
+ k.style.cssText = `position:absolute;width:${b}px;height:${b}px;background:${O};border-radius:${E ? "50%" : "2px"};left:${i}px;top:${l}px;pointer-events:none;`, c.appendChild(k);
1923
+ const _ = p + (Math.random() * 2 - 1) * u, U = n * (0.7 + Math.random() * 0.6);
1924
+ d.push({
1925
+ el: k,
1926
+ x: 0,
1927
+ y: 0,
1928
+ vx: Math.cos(_) * U,
1929
+ vy: Math.sin(_) * U,
1930
+ rotation: Math.random() * 360,
1931
+ rotationSpeed: (Math.random() - 0.5) * 20,
1932
+ opacity: 1
1933
+ });
1934
+ }
1935
+ e.host.setAttribute("data-confetti-active", "");
1936
+ const g = performance.now(), v = o * 0.7, P = (M) => {
1937
+ const k = M - g;
1938
+ if (k >= o) {
1939
+ c.remove(), a.delete(c), a.size === 0 && e.host.removeAttribute("data-confetti-active");
1940
+ return;
1941
+ }
1942
+ for (const b of d)
1943
+ b.vy += r, b.vx *= 0.98, b.vy *= 0.98, b.x += b.vx, b.y += b.vy, b.rotation += b.rotationSpeed, k > v && (b.opacity = 1 - (k - v) / (o - v)), b.el.style.transform = `translate(${b.x}px, ${b.y}px) rotate(${b.rotation}deg)`, b.el.style.opacity = String(b.opacity);
1944
+ requestAnimationFrame(P);
1945
+ };
1946
+ requestAnimationFrame(P);
1947
+ };
1948
+ return e.host.addEventListener("press", h), () => {
1949
+ e.host.removeEventListener("press", h);
1950
+ for (const f of a) f.remove();
1951
+ a.clear();
1952
+ };
1953
+ }
1954
+ }, St = {
1955
+ name: "flip",
1956
+ category: "effect",
1957
+ targets: "self",
1958
+ defaults: {
1959
+ duration: "600",
1960
+ direction: "horizontal"
1961
+ },
1962
+ actions: ["press"],
1963
+ attach(e) {
1964
+ const t = e.config("duration") ?? "600", s = e.config("direction") ?? "horizontal";
1965
+ let n = !1;
1966
+ s === "vertical" && e.host.setAttribute("data-flip-direction", "vertical"), t !== "600" && e.host.style.setProperty("--aui-flip-duration", `${t}ms`);
1967
+ const r = () => {
1968
+ n = !n, e.expose("flipped", n);
1969
+ };
1970
+ return e.expose("flipped", !1), e.host.addEventListener("press", r), () => {
1971
+ e.host.removeEventListener("press", r), e.host.removeAttribute("data-flip-direction"), e.host.style.removeProperty("--aui-flip-duration"), e.unexpose("flipped");
1972
+ };
1973
+ }
1974
+ }, Mt = {
1975
+ name: "parallax",
1976
+ category: "effect",
1977
+ targets: "self",
1978
+ defaults: {
1979
+ speed: "0.5",
1980
+ direction: "vertical"
1981
+ },
1982
+ attach(e) {
1983
+ const t = parseFloat(e.config("speed") ?? "0.5"), n = (e.config("direction") ?? "vertical") === "vertical", r = "--_parallax-offset";
1984
+ e.host.style.transform = n ? `translateY(var(${r}, 0px))` : `translateX(var(${r}, 0px))`, e.host.style.willChange = "transform";
1985
+ let o = 0, a = !1;
1986
+ const h = () => {
1987
+ const i = e.host.getBoundingClientRect(), l = n ? window.innerHeight : window.innerWidth, d = ((n ? i.top + i.height / 2 : i.left + i.width / 2) - l / 2) * t;
1988
+ e.host.style.setProperty(r, `${d}px`), a = !1;
1989
+ }, f = () => {
1990
+ a || (o = requestAnimationFrame(h), a = !0);
1991
+ };
1992
+ return h(), window.addEventListener("scroll", f, { passive: !0 }), window.addEventListener("resize", f, { passive: !0 }), () => {
1993
+ cancelAnimationFrame(o), window.removeEventListener("scroll", f), window.removeEventListener("resize", f), e.host.style.transform = "", e.host.style.willChange = "", e.host.style.removeProperty(r);
1994
+ };
1995
+ }
1996
+ }, It = {
1997
+ name: "toss",
1998
+ category: "effect",
1999
+ targets: "self",
2000
+ defaults: {
2001
+ friction: "0.92",
2002
+ bounce: "0.15",
2003
+ max: "200"
2004
+ },
2005
+ attach(e) {
2006
+ const t = parseFloat(e.config("friction") ?? "0.92"), s = parseFloat(e.config("bounce") ?? "0.15"), n = parseFloat(e.config("max") ?? "200");
2007
+ e.host.style.setProperty("--_toss-x", "0px"), e.host.style.setProperty("--_toss-y", "0px"), e.host.style.transform = "translate(var(--_toss-x), var(--_toss-y))";
2008
+ let r = [], o = null;
2009
+ const a = (f) => {
2010
+ const i = f, l = performance.now();
2011
+ r.push({ x: i.clientX, y: i.clientY, t: l }), r.length > 4 && (r = r.slice(-4));
2012
+ }, h = () => {
2013
+ if (r.length < 2) {
2014
+ r = [];
2015
+ return;
2016
+ }
2017
+ const f = r[0], i = r[r.length - 1], l = i.t - f.t || 1;
2018
+ let c = (i.x - f.x) / l * 16, d = (i.y - f.y) / l * 16;
2019
+ r = [];
2020
+ let u = 0, p = 0;
2021
+ o !== null && cancelAnimationFrame(o), e.expose("active", !0);
2022
+ const g = () => {
2023
+ u += c, p += d;
2024
+ const v = Math.sqrt(u * u + p * p);
2025
+ if (v > n) {
2026
+ const k = n / v;
2027
+ u *= k, p *= k, c *= 0.5, d *= 0.5;
2028
+ }
2029
+ c *= t, d *= t, u -= u * s, p -= p * s, e.host.style.setProperty("--_toss-x", `${u}px`), e.host.style.setProperty("--_toss-y", `${p}px`);
2030
+ const P = Math.abs(c) + Math.abs(d), M = Math.abs(u) + Math.abs(p);
2031
+ if (P < 0.1 && M < 0.5) {
2032
+ e.host.style.setProperty("--_toss-x", "0px"), e.host.style.setProperty("--_toss-y", "0px"), e.unexpose("active"), o = null;
2033
+ return;
2034
+ }
2035
+ o = requestAnimationFrame(g);
2036
+ };
2037
+ o = requestAnimationFrame(g);
2038
+ };
2039
+ return e.host.addEventListener("pointermove", a), e.host.addEventListener("pointerup", h), () => {
2040
+ e.host.removeEventListener("pointermove", a), e.host.removeEventListener("pointerup", h), o !== null && (cancelAnimationFrame(o), o = null), e.host.style.removeProperty("--_toss-x"), e.host.style.removeProperty("--_toss-y");
2041
+ };
2042
+ }
2043
+ }, $t = {
2044
+ name: "magnet",
2045
+ category: "effect",
2046
+ targets: "self",
2047
+ defaults: {
2048
+ strength: "10",
2049
+ tilt: "5"
2050
+ },
2051
+ attach(e) {
2052
+ const t = parseFloat(e.config("strength") ?? "10"), s = parseFloat(e.config("tilt") ?? "5");
2053
+ e.host.style.setProperty("--_magnet-x", "0px"), e.host.style.setProperty("--_magnet-y", "0px"), e.host.style.setProperty("--_magnet-rx", "0deg"), e.host.style.setProperty("--_magnet-ry", "0deg"), e.host.style.transform = "perspective(800px) translate(var(--_magnet-x), var(--_magnet-y)) rotateX(var(--_magnet-rx)) rotateY(var(--_magnet-ry))", e.host.style.willChange = "transform";
2054
+ const n = (a) => {
2055
+ const h = a, f = e.host.getBoundingClientRect(), i = f.left + f.width / 2, l = f.top + f.height / 2, c = (h.clientX - i) / (f.width / 2), d = (h.clientY - l) / (f.height / 2);
2056
+ e.host.style.setProperty("--_magnet-x", `${c * t}px`), e.host.style.setProperty("--_magnet-y", `${d * t}px`), e.host.style.setProperty("--_magnet-rx", `${-d * s}deg`), e.host.style.setProperty("--_magnet-ry", `${c * s}deg`);
2057
+ }, r = () => {
2058
+ e.host.style.transition = "none";
2059
+ }, o = () => {
2060
+ e.host.style.transition = "transform 0.3s ease-out", e.host.style.setProperty("--_magnet-x", "0px"), e.host.style.setProperty("--_magnet-y", "0px"), e.host.style.setProperty("--_magnet-rx", "0deg"), e.host.style.setProperty("--_magnet-ry", "0deg");
2061
+ };
2062
+ return e.host.addEventListener("mousemove", n), e.host.addEventListener("mouseenter", r), e.host.addEventListener("mouseleave", o), () => {
2063
+ e.host.removeEventListener("mousemove", n), e.host.removeEventListener("mouseenter", r), e.host.removeEventListener("mouseleave", o), e.host.style.willChange = "", e.host.style.transition = "", e.host.style.transform = "", e.host.style.removeProperty("--_magnet-x"), e.host.style.removeProperty("--_magnet-y"), e.host.style.removeProperty("--_magnet-rx"), e.host.style.removeProperty("--_magnet-ry");
2064
+ };
2065
+ }
2066
+ }, Ee = "http://www.w3.org/2000/svg", zt = {
2067
+ name: "noodle",
2068
+ category: "effect",
2069
+ targets: "external",
2070
+ defaults: {
2071
+ target: "",
2072
+ color: "currentColor",
2073
+ width: "2",
2074
+ curvature: "0.5"
2075
+ },
2076
+ attach(e) {
2077
+ const t = e.config("target") ?? "", s = e.config("color") ?? "currentColor", n = parseFloat(e.config("width") ?? "2"), r = parseFloat(e.config("curvature") ?? "0.5");
2078
+ if (!t) return;
2079
+ const o = document.createElementNS(Ee, "svg");
2080
+ o.setAttribute("data-noodle-svg", ""), o.setAttribute("aria-hidden", "true");
2081
+ const a = document.createElementNS(Ee, "path");
2082
+ a.setAttribute("fill", "none"), a.setAttribute("stroke", s), a.setAttribute("stroke-width", String(n)), a.setAttribute("stroke-linecap", "round"), o.appendChild(a), document.body.appendChild(o);
2083
+ let h = 0, f = !1;
2084
+ const i = () => {
2085
+ const u = document.querySelector(t);
2086
+ if (!u) {
2087
+ e.expose("connected", !1), a.setAttribute("d", ""), f = !1;
2088
+ return;
2089
+ }
2090
+ e.expose("connected", !0);
2091
+ const p = e.host.getBoundingClientRect(), g = u.getBoundingClientRect(), v = p.left + p.width / 2, P = p.top + p.height / 2, M = g.left + g.width / 2, k = g.top + g.height / 2, b = Math.abs(M - v) * r, O = v + b, E = P, _ = M - b, U = k;
2092
+ a.setAttribute("d", `M ${v} ${P} C ${O} ${E}, ${_} ${U}, ${M} ${k}`), f = !1;
2093
+ }, l = () => {
2094
+ f || (h = requestAnimationFrame(i), f = !0);
2095
+ };
2096
+ i();
2097
+ const c = new ResizeObserver(l);
2098
+ c.observe(e.host);
2099
+ const d = document.querySelector(t);
2100
+ return d && c.observe(d), window.addEventListener("scroll", l, { passive: !0, capture: !0 }), window.addEventListener("resize", l, { passive: !0 }), () => {
2101
+ cancelAnimationFrame(h), c.disconnect(), window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l), o.remove(), e.unexpose("connected");
2102
+ };
2103
+ }
2104
+ };
2105
+ class Rt {
2106
+ host;
2107
+ depth;
2108
+ scale;
2109
+ maxTilt;
2110
+ tiltRadius;
2111
+ perspective;
2112
+ labels;
2113
+ recursive;
2114
+ pick;
2115
+ alwaysReady;
2116
+ dismissOnClickOutside;
2117
+ tiltElement;
2118
+ disabled;
2119
+ #p = !1;
2120
+ #e = !1;
2121
+ #i = !1;
2122
+ #w = !1;
2123
+ #c = !1;
2124
+ #s = null;
2125
+ #m = null;
2126
+ #v = [];
2127
+ #L = 0;
2128
+ #r = 1;
2129
+ #a = 0;
2130
+ #t = null;
2131
+ #n = null;
2132
+ #A = null;
2133
+ #l = null;
2134
+ #d = null;
2135
+ #h = null;
2136
+ constructor(t, s = {}) {
2137
+ this.host = t, this.depth = s.depth ?? 16, this.scale = s.scale ?? 0.85, this.maxTilt = s.maxTilt ?? 60, this.tiltRadius = s.tiltRadius ?? 384, this.perspective = s.perspective ?? 1200, this.labels = s.labels ?? !0, this.recursive = s.recursive ?? !0, this.pick = s.pick ?? !1, this.alwaysReady = s.alwaysReady ?? !1, this.dismissOnClickOutside = s.dismissOnClickOutside ?? !0, this.tiltElement = s.tiltElement ?? null, this.disabled = s.disabled ?? !1, this.attach();
2138
+ }
2139
+ get active() {
2140
+ return this.#e;
2141
+ }
2142
+ get inspectRoot() {
2143
+ return this.#t ?? this.host;
2144
+ }
2145
+ attach() {
2146
+ this.#p || (this.#p = !0, this.host.addEventListener("pointerenter", this.#C), this.host.addEventListener("pointerleave", this.#P), this.host.addEventListener("pointermove", this.#g), this.host.addEventListener("pointerdown", this.#$), this.host.addEventListener("click", this.#y), document.addEventListener("keydown", this.#S), document.addEventListener("keyup", this.#M));
2147
+ }
2148
+ detach() {
2149
+ this.#p && (this.#p = !1, this.host.removeEventListener("pointerenter", this.#C), this.host.removeEventListener("pointerleave", this.#P), this.host.removeEventListener("pointermove", this.#g), this.host.removeEventListener("pointerdown", this.#$), this.host.removeEventListener("click", this.#y), document.removeEventListener("keydown", this.#S), document.removeEventListener("keyup", this.#M), this.#e && this.#E(), this.#o(), this.#T());
2150
+ }
2151
+ destroy() {
2152
+ this.detach();
2153
+ }
2154
+ inspect(t) {
2155
+ if (this.#e) return;
2156
+ const s = t ?? this.host, n = s.getBoundingClientRect();
2157
+ this.#f(s, n.left + n.width / 2, n.top + n.height / 2);
2158
+ }
2159
+ dismiss() {
2160
+ this.#e && this.#E();
2161
+ }
2162
+ // ── Handlers ──
2163
+ #C = () => {
2164
+ this.#w = !0, !(this.disabled || this.#e) && (this.#i || this.alwaysReady) && this.#u(!0);
2165
+ };
2166
+ #P = () => {
2167
+ this.#w = !1, this.#u(!1), this.#e || (this.#o(), this.#T());
2168
+ };
2169
+ #S = (t) => {
2170
+ t.key !== "Alt" || this.#i || (this.#i = !0, !(this.disabled || this.#e) && this.#w && this.#u(!0));
2171
+ };
2172
+ #M = (t) => {
2173
+ t.key === "Alt" && (this.#i = !1, !(this.#e || this.alwaysReady) && (this.#u(!1), this.#o(), this.#T()));
2174
+ };
2175
+ #I = (t) => {
2176
+ const s = this.#t;
2177
+ if (!s) return;
2178
+ const n = (this.#n ?? s).getBoundingClientRect(), r = t.clientX - (n.left + n.width / 2), o = t.clientY - (n.top + n.height / 2), a = Math.max(-1, Math.min(1, r / this.tiltRadius)), f = Math.max(-1, Math.min(1, o / this.tiltRadius)) * this.maxTilt, i = a * -this.maxTilt, l = this.#a * this.#r;
2179
+ s.style.transform = `translateZ(${l}px) perspective(${this.perspective}px) scale(${this.scale}) rotateX(${f}deg) rotateY(${i}deg)`, s.style.setProperty("--inspect-tilt-x", `${f}deg`), s.style.setProperty("--inspect-tilt-y", `${i}deg`);
2180
+ };
2181
+ #$ = (t) => {
2182
+ if (!(this.disabled || this.#e) && t.button === 0 && !(!t.altKey && !this.alwaysReady))
2183
+ if (t.preventDefault(), this.#c = !0, this.pick) {
2184
+ if (!this.#s) return;
2185
+ const s = this.#s;
2186
+ this.#o(), this.#f(s, t.clientX, t.clientY);
2187
+ } else
2188
+ this.#f(this.host, t.clientX, t.clientY);
2189
+ };
2190
+ #g = (t) => {
2191
+ if (this.disabled || !this.#e && !this.#i && !this.alwaysReady) return;
2192
+ const s = this.#t ?? this.host, n = t.target, r = n === s ? null : this.#_(n, s);
2193
+ if (r !== this.#s && (this.#o(), r))
2194
+ if (this.#s = r, !this.#e)
2195
+ this.#Y(), this.#X(this.#h, r, this.labels ? this.#k(r) : void 0);
2196
+ else {
2197
+ r.toggleAttribute("inspect-hover", !0);
2198
+ let o = r.parentElement;
2199
+ for (; o && o !== s; )
2200
+ o.toggleAttribute("inspect-hover", !0), o = o.parentElement;
2201
+ }
2202
+ };
2203
+ #y = (t) => {
2204
+ if (this.disabled) return;
2205
+ if (!this.#e) {
2206
+ if (this.#c) {
2207
+ this.#c = !1, t.stopPropagation();
2208
+ return;
2209
+ }
2210
+ if (this.pick) {
2211
+ if (!this.#i && !this.alwaysReady || !this.#s) return;
2212
+ t.stopPropagation();
2213
+ const o = this.#s;
2214
+ this.#o(), this.#f(o, t.clientX, t.clientY);
2215
+ } else
2216
+ t.stopPropagation(), this.#f(this.host, t.clientX, t.clientY);
2217
+ return;
2218
+ }
2219
+ t.stopPropagation();
2220
+ const s = this.#t, n = t.target, r = n === s ? null : this.#_(n, s);
2221
+ r && this.#W(r);
2222
+ };
2223
+ #b = (t) => {
2224
+ this.#e && (t.preventDefault(), this.#r = Math.max(0.1, this.#r + (t.deltaY > 0 ? -0.5 : 0.5)), this.#K());
2225
+ };
2226
+ #z = (t) => {
2227
+ if (this.#e) {
2228
+ if (this.#c) {
2229
+ this.#c = !1;
2230
+ return;
2231
+ }
2232
+ this.#n && !this.#n.contains(t.target) && this.#E();
2233
+ }
2234
+ };
2235
+ #R = (t) => {
2236
+ this.#e && t.key === "Escape" && (t.preventDefault(), this.#E());
2237
+ };
2238
+ #D = (t) => {
2239
+ t.preventDefault();
2240
+ };
2241
+ #H = (t) => {
2242
+ t.preventDefault();
2243
+ };
2244
+ // ── Internals ──
2245
+ #u(t) {
2246
+ t ? (this.host.toggleAttribute("inspect-ready", !0), this.#Y(), this.#X(this.#d, this.host, this.labels ? this.#k(this.host) : void 0)) : (this.host.removeAttribute("inspect-ready"), this.#O(this.#d));
2247
+ }
2248
+ #Y() {
2249
+ if (this.#l) return;
2250
+ const t = document.createElement("div");
2251
+ t.setAttribute("popover", "manual"), t.style.cssText = "position:fixed;inset:0;margin:0;padding:0;border:none;background:transparent;pointer-events:none;overflow:visible;", this.#d = this.#N("oklch(0.6 0.2 250 / 0.5)"), this.#h = this.#N("oklch(0.6 0.2 250 / 0.7)"), t.append(this.#d, this.#h), document.body.appendChild(t), typeof t.showPopover == "function" && t.showPopover(), this.#l = t;
2252
+ }
2253
+ #N(t) {
2254
+ const s = document.createElement("div");
2255
+ s.style.cssText = `position:fixed;pointer-events:none;display:none;box-sizing:border-box;outline:2px solid ${t};outline-offset:-1px;`;
2256
+ const n = document.createElement("span");
2257
+ return n.style.cssText = "position:absolute;bottom:100%;left:0.25rem;margin-bottom:2px;font:500 0.625rem/1.4 ui-monospace,monospace;color:oklch(0.85 0.15 250);background:oklch(0.2 0.05 250/0.85);padding:0.1rem 0.35rem;border-radius:0.2rem;white-space:nowrap;display:none;", s.appendChild(n), s;
2258
+ }
2259
+ #X(t, s, n) {
2260
+ const r = s.getBoundingClientRect();
2261
+ t.style.top = `${r.top}px`, t.style.left = `${r.left}px`, t.style.width = `${r.width}px`, t.style.height = `${r.height}px`, t.style.display = "block";
2262
+ const o = t.firstElementChild;
2263
+ n ? (o.textContent = n, o.style.display = "block") : o.style.display = "none";
2264
+ }
2265
+ #O(t) {
2266
+ t && (t.style.display = "none");
2267
+ }
2268
+ #T() {
2269
+ if (this.#l) {
2270
+ try {
2271
+ this.#l.hidePopover();
2272
+ } catch {
2273
+ }
2274
+ this.#l.remove(), this.#l = null, this.#d = null, this.#h = null;
2275
+ }
2276
+ }
2277
+ #K() {
2278
+ const t = this.#t ?? this.host;
2279
+ if (this.#v.forEach((s, n) => {
2280
+ const r = this.recursive ? this.#B(s, t) * this.depth : (n + 1) * this.depth;
2281
+ s.style.transform = `translateZ(${r * this.#r}px)`;
2282
+ }), this.#t && this.#a) {
2283
+ const s = this.#t.style.transform, n = this.#a * this.#r;
2284
+ this.#t.style.transform = s.replace(/translateZ\([^)]+\)/, `translateZ(${n}px)`);
2285
+ }
2286
+ }
2287
+ #_(t, s) {
2288
+ if (this.recursive && s.contains(t) && t !== s) return t;
2289
+ let n = t;
2290
+ for (; n && n !== s; ) {
2291
+ if (n.parentElement === s) return n;
2292
+ n = n.parentElement;
2293
+ }
2294
+ return null;
2295
+ }
2296
+ #o() {
2297
+ if (!this.#s) return;
2298
+ const t = this.#t ?? this.host;
2299
+ let s = this.#s;
2300
+ for (; s && s !== t; )
2301
+ s.removeAttribute("inspect-hover"), s = s.parentElement;
2302
+ this.#O(this.#h), this.#s = null;
2303
+ }
2304
+ #W(t) {
2305
+ this.#q(), this.#m = t;
2306
+ const s = this.#t ?? this.host;
2307
+ let n = t;
2308
+ for (; n && n !== s; )
2309
+ n.toggleAttribute("inspect-selected", !0), n = n.parentElement;
2310
+ }
2311
+ #q() {
2312
+ if (!this.#m) return;
2313
+ const t = this.#t ?? this.host;
2314
+ let s = this.#m;
2315
+ for (; s && s !== t; )
2316
+ s.removeAttribute("inspect-selected"), s = s.parentElement;
2317
+ this.#m = null;
2318
+ }
2319
+ #k(t) {
2320
+ const s = t.tagName.toLowerCase(), n = t.id ? `#${t.id}` : "", r = typeof t.className == "string" && t.className ? `.${t.className.split(/\s+/)[0]}` : "";
2321
+ return `${s}${n}${r}`;
2322
+ }
2323
+ #F(t) {
2324
+ t.setAttribute("data-inspect-label", this.#k(t));
2325
+ }
2326
+ #B(t, s) {
2327
+ let n = 0, r = t;
2328
+ for (; r && r !== s; )
2329
+ n++, r = r.parentElement;
2330
+ return n;
2331
+ }
2332
+ #U(t) {
2333
+ if (!this.recursive) return Array.from(t.children).filter((o) => o instanceof HTMLElement);
2334
+ const s = [], n = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
2335
+ acceptNode: (o) => o instanceof HTMLElement ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
2336
+ });
2337
+ let r;
2338
+ for (; r = n.nextNode(); )
2339
+ r instanceof HTMLElement && s.push(r);
2340
+ return s;
2341
+ }
2342
+ #f(t, s, n) {
2343
+ this.#e = !0;
2344
+ const r = ++this.#L;
2345
+ this.#o(), this.#u(!1), this.#A = t, t.toggleAttribute("inspecting", !0);
2346
+ const o = t.getBoundingClientRect(), a = t.cloneNode(!0);
2347
+ a.setAttribute("data-inspect-clone", ""), a.querySelectorAll("*").forEach((v) => {
2348
+ v.tagName.includes("-") && v.setAttribute("data-inspect-clone", "");
2349
+ });
2350
+ const h = document.createElement("div");
2351
+ h.setAttribute("popover", "manual"), h.style.cssText = `position:fixed;inset:auto;margin:0;padding:0;border:none;background:transparent;overflow:visible;top:${o.top}px;left:${o.left}px;width:${o.width}px;height:${o.height}px;`, h.appendChild(a), document.body.appendChild(h), typeof h.showPopover == "function" && h.showPopover(), this.#t = a, this.#n = h, t.style.visibility = "hidden", this.#a = this.pick ? this.depth * 2 : 0, a.toggleAttribute("inspecting", !0), a.style.transformStyle = "preserve-3d", a.style.transformOrigin = "center center", a.style.userSelect = "none", a.style.overflow = "visible", h.style.transformStyle = "preserve-3d", h.style.perspective = `${this.perspective}px`;
2352
+ const f = s - (o.left + o.width / 2), i = n - (o.top + o.height / 2), l = Math.max(-1, Math.min(1, f / this.tiltRadius)), d = Math.max(-1, Math.min(1, i / this.tiltRadius)) * this.maxTilt, u = l * -this.maxTilt, p = this.#a * this.#r;
2353
+ a.style.transform = `translateZ(${p}px) perspective(${this.perspective}px) scale(${this.scale}) rotateX(${d}deg) rotateY(${u}deg)`, a.style.transition = "transform 500ms cubic-bezier(0.2, 0, 0, 1)";
2354
+ const g = this.#U(a);
2355
+ this.#v = g, g.forEach((v, P) => {
2356
+ const M = this.recursive ? this.#B(v, a) * this.depth : (P + 1) * this.depth;
2357
+ v.toggleAttribute("inspect-layer", !0), v.style.transformStyle = "preserve-3d", v.style.overflow = "visible", v.style.transform = `translateZ(${M}px)`, v.style.transition = "transform 500ms cubic-bezier(0.2, 0, 0, 1)", this.labels && this.#F(v);
2358
+ }), this.labels && this.#F(a), setTimeout(() => {
2359
+ this.#L === r && this.#e && (a.style.transition = "transform 60ms ease-out");
2360
+ }, 520), a.addEventListener("pointermove", this.#g), a.addEventListener("click", this.#y), h.addEventListener("wheel", this.#b, { passive: !1 }), this.dismissOnClickOutside && document.addEventListener("click", this.#z, !0), document.addEventListener("keydown", this.#R), (this.tiltElement ?? document).addEventListener("pointermove", this.#I), document.addEventListener("wheel", this.#b, { passive: !1 }), document.addEventListener("selectstart", this.#D), document.addEventListener("pointerdown", this.#H), this.host.dispatchEvent(new CustomEvent("aui:inspect", { bubbles: !0, composed: !0, detail: { active: !0, layers: g.length } }));
2361
+ }
2362
+ #E() {
2363
+ this.#e = !1, ++this.#L, this.#q(), this.#o();
2364
+ const t = this.#v.length;
2365
+ if (this.#v = [], this.#t && (this.#t.removeEventListener("pointermove", this.#g), this.#t.removeEventListener("click", this.#y)), this.#n) {
2366
+ this.#n.removeEventListener("wheel", this.#b);
2367
+ try {
2368
+ this.#n.hidePopover();
2369
+ } catch {
2370
+ }
2371
+ this.#n.remove();
2372
+ }
2373
+ this.#t = null, this.#n = null, this.#r = 1, this.#a = 0;
2374
+ const s = this.#A ?? this.host;
2375
+ s.style.visibility = "", s.removeAttribute("inspecting"), this.#A = null, document.removeEventListener("click", this.#z, !0), document.removeEventListener("keydown", this.#R), (this.tiltElement ?? document).removeEventListener("pointermove", this.#I), document.removeEventListener("wheel", this.#b), document.removeEventListener("selectstart", this.#D), document.removeEventListener("pointerdown", this.#H), this.host.dispatchEvent(new CustomEvent("aui:inspect", { bubbles: !0, composed: !0, detail: { active: !1, layers: t } }));
2376
+ }
2377
+ }
2378
+ const Dt = {
2379
+ name: "css-inspect",
2380
+ category: "effect",
2381
+ targets: "self",
2382
+ defaults: {
2383
+ depth: "16",
2384
+ scale: "0.85",
2385
+ "max-tilt": "60",
2386
+ "tilt-radius": "384",
2387
+ perspective: "1200",
2388
+ labels: "true",
2389
+ recursive: "true",
2390
+ pick: "false",
2391
+ "always-ready": "false"
2392
+ },
2393
+ attach(e) {
2394
+ const t = new Rt(e.host, {
2395
+ depth: Number(e.config("depth") ?? "16"),
2396
+ scale: Number(e.config("scale") ?? "0.85"),
2397
+ maxTilt: Number(e.config("max-tilt") ?? "60"),
2398
+ tiltRadius: Number(e.config("tilt-radius") ?? "384"),
2399
+ perspective: Number(e.config("perspective") ?? "1200"),
2400
+ labels: (e.config("labels") ?? "true") === "true",
2401
+ recursive: (e.config("recursive") ?? "true") === "true",
2402
+ pick: (e.config("pick") ?? "false") === "true",
2403
+ alwaysReady: (e.config("always-ready") ?? "false") === "true"
2404
+ });
2405
+ return e.host.addEventListener("aui:inspect", ((s) => {
2406
+ e.expose("active", s.detail.active);
2407
+ })), () => {
2408
+ t.destroy();
2409
+ };
2410
+ }
2411
+ }, Ht = {
2412
+ name: "snap-resize",
2413
+ category: "effect",
2414
+ targets: "self",
2415
+ defaults: {
2416
+ grid: "50",
2417
+ modifier: ""
2418
+ },
2419
+ attach(e) {
2420
+ const t = parseInt(e.config("grid") ?? "50", 10), s = e.config("modifier") ?? "";
2421
+ let n = !1;
2422
+ e.expose("grid", t.toString());
2423
+ const r = (f) => Math.round(f / t) * t, o = (f) => {
2424
+ if (s && !n) return;
2425
+ const i = f.detail;
2426
+ if (!i?.sizes) return;
2427
+ const l = i.sizes.map(r), c = [...e.host.children];
2428
+ for (let d = 0; d < c.length && d < l.length; d++)
2429
+ c[d].style.flexBasis = `${l[d]}px`;
2430
+ }, a = (f) => {
2431
+ s && f.key === s && (n = !0);
2432
+ }, h = (f) => {
2433
+ s && f.key === s && (n = !1);
2434
+ };
2435
+ return e.host.addEventListener("aui:panes-resize", o), s && (document.addEventListener("keydown", a), document.addEventListener("keyup", h)), () => {
2436
+ e.host.removeEventListener("aui:panes-resize", o), s && (document.removeEventListener("keydown", a), document.removeEventListener("keyup", h));
2437
+ };
2438
+ }
2439
+ };
2440
+ function Xt() {
2441
+ T(Te), T(ke), T(Ce), T(Pe), T(Me), T(Ie), T($e), T(ze), T(_e), T(qe), T(Fe), T(We), T(Ue), T(Ze), T(Ge), T(Je), T(Qe), T(xe), T(et), T(tt), T(st), T(nt), T(ot), T(rt), T(it), T(at), T(lt), T(dt), T(ht), T(ut), T(pt), T(mt), T(gt), T(yt), T(bt), T(Et), T(wt), T(Lt), T(Tt), T(kt), T(Ct), T(Pt), T(St), T(Mt), T(It), T($t), T(zt), T(Dt), T(Ht);
2442
+ }
2443
+ export {
2444
+ qt as attachTrait,
2445
+ Ft as getTrait,
2446
+ Bt as getTraitNames,
2447
+ Kt as getTraitsByCategory,
2448
+ Wt as parseTraitsAttribute,
2449
+ Xt as registerBuiltinTraits,
2450
+ T as registerTrait,
2451
+ Ut as validateComposition
2452
+ };
2453
+ //# sourceMappingURL=traits.js.map