@thanh-libs/menu 0.0.2

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2413 -0
  5. package/dist/lib/components/Menu.d.ts +23 -0
  6. package/dist/lib/components/Menu.d.ts.map +1 -0
  7. package/dist/lib/components/MenuDivider.d.ts +9 -0
  8. package/dist/lib/components/MenuDivider.d.ts.map +1 -0
  9. package/dist/lib/components/MenuGroup.d.ts +9 -0
  10. package/dist/lib/components/MenuGroup.d.ts.map +1 -0
  11. package/dist/lib/components/MenuItem.d.ts +8 -0
  12. package/dist/lib/components/MenuItem.d.ts.map +1 -0
  13. package/dist/lib/components/MenuLabel.d.ts +9 -0
  14. package/dist/lib/components/MenuLabel.d.ts.map +1 -0
  15. package/dist/lib/components/MenuSub.d.ts +39 -0
  16. package/dist/lib/components/MenuSub.d.ts.map +1 -0
  17. package/dist/lib/components/MenuSubContent.d.ts +7 -0
  18. package/dist/lib/components/MenuSubContent.d.ts.map +1 -0
  19. package/dist/lib/components/MenuSubContentInline.d.ts +2 -0
  20. package/dist/lib/components/MenuSubContentInline.d.ts.map +1 -0
  21. package/dist/lib/components/MenuSubContentPopover.d.ts +2 -0
  22. package/dist/lib/components/MenuSubContentPopover.d.ts.map +1 -0
  23. package/dist/lib/components/MenuSubTrigger.d.ts +8 -0
  24. package/dist/lib/components/MenuSubTrigger.d.ts.map +1 -0
  25. package/dist/lib/components/index.d.ts +9 -0
  26. package/dist/lib/components/index.d.ts.map +1 -0
  27. package/dist/lib/constants/index.d.ts +35 -0
  28. package/dist/lib/constants/index.d.ts.map +1 -0
  29. package/dist/lib/helpers/index.d.ts +24 -0
  30. package/dist/lib/helpers/index.d.ts.map +1 -0
  31. package/dist/lib/hooks/useMenuContext.d.ts +21 -0
  32. package/dist/lib/hooks/useMenuContext.d.ts.map +1 -0
  33. package/dist/lib/hooks/useMenuKeyboard.d.ts +4 -0
  34. package/dist/lib/hooks/useMenuKeyboard.d.ts.map +1 -0
  35. package/dist/lib/models/index.d.ts +156 -0
  36. package/dist/lib/models/index.d.ts.map +1 -0
  37. package/dist/lib/styled/Menu.styled.d.ts +11 -0
  38. package/dist/lib/styled/Menu.styled.d.ts.map +1 -0
  39. package/dist/lib/styled/MenuDivider.styled.d.ts +10 -0
  40. package/dist/lib/styled/MenuDivider.styled.d.ts.map +1 -0
  41. package/dist/lib/styled/MenuIndicator.styled.d.ts +18 -0
  42. package/dist/lib/styled/MenuIndicator.styled.d.ts.map +1 -0
  43. package/dist/lib/styled/MenuItem.styled.d.ts +38 -0
  44. package/dist/lib/styled/MenuItem.styled.d.ts.map +1 -0
  45. package/dist/lib/styled/MenuLabel.styled.d.ts +10 -0
  46. package/dist/lib/styled/MenuLabel.styled.d.ts.map +1 -0
  47. package/dist/lib/styled/MenuSub.styled.d.ts +26 -0
  48. package/dist/lib/styled/MenuSub.styled.d.ts.map +1 -0
  49. package/dist/lib/styled/index.d.ts +7 -0
  50. package/dist/lib/styled/index.d.ts.map +1 -0
  51. package/package.json +69 -0
