v-float 0.4.0 → 0.6.0

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.
Files changed (34) hide show
  1. package/LICENSE +20 -20
  2. package/dist/composables/index.d.ts +2 -3
  3. package/dist/composables/index.d.ts.map +1 -1
  4. package/dist/composables/interactions/index.d.ts +3 -3
  5. package/dist/composables/interactions/index.d.ts.map +1 -1
  6. package/dist/composables/interactions/polygon.d.ts +1 -1
  7. package/dist/composables/interactions/polygon.d.ts.map +1 -1
  8. package/dist/composables/interactions/use-click.d.ts +2 -2
  9. package/dist/composables/interactions/use-click.d.ts.map +1 -1
  10. package/dist/composables/interactions/use-client-point.d.ts +180 -20
  11. package/dist/composables/interactions/use-client-point.d.ts.map +1 -1
  12. package/dist/composables/interactions/use-escape-key.d.ts +37 -4
  13. package/dist/composables/interactions/use-escape-key.d.ts.map +1 -1
  14. package/dist/composables/interactions/use-focus.d.ts +2 -2
  15. package/dist/composables/interactions/use-focus.d.ts.map +1 -1
  16. package/dist/composables/interactions/use-hover.d.ts +1 -1
  17. package/dist/composables/interactions/use-hover.d.ts.map +1 -1
  18. package/dist/composables/interactions/utils/index.d.ts +3 -3
  19. package/dist/composables/interactions/utils/index.d.ts.map +1 -1
  20. package/dist/composables/interactions/utils/tree-context.d.ts +2 -2
  21. package/dist/composables/interactions/utils/tree-context.d.ts.map +1 -1
  22. package/dist/composables/middlewares/index.d.ts +1 -1
  23. package/dist/composables/middlewares/index.d.ts.map +1 -1
  24. package/dist/composables/use-arrow.d.ts +0 -5
  25. package/dist/composables/use-arrow.d.ts.map +1 -1
  26. package/dist/composables/use-floating-tree.d.ts +72 -10
  27. package/dist/composables/use-floating-tree.d.ts.map +1 -1
  28. package/dist/composables/use-floating.d.ts +1 -1
  29. package/dist/composables/use-floating.d.ts.map +1 -1
  30. package/dist/v-float.es.js +2313 -2166
  31. package/dist/v-float.umd.js +1 -1
  32. package/package.json +2 -2
  33. package/dist/composables/use-tree.d.ts +0 -144
  34. package/dist/composables/use-tree.d.ts.map +0 -1
@@ -1,2345 +1,2492 @@
1
- var Qt = Object.defineProperty;
2
- var mt = (e) => {
3
- throw TypeError(e);
4
- };
5
- var Zt = (e, t, n) => t in e ? Qt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
- var ce = (e, t, n) => Zt(e, typeof t != "symbol" ? t + "" : t, n), $e = (e, t, n) => t.has(e) || mt("Cannot " + n);
7
- var Xe = (e, t, n) => ($e(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Ne = (e, t, n) => t.has(e) ? mt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), Ye = (e, t, n, o) => ($e(e, t, "write to private field"), o ? o.call(e, n) : t.set(e, n), n), je = (e, t, n) => ($e(e, t, "access private method"), n);
8
- import { toValue as S, ref as U, computed as I, shallowRef as qe, watch as pe, onWatcherCleanup as ue, onScopeDispose as ge, watchPostEffect as Te, getCurrentScope as en, unref as tn, onMounted as nn, watchEffect as pt, readonly as on, shallowReactive as rn } from "vue";
9
- const sn = ["top", "right", "bottom", "left"], we = Math.min, fe = Math.max, Re = Math.round, De = Math.floor, K = (e) => ({
10
- x: e,
11
- y: e
12
- }), ln = {
13
- left: "right",
14
- right: "left",
15
- bottom: "top",
16
- top: "bottom"
17
- }, an = {
18
- start: "end",
19
- end: "start"
20
- };
21
- function Ke(e, t, n) {
22
- return fe(e, we(t, n));
1
+ var Yt = Object.defineProperty;
2
+ var zt = (e, t, n) => t in e ? Yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var ve = (e, t, n) => zt(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { watch as ne, getCurrentScope as _t, onScopeDispose as we, computed as N, toValue as A, unref as Ut, watchPostEffect as Ce, onWatcherCleanup as ue, ref as _, watchEffect as Kt, readonly as qt, onMounted as Gt, shallowRef as je, shallowReactive as Jt } from "vue";
5
+ function Qt(e) {
6
+ return _t() ? (we(e), !0) : !1;
7
+ }
8
+ const Zt = typeof window < "u" && typeof document < "u";
9
+ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
10
+ const en = Object.prototype.toString, tn = (e) => en.call(e) === "[object Object]";
11
+ function $e(e) {
12
+ return Array.isArray(e) ? e : [e];
23
13
  }
24
- function be(e, t) {
25
- return typeof e == "function" ? e(t) : e;
14
+ function nn(e, t, n) {
15
+ return ne(
16
+ e,
17
+ t,
18
+ {
19
+ ...n,
20
+ immediate: !0
21
+ }
22
+ );
26
23
  }
27
- function de(e) {
28
- return e.split("-")[0];
24
+ const on = Zt ? window : void 0;
25
+ function rn(e) {
26
+ var t;
27
+ const n = A(e);
28
+ return (t = n == null ? void 0 : n.$el) != null ? t : n;
29
29
  }
30
- function Me(e) {
31
- return e.split("-")[1];
30
+ function q(...e) {
31
+ const t = [], n = () => {
32
+ t.forEach((a) => a()), t.length = 0;
33
+ }, o = (a, f, c, u) => (a.addEventListener(f, c, u), () => a.removeEventListener(f, c, u)), i = N(() => {
34
+ const a = $e(A(e[0])).filter((f) => f != null);
35
+ return a.every((f) => typeof f != "string") ? a : void 0;
36
+ }), l = nn(
37
+ () => {
38
+ var a, f;
39
+ return [
40
+ (f = (a = i.value) == null ? void 0 : a.map((c) => rn(c))) != null ? f : [on].filter((c) => c != null),
41
+ $e(A(i.value ? e[1] : e[0])),
42
+ $e(Ut(i.value ? e[2] : e[1])),
43
+ // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
44
+ A(i.value ? e[3] : e[2])
45
+ ];
46
+ },
47
+ ([a, f, c, u]) => {
48
+ if (n(), !(a != null && a.length) || !(f != null && f.length) || !(c != null && c.length))
49
+ return;
50
+ const p = tn(u) ? { ...u } : u;
51
+ t.push(
52
+ ...a.flatMap(
53
+ (h) => f.flatMap(
54
+ (d) => c.map((m) => o(h, d, m, p))
55
+ )
56
+ )
57
+ );
58
+ },
59
+ { flush: "post" }
60
+ ), r = () => {
61
+ l(), n();
62
+ };
63
+ return Qt(n), r;
32
64
  }
33
- function It(e) {
34
- return e === "x" ? "y" : "x";
65
+ function st() {
66
+ return typeof navigator > "u" ? !1 : navigator.platform.toUpperCase().indexOf("MAC") >= 0;
35
67
  }
36
- function et(e) {
37
- return e === "y" ? "height" : "width";
68
+ function lt() {
69
+ return typeof navigator > "u" ? !1 : /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
38
70
  }
39
- const cn = /* @__PURE__ */ new Set(["top", "bottom"]);
40
- function ne(e) {
41
- return cn.has(de(e)) ? "y" : "x";
71
+ function sn(e) {
72
+ return typeof (e == null ? void 0 : e.matches) != "function" ? !1 : e.matches(":focus-visible");
42
73
  }
43
- function tt(e) {
44
- return It(ne(e));
74
+ function St(e, t) {
75
+ if (e === void 0) return !1;
76
+ const n = e === "mouse";
77
+ return t ? n : n || e === "pen";
45
78
  }
46
- function un(e, t, n) {
47
- n === void 0 && (n = !1);
48
- const o = Me(e), i = tt(e), r = et(i);
49
- let l = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
50
- return t.reference[r] > t.floating[r] && (l = ke(l)), [l, ke(l)];
79
+ function At(e) {
80
+ return !e || !(e instanceof HTMLElement) ? !1 : e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e.isContentEditable && e.contentEditable !== "false";
51
81
  }
52
- function fn(e) {
53
- const t = ke(e);
54
- return [Ge(e), t, Ge(t)];
82
+ function at(e) {
83
+ const t = e.target;
84
+ return t instanceof HTMLElement ? t.tagName === "BUTTON" || t.tagName === "INPUT" && t.getAttribute("type") === "button" || t.getAttribute("role") === "button" : !1;
55
85
  }
56
- function Ge(e) {
57
- return e.replace(/start|end/g, (t) => an[t]);
86
+ function ct(e) {
87
+ return At(e);
58
88
  }
59
- const vt = ["left", "right"], gt = ["right", "left"], dn = ["top", "bottom"], hn = ["bottom", "top"];
60
- function mn(e, t, n) {
61
- switch (e) {
62
- case "top":
63
- case "bottom":
64
- return n ? t ? gt : vt : t ? vt : gt;
65
- case "left":
66
- case "right":
67
- return t ? dn : hn;
68
- default:
69
- return [];
89
+ function ln(e) {
90
+ return e instanceof Element && e instanceof HTMLElement;
91
+ }
92
+ function xo(e) {
93
+ return typeof e == "object" && e !== null && "contextElement" in e;
94
+ }
95
+ function ut(e, t) {
96
+ return t ? "composedPath" in e && typeof e.composedPath == "function" ? e.composedPath().includes(t) : t.contains(e.target) : !1;
97
+ }
98
+ function an(e, t) {
99
+ const n = t.getBoundingClientRect(), o = t.offsetWidth - t.clientWidth, i = t.offsetHeight - t.clientHeight, l = e.clientX - n.left, r = e.clientY - n.top;
100
+ if (o > 0) {
101
+ const a = t.clientWidth;
102
+ if (l >= a && l <= t.offsetWidth)
103
+ return !0;
104
+ }
105
+ if (i > 0) {
106
+ const a = t.clientHeight;
107
+ if (r >= a && r <= t.offsetHeight)
108
+ return !0;
70
109
  }
110
+ return !1;
111
+ }
112
+ function Ve(e, t) {
113
+ return e.contains(t);
71
114
  }
72
- function pn(e, t, n, o) {
73
- const i = Me(e);
74
- let r = mn(de(e), n === "start", o);
75
- return i && (r = r.map((l) => l + "-" + i), t && (r = r.concat(r.map(Ge)))), r;
115
+ function cn(e) {
116
+ return e.target;
76
117
  }
77
- function ke(e) {
78
- return e.replace(/left|right|bottom|top/g, (t) => ln[t]);
118
+ function ft() {
119
+ return typeof performance < "u" ? performance.now() : Date.now();
79
120
  }
80
- function vn(e) {
81
- return {
82
- top: 0,
83
- right: 0,
84
- bottom: 0,
85
- left: 0,
86
- ...e
87
- };
121
+ function dt(e) {
122
+ e !== -1 && clearTimeout(e);
88
123
  }
89
- function Wt(e) {
90
- return typeof e != "number" ? vn(e) : {
91
- top: e,
92
- right: e,
93
- bottom: e,
94
- left: e
95
- };
124
+ function un(e) {
125
+ return e !== null && typeof e == "object" && "data" in e && "id" in e && "children" in e && "parent" in e;
96
126
  }
97
127
  function Fe(e) {
98
- const {
99
- x: t,
100
- y: n,
101
- width: o,
102
- height: i
103
- } = e;
104
- return {
105
- width: o,
106
- height: i,
107
- top: n,
108
- left: t,
109
- right: t + o,
110
- bottom: n + i,
111
- x: t,
112
- y: n
128
+ return un(e) ? {
129
+ floatingContext: e.data,
130
+ treeContext: e
131
+ } : {
132
+ floatingContext: e,
133
+ treeContext: null
113
134
  };
114
135
  }
115
- function wt(e, t, n) {
116
- let {
117
- reference: o,
118
- floating: i
119
- } = e;
120
- const r = ne(t), l = tt(t), a = et(l), u = de(t), c = r === "y", h = o.x + o.width / 2 - i.width / 2, f = o.y + o.height / 2 - i.height / 2, p = o[a] / 2 - i[a] / 2;
121
- let d;
122
- switch (u) {
123
- case "top":
124
- d = {
125
- x: h,
126
- y: o.y - i.height
127
- };
128
- break;
129
- case "bottom":
130
- d = {
131
- x: h,
132
- y: o.y + o.height
133
- };
134
- break;
135
- case "right":
136
- d = {
137
- x: o.x + o.width,
138
- y: f
139
- };
140
- break;
141
- case "left":
142
- d = {
143
- x: o.x - i.width,
144
- y: f
145
- };
146
- break;
147
- default:
148
- d = {
149
- x: o.x,
150
- y: o.y
151
- };
136
+ function J(e, t) {
137
+ if (!t) return !1;
138
+ if (typeof t == "object" && t !== null && "contextElement" in t) {
139
+ const n = t.contextElement;
140
+ return n instanceof Element ? n.contains(e) : !1;
152
141
  }
153
- switch (Me(t)) {
154
- case "start":
155
- d[l] -= p * (n && c ? -1 : 1);
156
- break;
157
- case "end":
158
- d[l] += p * (n && c ? -1 : 1);
159
- break;
142
+ return t instanceof Element ? t.contains(e) : !1;
143
+ }
144
+ function Ke(e, t) {
145
+ for (const n of e.children.value)
146
+ if (n.data.open.value) {
147
+ if (J(t, n.data.refs.anchorEl.value) || J(t, n.data.refs.floatingEl.value))
148
+ return n;
149
+ const o = Ke(n, t);
150
+ if (o) return o;
151
+ }
152
+ return null;
153
+ }
154
+ function Eo(e, t = {}) {
155
+ const { floatingContext: n, treeContext: o } = Fe(e), { open: i, setOpen: l, refs: r } = n, {
156
+ enabled: a = !0,
157
+ event: f = "click",
158
+ toggle: c = !0,
159
+ ignoreMouse: u = !1,
160
+ ignoreKeyboard: p = !1,
161
+ ignoreTouch: h = !1,
162
+ // Outside click options
163
+ outsideClick: d = !1,
164
+ outsideEvent: m = "pointerdown",
165
+ outsideCapture: g = !0,
166
+ onOutsideClick: v,
167
+ preventScrollbarClick: x = !0,
168
+ handleDragEvents: T = !0
169
+ } = t;
170
+ let C, S = !1, w = !1, b = !1;
171
+ const P = N(() => A(a)), F = N(() => A(d)), D = N(() => {
172
+ const O = r.anchorEl.value;
173
+ return O instanceof HTMLElement ? O : null;
174
+ }), M = N(() => r.floatingEl.value);
175
+ function B() {
176
+ b = !0;
177
+ try {
178
+ i.value ? A(c) && l(!1) : l(!0);
179
+ } finally {
180
+ Promise.resolve().then(() => {
181
+ b = !1;
182
+ });
183
+ }
160
184
  }
161
- return d;
185
+ function W() {
186
+ C = void 0, S = !1, w = !1;
187
+ }
188
+ function X(O) {
189
+ C = O.pointerType;
190
+ }
191
+ function R(O) {
192
+ O.button === 0 && A(f) !== "click" && ($(C) || B());
193
+ }
194
+ function E() {
195
+ if (A(f) === "mousedown" && C) {
196
+ W();
197
+ return;
198
+ }
199
+ if ($(C)) {
200
+ W();
201
+ return;
202
+ }
203
+ B(), W();
204
+ }
205
+ function s(O) {
206
+ if (C = void 0, O.defaultPrevented || A(p) || at(O))
207
+ return;
208
+ const V = D.value;
209
+ V && (O.key === " " && !ct(V) && (O.preventDefault(), S = !0), O.key === "Enter" && B());
210
+ }
211
+ function k(O) {
212
+ const V = D.value;
213
+ V && (O.defaultPrevented || A(p) || at(O) || ct(V) || O.key === " " && S && (S = !1, B()));
214
+ }
215
+ function y(O) {
216
+ if (!P.value || !F.value || !i.value)
217
+ return;
218
+ if (A(m) === "click" && A(T) && w) {
219
+ w = !1;
220
+ return;
221
+ }
222
+ if (b)
223
+ return;
224
+ const V = O.target;
225
+ if (V && !(A(x) && ln(V) && M.value && an(O, V))) {
226
+ if (o) {
227
+ if (!fn(o, V))
228
+ return;
229
+ } else if (ut(O, D.value) || ut(O, M.value))
230
+ return;
231
+ v ? v(O, n) : l(!1);
232
+ }
233
+ }
234
+ function H() {
235
+ w = !0;
236
+ }
237
+ function ee() {
238
+ setTimeout(() => {
239
+ w = !1;
240
+ }, 0);
241
+ }
242
+ function $(O) {
243
+ return !!(St(O, !0) && A(u) || O === "touch" && A(h));
244
+ }
245
+ Ce(() => {
246
+ const O = D.value;
247
+ !P.value || !O || (O.addEventListener("pointerdown", X), O.addEventListener("mousedown", R), O.addEventListener("click", E), O.addEventListener("keydown", s), O.addEventListener("keyup", k), ue(() => {
248
+ O.removeEventListener("pointerdown", X), O.removeEventListener("mousedown", R), O.removeEventListener("click", E), O.removeEventListener("keydown", s), O.removeEventListener("keyup", k), W();
249
+ }));
250
+ }), q(
251
+ () => P.value && F.value ? document : null,
252
+ () => A(m),
253
+ y,
254
+ { capture: A(g) }
255
+ ), q(
256
+ () => P.value && F.value && A(T) ? M.value : null,
257
+ "mousedown",
258
+ H,
259
+ { capture: !0 }
260
+ ), q(
261
+ () => P.value && F.value && A(T) ? M.value : null,
262
+ "mouseup",
263
+ ee,
264
+ { capture: !0 }
265
+ );
162
266
  }
163
- const gn = async (e, t, n) => {
164
- const {
165
- placement: o = "bottom",
166
- strategy: i = "absolute",
167
- middleware: r = [],
168
- platform: l
169
- } = n, a = r.filter(Boolean), u = await (l.isRTL == null ? void 0 : l.isRTL(t));
170
- let c = await l.getElementRects({
171
- reference: e,
172
- floating: t,
173
- strategy: i
174
- }), {
175
- x: h,
176
- y: f
177
- } = wt(c, o, u), p = o, d = {}, g = 0;
178
- for (let m = 0; m < a.length; m++) {
179
- const {
180
- name: b,
181
- fn: w
182
- } = a[m], {
183
- x: y,
184
- y: C,
185
- data: P,
186
- reset: E
187
- } = await w({
188
- x: h,
189
- y: f,
190
- initialPlacement: o,
191
- placement: p,
192
- strategy: i,
193
- middlewareData: d,
194
- rects: c,
195
- platform: l,
196
- elements: {
197
- reference: e,
198
- floating: t
199
- }
267
+ function fn(e, t) {
268
+ return !(J(t, e.data.refs.anchorEl.value) || J(t, e.data.refs.floatingEl.value) || Ke(e, t));
269
+ }
270
+ const Ae = (e) => typeof e == "number" && Number.isFinite(e) ? e : null, ce = class ce {
271
+ /**
272
+ * Create a virtual anchor element
273
+ */
274
+ create(t) {
275
+ const n = this.buildConfiguration(t);
276
+ return {
277
+ contextElement: n.referenceElement || void 0,
278
+ getBoundingClientRect: () => this.buildBoundingRect(n)
279
+ };
280
+ }
281
+ /**
282
+ * Build configuration from options with defaults
283
+ */
284
+ buildConfiguration(t) {
285
+ return {
286
+ coordinates: t.coordinates,
287
+ referenceElement: t.referenceElement ?? null,
288
+ baselineCoordinates: t.baselineCoordinates ?? null,
289
+ axis: t.axis ?? "both"
290
+ };
291
+ }
292
+ /**
293
+ * Build the bounding rectangle for the virtual element
294
+ */
295
+ buildBoundingRect(t) {
296
+ const n = this.getReferenceRect(t.referenceElement), o = this.resolvePosition(t, n), i = this.calculateSize(t.axis, n);
297
+ return this.buildDOMRect({
298
+ x: o.x,
299
+ y: o.y,
300
+ width: i.width,
301
+ height: i.height
200
302
  });
201
- h = y ?? h, f = C ?? f, d = {
202
- ...d,
203
- [b]: {
204
- ...d[b],
205
- ...P
303
+ }
304
+ /**
305
+ * Get reference element bounds with fallback
306
+ */
307
+ getReferenceRect(t) {
308
+ if (t)
309
+ try {
310
+ return t.getBoundingClientRect();
311
+ } catch (n) {
312
+ console.warn("VirtualElementFactory: Failed to get element bounds", { element: t, error: n });
206
313
  }
207
- }, E && g <= 50 && (g++, typeof E == "object" && (E.placement && (p = E.placement), E.rects && (c = E.rects === !0 ? await l.getElementRects({
208
- reference: e,
209
- floating: t,
210
- strategy: i
211
- }) : E.rects), {
212
- x: h,
213
- y: f
214
- } = wt(c, p, u)), m = -1);
314
+ return this.buildDOMRect({
315
+ x: 0,
316
+ y: 0,
317
+ width: ce.DEFAULT_DIMENSIONS.width,
318
+ height: ce.DEFAULT_DIMENSIONS.height
319
+ });
215
320
  }
216
- return {
217
- x: h,
218
- y: f,
219
- placement: p,
220
- strategy: i,
221
- middlewareData: d
222
- };
223
- };
224
- async function He(e, t) {
225
- var n;
226
- t === void 0 && (t = {});
227
- const {
228
- x: o,
229
- y: i,
230
- platform: r,
231
- rects: l,
232
- elements: a,
233
- strategy: u
234
- } = e, {
235
- boundary: c = "clippingAncestors",
236
- rootBoundary: h = "viewport",
237
- elementContext: f = "floating",
238
- altBoundary: p = !1,
239
- padding: d = 0
240
- } = be(t, e), g = Wt(d), b = a[p ? f === "floating" ? "reference" : "floating" : f], w = Fe(await r.getClippingRect({
241
- element: (n = await (r.isElement == null ? void 0 : r.isElement(b))) == null || n ? b : b.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(a.floating)),
242
- boundary: c,
243
- rootBoundary: h,
244
- strategy: u
245
- })), y = f === "floating" ? {
246
- x: o,
247
- y: i,
248
- width: l.floating.width,
249
- height: l.floating.height
250
- } : l.reference, C = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a.floating)), P = await (r.isElement == null ? void 0 : r.isElement(C)) ? await (r.getScale == null ? void 0 : r.getScale(C)) || {
251
- x: 1,
252
- y: 1
253
- } : {
254
- x: 1,
255
- y: 1
256
- }, E = Fe(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
257
- elements: a,
258
- rect: y,
259
- offsetParent: C,
260
- strategy: u
261
- }) : y);
262
- return {
263
- top: (w.top - E.top + g.top) / P.y,
264
- bottom: (E.bottom - w.bottom + g.bottom) / P.y,
265
- left: (w.left - E.left + g.left) / P.x,
266
- right: (E.right - w.right + g.right) / P.x
267
- };
268
- }
269
- const wn = (e) => ({
270
- name: "arrow",
271
- options: e,
272
- async fn(t) {
273
- const {
274
- x: n,
275
- y: o,
276
- placement: i,
277
- rects: r,
278
- platform: l,
279
- elements: a,
280
- middlewareData: u
281
- } = t, {
282
- element: c,
283
- padding: h = 0
284
- } = be(e, t) || {};
285
- if (c == null)
286
- return {};
287
- const f = Wt(h), p = {
288
- x: n,
289
- y: o
290
- }, d = tt(i), g = et(d), m = await l.getDimensions(c), b = d === "y", w = b ? "top" : "left", y = b ? "bottom" : "right", C = b ? "clientHeight" : "clientWidth", P = r.reference[g] + r.reference[d] - p[d] - r.floating[g], E = p[d] - r.reference[d], T = await (l.getOffsetParent == null ? void 0 : l.getOffsetParent(c));
291
- let A = T ? T[C] : 0;
292
- (!A || !await (l.isElement == null ? void 0 : l.isElement(T))) && (A = a.floating[C] || r.floating[g]);
293
- const D = P / 2 - E / 2, R = A / 2 - m[g] / 2 - 1, N = we(f[w], R), M = we(f[y], R), k = N, V = A - m[g] - M, F = A / 2 - m[g] / 2 + D, Y = Ke(k, F, V), x = !u.arrow && Me(i) != null && F !== Y && r.reference[g] / 2 - (F < k ? N : M) - m[g] / 2 < 0, s = x ? F < k ? F - k : F - V : 0;
321
+ /**
322
+ * Resolve final position from coordinate sources
323
+ */
324
+ resolvePosition(t, n) {
325
+ var o, i;
294
326
  return {
295
- [d]: p[d] + s,
296
- data: {
297
- [d]: Y,
298
- centerOffset: F - Y - s,
299
- ...x && {
300
- alignmentOffset: s
301
- }
302
- },
303
- reset: x
327
+ x: this.resolveAxisCoordinate({
328
+ current: t.coordinates.x,
329
+ baseline: ((o = t.baselineCoordinates) == null ? void 0 : o.x) ?? null,
330
+ fallback: n.x,
331
+ isAxisEnabled: t.axis === "x" || t.axis === "both"
332
+ }),
333
+ y: this.resolveAxisCoordinate({
334
+ current: t.coordinates.y,
335
+ baseline: ((i = t.baselineCoordinates) == null ? void 0 : i.y) ?? null,
336
+ fallback: n.y,
337
+ isAxisEnabled: t.axis === "y" || t.axis === "both"
338
+ })
304
339
  };
305
340
  }
306
- }), yn = function(e) {
307
- return e === void 0 && (e = {}), {
308
- name: "flip",
309
- options: e,
310
- async fn(t) {
311
- var n, o;
312
- const {
313
- placement: i,
314
- middlewareData: r,
315
- rects: l,
316
- initialPlacement: a,
317
- platform: u,
318
- elements: c
319
- } = t, {
320
- mainAxis: h = !0,
321
- crossAxis: f = !0,
322
- fallbackPlacements: p,
323
- fallbackStrategy: d = "bestFit",
324
- fallbackAxisSideDirection: g = "none",
325
- flipAlignment: m = !0,
326
- ...b
327
- } = be(e, t);
328
- if ((n = r.arrow) != null && n.alignmentOffset)
329
- return {};
330
- const w = de(i), y = ne(a), C = de(a) === a, P = await (u.isRTL == null ? void 0 : u.isRTL(c.floating)), E = p || (C || !m ? [ke(a)] : fn(a)), T = g !== "none";
331
- !p && T && E.push(...pn(a, m, g, P));
332
- const A = [a, ...E], D = await He(t, b), R = [];
333
- let N = ((o = r.flip) == null ? void 0 : o.overflows) || [];
334
- if (h && R.push(D[w]), f) {
335
- const F = un(i, l, P);
336
- R.push(D[F[0]], D[F[1]]);
337
- }
338
- if (N = [...N, {
339
- placement: i,
340
- overflows: R
341
- }], !R.every((F) => F <= 0)) {
342
- var M, k;
343
- const F = (((M = r.flip) == null ? void 0 : M.index) || 0) + 1, Y = A[F];
344
- if (Y && (!(f === "alignment" ? y !== ne(Y) : !1) || // We leave the current main axis only if every placement on that axis
345
- // overflows the main axis.
346
- N.every((v) => ne(v.placement) === y ? v.overflows[0] > 0 : !0)))
347
- return {
348
- data: {
349
- index: F,
350
- overflows: N
351
- },
352
- reset: {
353
- placement: Y
354
- }
355
- };
356
- let x = (k = N.filter((s) => s.overflows[0] <= 0).sort((s, v) => s.overflows[1] - v.overflows[1])[0]) == null ? void 0 : k.placement;
357
- if (!x)
358
- switch (d) {
359
- case "bestFit": {
360
- var V;
361
- const s = (V = N.filter((v) => {
362
- if (T) {
363
- const H = ne(v.placement);
364
- return H === y || // Create a bias to the `y` side axis due to horizontal
365
- // reading directions favoring greater width.
366
- H === "y";
367
- }
368
- return !0;
369
- }).map((v) => [v.placement, v.overflows.filter((H) => H > 0).reduce((H, X) => H + X, 0)]).sort((v, H) => v[1] - H[1])[0]) == null ? void 0 : V[0];
370
- s && (x = s);
371
- break;
372
- }
373
- case "initialPlacement":
374
- x = a;
375
- break;
376
- }
377
- if (i !== x)
378
- return {
379
- reset: {
380
- placement: x
381
- }
382
- };
383
- }
384
- return {};
341
+ /**
342
+ * Resolve coordinate for a single axis with clear precedence
343
+ */
344
+ resolveAxisCoordinate(t) {
345
+ const { current: n, baseline: o, fallback: i, isAxisEnabled: l } = t;
346
+ return l && n !== null ? n : o !== null ? o : i;
347
+ }
348
+ /**
349
+ * Calculate virtual element size based on axis constraints
350
+ */
351
+ calculateSize(t, n) {
352
+ const o = (i, l) => Math.max(0, i || l);
353
+ switch (t) {
354
+ case "both":
355
+ return { width: 0, height: 0 };
356
+ case "x":
357
+ return {
358
+ width: o(
359
+ n.width,
360
+ ce.DEFAULT_DIMENSIONS.width
361
+ ),
362
+ height: 0
363
+ };
364
+ case "y":
365
+ return {
366
+ width: 0,
367
+ height: o(
368
+ n.height,
369
+ ce.DEFAULT_DIMENSIONS.height
370
+ )
371
+ };
385
372
  }
386
- };
373
+ }
374
+ /**
375
+ * Build a DOMRect object
376
+ */
377
+ buildDOMRect(t) {
378
+ const { x: n, y: o, width: i, height: l } = t, r = Math.max(0, i), a = Math.max(0, l);
379
+ return {
380
+ x: n,
381
+ y: o,
382
+ width: r,
383
+ height: a,
384
+ top: o,
385
+ right: n + r,
386
+ bottom: o + a,
387
+ left: n,
388
+ toJSON: () => ({ x: n, y: o, width: r, height: a })
389
+ };
390
+ }
387
391
  };
388
- function yt(e, t) {
389
- return {
390
- top: e.top - t.height,
391
- right: e.right - t.width,
392
- bottom: e.bottom - t.height,
393
- left: e.left - t.width
394
- };
392
+ ve(ce, "DEFAULT_DIMENSIONS", { width: 100, height: 30 });
393
+ let Ye = ce;
394
+ class Mt {
395
+ constructor() {
396
+ // The core state every strategy needs: the last known good coordinates
397
+ ve(this, "lastKnownCoordinates", null);
398
+ }
399
+ /**
400
+ * Get coordinates to use when the floating element opens
401
+ * This lets each strategy decide its opening behavior without client code needing to know the details
402
+ */
403
+ getCoordinatesForOpening() {
404
+ return this.lastKnownCoordinates;
405
+ }
406
+ /**
407
+ * Called when the floating element closes
408
+ * This is where strategies should clean up any temporary state
409
+ */
410
+ onClose() {
411
+ this.lastKnownCoordinates = null;
412
+ }
413
+ /**
414
+ * Reset all strategy state - used when the composable is disabled or reset
415
+ */
416
+ reset() {
417
+ this.lastKnownCoordinates = null;
418
+ }
395
419
  }
396
- function bt(e) {
397
- return sn.some((t) => e[t] >= 0);
420
+ class dn extends Mt {
421
+ constructor() {
422
+ super(...arguments);
423
+ ve(this, "name", "follow");
424
+ }
425
+ /**
426
+ * Follow strategy needs all pointer events for continuous tracking
427
+ */
428
+ getRequiredEvents() {
429
+ return ["pointerdown", "pointermove", "pointerenter"];
430
+ }
431
+ /**
432
+ * Follow strategy: always update coordinates based on the current pointer position
433
+ * This creates smooth, continuous tracking behavior
434
+ */
435
+ process(n, o) {
436
+ const i = n.coordinates;
437
+ switch (this.lastKnownCoordinates = i, n.type) {
438
+ case "pointerdown":
439
+ return i;
440
+ case "pointermove":
441
+ return o.isOpen && St(n.originalEvent.pointerType, !0) ? i : null;
442
+ case "pointerenter":
443
+ return i;
444
+ default:
445
+ return null;
446
+ }
447
+ }
398
448
  }
399
- const bn = function(e) {
400
- return e === void 0 && (e = {}), {
401
- name: "hide",
402
- options: e,
403
- async fn(t) {
404
- const {
405
- rects: n
406
- } = t, {
407
- strategy: o = "referenceHidden",
408
- ...i
409
- } = be(e, t);
410
- switch (o) {
411
- case "referenceHidden": {
412
- const r = await He(t, {
413
- ...i,
414
- elementContext: "reference"
415
- }), l = yt(r, n.reference);
416
- return {
417
- data: {
418
- referenceHiddenOffsets: l,
419
- referenceHidden: bt(l)
420
- }
421
- };
422
- }
423
- case "escaped": {
424
- const r = await He(t, {
425
- ...i,
426
- altBoundary: !0
427
- }), l = yt(r, n.floating);
428
- return {
429
- data: {
430
- escapedOffsets: l,
431
- escaped: bt(l)
432
- }
433
- };
434
- }
435
- default:
436
- return {};
437
- }
449
+ class hn extends Mt {
450
+ constructor() {
451
+ super(...arguments);
452
+ ve(this, "name", "static");
453
+ // Static strategy needs to remember the "trigger" coordinates from clicks
454
+ // These take priority over hover coordinates for positioning
455
+ ve(this, "triggerCoordinates", null);
456
+ }
457
+ /**
458
+ * Static strategy only needs click events, not hover or continuous movement
459
+ * This optimization avoids registering unnecessary pointer events
460
+ */
461
+ getRequiredEvents() {
462
+ return ["pointerdown"];
463
+ }
464
+ /**
465
+ * Static strategy: capture coordinates from trigger events, ignore movement
466
+ * This creates stable positioning that doesn't jump around
467
+ */
468
+ process(n, o) {
469
+ const i = n.coordinates;
470
+ return this.triggerCoordinates = i, this.lastKnownCoordinates = i, o.isOpen ? i : null;
471
+ }
472
+ /**
473
+ * Get coordinates to use when floating element opens
474
+ */
475
+ getCoordinatesForOpening() {
476
+ return this.triggerCoordinates ? this.triggerCoordinates : this.lastKnownCoordinates;
477
+ }
478
+ /**
479
+ * Reset tracking state
480
+ */
481
+ reset() {
482
+ super.reset(), this.triggerCoordinates = null;
483
+ }
484
+ onClose() {
485
+ this.triggerCoordinates = null;
486
+ }
487
+ }
488
+ function Co(e, t, n = {}) {
489
+ const { open: o, refs: i } = t, l = new Ye(), r = _({ x: null, y: null }), a = _(null), f = N(() => A(n.axis ?? "both")), c = N(() => A(n.enabled ?? !0)), u = N(() => Ae(A(n.x ?? null))), p = N(() => Ae(A(n.y ?? null))), h = N(
490
+ () => u.value !== null && p.value !== null
491
+ ), d = N(() => h.value ? {
492
+ x: u.value,
493
+ y: p.value
494
+ } : r.value), m = N(() => {
495
+ const b = d.value;
496
+ switch (f.value) {
497
+ case "x":
498
+ return { x: b.x, y: null };
499
+ case "y":
500
+ return { x: null, y: b.y };
501
+ case "both":
502
+ return b;
438
503
  }
504
+ }), g = (n.trackingMode ?? "follow") === "follow" ? new dn() : new hn(), v = (b, P) => {
505
+ h.value || (r.value = {
506
+ x: Ae(b),
507
+ y: Ae(P)
508
+ });
509
+ }, x = () => {
510
+ h.value || (r.value = { x: null, y: null });
511
+ }, T = (b, P) => {
512
+ const F = {
513
+ type: P,
514
+ coordinates: { x: b.clientX, y: b.clientY },
515
+ originalEvent: b
516
+ }, D = g.process(F, {
517
+ isOpen: o.value
518
+ });
519
+ D && v(D.x, D.y);
439
520
  };
440
- }, xn = /* @__PURE__ */ new Set(["left", "top"]);
441
- async function En(e, t) {
442
- const {
443
- placement: n,
444
- platform: o,
445
- elements: i
446
- } = e, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), l = de(n), a = Me(n), u = ne(n) === "y", c = xn.has(l) ? -1 : 1, h = r && u ? -1 : 1, f = be(t, e);
447
- let {
448
- mainAxis: p,
449
- crossAxis: d,
450
- alignmentAxis: g
451
- } = typeof f == "number" ? {
452
- mainAxis: f,
453
- crossAxis: 0,
454
- alignmentAxis: null
455
- } : {
456
- mainAxis: f.mainAxis || 0,
457
- crossAxis: f.crossAxis || 0,
458
- alignmentAxis: f.alignmentAxis
521
+ ne(
522
+ [m, a, f, e],
523
+ () => {
524
+ i.anchorEl.value = l.create({
525
+ coordinates: m.value,
526
+ referenceElement: e.value,
527
+ baselineCoordinates: a.value,
528
+ axis: f.value
529
+ });
530
+ },
531
+ { immediate: !0 }
532
+ ), ne(o, (b) => {
533
+ if (!(!c.value || h.value))
534
+ if (b) {
535
+ const P = g.getCoordinatesForOpening();
536
+ P ? (v(P.x, P.y), a.value = { ...P }) : a.value = { ...r.value };
537
+ } else
538
+ g.onClose(), x(), a.value = null;
539
+ });
540
+ const C = (b) => {
541
+ T(b, "pointerdown");
542
+ }, S = (b) => {
543
+ T(b, "pointerenter");
544
+ }, w = (b) => {
545
+ T(b, "pointermove");
459
546
  };
460
- return a && typeof g == "number" && (d = a === "end" ? g * -1 : g), u ? {
461
- x: d * h,
462
- y: p * c
463
- } : {
464
- x: p * c,
465
- y: d * h
547
+ return Kt(() => {
548
+ if (h.value || !c.value) return;
549
+ const b = e.value;
550
+ if (!b) return;
551
+ const P = g.getRequiredEvents(), F = {
552
+ pointerenter: S,
553
+ pointerdown: C,
554
+ pointermove: w
555
+ };
556
+ P.forEach((D) => {
557
+ const M = F[D];
558
+ M && b.addEventListener(D, M);
559
+ }), ue(() => {
560
+ P.forEach((D) => {
561
+ const M = F[D];
562
+ M && b.removeEventListener(D, M);
563
+ });
564
+ });
565
+ }), {
566
+ coordinates: qt(m),
567
+ updatePosition: (b, P) => v(b, P)
466
568
  };
467
569
  }
468
- const Tn = function(e) {
469
- return e === void 0 && (e = 0), {
470
- name: "offset",
471
- options: e,
472
- async fn(t) {
473
- var n, o;
474
- const {
475
- x: i,
476
- y: r,
477
- placement: l,
478
- middlewareData: a
479
- } = t, u = await En(t, e);
480
- return l === ((n = a.offset) == null ? void 0 : n.placement) && (o = a.arrow) != null && o.alignmentOffset ? {} : {
481
- x: i + u.x,
482
- y: r + u.y,
483
- data: {
484
- ...u,
485
- placement: l
486
- }
487
- };
488
- }
489
- };
490
- }, Cn = function(e) {
491
- return e === void 0 && (e = {}), {
492
- name: "shift",
493
- options: e,
494
- async fn(t) {
495
- const {
496
- x: n,
497
- y: o,
498
- placement: i
499
- } = t, {
500
- mainAxis: r = !0,
501
- crossAxis: l = !1,
502
- limiter: a = {
503
- fn: (b) => {
504
- let {
505
- x: w,
506
- y
507
- } = b;
508
- return {
509
- x: w,
510
- y
511
- };
512
- }
513
- },
514
- ...u
515
- } = be(e, t), c = {
516
- x: n,
517
- y: o
518
- }, h = await He(t, u), f = ne(de(i)), p = It(f);
519
- let d = c[p], g = c[f];
570
+ function To(e, t = {}) {
571
+ const { floatingContext: n, treeContext: o } = Fe(e), { enabled: i = !0, capture: l = !1, onEscape: r } = t, { isComposing: a } = pn();
572
+ q(document, "keydown", (c) => {
573
+ if (!(c.key !== "Escape" || !A(i) || a())) {
520
574
  if (r) {
521
- const b = p === "y" ? "top" : "left", w = p === "y" ? "bottom" : "right", y = d + h[b], C = d - h[w];
522
- d = Ke(y, d, C);
523
- }
524
- if (l) {
525
- const b = f === "y" ? "top" : "left", w = f === "y" ? "bottom" : "right", y = g + h[b], C = g - h[w];
526
- g = Ke(y, g, C);
575
+ r(c);
576
+ return;
527
577
  }
528
- const m = a.fn({
529
- ...t,
530
- [p]: d,
531
- [f]: g
532
- });
533
- return {
534
- ...m,
535
- data: {
536
- x: m.x - n,
537
- y: m.y - o,
538
- enabled: {
539
- [p]: r,
540
- [f]: l
541
- }
542
- }
543
- };
578
+ if (o) {
579
+ const u = mn(o);
580
+ u && u.data.setOpen(!1);
581
+ } else
582
+ n.setOpen(!1);
583
+ }
584
+ }, l);
585
+ }
586
+ function mn(e) {
587
+ let t = e;
588
+ for (; t.parent.value && !t.isRoot; )
589
+ t = t.parent.value;
590
+ let n = null, o = -1;
591
+ const i = (l) => {
592
+ if (l.data.open.value) {
593
+ const r = l.getPath().length;
594
+ r > o && (o = r, n = l);
544
595
  }
596
+ for (const r of l.children.value)
597
+ i(r);
545
598
  };
546
- };
547
- function Be() {
548
- return typeof window < "u";
549
- }
550
- function xe(e) {
551
- return Vt(e) ? (e.nodeName || "").toLowerCase() : "#document";
552
- }
553
- function j(e) {
554
- var t;
555
- return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
556
- }
557
- function Q(e) {
558
- var t;
559
- return (t = (Vt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
560
- }
561
- function Vt(e) {
562
- return Be() ? e instanceof Node || e instanceof j(e).Node : !1;
563
- }
564
- function _(e) {
565
- return Be() ? e instanceof Element || e instanceof j(e).Element : !1;
566
- }
567
- function G(e) {
568
- return Be() ? e instanceof HTMLElement || e instanceof j(e).HTMLElement : !1;
599
+ return i(t), n;
569
600
  }
570
- function xt(e) {
571
- return !Be() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof j(e).ShadowRoot;
601
+ function pn() {
602
+ const e = _(!1);
603
+ return q(document, "compositionstart", () => {
604
+ e.value = !0;
605
+ }), q(document, "compositionend", () => {
606
+ e.value = !1;
607
+ }), {
608
+ isComposing: () => e.value
609
+ };
572
610
  }
573
- const Ln = /* @__PURE__ */ new Set(["inline", "contents"]);
574
- function Se(e) {
575
- const {
576
- overflow: t,
577
- overflowX: n,
578
- overflowY: o,
579
- display: i
580
- } = z(e);
581
- return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !Ln.has(i);
582
- }
583
- const Pn = /* @__PURE__ */ new Set(["table", "td", "th"]);
584
- function On(e) {
585
- return Pn.has(xe(e));
586
- }
587
- const Mn = [":popover-open", ":modal"];
588
- function Ie(e) {
589
- return Mn.some((t) => {
590
- try {
591
- return e.matches(t);
592
- } catch {
593
- return !1;
611
+ function Oo(e, t = {}) {
612
+ const { floatingContext: n, treeContext: o } = Fe(e), {
613
+ open: i,
614
+ setOpen: l,
615
+ refs: { floatingEl: r, anchorEl: a }
616
+ } = n, { enabled: f = !0, requireFocusVisible: c = !0 } = t, u = N(() => a.value ? a.value instanceof HTMLElement ? a.value : a.value.contextElement : null);
617
+ let p = !1, h = !0, d;
618
+ q(window, "blur", () => {
619
+ !i.value && u.value && u.value === document.activeElement && (p = !0);
620
+ }), q(window, "focus", () => {
621
+ p = !1;
622
+ }), Gt(() => {
623
+ st() && lt() && (q(
624
+ window,
625
+ "keydown",
626
+ () => {
627
+ h = !0;
628
+ },
629
+ { capture: !0 }
630
+ ), q(
631
+ window,
632
+ "pointerdown",
633
+ () => {
634
+ h = !1;
635
+ },
636
+ { capture: !0 }
637
+ ));
638
+ });
639
+ function m(v) {
640
+ if (p) {
641
+ p = !1;
642
+ return;
643
+ }
644
+ const x = v.target;
645
+ if (A(c) && x) {
646
+ if (st() && lt() && !v.relatedTarget) {
647
+ if (!h && !At(x))
648
+ return;
649
+ } else if (!sn(x))
650
+ return;
594
651
  }
652
+ l(!0);
653
+ }
654
+ function g(v) {
655
+ clearTimeout(d), d = window.setTimeout(() => {
656
+ var C;
657
+ const T = (((C = u.value) == null ? void 0 : C.ownerDocument) ?? document).activeElement;
658
+ if (!(!v.relatedTarget && T === u.value)) {
659
+ if (o) {
660
+ if (T && vn(o, T))
661
+ return;
662
+ } else if (r.value && T && r.value.contains(T))
663
+ return;
664
+ l(!1);
665
+ }
666
+ }, 0);
667
+ }
668
+ Ce(() => {
669
+ if (!A(f)) return;
670
+ const v = u.value;
671
+ !v || !(v instanceof HTMLElement) || (v.addEventListener("focus", m), v.addEventListener("blur", g), ue(() => {
672
+ v.removeEventListener("focus", m), v.removeEventListener("blur", g);
673
+ }));
674
+ }), we(() => {
675
+ clearTimeout(d);
595
676
  });
596
677
  }
597
- const Sn = ["transform", "translate", "scale", "rotate", "perspective"], An = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Nn = ["paint", "layout", "strict", "content"];
598
- function nt(e) {
599
- const t = ot(), n = _(e) ? z(e) : e;
600
- return Sn.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || An.some((o) => (n.willChange || "").includes(o)) || Nn.some((o) => (n.contain || "").includes(o));
678
+ function vn(e, t) {
679
+ return J(t, e.data.refs.anchorEl.value) || J(t, e.data.refs.floatingEl.value) ? !0 : Dt(e, t) !== null;
601
680
  }
602
- function Dn(e) {
603
- let t = oe(e);
604
- for (; G(t) && !ye(t); ) {
605
- if (nt(t))
606
- return t;
607
- if (Ie(t))
608
- return null;
609
- t = oe(t);
610
- }
681
+ function Dt(e, t) {
682
+ for (const n of e.children.value)
683
+ if (n.data.open.value) {
684
+ if (J(t, n.data.refs.anchorEl.value) || J(t, n.data.refs.floatingEl.value))
685
+ return n;
686
+ const o = Dt(n, t);
687
+ if (o) return o;
688
+ }
611
689
  return null;
612
690
  }
613
- function ot() {
614
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
615
- }
616
- const Rn = /* @__PURE__ */ new Set(["html", "body", "#document"]);
617
- function ye(e) {
618
- return Rn.has(xe(e));
619
- }
620
- function z(e) {
621
- return j(e).getComputedStyle(e);
691
+ let gn = 0;
692
+ function wn() {
693
+ return `vfloat-id-${gn++}`;
622
694
  }
623
- function We(e) {
624
- return _(e) ? {
625
- scrollLeft: e.scrollLeft,
626
- scrollTop: e.scrollTop
627
- } : {
628
- scrollLeft: e.scrollX,
629
- scrollTop: e.scrollY
630
- };
695
+ function ht(e) {
696
+ return typeof e == "object" && e instanceof HTMLElement;
631
697
  }
632
- function oe(e) {
633
- if (xe(e) === "html")
634
- return e;
635
- const t = (
636
- // Step into the shadow DOM of the parent of a slotted node.
637
- e.assignedSlot || // DOM Element detected.
638
- e.parentNode || // ShadowRoot detected.
639
- xt(e) && e.host || // Fallback.
640
- Q(e)
698
+ function Nt(e) {
699
+ return e.children.value.some(
700
+ (t) => t.data.open.value || Nt(t)
641
701
  );
642
- return xt(t) ? t.host : t;
643
702
  }
644
- function $t(e) {
645
- const t = oe(e);
646
- return ye(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : G(t) && Se(t) ? t : $t(t);
703
+ function yn(e, t) {
704
+ return e[0] >= t.x && e[0] <= t.x + t.width && e[1] >= t.y && e[1] <= t.y + t.height;
647
705
  }
648
- function Ce(e, t, n) {
649
- var o;
650
- t === void 0 && (t = []), n === void 0 && (n = !0);
651
- const i = $t(e), r = i === ((o = e.ownerDocument) == null ? void 0 : o.body), l = j(i);
652
- if (r) {
653
- const a = Je(l);
654
- return t.concat(l, l.visualViewport || [], Se(i) ? i : [], a && n ? Ce(a) : []);
706
+ function mt(e, t) {
707
+ const [n, o] = e;
708
+ let i = !1;
709
+ const l = t.length;
710
+ for (let r = 0, a = l - 1; r < l; a = r++) {
711
+ const [f, c] = t[r] || [0, 0], [u, p] = t[a] || [0, 0];
712
+ c >= o != p >= o && n <= (u - f) * (o - c) / (p - c) + f && (i = !i);
655
713
  }
656
- return t.concat(i, Ce(i, [], n));
657
- }
658
- function Je(e) {
659
- return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
714
+ return i;
660
715
  }
661
- function Xt(e) {
662
- const t = z(e);
663
- let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
664
- const i = G(e), r = i ? e.offsetWidth : n, l = i ? e.offsetHeight : o, a = Re(n) !== r || Re(o) !== l;
665
- return a && (n = r, o = l), {
666
- width: n,
667
- height: o,
668
- $: a
716
+ function bn(e = {}) {
717
+ const { blockPointerEvents: t = !1, requireIntent: n = !0 } = e;
718
+ let o = -1, i = !1;
719
+ function l(a, f, c, u, p) {
720
+ const h = ft(), d = h - p;
721
+ if (c === null || u === null || d === 0)
722
+ return {
723
+ speed: null,
724
+ lastX: a,
725
+ lastY: f,
726
+ lastCursorTime: h
727
+ };
728
+ const m = a - c, g = f - u;
729
+ return {
730
+ speed: Math.sqrt(m * m + g * g) / d,
731
+ lastX: a,
732
+ lastY: f,
733
+ lastCursorTime: h
734
+ };
735
+ }
736
+ const r = function(f) {
737
+ const { x: c, y: u, placement: p, elements: h, buffer: d, onClose: m, nodeId: g, tree: v } = f, x = N(() => {
738
+ const w = h.domReference;
739
+ return ht(w) ? w : (w == null ? void 0 : w.contextElement) ?? null;
740
+ });
741
+ let T = null, C = null, S = ft();
742
+ return function(b) {
743
+ var Se, et, tt, nt, ot, it, rt;
744
+ function P() {
745
+ dt(o), o = -1, m();
746
+ }
747
+ if (dt(o), o = -1, !h.domReference || !h.floating || p == null || c == null || u == null)
748
+ return;
749
+ const { clientX: F, clientY: D } = b, M = [F, D], B = cn(b), W = b.type === "mouseleave", X = h.floating && Ve(h.floating, B), R = x.value && Ve(x.value, B), E = (Se = x.value) == null ? void 0 : Se.getBoundingClientRect(), s = (et = h.floating) == null ? void 0 : et.getBoundingClientRect(), k = p.split("-")[0], y = c > ((s == null ? void 0 : s.right) ?? 0) - ((s == null ? void 0 : s.width) ?? 0) / 2, H = u > ((s == null ? void 0 : s.bottom) ?? 0) - ((s == null ? void 0 : s.height) ?? 0) / 2, ee = E ? yn(M, E) : !1, $ = ((s == null ? void 0 : s.width) ?? 0) > ((E == null ? void 0 : E.width) ?? 0), O = ((s == null ? void 0 : s.height) ?? 0) > ((E == null ? void 0 : E.height) ?? 0), V = ((tt = $ ? E : s) == null ? void 0 : tt.left) ?? 0, re = ((nt = $ ? E : s) == null ? void 0 : nt.right) ?? 0, z = ((ot = O ? E : s) == null ? void 0 : ot.top) ?? 0, se = ((it = O ? E : s) == null ? void 0 : it.bottom) ?? 0;
750
+ if (X && (i = !0, !W))
751
+ return;
752
+ if (R && (i = !1), R && !W) {
753
+ i = !0;
754
+ return;
755
+ }
756
+ if (W && ht(b.relatedTarget) && h.floating && Ve(h.floating, b.relatedTarget))
757
+ return;
758
+ if (v && g) {
759
+ const I = v.nodes.get(g);
760
+ if (I && Nt(I))
761
+ return;
762
+ }
763
+ if (k === "top" && u >= ((E == null ? void 0 : E.bottom) ?? 0) - 1 || k === "bottom" && u <= ((E == null ? void 0 : E.top) ?? 0) + 1 || k === "left" && c >= ((E == null ? void 0 : E.right) ?? 0) - 1 || k === "right" && c <= ((E == null ? void 0 : E.left) ?? 0) + 1)
764
+ return P();
765
+ let te = [];
766
+ switch (k) {
767
+ case "top":
768
+ te = [
769
+ [V, ((E == null ? void 0 : E.top) ?? 0) + 1],
770
+ [V, ((s == null ? void 0 : s.bottom) ?? 0) - 1],
771
+ [re, ((s == null ? void 0 : s.bottom) ?? 0) - 1],
772
+ [re, ((E == null ? void 0 : E.top) ?? 0) + 1]
773
+ ];
774
+ break;
775
+ case "bottom":
776
+ te = [
777
+ [V, ((s == null ? void 0 : s.top) ?? 0) + 1],
778
+ [V, ((E == null ? void 0 : E.bottom) ?? 0) - 1],
779
+ [re, ((E == null ? void 0 : E.bottom) ?? 0) - 1],
780
+ [re, ((s == null ? void 0 : s.top) ?? 0) + 1]
781
+ ];
782
+ break;
783
+ case "left":
784
+ te = [
785
+ [((s == null ? void 0 : s.right) ?? 0) - 1, se],
786
+ [((s == null ? void 0 : s.right) ?? 0) - 1, z],
787
+ [((E == null ? void 0 : E.left) ?? 0) + 1, z],
788
+ [((E == null ? void 0 : E.left) ?? 0) + 1, se]
789
+ ];
790
+ break;
791
+ case "right":
792
+ te = [
793
+ [((E == null ? void 0 : E.right) ?? 0) - 1, se],
794
+ [((E == null ? void 0 : E.right) ?? 0) - 1, z],
795
+ [((s == null ? void 0 : s.left) ?? 0) + 1, z],
796
+ [((s == null ? void 0 : s.left) ?? 0) + 1, se]
797
+ ];
798
+ break;
799
+ }
800
+ function Le([I, j]) {
801
+ const L = d;
802
+ switch (k) {
803
+ case "top": {
804
+ const le = [
805
+ $ ? I + L / 2 : y ? I + L * 4 : I - L * 4,
806
+ j + L + 1
807
+ ], ae = [
808
+ $ ? I - L / 2 : y ? I + L * 4 : I - L * 4,
809
+ j + L + 1
810
+ ], pe = [
811
+ [
812
+ (s == null ? void 0 : s.left) ?? 0,
813
+ y || $ ? ((s == null ? void 0 : s.bottom) ?? 0) - L : (s == null ? void 0 : s.top) ?? 0
814
+ ],
815
+ [
816
+ (s == null ? void 0 : s.right) ?? 0,
817
+ y ? $ ? ((s == null ? void 0 : s.bottom) ?? 0) - L : (s == null ? void 0 : s.top) ?? 0 : ((s == null ? void 0 : s.bottom) ?? 0) - L
818
+ ]
819
+ ];
820
+ return [le, ae, ...pe];
821
+ }
822
+ case "bottom": {
823
+ const le = [
824
+ $ ? I + L / 2 : y ? I + L * 4 : I - L * 4,
825
+ j - L
826
+ ], ae = [
827
+ $ ? I - L / 2 : y ? I + L * 4 : I - L * 4,
828
+ j - L
829
+ ], pe = [
830
+ [
831
+ (s == null ? void 0 : s.left) ?? 0,
832
+ y || $ ? ((s == null ? void 0 : s.top) ?? 0) + L : (s == null ? void 0 : s.bottom) ?? 0
833
+ ],
834
+ [
835
+ (s == null ? void 0 : s.right) ?? 0,
836
+ y ? $ ? ((s == null ? void 0 : s.top) ?? 0) + L : (s == null ? void 0 : s.bottom) ?? 0 : ((s == null ? void 0 : s.top) ?? 0) + L
837
+ ]
838
+ ];
839
+ return [le, ae, ...pe];
840
+ }
841
+ case "left": {
842
+ const le = [
843
+ I + L + 1,
844
+ O ? j + L / 2 : H ? j + L * 4 : j - L * 4
845
+ ], ae = [
846
+ I + L + 1,
847
+ O ? j - L / 2 : H ? j + L * 4 : j - L * 4
848
+ ];
849
+ return [...[
850
+ [
851
+ H || O ? ((s == null ? void 0 : s.right) ?? 0) - L : (s == null ? void 0 : s.left) ?? 0,
852
+ (s == null ? void 0 : s.top) ?? 0
853
+ ],
854
+ [
855
+ H ? O ? ((s == null ? void 0 : s.right) ?? 0) - L : (s == null ? void 0 : s.left) ?? 0 : ((s == null ? void 0 : s.right) ?? 0) - L,
856
+ (s == null ? void 0 : s.bottom) ?? 0
857
+ ]
858
+ ], le, ae];
859
+ }
860
+ case "right": {
861
+ const le = [
862
+ I - L,
863
+ O ? j + L / 2 : H ? j + L * 4 : j - L * 4
864
+ ], ae = [
865
+ I - L,
866
+ O ? j - L / 2 : H ? j + L * 4 : j - L * 4
867
+ ], pe = [
868
+ [
869
+ H || O ? ((s == null ? void 0 : s.left) ?? 0) + L : (s == null ? void 0 : s.right) ?? 0,
870
+ (s == null ? void 0 : s.top) ?? 0
871
+ ],
872
+ [
873
+ H ? O ? ((s == null ? void 0 : s.left) ?? 0) + L : (s == null ? void 0 : s.right) ?? 0 : ((s == null ? void 0 : s.left) ?? 0) + L,
874
+ (s == null ? void 0 : s.bottom) ?? 0
875
+ ]
876
+ ];
877
+ return [le, ae, ...pe];
878
+ }
879
+ }
880
+ }
881
+ const me = Le([c, u]);
882
+ if ((rt = e.onPolygonChange) == null || rt.call(e, me), !mt(M, te)) {
883
+ if (mt(M, me)) {
884
+ if (!i && n) {
885
+ const I = l(
886
+ b.clientX,
887
+ b.clientY,
888
+ T,
889
+ C,
890
+ S
891
+ );
892
+ T = I.lastX, C = I.lastY, S = I.lastCursorTime, I.speed !== null && I.speed < 0.1 && (o = window.setTimeout(P, 40));
893
+ }
894
+ return;
895
+ }
896
+ if (i && !ee)
897
+ return P();
898
+ P();
899
+ }
900
+ };
669
901
  };
670
- }
671
- function it(e) {
672
- return _(e) ? e : e.contextElement;
673
- }
674
- function ve(e) {
675
- const t = it(e);
676
- if (!G(t))
677
- return K(1);
678
- const n = t.getBoundingClientRect(), {
679
- width: o,
680
- height: i,
681
- $: r
682
- } = Xt(t);
683
- let l = (r ? Re(n.width) : n.width) / o, a = (r ? Re(n.height) : n.height) / i;
684
- return (!l || !Number.isFinite(l)) && (l = 1), (!a || !Number.isFinite(a)) && (a = 1), {
685
- x: l,
686
- y: a
902
+ return r.__options = {
903
+ blockPointerEvents: t
904
+ }, r;
905
+ }
906
+ const pt = 10;
907
+ function xn(e, t, n) {
908
+ const { delay: o } = n, i = N(() => {
909
+ const c = A(o);
910
+ return (typeof c == "number" ? c : c.open) ?? 0;
911
+ }), l = N(() => {
912
+ const c = A(o);
913
+ return (typeof c == "number" ? c : c.close) ?? 0;
914
+ });
915
+ let r, a;
916
+ const f = () => {
917
+ clearTimeout(r), clearTimeout(a);
687
918
  };
688
- }
689
- const kn = /* @__PURE__ */ K(0);
690
- function Yt(e) {
691
- const t = j(e);
692
- return !ot() || !t.visualViewport ? kn : {
693
- x: t.visualViewport.offsetLeft,
694
- y: t.visualViewport.offsetTop
919
+ return we(f), {
920
+ show: (c) => {
921
+ f();
922
+ const u = c ?? i.value;
923
+ u === 0 ? e() : r = setTimeout(e, u);
924
+ },
925
+ hide: (c) => {
926
+ f();
927
+ const u = c ?? l.value;
928
+ u === 0 ? t() : a = setTimeout(t, u);
929
+ },
930
+ showDelay: i,
931
+ hideDelay: l,
932
+ clearTimeouts: f
695
933
  };
696
934
  }
697
- function Fn(e, t, n) {
698
- return t === void 0 && (t = !1), !n || t && n !== j(e) ? !1 : t;
699
- }
700
- function he(e, t, n, o) {
701
- t === void 0 && (t = !1), n === void 0 && (n = !1);
702
- const i = e.getBoundingClientRect(), r = it(e);
703
- let l = K(1);
704
- t && (o ? _(o) && (l = ve(o)) : l = ve(e));
705
- const a = Fn(r, n, o) ? Yt(r) : K(0);
706
- let u = (i.left + a.x) / l.x, c = (i.top + a.y) / l.y, h = i.width / l.x, f = i.height / l.y;
707
- if (r) {
708
- const p = j(r), d = o && _(o) ? j(o) : o;
709
- let g = p, m = Je(g);
710
- for (; m && o && d !== g; ) {
711
- const b = ve(m), w = m.getBoundingClientRect(), y = z(m), C = w.left + (m.clientLeft + parseFloat(y.paddingLeft)) * b.x, P = w.top + (m.clientTop + parseFloat(y.paddingTop)) * b.y;
712
- u *= b.x, c *= b.y, h *= b.x, f *= b.y, u += C, c += P, g = j(m), m = Je(g);
935
+ function Po(e, t = {}) {
936
+ const { floatingContext: n, treeContext: o } = Fe(e), {
937
+ open: i,
938
+ setOpen: l,
939
+ refs: { anchorEl: r, floatingEl: a }
940
+ } = n, {
941
+ enabled: f = !0,
942
+ delay: c = 0,
943
+ restMs: u = 0,
944
+ mouseOnly: p = !1,
945
+ safePolygon: h = !1
946
+ } = t, d = N(() => A(f)), m = N(() => A(u)), g = N(() => {
947
+ const y = r.value;
948
+ return !y || y instanceof HTMLElement ? y : y.contextElement ?? null;
949
+ }), { hide: v, show: x, showDelay: T, clearTimeouts: C } = xn(
950
+ () => {
951
+ i.value || l(!0);
952
+ },
953
+ () => {
954
+ i.value && l(!1);
955
+ },
956
+ { delay: c }
957
+ );
958
+ let S = null, w;
959
+ const b = N(() => T.value === 0 && m.value > 0);
960
+ function P(y) {
961
+ if (!d.value || !M(y) || !b.value || !S) return;
962
+ const H = { x: y.clientX, y: y.clientY }, ee = Math.abs(H.x - S.x), $ = Math.abs(H.y - S.y);
963
+ (ee > pt || $ > pt) && (S = H, clearTimeout(w), w = setTimeout(() => {
964
+ x(0);
965
+ }, m.value));
966
+ }
967
+ function F(y) {
968
+ !d.value || !M(y) || !b.value || (S = { x: y.clientX, y: y.clientY }, w = setTimeout(() => {
969
+ x(0);
970
+ }, m.value));
971
+ }
972
+ function D() {
973
+ clearTimeout(w), S = null;
974
+ }
975
+ Ce(() => {
976
+ const y = g.value;
977
+ !y || !d.value || !b.value || (y.addEventListener("pointerenter", F), y.addEventListener("pointermove", P), y.addEventListener("pointerleave", D), ue(() => {
978
+ y.removeEventListener("pointerenter", F), y.removeEventListener("pointermove", P), y.removeEventListener("pointerleave", D);
979
+ }));
980
+ }), we(() => {
981
+ clearTimeout(w);
982
+ });
983
+ function M(y) {
984
+ return A(p) ? y.pointerType === "mouse" : !0;
985
+ }
986
+ function B(y) {
987
+ !d.value || !M(y) || b.value || (R(), x());
988
+ }
989
+ function W(y) {
990
+ !d.value || !M(y) || (C(), R());
991
+ }
992
+ let X = null;
993
+ function R() {
994
+ X && (document.removeEventListener("pointermove", X), X = null);
995
+ const y = s.value;
996
+ y != null && y.onPolygonChange && y.onPolygonChange([]);
997
+ }
998
+ const E = N(() => !!A(h)), s = N(() => {
999
+ const y = A(h);
1000
+ if (typeof y == "object" && y) return y;
1001
+ if (y === !0) return {};
1002
+ });
1003
+ function k(y) {
1004
+ var O;
1005
+ if (!d.value || !M(y)) return;
1006
+ const { clientX: H, clientY: ee } = y, $ = y.relatedTarget;
1007
+ if (E.value)
1008
+ setTimeout(() => {
1009
+ var te;
1010
+ R();
1011
+ const V = g.value, re = a.value;
1012
+ if (!V || !re) {
1013
+ v();
1014
+ return;
1015
+ }
1016
+ let z, se;
1017
+ if (o) {
1018
+ z = /* @__PURE__ */ new Map();
1019
+ const Le = (me) => {
1020
+ z == null || z.set(me.id, me);
1021
+ for (const Se of me.children.value)
1022
+ Le(Se);
1023
+ };
1024
+ Le(o), se = o.id;
1025
+ }
1026
+ X = bn(s.value)({
1027
+ x: H,
1028
+ y: ee,
1029
+ placement: n.placement.value,
1030
+ elements: {
1031
+ domReference: V,
1032
+ floating: re
1033
+ },
1034
+ buffer: ((te = s.value) == null ? void 0 : te.buffer) ?? 1,
1035
+ onClose: () => {
1036
+ R(), v();
1037
+ },
1038
+ nodeId: se,
1039
+ tree: z ? { nodes: z } : void 0
1040
+ }), X && document.addEventListener("pointermove", X);
1041
+ }, 0);
1042
+ else {
1043
+ if (o) {
1044
+ if (!En(o, $))
1045
+ return;
1046
+ } else if ((O = a.value) != null && O.contains($))
1047
+ return;
1048
+ v();
713
1049
  }
714
1050
  }
715
- return Fe({
716
- width: h,
717
- height: f,
718
- x: u,
719
- y: c
1051
+ Ce(() => {
1052
+ const y = g.value;
1053
+ !y || !d.value || (y.addEventListener("pointerenter", B), y.addEventListener("pointerleave", k), ue(() => {
1054
+ y.removeEventListener("pointerenter", B), y.removeEventListener("pointerleave", k);
1055
+ }));
1056
+ }), Ce(() => {
1057
+ const y = a.value;
1058
+ !y || !d.value || (y.addEventListener("pointerenter", W), y.addEventListener("pointerleave", k), ue(() => {
1059
+ y.removeEventListener("pointerenter", W), y.removeEventListener("pointerleave", k);
1060
+ }));
1061
+ }), we(() => {
1062
+ R();
720
1063
  });
721
1064
  }
722
- function Ve(e, t) {
723
- const n = We(e).scrollLeft;
724
- return t ? t.left + n : he(Q(e)).left + n;
1065
+ function En(e, t) {
1066
+ return t ? !(J(t, e.data.refs.anchorEl.value) || J(t, e.data.refs.floatingEl.value) || Ke(e, t)) : !0;
725
1067
  }
726
- function jt(e, t) {
727
- const n = e.getBoundingClientRect(), o = n.left + t.scrollLeft - Ve(e, n), i = n.top + t.scrollTop;
728
- return {
729
- x: o,
730
- y: i
731
- };
1068
+ const Cn = ["top", "right", "bottom", "left"], ye = Math.min, fe = Math.max, De = Math.round, Me = Math.floor, G = (e) => ({
1069
+ x: e,
1070
+ y: e
1071
+ }), Tn = {
1072
+ left: "right",
1073
+ right: "left",
1074
+ bottom: "top",
1075
+ top: "bottom"
1076
+ }, On = {
1077
+ start: "end",
1078
+ end: "start"
1079
+ };
1080
+ function ze(e, t, n) {
1081
+ return fe(e, ye(t, n));
732
1082
  }
733
- function Hn(e) {
734
- let {
735
- elements: t,
736
- rect: n,
737
- offsetParent: o,
738
- strategy: i
739
- } = e;
740
- const r = i === "fixed", l = Q(o), a = t ? Ie(t.floating) : !1;
741
- if (o === l || a && r)
742
- return n;
743
- let u = {
744
- scrollLeft: 0,
745
- scrollTop: 0
746
- }, c = K(1);
747
- const h = K(0), f = G(o);
748
- if ((f || !f && !r) && ((xe(o) !== "body" || Se(l)) && (u = We(o)), G(o))) {
749
- const d = he(o);
750
- c = ve(o), h.x = d.x + o.clientLeft, h.y = d.y + o.clientTop;
751
- }
752
- const p = l && !f && !r ? jt(l, u) : K(0);
753
- return {
754
- width: n.width * c.x,
755
- height: n.height * c.y,
756
- x: n.x * c.x - u.scrollLeft * c.x + h.x + p.x,
757
- y: n.y * c.y - u.scrollTop * c.y + h.y + p.y
758
- };
1083
+ function xe(e, t) {
1084
+ return typeof e == "function" ? e(t) : e;
759
1085
  }
760
- function Bn(e) {
761
- return Array.from(e.getClientRects());
1086
+ function de(e) {
1087
+ return e.split("-")[0];
762
1088
  }
763
- function In(e) {
764
- const t = Q(e), n = We(e), o = e.ownerDocument.body, i = fe(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), r = fe(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
765
- let l = -n.scrollLeft + Ve(e);
766
- const a = -n.scrollTop;
767
- return z(o).direction === "rtl" && (l += fe(t.clientWidth, o.clientWidth) - i), {
768
- width: i,
769
- height: r,
770
- x: l,
771
- y: a
772
- };
1089
+ function Oe(e) {
1090
+ return e.split("-")[1];
773
1091
  }
774
- const Et = 25;
775
- function Wn(e, t) {
776
- const n = j(e), o = Q(e), i = n.visualViewport;
777
- let r = o.clientWidth, l = o.clientHeight, a = 0, u = 0;
778
- if (i) {
779
- r = i.width, l = i.height;
780
- const h = ot();
781
- (!h || h && t === "fixed") && (a = i.offsetLeft, u = i.offsetTop);
782
- }
783
- const c = Ve(o);
784
- if (c <= 0) {
785
- const h = o.ownerDocument, f = h.body, p = getComputedStyle(f), d = h.compatMode === "CSS1Compat" && parseFloat(p.marginLeft) + parseFloat(p.marginRight) || 0, g = Math.abs(o.clientWidth - f.clientWidth - d);
786
- g <= Et && (r -= g);
787
- } else c <= Et && (r += c);
788
- return {
789
- width: r,
790
- height: l,
791
- x: a,
792
- y: u
793
- };
1092
+ function Rt(e) {
1093
+ return e === "x" ? "y" : "x";
794
1094
  }
795
- const Vn = /* @__PURE__ */ new Set(["absolute", "fixed"]);
796
- function $n(e, t) {
797
- const n = he(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, r = G(e) ? ve(e) : K(1), l = e.clientWidth * r.x, a = e.clientHeight * r.y, u = i * r.x, c = o * r.y;
798
- return {
799
- width: l,
800
- height: a,
801
- x: u,
802
- y: c
803
- };
1095
+ function qe(e) {
1096
+ return e === "y" ? "height" : "width";
804
1097
  }
805
- function Tt(e, t, n) {
806
- let o;
807
- if (t === "viewport")
808
- o = Wn(e, n);
809
- else if (t === "document")
810
- o = In(Q(e));
811
- else if (_(t))
812
- o = $n(t, n);
813
- else {
814
- const i = Yt(e);
815
- o = {
816
- x: t.x - i.x,
817
- y: t.y - i.y,
818
- width: t.width,
819
- height: t.height
820
- };
821
- }
822
- return Fe(o);
1098
+ const Pn = /* @__PURE__ */ new Set(["top", "bottom"]);
1099
+ function oe(e) {
1100
+ return Pn.has(de(e)) ? "y" : "x";
823
1101
  }
824
- function _t(e, t) {
825
- const n = oe(e);
826
- return n === t || !_(n) || ye(n) ? !1 : z(n).position === "fixed" || _t(n, t);
1102
+ function Ge(e) {
1103
+ return Rt(oe(e));
827
1104
  }
828
- function Xn(e, t) {
829
- const n = t.get(e);
830
- if (n)
831
- return n;
832
- let o = Ce(e, [], !1).filter((a) => _(a) && xe(a) !== "body"), i = null;
833
- const r = z(e).position === "fixed";
834
- let l = r ? oe(e) : e;
835
- for (; _(l) && !ye(l); ) {
836
- const a = z(l), u = nt(l);
837
- !u && a.position === "fixed" && (i = null), (r ? !u && !i : !u && a.position === "static" && !!i && Vn.has(i.position) || Se(l) && !u && _t(e, l)) ? o = o.filter((h) => h !== l) : i = a, l = oe(l);
838
- }
839
- return t.set(e, o), o;
1105
+ function Ln(e, t, n) {
1106
+ n === void 0 && (n = !1);
1107
+ const o = Oe(e), i = Ge(e), l = qe(i);
1108
+ let r = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
1109
+ return t.reference[l] > t.floating[l] && (r = Ne(r)), [r, Ne(r)];
840
1110
  }
841
- function Yn(e) {
842
- let {
843
- element: t,
844
- boundary: n,
845
- rootBoundary: o,
846
- strategy: i
847
- } = e;
848
- const l = [...n === "clippingAncestors" ? Ie(t) ? [] : Xn(t, this._c) : [].concat(n), o], a = l[0], u = l.reduce((c, h) => {
849
- const f = Tt(t, h, i);
850
- return c.top = fe(f.top, c.top), c.right = we(f.right, c.right), c.bottom = we(f.bottom, c.bottom), c.left = fe(f.left, c.left), c;
851
- }, Tt(t, a, i));
852
- return {
853
- width: u.right - u.left,
854
- height: u.bottom - u.top,
855
- x: u.left,
856
- y: u.top
857
- };
1111
+ function Sn(e) {
1112
+ const t = Ne(e);
1113
+ return [_e(e), t, _e(t)];
858
1114
  }
859
- function jn(e) {
860
- const {
861
- width: t,
862
- height: n
863
- } = Xt(e);
864
- return {
865
- width: t,
866
- height: n
867
- };
1115
+ function _e(e) {
1116
+ return e.replace(/start|end/g, (t) => On[t]);
868
1117
  }
869
- function _n(e, t, n) {
870
- const o = G(t), i = Q(t), r = n === "fixed", l = he(e, !0, r, t);
871
- let a = {
872
- scrollLeft: 0,
873
- scrollTop: 0
874
- };
875
- const u = K(0);
876
- function c() {
877
- u.x = Ve(i);
1118
+ const vt = ["left", "right"], gt = ["right", "left"], An = ["top", "bottom"], Mn = ["bottom", "top"];
1119
+ function Dn(e, t, n) {
1120
+ switch (e) {
1121
+ case "top":
1122
+ case "bottom":
1123
+ return n ? t ? gt : vt : t ? vt : gt;
1124
+ case "left":
1125
+ case "right":
1126
+ return t ? An : Mn;
1127
+ default:
1128
+ return [];
878
1129
  }
879
- if (o || !o && !r)
880
- if ((xe(t) !== "body" || Se(i)) && (a = We(t)), o) {
881
- const d = he(t, !0, r, t);
882
- u.x = d.x + t.clientLeft, u.y = d.y + t.clientTop;
883
- } else i && c();
884
- r && !o && i && c();
885
- const h = i && !o && !r ? jt(i, a) : K(0), f = l.left + a.scrollLeft - u.x - h.x, p = l.top + a.scrollTop - u.y - h.y;
886
- return {
887
- x: f,
888
- y: p,
889
- width: l.width,
890
- height: l.height
891
- };
892
1130
  }
893
- function _e(e) {
894
- return z(e).position === "static";
1131
+ function Nn(e, t, n, o) {
1132
+ const i = Oe(e);
1133
+ let l = Dn(de(e), n === "start", o);
1134
+ return i && (l = l.map((r) => r + "-" + i), t && (l = l.concat(l.map(_e)))), l;
895
1135
  }
896
- function Ct(e, t) {
897
- if (!G(e) || z(e).position === "fixed")
898
- return null;
899
- if (t)
900
- return t(e);
901
- let n = e.offsetParent;
902
- return Q(e) === n && (n = n.ownerDocument.body), n;
1136
+ function Ne(e) {
1137
+ return e.replace(/left|right|bottom|top/g, (t) => Tn[t]);
903
1138
  }
904
- function zt(e, t) {
905
- const n = j(e);
906
- if (Ie(e))
907
- return n;
908
- if (!G(e)) {
909
- let i = oe(e);
910
- for (; i && !ye(i); ) {
911
- if (_(i) && !_e(i))
912
- return i;
913
- i = oe(i);
914
- }
915
- return n;
916
- }
917
- let o = Ct(e, t);
918
- for (; o && On(o) && _e(o); )
919
- o = Ct(o, t);
920
- return o && ye(o) && _e(o) && !nt(o) ? n : o || Dn(e) || n;
1139
+ function Rn(e) {
1140
+ return {
1141
+ top: 0,
1142
+ right: 0,
1143
+ bottom: 0,
1144
+ left: 0,
1145
+ ...e
1146
+ };
1147
+ }
1148
+ function kt(e) {
1149
+ return typeof e != "number" ? Rn(e) : {
1150
+ top: e,
1151
+ right: e,
1152
+ bottom: e,
1153
+ left: e
1154
+ };
921
1155
  }
922
- const zn = async function(e) {
923
- const t = this.getOffsetParent || zt, n = this.getDimensions, o = await n(e.floating);
1156
+ function Re(e) {
1157
+ const {
1158
+ x: t,
1159
+ y: n,
1160
+ width: o,
1161
+ height: i
1162
+ } = e;
924
1163
  return {
925
- reference: _n(e.reference, await t(e.floating), e.strategy),
926
- floating: {
927
- x: 0,
928
- y: 0,
929
- width: o.width,
930
- height: o.height
931
- }
1164
+ width: o,
1165
+ height: i,
1166
+ top: n,
1167
+ left: t,
1168
+ right: t + o,
1169
+ bottom: n + i,
1170
+ x: t,
1171
+ y: n
932
1172
  };
933
- };
934
- function Un(e) {
935
- return z(e).direction === "rtl";
936
- }
937
- const qn = {
938
- convertOffsetParentRelativeRectToViewportRelativeRect: Hn,
939
- getDocumentElement: Q,
940
- getClippingRect: Yn,
941
- getOffsetParent: zt,
942
- getElementRects: zn,
943
- getClientRects: Bn,
944
- getDimensions: jn,
945
- getScale: ve,
946
- isElement: _,
947
- isRTL: Un
948
- };
949
- function Ut(e, t) {
950
- return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
951
1173
  }
952
- function Kn(e, t) {
953
- let n = null, o;
954
- const i = Q(e);
955
- function r() {
956
- var a;
957
- clearTimeout(o), (a = n) == null || a.disconnect(), n = null;
1174
+ function wt(e, t, n) {
1175
+ let {
1176
+ reference: o,
1177
+ floating: i
1178
+ } = e;
1179
+ const l = oe(t), r = Ge(t), a = qe(r), f = de(t), c = l === "y", u = o.x + o.width / 2 - i.width / 2, p = o.y + o.height / 2 - i.height / 2, h = o[a] / 2 - i[a] / 2;
1180
+ let d;
1181
+ switch (f) {
1182
+ case "top":
1183
+ d = {
1184
+ x: u,
1185
+ y: o.y - i.height
1186
+ };
1187
+ break;
1188
+ case "bottom":
1189
+ d = {
1190
+ x: u,
1191
+ y: o.y + o.height
1192
+ };
1193
+ break;
1194
+ case "right":
1195
+ d = {
1196
+ x: o.x + o.width,
1197
+ y: p
1198
+ };
1199
+ break;
1200
+ case "left":
1201
+ d = {
1202
+ x: o.x - i.width,
1203
+ y: p
1204
+ };
1205
+ break;
1206
+ default:
1207
+ d = {
1208
+ x: o.x,
1209
+ y: o.y
1210
+ };
958
1211
  }
959
- function l(a, u) {
960
- a === void 0 && (a = !1), u === void 0 && (u = 1), r();
961
- const c = e.getBoundingClientRect(), {
962
- left: h,
963
- top: f,
964
- width: p,
965
- height: d
966
- } = c;
967
- if (a || t(), !p || !d)
968
- return;
969
- const g = De(f), m = De(i.clientWidth - (h + p)), b = De(i.clientHeight - (f + d)), w = De(h), C = {
970
- rootMargin: -g + "px " + -m + "px " + -b + "px " + -w + "px",
971
- threshold: fe(0, we(1, u)) || 1
972
- };
973
- let P = !0;
974
- function E(T) {
975
- const A = T[0].intersectionRatio;
976
- if (A !== u) {
977
- if (!P)
978
- return l();
979
- A ? l(!1, A) : o = setTimeout(() => {
980
- l(!1, 1e-7);
981
- }, 1e3);
982
- }
983
- A === 1 && !Ut(c, e.getBoundingClientRect()) && l(), P = !1;
984
- }
985
- try {
986
- n = new IntersectionObserver(E, {
987
- ...C,
988
- // Handle <iframe>s
989
- root: i.ownerDocument
990
- });
991
- } catch {
992
- n = new IntersectionObserver(E, C);
993
- }
994
- n.observe(e);
1212
+ switch (Oe(t)) {
1213
+ case "start":
1214
+ d[r] -= h * (n && c ? -1 : 1);
1215
+ break;
1216
+ case "end":
1217
+ d[r] += h * (n && c ? -1 : 1);
1218
+ break;
995
1219
  }
996
- return l(!0), r;
1220
+ return d;
997
1221
  }
998
- function Gn(e, t, n, o) {
999
- o === void 0 && (o = {});
1222
+ const kn = async (e, t, n) => {
1000
1223
  const {
1001
- ancestorScroll: i = !0,
1002
- ancestorResize: r = !0,
1003
- elementResize: l = typeof ResizeObserver == "function",
1004
- layoutShift: a = typeof IntersectionObserver == "function",
1005
- animationFrame: u = !1
1006
- } = o, c = it(e), h = i || r ? [...c ? Ce(c) : [], ...Ce(t)] : [];
1007
- h.forEach((w) => {
1008
- i && w.addEventListener("scroll", n, {
1009
- passive: !0
1010
- }), r && w.addEventListener("resize", n);
1011
- });
1012
- const f = c && a ? Kn(c, n) : null;
1013
- let p = -1, d = null;
1014
- l && (d = new ResizeObserver((w) => {
1015
- let [y] = w;
1016
- y && y.target === c && d && (d.unobserve(t), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
1017
- var C;
1018
- (C = d) == null || C.observe(t);
1019
- })), n();
1020
- }), c && !u && d.observe(c), d.observe(t));
1021
- let g, m = u ? he(e) : null;
1022
- u && b();
1023
- function b() {
1024
- const w = he(e);
1025
- m && !Ut(m, w) && n(), m = w, g = requestAnimationFrame(b);
1026
- }
1027
- return n(), () => {
1028
- var w;
1029
- h.forEach((y) => {
1030
- i && y.removeEventListener("scroll", n), r && y.removeEventListener("resize", n);
1031
- }), f == null || f(), (w = d) == null || w.disconnect(), d = null, u && cancelAnimationFrame(g);
1032
- };
1033
- }
1034
- const Oo = Tn, Mo = Cn, So = yn, Ao = bn, Jn = wn, Qn = (e, t, n) => {
1035
- const o = /* @__PURE__ */ new Map(), i = {
1036
- platform: qn,
1037
- ...n
1038
- }, r = {
1039
- ...i.platform,
1040
- _c: o
1041
- };
1042
- return gn(e, t, {
1043
- ...i,
1224
+ placement: o = "bottom",
1225
+ strategy: i = "absolute",
1226
+ middleware: l = [],
1044
1227
  platform: r
1045
- });
1046
- };
1047
- function Zn(e) {
1228
+ } = n, a = l.filter(Boolean), f = await (r.isRTL == null ? void 0 : r.isRTL(t));
1229
+ let c = await r.getElementRects({
1230
+ reference: e,
1231
+ floating: t,
1232
+ strategy: i
1233
+ }), {
1234
+ x: u,
1235
+ y: p
1236
+ } = wt(c, o, f), h = o, d = {}, m = 0;
1237
+ for (let g = 0; g < a.length; g++) {
1238
+ const {
1239
+ name: v,
1240
+ fn: x
1241
+ } = a[g], {
1242
+ x: T,
1243
+ y: C,
1244
+ data: S,
1245
+ reset: w
1246
+ } = await x({
1247
+ x: u,
1248
+ y: p,
1249
+ initialPlacement: o,
1250
+ placement: h,
1251
+ strategy: i,
1252
+ middlewareData: d,
1253
+ rects: c,
1254
+ platform: r,
1255
+ elements: {
1256
+ reference: e,
1257
+ floating: t
1258
+ }
1259
+ });
1260
+ u = T ?? u, p = C ?? p, d = {
1261
+ ...d,
1262
+ [v]: {
1263
+ ...d[v],
1264
+ ...S
1265
+ }
1266
+ }, w && m <= 50 && (m++, typeof w == "object" && (w.placement && (h = w.placement), w.rects && (c = w.rects === !0 ? await r.getElementRects({
1267
+ reference: e,
1268
+ floating: t,
1269
+ strategy: i
1270
+ }) : w.rects), {
1271
+ x: u,
1272
+ y: p
1273
+ } = wt(c, h, f)), g = -1);
1274
+ }
1048
1275
  return {
1049
- name: "arrow",
1050
- options: e,
1051
- fn(t) {
1052
- const n = S(e.element);
1053
- return n == null ? {} : Jn({ element: n, padding: e.padding }).fn(t);
1054
- }
1276
+ x: u,
1277
+ y: p,
1278
+ placement: h,
1279
+ strategy: i,
1280
+ middlewareData: d
1055
1281
  };
1056
- }
1057
- function Lt(e, t, n = {}) {
1282
+ };
1283
+ async function ke(e, t) {
1284
+ var n;
1285
+ t === void 0 && (t = {});
1058
1286
  const {
1059
- transform: o = !0,
1060
- middlewares: i,
1061
- autoUpdate: r = !0,
1062
- open: l = U(!1)
1063
- } = n, a = (E) => {
1064
- l.value = E;
1065
- }, u = I(() => S(n.placement) ?? "bottom"), c = I(() => S(n.strategy) ?? "absolute"), h = U(0), f = U(0), p = U(u.value), d = U(c.value), g = qe({}), m = U(!1), b = U(null), w = I(() => {
1066
- const E = i || [];
1067
- return b.value && !E.some((A) => A.name === "arrow") ? [...E, Zn({ element: b })] : E;
1068
- }), y = async () => {
1069
- if (!e.value || !t.value) return;
1070
- const E = await Qn(e.value, t.value, {
1071
- placement: u.value,
1072
- strategy: c.value,
1073
- middleware: w.value
1074
- });
1075
- h.value = E.x, f.value = E.y, p.value = E.placement, d.value = E.strategy, g.value = E.middlewareData, m.value = l.value;
1076
- };
1077
- pe([u, c], () => {
1078
- l.value && y();
1079
- });
1080
- let C;
1081
- pe(
1082
- [e, t, l],
1083
- ([E, T, A]) => {
1084
- !A || !E || !T || (r && (C = Gn(
1085
- E,
1086
- T,
1087
- y,
1088
- typeof r == "object" ? r : void 0
1089
- )), ue(() => {
1090
- C == null || C(), C = void 0;
1091
- }));
1092
- },
1093
- { immediate: !0 }
1094
- ), ge(() => C == null ? void 0 : C()), pe(l, (E) => {
1095
- E || (m.value = !1);
1096
- });
1097
- const P = U({
1098
- position: c.value,
1099
- left: "0",
1100
- top: "0"
1101
- });
1102
- return pe(
1103
- [h, f, () => S(o)],
1104
- ([E, T, A]) => {
1105
- const D = t.value;
1106
- if (!D) return;
1107
- const R = {
1108
- position: d.value,
1109
- left: "0",
1110
- top: "0"
1111
- }, N = Pt(D, E), M = Pt(D, T);
1112
- A ? P.value = {
1113
- ...R,
1114
- transform: `translate(${N}px, ${M}px)`,
1115
- ...qt(D) >= 1.5 && {
1116
- "will-change": "transform"
1117
- }
1118
- } : P.value = {
1119
- ...R,
1120
- left: `${N}px`,
1121
- top: `${M}px`
1122
- };
1123
- },
1124
- { immediate: !0 }
1125
- ), {
1126
- x: h,
1127
- y: f,
1128
- strategy: d,
1129
- placement: p,
1130
- middlewareData: g,
1131
- isPositioned: m,
1132
- floatingStyles: P,
1133
- update: y,
1134
- refs: {
1135
- anchorEl: e,
1136
- floatingEl: t,
1137
- arrowEl: b
1138
- },
1139
- open: l,
1140
- setOpen: a
1287
+ x: o,
1288
+ y: i,
1289
+ platform: l,
1290
+ rects: r,
1291
+ elements: a,
1292
+ strategy: f
1293
+ } = e, {
1294
+ boundary: c = "clippingAncestors",
1295
+ rootBoundary: u = "viewport",
1296
+ elementContext: p = "floating",
1297
+ altBoundary: h = !1,
1298
+ padding: d = 0
1299
+ } = xe(t, e), m = kt(d), v = a[h ? p === "floating" ? "reference" : "floating" : p], x = Re(await l.getClippingRect({
1300
+ element: (n = await (l.isElement == null ? void 0 : l.isElement(v))) == null || n ? v : v.contextElement || await (l.getDocumentElement == null ? void 0 : l.getDocumentElement(a.floating)),
1301
+ boundary: c,
1302
+ rootBoundary: u,
1303
+ strategy: f
1304
+ })), T = p === "floating" ? {
1305
+ x: o,
1306
+ y: i,
1307
+ width: r.floating.width,
1308
+ height: r.floating.height
1309
+ } : r.reference, C = await (l.getOffsetParent == null ? void 0 : l.getOffsetParent(a.floating)), S = await (l.isElement == null ? void 0 : l.isElement(C)) ? await (l.getScale == null ? void 0 : l.getScale(C)) || {
1310
+ x: 1,
1311
+ y: 1
1312
+ } : {
1313
+ x: 1,
1314
+ y: 1
1315
+ }, w = Re(l.convertOffsetParentRelativeRectToViewportRelativeRect ? await l.convertOffsetParentRelativeRectToViewportRelativeRect({
1316
+ elements: a,
1317
+ rect: T,
1318
+ offsetParent: C,
1319
+ strategy: f
1320
+ }) : T);
1321
+ return {
1322
+ top: (x.top - w.top + m.top) / S.y,
1323
+ bottom: (w.bottom - x.bottom + m.bottom) / S.y,
1324
+ left: (x.left - w.left + m.left) / S.x,
1325
+ right: (w.right - x.right + m.right) / S.x
1141
1326
  };
1142
1327
  }
1143
- function Pt(e, t) {
1144
- const n = qt(e);
1145
- return Math.round(t * n) / n;
1146
- }
1147
- function qt(e) {
1148
- return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
1149
- }
1150
- function No(e, t, n = {}) {
1151
- const { offset: o = "-4px", padding: i } = n, { middlewareData: r, placement: l, refs: a } = t;
1152
- pe(e, (f) => {
1153
- a.arrowEl.value = f;
1154
- });
1155
- const u = I(() => {
1156
- var f;
1157
- return ((f = r.value.arrow) == null ? void 0 : f.x) ?? 0;
1158
- }), c = I(() => {
1159
- var f;
1160
- return ((f = r.value.arrow) == null ? void 0 : f.y) ?? 0;
1161
- }), h = I(() => {
1162
- if (!(e.value || a.arrowEl.value) || !r.value.arrow)
1328
+ const Fn = (e) => ({
1329
+ name: "arrow",
1330
+ options: e,
1331
+ async fn(t) {
1332
+ const {
1333
+ x: n,
1334
+ y: o,
1335
+ placement: i,
1336
+ rects: l,
1337
+ platform: r,
1338
+ elements: a,
1339
+ middlewareData: f
1340
+ } = t, {
1341
+ element: c,
1342
+ padding: u = 0
1343
+ } = xe(e, t) || {};
1344
+ if (c == null)
1163
1345
  return {};
1164
- const p = S(l).split("-")[0], d = u.value, g = c.value;
1165
- return p === "bottom" ? {
1166
- "inset-inline-start": `${d}px`,
1167
- "inset-block-start": o
1168
- } : p === "top" ? {
1169
- "inset-inline-start": `${d}px`,
1170
- "inset-block-end": o
1171
- } : p === "right" ? {
1172
- "inset-block-start": `${g}px`,
1173
- "inset-inline-start": o
1174
- } : p === "left" ? {
1175
- "inset-block-start": `${g}px`,
1176
- "inset-inline-end": o
1177
- } : {};
1178
- });
1346
+ const p = kt(u), h = {
1347
+ x: n,
1348
+ y: o
1349
+ }, d = Ge(i), m = qe(d), g = await r.getDimensions(c), v = d === "y", x = v ? "top" : "left", T = v ? "bottom" : "right", C = v ? "clientHeight" : "clientWidth", S = l.reference[m] + l.reference[d] - h[d] - l.floating[m], w = h[d] - l.reference[d], b = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c));
1350
+ let P = b ? b[C] : 0;
1351
+ (!P || !await (r.isElement == null ? void 0 : r.isElement(b))) && (P = a.floating[C] || l.floating[m]);
1352
+ const F = S / 2 - w / 2, D = P / 2 - g[m] / 2 - 1, M = ye(p[x], D), B = ye(p[T], D), W = M, X = P - g[m] - B, R = P / 2 - g[m] / 2 + F, E = ze(W, R, X), s = !f.arrow && Oe(i) != null && R !== E && l.reference[m] / 2 - (R < W ? M : B) - g[m] / 2 < 0, k = s ? R < W ? R - W : R - X : 0;
1353
+ return {
1354
+ [d]: h[d] + k,
1355
+ data: {
1356
+ [d]: E,
1357
+ centerOffset: R - E - k,
1358
+ ...s && {
1359
+ alignmentOffset: k
1360
+ }
1361
+ },
1362
+ reset: s
1363
+ };
1364
+ }
1365
+ }), Hn = function(e) {
1366
+ return e === void 0 && (e = {}), {
1367
+ name: "flip",
1368
+ options: e,
1369
+ async fn(t) {
1370
+ var n, o;
1371
+ const {
1372
+ placement: i,
1373
+ middlewareData: l,
1374
+ rects: r,
1375
+ initialPlacement: a,
1376
+ platform: f,
1377
+ elements: c
1378
+ } = t, {
1379
+ mainAxis: u = !0,
1380
+ crossAxis: p = !0,
1381
+ fallbackPlacements: h,
1382
+ fallbackStrategy: d = "bestFit",
1383
+ fallbackAxisSideDirection: m = "none",
1384
+ flipAlignment: g = !0,
1385
+ ...v
1386
+ } = xe(e, t);
1387
+ if ((n = l.arrow) != null && n.alignmentOffset)
1388
+ return {};
1389
+ const x = de(i), T = oe(a), C = de(a) === a, S = await (f.isRTL == null ? void 0 : f.isRTL(c.floating)), w = h || (C || !g ? [Ne(a)] : Sn(a)), b = m !== "none";
1390
+ !h && b && w.push(...Nn(a, g, m, S));
1391
+ const P = [a, ...w], F = await ke(t, v), D = [];
1392
+ let M = ((o = l.flip) == null ? void 0 : o.overflows) || [];
1393
+ if (u && D.push(F[x]), p) {
1394
+ const R = Ln(i, r, S);
1395
+ D.push(F[R[0]], F[R[1]]);
1396
+ }
1397
+ if (M = [...M, {
1398
+ placement: i,
1399
+ overflows: D
1400
+ }], !D.every((R) => R <= 0)) {
1401
+ var B, W;
1402
+ const R = (((B = l.flip) == null ? void 0 : B.index) || 0) + 1, E = P[R];
1403
+ if (E && (!(p === "alignment" ? T !== oe(E) : !1) || // We leave the current main axis only if every placement on that axis
1404
+ // overflows the main axis.
1405
+ M.every((y) => oe(y.placement) === T ? y.overflows[0] > 0 : !0)))
1406
+ return {
1407
+ data: {
1408
+ index: R,
1409
+ overflows: M
1410
+ },
1411
+ reset: {
1412
+ placement: E
1413
+ }
1414
+ };
1415
+ let s = (W = M.filter((k) => k.overflows[0] <= 0).sort((k, y) => k.overflows[1] - y.overflows[1])[0]) == null ? void 0 : W.placement;
1416
+ if (!s)
1417
+ switch (d) {
1418
+ case "bestFit": {
1419
+ var X;
1420
+ const k = (X = M.filter((y) => {
1421
+ if (b) {
1422
+ const H = oe(y.placement);
1423
+ return H === T || // Create a bias to the `y` side axis due to horizontal
1424
+ // reading directions favoring greater width.
1425
+ H === "y";
1426
+ }
1427
+ return !0;
1428
+ }).map((y) => [y.placement, y.overflows.filter((H) => H > 0).reduce((H, ee) => H + ee, 0)]).sort((y, H) => y[1] - H[1])[0]) == null ? void 0 : X[0];
1429
+ k && (s = k);
1430
+ break;
1431
+ }
1432
+ case "initialPlacement":
1433
+ s = a;
1434
+ break;
1435
+ }
1436
+ if (i !== s)
1437
+ return {
1438
+ reset: {
1439
+ placement: s
1440
+ }
1441
+ };
1442
+ }
1443
+ return {};
1444
+ }
1445
+ };
1446
+ };
1447
+ function yt(e, t) {
1179
1448
  return {
1180
- arrowX: u,
1181
- arrowY: c,
1182
- arrowStyles: h
1449
+ top: e.top - t.height,
1450
+ right: e.right - t.width,
1451
+ bottom: e.bottom - t.height,
1452
+ left: e.left - t.width
1183
1453
  };
1184
1454
  }
1185
- let eo = 0;
1186
- function to() {
1187
- return `vfloat-id-${eo++}`;
1188
- }
1189
- function Ot(e) {
1190
- return typeof e == "object" && e instanceof HTMLElement;
1191
- }
1192
- function no(e) {
1193
- return e !== null && typeof e == "object" && "data" in e && "id" in e && "children" in e && "parent" in e;
1455
+ function bt(e) {
1456
+ return Cn.some((t) => e[t] >= 0);
1194
1457
  }
1195
- function rt(e) {
1196
- return no(e) ? {
1197
- floatingContext: e.data,
1198
- treeContext: e
1458
+ const In = function(e) {
1459
+ return e === void 0 && (e = {}), {
1460
+ name: "hide",
1461
+ options: e,
1462
+ async fn(t) {
1463
+ const {
1464
+ rects: n
1465
+ } = t, {
1466
+ strategy: o = "referenceHidden",
1467
+ ...i
1468
+ } = xe(e, t);
1469
+ switch (o) {
1470
+ case "referenceHidden": {
1471
+ const l = await ke(t, {
1472
+ ...i,
1473
+ elementContext: "reference"
1474
+ }), r = yt(l, n.reference);
1475
+ return {
1476
+ data: {
1477
+ referenceHiddenOffsets: r,
1478
+ referenceHidden: bt(r)
1479
+ }
1480
+ };
1481
+ }
1482
+ case "escaped": {
1483
+ const l = await ke(t, {
1484
+ ...i,
1485
+ altBoundary: !0
1486
+ }), r = yt(l, n.floating);
1487
+ return {
1488
+ data: {
1489
+ escapedOffsets: r,
1490
+ escaped: bt(r)
1491
+ }
1492
+ };
1493
+ }
1494
+ default:
1495
+ return {};
1496
+ }
1497
+ }
1498
+ };
1499
+ }, Bn = /* @__PURE__ */ new Set(["left", "top"]);
1500
+ async function Wn(e, t) {
1501
+ const {
1502
+ placement: n,
1503
+ platform: o,
1504
+ elements: i
1505
+ } = e, l = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), r = de(n), a = Oe(n), f = oe(n) === "y", c = Bn.has(r) ? -1 : 1, u = l && f ? -1 : 1, p = xe(t, e);
1506
+ let {
1507
+ mainAxis: h,
1508
+ crossAxis: d,
1509
+ alignmentAxis: m
1510
+ } = typeof p == "number" ? {
1511
+ mainAxis: p,
1512
+ crossAxis: 0,
1513
+ alignmentAxis: null
1199
1514
  } : {
1200
- floatingContext: e,
1201
- treeContext: null
1515
+ mainAxis: p.mainAxis || 0,
1516
+ crossAxis: p.crossAxis || 0,
1517
+ alignmentAxis: p.alignmentAxis
1518
+ };
1519
+ return a && typeof m == "number" && (d = a === "end" ? m * -1 : m), f ? {
1520
+ x: d * u,
1521
+ y: h * c
1522
+ } : {
1523
+ x: h * c,
1524
+ y: d * u
1202
1525
  };
1203
1526
  }
1204
- function J(e, t) {
1205
- if (!t) return !1;
1206
- if (typeof t == "object" && t !== null && "contextElement" in t) {
1207
- const n = t.contextElement;
1208
- return n instanceof Element ? n.contains(e) : !1;
1209
- }
1210
- return t instanceof Element ? t.contains(e) : !1;
1211
- }
1212
- function st(e, t) {
1213
- for (const n of e.children.value)
1214
- if (n.data.open.value) {
1215
- if (J(t, n.data.refs.anchorEl.value) || J(t, n.data.refs.floatingEl.value))
1216
- return n;
1217
- const o = st(n, t);
1218
- if (o) return o;
1527
+ const $n = function(e) {
1528
+ return e === void 0 && (e = 0), {
1529
+ name: "offset",
1530
+ options: e,
1531
+ async fn(t) {
1532
+ var n, o;
1533
+ const {
1534
+ x: i,
1535
+ y: l,
1536
+ placement: r,
1537
+ middlewareData: a
1538
+ } = t, f = await Wn(t, e);
1539
+ return r === ((n = a.offset) == null ? void 0 : n.placement) && (o = a.arrow) != null && o.alignmentOffset ? {} : {
1540
+ x: i + f.x,
1541
+ y: l + f.y,
1542
+ data: {
1543
+ ...f,
1544
+ placement: r
1545
+ }
1546
+ };
1219
1547
  }
1220
- return null;
1221
- }
1222
- function Qe(e, t) {
1223
- if (e === void 0) return !1;
1224
- const n = e === "mouse";
1225
- return t ? n : n || e === "pen";
1226
- }
1227
- function Kt(e) {
1228
- return !e || !(e instanceof HTMLElement) ? !1 : e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e.isContentEditable && e.contentEditable !== "false";
1229
- }
1230
- function Mt(e) {
1231
- const t = e.target;
1232
- return t instanceof HTMLElement ? t.tagName === "BUTTON" || t.tagName === "INPUT" && t.getAttribute("type") === "button" || t.getAttribute("role") === "button" : !1;
1233
- }
1234
- function St(e) {
1235
- return Kt(e);
1236
- }
1237
- function oo(e) {
1238
- return e instanceof Element && e instanceof HTMLElement;
1239
- }
1240
- function io(e) {
1241
- return typeof e == "object" && e !== null && "contextElement" in e;
1242
- }
1243
- function At(e, t) {
1244
- return t ? "composedPath" in e && typeof e.composedPath == "function" ? e.composedPath().includes(t) : t.contains(e.target) : !1;
1245
- }
1246
- function ro(e, t) {
1247
- const n = t.getBoundingClientRect(), o = t.offsetWidth - t.clientWidth, i = t.offsetHeight - t.clientHeight, r = e.clientX - n.left, l = e.clientY - n.top;
1248
- if (o > 0) {
1249
- const a = t.clientWidth;
1250
- if (r >= a && r <= t.offsetWidth)
1251
- return !0;
1252
- }
1253
- if (i > 0) {
1254
- const a = t.clientHeight;
1255
- if (l >= a && l <= t.offsetHeight)
1256
- return !0;
1257
- }
1258
- return !1;
1259
- }
1260
- function Nt() {
1261
- return typeof navigator > "u" ? !1 : navigator.platform.toUpperCase().indexOf("MAC") >= 0;
1548
+ };
1549
+ }, Vn = function(e) {
1550
+ return e === void 0 && (e = {}), {
1551
+ name: "shift",
1552
+ options: e,
1553
+ async fn(t) {
1554
+ const {
1555
+ x: n,
1556
+ y: o,
1557
+ placement: i
1558
+ } = t, {
1559
+ mainAxis: l = !0,
1560
+ crossAxis: r = !1,
1561
+ limiter: a = {
1562
+ fn: (v) => {
1563
+ let {
1564
+ x,
1565
+ y: T
1566
+ } = v;
1567
+ return {
1568
+ x,
1569
+ y: T
1570
+ };
1571
+ }
1572
+ },
1573
+ ...f
1574
+ } = xe(e, t), c = {
1575
+ x: n,
1576
+ y: o
1577
+ }, u = await ke(t, f), p = oe(de(i)), h = Rt(p);
1578
+ let d = c[h], m = c[p];
1579
+ if (l) {
1580
+ const v = h === "y" ? "top" : "left", x = h === "y" ? "bottom" : "right", T = d + u[v], C = d - u[x];
1581
+ d = ze(T, d, C);
1582
+ }
1583
+ if (r) {
1584
+ const v = p === "y" ? "top" : "left", x = p === "y" ? "bottom" : "right", T = m + u[v], C = m - u[x];
1585
+ m = ze(T, m, C);
1586
+ }
1587
+ const g = a.fn({
1588
+ ...t,
1589
+ [h]: d,
1590
+ [p]: m
1591
+ });
1592
+ return {
1593
+ ...g,
1594
+ data: {
1595
+ x: g.x - n,
1596
+ y: g.y - o,
1597
+ enabled: {
1598
+ [h]: l,
1599
+ [p]: r
1600
+ }
1601
+ }
1602
+ };
1603
+ }
1604
+ };
1605
+ };
1606
+ function He() {
1607
+ return typeof window < "u";
1262
1608
  }
1263
- function Dt() {
1264
- return typeof navigator > "u" ? !1 : /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1609
+ function Ee(e) {
1610
+ return Ft(e) ? (e.nodeName || "").toLowerCase() : "#document";
1265
1611
  }
1266
- function so(e) {
1267
- return typeof (e == null ? void 0 : e.matches) != "function" ? !1 : e.matches(":focus-visible");
1612
+ function Y(e) {
1613
+ var t;
1614
+ return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
1268
1615
  }
1269
- function ze(e, t) {
1270
- return e.contains(t);
1616
+ function Z(e) {
1617
+ var t;
1618
+ return (t = (Ft(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
1271
1619
  }
1272
- function lo(e) {
1273
- return e.target;
1620
+ function Ft(e) {
1621
+ return He() ? e instanceof Node || e instanceof Y(e).Node : !1;
1274
1622
  }
1275
- function Rt() {
1276
- return typeof performance < "u" ? performance.now() : Date.now();
1623
+ function U(e) {
1624
+ return He() ? e instanceof Element || e instanceof Y(e).Element : !1;
1277
1625
  }
1278
- function kt(e) {
1279
- e !== -1 && clearTimeout(e);
1626
+ function Q(e) {
1627
+ return He() ? e instanceof HTMLElement || e instanceof Y(e).HTMLElement : !1;
1280
1628
  }
1281
- function Gt(e) {
1282
- return e.children.value.some(
1283
- (t) => t.data.open.value || Gt(t)
1284
- );
1629
+ function xt(e) {
1630
+ return !He() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof Y(e).ShadowRoot;
1285
1631
  }
1286
- function ao(e, t) {
1287
- return e[0] >= t.x && e[0] <= t.x + t.width && e[1] >= t.y && e[1] <= t.y + t.height;
1632
+ const Xn = /* @__PURE__ */ new Set(["inline", "contents"]);
1633
+ function Pe(e) {
1634
+ const {
1635
+ overflow: t,
1636
+ overflowX: n,
1637
+ overflowY: o,
1638
+ display: i
1639
+ } = K(e);
1640
+ return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !Xn.has(i);
1288
1641
  }
1289
- function Ft(e, t) {
1290
- const [n, o] = e;
1291
- let i = !1;
1292
- const r = t.length;
1293
- for (let l = 0, a = r - 1; l < r; a = l++) {
1294
- const [u, c] = t[l] || [0, 0], [h, f] = t[a] || [0, 0];
1295
- c >= o != f >= o && n <= (h - u) * (o - c) / (f - c) + u && (i = !i);
1296
- }
1297
- return i;
1642
+ const jn = /* @__PURE__ */ new Set(["table", "td", "th"]);
1643
+ function Yn(e) {
1644
+ return jn.has(Ee(e));
1298
1645
  }
1299
- function co(e = {}) {
1300
- const { buffer: t = 0.5, blockPointerEvents: n = !1, requireIntent: o = !0 } = e;
1301
- let i = -1, r = !1;
1302
- function l(u, c, h, f, p) {
1303
- const d = Rt(), g = d - p;
1304
- if (h === null || f === null || g === 0)
1305
- return {
1306
- speed: null,
1307
- lastX: u,
1308
- lastY: c,
1309
- lastCursorTime: d
1310
- };
1311
- const m = u - h, b = c - f;
1312
- return {
1313
- speed: Math.sqrt(m * m + b * b) / g,
1314
- lastX: u,
1315
- lastY: c,
1316
- lastCursorTime: d
1317
- };
1318
- }
1319
- const a = function(c) {
1320
- const { x: h, y: f, placement: p, elements: d, buffer: g, onClose: m, nodeId: b, tree: w } = c, y = I(() => {
1321
- const T = d.domReference;
1322
- return Ot(T) ? T : (T == null ? void 0 : T.contextElement) ?? null;
1323
- });
1324
- let C = null, P = null, E = Rt();
1325
- return function(A) {
1326
- var lt, at, ct, ut, ft, dt, ht;
1327
- function D() {
1328
- kt(i), i = -1, m();
1329
- }
1330
- if (kt(i), i = -1, !d.domReference || !d.floating || p == null || h == null || f == null)
1331
- return;
1332
- const { clientX: R, clientY: N } = A, M = [R, N], k = lo(A), V = A.type === "mouseleave", F = d.floating && ze(d.floating, k), Y = y.value && ze(y.value, k), x = (lt = y.value) == null ? void 0 : lt.getBoundingClientRect(), s = (at = d.floating) == null ? void 0 : at.getBoundingClientRect(), v = p.split("-")[0], H = h > ((s == null ? void 0 : s.right) ?? 0) - ((s == null ? void 0 : s.width) ?? 0) / 2, X = f > ((s == null ? void 0 : s.bottom) ?? 0) - ((s == null ? void 0 : s.height) ?? 0) / 2, Z = x ? ao(M, x) : !1, L = ((s == null ? void 0 : s.width) ?? 0) > ((x == null ? void 0 : x.width) ?? 0), W = ((s == null ? void 0 : s.height) ?? 0) > ((x == null ? void 0 : x.height) ?? 0), ie = ((ct = L ? x : s) == null ? void 0 : ct.left) ?? 0, ee = ((ut = L ? x : s) == null ? void 0 : ut.right) ?? 0, re = ((ft = W ? x : s) == null ? void 0 : ft.top) ?? 0, se = ((dt = W ? x : s) == null ? void 0 : dt.bottom) ?? 0;
1333
- if (F && (r = !0, !V))
1334
- return;
1335
- if (Y && (r = !1), Y && !V) {
1336
- r = !0;
1337
- return;
1338
- }
1339
- if (V && Ot(A.relatedTarget) && d.floating && ze(d.floating, A.relatedTarget))
1340
- return;
1341
- if (w && b) {
1342
- const B = w.nodes.get(b);
1343
- if (B && Gt(B))
1344
- return;
1345
- }
1346
- if (v === "top" && f >= ((x == null ? void 0 : x.bottom) ?? 0) - 1 || v === "bottom" && f <= ((x == null ? void 0 : x.top) ?? 0) + 1 || v === "left" && h >= ((x == null ? void 0 : x.right) ?? 0) - 1 || v === "right" && h <= ((x == null ? void 0 : x.left) ?? 0) + 1)
1347
- return D();
1348
- let te = [];
1349
- switch (v) {
1350
- case "top":
1351
- te = [
1352
- [ie, ((x == null ? void 0 : x.top) ?? 0) + 1],
1353
- [ie, ((s == null ? void 0 : s.bottom) ?? 0) - 1],
1354
- [ee, ((s == null ? void 0 : s.bottom) ?? 0) - 1],
1355
- [ee, ((x == null ? void 0 : x.top) ?? 0) + 1]
1356
- ];
1357
- break;
1358
- case "bottom":
1359
- te = [
1360
- [ie, ((s == null ? void 0 : s.top) ?? 0) + 1],
1361
- [ie, ((x == null ? void 0 : x.bottom) ?? 0) - 1],
1362
- [ee, ((x == null ? void 0 : x.bottom) ?? 0) - 1],
1363
- [ee, ((s == null ? void 0 : s.top) ?? 0) + 1]
1364
- ];
1365
- break;
1366
- case "left":
1367
- te = [
1368
- [((s == null ? void 0 : s.right) ?? 0) - 1, se],
1369
- [((s == null ? void 0 : s.right) ?? 0) - 1, re],
1370
- [((x == null ? void 0 : x.left) ?? 0) + 1, re],
1371
- [((x == null ? void 0 : x.left) ?? 0) + 1, se]
1372
- ];
1373
- break;
1374
- case "right":
1375
- te = [
1376
- [((x == null ? void 0 : x.right) ?? 0) - 1, se],
1377
- [((x == null ? void 0 : x.right) ?? 0) - 1, re],
1378
- [((s == null ? void 0 : s.left) ?? 0) + 1, re],
1379
- [((s == null ? void 0 : s.left) ?? 0) + 1, se]
1380
- ];
1381
- break;
1382
- }
1383
- function Ee([B, $]) {
1384
- const O = g;
1385
- switch (v) {
1386
- case "top": {
1387
- const le = [
1388
- L ? B + O / 2 : H ? B + O * 4 : B - O * 4,
1389
- $ + O + 1
1390
- ], ae = [
1391
- L ? B - O / 2 : H ? B + O * 4 : B - O * 4,
1392
- $ + O + 1
1393
- ], me = [
1394
- [
1395
- (s == null ? void 0 : s.left) ?? 0,
1396
- H || L ? ((s == null ? void 0 : s.bottom) ?? 0) - O : (s == null ? void 0 : s.top) ?? 0
1397
- ],
1398
- [
1399
- (s == null ? void 0 : s.right) ?? 0,
1400
- H ? L ? ((s == null ? void 0 : s.bottom) ?? 0) - O : (s == null ? void 0 : s.top) ?? 0 : ((s == null ? void 0 : s.bottom) ?? 0) - O
1401
- ]
1402
- ];
1403
- return [le, ae, ...me];
1404
- }
1405
- case "bottom": {
1406
- const le = [
1407
- L ? B + O / 2 : H ? B + O * 4 : B - O * 4,
1408
- $ - O
1409
- ], ae = [
1410
- L ? B - O / 2 : H ? B + O * 4 : B - O * 4,
1411
- $ - O
1412
- ], me = [
1413
- [
1414
- (s == null ? void 0 : s.left) ?? 0,
1415
- H || L ? ((s == null ? void 0 : s.top) ?? 0) + O : (s == null ? void 0 : s.bottom) ?? 0
1416
- ],
1417
- [
1418
- (s == null ? void 0 : s.right) ?? 0,
1419
- H ? L ? ((s == null ? void 0 : s.top) ?? 0) + O : (s == null ? void 0 : s.bottom) ?? 0 : ((s == null ? void 0 : s.top) ?? 0) + O
1420
- ]
1421
- ];
1422
- return [le, ae, ...me];
1423
- }
1424
- case "left": {
1425
- const le = [
1426
- B + O + 1,
1427
- W ? $ + O / 2 : X ? $ + O * 4 : $ - O * 4
1428
- ], ae = [
1429
- B + O + 1,
1430
- W ? $ - O / 2 : X ? $ + O * 4 : $ - O * 4
1431
- ];
1432
- return [...[
1433
- [
1434
- X || W ? ((s == null ? void 0 : s.right) ?? 0) - O : (s == null ? void 0 : s.left) ?? 0,
1435
- (s == null ? void 0 : s.top) ?? 0
1436
- ],
1437
- [
1438
- X ? W ? ((s == null ? void 0 : s.right) ?? 0) - O : (s == null ? void 0 : s.left) ?? 0 : ((s == null ? void 0 : s.right) ?? 0) - O,
1439
- (s == null ? void 0 : s.bottom) ?? 0
1440
- ]
1441
- ], le, ae];
1442
- }
1443
- case "right": {
1444
- const le = [
1445
- B - O,
1446
- W ? $ + O / 2 : X ? $ + O * 4 : $ - O * 4
1447
- ], ae = [
1448
- B - O,
1449
- W ? $ - O / 2 : X ? $ + O * 4 : $ - O * 4
1450
- ], me = [
1451
- [
1452
- X || W ? ((s == null ? void 0 : s.left) ?? 0) + O : (s == null ? void 0 : s.right) ?? 0,
1453
- (s == null ? void 0 : s.top) ?? 0
1454
- ],
1455
- [
1456
- X ? W ? ((s == null ? void 0 : s.left) ?? 0) + O : (s == null ? void 0 : s.right) ?? 0 : ((s == null ? void 0 : s.left) ?? 0) + O,
1457
- (s == null ? void 0 : s.bottom) ?? 0
1458
- ]
1459
- ];
1460
- return [le, ae, ...me];
1461
- }
1462
- }
1463
- }
1464
- const Ae = Ee([h, f]);
1465
- if ((ht = e.onPolygonChange) == null || ht.call(e, Ae), !Ft(M, te)) {
1466
- if (Ft(M, Ae)) {
1467
- if (!r && o) {
1468
- const B = l(
1469
- A.clientX,
1470
- A.clientY,
1471
- C,
1472
- P,
1473
- E
1474
- );
1475
- C = B.lastX, P = B.lastY, E = B.lastCursorTime, B.speed !== null && B.speed < 0.1 && (i = window.setTimeout(D, 40));
1476
- }
1477
- return;
1478
- }
1479
- if (r && !Z)
1480
- return D();
1481
- D();
1482
- }
1483
- };
1484
- };
1485
- return a.__options = {
1486
- blockPointerEvents: n
1487
- }, a;
1488
- }
1489
- const Ht = 10;
1490
- function uo(e, t, n) {
1491
- const { delay: o } = n, i = I(() => {
1492
- const c = S(o);
1493
- return (typeof c == "number" ? c : c.open) ?? 0;
1494
- }), r = I(() => {
1495
- const c = S(o);
1496
- return (typeof c == "number" ? c : c.close) ?? 0;
1646
+ const zn = [":popover-open", ":modal"];
1647
+ function Ie(e) {
1648
+ return zn.some((t) => {
1649
+ try {
1650
+ return e.matches(t);
1651
+ } catch {
1652
+ return !1;
1653
+ }
1497
1654
  });
1498
- let l, a;
1499
- const u = () => {
1500
- clearTimeout(l), clearTimeout(a);
1501
- };
1502
- return ge(u), {
1503
- show: (c) => {
1504
- u();
1505
- const h = c ?? i.value;
1506
- h === 0 ? e() : l = setTimeout(e, h);
1507
- },
1508
- hide: (c) => {
1509
- u();
1510
- const h = c ?? r.value;
1511
- h === 0 ? t() : a = setTimeout(t, h);
1512
- },
1513
- showDelay: i,
1514
- hideDelay: r,
1515
- clearTimeouts: u
1655
+ }
1656
+ const _n = ["transform", "translate", "scale", "rotate", "perspective"], Un = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Kn = ["paint", "layout", "strict", "content"];
1657
+ function Je(e) {
1658
+ const t = Qe(), n = U(e) ? K(e) : e;
1659
+ return _n.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || Un.some((o) => (n.willChange || "").includes(o)) || Kn.some((o) => (n.contain || "").includes(o));
1660
+ }
1661
+ function qn(e) {
1662
+ let t = ie(e);
1663
+ for (; Q(t) && !be(t); ) {
1664
+ if (Je(t))
1665
+ return t;
1666
+ if (Ie(t))
1667
+ return null;
1668
+ t = ie(t);
1669
+ }
1670
+ return null;
1671
+ }
1672
+ function Qe() {
1673
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
1674
+ }
1675
+ const Gn = /* @__PURE__ */ new Set(["html", "body", "#document"]);
1676
+ function be(e) {
1677
+ return Gn.has(Ee(e));
1678
+ }
1679
+ function K(e) {
1680
+ return Y(e).getComputedStyle(e);
1681
+ }
1682
+ function Be(e) {
1683
+ return U(e) ? {
1684
+ scrollLeft: e.scrollLeft,
1685
+ scrollTop: e.scrollTop
1686
+ } : {
1687
+ scrollLeft: e.scrollX,
1688
+ scrollTop: e.scrollY
1516
1689
  };
1517
1690
  }
1518
- function Do(e, t = {}) {
1519
- const { floatingContext: n, treeContext: o } = rt(e), {
1520
- open: i,
1521
- setOpen: r,
1522
- refs: { anchorEl: l, floatingEl: a }
1523
- } = n, {
1524
- enabled: u = !0,
1525
- delay: c = 0,
1526
- restMs: h = 0,
1527
- mouseOnly: f = !1,
1528
- safePolygon: p = !1
1529
- } = t, d = I(() => S(u)), g = I(() => S(h)), m = I(() => {
1530
- const v = l.value;
1531
- return !v || v instanceof HTMLElement ? v : v.contextElement ?? null;
1532
- }), { hide: b, show: w, showDelay: y, clearTimeouts: C } = uo(
1533
- () => {
1534
- i.value || r(!0);
1535
- },
1536
- () => {
1537
- i.value && r(!1);
1538
- },
1539
- { delay: c }
1691
+ function ie(e) {
1692
+ if (Ee(e) === "html")
1693
+ return e;
1694
+ const t = (
1695
+ // Step into the shadow DOM of the parent of a slotted node.
1696
+ e.assignedSlot || // DOM Element detected.
1697
+ e.parentNode || // ShadowRoot detected.
1698
+ xt(e) && e.host || // Fallback.
1699
+ Z(e)
1540
1700
  );
1541
- let P = null, E;
1542
- const T = I(() => y.value === 0 && g.value > 0);
1543
- function A(v) {
1544
- if (!d.value || !N(v) || !T.value || !P) return;
1545
- const H = { x: v.clientX, y: v.clientY }, X = Math.abs(H.x - P.x), Z = Math.abs(H.y - P.y);
1546
- (X > Ht || Z > Ht) && (P = H, clearTimeout(E), E = setTimeout(() => {
1547
- w(0);
1548
- }, g.value));
1549
- }
1550
- function D(v) {
1551
- !d.value || !N(v) || !T.value || (P = { x: v.clientX, y: v.clientY }, E = setTimeout(() => {
1552
- w(0);
1553
- }, g.value));
1554
- }
1555
- function R() {
1556
- clearTimeout(E), P = null;
1557
- }
1558
- Te(() => {
1559
- const v = m.value;
1560
- !v || !d.value || !T.value || (v.addEventListener("pointerenter", D), v.addEventListener("pointermove", A), v.addEventListener("pointerleave", R), ue(() => {
1561
- v.removeEventListener("pointerenter", D), v.removeEventListener("pointermove", A), v.removeEventListener("pointerleave", R);
1562
- }));
1563
- }), ge(() => {
1564
- clearTimeout(E);
1565
- });
1566
- function N(v) {
1567
- return S(f) ? v.pointerType === "mouse" : !0;
1568
- }
1569
- function M(v) {
1570
- !d.value || !N(v) || T.value || (F(), w());
1571
- }
1572
- function k(v) {
1573
- !d.value || !N(v) || (C(), F());
1574
- }
1575
- let V = null;
1576
- function F() {
1577
- V && (document.removeEventListener("pointermove", V), V = null);
1578
- const v = x.value;
1579
- v != null && v.onPolygonChange && v.onPolygonChange([]);
1701
+ return xt(t) ? t.host : t;
1702
+ }
1703
+ function Ht(e) {
1704
+ const t = ie(e);
1705
+ return be(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Q(t) && Pe(t) ? t : Ht(t);
1706
+ }
1707
+ function Te(e, t, n) {
1708
+ var o;
1709
+ t === void 0 && (t = []), n === void 0 && (n = !0);
1710
+ const i = Ht(e), l = i === ((o = e.ownerDocument) == null ? void 0 : o.body), r = Y(i);
1711
+ if (l) {
1712
+ const a = Ue(r);
1713
+ return t.concat(r, r.visualViewport || [], Pe(i) ? i : [], a && n ? Te(a) : []);
1580
1714
  }
1581
- const Y = I(() => !!S(p)), x = I(() => {
1582
- const v = S(p);
1583
- if (typeof v == "object" && v) return v;
1584
- if (v === !0) return {};
1585
- });
1586
- function s(v) {
1587
- var L;
1588
- if (!d.value || !N(v)) return;
1589
- const { clientX: H, clientY: X } = v, Z = v.relatedTarget;
1590
- if (Y.value)
1591
- setTimeout(() => {
1592
- var se;
1593
- F();
1594
- const W = m.value, ie = a.value;
1595
- if (!W || !ie) {
1596
- b();
1597
- return;
1598
- }
1599
- let ee, re;
1600
- if (o) {
1601
- ee = /* @__PURE__ */ new Map();
1602
- const te = (Ee) => {
1603
- ee.set(Ee.id, Ee);
1604
- for (const Ae of Ee.children.value)
1605
- te(Ae);
1606
- };
1607
- te(o), re = o.id;
1608
- }
1609
- V = co(x.value)({
1610
- x: H,
1611
- y: X,
1612
- placement: n.placement.value,
1613
- elements: {
1614
- domReference: W,
1615
- floating: ie
1616
- },
1617
- buffer: ((se = x.value) == null ? void 0 : se.buffer) ?? 1,
1618
- onClose: () => {
1619
- F(), b();
1620
- },
1621
- nodeId: re,
1622
- tree: ee ? { nodes: ee } : void 0
1623
- }), V && document.addEventListener("pointermove", V);
1624
- }, 0);
1625
- else {
1626
- if (o) {
1627
- if (!fo(o, Z))
1628
- return;
1629
- } else if ((L = a.value) != null && L.contains(Z))
1630
- return;
1631
- b();
1715
+ return t.concat(i, Te(i, [], n));
1716
+ }
1717
+ function Ue(e) {
1718
+ return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
1719
+ }
1720
+ function It(e) {
1721
+ const t = K(e);
1722
+ let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
1723
+ const i = Q(e), l = i ? e.offsetWidth : n, r = i ? e.offsetHeight : o, a = De(n) !== l || De(o) !== r;
1724
+ return a && (n = l, o = r), {
1725
+ width: n,
1726
+ height: o,
1727
+ $: a
1728
+ };
1729
+ }
1730
+ function Ze(e) {
1731
+ return U(e) ? e : e.contextElement;
1732
+ }
1733
+ function ge(e) {
1734
+ const t = Ze(e);
1735
+ if (!Q(t))
1736
+ return G(1);
1737
+ const n = t.getBoundingClientRect(), {
1738
+ width: o,
1739
+ height: i,
1740
+ $: l
1741
+ } = It(t);
1742
+ let r = (l ? De(n.width) : n.width) / o, a = (l ? De(n.height) : n.height) / i;
1743
+ return (!r || !Number.isFinite(r)) && (r = 1), (!a || !Number.isFinite(a)) && (a = 1), {
1744
+ x: r,
1745
+ y: a
1746
+ };
1747
+ }
1748
+ const Jn = /* @__PURE__ */ G(0);
1749
+ function Bt(e) {
1750
+ const t = Y(e);
1751
+ return !Qe() || !t.visualViewport ? Jn : {
1752
+ x: t.visualViewport.offsetLeft,
1753
+ y: t.visualViewport.offsetTop
1754
+ };
1755
+ }
1756
+ function Qn(e, t, n) {
1757
+ return t === void 0 && (t = !1), !n || t && n !== Y(e) ? !1 : t;
1758
+ }
1759
+ function he(e, t, n, o) {
1760
+ t === void 0 && (t = !1), n === void 0 && (n = !1);
1761
+ const i = e.getBoundingClientRect(), l = Ze(e);
1762
+ let r = G(1);
1763
+ t && (o ? U(o) && (r = ge(o)) : r = ge(e));
1764
+ const a = Qn(l, n, o) ? Bt(l) : G(0);
1765
+ let f = (i.left + a.x) / r.x, c = (i.top + a.y) / r.y, u = i.width / r.x, p = i.height / r.y;
1766
+ if (l) {
1767
+ const h = Y(l), d = o && U(o) ? Y(o) : o;
1768
+ let m = h, g = Ue(m);
1769
+ for (; g && o && d !== m; ) {
1770
+ const v = ge(g), x = g.getBoundingClientRect(), T = K(g), C = x.left + (g.clientLeft + parseFloat(T.paddingLeft)) * v.x, S = x.top + (g.clientTop + parseFloat(T.paddingTop)) * v.y;
1771
+ f *= v.x, c *= v.y, u *= v.x, p *= v.y, f += C, c += S, m = Y(g), g = Ue(m);
1632
1772
  }
1633
1773
  }
1634
- Te(() => {
1635
- const v = m.value;
1636
- !v || !d.value || (v.addEventListener("pointerenter", M), v.addEventListener("pointerleave", s), ue(() => {
1637
- v.removeEventListener("pointerenter", M), v.removeEventListener("pointerleave", s);
1638
- }));
1639
- }), Te(() => {
1640
- const v = a.value;
1641
- !v || !d.value || (v.addEventListener("pointerenter", k), v.addEventListener("pointerleave", s), ue(() => {
1642
- v.removeEventListener("pointerenter", k), v.removeEventListener("pointerleave", s);
1643
- }));
1644
- }), ge(() => {
1645
- F();
1774
+ return Re({
1775
+ width: u,
1776
+ height: p,
1777
+ x: f,
1778
+ y: c
1646
1779
  });
1647
1780
  }
1648
- function fo(e, t) {
1649
- return t ? !(J(t, e.data.refs.anchorEl.value) || J(t, e.data.refs.floatingEl.value) || st(e, t)) : !0;
1781
+ function We(e, t) {
1782
+ const n = Be(e).scrollLeft;
1783
+ return t ? t.left + n : he(Z(e)).left + n;
1650
1784
  }
1651
- function ho(e) {
1652
- return en() ? (ge(e), !0) : !1;
1785
+ function Wt(e, t) {
1786
+ const n = e.getBoundingClientRect(), o = n.left + t.scrollLeft - We(e, n), i = n.top + t.scrollTop;
1787
+ return {
1788
+ x: o,
1789
+ y: i
1790
+ };
1653
1791
  }
1654
- const mo = typeof window < "u" && typeof document < "u";
1655
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
1656
- const po = Object.prototype.toString, vo = (e) => po.call(e) === "[object Object]";
1657
- function Ue(e) {
1658
- return Array.isArray(e) ? e : [e];
1792
+ function Zn(e) {
1793
+ let {
1794
+ elements: t,
1795
+ rect: n,
1796
+ offsetParent: o,
1797
+ strategy: i
1798
+ } = e;
1799
+ const l = i === "fixed", r = Z(o), a = t ? Ie(t.floating) : !1;
1800
+ if (o === r || a && l)
1801
+ return n;
1802
+ let f = {
1803
+ scrollLeft: 0,
1804
+ scrollTop: 0
1805
+ }, c = G(1);
1806
+ const u = G(0), p = Q(o);
1807
+ if ((p || !p && !l) && ((Ee(o) !== "body" || Pe(r)) && (f = Be(o)), Q(o))) {
1808
+ const d = he(o);
1809
+ c = ge(o), u.x = d.x + o.clientLeft, u.y = d.y + o.clientTop;
1810
+ }
1811
+ const h = r && !p && !l ? Wt(r, f) : G(0);
1812
+ return {
1813
+ width: n.width * c.x,
1814
+ height: n.height * c.y,
1815
+ x: n.x * c.x - f.scrollLeft * c.x + u.x + h.x,
1816
+ y: n.y * c.y - f.scrollTop * c.y + u.y + h.y
1817
+ };
1659
1818
  }
1660
- function go(e, t, n) {
1661
- return pe(
1662
- e,
1663
- t,
1664
- {
1665
- ...n,
1666
- immediate: !0
1667
- }
1668
- );
1819
+ function eo(e) {
1820
+ return Array.from(e.getClientRects());
1669
1821
  }
1670
- const wo = mo ? window : void 0;
1671
- function yo(e) {
1672
- var t;
1673
- const n = S(e);
1674
- return (t = n == null ? void 0 : n.$el) != null ? t : n;
1822
+ function to(e) {
1823
+ const t = Z(e), n = Be(e), o = e.ownerDocument.body, i = fe(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), l = fe(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
1824
+ let r = -n.scrollLeft + We(e);
1825
+ const a = -n.scrollTop;
1826
+ return K(o).direction === "rtl" && (r += fe(t.clientWidth, o.clientWidth) - i), {
1827
+ width: i,
1828
+ height: l,
1829
+ x: r,
1830
+ y: a
1831
+ };
1675
1832
  }
1676
- function q(...e) {
1677
- const t = [], n = () => {
1678
- t.forEach((a) => a()), t.length = 0;
1679
- }, o = (a, u, c, h) => (a.addEventListener(u, c, h), () => a.removeEventListener(u, c, h)), i = I(() => {
1680
- const a = Ue(S(e[0])).filter((u) => u != null);
1681
- return a.every((u) => typeof u != "string") ? a : void 0;
1682
- }), r = go(
1683
- () => {
1684
- var a, u;
1685
- return [
1686
- (u = (a = i.value) == null ? void 0 : a.map((c) => yo(c))) != null ? u : [wo].filter((c) => c != null),
1687
- Ue(S(i.value ? e[1] : e[0])),
1688
- Ue(tn(i.value ? e[2] : e[1])),
1689
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
1690
- S(i.value ? e[3] : e[2])
1691
- ];
1692
- },
1693
- ([a, u, c, h]) => {
1694
- if (n(), !(a != null && a.length) || !(u != null && u.length) || !(c != null && c.length))
1695
- return;
1696
- const f = vo(h) ? { ...h } : h;
1697
- t.push(
1698
- ...a.flatMap(
1699
- (p) => u.flatMap(
1700
- (d) => c.map((g) => o(p, d, g, f))
1701
- )
1702
- )
1703
- );
1704
- },
1705
- { flush: "post" }
1706
- ), l = () => {
1707
- r(), n();
1833
+ const Et = 25;
1834
+ function no(e, t) {
1835
+ const n = Y(e), o = Z(e), i = n.visualViewport;
1836
+ let l = o.clientWidth, r = o.clientHeight, a = 0, f = 0;
1837
+ if (i) {
1838
+ l = i.width, r = i.height;
1839
+ const u = Qe();
1840
+ (!u || u && t === "fixed") && (a = i.offsetLeft, f = i.offsetTop);
1841
+ }
1842
+ const c = We(o);
1843
+ if (c <= 0) {
1844
+ const u = o.ownerDocument, p = u.body, h = getComputedStyle(p), d = u.compatMode === "CSS1Compat" && parseFloat(h.marginLeft) + parseFloat(h.marginRight) || 0, m = Math.abs(o.clientWidth - p.clientWidth - d);
1845
+ m <= Et && (l -= m);
1846
+ } else c <= Et && (l += c);
1847
+ return {
1848
+ width: l,
1849
+ height: r,
1850
+ x: a,
1851
+ y: f
1708
1852
  };
1709
- return ho(n), l;
1710
1853
  }
1711
- function Ro(e, t = {}) {
1712
- const { floatingContext: n, treeContext: o } = rt(e), {
1713
- open: i,
1714
- setOpen: r,
1715
- refs: { floatingEl: l, anchorEl: a }
1716
- } = n, { enabled: u = !0, requireFocusVisible: c = !0 } = t, h = I(() => a.value ? a.value instanceof HTMLElement ? a.value : a.value.contextElement : null);
1717
- let f = !1, p = !0, d;
1718
- q(window, "blur", () => {
1719
- !i.value && h.value && h.value === document.activeElement && (f = !0);
1720
- }), q(window, "focus", () => {
1721
- f = !1;
1722
- }), nn(() => {
1723
- Nt() && Dt() && (q(
1724
- window,
1725
- "keydown",
1726
- () => {
1727
- p = !0;
1728
- },
1729
- { capture: !0 }
1730
- ), q(
1731
- window,
1732
- "pointerdown",
1733
- () => {
1734
- p = !1;
1735
- },
1736
- { capture: !0 }
1737
- ));
1738
- });
1739
- function g(b) {
1740
- if (f) {
1741
- f = !1;
1742
- return;
1743
- }
1744
- const w = b.target;
1745
- if (S(c) && w) {
1746
- if (Nt() && Dt() && !b.relatedTarget) {
1747
- if (!p && !Kt(w))
1748
- return;
1749
- } else if (!so(w))
1750
- return;
1751
- }
1752
- r(!0);
1854
+ const oo = /* @__PURE__ */ new Set(["absolute", "fixed"]);
1855
+ function io(e, t) {
1856
+ const n = he(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, l = Q(e) ? ge(e) : G(1), r = e.clientWidth * l.x, a = e.clientHeight * l.y, f = i * l.x, c = o * l.y;
1857
+ return {
1858
+ width: r,
1859
+ height: a,
1860
+ x: f,
1861
+ y: c
1862
+ };
1863
+ }
1864
+ function Ct(e, t, n) {
1865
+ let o;
1866
+ if (t === "viewport")
1867
+ o = no(e, n);
1868
+ else if (t === "document")
1869
+ o = to(Z(e));
1870
+ else if (U(t))
1871
+ o = io(t, n);
1872
+ else {
1873
+ const i = Bt(e);
1874
+ o = {
1875
+ x: t.x - i.x,
1876
+ y: t.y - i.y,
1877
+ width: t.width,
1878
+ height: t.height
1879
+ };
1753
1880
  }
1754
- function m(b) {
1755
- clearTimeout(d), d = window.setTimeout(() => {
1756
- var C;
1757
- const y = (((C = h.value) == null ? void 0 : C.ownerDocument) ?? document).activeElement;
1758
- if (!(!b.relatedTarget && y === h.value)) {
1759
- if (o) {
1760
- if (y && bo(o, y))
1761
- return;
1762
- } else if (l.value && y && l.value.contains(y))
1763
- return;
1764
- r(!1);
1765
- }
1766
- }, 0);
1881
+ return Re(o);
1882
+ }
1883
+ function $t(e, t) {
1884
+ const n = ie(e);
1885
+ return n === t || !U(n) || be(n) ? !1 : K(n).position === "fixed" || $t(n, t);
1886
+ }
1887
+ function ro(e, t) {
1888
+ const n = t.get(e);
1889
+ if (n)
1890
+ return n;
1891
+ let o = Te(e, [], !1).filter((a) => U(a) && Ee(a) !== "body"), i = null;
1892
+ const l = K(e).position === "fixed";
1893
+ let r = l ? ie(e) : e;
1894
+ for (; U(r) && !be(r); ) {
1895
+ const a = K(r), f = Je(r);
1896
+ !f && a.position === "fixed" && (i = null), (l ? !f && !i : !f && a.position === "static" && !!i && oo.has(i.position) || Pe(r) && !f && $t(e, r)) ? o = o.filter((u) => u !== r) : i = a, r = ie(r);
1767
1897
  }
1768
- Te(() => {
1769
- if (!S(u)) return;
1770
- const b = h.value;
1771
- !b || !(b instanceof HTMLElement) || (b.addEventListener("focus", g), b.addEventListener("blur", m), ue(() => {
1772
- b.removeEventListener("focus", g), b.removeEventListener("blur", m);
1773
- }));
1774
- }), ge(() => {
1775
- clearTimeout(d);
1776
- });
1898
+ return t.set(e, o), o;
1899
+ }
1900
+ function so(e) {
1901
+ let {
1902
+ element: t,
1903
+ boundary: n,
1904
+ rootBoundary: o,
1905
+ strategy: i
1906
+ } = e;
1907
+ const r = [...n === "clippingAncestors" ? Ie(t) ? [] : ro(t, this._c) : [].concat(n), o], a = r[0], f = r.reduce((c, u) => {
1908
+ const p = Ct(t, u, i);
1909
+ return c.top = fe(p.top, c.top), c.right = ye(p.right, c.right), c.bottom = ye(p.bottom, c.bottom), c.left = fe(p.left, c.left), c;
1910
+ }, Ct(t, a, i));
1911
+ return {
1912
+ width: f.right - f.left,
1913
+ height: f.bottom - f.top,
1914
+ x: f.left,
1915
+ y: f.top
1916
+ };
1777
1917
  }
1778
- function bo(e, t) {
1779
- return J(t, e.data.refs.anchorEl.value) || J(t, e.data.refs.floatingEl.value) ? !0 : Jt(e, t) !== null;
1918
+ function lo(e) {
1919
+ const {
1920
+ width: t,
1921
+ height: n
1922
+ } = It(e);
1923
+ return {
1924
+ width: t,
1925
+ height: n
1926
+ };
1780
1927
  }
1781
- function Jt(e, t) {
1782
- for (const n of e.children.value)
1783
- if (n.data.open.value) {
1784
- if (J(t, n.data.refs.anchorEl.value) || J(t, n.data.refs.floatingEl.value))
1785
- return n;
1786
- const o = Jt(n, t);
1787
- if (o) return o;
1788
- }
1789
- return null;
1928
+ function ao(e, t, n) {
1929
+ const o = Q(t), i = Z(t), l = n === "fixed", r = he(e, !0, l, t);
1930
+ let a = {
1931
+ scrollLeft: 0,
1932
+ scrollTop: 0
1933
+ };
1934
+ const f = G(0);
1935
+ function c() {
1936
+ f.x = We(i);
1937
+ }
1938
+ if (o || !o && !l)
1939
+ if ((Ee(t) !== "body" || Pe(i)) && (a = Be(t)), o) {
1940
+ const d = he(t, !0, l, t);
1941
+ f.x = d.x + t.clientLeft, f.y = d.y + t.clientTop;
1942
+ } else i && c();
1943
+ l && !o && i && c();
1944
+ const u = i && !o && !l ? Wt(i, a) : G(0), p = r.left + a.scrollLeft - f.x - u.x, h = r.top + a.scrollTop - f.y - u.y;
1945
+ return {
1946
+ x: p,
1947
+ y: h,
1948
+ width: r.width,
1949
+ height: r.height
1950
+ };
1790
1951
  }
1791
- function ko(e, t = {}) {
1792
- const { floatingContext: n, treeContext: o } = rt(e), { open: i, setOpen: r, refs: l } = n, {
1793
- enabled: a = !0,
1794
- event: u = "click",
1795
- toggle: c = !0,
1796
- ignoreMouse: h = !1,
1797
- ignoreKeyboard: f = !1,
1798
- ignoreTouch: p = !1,
1799
- // Outside click options
1800
- outsideClick: d = !1,
1801
- outsideEvent: g = "pointerdown",
1802
- outsideCapture: m = !0,
1803
- onOutsideClick: b,
1804
- preventScrollbarClick: w = !0,
1805
- handleDragEvents: y = !0
1806
- } = t;
1807
- let C, P = !1, E = !1, T = !1;
1808
- const A = I(() => S(a)), D = I(() => S(d)), R = I(() => {
1809
- const L = l.anchorEl.value;
1810
- return L ? L instanceof HTMLElement ? L : io(L) && L.contextElement instanceof HTMLElement ? L.contextElement : null : null;
1811
- }), N = I(() => l.floatingEl.value);
1812
- function M() {
1813
- T = !0;
1814
- try {
1815
- i.value ? S(c) && r(!1) : r(!0);
1816
- } finally {
1817
- Promise.resolve().then(() => {
1818
- T = !1;
1819
- });
1952
+ function Xe(e) {
1953
+ return K(e).position === "static";
1954
+ }
1955
+ function Tt(e, t) {
1956
+ if (!Q(e) || K(e).position === "fixed")
1957
+ return null;
1958
+ if (t)
1959
+ return t(e);
1960
+ let n = e.offsetParent;
1961
+ return Z(e) === n && (n = n.ownerDocument.body), n;
1962
+ }
1963
+ function Vt(e, t) {
1964
+ const n = Y(e);
1965
+ if (Ie(e))
1966
+ return n;
1967
+ if (!Q(e)) {
1968
+ let i = ie(e);
1969
+ for (; i && !be(i); ) {
1970
+ if (U(i) && !Xe(i))
1971
+ return i;
1972
+ i = ie(i);
1820
1973
  }
1974
+ return n;
1821
1975
  }
1822
- function k() {
1823
- C = void 0, P = !1, E = !1;
1824
- }
1825
- function V(L) {
1826
- C = L.pointerType;
1827
- }
1828
- function F(L) {
1829
- L.button === 0 && S(u) !== "click" && (Z(C) || M());
1830
- }
1831
- function Y() {
1832
- if (S(u) === "mousedown" && C) {
1833
- k();
1834
- return;
1835
- }
1836
- if (Z(C)) {
1837
- k();
1838
- return;
1976
+ let o = Tt(e, t);
1977
+ for (; o && Yn(o) && Xe(o); )
1978
+ o = Tt(o, t);
1979
+ return o && be(o) && Xe(o) && !Je(o) ? n : o || qn(e) || n;
1980
+ }
1981
+ const co = async function(e) {
1982
+ const t = this.getOffsetParent || Vt, n = this.getDimensions, o = await n(e.floating);
1983
+ return {
1984
+ reference: ao(e.reference, await t(e.floating), e.strategy),
1985
+ floating: {
1986
+ x: 0,
1987
+ y: 0,
1988
+ width: o.width,
1989
+ height: o.height
1839
1990
  }
1840
- M(), k();
1841
- }
1842
- function x(L) {
1843
- if (C = void 0, L.defaultPrevented || S(f) || Mt(L))
1844
- return;
1845
- const W = R.value;
1846
- W && (L.key === " " && !St(W) && (L.preventDefault(), P = !0), L.key === "Enter" && M());
1847
- }
1848
- function s(L) {
1849
- const W = R.value;
1850
- W && (L.defaultPrevented || S(f) || Mt(L) || St(W) || L.key === " " && P && (P = !1, M()));
1991
+ };
1992
+ };
1993
+ function uo(e) {
1994
+ return K(e).direction === "rtl";
1995
+ }
1996
+ const fo = {
1997
+ convertOffsetParentRelativeRectToViewportRelativeRect: Zn,
1998
+ getDocumentElement: Z,
1999
+ getClippingRect: so,
2000
+ getOffsetParent: Vt,
2001
+ getElementRects: co,
2002
+ getClientRects: eo,
2003
+ getDimensions: lo,
2004
+ getScale: ge,
2005
+ isElement: U,
2006
+ isRTL: uo
2007
+ };
2008
+ function Xt(e, t) {
2009
+ return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
2010
+ }
2011
+ function ho(e, t) {
2012
+ let n = null, o;
2013
+ const i = Z(e);
2014
+ function l() {
2015
+ var a;
2016
+ clearTimeout(o), (a = n) == null || a.disconnect(), n = null;
1851
2017
  }
1852
- function v(L) {
1853
- if (!A.value || !D.value || !i.value)
1854
- return;
1855
- if (S(g) === "click" && S(y) && E) {
1856
- E = !1;
2018
+ function r(a, f) {
2019
+ a === void 0 && (a = !1), f === void 0 && (f = 1), l();
2020
+ const c = e.getBoundingClientRect(), {
2021
+ left: u,
2022
+ top: p,
2023
+ width: h,
2024
+ height: d
2025
+ } = c;
2026
+ if (a || t(), !h || !d)
1857
2027
  return;
2028
+ const m = Me(p), g = Me(i.clientWidth - (u + h)), v = Me(i.clientHeight - (p + d)), x = Me(u), C = {
2029
+ rootMargin: -m + "px " + -g + "px " + -v + "px " + -x + "px",
2030
+ threshold: fe(0, ye(1, f)) || 1
2031
+ };
2032
+ let S = !0;
2033
+ function w(b) {
2034
+ const P = b[0].intersectionRatio;
2035
+ if (P !== f) {
2036
+ if (!S)
2037
+ return r();
2038
+ P ? r(!1, P) : o = setTimeout(() => {
2039
+ r(!1, 1e-7);
2040
+ }, 1e3);
2041
+ }
2042
+ P === 1 && !Xt(c, e.getBoundingClientRect()) && r(), S = !1;
1858
2043
  }
1859
- if (T)
1860
- return;
1861
- const W = L.target;
1862
- if (W && !(S(w) && oo(W) && N.value && ro(L, W))) {
1863
- if (o) {
1864
- if (!xo(o, W))
1865
- return;
1866
- } else if (At(L, R.value) || At(L, N.value))
1867
- return;
1868
- b ? b(L, n) : r(!1);
2044
+ try {
2045
+ n = new IntersectionObserver(w, {
2046
+ ...C,
2047
+ // Handle <iframe>s
2048
+ root: i.ownerDocument
2049
+ });
2050
+ } catch {
2051
+ n = new IntersectionObserver(w, C);
1869
2052
  }
2053
+ n.observe(e);
1870
2054
  }
1871
- function H() {
1872
- E = !0;
1873
- }
1874
- function X() {
1875
- setTimeout(() => {
1876
- E = !1;
1877
- }, 0);
1878
- }
1879
- function Z(L) {
1880
- return !!(Qe(L, !0) && S(h) || L === "touch" && S(p));
2055
+ return r(!0), l;
2056
+ }
2057
+ function mo(e, t, n, o) {
2058
+ o === void 0 && (o = {});
2059
+ const {
2060
+ ancestorScroll: i = !0,
2061
+ ancestorResize: l = !0,
2062
+ elementResize: r = typeof ResizeObserver == "function",
2063
+ layoutShift: a = typeof IntersectionObserver == "function",
2064
+ animationFrame: f = !1
2065
+ } = o, c = Ze(e), u = i || l ? [...c ? Te(c) : [], ...Te(t)] : [];
2066
+ u.forEach((x) => {
2067
+ i && x.addEventListener("scroll", n, {
2068
+ passive: !0
2069
+ }), l && x.addEventListener("resize", n);
2070
+ });
2071
+ const p = c && a ? ho(c, n) : null;
2072
+ let h = -1, d = null;
2073
+ r && (d = new ResizeObserver((x) => {
2074
+ let [T] = x;
2075
+ T && T.target === c && d && (d.unobserve(t), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
2076
+ var C;
2077
+ (C = d) == null || C.observe(t);
2078
+ })), n();
2079
+ }), c && !f && d.observe(c), d.observe(t));
2080
+ let m, g = f ? he(e) : null;
2081
+ f && v();
2082
+ function v() {
2083
+ const x = he(e);
2084
+ g && !Xt(g, x) && n(), g = x, m = requestAnimationFrame(v);
1881
2085
  }
1882
- Te(() => {
1883
- const L = R.value;
1884
- !A.value || !L || (L.addEventListener("pointerdown", V), L.addEventListener("mousedown", F), L.addEventListener("click", Y), L.addEventListener("keydown", x), L.addEventListener("keyup", s), ue(() => {
1885
- L.removeEventListener("pointerdown", V), L.removeEventListener("mousedown", F), L.removeEventListener("click", Y), L.removeEventListener("keydown", x), L.removeEventListener("keyup", s), k();
1886
- }));
1887
- }), q(
1888
- () => A.value && D.value ? document : null,
1889
- () => S(g),
1890
- v,
1891
- { capture: S(m) }
1892
- ), q(
1893
- () => A.value && D.value && S(y) ? N.value : null,
1894
- "mousedown",
1895
- H,
1896
- { capture: !0 }
1897
- ), q(
1898
- () => A.value && D.value && S(y) ? N.value : null,
1899
- "mouseup",
1900
- X,
1901
- { capture: !0 }
1902
- );
2086
+ return n(), () => {
2087
+ var x;
2088
+ u.forEach((T) => {
2089
+ i && T.removeEventListener("scroll", n), l && T.removeEventListener("resize", n);
2090
+ }), p == null || p(), (x = d) == null || x.disconnect(), d = null, f && cancelAnimationFrame(m);
2091
+ };
1903
2092
  }
1904
- function xo(e, t) {
1905
- return !(J(t, e.data.refs.anchorEl.value) || J(t, e.data.refs.floatingEl.value) || st(e, t));
1906
- }
1907
- function Fo(e, t, n = {}) {
1908
- const { open: o, refs: i } = t;
1909
- let r;
1910
- const l = U({ x: null, y: null }), a = I(() => S(n.axis ?? "both")), u = I(() => S(n.enabled ?? !0)), c = I(() => S(n.x ?? null)), h = I(() => S(n.y ?? null)), f = (m, b) => {
1911
- l.value = {
1912
- x: m,
1913
- y: b
1914
- }, o.value && (i.anchorEl.value = Eo(
1915
- e.value,
1916
- a.value,
1917
- l.value
1918
- ));
2093
+ const Lo = $n, So = Vn, Ao = Hn, Mo = In, po = Fn, vo = (e, t, n) => {
2094
+ const o = /* @__PURE__ */ new Map(), i = {
2095
+ platform: fo,
2096
+ ...n
2097
+ }, l = {
2098
+ ...i.platform,
2099
+ _c: o
1919
2100
  };
1920
- pt(() => {
1921
- const m = c.value, b = h.value;
1922
- u.value && m != null && b != null && f(m, b);
2101
+ return kn(e, t, {
2102
+ ...i,
2103
+ platform: l
1923
2104
  });
1924
- const p = (m) => {
1925
- r = m.pointerType, f(m.clientX, m.clientY);
1926
- }, d = (m) => {
1927
- r = m.pointerType, !o.value && Qe(r, !0) && f(m.clientX, m.clientY);
1928
- }, g = (m) => {
1929
- o.value && Qe(r, !0) && f(m.clientX, m.clientY);
1930
- };
1931
- return pt(() => {
1932
- if (c.value != null || h.value != null) return;
1933
- const m = e.value;
1934
- !m || !u.value || (m.addEventListener("pointerenter", d), m.addEventListener("pointerdown", p), m.addEventListener("pointermove", g), ue(() => {
1935
- m == null || m.removeEventListener("pointerenter", d), m == null || m.removeEventListener("pointerdown", p), m == null || m.removeEventListener("pointermove", g);
1936
- }));
1937
- }), {
1938
- coordinates: on(l),
1939
- updatePosition: f
2105
+ };
2106
+ function Do(e, t, n = {}) {
2107
+ const { offset: o = "-4px" } = n, { middlewareData: i, placement: l, refs: r } = t;
2108
+ ne(e, (u) => {
2109
+ r.arrowEl.value = u;
2110
+ });
2111
+ const a = N(() => {
2112
+ var u;
2113
+ return ((u = i.value.arrow) == null ? void 0 : u.x) ?? 0;
2114
+ }), f = N(() => {
2115
+ var u;
2116
+ return ((u = i.value.arrow) == null ? void 0 : u.y) ?? 0;
2117
+ }), c = N(() => {
2118
+ if (!(e.value || r.arrowEl.value) || !i.value.arrow)
2119
+ return {};
2120
+ const p = A(l).split("-")[0], h = a.value, d = f.value;
2121
+ return p === "bottom" ? {
2122
+ "inset-inline-start": `${h}px`,
2123
+ "inset-block-start": o
2124
+ } : p === "top" ? {
2125
+ "inset-inline-start": `${h}px`,
2126
+ "inset-block-end": o
2127
+ } : p === "right" ? {
2128
+ "inset-block-start": `${d}px`,
2129
+ "inset-inline-start": o
2130
+ } : p === "left" ? {
2131
+ "inset-block-start": `${d}px`,
2132
+ "inset-inline-end": o
2133
+ } : {};
2134
+ });
2135
+ return {
2136
+ arrowX: a,
2137
+ arrowY: f,
2138
+ arrowStyles: c
1940
2139
  };
1941
2140
  }
1942
- function Eo(e, t, n) {
1943
- let o = null, i = null;
1944
- const r = e;
2141
+ function go(e) {
1945
2142
  return {
1946
- contextElement: r || void 0,
1947
- getBoundingClientRect: () => {
1948
- const l = (r == null ? void 0 : r.getBoundingClientRect()) ?? {
1949
- width: 0,
1950
- height: 0,
1951
- x: 0,
1952
- y: 0
1953
- }, a = t === "x" || t === "both", u = t === "y" || t === "both";
1954
- let c = 0, h = 0, f = l.x, p = l.y;
1955
- return r && (o == null && n.x != null && a && (o = l.x - n.x), i == null && n.y != null && u && (i = l.y - n.y), f -= o || 0, p -= i || 0), a && n.x != null ? f = n.x : (o = null, c = l.width), u && n.y != null ? p = n.y : (i = null, h = l.height), t === "both" && (c = 0, h = 0), {
1956
- width: c,
1957
- height: h,
1958
- x: f,
1959
- y: p,
1960
- top: p,
1961
- right: f + c,
1962
- bottom: p + h,
1963
- left: f
1964
- };
2143
+ name: "arrow",
2144
+ options: e,
2145
+ fn(t) {
2146
+ const n = A(e.element);
2147
+ return n == null ? {} : po({ element: n, padding: e.padding }).fn(t);
1965
2148
  }
1966
2149
  };
1967
2150
  }
1968
- function Ho(e) {
1969
- const { enabled: t = !0, onEscape: n, capture: o } = e, { isComposing: i } = To();
1970
- q(
1971
- document,
1972
- "keydown",
1973
- (r) => {
1974
- r.key !== "Escape" || !S(t) || i() || n(r);
2151
+ function Ot(e, t, n = {}) {
2152
+ const {
2153
+ transform: o = !0,
2154
+ middlewares: i,
2155
+ autoUpdate: l = !0,
2156
+ open: r = _(!1)
2157
+ } = n, a = (w) => {
2158
+ r.value = w;
2159
+ }, f = N(() => A(n.placement) ?? "bottom"), c = N(() => A(n.strategy) ?? "absolute"), u = _(0), p = _(0), h = _(f.value), d = _(c.value), m = je({}), g = _(!1), v = _(null), x = N(() => {
2160
+ const w = A(i) || [];
2161
+ return v.value && !w.some((P) => P.name === "arrow") ? [...w, go({ element: v })] : w;
2162
+ }), T = async () => {
2163
+ if (!e.value || !t.value) return;
2164
+ const w = await vo(e.value, t.value, {
2165
+ placement: f.value,
2166
+ strategy: c.value,
2167
+ middleware: x.value
2168
+ });
2169
+ u.value = w.x, p.value = w.y, h.value = w.placement, d.value = w.strategy, m.value = w.middlewareData, g.value = r.value;
2170
+ };
2171
+ ne([f, c, x], () => {
2172
+ r.value && T();
2173
+ });
2174
+ let C;
2175
+ ne(
2176
+ [e, t, r],
2177
+ ([w, b, P]) => {
2178
+ !P || !w || !b || (l && (C = mo(
2179
+ w,
2180
+ b,
2181
+ T,
2182
+ typeof l == "object" ? l : void 0
2183
+ )), ue(() => {
2184
+ C == null || C(), C = void 0;
2185
+ }));
1975
2186
  },
1976
- o
1977
- );
1978
- }
1979
- function To() {
1980
- const e = U(!1);
1981
- return q(document, "compositionstart", () => {
1982
- e.value = !0;
1983
- }), q(document, "compositionend", () => {
1984
- e.value = !1;
1985
- }), {
1986
- isComposing: () => e.value
2187
+ { immediate: !0 }
2188
+ ), we(() => C == null ? void 0 : C()), ne(r, (w) => {
2189
+ w || (g.value = !1);
2190
+ });
2191
+ const S = _({
2192
+ position: c.value,
2193
+ left: "0",
2194
+ top: "0"
2195
+ });
2196
+ return ne(
2197
+ [u, p, () => A(o)],
2198
+ ([w, b, P]) => {
2199
+ const F = t.value;
2200
+ if (!F) return;
2201
+ const D = {
2202
+ position: d.value,
2203
+ left: "0",
2204
+ top: "0"
2205
+ }, M = Pt(F, w), B = Pt(F, b);
2206
+ P ? S.value = {
2207
+ ...D,
2208
+ transform: `translate(${M}px, ${B}px)`,
2209
+ ...jt(F) >= 1.5 && {
2210
+ "will-change": "transform"
2211
+ }
2212
+ } : S.value = {
2213
+ ...D,
2214
+ left: `${M}px`,
2215
+ top: `${B}px`
2216
+ };
2217
+ },
2218
+ { immediate: !0 }
2219
+ ), {
2220
+ x: u,
2221
+ y: p,
2222
+ strategy: d,
2223
+ placement: h,
2224
+ middlewareData: m,
2225
+ isPositioned: g,
2226
+ floatingStyles: S,
2227
+ update: T,
2228
+ refs: {
2229
+ anchorEl: e,
2230
+ floatingEl: t,
2231
+ arrowEl: v
2232
+ },
2233
+ open: r,
2234
+ setOpen: a
1987
2235
  };
1988
2236
  }
1989
- var Le;
1990
- class Bt {
1991
- constructor(t, n = null, o = {}, i = !1) {
1992
- ce(this, "id");
1993
- ce(this, "data");
1994
- ce(this, "parent");
1995
- ce(this, "children");
1996
- Ne(this, Le);
1997
- this.id = o.id ?? to(), this.data = t, this.parent = qe(n), this.children = qe([]), Ye(this, Le, i);
1998
- }
1999
- /**
2000
- * Adds an existing node instance to this node's children array.
2001
- * @internal
2002
- * @param childNode The TreeNode instance to add.
2003
- */
2004
- addChild(t) {
2005
- this.children.value = [...this.children.value, t];
2006
- }
2007
- /**
2008
- * Removes a specific child node instance from this node's children.
2009
- * @internal
2010
- * Note: This only removes the direct child link. Use the Tree's `removeNode` method for full removal including map updates and recursive deletion.
2011
- * @param childNode The child node instance to remove.
2012
- * @returns True if the child was found and removed, false otherwise.
2013
- */
2014
- _removeChildInstance(t) {
2015
- return this.children.value.includes(t) ? (this.children.value = this.children.value.filter((n) => n.id !== t.id), t.parent.value = null, !0) : !1;
2016
- }
2017
- /**
2018
- * Finds the first direct child matching the predicate.
2019
- * @param predicate Function to test each child node.
2020
- * @returns The matching child node or null if not found.
2021
- */
2022
- findChild(t) {
2023
- return this.children.value.find(t) ?? null;
2024
- }
2025
- /**
2026
- * Finds the first descendant node (including self) matching the predicate using DFS.
2027
- * @param predicate Function to test each node.
2028
- * @returns The matching descendant node or null if not found.
2029
- */
2030
- findDescendant(t) {
2031
- const n = [this];
2032
- for (; n.length > 0; ) {
2033
- const o = n.pop();
2034
- if (t(o))
2035
- return o;
2036
- for (let i = o.children.value.length - 1; i >= 0; i--)
2037
- n.push(o.children.value[i]);
2038
- }
2039
- return null;
2040
- }
2041
- /**
2042
- * Checks if this node is a descendant of the potential ancestor.
2043
- * @param potentialAncestor The node to check against.
2044
- * @returns True if this node is a descendant, false otherwise.
2045
- */
2046
- isDescendantOf(t) {
2047
- let n = this.parent.value;
2048
- for (; n; ) {
2049
- if (n.id === t.id)
2050
- return !0;
2051
- n = n.parent.value;
2237
+ function Pt(e, t) {
2238
+ const n = jt(e);
2239
+ return Math.round(t * n) / n;
2240
+ }
2241
+ function jt(e) {
2242
+ return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
2243
+ }
2244
+ function No(e, t, n = {}, o = {}) {
2245
+ const { ...i } = n, l = Ot(e, t, i), r = wo(l, o);
2246
+ return {
2247
+ ...r,
2248
+ addNode: (p, h, d = {}) => {
2249
+ const { parentId: m, ...g } = d, v = Ot(p, h, g);
2250
+ return r.addNode(v, m);
2251
+ },
2252
+ getAllOpenNodes: () => {
2253
+ const p = [];
2254
+ for (const h of r.nodeMap.values())
2255
+ h.data.open.value && p.push(h);
2256
+ return p;
2257
+ },
2258
+ getTopmostOpenNode: () => {
2259
+ let p = null, h = -1;
2260
+ for (const d of r.nodeMap.values())
2261
+ if (d.data.open.value) {
2262
+ const m = d.getPath().length;
2263
+ m > h && (h = m, p = d);
2264
+ }
2265
+ return p;
2266
+ },
2267
+ applyToNodes: (p, h, d = {}) => {
2268
+ const { relationship: m = "self-and-children", applyToMatching: g = !0 } = d, v = r.findNodeById(p);
2269
+ if (!v)
2270
+ return;
2271
+ const x = [], T = /* @__PURE__ */ new Set(), C = (w) => {
2272
+ w && !T.has(w.id) && (x.push(w), T.add(w.id));
2273
+ }, S = (w) => {
2274
+ for (const b of w)
2275
+ C(b);
2276
+ };
2277
+ if (m === "ancestors-only")
2278
+ for (const w of v.getPath())
2279
+ w.id !== v.id && C(w);
2280
+ else if (m === "siblings-only") {
2281
+ if (v.parent.value)
2282
+ for (const w of v.parent.value.children.value)
2283
+ w.id !== v.id && C(w);
2284
+ } else if (m === "descendants-only")
2285
+ for (const w of r.traverse("dfs", v))
2286
+ w.id !== v.id && C(w);
2287
+ else if (m === "children-only")
2288
+ S(v.children.value);
2289
+ else if (m === "self-and-ancestors")
2290
+ S(v.getPath());
2291
+ else if (m === "self-and-children")
2292
+ C(v), S(v.children.value);
2293
+ else if (m === "self-and-descendants")
2294
+ S(r.traverse("dfs", v));
2295
+ else if (m === "self-and-siblings")
2296
+ C(v), v.parent.value && S(v.parent.value.children.value);
2297
+ else if (m === "self-ancestors-and-children")
2298
+ S(v.getPath()), S(v.children.value);
2299
+ else if (m === "full-branch")
2300
+ S(v.getPath()), S(r.traverse("dfs", v));
2301
+ else if (m === "all-except-branch") {
2302
+ const w = /* @__PURE__ */ new Set();
2303
+ for (const b of v.getPath())
2304
+ w.add(b.id);
2305
+ for (const b of r.traverse("dfs", v))
2306
+ w.add(b.id);
2307
+ for (const b of r.nodeMap.values())
2308
+ !w.has(b.id) === g && h(b);
2309
+ return;
2310
+ } else {
2311
+ console.warn(`applyToNodes: Unknown relationship "${m}".`);
2312
+ return;
2313
+ }
2314
+ if (g)
2315
+ for (const w of x)
2316
+ h(w);
2317
+ else
2318
+ for (const w of r.nodeMap.values())
2319
+ T.has(w.id) || h(w);
2052
2320
  }
2053
- return !1;
2054
- }
2055
- /**
2056
- * Gets the path of nodes from the root to this node.
2057
- * @returns An array of nodes starting with the root and ending with this node.
2058
- */
2059
- getPath() {
2060
- const t = [];
2061
- let n = this;
2062
- for (; n; )
2063
- t.push(n), n = n.parent.value;
2064
- return t.reverse();
2065
- }
2066
- /** Checks if the node is the true root of the tree, distinct from an orphaned node. */
2067
- get isRoot() {
2068
- return Xe(this, Le);
2069
- }
2070
- /** Checks if the node is a leaf node (has no children). */
2071
- get isLeaf() {
2072
- return this.children.value.length === 0;
2073
- }
2321
+ };
2074
2322
  }
2075
- Le = new WeakMap();
2076
- var Pe, Oe, Ze;
2077
- class Co {
2078
- /**
2079
- * Creates a new Tree instance.
2080
- * @param initialRootData Data for the root node.
2081
- * @param options Configuration options for the tree behavior.
2082
- *
2083
- * @example
2084
- * ```ts
2085
- * const myTree = new Tree({ name: 'Root' });
2086
- * const childNode = myTree.addNode({ name: 'Child' }, myTree.root.id);
2087
- * ```
2088
- */
2089
- constructor(t, n) {
2090
- Ne(this, Oe);
2091
- /** The root node of the tree. */
2092
- ce(this, "root");
2093
- /** Readonly reactive map of node IDs to TreeNode instances for quick lookups. */
2094
- ce(this, "nodeMap");
2095
- Ne(this, Pe);
2096
- Ye(this, Pe, (n == null ? void 0 : n.deleteStrategy) ?? "recursive"), this.nodeMap = rn(/* @__PURE__ */ new Map()), this.root = new Bt(t, null, {}, !0), this.nodeMap.set(this.root.id, this.root);
2097
- }
2098
- /**
2099
- * Finds a node anywhere in the tree by its ID.
2100
- * @param id The ID of the node to find.
2101
- * @returns The node if found, otherwise null.
2102
- */
2103
- findNodeById(t) {
2104
- return this.nodeMap.get(t) ?? null;
2105
- }
2106
- /**
2107
- * Adds a new node to the tree.
2108
- * @param data The data for the new node.
2109
- * @param parentId The ID of the parent node. If null or undefined, adds to the root.
2110
- * @param nodeOptions Optional configuration for the new node (e.g., custom ID).
2111
- * @returns The newly created TreeNode, or null if the parent was not found.
2112
- */
2113
- addNode(t, n = null, o = {}) {
2114
- const i = n ? this.findNodeById(n) : this.root;
2115
- if (!i)
2116
- return console.error(`Tree addNode: Parent node with ID ${n} not found.`), null;
2117
- o.id && this.nodeMap.has(o.id) && (o.id = void 0);
2118
- const r = new Bt(t, i, o);
2119
- return this.nodeMap.set(r.id, r), i.addChild(r), r;
2120
- }
2121
- /**
2122
- * Removes a node from the tree by its ID.
2123
- * Handles deletion of descendants based on the provided strategy or the tree's default.
2124
- * @param nodeId The ID of the node to remove.
2125
- * @param deleteStrategy Optional strategy override. If not provided, uses the tree's default strategy.
2126
- * @returns True if the node was successfully removed, false otherwise.
2127
- */
2128
- removeNode(t, n) {
2129
- const o = n ?? Xe(this, Pe), i = this.findNodeById(t);
2130
- if (!i)
2323
+ function Lt(e, t = null, n = {}, o = !1) {
2324
+ const i = n.id ?? wn(), l = je(t), r = je([]), a = N(() => r.value.length === 0), f = {
2325
+ id: i,
2326
+ data: e,
2327
+ parent: l,
2328
+ children: r,
2329
+ isRoot: o,
2330
+ isLeaf: a,
2331
+ addChild: (c) => {
2332
+ r.value = [...r.value, c];
2333
+ },
2334
+ _removeChildInstance: (c) => r.value.includes(c) ? (r.value = r.value.filter((u) => u.id !== c.id), c.parent.value = null, !0) : !1,
2335
+ findChild: (c) => r.value.find(c) ?? null,
2336
+ findDescendant: (c) => {
2337
+ const u = [f];
2338
+ for (; u.length > 0; ) {
2339
+ const p = u.pop();
2340
+ if (c(p))
2341
+ return p;
2342
+ for (let h = p.children.value.length - 1; h >= 0; h--)
2343
+ u.push(p.children.value[h]);
2344
+ }
2345
+ return null;
2346
+ },
2347
+ isDescendantOf: (c) => {
2348
+ let u = l.value;
2349
+ for (; u; ) {
2350
+ if (u.id === c.id)
2351
+ return !0;
2352
+ u = u.parent.value;
2353
+ }
2354
+ return !1;
2355
+ },
2356
+ getPath: () => {
2357
+ const c = [];
2358
+ let u = f;
2359
+ for (; u; )
2360
+ c.push(u), u = u.parent.value;
2361
+ return c.reverse();
2362
+ }
2363
+ };
2364
+ return Object.freeze(f);
2365
+ }
2366
+ function wo(e, t) {
2367
+ const n = (t == null ? void 0 : t.deleteStrategy) ?? "recursive", o = Jt(/* @__PURE__ */ new Map()), i = Lt(e, null, {}, !0);
2368
+ o.set(i.id, i);
2369
+ const l = (h) => o.get(h) ?? null, r = (h, d = null, m = {}) => {
2370
+ const g = d ? l(d) : i;
2371
+ if (!g)
2372
+ return console.error(`Tree addNode: Parent node with ID ${d} not found.`), null;
2373
+ m.id && o.has(m.id) && (m.id = void 0);
2374
+ const v = Lt(h, g, m);
2375
+ return o.set(v.id, v), g.addChild(v), v;
2376
+ }, a = (h, d) => {
2377
+ const m = d ?? n, g = l(h);
2378
+ if (!g)
2131
2379
  return !1;
2132
- if (i.isRoot)
2380
+ if (g.isRoot)
2133
2381
  return console.error("Tree removeNode: Cannot remove the root node."), !1;
2134
- const r = i.parent.value;
2135
- if (o === "recursive")
2136
- je(this, Oe, Ze).call(this, i);
2382
+ const v = g.parent.value;
2383
+ if (m === "recursive")
2384
+ p(g);
2137
2385
  else {
2138
- for (const l of i.children.value)
2139
- l.parent.value = null;
2140
- i.children.value = [], this.nodeMap.delete(i.id);
2386
+ for (const x of g.children.value)
2387
+ x.parent.value = null;
2388
+ g.children.value = [], o.delete(g.id);
2141
2389
  }
2142
- return r._removeChildInstance(i);
2143
- }
2144
- /**
2145
- * Moves a node to become a child of a new parent.
2146
- * @param nodeId The ID of the node to move.
2147
- * @param newParentId The ID of the new parent node. Set to null to move to the root level.
2148
- * @returns True if the node was successfully moved, false otherwise.
2149
- */
2150
- moveNode(t, n) {
2151
- const o = this.findNodeById(t);
2152
- if (!o)
2153
- return console.error(`Tree moveNode: Node with ID ${t} not found.`), !1;
2154
- if (o.isRoot)
2390
+ return v._removeChildInstance(g);
2391
+ }, f = (h, d) => {
2392
+ const m = l(h);
2393
+ if (!m)
2394
+ return console.error(`Tree moveNode: Node with ID ${h} not found.`), !1;
2395
+ if (m.isRoot)
2155
2396
  return console.error("Tree moveNode: Cannot move the root node."), !1;
2156
- if (t === n)
2397
+ if (h === d)
2157
2398
  return console.error("Tree moveNode: Cannot move a node to be a child of itself."), !1;
2158
- const i = n ? this.findNodeById(n) : this.root;
2159
- if (!i)
2160
- return console.error(`Tree moveNode: New parent node with ID ${n} not found.`), !1;
2161
- if (i.isDescendantOf(o))
2399
+ const g = d ? l(d) : i;
2400
+ if (!g)
2401
+ return console.error(`Tree moveNode: New parent node with ID ${d} not found.`), !1;
2402
+ if (g.isDescendantOf(m))
2162
2403
  return console.error("Tree moveNode: Cannot move a node to become its own descendant."), !1;
2163
- const r = o.parent.value;
2164
- if (r) {
2165
- if (!r._removeChildInstance(o))
2404
+ const v = m.parent.value;
2405
+ if (v) {
2406
+ if (!v._removeChildInstance(m))
2166
2407
  return console.error("Tree moveNode: Failed to remove node from its original parent."), !1;
2167
- } else if (o.isRoot) {
2168
- if (o.isRoot)
2408
+ } else if (m.isRoot) {
2409
+ if (m.isRoot)
2169
2410
  return console.error("Tree moveNode: Attempting to move the root node, which is not allowed."), !1;
2170
2411
  }
2171
- return i.addChild(o), o.parent.value = i, !0;
2172
- }
2173
- /**
2174
- * Traverses the tree using either Depth-First Search (DFS) or Breadth-First Search (BFS).
2175
- * @param strategy The traversal strategy ('dfs' or 'bfs'). Defaults to 'dfs'.
2176
- * @param startNode The node to start traversal from. Defaults to the root node.
2177
- * @returns An array of nodes in the order they were visited.
2178
- */
2179
- traverse(t = "dfs", n = this.root) {
2180
- const o = [];
2181
- if (!n)
2182
- return console.warn("Tree traverse: Start node is null, returning empty array."), o;
2183
- if (t === "dfs") {
2184
- const i = [n];
2185
- for (; i.length > 0; ) {
2186
- const r = i.pop();
2187
- o.push(r);
2188
- for (let l = r.children.value.length - 1; l >= 0; l--)
2189
- i.push(r.children.value[l]);
2412
+ return g.addChild(m), m.parent.value = g, !0;
2413
+ }, c = (h = "dfs", d = i) => {
2414
+ const m = [];
2415
+ if (!d)
2416
+ return console.warn("Tree traverse: Start node is null, returning empty array."), m;
2417
+ if (h === "dfs") {
2418
+ const g = [d];
2419
+ for (; g.length > 0; ) {
2420
+ const v = g.pop();
2421
+ m.push(v);
2422
+ for (let x = v.children.value.length - 1; x >= 0; x--)
2423
+ g.push(v.children.value[x]);
2190
2424
  }
2191
2425
  } else {
2192
- const i = [n];
2193
- for (; i.length > 0; ) {
2194
- const r = i.shift();
2195
- o.push(r);
2196
- for (const l of r.children.value)
2197
- i.push(l);
2426
+ const g = [d];
2427
+ for (; g.length > 0; ) {
2428
+ const v = g.shift();
2429
+ m.push(v);
2430
+ for (const x of v.children.value)
2431
+ g.push(x);
2198
2432
  }
2199
2433
  }
2200
- return o;
2201
- }
2202
- /**
2203
- * Clears the internal node map. This is crucial for allowing garbage collection
2204
- * when the Tree instance is no longer needed, especially in scenarios like
2205
- * Vue components where the instance might be tied to the component lifecycle.
2206
- * Call this method when you are finished with the Tree instance (e.g., in `onScopeDispose`).
2207
- */
2208
- dispose() {
2209
- this.nodeMap.clear();
2210
- }
2211
- }
2212
- Pe = new WeakMap(), Oe = new WeakSet(), // --- Internal Recursive Helper for Deletion/Cleanup ---
2213
- Ze = function(t) {
2214
- const n = [...t.children.value];
2215
- for (const o of n)
2216
- je(this, Oe, Ze).call(this, o);
2217
- this.nodeMap.delete(t.id), t.children.value = [];
2218
- };
2219
- function Bo(e, t, n = {}, o = {}) {
2220
- const { parentId: i, ...r } = n, l = Lt(e, t, r), a = new Co(l, o);
2221
- return {
2222
- // Wrap original Tree methods in arrow functions to preserve context
2223
- get nodeMap() {
2224
- return a.nodeMap;
2225
- },
2434
+ return m;
2435
+ }, u = () => {
2436
+ o.clear();
2437
+ }, p = (h) => {
2438
+ const d = [...h.children.value];
2439
+ for (const m of d)
2440
+ p(m);
2441
+ o.delete(h.id), h.children.value = [];
2442
+ };
2443
+ return Object.freeze({
2226
2444
  get root() {
2227
- return a.root;
2228
- },
2229
- findNodeById: (w) => a.findNodeById(w),
2230
- moveNode: (w, y) => a.moveNode(w, y),
2231
- dispose: () => {
2232
- a.dispose();
2445
+ return i;
2233
2446
  },
2234
- addNode: (w, y, C = {}) => {
2235
- const { parentId: P, ...E } = C, T = Lt(w, y, E);
2236
- return a.addNode(T, P);
2237
- },
2238
- removeNode: (w, y) => a.removeNode(w, y),
2239
- traverse: (w, y) => a.traverse(w, y),
2240
- getAllOpenNodes: () => {
2241
- const w = [];
2242
- for (const y of a.nodeMap.values())
2243
- y.data.open.value && w.push(y);
2244
- return w;
2245
- },
2246
- getTopmostOpenNode: () => {
2247
- let w = null, y = -1;
2248
- for (const C of a.nodeMap.values())
2249
- if (C.data.open.value) {
2250
- const P = C.getPath().length;
2251
- P > y && (y = P, w = C);
2252
- }
2253
- return w;
2447
+ get nodeMap() {
2448
+ return o;
2254
2449
  },
2255
- forEach: (w, y, C = {}) => {
2256
- const { relationship: P = "self-and-children", applyToMatching: E = !0 } = C, T = a.findNodeById(w);
2257
- if (!T)
2258
- return;
2259
- const A = [], D = /* @__PURE__ */ new Set(), R = (M) => {
2260
- M && !D.has(M.id) && (A.push(M), D.add(M.id));
2261
- }, N = (M) => {
2262
- for (const k of M)
2263
- R(k);
2264
- };
2265
- if (P === "ancestors-only")
2266
- for (const M of T.getPath())
2267
- M.id !== T.id && R(M);
2268
- else if (P === "siblings-only") {
2269
- if (T.parent.value)
2270
- for (const M of T.parent.value.children.value)
2271
- M.id !== T.id && R(M);
2272
- } else if (P === "descendants-only")
2273
- for (const M of a.traverse("dfs", T))
2274
- M.id !== T.id && R(M);
2275
- else if (P === "children-only")
2276
- N(T.children.value);
2277
- else if (P === "self-and-ancestors")
2278
- N(T.getPath());
2279
- else if (P === "self-and-children")
2280
- R(T), N(T.children.value);
2281
- else if (P === "self-and-descendants")
2282
- N(a.traverse("dfs", T));
2283
- else if (P === "self-and-siblings")
2284
- R(T), T.parent.value && N(T.parent.value.children.value);
2285
- else if (P === "self-ancestors-and-children")
2286
- N(T.getPath()), N(T.children.value);
2287
- else if (P === "full-branch")
2288
- N(T.getPath()), N(a.traverse("dfs", T));
2289
- else if (P === "all-except-branch") {
2290
- const M = /* @__PURE__ */ new Set();
2291
- for (const k of T.getPath())
2292
- M.add(k.id);
2293
- for (const k of a.traverse("dfs", T))
2294
- M.add(k.id);
2295
- for (const k of a.nodeMap.values())
2296
- !M.has(k.id) === E && y(k);
2297
- return;
2298
- } else {
2299
- console.warn(`forEach: Unknown relationship "${P}".`);
2300
- return;
2301
- }
2302
- if (E)
2303
- for (const M of A)
2304
- y(M);
2305
- else
2306
- for (const M of a.nodeMap.values())
2307
- D.has(M.id) || y(M);
2308
- }
2309
- };
2450
+ findNodeById: l,
2451
+ addNode: r,
2452
+ removeNode: a,
2453
+ moveNode: f,
2454
+ traverse: c,
2455
+ dispose: u
2456
+ });
2310
2457
  }
2311
2458
  export {
2312
- Co as Tree,
2313
- Bt as TreeNode,
2314
- kt as clearTimeoutIfSet,
2315
- ze as contains,
2316
- st as findDescendantContainingTarget,
2317
- So as flip,
2318
- rt as getContextFromParameter,
2319
- Rt as getCurrentTime,
2320
- lo as getTarget,
2321
- Ao as hide,
2322
- Mt as isButtonTarget,
2323
- ro as isClickOnScrollbar,
2324
- At as isEventTargetWithin,
2325
- oo as isHTMLElement,
2326
- Nt as isMac,
2327
- Qe as isMouseLikePointerType,
2328
- Dt as isSafari,
2329
- St as isSpaceIgnored,
2459
+ dt as clearTimeoutIfSet,
2460
+ Ve as contains,
2461
+ wo as createTree,
2462
+ Lt as createTreeNode,
2463
+ Ke as findDescendantContainingTarget,
2464
+ Ao as flip,
2465
+ Fe as getContextFromParameter,
2466
+ ft as getCurrentTime,
2467
+ cn as getTarget,
2468
+ Mo as hide,
2469
+ at as isButtonTarget,
2470
+ an as isClickOnScrollbar,
2471
+ ut as isEventTargetWithin,
2472
+ ln as isHTMLElement,
2473
+ st as isMac,
2474
+ St as isMouseLikePointerType,
2475
+ lt as isSafari,
2476
+ ct as isSpaceIgnored,
2330
2477
  J as isTargetWithinElement,
2331
- no as isTreeNode,
2332
- Kt as isTypeableElement,
2333
- io as isVirtualElement,
2334
- so as matchesFocusVisible,
2335
- Oo as offset,
2336
- Mo as shift,
2337
- No as useArrow,
2338
- ko as useClick,
2339
- Fo as useClientPoint,
2340
- Ho as useEscapeKey,
2341
- Lt as useFloating,
2342
- Bo as useFloatingTree,
2343
- Ro as useFocus,
2344
- Do as useHover
2478
+ un as isTreeNode,
2479
+ At as isTypeableElement,
2480
+ xo as isVirtualElement,
2481
+ sn as matchesFocusVisible,
2482
+ Lo as offset,
2483
+ So as shift,
2484
+ Do as useArrow,
2485
+ Eo as useClick,
2486
+ Co as useClientPoint,
2487
+ To as useEscapeKey,
2488
+ Ot as useFloating,
2489
+ No as useFloatingTree,
2490
+ Oo as useFocus,
2491
+ Po as useHover
2345
2492
  };