package/dist/index.js ADDED
@@ -0,0 +1,2413 @@
1
+ import { jsxs as $e, jsx as O, Fragment as In } from "react/jsx-runtime";
2
+ import * as d from "react";
3
+ import { useLayoutEffect as Tn, createContext as Xt, useContext as Be, useRef as Re, useCallback as J, useEffect as qe, forwardRef as Ae, useMemo as gt, useState as Ye, useId as bt } from "react";
4
+ import * as kn from "react-dom";
5
+ import { useTheme as de } from "@emotion/react";
6
+ import re from "@emotion/styled";
7
+ import { useFloatingPosition as Mn } from "@thanh-libs/dialog";
8
+ function Je() {
9
+ return typeof window < "u";
10
+ }
11
+ function Qe(e) {
12
+ return vt(e) ? (e.nodeName || "").toLowerCase() : "#document";
13
+ }
14
+ function De(e) {
15
+ var t;
16
+ return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
17
+ }
18
+ function Pn(e) {
19
+ var t;
20
+ return (t = (vt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
21
+ }
22
+ function vt(e) {
23
+ return Je() ? e instanceof Node || e instanceof De(e).Node : !1;
24
+ }
25
+ function ge(e) {
26
+ return Je() ? e instanceof Element || e instanceof De(e).Element : !1;
27
+ }
28
+ function fe(e) {
29
+ return Je() ? e instanceof HTMLElement || e instanceof De(e).HTMLElement : !1;
30
+ }
31
+ function Fe(e) {
32
+ return !Je() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof De(e).ShadowRoot;
33
+ }
34
+ function jt(e) {
35
+ const {
36
+ overflow: t,
37
+ overflowX: n,
38
+ overflowY: r,
39
+ display: o
40
+ } = Gt(e);
41
+ return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && o !== "inline" && o !== "contents";
42
+ }
43
+ let rt;
44
+ function An() {
45
+ return rt == null && (rt = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), rt;
46
+ }
47
+ function Ue(e) {
48
+ return /^(html|body|#document)$/.test(Qe(e));
49
+ }
50
+ function Gt(e) {
51
+ return De(e).getComputedStyle(e);
52
+ }
53
+ function Zt(e) {
54
+ if (Qe(e) === "html")
55
+ return e;
56
+ const t = (
57
+ // Step into the shadow DOM of the parent of a slotted node.
58
+ e.assignedSlot || // DOM Element detected.
59
+ e.parentNode || // ShadowRoot detected.
60
+ Fe(e) && e.host || // Fallback.
61
+ Pn(e)
62
+ );
63
+ return Fe(t) ? t.host : t;
64
+ }
65
+ function zt(e) {
66
+ const t = Zt(e);
67
+ return Ue(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : fe(t) && jt(t) ? t : zt(t);
68
+ }
69
+ function Oe(e, t, n) {
70
+ var r;
71
+ t === void 0 && (t = []), n === void 0 && (n = !0);
72
+ const o = zt(e), s = o === ((r = e.ownerDocument) == null ? void 0 : r.body), i = De(o);
73
+ if (s) {
74
+ const u = Dn(i);
75
+ return t.concat(i, i.visualViewport || [], jt(o) ? o : [], u && n ? Oe(u) : []);
76
+ } else
77
+ return t.concat(o, Oe(o, [], n));
78
+ }
79
+ function Dn(e) {
80
+ return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
81
+ }
82
+ var On = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], Xe = /* @__PURE__ */ On.join(","), Jt = typeof Element > "u", ke = Jt ? function() {
83
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, je = !Jt && Element.prototype.getRootNode ? function(e) {
84
+ var t;
85
+ return e == null || (t = e.getRootNode) === null || t === void 0 ? void 0 : t.call(e);
86
+ } : function(e) {
87
+ return e?.ownerDocument;
88
+ }, Ge = function(t, n) {
89
+ var r;
90
+ n === void 0 && (n = !0);
91
+ var o = t == null || (r = t.getAttribute) === null || r === void 0 ? void 0 : r.call(t, "inert"), s = o === "" || o === "true", i = s || n && t && // closest does not exist on shadow roots, so we fall back to a manual
92
+ // lookup upward, in case it is not defined.
93
+ (typeof t.closest == "function" ? t.closest("[inert]") : Ge(t.parentNode));
94
+ return i;
95
+ }, Nn = function(t) {
96
+ var n, r = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
97
+ return r === "" || r === "true";
98
+ }, Qt = function(t, n, r) {
99
+ if (Ge(t))
100
+ return [];
101
+ var o = Array.prototype.slice.apply(t.querySelectorAll(Xe));
102
+ return n && ke.call(t, Xe) && o.unshift(t), o = o.filter(r), o;
103
+ }, Ze = function(t, n, r) {
104
+ for (var o = [], s = Array.from(t); s.length; ) {
105
+ var i = s.shift();
106
+ if (!Ge(i, !1))
107
+ if (i.tagName === "SLOT") {
108
+ var u = i.assignedElements(), l = u.length ? u : i.children, c = Ze(l, !0, r);
109
+ r.flatten ? o.push.apply(o, c) : o.push({
110
+ scopeParent: i,
111
+ candidates: c
112
+ });
113
+ } else {
114
+ var p = ke.call(i, Xe);
115
+ p && r.filter(i) && (n || !t.includes(i)) && o.push(i);
116
+ var g = i.shadowRoot || // check for an undisclosed shadow
117
+ typeof r.getShadowRoot == "function" && r.getShadowRoot(i), v = !Ge(g, !1) && (!r.shadowRootFilter || r.shadowRootFilter(i));
118
+ if (g && v) {
119
+ var h = Ze(g === !0 ? i.children : g.children, !0, r);
120
+ r.flatten ? o.push.apply(o, h) : o.push({
121
+ scopeParent: i,
122
+ candidates: h
123
+ });
124
+ } else
125
+ s.unshift.apply(s, i.children);
126
+ }
127
+ }
128
+ return o;
129
+ }, en = function(t) {
130
+ return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
131
+ }, tn = function(t) {
132
+ if (!t)
133
+ throw new Error("No node provided");
134
+ return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || Nn(t)) && !en(t) ? 0 : t.tabIndex;
135
+ }, Ln = function(t, n) {
136
+ var r = tn(t);
137
+ return r < 0 && n && !en(t) ? 0 : r;
138
+ }, Fn = function(t, n) {
139
+ return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
140
+ }, nn = function(t) {
141
+ return t.tagName === "INPUT";
142
+ }, _n = function(t) {
143
+ return nn(t) && t.type === "hidden";
144
+ }, $n = function(t) {
145
+ var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
146
+ return r.tagName === "SUMMARY";
147
+ });
148
+ return n;
149
+ }, Bn = function(t, n) {
150
+ for (var r = 0; r < t.length; r++)
151
+ if (t[r].checked && t[r].form === n)
152
+ return t[r];
153
+ }, Kn = function(t) {
154
+ if (!t.name)
155
+ return !0;
156
+ var n = t.form || je(t), r = function(u) {
157
+ return n.querySelectorAll('input[type="radio"][name="' + u + '"]');
158
+ }, o;
159
+ if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
160
+ o = r(window.CSS.escape(t.name));
161
+ else
162
+ try {
163
+ o = r(t.name);
164
+ } catch (i) {
165
+ return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", i.message), !1;
166
+ }
167
+ var s = Bn(o, t.form);
168
+ return !s || s === t;
169
+ }, Wn = function(t) {
170
+ return nn(t) && t.type === "radio";
171
+ }, Hn = function(t) {
172
+ return Wn(t) && !Kn(t);
173
+ }, Vn = function(t) {
174
+ var n, r = t && je(t), o = (n = r) === null || n === void 0 ? void 0 : n.host, s = !1;
175
+ if (r && r !== t) {
176
+ var i, u, l;
177
+ for (s = !!((i = o) !== null && i !== void 0 && (u = i.ownerDocument) !== null && u !== void 0 && u.contains(o) || t != null && (l = t.ownerDocument) !== null && l !== void 0 && l.contains(t)); !s && o; ) {
178
+ var c, p, g;
179
+ r = je(o), o = (c = r) === null || c === void 0 ? void 0 : c.host, s = !!((p = o) !== null && p !== void 0 && (g = p.ownerDocument) !== null && g !== void 0 && g.contains(o));
180
+ }
181
+ }
182
+ return s;
183
+ }, St = function(t) {
184
+ var n = t.getBoundingClientRect(), r = n.width, o = n.height;
185
+ return r === 0 && o === 0;
186
+ }, Un = function(t, n) {
187
+ var r = n.displayCheck, o = n.getShadowRoot;
188
+ if (r === "full-native" && "checkVisibility" in t) {
189
+ var s = t.checkVisibility({
190
+ // Checking opacity might be desirable for some use cases, but natively,
191
+ // opacity zero elements _are_ focusable and tabbable.
192
+ checkOpacity: !1,
193
+ opacityProperty: !1,
194
+ contentVisibilityAuto: !0,
195
+ visibilityProperty: !0,
196
+ // This is an alias for `visibilityProperty`. Contemporary browsers
197
+ // support both. However, this alias has wider browser support (Chrome
198
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
199
+ // we include it anyway.
200
+ checkVisibilityCSS: !0
201
+ });
202
+ return !s;
203
+ }
204
+ if (getComputedStyle(t).visibility === "hidden")
205
+ return !0;
206
+ var i = ke.call(t, "details>summary:first-of-type"), u = i ? t.parentElement : t;
207
+ if (ke.call(u, "details:not([open]) *"))
208
+ return !0;
209
+ if (!r || r === "full" || // full-native can run this branch when it falls through in case
210
+ // Element#checkVisibility is unsupported
211
+ r === "full-native" || r === "legacy-full") {
212
+ if (typeof o == "function") {
213
+ for (var l = t; t; ) {
214
+ var c = t.parentElement, p = je(t);
215
+ if (c && !c.shadowRoot && o(c) === !0)
216
+ return St(t);
217
+ t.assignedSlot ? t = t.assignedSlot : !c && p !== t.ownerDocument ? t = p.host : t = c;
218
+ }
219
+ t = l;
220
+ }
221
+ if (Vn(t))
222
+ return !t.getClientRects().length;
223
+ if (r !== "legacy-full")
224
+ return !0;
225
+ } else if (r === "non-zero-area")
226
+ return St(t);
227
+ return !1;
228
+ }, qn = function(t) {
229
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
230
+ for (var n = t.parentElement; n; ) {
231
+ if (n.tagName === "FIELDSET" && n.disabled) {
232
+ for (var r = 0; r < n.children.length; r++) {
233
+ var o = n.children.item(r);
234
+ if (o.tagName === "LEGEND")
235
+ return ke.call(n, "fieldset[disabled] *") ? !0 : !o.contains(t);
236
+ }
237
+ return !0;
238
+ }
239
+ n = n.parentElement;
240
+ }
241
+ return !1;
242
+ }, ft = function(t, n) {
243
+ return !(n.disabled || _n(n) || Un(n, t) || // For a details element with a summary, the summary element gets the focus
244
+ $n(n) || qn(n));
245
+ }, dt = function(t, n) {
246
+ return !(Hn(n) || tn(n) < 0 || !ft(t, n));
247
+ }, Yn = function(t) {
248
+ var n = parseInt(t.getAttribute("tabindex"), 10);
249
+ return !!(isNaN(n) || n >= 0);
250
+ }, rn = function(t) {
251
+ var n = [], r = [];
252
+ return t.forEach(function(o, s) {
253
+ var i = !!o.scopeParent, u = i ? o.scopeParent : o, l = Ln(u, i), c = i ? rn(o.candidates) : u;
254
+ l === 0 ? i ? n.push.apply(n, c) : n.push(u) : r.push({
255
+ documentOrder: s,
256
+ tabIndex: l,
257
+ item: o,
258
+ isScope: i,
259
+ content: c
260
+ });
261
+ }), r.sort(Fn).reduce(function(o, s) {
262
+ return s.isScope ? o.push.apply(o, s.content) : o.push(s.content), o;
263
+ }, []).concat(n);
264
+ }, et = function(t, n) {
265
+ n = n || {};
266
+ var r;
267
+ return n.getShadowRoot ? r = Ze([t], n.includeContainer, {
268
+ filter: dt.bind(null, n),
269
+ flatten: !1,
270
+ getShadowRoot: n.getShadowRoot,
271
+ shadowRootFilter: Yn
272
+ }) : r = Qt(t, n.includeContainer, dt.bind(null, n)), rn(r);
273
+ }, Xn = function(t, n) {
274
+ n = n || {};
275
+ var r;
276
+ return n.getShadowRoot ? r = Ze([t], n.includeContainer, {
277
+ filter: ft.bind(null, n),
278
+ flatten: !0,
279
+ getShadowRoot: n.getShadowRoot
280
+ }) : r = Qt(t, n.includeContainer, ft.bind(null, n)), r;
281
+ }, on = function(t, n) {
282
+ if (n = n || {}, !t)
283
+ throw new Error("No node provided");
284
+ return ke.call(t, Xe) === !1 ? !1 : dt(n, t);
285
+ };
286
+ function jn() {
287
+ const e = navigator.userAgentData;
288
+ return e != null && e.platform ? e.platform : navigator.platform;
289
+ }
290
+ function sn() {
291
+ const e = navigator.userAgentData;
292
+ return e && Array.isArray(e.brands) ? e.brands.map((t) => {
293
+ let {
294
+ brand: n,
295
+ version: r
296
+ } = t;
297
+ return n + "/" + r;
298
+ }).join(" ") : navigator.userAgent;
299
+ }
300
+ function Gn() {
301
+ return /apple/i.test(navigator.vendor);
302
+ }
303
+ function pt() {
304
+ const e = /android/i;
305
+ return e.test(jn()) || e.test(sn());
306
+ }
307
+ function Zn() {
308
+ return sn().includes("jsdom/");
309
+ }
310
+ const wt = "data-floating-ui-focusable", zn = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
311
+ function Ce(e) {
312
+ let t = e.activeElement;
313
+ for (; ((n = t) == null || (n = n.shadowRoot) == null ? void 0 : n.activeElement) != null; ) {
314
+ var n;
315
+ t = t.shadowRoot.activeElement;
316
+ }
317
+ return t;
318
+ }
319
+ function ne(e, t) {
320
+ if (!e || !t)
321
+ return !1;
322
+ const n = t.getRootNode == null ? void 0 : t.getRootNode();
323
+ if (e.contains(t))
324
+ return !0;
325
+ if (n && Fe(n)) {
326
+ let r = t;
327
+ for (; r; ) {
328
+ if (e === r)
329
+ return !0;
330
+ r = r.parentNode || r.host;
331
+ }
332
+ }
333
+ return !1;
334
+ }
335
+ function ye(e) {
336
+ return "composedPath" in e ? e.composedPath()[0] : e.target;
337
+ }
338
+ function ot(e, t) {
339
+ if (t == null)
340
+ return !1;
341
+ if ("composedPath" in e)
342
+ return e.composedPath().includes(t);
343
+ const n = e;
344
+ return n.target != null && t.contains(n.target);
345
+ }
346
+ function Jn(e) {
347
+ return e.matches("html,body");
348
+ }
349
+ function Q(e) {
350
+ return e?.ownerDocument || document;
351
+ }
352
+ function un(e) {
353
+ return fe(e) && e.matches(zn);
354
+ }
355
+ function Ct(e) {
356
+ return e ? e.getAttribute("role") === "combobox" && un(e) : !1;
357
+ }
358
+ function mt(e) {
359
+ return e ? e.hasAttribute(wt) ? e : e.querySelector("[" + wt + "]") || e : null;
360
+ }
361
+ function Ie(e, t, n) {
362
+ return n === void 0 && (n = !0), e.filter((o) => {
363
+ var s;
364
+ return o.parentId === t && (!n || ((s = o.context) == null ? void 0 : s.open));
365
+ }).flatMap((o) => [o, ...Ie(e, o.id, n)]);
366
+ }
367
+ function It(e, t) {
368
+ var n;
369
+ let r = [], o = (n = e.find((s) => s.id === t)) == null ? void 0 : n.parentId;
370
+ for (; o; ) {
371
+ const s = e.find((i) => i.id === o);
372
+ o = s?.parentId, s && (r = r.concat(s));
373
+ }
374
+ return r;
375
+ }
376
+ function it(e) {
377
+ e.preventDefault(), e.stopPropagation();
378
+ }
379
+ function Qn(e) {
380
+ return "nativeEvent" in e;
381
+ }
382
+ function er(e) {
383
+ return e.mozInputSource === 0 && e.isTrusted ? !0 : pt() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
384
+ }
385
+ function tr(e) {
386
+ return Zn() ? !1 : !pt() && e.width === 0 && e.height === 0 || pt() && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
387
+ e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
388
+ }
389
+ function _e(e, t) {
390
+ const n = ["mouse", "pen"];
391
+ return t || n.push("", void 0), n.includes(e);
392
+ }
393
+ var nr = typeof document < "u", rr = function() {
394
+ }, ue = nr ? Tn : rr;
395
+ const or = {
396
+ ...d
397
+ };
398
+ function Se(e) {
399
+ const t = d.useRef(e);
400
+ return ue(() => {
401
+ t.current = e;
402
+ }), t;
403
+ }
404
+ const ir = or.useInsertionEffect, sr = ir || ((e) => e());
405
+ function se(e) {
406
+ const t = d.useRef(() => {
407
+ if (process.env.NODE_ENV !== "production")
408
+ throw new Error("Cannot call an event handler while rendering.");
409
+ });
410
+ return sr(() => {
411
+ t.current = e;
412
+ }), d.useCallback(function() {
413
+ for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++)
414
+ r[o] = arguments[o];
415
+ return t.current == null ? void 0 : t.current(...r);
416
+ }, []);
417
+ }
418
+ const Ke = () => ({
419
+ getShadowRoot: !0,
420
+ displayCheck: (
421
+ // JSDOM does not support the `tabbable` library. To solve this we can
422
+ // check if `ResizeObserver` is a real function (not polyfilled), which
423
+ // determines if the current environment is JSDOM-like.
424
+ typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
425
+ )
426
+ });
427
+ function cn(e, t) {
428
+ const n = et(e, Ke()), r = n.length;
429
+ if (r === 0) return;
430
+ const o = Ce(Q(e)), s = n.indexOf(o), i = s === -1 ? t === 1 ? 0 : r - 1 : s + t;
431
+ return n[i];
432
+ }
433
+ function an(e) {
434
+ return cn(Q(e).body, 1) || e;
435
+ }
436
+ function ln(e) {
437
+ return cn(Q(e).body, -1) || e;
438
+ }
439
+ function Ne(e, t) {
440
+ const n = t || e.currentTarget, r = e.relatedTarget;
441
+ return !r || !ne(n, r);
442
+ }
443
+ function ur(e) {
444
+ et(e, Ke()).forEach((n) => {
445
+ n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
446
+ });
447
+ }
448
+ function Tt(e) {
449
+ e.querySelectorAll("[data-tabindex]").forEach((n) => {
450
+ const r = n.dataset.tabindex;
451
+ delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
452
+ });
453
+ }
454
+ function fn(e) {
455
+ const t = d.useRef(void 0), n = d.useCallback((r) => {
456
+ const o = e.map((s) => {
457
+ if (s != null) {
458
+ if (typeof s == "function") {
459
+ const i = s, u = i(r);
460
+ return typeof u == "function" ? u : () => {
461
+ i(null);
462
+ };
463
+ }
464
+ return s.current = r, () => {
465
+ s.current = null;
466
+ };
467
+ }
468
+ });
469
+ return () => {
470
+ o.forEach((s) => s?.());
471
+ };
472
+ }, e);
473
+ return d.useMemo(() => e.every((r) => r == null) ? null : (r) => {
474
+ t.current && (t.current(), t.current = void 0), r != null && (t.current = n(r));
475
+ }, e);
476
+ }
477
+ const cr = "data-floating-ui-focusable", kt = "active", Mt = "selected", ar = {
478
+ ...d
479
+ };
480
+ let Pt = !1, lr = 0;
481
+ const At = () => (
482
+ // Ensure the id is unique with multiple independent versions of Floating UI
483
+ // on <React 18
484
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + lr++
485
+ );
486
+ function fr() {
487
+ const [e, t] = d.useState(() => Pt ? At() : void 0);
488
+ return ue(() => {
489
+ e == null && t(At());
490
+ }, []), d.useEffect(() => {
491
+ Pt = !0;
492
+ }, []), e;
493
+ }
494
+ const dr = ar.useId, ht = dr || fr;
495
+ process.env.NODE_ENV;
496
+ function pr() {
497
+ const e = /* @__PURE__ */ new Map();
498
+ return {
499
+ emit(t, n) {
500
+ var r;
501
+ (r = e.get(t)) == null || r.forEach((o) => o(n));
502
+ },
503
+ on(t, n) {
504
+ e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
505
+ },
506
+ off(t, n) {
507
+ var r;
508
+ (r = e.get(t)) == null || r.delete(n);
509
+ }
510
+ };
511
+ }
512
+ const dn = /* @__PURE__ */ d.createContext(null), pn = /* @__PURE__ */ d.createContext(null), We = () => {
513
+ var e;
514
+ return ((e = d.useContext(dn)) == null ? void 0 : e.id) || null;
515
+ }, tt = () => d.useContext(pn);
516
+ function mr(e) {
517
+ const t = ht(), n = tt(), o = We();
518
+ return ue(() => {
519
+ if (!t) return;
520
+ const s = {
521
+ id: t,
522
+ parentId: o
523
+ };
524
+ return n?.addNode(s), () => {
525
+ n?.removeNode(s);
526
+ };
527
+ }, [n, t, o]), t;
528
+ }
529
+ function gr(e) {
530
+ const {
531
+ children: t,
532
+ id: n
533
+ } = e, r = We();
534
+ return /* @__PURE__ */ O(dn.Provider, {
535
+ value: d.useMemo(() => ({
536
+ id: n,
537
+ parentId: r
538
+ }), [n, r]),
539
+ children: t
540
+ });
541
+ }
542
+ function br(e) {
543
+ const {
544
+ children: t
545
+ } = e, n = d.useRef([]), r = d.useCallback((i) => {
546
+ n.current = [...n.current, i];
547
+ }, []), o = d.useCallback((i) => {
548
+ n.current = n.current.filter((u) => u !== i);
549
+ }, []), [s] = d.useState(() => pr());
550
+ return /* @__PURE__ */ O(pn.Provider, {
551
+ value: d.useMemo(() => ({
552
+ nodesRef: n,
553
+ addNode: r,
554
+ removeNode: o,
555
+ events: s
556
+ }), [r, o, s]),
557
+ children: t
558
+ });
559
+ }
560
+ function Me(e) {
561
+ return "data-floating-ui-" + e;
562
+ }
563
+ function te(e) {
564
+ e.current !== -1 && (clearTimeout(e.current), e.current = -1);
565
+ }
566
+ const Dt = /* @__PURE__ */ Me("safe-polygon");
567
+ function st(e, t, n) {
568
+ if (n && !_e(n))
569
+ return 0;
570
+ if (typeof e == "number")
571
+ return e;
572
+ if (typeof e == "function") {
573
+ const r = e();
574
+ return typeof r == "number" ? r : r?.[t];
575
+ }
576
+ return e?.[t];
577
+ }
578
+ function ut(e) {
579
+ return typeof e == "function" ? e() : e;
580
+ }
581
+ function vr(e, t) {
582
+ t === void 0 && (t = {});
583
+ const {
584
+ open: n,
585
+ onOpenChange: r,
586
+ dataRef: o,
587
+ events: s,
588
+ elements: i
589
+ } = e, {
590
+ enabled: u = !0,
591
+ delay: l = 0,
592
+ handleClose: c = null,
593
+ mouseOnly: p = !1,
594
+ restMs: g = 0,
595
+ move: v = !0
596
+ } = t, h = tt(), m = We(), f = Se(c), E = Se(l), x = Se(n), b = Se(g), C = d.useRef(), P = d.useRef(-1), T = d.useRef(), L = d.useRef(-1), _ = d.useRef(!0), X = d.useRef(!1), G = d.useRef(() => {
597
+ }), H = d.useRef(!1), W = se(() => {
598
+ var S;
599
+ const y = (S = o.current.openEvent) == null ? void 0 : S.type;
600
+ return y?.includes("mouse") && y !== "mousedown";
601
+ });
602
+ d.useEffect(() => {
603
+ if (!u) return;
604
+ function S(y) {
605
+ let {
606
+ open: I
607
+ } = y;
608
+ I || (te(P), te(L), _.current = !0, H.current = !1);
609
+ }
610
+ return s.on("openchange", S), () => {
611
+ s.off("openchange", S);
612
+ };
613
+ }, [u, s]), d.useEffect(() => {
614
+ if (!u || !f.current || !n) return;
615
+ function S(I) {
616
+ W() && r(!1, I, "hover");
617
+ }
618
+ const y = Q(i.floating).documentElement;
619
+ return y.addEventListener("mouseleave", S), () => {
620
+ y.removeEventListener("mouseleave", S);
621
+ };
622
+ }, [i.floating, n, r, u, f, W]);
623
+ const Z = d.useCallback(function(S, y, I) {
624
+ y === void 0 && (y = !0), I === void 0 && (I = "hover");
625
+ const A = st(E.current, "close", C.current);
626
+ A && !T.current ? (te(P), P.current = window.setTimeout(() => r(!1, S, I), A)) : y && (te(P), r(!1, S, I));
627
+ }, [E, r]), k = se(() => {
628
+ G.current(), T.current = void 0;
629
+ }), a = se(() => {
630
+ if (X.current) {
631
+ const S = Q(i.floating).body;
632
+ S.style.pointerEvents = "", S.removeAttribute(Dt), X.current = !1;
633
+ }
634
+ }), R = se(() => o.current.openEvent ? ["click", "mousedown"].includes(o.current.openEvent.type) : !1);
635
+ d.useEffect(() => {
636
+ if (!u) return;
637
+ function S(D) {
638
+ if (te(P), _.current = !1, p && !_e(C.current) || ut(b.current) > 0 && !st(E.current, "open"))
639
+ return;
640
+ const w = st(E.current, "open", C.current);
641
+ w ? P.current = window.setTimeout(() => {
642
+ x.current || r(!0, D, "hover");
643
+ }, w) : n || r(!0, D, "hover");
644
+ }
645
+ function y(D) {
646
+ if (R()) {
647
+ a();
648
+ return;
649
+ }
650
+ G.current();
651
+ const w = Q(i.floating);
652
+ if (te(L), H.current = !1, f.current && o.current.floatingContext) {
653
+ n || te(P), T.current = f.current({
654
+ ...o.current.floatingContext,
655
+ tree: h,
656
+ x: D.clientX,
657
+ y: D.clientY,
658
+ onClose() {
659
+ a(), k(), R() || Z(D, !0, "safe-polygon");
660
+ }
661
+ });
662
+ const $ = T.current;
663
+ w.addEventListener("mousemove", $), G.current = () => {
664
+ w.removeEventListener("mousemove", $);
665
+ };
666
+ return;
667
+ }
668
+ (C.current !== "touch" || !ne(i.floating, D.relatedTarget)) && Z(D);
669
+ }
670
+ function I(D) {
671
+ R() || o.current.floatingContext && (f.current == null || f.current({
672
+ ...o.current.floatingContext,
673
+ tree: h,
674
+ x: D.clientX,
675
+ y: D.clientY,
676
+ onClose() {
677
+ a(), k(), R() || Z(D);
678
+ }
679
+ })(D));
680
+ }
681
+ function A() {
682
+ te(P);
683
+ }
684
+ function V(D) {
685
+ R() || Z(D, !1);
686
+ }
687
+ if (ge(i.domReference)) {
688
+ const D = i.domReference, w = i.floating;
689
+ return n && D.addEventListener("mouseleave", I), v && D.addEventListener("mousemove", S, {
690
+ once: !0
691
+ }), D.addEventListener("mouseenter", S), D.addEventListener("mouseleave", y), w && (w.addEventListener("mouseleave", I), w.addEventListener("mouseenter", A), w.addEventListener("mouseleave", V)), () => {
692
+ n && D.removeEventListener("mouseleave", I), v && D.removeEventListener("mousemove", S), D.removeEventListener("mouseenter", S), D.removeEventListener("mouseleave", y), w && (w.removeEventListener("mouseleave", I), w.removeEventListener("mouseenter", A), w.removeEventListener("mouseleave", V));
693
+ };
694
+ }
695
+ }, [i, u, e, p, v, Z, k, a, r, n, x, h, E, f, o, R, b]), ue(() => {
696
+ var S;
697
+ if (u && n && (S = f.current) != null && (S = S.__options) != null && S.blockPointerEvents && W()) {
698
+ X.current = !0;
699
+ const I = i.floating;
700
+ if (ge(i.domReference) && I) {
701
+ var y;
702
+ const A = Q(i.floating).body;
703
+ A.setAttribute(Dt, "");
704
+ const V = i.domReference, D = h == null || (y = h.nodesRef.current.find((w) => w.id === m)) == null || (y = y.context) == null ? void 0 : y.elements.floating;
705
+ return D && (D.style.pointerEvents = ""), A.style.pointerEvents = "none", V.style.pointerEvents = "auto", I.style.pointerEvents = "auto", () => {
706
+ A.style.pointerEvents = "", V.style.pointerEvents = "", I.style.pointerEvents = "";
707
+ };
708
+ }
709
+ }
710
+ }, [u, n, m, i, h, f, W]), ue(() => {
711
+ n || (C.current = void 0, H.current = !1, k(), a());
712
+ }, [n, k, a]), d.useEffect(() => () => {
713
+ k(), te(P), te(L), a();
714
+ }, [u, i.domReference, k, a]);
715
+ const K = d.useMemo(() => {
716
+ function S(y) {
717
+ C.current = y.pointerType;
718
+ }
719
+ return {
720
+ onPointerDown: S,
721
+ onPointerEnter: S,
722
+ onMouseMove(y) {
723
+ const {
724
+ nativeEvent: I
725
+ } = y;
726
+ function A() {
727
+ !_.current && !x.current && r(!0, I, "hover");
728
+ }
729
+ p && !_e(C.current) || n || ut(b.current) === 0 || H.current && y.movementX ** 2 + y.movementY ** 2 < 2 || (te(L), C.current === "touch" ? A() : (H.current = !0, L.current = window.setTimeout(A, ut(b.current))));
730
+ }
731
+ };
732
+ }, [p, r, n, x, b]);
733
+ return d.useMemo(() => u ? {
734
+ reference: K
735
+ } : {}, [u, K]);
736
+ }
737
+ let Ot = 0;
738
+ function we(e, t) {
739
+ t === void 0 && (t = {});
740
+ const {
741
+ preventScroll: n = !1,
742
+ cancelPrevious: r = !0,
743
+ sync: o = !1
744
+ } = t;
745
+ r && cancelAnimationFrame(Ot);
746
+ const s = () => e?.focus({
747
+ preventScroll: n
748
+ });
749
+ o ? s() : Ot = requestAnimationFrame(s);
750
+ }
751
+ function ct(e, t) {
752
+ if (!e || !t)
753
+ return !1;
754
+ const n = t.getRootNode == null ? void 0 : t.getRootNode();
755
+ if (e.contains(t))
756
+ return !0;
757
+ if (n && Fe(n)) {
758
+ let r = t;
759
+ for (; r; ) {
760
+ if (e === r)
761
+ return !0;
762
+ r = r.parentNode || r.host;
763
+ }
764
+ }
765
+ return !1;
766
+ }
767
+ function hr(e) {
768
+ return "composedPath" in e ? e.composedPath()[0] : e.target;
769
+ }
770
+ function yr(e) {
771
+ return e?.ownerDocument || document;
772
+ }
773
+ const Te = {
774
+ inert: /* @__PURE__ */ new WeakMap(),
775
+ "aria-hidden": /* @__PURE__ */ new WeakMap(),
776
+ none: /* @__PURE__ */ new WeakMap()
777
+ };
778
+ function Nt(e) {
779
+ return e === "inert" ? Te.inert : e === "aria-hidden" ? Te["aria-hidden"] : Te.none;
780
+ }
781
+ let He = /* @__PURE__ */ new WeakSet(), Ve = {}, at = 0;
782
+ const Er = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype;
783
+ function mn(e) {
784
+ return e ? Fe(e) ? e.host : mn(e.parentNode) : null;
785
+ }
786
+ const Rr = (e, t) => t.map((n) => {
787
+ if (e.contains(n))
788
+ return n;
789
+ const r = mn(n);
790
+ return e.contains(r) ? r : null;
791
+ }).filter((n) => n != null);
792
+ function xr(e, t, n, r) {
793
+ const o = "data-floating-ui-inert", s = r ? "inert" : n ? "aria-hidden" : null, i = Rr(t, e), u = /* @__PURE__ */ new Set(), l = new Set(i), c = [];
794
+ Ve[o] || (Ve[o] = /* @__PURE__ */ new WeakMap());
795
+ const p = Ve[o];
796
+ i.forEach(g), v(t), u.clear();
797
+ function g(h) {
798
+ !h || u.has(h) || (u.add(h), h.parentNode && g(h.parentNode));
799
+ }
800
+ function v(h) {
801
+ !h || l.has(h) || [].forEach.call(h.children, (m) => {
802
+ if (Qe(m) !== "script")
803
+ if (u.has(m))
804
+ v(m);
805
+ else {
806
+ const f = s ? m.getAttribute(s) : null, E = f !== null && f !== "false", x = Nt(s), b = (x.get(m) || 0) + 1, C = (p.get(m) || 0) + 1;
807
+ x.set(m, b), p.set(m, C), c.push(m), b === 1 && E && He.add(m), C === 1 && m.setAttribute(o, ""), !E && s && m.setAttribute(s, s === "inert" ? "" : "true");
808
+ }
809
+ });
810
+ }
811
+ return at++, () => {
812
+ c.forEach((h) => {
813
+ const m = Nt(s), E = (m.get(h) || 0) - 1, x = (p.get(h) || 0) - 1;
814
+ m.set(h, E), p.set(h, x), E || (!He.has(h) && s && h.removeAttribute(s), He.delete(h)), x || h.removeAttribute(o);
815
+ }), at--, at || (Te.inert = /* @__PURE__ */ new WeakMap(), Te["aria-hidden"] = /* @__PURE__ */ new WeakMap(), Te.none = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakSet(), Ve = {});
816
+ };
817
+ }
818
+ function Lt(e, t, n) {
819
+ t === void 0 && (t = !1), n === void 0 && (n = !1);
820
+ const r = yr(e[0]).body;
821
+ return xr(e.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))), r, t, n);
822
+ }
823
+ const yt = {
824
+ border: 0,
825
+ clip: "rect(0 0 0 0)",
826
+ height: "1px",
827
+ margin: "-1px",
828
+ overflow: "hidden",
829
+ padding: 0,
830
+ position: "fixed",
831
+ whiteSpace: "nowrap",
832
+ width: "1px",
833
+ top: 0,
834
+ left: 0
835
+ }, ze = /* @__PURE__ */ d.forwardRef(function(t, n) {
836
+ const [r, o] = d.useState();
837
+ ue(() => {
838
+ Gn() && o("button");
839
+ }, []);
840
+ const s = {
841
+ ref: n,
842
+ tabIndex: 0,
843
+ // Role is only for VoiceOver
844
+ role: r,
845
+ "aria-hidden": r ? void 0 : !0,
846
+ [Me("focus-guard")]: "",
847
+ style: yt
848
+ };
849
+ return /* @__PURE__ */ O("span", {
850
+ ...t,
851
+ ...s
852
+ });
853
+ }), Sr = {
854
+ clipPath: "inset(50%)",
855
+ position: "fixed",
856
+ top: 0,
857
+ left: 0
858
+ }, gn = /* @__PURE__ */ d.createContext(null), Ft = /* @__PURE__ */ Me("portal");
859
+ function wr(e) {
860
+ e === void 0 && (e = {});
861
+ const {
862
+ id: t,
863
+ root: n
864
+ } = e, r = ht(), o = bn(), [s, i] = d.useState(null), u = d.useRef(null);
865
+ return ue(() => () => {
866
+ s?.remove(), queueMicrotask(() => {
867
+ u.current = null;
868
+ });
869
+ }, [s]), ue(() => {
870
+ if (!r || u.current) return;
871
+ const l = t ? document.getElementById(t) : null;
872
+ if (!l) return;
873
+ const c = document.createElement("div");
874
+ c.id = r, c.setAttribute(Ft, ""), l.appendChild(c), u.current = c, i(c);
875
+ }, [t, r]), ue(() => {
876
+ if (n === null || !r || u.current) return;
877
+ let l = n || o?.portalNode;
878
+ l && !vt(l) && (l = l.current), l = l || document.body;
879
+ let c = null;
880
+ t && (c = document.createElement("div"), c.id = t, l.appendChild(c));
881
+ const p = document.createElement("div");
882
+ p.id = r, p.setAttribute(Ft, ""), l = c || l, l.appendChild(p), u.current = p, i(p);
883
+ }, [t, n, r, o]), s;
884
+ }
885
+ function Cr(e) {
886
+ const {
887
+ children: t,
888
+ id: n,
889
+ root: r,
890
+ preserveTabOrder: o = !0
891
+ } = e, s = wr({
892
+ id: n,
893
+ root: r
894
+ }), [i, u] = d.useState(null), l = d.useRef(null), c = d.useRef(null), p = d.useRef(null), g = d.useRef(null), v = i?.modal, h = i?.open, m = (
895
+ // The FocusManager and therefore floating element are currently open/
896
+ // rendered.
897
+ !!i && // Guards are only for non-modal focus management.
898
+ !i.modal && // Don't render if unmount is transitioning.
899
+ i.open && o && !!(r || s)
900
+ );
901
+ return d.useEffect(() => {
902
+ if (!s || !o || v)
903
+ return;
904
+ function f(E) {
905
+ s && Ne(E) && (E.type === "focusin" ? Tt : ur)(s);
906
+ }
907
+ return s.addEventListener("focusin", f, !0), s.addEventListener("focusout", f, !0), () => {
908
+ s.removeEventListener("focusin", f, !0), s.removeEventListener("focusout", f, !0);
909
+ };
910
+ }, [s, o, v]), d.useEffect(() => {
911
+ s && (h || Tt(s));
912
+ }, [h, s]), /* @__PURE__ */ $e(gn.Provider, {
913
+ value: d.useMemo(() => ({
914
+ preserveTabOrder: o,
915
+ beforeOutsideRef: l,
916
+ afterOutsideRef: c,
917
+ beforeInsideRef: p,
918
+ afterInsideRef: g,
919
+ portalNode: s,
920
+ setFocusManagerState: u
921
+ }), [o, s]),
922
+ children: [m && s && /* @__PURE__ */ O(ze, {
923
+ "data-type": "outside",
924
+ ref: l,
925
+ onFocus: (f) => {
926
+ if (Ne(f, s)) {
927
+ var E;
928
+ (E = p.current) == null || E.focus();
929
+ } else {
930
+ const x = i ? i.domReference : null, b = ln(x);
931
+ b?.focus();
932
+ }
933
+ }
934
+ }), m && s && /* @__PURE__ */ O("span", {
935
+ "aria-owns": s.id,
936
+ style: Sr
937
+ }), s && /* @__PURE__ */ kn.createPortal(t, s), m && s && /* @__PURE__ */ O(ze, {
938
+ "data-type": "outside",
939
+ ref: c,
940
+ onFocus: (f) => {
941
+ if (Ne(f, s)) {
942
+ var E;
943
+ (E = g.current) == null || E.focus();
944
+ } else {
945
+ const x = i ? i.domReference : null, b = an(x);
946
+ b?.focus(), i?.closeOnFocusOut && i?.onOpenChange(!1, f.nativeEvent, "focus-out");
947
+ }
948
+ }
949
+ })]
950
+ });
951
+ }
952
+ const bn = () => d.useContext(gn);
953
+ function _t(e) {
954
+ return d.useMemo(() => (t) => {
955
+ e.forEach((n) => {
956
+ n && (n.current = t);
957
+ });
958
+ }, e);
959
+ }
960
+ const $t = 20;
961
+ let Ee = [];
962
+ function Et() {
963
+ Ee = Ee.filter((e) => {
964
+ var t;
965
+ return (t = e.deref()) == null ? void 0 : t.isConnected;
966
+ });
967
+ }
968
+ function Ir(e) {
969
+ Et(), e && Qe(e) !== "body" && (Ee.push(new WeakRef(e)), Ee.length > $t && (Ee = Ee.slice(-$t)));
970
+ }
971
+ function Bt() {
972
+ Et();
973
+ const e = Ee[Ee.length - 1];
974
+ return e?.deref();
975
+ }
976
+ function Tr(e) {
977
+ const t = Ke();
978
+ return on(e, t) ? e : et(e, t)[0] || e;
979
+ }
980
+ function Kt(e, t) {
981
+ var n;
982
+ if (!t.current.includes("floating") && !((n = e.getAttribute("role")) != null && n.includes("dialog")))
983
+ return;
984
+ const r = Ke(), s = Xn(e, r).filter((u) => {
985
+ const l = u.getAttribute("data-tabindex") || "";
986
+ return on(u, r) || u.hasAttribute("data-tabindex") && !l.startsWith("-");
987
+ }), i = e.getAttribute("tabindex");
988
+ t.current.includes("floating") || s.length === 0 ? i !== "0" && e.setAttribute("tabindex", "0") : (i !== "-1" || e.hasAttribute("data-tabindex") && e.getAttribute("data-tabindex") !== "-1") && (e.setAttribute("tabindex", "-1"), e.setAttribute("data-tabindex", "-1"));
989
+ }
990
+ const kr = /* @__PURE__ */ d.forwardRef(function(t, n) {
991
+ return /* @__PURE__ */ O("button", {
992
+ ...t,
993
+ type: "button",
994
+ ref: n,
995
+ tabIndex: -1,
996
+ style: yt
997
+ });
998
+ });
999
+ function Mr(e) {
1000
+ const {
1001
+ context: t,
1002
+ children: n,
1003
+ disabled: r = !1,
1004
+ order: o = ["content"],
1005
+ guards: s = !0,
1006
+ initialFocus: i = 0,
1007
+ returnFocus: u = !0,
1008
+ restoreFocus: l = !1,
1009
+ modal: c = !0,
1010
+ visuallyHiddenDismiss: p = !1,
1011
+ closeOnFocusOut: g = !0,
1012
+ outsideElementsInert: v = !1,
1013
+ getInsideElements: h = () => []
1014
+ } = e, {
1015
+ open: m,
1016
+ onOpenChange: f,
1017
+ events: E,
1018
+ dataRef: x,
1019
+ elements: {
1020
+ domReference: b,
1021
+ floating: C
1022
+ }
1023
+ } = t, P = se(() => {
1024
+ var M;
1025
+ return (M = x.current.floatingContext) == null ? void 0 : M.nodeId;
1026
+ }), T = se(h), L = typeof i == "number" && i < 0, _ = Ct(b) && L, X = Er(), G = X ? s : !0, H = !G || X && v, W = Se(o), Z = Se(i), k = Se(u), a = tt(), R = bn(), K = d.useRef(null), S = d.useRef(null), y = d.useRef(!1), I = d.useRef(!1), A = d.useRef(-1), V = d.useRef(-1), D = R != null, w = mt(C), z = se(function(M) {
1027
+ return M === void 0 && (M = w), M ? et(M, Ke()) : [];
1028
+ }), $ = se((M) => {
1029
+ const F = z(M);
1030
+ return W.current.map((N) => b && N === "reference" ? b : w && N === "floating" ? w : F).filter(Boolean).flat();
1031
+ });
1032
+ d.useEffect(() => {
1033
+ if (r || !c) return;
1034
+ function M(N) {
1035
+ if (N.key === "Tab") {
1036
+ ne(w, Ce(Q(w))) && z().length === 0 && !_ && it(N);
1037
+ const q = $(), j = ye(N);
1038
+ W.current[0] === "reference" && j === b && (it(N), N.shiftKey ? we(q[q.length - 1]) : we(q[1])), W.current[1] === "floating" && j === w && N.shiftKey && (it(N), we(q[0]));
1039
+ }
1040
+ }
1041
+ const F = Q(w);
1042
+ return F.addEventListener("keydown", M), () => {
1043
+ F.removeEventListener("keydown", M);
1044
+ };
1045
+ }, [r, b, w, c, W, _, z, $]), d.useEffect(() => {
1046
+ if (r || !C) return;
1047
+ function M(F) {
1048
+ const N = ye(F), j = z().indexOf(N);
1049
+ j !== -1 && (A.current = j);
1050
+ }
1051
+ return C.addEventListener("focusin", M), () => {
1052
+ C.removeEventListener("focusin", M);
1053
+ };
1054
+ }, [r, C, z]), d.useEffect(() => {
1055
+ if (r || !g) return;
1056
+ function M() {
1057
+ I.current = !0, setTimeout(() => {
1058
+ I.current = !1;
1059
+ });
1060
+ }
1061
+ function F(j) {
1062
+ const B = j.relatedTarget, pe = j.currentTarget, le = ye(j);
1063
+ queueMicrotask(() => {
1064
+ const ie = P(), xe = !(ne(b, B) || ne(C, B) || ne(B, C) || ne(R?.portalNode, B) || B != null && B.hasAttribute(Me("focus-guard")) || a && (Ie(a.nodesRef.current, ie).find((ve) => {
1065
+ var me, he;
1066
+ return ne((me = ve.context) == null ? void 0 : me.elements.floating, B) || ne((he = ve.context) == null ? void 0 : he.elements.domReference, B);
1067
+ }) || It(a.nodesRef.current, ie).find((ve) => {
1068
+ var me, he, xt;
1069
+ return [(me = ve.context) == null ? void 0 : me.elements.floating, mt((he = ve.context) == null ? void 0 : he.elements.floating)].includes(B) || ((xt = ve.context) == null ? void 0 : xt.elements.domReference) === B;
1070
+ })));
1071
+ if (pe === b && w && Kt(w, W), l && pe !== b && !(le != null && le.isConnected) && Ce(Q(w)) === Q(w).body) {
1072
+ fe(w) && w.focus();
1073
+ const ve = A.current, me = z(), he = me[ve] || me[me.length - 1] || w;
1074
+ fe(he) && he.focus();
1075
+ }
1076
+ if (x.current.insideReactTree) {
1077
+ x.current.insideReactTree = !1;
1078
+ return;
1079
+ }
1080
+ (_ || !c) && B && xe && !I.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
1081
+ B !== Bt() && (y.current = !0, f(!1, j, "focus-out"));
1082
+ });
1083
+ }
1084
+ const N = !!(!a && R);
1085
+ function q() {
1086
+ te(V), x.current.insideReactTree = !0, V.current = window.setTimeout(() => {
1087
+ x.current.insideReactTree = !1;
1088
+ });
1089
+ }
1090
+ if (C && fe(b))
1091
+ return b.addEventListener("focusout", F), b.addEventListener("pointerdown", M), C.addEventListener("focusout", F), N && C.addEventListener("focusout", q, !0), () => {
1092
+ b.removeEventListener("focusout", F), b.removeEventListener("pointerdown", M), C.removeEventListener("focusout", F), N && C.removeEventListener("focusout", q, !0);
1093
+ };
1094
+ }, [r, b, C, w, c, a, R, f, g, l, z, _, P, W, x]);
1095
+ const ee = d.useRef(null), oe = d.useRef(null), U = _t([ee, R?.beforeInsideRef]), Y = _t([oe, R?.afterInsideRef]);
1096
+ d.useEffect(() => {
1097
+ var M, F;
1098
+ if (r || !C) return;
1099
+ const N = Array.from((R == null || (M = R.portalNode) == null ? void 0 : M.querySelectorAll("[" + Me("portal") + "]")) || []), j = (F = (a ? It(a.nodesRef.current, P()) : []).find((le) => {
1100
+ var ie;
1101
+ return Ct(((ie = le.context) == null ? void 0 : ie.elements.domReference) || null);
1102
+ })) == null || (F = F.context) == null ? void 0 : F.elements.domReference, B = [C, j, ...N, ...T(), K.current, S.current, ee.current, oe.current, R?.beforeOutsideRef.current, R?.afterOutsideRef.current, W.current.includes("reference") || _ ? b : null].filter((le) => le != null), pe = c || _ ? Lt(B, !H, H) : Lt(B);
1103
+ return () => {
1104
+ pe();
1105
+ };
1106
+ }, [r, b, C, c, W, R, _, G, H, a, P, T]), ue(() => {
1107
+ if (r || !fe(w)) return;
1108
+ const M = Q(w), F = Ce(M);
1109
+ queueMicrotask(() => {
1110
+ const N = $(w), q = Z.current, j = (typeof q == "number" ? N[q] : q.current) || w, B = ne(w, F);
1111
+ !L && !B && m && we(j, {
1112
+ preventScroll: j === w
1113
+ });
1114
+ });
1115
+ }, [r, m, w, L, $, Z]), ue(() => {
1116
+ if (r || !w) return;
1117
+ const M = Q(w), F = Ce(M);
1118
+ Ir(F);
1119
+ function N(B) {
1120
+ let {
1121
+ reason: pe,
1122
+ event: le,
1123
+ nested: ie
1124
+ } = B;
1125
+ if (["hover", "safe-polygon"].includes(pe) && le.type === "mouseleave" && (y.current = !0), pe === "outside-press")
1126
+ if (ie)
1127
+ y.current = !1;
1128
+ else if (er(le) || tr(le))
1129
+ y.current = !1;
1130
+ else {
1131
+ let xe = !1;
1132
+ document.createElement("div").focus({
1133
+ get preventScroll() {
1134
+ return xe = !0, !1;
1135
+ }
1136
+ }), xe ? y.current = !1 : y.current = !0;
1137
+ }
1138
+ }
1139
+ E.on("openchange", N);
1140
+ const q = M.createElement("span");
1141
+ q.setAttribute("tabindex", "-1"), q.setAttribute("aria-hidden", "true"), Object.assign(q.style, yt), D && b && b.insertAdjacentElement("afterend", q);
1142
+ function j() {
1143
+ if (typeof k.current == "boolean") {
1144
+ const B = b || Bt();
1145
+ return B && B.isConnected ? B : q;
1146
+ }
1147
+ return k.current.current || q;
1148
+ }
1149
+ return () => {
1150
+ E.off("openchange", N);
1151
+ const B = Ce(M), pe = ne(C, B) || a && Ie(a.nodesRef.current, P(), !1).some((ie) => {
1152
+ var xe;
1153
+ return ne((xe = ie.context) == null ? void 0 : xe.elements.floating, B);
1154
+ }), le = j();
1155
+ queueMicrotask(() => {
1156
+ const ie = Tr(le);
1157
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1158
+ k.current && !y.current && fe(ie) && // If the focus moved somewhere else after mount, avoid returning focus
1159
+ // since it likely entered a different element which should be
1160
+ // respected: https://github.com/floating-ui/floating-ui/issues/2607
1161
+ (!(ie !== B && B !== M.body) || pe) && ie.focus({
1162
+ preventScroll: !0
1163
+ }), q.remove();
1164
+ });
1165
+ };
1166
+ }, [r, C, w, k, x, E, a, D, b, P]), d.useEffect(() => (queueMicrotask(() => {
1167
+ y.current = !1;
1168
+ }), () => {
1169
+ queueMicrotask(Et);
1170
+ }), [r]), ue(() => {
1171
+ if (!r && R)
1172
+ return R.setFocusManagerState({
1173
+ modal: c,
1174
+ closeOnFocusOut: g,
1175
+ open: m,
1176
+ onOpenChange: f,
1177
+ domReference: b
1178
+ }), () => {
1179
+ R.setFocusManagerState(null);
1180
+ };
1181
+ }, [r, R, c, m, f, g, b]), ue(() => {
1182
+ r || w && Kt(w, W);
1183
+ }, [r, w, W]);
1184
+ function ce(M) {
1185
+ return r || !p || !c ? null : /* @__PURE__ */ O(kr, {
1186
+ ref: M === "start" ? K : S,
1187
+ onClick: (F) => f(!1, F.nativeEvent),
1188
+ children: typeof p == "string" ? p : "Dismiss"
1189
+ });
1190
+ }
1191
+ const ae = !r && G && (c ? !_ : !0) && (D || c);
1192
+ return /* @__PURE__ */ $e(In, {
1193
+ children: [ae && /* @__PURE__ */ O(ze, {
1194
+ "data-type": "inside",
1195
+ ref: U,
1196
+ onFocus: (M) => {
1197
+ if (c) {
1198
+ const N = $();
1199
+ we(o[0] === "reference" ? N[0] : N[N.length - 1]);
1200
+ } else if (R != null && R.preserveTabOrder && R.portalNode)
1201
+ if (y.current = !1, Ne(M, R.portalNode)) {
1202
+ const N = an(b);
1203
+ N?.focus();
1204
+ } else {
1205
+ var F;
1206
+ (F = R.beforeOutsideRef.current) == null || F.focus();
1207
+ }
1208
+ }
1209
+ }), !_ && ce("start"), n, ce("end"), ae && /* @__PURE__ */ O(ze, {
1210
+ "data-type": "inside",
1211
+ ref: Y,
1212
+ onFocus: (M) => {
1213
+ if (c)
1214
+ we($()[0]);
1215
+ else if (R != null && R.preserveTabOrder && R.portalNode)
1216
+ if (g && (y.current = !0), Ne(M, R.portalNode)) {
1217
+ const N = ln(b);
1218
+ N?.focus();
1219
+ } else {
1220
+ var F;
1221
+ (F = R.afterOutsideRef.current) == null || F.focus();
1222
+ }
1223
+ }
1224
+ })]
1225
+ });
1226
+ }
1227
+ function Wt(e) {
1228
+ return fe(e.target) && e.target.tagName === "BUTTON";
1229
+ }
1230
+ function Pr(e) {
1231
+ return fe(e.target) && e.target.tagName === "A";
1232
+ }
1233
+ function Ht(e) {
1234
+ return un(e);
1235
+ }
1236
+ function Ar(e, t) {
1237
+ t === void 0 && (t = {});
1238
+ const {
1239
+ open: n,
1240
+ onOpenChange: r,
1241
+ dataRef: o,
1242
+ elements: {
1243
+ domReference: s
1244
+ }
1245
+ } = e, {
1246
+ enabled: i = !0,
1247
+ event: u = "click",
1248
+ toggle: l = !0,
1249
+ ignoreMouse: c = !1,
1250
+ keyboardHandlers: p = !0,
1251
+ stickIfOpen: g = !0
1252
+ } = t, v = d.useRef(), h = d.useRef(!1), m = d.useMemo(() => ({
1253
+ onPointerDown(f) {
1254
+ v.current = f.pointerType;
1255
+ },
1256
+ onMouseDown(f) {
1257
+ const E = v.current;
1258
+ f.button === 0 && u !== "click" && (_e(E, !0) && c || (n && l && (!(o.current.openEvent && g) || o.current.openEvent.type === "mousedown") ? r(!1, f.nativeEvent, "click") : (f.preventDefault(), r(!0, f.nativeEvent, "click"))));
1259
+ },
1260
+ onClick(f) {
1261
+ const E = v.current;
1262
+ if (u === "mousedown" && v.current) {
1263
+ v.current = void 0;
1264
+ return;
1265
+ }
1266
+ _e(E, !0) && c || (n && l && (!(o.current.openEvent && g) || o.current.openEvent.type === "click") ? r(!1, f.nativeEvent, "click") : r(!0, f.nativeEvent, "click"));
1267
+ },
1268
+ onKeyDown(f) {
1269
+ v.current = void 0, !(f.defaultPrevented || !p || Wt(f)) && (f.key === " " && !Ht(s) && (f.preventDefault(), h.current = !0), !Pr(f) && f.key === "Enter" && r(!(n && l), f.nativeEvent, "click"));
1270
+ },
1271
+ onKeyUp(f) {
1272
+ f.defaultPrevented || !p || Wt(f) || Ht(s) || f.key === " " && h.current && (h.current = !1, r(!(n && l), f.nativeEvent, "click"));
1273
+ }
1274
+ }), [o, s, u, c, p, r, n, g, l]);
1275
+ return d.useMemo(() => i ? {
1276
+ reference: m
1277
+ } : {}, [i, m]);
1278
+ }
1279
+ const Dr = {
1280
+ pointerdown: "onPointerDown",
1281
+ mousedown: "onMouseDown",
1282
+ click: "onClick"
1283
+ }, Or = {
1284
+ pointerdown: "onPointerDownCapture",
1285
+ mousedown: "onMouseDownCapture",
1286
+ click: "onClickCapture"
1287
+ }, Vt = (e) => {
1288
+ var t, n;
1289
+ return {
1290
+ escapeKey: typeof e == "boolean" ? e : (t = e?.escapeKey) != null ? t : !1,
1291
+ outsidePress: typeof e == "boolean" ? e : (n = e?.outsidePress) != null ? n : !0
1292
+ };
1293
+ };
1294
+ function Nr(e, t) {
1295
+ t === void 0 && (t = {});
1296
+ const {
1297
+ open: n,
1298
+ onOpenChange: r,
1299
+ elements: o,
1300
+ dataRef: s
1301
+ } = e, {
1302
+ enabled: i = !0,
1303
+ escapeKey: u = !0,
1304
+ outsidePress: l = !0,
1305
+ outsidePressEvent: c = "pointerdown",
1306
+ referencePress: p = !1,
1307
+ referencePressEvent: g = "pointerdown",
1308
+ ancestorScroll: v = !1,
1309
+ bubbles: h,
1310
+ capture: m
1311
+ } = t, f = tt(), E = se(typeof l == "function" ? l : () => !1), x = typeof l == "function" ? E : l, b = d.useRef(!1), {
1312
+ escapeKey: C,
1313
+ outsidePress: P
1314
+ } = Vt(h), {
1315
+ escapeKey: T,
1316
+ outsidePress: L
1317
+ } = Vt(m), _ = d.useRef(!1), X = se((a) => {
1318
+ var R;
1319
+ if (!n || !i || !u || a.key !== "Escape" || _.current)
1320
+ return;
1321
+ const K = (R = s.current.floatingContext) == null ? void 0 : R.nodeId, S = f ? Ie(f.nodesRef.current, K) : [];
1322
+ if (!C && (a.stopPropagation(), S.length > 0)) {
1323
+ let y = !0;
1324
+ if (S.forEach((I) => {
1325
+ var A;
1326
+ if ((A = I.context) != null && A.open && !I.context.dataRef.current.__escapeKeyBubbles) {
1327
+ y = !1;
1328
+ return;
1329
+ }
1330
+ }), !y)
1331
+ return;
1332
+ }
1333
+ r(!1, Qn(a) ? a.nativeEvent : a, "escape-key");
1334
+ }), G = se((a) => {
1335
+ var R;
1336
+ const K = () => {
1337
+ var S;
1338
+ X(a), (S = ye(a)) == null || S.removeEventListener("keydown", K);
1339
+ };
1340
+ (R = ye(a)) == null || R.addEventListener("keydown", K);
1341
+ }), H = se((a) => {
1342
+ var R;
1343
+ const K = s.current.insideReactTree;
1344
+ s.current.insideReactTree = !1;
1345
+ const S = b.current;
1346
+ if (b.current = !1, c === "click" && S || K || typeof x == "function" && !x(a))
1347
+ return;
1348
+ const y = ye(a), I = "[" + Me("inert") + "]", A = Q(o.floating).querySelectorAll(I);
1349
+ let V = ge(y) ? y : null;
1350
+ for (; V && !Ue(V); ) {
1351
+ const $ = Zt(V);
1352
+ if (Ue($) || !ge($))
1353
+ break;
1354
+ V = $;
1355
+ }
1356
+ if (A.length && ge(y) && !Jn(y) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
1357
+ !ne(y, o.floating) && // If the target root element contains none of the markers, then the
1358
+ // element was injected after the floating element rendered.
1359
+ Array.from(A).every(($) => !ne(V, $)))
1360
+ return;
1361
+ if (fe(y) && k) {
1362
+ const $ = Ue(y), ee = Gt(y), oe = /auto|scroll/, U = $ || oe.test(ee.overflowX), Y = $ || oe.test(ee.overflowY), ce = U && y.clientWidth > 0 && y.scrollWidth > y.clientWidth, ae = Y && y.clientHeight > 0 && y.scrollHeight > y.clientHeight, M = ee.direction === "rtl", F = ae && (M ? a.offsetX <= y.offsetWidth - y.clientWidth : a.offsetX > y.clientWidth), N = ce && a.offsetY > y.clientHeight;
1363
+ if (F || N)
1364
+ return;
1365
+ }
1366
+ const D = (R = s.current.floatingContext) == null ? void 0 : R.nodeId, w = f && Ie(f.nodesRef.current, D).some(($) => {
1367
+ var ee;
1368
+ return ot(a, (ee = $.context) == null ? void 0 : ee.elements.floating);
1369
+ });
1370
+ if (ot(a, o.floating) || ot(a, o.domReference) || w)
1371
+ return;
1372
+ const z = f ? Ie(f.nodesRef.current, D) : [];
1373
+ if (z.length > 0) {
1374
+ let $ = !0;
1375
+ if (z.forEach((ee) => {
1376
+ var oe;
1377
+ if ((oe = ee.context) != null && oe.open && !ee.context.dataRef.current.__outsidePressBubbles) {
1378
+ $ = !1;
1379
+ return;
1380
+ }
1381
+ }), !$)
1382
+ return;
1383
+ }
1384
+ r(!1, a, "outside-press");
1385
+ }), W = se((a) => {
1386
+ var R;
1387
+ const K = () => {
1388
+ var S;
1389
+ H(a), (S = ye(a)) == null || S.removeEventListener(c, K);
1390
+ };
1391
+ (R = ye(a)) == null || R.addEventListener(c, K);
1392
+ });
1393
+ d.useEffect(() => {
1394
+ if (!n || !i)
1395
+ return;
1396
+ s.current.__escapeKeyBubbles = C, s.current.__outsidePressBubbles = P;
1397
+ let a = -1;
1398
+ function R(A) {
1399
+ r(!1, A, "ancestor-scroll");
1400
+ }
1401
+ function K() {
1402
+ window.clearTimeout(a), _.current = !0;
1403
+ }
1404
+ function S() {
1405
+ a = window.setTimeout(
1406
+ () => {
1407
+ _.current = !1;
1408
+ },
1409
+ // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
1410
+ // Only apply to WebKit for the test to remain 0ms.
1411
+ An() ? 5 : 0
1412
+ );
1413
+ }
1414
+ const y = Q(o.floating);
1415
+ u && (y.addEventListener("keydown", T ? G : X, T), y.addEventListener("compositionstart", K), y.addEventListener("compositionend", S)), x && y.addEventListener(c, L ? W : H, L);
1416
+ let I = [];
1417
+ return v && (ge(o.domReference) && (I = Oe(o.domReference)), ge(o.floating) && (I = I.concat(Oe(o.floating))), !ge(o.reference) && o.reference && o.reference.contextElement && (I = I.concat(Oe(o.reference.contextElement)))), I = I.filter((A) => {
1418
+ var V;
1419
+ return A !== ((V = y.defaultView) == null ? void 0 : V.visualViewport);
1420
+ }), I.forEach((A) => {
1421
+ A.addEventListener("scroll", R, {
1422
+ passive: !0
1423
+ });
1424
+ }), () => {
1425
+ u && (y.removeEventListener("keydown", T ? G : X, T), y.removeEventListener("compositionstart", K), y.removeEventListener("compositionend", S)), x && y.removeEventListener(c, L ? W : H, L), I.forEach((A) => {
1426
+ A.removeEventListener("scroll", R);
1427
+ }), window.clearTimeout(a);
1428
+ };
1429
+ }, [s, o, u, x, c, n, r, v, i, C, P, X, T, G, H, L, W]), d.useEffect(() => {
1430
+ s.current.insideReactTree = !1;
1431
+ }, [s, x, c]);
1432
+ const Z = d.useMemo(() => ({
1433
+ onKeyDown: X,
1434
+ ...p && {
1435
+ [Dr[g]]: (a) => {
1436
+ r(!1, a.nativeEvent, "reference-press");
1437
+ },
1438
+ ...g !== "click" && {
1439
+ onClick(a) {
1440
+ r(!1, a.nativeEvent, "reference-press");
1441
+ }
1442
+ }
1443
+ }
1444
+ }), [X, r, p, g]), k = d.useMemo(() => {
1445
+ function a(R) {
1446
+ R.button === 0 && (b.current = !0);
1447
+ }
1448
+ return {
1449
+ onKeyDown: X,
1450
+ onMouseDown: a,
1451
+ onMouseUp: a,
1452
+ [Or[c]]: () => {
1453
+ s.current.insideReactTree = !0;
1454
+ }
1455
+ };
1456
+ }, [X, c, s]);
1457
+ return d.useMemo(() => i ? {
1458
+ reference: Z,
1459
+ floating: k
1460
+ } : {}, [i, Z, k]);
1461
+ }
1462
+ function lt(e, t, n) {
1463
+ const r = /* @__PURE__ */ new Map(), o = n === "item";
1464
+ let s = e;
1465
+ if (o && e) {
1466
+ const {
1467
+ [kt]: i,
1468
+ [Mt]: u,
1469
+ ...l
1470
+ } = e;
1471
+ s = l;
1472
+ }
1473
+ return {
1474
+ ...n === "floating" && {
1475
+ tabIndex: -1,
1476
+ [cr]: ""
1477
+ },
1478
+ ...s,
1479
+ ...t.map((i) => {
1480
+ const u = i ? i[n] : null;
1481
+ return typeof u == "function" ? e ? u(e) : null : u;
1482
+ }).concat(e).reduce((i, u) => (u && Object.entries(u).forEach((l) => {
1483
+ let [c, p] = l;
1484
+ if (!(o && [kt, Mt].includes(c)))
1485
+ if (c.indexOf("on") === 0) {
1486
+ if (r.has(c) || r.set(c, []), typeof p == "function") {
1487
+ var g;
1488
+ (g = r.get(c)) == null || g.push(p), i[c] = function() {
1489
+ for (var v, h = arguments.length, m = new Array(h), f = 0; f < h; f++)
1490
+ m[f] = arguments[f];
1491
+ return (v = r.get(c)) == null ? void 0 : v.map((E) => E(...m)).find((E) => E !== void 0);
1492
+ };
1493
+ }
1494
+ } else
1495
+ i[c] = p;
1496
+ }), i), {})
1497
+ };
1498
+ }
1499
+ function Lr(e) {
1500
+ e === void 0 && (e = []);
1501
+ const t = e.map((u) => u?.reference), n = e.map((u) => u?.floating), r = e.map((u) => u?.item), o = d.useCallback(
1502
+ (u) => lt(u, e, "reference"),
1503
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1504
+ t
1505
+ ), s = d.useCallback(
1506
+ (u) => lt(u, e, "floating"),
1507
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1508
+ n
1509
+ ), i = d.useCallback(
1510
+ (u) => lt(u, e, "item"),
1511
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1512
+ r
1513
+ );
1514
+ return d.useMemo(() => ({
1515
+ getReferenceProps: o,
1516
+ getFloatingProps: s,
1517
+ getItemProps: i
1518
+ }), [o, s, i]);
1519
+ }
1520
+ const Fr = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
1521
+ function _r(e, t) {
1522
+ var n, r;
1523
+ t === void 0 && (t = {});
1524
+ const {
1525
+ open: o,
1526
+ elements: s,
1527
+ floatingId: i
1528
+ } = e, {
1529
+ enabled: u = !0,
1530
+ role: l = "dialog"
1531
+ } = t, c = ht(), p = ((n = s.domReference) == null ? void 0 : n.id) || c, g = d.useMemo(() => {
1532
+ var b;
1533
+ return ((b = mt(s.floating)) == null ? void 0 : b.id) || i;
1534
+ }, [s.floating, i]), v = (r = Fr.get(l)) != null ? r : l, m = We() != null, f = d.useMemo(() => v === "tooltip" || l === "label" ? {
1535
+ ["aria-" + (l === "label" ? "labelledby" : "describedby")]: o ? g : void 0
1536
+ } : {
1537
+ "aria-expanded": o ? "true" : "false",
1538
+ "aria-haspopup": v === "alertdialog" ? "dialog" : v,
1539
+ "aria-controls": o ? g : void 0,
1540
+ ...v === "listbox" && {
1541
+ role: "combobox"
1542
+ },
1543
+ ...v === "menu" && {
1544
+ id: p
1545
+ },
1546
+ ...v === "menu" && m && {
1547
+ role: "menuitem"
1548
+ },
1549
+ ...l === "select" && {
1550
+ "aria-autocomplete": "none"
1551
+ },
1552
+ ...l === "combobox" && {
1553
+ "aria-autocomplete": "list"
1554
+ }
1555
+ }, [v, g, m, o, p, l]), E = d.useMemo(() => {
1556
+ const b = {
1557
+ id: g,
1558
+ ...v && {
1559
+ role: v
1560
+ }
1561
+ };
1562
+ return v === "tooltip" || l === "label" ? b : {
1563
+ ...b,
1564
+ ...v === "menu" && {
1565
+ "aria-labelledby": p
1566
+ }
1567
+ };
1568
+ }, [v, g, p, l]), x = d.useCallback((b) => {
1569
+ let {
1570
+ active: C,
1571
+ selected: P
1572
+ } = b;
1573
+ const T = {
1574
+ role: "option",
1575
+ ...C && {
1576
+ id: g + "-fui-option"
1577
+ }
1578
+ };
1579
+ switch (l) {
1580
+ case "select":
1581
+ case "combobox":
1582
+ return {
1583
+ ...T,
1584
+ "aria-selected": P
1585
+ };
1586
+ }
1587
+ return {};
1588
+ }, [g, l]);
1589
+ return d.useMemo(() => u ? {
1590
+ reference: f,
1591
+ floating: E,
1592
+ item: x
1593
+ } : {}, [u, f, E, x]);
1594
+ }
1595
+ function vn(e, t, n) {
1596
+ return n === void 0 && (n = !0), e.filter((o) => {
1597
+ var s;
1598
+ return o.parentId === t && (!n || ((s = o.context) == null ? void 0 : s.open));
1599
+ }).flatMap((o) => [o, ...vn(e, o.id, n)]);
1600
+ }
1601
+ function Ut(e, t) {
1602
+ const [n, r] = e;
1603
+ let o = !1;
1604
+ const s = t.length;
1605
+ for (let i = 0, u = s - 1; i < s; u = i++) {
1606
+ const [l, c] = t[i] || [0, 0], [p, g] = t[u] || [0, 0];
1607
+ c >= r != g >= r && n <= (p - l) * (r - c) / (g - c) + l && (o = !o);
1608
+ }
1609
+ return o;
1610
+ }
1611
+ function $r(e, t) {
1612
+ return e[0] >= t.x && e[0] <= t.x + t.width && e[1] >= t.y && e[1] <= t.y + t.height;
1613
+ }
1614
+ function Br(e) {
1615
+ e === void 0 && (e = {});
1616
+ const {
1617
+ buffer: t = 0.5,
1618
+ blockPointerEvents: n = !1,
1619
+ requireIntent: r = !0
1620
+ } = e, o = {
1621
+ current: -1
1622
+ };
1623
+ let s = !1, i = null, u = null, l = typeof performance < "u" ? performance.now() : 0;
1624
+ function c(g, v) {
1625
+ const h = performance.now(), m = h - l;
1626
+ if (i === null || u === null || m === 0)
1627
+ return i = g, u = v, l = h, null;
1628
+ const f = g - i, E = v - u, b = Math.sqrt(f * f + E * E) / m;
1629
+ return i = g, u = v, l = h, b;
1630
+ }
1631
+ const p = (g) => {
1632
+ let {
1633
+ x: v,
1634
+ y: h,
1635
+ placement: m,
1636
+ elements: f,
1637
+ onClose: E,
1638
+ nodeId: x,
1639
+ tree: b
1640
+ } = g;
1641
+ return function(P) {
1642
+ function T() {
1643
+ te(o), E();
1644
+ }
1645
+ if (te(o), !f.domReference || !f.floating || m == null || v == null || h == null)
1646
+ return;
1647
+ const {
1648
+ clientX: L,
1649
+ clientY: _
1650
+ } = P, X = [L, _], G = hr(P), H = P.type === "mouseleave", W = ct(f.floating, G), Z = ct(f.domReference, G), k = f.domReference.getBoundingClientRect(), a = f.floating.getBoundingClientRect(), R = m.split("-")[0], K = v > a.right - a.width / 2, S = h > a.bottom - a.height / 2, y = $r(X, k), I = a.width > k.width, A = a.height > k.height, V = (I ? k : a).left, D = (I ? k : a).right, w = (A ? k : a).top, z = (A ? k : a).bottom;
1651
+ if (W && (s = !0, !H))
1652
+ return;
1653
+ if (Z && (s = !1), Z && !H) {
1654
+ s = !0;
1655
+ return;
1656
+ }
1657
+ if (H && ge(P.relatedTarget) && ct(f.floating, P.relatedTarget) || b && vn(b.nodesRef.current, x).length)
1658
+ return;
1659
+ if (R === "top" && h >= k.bottom - 1 || R === "bottom" && h <= k.top + 1 || R === "left" && v >= k.right - 1 || R === "right" && v <= k.left + 1)
1660
+ return T();
1661
+ let $ = [];
1662
+ switch (R) {
1663
+ case "top":
1664
+ $ = [[V, k.top + 1], [V, a.bottom - 1], [D, a.bottom - 1], [D, k.top + 1]];
1665
+ break;
1666
+ case "bottom":
1667
+ $ = [[V, a.top + 1], [V, k.bottom - 1], [D, k.bottom - 1], [D, a.top + 1]];
1668
+ break;
1669
+ case "left":
1670
+ $ = [[a.right - 1, z], [a.right - 1, w], [k.left + 1, w], [k.left + 1, z]];
1671
+ break;
1672
+ case "right":
1673
+ $ = [[k.right - 1, z], [k.right - 1, w], [a.left + 1, w], [a.left + 1, z]];
1674
+ break;
1675
+ }
1676
+ function ee(oe) {
1677
+ let [U, Y] = oe;
1678
+ switch (R) {
1679
+ case "top": {
1680
+ const ce = [I ? U + t / 2 : K ? U + t * 4 : U - t * 4, Y + t + 1], ae = [I ? U - t / 2 : K ? U + t * 4 : U - t * 4, Y + t + 1], M = [[a.left, K || I ? a.bottom - t : a.top], [a.right, K ? I ? a.bottom - t : a.top : a.bottom - t]];
1681
+ return [ce, ae, ...M];
1682
+ }
1683
+ case "bottom": {
1684
+ const ce = [I ? U + t / 2 : K ? U + t * 4 : U - t * 4, Y - t], ae = [I ? U - t / 2 : K ? U + t * 4 : U - t * 4, Y - t], M = [[a.left, K || I ? a.top + t : a.bottom], [a.right, K ? I ? a.top + t : a.bottom : a.top + t]];
1685
+ return [ce, ae, ...M];
1686
+ }
1687
+ case "left": {
1688
+ const ce = [U + t + 1, A ? Y + t / 2 : S ? Y + t * 4 : Y - t * 4], ae = [U + t + 1, A ? Y - t / 2 : S ? Y + t * 4 : Y - t * 4];
1689
+ return [...[[S || A ? a.right - t : a.left, a.top], [S ? A ? a.right - t : a.left : a.right - t, a.bottom]], ce, ae];
1690
+ }
1691
+ case "right": {
1692
+ const ce = [U - t, A ? Y + t / 2 : S ? Y + t * 4 : Y - t * 4], ae = [U - t, A ? Y - t / 2 : S ? Y + t * 4 : Y - t * 4], M = [[S || A ? a.left + t : a.right, a.top], [S ? A ? a.left + t : a.right : a.left + t, a.bottom]];
1693
+ return [ce, ae, ...M];
1694
+ }
1695
+ }
1696
+ }
1697
+ if (!Ut([L, _], $)) {
1698
+ if (s && !y)
1699
+ return T();
1700
+ if (!H && r) {
1701
+ const oe = c(P.clientX, P.clientY);
1702
+ if (oe !== null && oe < 0.1)
1703
+ return T();
1704
+ }
1705
+ Ut([L, _], ee([v, h])) ? !s && r && (o.current = window.setTimeout(T, 40)) : T();
1706
+ }
1707
+ };
1708
+ };
1709
+ return p.__options = {
1710
+ blockPointerEvents: n
1711
+ }, p;
1712
+ }
1713
+ const Rt = Xt(null), be = () => {
1714
+ const e = Be(Rt);
1715
+ if (!e)
1716
+ throw new Error("Menu compound components must be used within <Menu>");
1717
+ return e;
1718
+ }, Kr = 150, Wr = 160, Hr = 1300, Vr = 250, Ur = "0.875rem", qr = "0.8125rem", Yr = "0.75rem", Xr = "0.75rem", jr = "0.625rem", qt = 20, Gr = 20, hn = "0.375rem", Zr = 1.5, zr = 150, Jr = 200, Qr = 500, yn = '[role="menuitem"]:not([aria-disabled="true"])', eo = (e) => Array.from(
1719
+ e.querySelectorAll(yn)
1720
+ ).filter(
1721
+ (n) => n.closest('[role="menu"][data-collapsed="true"]') === null
1722
+ ), Le = (e) => {
1723
+ e.stopPropagation(), e.preventDefault();
1724
+ }, to = (e) => {
1725
+ const t = Re(""), n = Re(null), r = J(() => e.current ? eo(e.current) : [], [e]), o = J((i) => {
1726
+ r().forEach((u) => {
1727
+ u.tabIndex = -1;
1728
+ }), i.tabIndex = 0, i.focus();
1729
+ }, [r]);
1730
+ return qe(() => {
1731
+ const i = r();
1732
+ if (i.length > 0) {
1733
+ const u = i.find((l) => l.tabIndex === 0) || i[0];
1734
+ u.tabIndex = 0;
1735
+ }
1736
+ }, [r]), qe(() => {
1737
+ const i = e.current;
1738
+ if (!i) return;
1739
+ const u = (l) => {
1740
+ if (l.target === i) {
1741
+ const c = r();
1742
+ if (c.length > 0) {
1743
+ const p = c.find((g) => g.tabIndex === 0) || c[0];
1744
+ o(p);
1745
+ }
1746
+ }
1747
+ };
1748
+ return i.addEventListener("focusin", u), () => i.removeEventListener("focusin", u);
1749
+ }, [e, r, o]), { onKeyDown: J((i) => {
1750
+ if (!e.current?.contains(i.target))
1751
+ return;
1752
+ const u = r();
1753
+ if (u.length === 0) return;
1754
+ const l = u.indexOf(document.activeElement);
1755
+ switch (i.key) {
1756
+ case "ArrowDown":
1757
+ i.preventDefault(), o(u[(l + 1) % u.length]);
1758
+ break;
1759
+ case "ArrowUp":
1760
+ i.preventDefault(), o(u[(l - 1 + u.length) % u.length]);
1761
+ break;
1762
+ case "Home":
1763
+ i.preventDefault(), o(u[0]);
1764
+ break;
1765
+ case "End":
1766
+ i.preventDefault(), o(u[u.length - 1]);
1767
+ break;
1768
+ default:
1769
+ if (i.key.length === 1 && !i.ctrlKey && !i.metaKey && !i.altKey) {
1770
+ Le(i), n.current && clearTimeout(n.current), t.current += i.key.toLowerCase();
1771
+ const c = u.find((p) => (p.textContent?.trim().toLowerCase() || "").startsWith(t.current));
1772
+ c && o(c), n.current = window.setTimeout(() => {
1773
+ t.current = "";
1774
+ }, Qr);
1775
+ }
1776
+ break;
1777
+ }
1778
+ }, [r, o]) };
1779
+ }, no = re.div(
1780
+ ({ ownerMaxHeight: e, ownerColorScheme: t }) => {
1781
+ const { palette: n } = de();
1782
+ return {
1783
+ display: "flex",
1784
+ flexDirection: "column",
1785
+ "&:focus": {
1786
+ outline: "none"
1787
+ },
1788
+ ...t?.background && { backgroundColor: t.background },
1789
+ color: t?.color ?? n?.text?.primary ?? "rgba(0,0,0,0.87)",
1790
+ ...e !== void 0 && {
1791
+ maxHeight: typeof e == "number" ? `${e}px` : e,
1792
+ overflowY: "auto"
1793
+ }
1794
+ };
1795
+ }
1796
+ ), En = re.div(
1797
+ ({ ownerDanger: e, ownerDisabled: t, ownerSelected: n, ownerSoftSelected: r, ownerDense: o, ownerIconOnly: s, ownerColorScheme: i }) => {
1798
+ const { palette: u, spacing: l } = de(), c = i?.activeBg ?? u?.action?.selected ?? "rgba(25,118,210,0.16)", p = i?.softSelectedBg ?? u?.action?.hover ?? "rgba(25,118,210,0.06)", g = e ? i?.dangerColor ?? u?.error?.main ?? "#d32f2f" : t ? i?.disabledColor ?? u?.text?.disabled ?? "rgba(0,0,0,0.38)" : i?.color ?? u?.text?.primary ?? "rgba(0,0,0,0.87)";
1799
+ return {
1800
+ display: "flex",
1801
+ alignItems: "center",
1802
+ ...s && {
1803
+ justifyContent: "center"
1804
+ },
1805
+ gap: s ? 0 : l?.small ?? "0.5rem",
1806
+ padding: o ? s ? `${l?.tiny ?? "0.25rem"}` : `${l?.tiny ?? "0.25rem"} ${l?.medium ?? "0.75rem"}` : s ? `${l?.small ?? "0.5rem"}` : `${l?.small ?? "0.5rem"} ${l?.large ?? "1rem"}`,
1807
+ color: g,
1808
+ fontSize: o ? qr : Ur,
1809
+ lineHeight: Zr,
1810
+ cursor: t ? "default" : "pointer",
1811
+ userSelect: "none",
1812
+ position: "relative",
1813
+ outline: "none",
1814
+ borderRadius: hn,
1815
+ transition: `background-color ${zr}ms`,
1816
+ ...!t && {
1817
+ "&:hover": {
1818
+ backgroundColor: e ? i?.dangerHoverBg ?? u?.error?.light ?? "rgba(211,47,47,0.08)" : i?.hoverBg ?? u?.action?.hover ?? "rgba(0,0,0,0.04)",
1819
+ ...i?.hoverColor && { color: i.hoverColor }
1820
+ },
1821
+ "&:focus-visible": {
1822
+ outline: "2px solid transparent",
1823
+ boxShadow: `inset 0 0 0 2px ${i?.focusRingColor ?? u?.primary?.main ?? "#1976d2"}`
1824
+ }
1825
+ },
1826
+ // Soft-select: parent has selected child — light bg, no bold
1827
+ ...r && !n && {
1828
+ backgroundColor: p
1829
+ },
1830
+ // Full select: the actual selected item — darker bg + bold
1831
+ ...n && {
1832
+ backgroundColor: c,
1833
+ fontWeight: 600,
1834
+ ...i?.activeColor && { color: i.activeColor }
1835
+ }
1836
+ };
1837
+ }
1838
+ ), Rn = re.span({
1839
+ display: "inline-flex",
1840
+ alignItems: "center",
1841
+ justifyContent: "center",
1842
+ flexShrink: 0,
1843
+ width: qt,
1844
+ height: qt,
1845
+ "& > svg": {
1846
+ width: "100%",
1847
+ height: "100%",
1848
+ fill: "currentColor"
1849
+ }
1850
+ }), xn = re.span(
1851
+ ({ ownerIconOnly: e }) => ({
1852
+ flex: 1,
1853
+ overflow: "hidden",
1854
+ textOverflow: "ellipsis",
1855
+ whiteSpace: "nowrap",
1856
+ ...e && {
1857
+ display: "none"
1858
+ }
1859
+ })
1860
+ ), ro = re.span(
1861
+ ({ ownerColorScheme: e }) => {
1862
+ const { palette: t } = de();
1863
+ return {
1864
+ marginLeft: "auto",
1865
+ paddingLeft: "2rem",
1866
+ color: e?.secondaryColor ?? t?.text?.secondary ?? "rgba(0,0,0,0.6)",
1867
+ fontSize: Yr,
1868
+ flexShrink: 0
1869
+ };
1870
+ }
1871
+ );
1872
+ re.span({
1873
+ display: "inline-flex",
1874
+ width: Gr,
1875
+ flexShrink: 0
1876
+ });
1877
+ const oo = re.div(
1878
+ ({ ownerColorScheme: e }) => {
1879
+ const { palette: t, spacing: n } = de();
1880
+ return {
1881
+ padding: `${n?.small ?? "0.5rem"} ${n?.large ?? "1rem"}`,
1882
+ color: e?.secondaryColor ?? t?.text?.secondary ?? "rgba(0,0,0,0.6)",
1883
+ fontSize: Xr,
1884
+ fontWeight: 600,
1885
+ textTransform: "uppercase",
1886
+ letterSpacing: "0.05em",
1887
+ userSelect: "none"
1888
+ };
1889
+ }
1890
+ ), io = re.hr(
1891
+ ({ ownerColorScheme: e }) => {
1892
+ const { palette: t, spacing: n } = de();
1893
+ return {
1894
+ border: "none",
1895
+ borderTop: `1px solid ${e?.dividerColor ?? t?.divider ?? "rgba(0,0,0,0.12)"}`,
1896
+ margin: `${n?.tiny ?? "0.25rem"} 0`
1897
+ };
1898
+ }
1899
+ ), so = re.span(
1900
+ ({ ownerColorScheme: e }) => {
1901
+ const { palette: t } = de();
1902
+ return {
1903
+ marginLeft: "auto",
1904
+ paddingLeft: "1rem",
1905
+ color: e?.secondaryColor ?? t?.text?.secondary ?? "rgba(0,0,0,0.6)",
1906
+ fontSize: jr,
1907
+ flexShrink: 0
1908
+ };
1909
+ }
1910
+ ), uo = re.div(
1911
+ ({ ownerOpen: e, ownerColorScheme: t, ownerShowDot: n }) => {
1912
+ const { spacing: r, palette: o } = de();
1913
+ return {
1914
+ overflow: "hidden",
1915
+ maxHeight: e ? "100vh" : 0,
1916
+ opacity: e ? 1 : 0,
1917
+ transition: `max-height ${Vr}ms ease, opacity ${Jr}ms ease`,
1918
+ paddingLeft: r?.large ?? "1rem",
1919
+ '& > [role="menuitem"]': {
1920
+ "&:hover": {
1921
+ backgroundColor: t?.childHoverBg ?? "rgba(25,118,210,0.06)",
1922
+ ...t?.childHoverColor && { color: t.childHoverColor }
1923
+ },
1924
+ ...n && {
1925
+ "&::before": {
1926
+ content: '""',
1927
+ display: "inline-block",
1928
+ width: 6,
1929
+ height: 6,
1930
+ borderRadius: "50%",
1931
+ border: `1.5px solid ${t?.dotColor ?? o?.text?.secondary ?? "rgba(0,0,0,0.4)"}`,
1932
+ backgroundColor: "transparent",
1933
+ marginRight: r?.small ?? "0.5rem",
1934
+ flexShrink: 0,
1935
+ transition: "background-color 150ms, border-color 150ms"
1936
+ },
1937
+ // Hover → fill dot
1938
+ "&:hover::before": {
1939
+ backgroundColor: t?.dotColor ?? o?.text?.secondary ?? "rgba(0,0,0,0.4)",
1940
+ borderColor: t?.dotColor ?? o?.text?.secondary ?? "rgba(0,0,0,0.4)"
1941
+ },
1942
+ // Selected → fill dot with active color
1943
+ '&[aria-current="page"]::before': {
1944
+ backgroundColor: t?.dotActiveColor ?? o?.primary?.main ?? "#1976d2",
1945
+ borderColor: t?.dotActiveColor ?? o?.primary?.main ?? "#1976d2"
1946
+ }
1947
+ }
1948
+ }
1949
+ };
1950
+ }
1951
+ ), co = re.div(
1952
+ ({ ownerColorScheme: e }) => {
1953
+ const { palette: t, spacing: n } = de();
1954
+ return {
1955
+ minWidth: Wr,
1956
+ backgroundColor: e?.popoverBg ?? t?.background?.paper ?? "#fff",
1957
+ borderRadius: hn,
1958
+ boxShadow: "0 4px 20px rgba(0,0,0,0.15)",
1959
+ border: `1px solid ${e?.popoverBorderColor ?? t?.divider ?? "rgba(0,0,0,0.12)"}`,
1960
+ padding: `${n?.tiny ?? "0.25rem"} 0`,
1961
+ zIndex: Hr,
1962
+ display: "flex",
1963
+ flexDirection: "column"
1964
+ };
1965
+ }
1966
+ ), Yt = re.span({
1967
+ display: "inline-flex",
1968
+ alignItems: "center",
1969
+ marginLeft: "auto",
1970
+ paddingLeft: "0.5rem",
1971
+ flexShrink: 0
1972
+ }), ao = re.span(
1973
+ ({ ownerColorScheme: e }) => {
1974
+ const { palette: t } = de();
1975
+ return {
1976
+ display: "inline-block",
1977
+ width: 6,
1978
+ height: 6,
1979
+ borderRadius: "50%",
1980
+ backgroundColor: e?.activeIconColor ?? t?.primary?.main ?? "#1976d2",
1981
+ transition: "background-color 150ms"
1982
+ };
1983
+ }
1984
+ ), lo = re.span(
1985
+ ({ ownerColorScheme: e }) => {
1986
+ const { palette: t } = de();
1987
+ return {
1988
+ display: "inline-block",
1989
+ width: 3,
1990
+ height: 16,
1991
+ borderRadius: 1.5,
1992
+ backgroundColor: e?.activeIconColor ?? t?.primary?.main ?? "#1976d2",
1993
+ transition: "background-color 150ms"
1994
+ };
1995
+ }
1996
+ ), fo = Ae(
1997
+ ({ children: e, dense: t = !1, mode: n = "inline", display: r = "default", trigger: o = "hover", floatingSettings: s, colorScheme: i, activeIndicator: u = "dot", showDot: l = !1, maxHeight: c, className: p, style: g, onKeyDown: v, ...h }, m) => {
1998
+ const f = Re(null), E = fn([f, m]), { onKeyDown: x } = to(f), b = J(
1999
+ (P) => {
2000
+ x(P), v?.(P);
2001
+ },
2002
+ [x, v]
2003
+ ), C = gt(
2004
+ () => ({ dense: t, mode: n, display: r, trigger: o, floatingSettings: s, colorScheme: i, activeIndicator: u, showDot: l }),
2005
+ [t, n, r, o, s, i, u, l]
2006
+ );
2007
+ return /* @__PURE__ */ O(Rt.Provider, { value: C, children: /* @__PURE__ */ O(
2008
+ no,
2009
+ {
2010
+ ref: E,
2011
+ role: "menu",
2012
+ tabIndex: 0,
2013
+ className: p,
2014
+ style: g,
2015
+ ownerMaxHeight: c,
2016
+ ownerColorScheme: i,
2017
+ onKeyDown: b,
2018
+ ...h,
2019
+ children: e
2020
+ }
2021
+ ) });
2022
+ }
2023
+ );
2024
+ fo.displayName = "Menu";
2025
+ const Pe = Xt(null), nt = () => {
2026
+ const e = Be(Pe);
2027
+ if (!e)
2028
+ throw new Error("MenuSubTrigger/MenuSubContent must be used within <MenuSub>");
2029
+ return e;
2030
+ }, po = () => Be(Pe), mo = ({
2031
+ children: e,
2032
+ open: t,
2033
+ defaultOpen: n = !1,
2034
+ onOpenChange: r,
2035
+ resolvedMode: o,
2036
+ resolvedTrigger: s
2037
+ }) => {
2038
+ const [i, u] = Ye(n), [l, c] = Ye(0), p = Re(!1), g = t !== void 0, v = g ? t : i, h = l > 0, m = bt(), f = J(
2039
+ (T) => {
2040
+ g || u(T), r?.(T);
2041
+ },
2042
+ [g, r]
2043
+ ), E = J(() => {
2044
+ f(!v);
2045
+ }, [v, f]), x = Be(Pe), b = Re(null), C = J(() => (c((T) => {
2046
+ const L = T + 1;
2047
+ return L === 1 && !p.current && (p.current = !0, f(!0)), L === 1 && x && (b.current = x.registerSelected()), L;
2048
+ }), () => {
2049
+ c((T) => {
2050
+ const L = T - 1;
2051
+ return L === 0 && b.current && (b.current(), b.current = null), L;
2052
+ });
2053
+ }), [f, x]), P = gt(
2054
+ () => ({
2055
+ isOpen: v,
2056
+ toggle: E,
2057
+ setOpen: f,
2058
+ hasSelectedChild: h,
2059
+ registerSelected: C,
2060
+ triggerId: m,
2061
+ resolvedMode: o,
2062
+ resolvedTrigger: s,
2063
+ // Inline mode does not use floating UI
2064
+ setReference: null,
2065
+ setFloating: null,
2066
+ floatingStyles: null,
2067
+ context: null,
2068
+ getReferenceProps: null,
2069
+ getFloatingProps: null
2070
+ }),
2071
+ [v, E, f, h, C, m, o, s]
2072
+ );
2073
+ return /* @__PURE__ */ O(Pe.Provider, { value: P, children: e });
2074
+ }, go = ({
2075
+ children: e,
2076
+ open: t,
2077
+ defaultOpen: n = !1,
2078
+ onOpenChange: r,
2079
+ resolvedMode: o,
2080
+ resolvedTrigger: s
2081
+ }) => {
2082
+ const [i, u] = Ye(n), [l, c] = Ye(0), p = t !== void 0, g = p ? t : i, v = l > 0, h = bt(), m = J(
2083
+ (k) => {
2084
+ p || u(k), r?.(k);
2085
+ },
2086
+ [p, r]
2087
+ ), f = J(() => {
2088
+ m(!g);
2089
+ }, [g, m]), E = Be(Pe), x = Re(null), b = J(() => (c((k) => {
2090
+ const a = k + 1;
2091
+ return a === 1 && E && (x.current = E.registerSelected()), a;
2092
+ }), () => {
2093
+ c((k) => {
2094
+ const a = k - 1;
2095
+ return a === 0 && x.current && (x.current(), x.current = null), a;
2096
+ });
2097
+ }), [E]), C = mr(), { floatingSettings: P } = be(), T = Mn({
2098
+ open: g,
2099
+ onOpenChange: m,
2100
+ nodeId: C,
2101
+ placement: P?.placement ?? "right-start",
2102
+ // default popover placement
2103
+ offset: P?.offset
2104
+ // Default offset, flip, shift are handled by useFloatingPosition
2105
+ }), L = vr(T.context, {
2106
+ enabled: s === "hover",
2107
+ delay: { open: 0, close: Kr },
2108
+ handleClose: Br({ blockPointerEvents: !0 })
2109
+ }), _ = Ar(T.context, {
2110
+ enabled: s === "click"
2111
+ }), X = Nr(T.context), G = _r(T.context, { role: "menu" }), { getReferenceProps: H, getFloatingProps: W } = Lr([
2112
+ L,
2113
+ _,
2114
+ X,
2115
+ G
2116
+ ]), Z = gt(
2117
+ () => ({
2118
+ isOpen: g,
2119
+ toggle: f,
2120
+ setOpen: m,
2121
+ hasSelectedChild: v,
2122
+ registerSelected: b,
2123
+ triggerId: h,
2124
+ resolvedMode: o,
2125
+ resolvedTrigger: s,
2126
+ setReference: T.setReference,
2127
+ setFloating: T.setFloating,
2128
+ floatingStyles: T.floatingStyles,
2129
+ context: T.context,
2130
+ getReferenceProps: H,
2131
+ getFloatingProps: W
2132
+ }),
2133
+ [
2134
+ g,
2135
+ f,
2136
+ m,
2137
+ v,
2138
+ b,
2139
+ h,
2140
+ o,
2141
+ s,
2142
+ T.setReference,
2143
+ T.setFloating,
2144
+ T.floatingStyles,
2145
+ T.context,
2146
+ H,
2147
+ W
2148
+ ]
2149
+ );
2150
+ return /* @__PURE__ */ O(Pe.Provider, { value: Z, children: /* @__PURE__ */ O(gr, { id: C, children: e }) });
2151
+ }, bo = ({ mode: e, trigger: t, ...n }) => {
2152
+ const { mode: r, trigger: o } = be(), s = We(), i = e ?? r ?? "inline", u = t ?? o ?? "hover";
2153
+ if (i === "popover") {
2154
+ const l = /* @__PURE__ */ O(go, { resolvedMode: i, resolvedTrigger: u, ...n });
2155
+ return s === null ? /* @__PURE__ */ O(br, { children: l }) : l;
2156
+ }
2157
+ return /* @__PURE__ */ O(mo, { resolvedMode: i, resolvedTrigger: u, ...n });
2158
+ };
2159
+ bo.displayName = "MenuSub";
2160
+ const vo = Ae(
2161
+ ({
2162
+ children: e,
2163
+ icon: t,
2164
+ shortcut: n,
2165
+ disabled: r = !1,
2166
+ danger: o = !1,
2167
+ selected: s = !1,
2168
+ onClick: i,
2169
+ ...u
2170
+ }, l) => {
2171
+ const { dense: c, display: p, colorScheme: g, activeIndicator: v } = be(), h = po(), m = p === "icon";
2172
+ qe(() => {
2173
+ if (s && h)
2174
+ return h.registerSelected();
2175
+ }, [s, h]);
2176
+ const f = J(() => {
2177
+ r || i?.();
2178
+ }, [r, i]), E = J(
2179
+ (b) => {
2180
+ r || (b.key === "Enter" || b.key === " ") && (b.preventDefault(), f());
2181
+ },
2182
+ [r, f]
2183
+ );
2184
+ return /* @__PURE__ */ $e(
2185
+ En,
2186
+ {
2187
+ ref: l,
2188
+ role: "menuitem",
2189
+ tabIndex: -1,
2190
+ "aria-disabled": r || void 0,
2191
+ "aria-current": s ? "page" : void 0,
2192
+ ownerDanger: o,
2193
+ ownerDisabled: r,
2194
+ ownerSelected: s,
2195
+ ownerSoftSelected: !1,
2196
+ ownerDense: c,
2197
+ ownerIconOnly: m,
2198
+ ownerColorScheme: g,
2199
+ onClick: f,
2200
+ onKeyDown: E,
2201
+ ...u,
2202
+ children: [
2203
+ t && /* @__PURE__ */ O(Rn, { "aria-hidden": "true", children: t }),
2204
+ /* @__PURE__ */ O(xn, { ownerIconOnly: m, children: e }),
2205
+ n && !m && /* @__PURE__ */ O(ro, { ownerColorScheme: g, children: n }),
2206
+ !s || v === !1 || m ? null : v !== "dot" && v !== "bar" && v !== void 0 ? /* @__PURE__ */ O(Yt, { children: v }) : /* @__PURE__ */ O(Yt, { children: /* @__PURE__ */ O((v ?? "dot") === "bar" ? lo : ao, { ownerColorScheme: g }) })
2207
+ ]
2208
+ }
2209
+ );
2210
+ }
2211
+ );
2212
+ vo.displayName = "MenuItem";
2213
+ const Sn = ({ children: e, className: t, style: n, id: r }) => {
2214
+ const { colorScheme: o } = be();
2215
+ return /* @__PURE__ */ O(oo, { role: "none", className: t, style: n, id: r, ownerColorScheme: o, children: e });
2216
+ };
2217
+ Sn.displayName = "MenuLabel";
2218
+ const ho = ({ className: e, style: t, ...n }) => {
2219
+ const { colorScheme: r } = be();
2220
+ return /* @__PURE__ */ O(io, { role: "separator", className: e, style: t, ownerColorScheme: r, ...n });
2221
+ };
2222
+ ho.displayName = "MenuDivider";
2223
+ const yo = ({ children: e, label: t, className: n, ...r }) => {
2224
+ const o = bt();
2225
+ return /* @__PURE__ */ $e("div", { role: "group", className: n, "aria-labelledby": t ? o : void 0, ...r, children: [
2226
+ t && /* @__PURE__ */ O(Sn, { id: o, children: t }),
2227
+ e
2228
+ ] });
2229
+ };
2230
+ yo.displayName = "MenuGroup";
2231
+ const Eo = Ae(
2232
+ ({ children: e, icon: t, disabled: n = !1, onKeyDown: r, ...o }, s) => {
2233
+ const { dense: i, display: u, colorScheme: l } = be(), {
2234
+ isOpen: c,
2235
+ toggle: p,
2236
+ hasSelectedChild: g,
2237
+ triggerId: v,
2238
+ resolvedMode: h,
2239
+ setReference: m,
2240
+ getReferenceProps: f
2241
+ } = nt(), E = u === "icon", x = Re(null), b = fn([
2242
+ x,
2243
+ s,
2244
+ ...h === "popover" && m ? [m] : []
2245
+ ]), C = Re(c);
2246
+ qe(() => {
2247
+ C.current && !c && x.current?.focus(), C.current = c;
2248
+ }, [c]);
2249
+ const P = J(() => {
2250
+ n || p();
2251
+ }, [n, p]), T = J(
2252
+ (_) => {
2253
+ if (!n) {
2254
+ switch (_.key) {
2255
+ case "Enter":
2256
+ case " ":
2257
+ _.preventDefault(), p();
2258
+ break;
2259
+ case "ArrowRight":
2260
+ _.preventDefault(), c || p();
2261
+ break;
2262
+ case "ArrowDown":
2263
+ c && _.preventDefault();
2264
+ break;
2265
+ }
2266
+ r?.(_);
2267
+ }
2268
+ },
2269
+ [n, p, c, r]
2270
+ ), L = h === "popover" && f ? f({
2271
+ onClick: P,
2272
+ onKeyDown: T,
2273
+ ...o
2274
+ }) : {
2275
+ onClick: P,
2276
+ onKeyDown: T,
2277
+ ...o
2278
+ };
2279
+ return /* @__PURE__ */ $e(
2280
+ En,
2281
+ {
2282
+ ref: b,
2283
+ id: v,
2284
+ role: "menuitem",
2285
+ tabIndex: -1,
2286
+ "aria-haspopup": "menu",
2287
+ "aria-expanded": c,
2288
+ "aria-disabled": n || void 0,
2289
+ ownerDanger: !1,
2290
+ ownerDisabled: n,
2291
+ ownerSelected: !1,
2292
+ ownerSoftSelected: g,
2293
+ ownerDense: i,
2294
+ ownerIconOnly: E,
2295
+ ownerColorScheme: l,
2296
+ ...L,
2297
+ children: [
2298
+ t && /* @__PURE__ */ O(Rn, { "aria-hidden": "true", children: t }),
2299
+ /* @__PURE__ */ O(xn, { ownerIconOnly: E, children: e }),
2300
+ !E && /* @__PURE__ */ O(so, { "aria-hidden": "true", ownerColorScheme: l, children: h === "popover" ? "▸" : c ? "▴" : "▾" })
2301
+ ]
2302
+ }
2303
+ );
2304
+ }
2305
+ );
2306
+ Eo.displayName = "MenuSubTrigger";
2307
+ const wn = Ae(
2308
+ ({ children: e, onKeyDown: t, ...n }, r) => {
2309
+ const { isOpen: o, triggerId: s, setOpen: i } = nt(), { colorScheme: u, showDot: l } = be(), c = J(
2310
+ (p) => {
2311
+ (p.key === "ArrowLeft" || p.key === "Escape") && (Le(p), o && i(!1)), t?.(p);
2312
+ },
2313
+ [o, i, t]
2314
+ );
2315
+ return /* @__PURE__ */ O(
2316
+ uo,
2317
+ {
2318
+ ref: r,
2319
+ role: "menu",
2320
+ "aria-labelledby": s,
2321
+ ownerOpen: o,
2322
+ ownerColorScheme: u,
2323
+ ownerShowDot: l,
2324
+ "data-collapsed": !o,
2325
+ onKeyDown: c,
2326
+ ...n,
2327
+ children: e
2328
+ }
2329
+ );
2330
+ }
2331
+ );
2332
+ wn.displayName = "MenuSubContentInline";
2333
+ const Ro = ({
2334
+ children: e,
2335
+ context: t
2336
+ }) => {
2337
+ const n = be();
2338
+ return /* @__PURE__ */ O(Cr, { children: /* @__PURE__ */ O(Rt.Provider, { value: { ...n, display: "default" }, children: /* @__PURE__ */ O(Mr, { context: t, modal: !1, children: e }) }) });
2339
+ }, Cn = Ae(
2340
+ ({ children: e, onKeyDown: t, ...n }, r) => {
2341
+ const {
2342
+ isOpen: o,
2343
+ triggerId: s,
2344
+ setFloating: i,
2345
+ floatingStyles: u,
2346
+ getFloatingProps: l,
2347
+ context: c,
2348
+ setOpen: p
2349
+ } = nt(), g = be(), { colorScheme: v } = g, h = J(
2350
+ (m) => {
2351
+ const f = m.currentTarget, E = Array.from(
2352
+ f.querySelectorAll(yn)
2353
+ ), x = E.length > 0 ? E.indexOf(document.activeElement) : -1;
2354
+ switch (m.key) {
2355
+ case "ArrowDown":
2356
+ E.length > 0 && (Le(m), E[(x + 1) % E.length]?.focus());
2357
+ break;
2358
+ case "ArrowUp":
2359
+ E.length > 0 && (Le(m), E[(x - 1 + E.length) % E.length]?.focus());
2360
+ break;
2361
+ case "ArrowLeft":
2362
+ case "Escape":
2363
+ Le(m), o && p(!1);
2364
+ break;
2365
+ }
2366
+ t?.(m);
2367
+ },
2368
+ [o, p, t]
2369
+ );
2370
+ return !o || !c ? null : /* @__PURE__ */ O(Ro, { context: c, children: /* @__PURE__ */ O(
2371
+ co,
2372
+ {
2373
+ ownerColorScheme: v,
2374
+ ref: i ? (m) => {
2375
+ i(m), typeof r == "function" ? r(m) : r && (r.current = m);
2376
+ } : r,
2377
+ role: "menu",
2378
+ "aria-labelledby": s,
2379
+ style: u ?? void 0,
2380
+ ...l ? l({
2381
+ ...n,
2382
+ onKeyDown: (m) => {
2383
+ h(m), t?.(m);
2384
+ }
2385
+ }) : {
2386
+ ...n,
2387
+ onKeyDown: (m) => {
2388
+ h(m), t?.(m);
2389
+ }
2390
+ },
2391
+ children: e
2392
+ }
2393
+ ) });
2394
+ }
2395
+ );
2396
+ Cn.displayName = "MenuSubContentPopover";
2397
+ const xo = Ae(
2398
+ (e, t) => {
2399
+ const { resolvedMode: n } = nt();
2400
+ return n === "inline" ? /* @__PURE__ */ O(wn, { ref: t, ...e }) : /* @__PURE__ */ O(Cn, { ref: t, ...e });
2401
+ }
2402
+ );
2403
+ xo.displayName = "MenuSubContent";
2404
+ export {
2405
+ fo as Menu,
2406
+ ho as MenuDivider,
2407
+ yo as MenuGroup,
2408
+ vo as MenuItem,
2409
+ Sn as MenuLabel,
2410
+ bo as MenuSub,
2411
+ xo as MenuSubContent,
2412
+ Eo as MenuSubTrigger
2413
+ };