@altinn/altinn-components 0.24.1 → 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4073 @@
1
+ "use client";
2
+ import { jsx as v, Fragment as ut, jsxs as le } from "react/jsx-runtime";
3
+ import * as y from "react";
4
+ import { forwardRef as P, useLayoutEffect as Cn, useEffect as ie, useRef as oe, useState as ke, createContext as je, useContext as ae, useId as ft, version as No, useReducer as Do, useMemo as Ge, isValidElement as vr, memo as Po, useCallback as Lo, Children as qn } from "react";
5
+ import * as xr from "react-dom";
6
+ import { flushSync as Fo } from "react-dom";
7
+ import { u as Mo } from "./index-DyDqjche.js";
8
+ import { S as _o } from "./XMark-Bv1I87Ev.js";
9
+ import { S as Bo } from "./ChevronUp-H8Nuww4h.js";
10
+ import { S as $o } from "./ChevronDown-CRAwzuD3.js";
11
+ import { u as Vo } from "./useId-CsCRkvK3.js";
12
+ import { S as zo } from "./Checkmark-RgzvRNxP.js";
13
+ var jo = function(e, t) {
14
+ var n = {};
15
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
16
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
17
+ for (var o = 0, r = Object.getOwnPropertySymbols(e); o < r.length; o++)
18
+ t.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[o]) && (n[r[o]] = e[r[o]]);
19
+ return n;
20
+ };
21
+ const Ko = P((e, t) => {
22
+ var { title: n, titleId: r } = e, o = jo(e, ["title", "titleId"]);
23
+ let i = Vo();
24
+ return i = n ? r || "title-" + i : void 0, y.createElement(
25
+ "svg",
26
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: t, "aria-labelledby": i }, o),
27
+ n ? y.createElement("title", { id: i }, n) : null,
28
+ y.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 2.25A4.75 4.75 0 0 0 7.25 7v2.25H7A1.75 1.75 0 0 0 5.25 11v9c0 .414.336.75.75.75h12a.75.75 0 0 0 .75-.75v-9A1.75 1.75 0 0 0 17 9.25h-.25V7A4.75 4.75 0 0 0 12 2.25m3.25 7V7a3.25 3.25 0 0 0-6.5 0v2.25zM12 13a1.5 1.5 0 0 0-.75 2.8V17a.75.75 0 0 0 1.5 0v-1.2A1.5 1.5 0 0 0 12 13", clipRule: "evenodd" })
29
+ );
30
+ });
31
+ function Un(e, t) {
32
+ if (typeof e == "function")
33
+ return e(t);
34
+ e != null && (e.current = t);
35
+ }
36
+ function Wo(...e) {
37
+ return (t) => {
38
+ let n = !1;
39
+ const r = e.map((o) => {
40
+ const i = Un(o, t);
41
+ return !n && typeof i == "function" && (n = !0), i;
42
+ });
43
+ if (n)
44
+ return () => {
45
+ for (let o = 0; o < r.length; o++) {
46
+ const i = r[o];
47
+ typeof i == "function" ? i() : Un(e[o], null);
48
+ }
49
+ };
50
+ };
51
+ }
52
+ var Q = y.forwardRef((e, t) => {
53
+ const { children: n, ...r } = e, o = y.Children.toArray(n), i = o.find(Ho);
54
+ if (i) {
55
+ const s = i.props.children, c = o.map((l) => l === i ? y.Children.count(s) > 1 ? y.Children.only(null) : y.isValidElement(s) ? s.props.children : null : l);
56
+ return /* @__PURE__ */ v(dn, { ...r, ref: t, children: y.isValidElement(s) ? y.cloneElement(s, void 0, c) : null });
57
+ }
58
+ return /* @__PURE__ */ v(dn, { ...r, ref: t, children: n });
59
+ });
60
+ Q.displayName = "Slot";
61
+ var dn = y.forwardRef((e, t) => {
62
+ const { children: n, ...r } = e;
63
+ if (y.isValidElement(n)) {
64
+ const o = Uo(n), i = qo(r, n.props);
65
+ return n.type !== y.Fragment && (i.ref = t ? Wo(t, o) : o), y.cloneElement(n, i);
66
+ }
67
+ return y.Children.count(n) > 1 ? y.Children.only(null) : null;
68
+ });
69
+ dn.displayName = "SlotClone";
70
+ var En = ({ children: e }) => /* @__PURE__ */ v(ut, { children: e });
71
+ function Ho(e) {
72
+ return y.isValidElement(e) && e.type === En;
73
+ }
74
+ function qo(e, t) {
75
+ const n = { ...t };
76
+ for (const r in t) {
77
+ const o = e[r], i = t[r];
78
+ /^on[A-Z]/.test(r) ? o && i ? n[r] = (...c) => {
79
+ i(...c), o(...c);
80
+ } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...i } : r === "className" && (n[r] = [o, i].filter(Boolean).join(" "));
81
+ }
82
+ return { ...e, ...n };
83
+ }
84
+ function Uo(e) {
85
+ var r, o;
86
+ let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
87
+ return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
88
+ }
89
+ function K() {
90
+ for (var e, t = 0, n = "", r = arguments.length; t < r; t++) (e = arguments[t]) && typeof e == "string" && (n += (n && " ") + e);
91
+ return n;
92
+ }
93
+ function jt() {
94
+ return typeof window < "u";
95
+ }
96
+ function Ke(e) {
97
+ return wr(e) ? (e.nodeName || "").toLowerCase() : "#document";
98
+ }
99
+ function Ce(e) {
100
+ var t;
101
+ return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
102
+ }
103
+ function Ne(e) {
104
+ var t;
105
+ return (t = (wr(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
106
+ }
107
+ function wr(e) {
108
+ return jt() ? e instanceof Node || e instanceof Ce(e).Node : !1;
109
+ }
110
+ function J(e) {
111
+ return jt() ? e instanceof Element || e instanceof Ce(e).Element : !1;
112
+ }
113
+ function re(e) {
114
+ return jt() ? e instanceof HTMLElement || e instanceof Ce(e).HTMLElement : !1;
115
+ }
116
+ function mn(e) {
117
+ return !jt() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof Ce(e).ShadowRoot;
118
+ }
119
+ function vt(e) {
120
+ const {
121
+ overflow: t,
122
+ overflowX: n,
123
+ overflowY: r,
124
+ display: o
125
+ } = Ee(e);
126
+ return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && !["inline", "contents"].includes(o);
127
+ }
128
+ function Yo(e) {
129
+ return ["table", "td", "th"].includes(Ke(e));
130
+ }
131
+ function Kt(e) {
132
+ return [":popover-open", ":modal"].some((t) => {
133
+ try {
134
+ return e.matches(t);
135
+ } catch {
136
+ return !1;
137
+ }
138
+ });
139
+ }
140
+ function Rn(e) {
141
+ const t = In(), n = J(e) ? Ee(e) : e;
142
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((r) => n[r] ? n[r] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((r) => (n.willChange || "").includes(r)) || ["paint", "layout", "strict", "content"].some((r) => (n.contain || "").includes(r));
143
+ }
144
+ function Xo(e) {
145
+ let t = Fe(e);
146
+ for (; re(t) && !Ve(t); ) {
147
+ if (Rn(t))
148
+ return t;
149
+ if (Kt(t))
150
+ return null;
151
+ t = Fe(t);
152
+ }
153
+ return null;
154
+ }
155
+ function In() {
156
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
157
+ }
158
+ function Ve(e) {
159
+ return ["html", "body", "#document"].includes(Ke(e));
160
+ }
161
+ function Ee(e) {
162
+ return Ce(e).getComputedStyle(e);
163
+ }
164
+ function Wt(e) {
165
+ return J(e) ? {
166
+ scrollLeft: e.scrollLeft,
167
+ scrollTop: e.scrollTop
168
+ } : {
169
+ scrollLeft: e.scrollX,
170
+ scrollTop: e.scrollY
171
+ };
172
+ }
173
+ function Fe(e) {
174
+ if (Ke(e) === "html")
175
+ return e;
176
+ const t = (
177
+ // Step into the shadow DOM of the parent of a slotted node.
178
+ e.assignedSlot || // DOM Element detected.
179
+ e.parentNode || // ShadowRoot detected.
180
+ mn(e) && e.host || // Fallback.
181
+ Ne(e)
182
+ );
183
+ return mn(t) ? t.host : t;
184
+ }
185
+ function Cr(e) {
186
+ const t = Fe(e);
187
+ return Ve(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : re(t) && vt(t) ? t : Cr(t);
188
+ }
189
+ function $e(e, t, n) {
190
+ var r;
191
+ t === void 0 && (t = []), n === void 0 && (n = !0);
192
+ const o = Cr(e), i = o === ((r = e.ownerDocument) == null ? void 0 : r.body), s = Ce(o);
193
+ if (i) {
194
+ const c = pn(s);
195
+ return t.concat(s, s.visualViewport || [], vt(o) ? o : [], c && n ? $e(c) : []);
196
+ }
197
+ return t.concat(o, $e(o, [], n));
198
+ }
199
+ function pn(e) {
200
+ return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
201
+ }
202
+ function Le(e) {
203
+ let t = e.activeElement;
204
+ for (; ((n = t) == null || (n = n.shadowRoot) == null ? void 0 : n.activeElement) != null; ) {
205
+ var n;
206
+ t = t.shadowRoot.activeElement;
207
+ }
208
+ return t;
209
+ }
210
+ function pe(e, t) {
211
+ if (!e || !t)
212
+ return !1;
213
+ const n = t.getRootNode == null ? void 0 : t.getRootNode();
214
+ if (e.contains(t))
215
+ return !0;
216
+ if (n && mn(n)) {
217
+ let r = t;
218
+ for (; r; ) {
219
+ if (e === r)
220
+ return !0;
221
+ r = r.parentNode || r.host;
222
+ }
223
+ }
224
+ return !1;
225
+ }
226
+ function Er() {
227
+ const e = navigator.userAgentData;
228
+ return e != null && e.platform ? e.platform : navigator.platform;
229
+ }
230
+ function Rr() {
231
+ const e = navigator.userAgentData;
232
+ return e && Array.isArray(e.brands) ? e.brands.map((t) => {
233
+ let {
234
+ brand: n,
235
+ version: r
236
+ } = t;
237
+ return n + "/" + r;
238
+ }).join(" ") : navigator.userAgent;
239
+ }
240
+ function Ir(e) {
241
+ return e.mozInputSource === 0 && e.isTrusted ? !0 : bn() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
242
+ }
243
+ function Sr(e) {
244
+ return Zo() ? !1 : !bn() && e.width === 0 && e.height === 0 || bn() && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
245
+ e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
246
+ }
247
+ function Or() {
248
+ return /apple/i.test(navigator.vendor);
249
+ }
250
+ function bn() {
251
+ const e = /android/i;
252
+ return e.test(Er()) || e.test(Rr());
253
+ }
254
+ function Go() {
255
+ return Er().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
256
+ }
257
+ function Zo() {
258
+ return Rr().includes("jsdom/");
259
+ }
260
+ function Jo(e) {
261
+ return "nativeEvent" in e;
262
+ }
263
+ function Qo(e) {
264
+ return e.matches("html,body");
265
+ }
266
+ function xe(e) {
267
+ return (e == null ? void 0 : e.ownerDocument) || document;
268
+ }
269
+ function Zt(e, t) {
270
+ if (t == null)
271
+ return !1;
272
+ if ("composedPath" in e)
273
+ return e.composedPath().includes(t);
274
+ const n = e;
275
+ return n.target != null && t.contains(n.target);
276
+ }
277
+ function Ye(e) {
278
+ return "composedPath" in e ? e.composedPath()[0] : e.target;
279
+ }
280
+ const ei = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
281
+ function ti(e) {
282
+ return re(e) && e.matches(ei);
283
+ }
284
+ function be(e) {
285
+ e.preventDefault(), e.stopPropagation();
286
+ }
287
+ function Tr(e) {
288
+ return e ? e.getAttribute("role") === "combobox" && ti(e) : !1;
289
+ }
290
+ const ot = Math.min, we = Math.max, Dt = Math.round, tt = Math.floor, Ae = (e) => ({
291
+ x: e,
292
+ y: e
293
+ }), ni = {
294
+ left: "right",
295
+ right: "left",
296
+ bottom: "top",
297
+ top: "bottom"
298
+ }, ri = {
299
+ start: "end",
300
+ end: "start"
301
+ };
302
+ function Yn(e, t, n) {
303
+ return we(e, ot(t, n));
304
+ }
305
+ function xt(e, t) {
306
+ return typeof e == "function" ? e(t) : e;
307
+ }
308
+ function ze(e) {
309
+ return e.split("-")[0];
310
+ }
311
+ function wt(e) {
312
+ return e.split("-")[1];
313
+ }
314
+ function Ar(e) {
315
+ return e === "x" ? "y" : "x";
316
+ }
317
+ function kr(e) {
318
+ return e === "y" ? "height" : "width";
319
+ }
320
+ function Je(e) {
321
+ return ["top", "bottom"].includes(ze(e)) ? "y" : "x";
322
+ }
323
+ function Nr(e) {
324
+ return Ar(Je(e));
325
+ }
326
+ function oi(e, t, n) {
327
+ n === void 0 && (n = !1);
328
+ const r = wt(e), o = Nr(e), i = kr(o);
329
+ let s = o === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
330
+ return t.reference[i] > t.floating[i] && (s = Pt(s)), [s, Pt(s)];
331
+ }
332
+ function ii(e) {
333
+ const t = Pt(e);
334
+ return [hn(e), t, hn(t)];
335
+ }
336
+ function hn(e) {
337
+ return e.replace(/start|end/g, (t) => ri[t]);
338
+ }
339
+ function si(e, t, n) {
340
+ const r = ["left", "right"], o = ["right", "left"], i = ["top", "bottom"], s = ["bottom", "top"];
341
+ switch (e) {
342
+ case "top":
343
+ case "bottom":
344
+ return n ? t ? o : r : t ? r : o;
345
+ case "left":
346
+ case "right":
347
+ return t ? i : s;
348
+ default:
349
+ return [];
350
+ }
351
+ }
352
+ function ci(e, t, n, r) {
353
+ const o = wt(e);
354
+ let i = si(ze(e), n === "start", r);
355
+ return o && (i = i.map((s) => s + "-" + o), t && (i = i.concat(i.map(hn)))), i;
356
+ }
357
+ function Pt(e) {
358
+ return e.replace(/left|right|bottom|top/g, (t) => ni[t]);
359
+ }
360
+ function ai(e) {
361
+ return {
362
+ top: 0,
363
+ right: 0,
364
+ bottom: 0,
365
+ left: 0,
366
+ ...e
367
+ };
368
+ }
369
+ function li(e) {
370
+ return typeof e != "number" ? ai(e) : {
371
+ top: e,
372
+ right: e,
373
+ bottom: e,
374
+ left: e
375
+ };
376
+ }
377
+ function Lt(e) {
378
+ const {
379
+ x: t,
380
+ y: n,
381
+ width: r,
382
+ height: o
383
+ } = e;
384
+ return {
385
+ width: r,
386
+ height: o,
387
+ top: n,
388
+ left: t,
389
+ right: t + r,
390
+ bottom: n + o,
391
+ x: t,
392
+ y: n
393
+ };
394
+ }
395
+ /*!
396
+ * tabbable 6.2.0
397
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
398
+ */
399
+ var ui = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], Ft = /* @__PURE__ */ ui.join(","), Dr = typeof Element > "u", it = Dr ? function() {
400
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, Mt = !Dr && Element.prototype.getRootNode ? function(e) {
401
+ var t;
402
+ return e == null || (t = e.getRootNode) === null || t === void 0 ? void 0 : t.call(e);
403
+ } : function(e) {
404
+ return e == null ? void 0 : e.ownerDocument;
405
+ }, _t = function e(t, n) {
406
+ var r;
407
+ n === void 0 && (n = !0);
408
+ var o = t == null || (r = t.getAttribute) === null || r === void 0 ? void 0 : r.call(t, "inert"), i = o === "" || o === "true", s = i || n && t && e(t.parentNode);
409
+ return s;
410
+ }, fi = function(t) {
411
+ var n, r = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
412
+ return r === "" || r === "true";
413
+ }, di = function(t, n, r) {
414
+ if (_t(t))
415
+ return [];
416
+ var o = Array.prototype.slice.apply(t.querySelectorAll(Ft));
417
+ return n && it.call(t, Ft) && o.unshift(t), o = o.filter(r), o;
418
+ }, mi = function e(t, n, r) {
419
+ for (var o = [], i = Array.from(t); i.length; ) {
420
+ var s = i.shift();
421
+ if (!_t(s, !1))
422
+ if (s.tagName === "SLOT") {
423
+ var c = s.assignedElements(), l = c.length ? c : s.children, a = e(l, !0, r);
424
+ r.flatten ? o.push.apply(o, a) : o.push({
425
+ scopeParent: s,
426
+ candidates: a
427
+ });
428
+ } else {
429
+ var m = it.call(s, Ft);
430
+ m && r.filter(s) && (n || !t.includes(s)) && o.push(s);
431
+ var u = s.shadowRoot || // check for an undisclosed shadow
432
+ typeof r.getShadowRoot == "function" && r.getShadowRoot(s), d = !_t(u, !1) && (!r.shadowRootFilter || r.shadowRootFilter(s));
433
+ if (u && d) {
434
+ var f = e(u === !0 ? s.children : u.children, !0, r);
435
+ r.flatten ? o.push.apply(o, f) : o.push({
436
+ scopeParent: s,
437
+ candidates: f
438
+ });
439
+ } else
440
+ i.unshift.apply(i, s.children);
441
+ }
442
+ }
443
+ return o;
444
+ }, Pr = function(t) {
445
+ return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
446
+ }, Lr = function(t) {
447
+ if (!t)
448
+ throw new Error("No node provided");
449
+ return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || fi(t)) && !Pr(t) ? 0 : t.tabIndex;
450
+ }, pi = function(t, n) {
451
+ var r = Lr(t);
452
+ return r < 0 && n && !Pr(t) ? 0 : r;
453
+ }, bi = function(t, n) {
454
+ return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
455
+ }, Fr = function(t) {
456
+ return t.tagName === "INPUT";
457
+ }, hi = function(t) {
458
+ return Fr(t) && t.type === "hidden";
459
+ }, gi = function(t) {
460
+ var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
461
+ return r.tagName === "SUMMARY";
462
+ });
463
+ return n;
464
+ }, yi = function(t, n) {
465
+ for (var r = 0; r < t.length; r++)
466
+ if (t[r].checked && t[r].form === n)
467
+ return t[r];
468
+ }, vi = function(t) {
469
+ if (!t.name)
470
+ return !0;
471
+ var n = t.form || Mt(t), r = function(c) {
472
+ return n.querySelectorAll('input[type="radio"][name="' + c + '"]');
473
+ }, o;
474
+ if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
475
+ o = r(window.CSS.escape(t.name));
476
+ else
477
+ try {
478
+ o = r(t.name);
479
+ } catch (s) {
480
+ 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", s.message), !1;
481
+ }
482
+ var i = yi(o, t.form);
483
+ return !i || i === t;
484
+ }, xi = function(t) {
485
+ return Fr(t) && t.type === "radio";
486
+ }, wi = function(t) {
487
+ return xi(t) && !vi(t);
488
+ }, Ci = function(t) {
489
+ var n, r = t && Mt(t), o = (n = r) === null || n === void 0 ? void 0 : n.host, i = !1;
490
+ if (r && r !== t) {
491
+ var s, c, l;
492
+ for (i = !!((s = o) !== null && s !== void 0 && (c = s.ownerDocument) !== null && c !== void 0 && c.contains(o) || t != null && (l = t.ownerDocument) !== null && l !== void 0 && l.contains(t)); !i && o; ) {
493
+ var a, m, u;
494
+ r = Mt(o), o = (a = r) === null || a === void 0 ? void 0 : a.host, i = !!((m = o) !== null && m !== void 0 && (u = m.ownerDocument) !== null && u !== void 0 && u.contains(o));
495
+ }
496
+ }
497
+ return i;
498
+ }, Xn = function(t) {
499
+ var n = t.getBoundingClientRect(), r = n.width, o = n.height;
500
+ return r === 0 && o === 0;
501
+ }, Ei = function(t, n) {
502
+ var r = n.displayCheck, o = n.getShadowRoot;
503
+ if (getComputedStyle(t).visibility === "hidden")
504
+ return !0;
505
+ var i = it.call(t, "details>summary:first-of-type"), s = i ? t.parentElement : t;
506
+ if (it.call(s, "details:not([open]) *"))
507
+ return !0;
508
+ if (!r || r === "full" || r === "legacy-full") {
509
+ if (typeof o == "function") {
510
+ for (var c = t; t; ) {
511
+ var l = t.parentElement, a = Mt(t);
512
+ if (l && !l.shadowRoot && o(l) === !0)
513
+ return Xn(t);
514
+ t.assignedSlot ? t = t.assignedSlot : !l && a !== t.ownerDocument ? t = a.host : t = l;
515
+ }
516
+ t = c;
517
+ }
518
+ if (Ci(t))
519
+ return !t.getClientRects().length;
520
+ if (r !== "legacy-full")
521
+ return !0;
522
+ } else if (r === "non-zero-area")
523
+ return Xn(t);
524
+ return !1;
525
+ }, Ri = function(t) {
526
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
527
+ for (var n = t.parentElement; n; ) {
528
+ if (n.tagName === "FIELDSET" && n.disabled) {
529
+ for (var r = 0; r < n.children.length; r++) {
530
+ var o = n.children.item(r);
531
+ if (o.tagName === "LEGEND")
532
+ return it.call(n, "fieldset[disabled] *") ? !0 : !o.contains(t);
533
+ }
534
+ return !0;
535
+ }
536
+ n = n.parentElement;
537
+ }
538
+ return !1;
539
+ }, Ii = function(t, n) {
540
+ return !(n.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
541
+ // because we're limited in the type of selectors we can use in JSDom (see related
542
+ // note related to `candidateSelectors`)
543
+ _t(n) || hi(n) || Ei(n, t) || // For a details element with a summary, the summary element gets the focus
544
+ gi(n) || Ri(n));
545
+ }, gn = function(t, n) {
546
+ return !(wi(n) || Lr(n) < 0 || !Ii(t, n));
547
+ }, Si = function(t) {
548
+ var n = parseInt(t.getAttribute("tabindex"), 10);
549
+ return !!(isNaN(n) || n >= 0);
550
+ }, Oi = function e(t) {
551
+ var n = [], r = [];
552
+ return t.forEach(function(o, i) {
553
+ var s = !!o.scopeParent, c = s ? o.scopeParent : o, l = pi(c, s), a = s ? e(o.candidates) : c;
554
+ l === 0 ? s ? n.push.apply(n, a) : n.push(c) : r.push({
555
+ documentOrder: i,
556
+ tabIndex: l,
557
+ item: o,
558
+ isScope: s,
559
+ content: a
560
+ });
561
+ }), r.sort(bi).reduce(function(o, i) {
562
+ return i.isScope ? o.push.apply(o, i.content) : o.push(i.content), o;
563
+ }, []).concat(n);
564
+ }, gt = function(t, n) {
565
+ n = n || {};
566
+ var r;
567
+ return n.getShadowRoot ? r = mi([t], n.includeContainer, {
568
+ filter: gn.bind(null, n),
569
+ flatten: !1,
570
+ getShadowRoot: n.getShadowRoot,
571
+ shadowRootFilter: Si
572
+ }) : r = di(t, n.includeContainer, gn.bind(null, n)), Oi(r);
573
+ }, Ti = function(t, n) {
574
+ if (n = n || {}, !t)
575
+ throw new Error("No node provided");
576
+ return it.call(t, Ft) === !1 ? !1 : gn(n, t);
577
+ };
578
+ function Gn(e, t, n) {
579
+ let {
580
+ reference: r,
581
+ floating: o
582
+ } = e;
583
+ const i = Je(t), s = Nr(t), c = kr(s), l = ze(t), a = i === "y", m = r.x + r.width / 2 - o.width / 2, u = r.y + r.height / 2 - o.height / 2, d = r[c] / 2 - o[c] / 2;
584
+ let f;
585
+ switch (l) {
586
+ case "top":
587
+ f = {
588
+ x: m,
589
+ y: r.y - o.height
590
+ };
591
+ break;
592
+ case "bottom":
593
+ f = {
594
+ x: m,
595
+ y: r.y + r.height
596
+ };
597
+ break;
598
+ case "right":
599
+ f = {
600
+ x: r.x + r.width,
601
+ y: u
602
+ };
603
+ break;
604
+ case "left":
605
+ f = {
606
+ x: r.x - o.width,
607
+ y: u
608
+ };
609
+ break;
610
+ default:
611
+ f = {
612
+ x: r.x,
613
+ y: r.y
614
+ };
615
+ }
616
+ switch (wt(t)) {
617
+ case "start":
618
+ f[s] -= d * (n && a ? -1 : 1);
619
+ break;
620
+ case "end":
621
+ f[s] += d * (n && a ? -1 : 1);
622
+ break;
623
+ }
624
+ return f;
625
+ }
626
+ const Ai = async (e, t, n) => {
627
+ const {
628
+ placement: r = "bottom",
629
+ strategy: o = "absolute",
630
+ middleware: i = [],
631
+ platform: s
632
+ } = n, c = i.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(t));
633
+ let a = await s.getElementRects({
634
+ reference: e,
635
+ floating: t,
636
+ strategy: o
637
+ }), {
638
+ x: m,
639
+ y: u
640
+ } = Gn(a, r, l), d = r, f = {}, p = 0;
641
+ for (let h = 0; h < c.length; h++) {
642
+ const {
643
+ name: b,
644
+ fn: x
645
+ } = c[h], {
646
+ x: w,
647
+ y: g,
648
+ data: C,
649
+ reset: S
650
+ } = await x({
651
+ x: m,
652
+ y: u,
653
+ initialPlacement: r,
654
+ placement: d,
655
+ strategy: o,
656
+ middlewareData: f,
657
+ rects: a,
658
+ platform: s,
659
+ elements: {
660
+ reference: e,
661
+ floating: t
662
+ }
663
+ });
664
+ m = w ?? m, u = g ?? u, f = {
665
+ ...f,
666
+ [b]: {
667
+ ...f[b],
668
+ ...C
669
+ }
670
+ }, S && p <= 50 && (p++, typeof S == "object" && (S.placement && (d = S.placement), S.rects && (a = S.rects === !0 ? await s.getElementRects({
671
+ reference: e,
672
+ floating: t,
673
+ strategy: o
674
+ }) : S.rects), {
675
+ x: m,
676
+ y: u
677
+ } = Gn(a, d, l)), h = -1);
678
+ }
679
+ return {
680
+ x: m,
681
+ y: u,
682
+ placement: d,
683
+ strategy: o,
684
+ middlewareData: f
685
+ };
686
+ };
687
+ async function Sn(e, t) {
688
+ var n;
689
+ t === void 0 && (t = {});
690
+ const {
691
+ x: r,
692
+ y: o,
693
+ platform: i,
694
+ rects: s,
695
+ elements: c,
696
+ strategy: l
697
+ } = e, {
698
+ boundary: a = "clippingAncestors",
699
+ rootBoundary: m = "viewport",
700
+ elementContext: u = "floating",
701
+ altBoundary: d = !1,
702
+ padding: f = 0
703
+ } = xt(t, e), p = li(f), b = c[d ? u === "floating" ? "reference" : "floating" : u], x = Lt(await i.getClippingRect({
704
+ element: (n = await (i.isElement == null ? void 0 : i.isElement(b))) == null || n ? b : b.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(c.floating)),
705
+ boundary: a,
706
+ rootBoundary: m,
707
+ strategy: l
708
+ })), w = u === "floating" ? {
709
+ x: r,
710
+ y: o,
711
+ width: s.floating.width,
712
+ height: s.floating.height
713
+ } : s.reference, g = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(c.floating)), C = await (i.isElement == null ? void 0 : i.isElement(g)) ? await (i.getScale == null ? void 0 : i.getScale(g)) || {
714
+ x: 1,
715
+ y: 1
716
+ } : {
717
+ x: 1,
718
+ y: 1
719
+ }, S = Lt(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
720
+ elements: c,
721
+ rect: w,
722
+ offsetParent: g,
723
+ strategy: l
724
+ }) : w);
725
+ return {
726
+ top: (x.top - S.top + p.top) / C.y,
727
+ bottom: (S.bottom - x.bottom + p.bottom) / C.y,
728
+ left: (x.left - S.left + p.left) / C.x,
729
+ right: (S.right - x.right + p.right) / C.x
730
+ };
731
+ }
732
+ const ki = function(e) {
733
+ return e === void 0 && (e = {}), {
734
+ name: "flip",
735
+ options: e,
736
+ async fn(t) {
737
+ var n, r;
738
+ const {
739
+ placement: o,
740
+ middlewareData: i,
741
+ rects: s,
742
+ initialPlacement: c,
743
+ platform: l,
744
+ elements: a
745
+ } = t, {
746
+ mainAxis: m = !0,
747
+ crossAxis: u = !0,
748
+ fallbackPlacements: d,
749
+ fallbackStrategy: f = "bestFit",
750
+ fallbackAxisSideDirection: p = "none",
751
+ flipAlignment: h = !0,
752
+ ...b
753
+ } = xt(e, t);
754
+ if ((n = i.arrow) != null && n.alignmentOffset)
755
+ return {};
756
+ const x = ze(o), w = Je(c), g = ze(c) === c, C = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)), S = d || (g || !h ? [Pt(c)] : ii(c)), k = p !== "none";
757
+ !d && k && S.push(...ci(c, h, p, C));
758
+ const _ = [c, ...S], B = await Sn(t, b), U = [];
759
+ let H = ((r = i.flip) == null ? void 0 : r.overflows) || [];
760
+ if (m && U.push(B[x]), u) {
761
+ const D = oi(o, s, C);
762
+ U.push(B[D[0]], B[D[1]]);
763
+ }
764
+ if (H = [...H, {
765
+ placement: o,
766
+ overflows: U
767
+ }], !U.every((D) => D <= 0)) {
768
+ var W, O;
769
+ const D = (((W = i.flip) == null ? void 0 : W.index) || 0) + 1, E = _[D];
770
+ if (E)
771
+ return {
772
+ data: {
773
+ index: D,
774
+ overflows: H
775
+ },
776
+ reset: {
777
+ placement: E
778
+ }
779
+ };
780
+ let A = (O = H.filter((M) => M.overflows[0] <= 0).sort((M, T) => M.overflows[1] - T.overflows[1])[0]) == null ? void 0 : O.placement;
781
+ if (!A)
782
+ switch (f) {
783
+ case "bestFit": {
784
+ var N;
785
+ const M = (N = H.filter((T) => {
786
+ if (k) {
787
+ const I = Je(T.placement);
788
+ return I === w || // Create a bias to the `y` side axis due to horizontal
789
+ // reading directions favoring greater width.
790
+ I === "y";
791
+ }
792
+ return !0;
793
+ }).map((T) => [T.placement, T.overflows.filter((I) => I > 0).reduce((I, X) => I + X, 0)]).sort((T, I) => T[1] - I[1])[0]) == null ? void 0 : N[0];
794
+ M && (A = M);
795
+ break;
796
+ }
797
+ case "initialPlacement":
798
+ A = c;
799
+ break;
800
+ }
801
+ if (o !== A)
802
+ return {
803
+ reset: {
804
+ placement: A
805
+ }
806
+ };
807
+ }
808
+ return {};
809
+ }
810
+ };
811
+ };
812
+ async function Ni(e, t) {
813
+ const {
814
+ placement: n,
815
+ platform: r,
816
+ elements: o
817
+ } = e, i = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), s = ze(n), c = wt(n), l = Je(n) === "y", a = ["left", "top"].includes(s) ? -1 : 1, m = i && l ? -1 : 1, u = xt(t, e);
818
+ let {
819
+ mainAxis: d,
820
+ crossAxis: f,
821
+ alignmentAxis: p
822
+ } = typeof u == "number" ? {
823
+ mainAxis: u,
824
+ crossAxis: 0,
825
+ alignmentAxis: null
826
+ } : {
827
+ mainAxis: u.mainAxis || 0,
828
+ crossAxis: u.crossAxis || 0,
829
+ alignmentAxis: u.alignmentAxis
830
+ };
831
+ return c && typeof p == "number" && (f = c === "end" ? p * -1 : p), l ? {
832
+ x: f * m,
833
+ y: d * a
834
+ } : {
835
+ x: d * a,
836
+ y: f * m
837
+ };
838
+ }
839
+ const Di = function(e) {
840
+ return e === void 0 && (e = 0), {
841
+ name: "offset",
842
+ options: e,
843
+ async fn(t) {
844
+ var n, r;
845
+ const {
846
+ x: o,
847
+ y: i,
848
+ placement: s,
849
+ middlewareData: c
850
+ } = t, l = await Ni(t, e);
851
+ return s === ((n = c.offset) == null ? void 0 : n.placement) && (r = c.arrow) != null && r.alignmentOffset ? {} : {
852
+ x: o + l.x,
853
+ y: i + l.y,
854
+ data: {
855
+ ...l,
856
+ placement: s
857
+ }
858
+ };
859
+ }
860
+ };
861
+ }, Pi = function(e) {
862
+ return e === void 0 && (e = {}), {
863
+ name: "shift",
864
+ options: e,
865
+ async fn(t) {
866
+ const {
867
+ x: n,
868
+ y: r,
869
+ placement: o
870
+ } = t, {
871
+ mainAxis: i = !0,
872
+ crossAxis: s = !1,
873
+ limiter: c = {
874
+ fn: (b) => {
875
+ let {
876
+ x,
877
+ y: w
878
+ } = b;
879
+ return {
880
+ x,
881
+ y: w
882
+ };
883
+ }
884
+ },
885
+ ...l
886
+ } = xt(e, t), a = {
887
+ x: n,
888
+ y: r
889
+ }, m = await Sn(t, l), u = Je(ze(o)), d = Ar(u);
890
+ let f = a[d], p = a[u];
891
+ if (i) {
892
+ const b = d === "y" ? "top" : "left", x = d === "y" ? "bottom" : "right", w = f + m[b], g = f - m[x];
893
+ f = Yn(w, f, g);
894
+ }
895
+ if (s) {
896
+ const b = u === "y" ? "top" : "left", x = u === "y" ? "bottom" : "right", w = p + m[b], g = p - m[x];
897
+ p = Yn(w, p, g);
898
+ }
899
+ const h = c.fn({
900
+ ...t,
901
+ [d]: f,
902
+ [u]: p
903
+ });
904
+ return {
905
+ ...h,
906
+ data: {
907
+ x: h.x - n,
908
+ y: h.y - r,
909
+ enabled: {
910
+ [d]: i,
911
+ [u]: s
912
+ }
913
+ }
914
+ };
915
+ }
916
+ };
917
+ }, Li = function(e) {
918
+ return e === void 0 && (e = {}), {
919
+ name: "size",
920
+ options: e,
921
+ async fn(t) {
922
+ var n, r;
923
+ const {
924
+ placement: o,
925
+ rects: i,
926
+ platform: s,
927
+ elements: c
928
+ } = t, {
929
+ apply: l = () => {
930
+ },
931
+ ...a
932
+ } = xt(e, t), m = await Sn(t, a), u = ze(o), d = wt(o), f = Je(o) === "y", {
933
+ width: p,
934
+ height: h
935
+ } = i.floating;
936
+ let b, x;
937
+ u === "top" || u === "bottom" ? (b = u, x = d === (await (s.isRTL == null ? void 0 : s.isRTL(c.floating)) ? "start" : "end") ? "left" : "right") : (x = u, b = d === "end" ? "top" : "bottom");
938
+ const w = h - m.top - m.bottom, g = p - m.left - m.right, C = ot(h - m[b], w), S = ot(p - m[x], g), k = !t.middlewareData.shift;
939
+ let _ = C, B = S;
940
+ if ((n = t.middlewareData.shift) != null && n.enabled.x && (B = g), (r = t.middlewareData.shift) != null && r.enabled.y && (_ = w), k && !d) {
941
+ const H = we(m.left, 0), W = we(m.right, 0), O = we(m.top, 0), N = we(m.bottom, 0);
942
+ f ? B = p - 2 * (H !== 0 || W !== 0 ? H + W : we(m.left, m.right)) : _ = h - 2 * (O !== 0 || N !== 0 ? O + N : we(m.top, m.bottom));
943
+ }
944
+ await l({
945
+ ...t,
946
+ availableWidth: B,
947
+ availableHeight: _
948
+ });
949
+ const U = await s.getDimensions(c.floating);
950
+ return p !== U.width || h !== U.height ? {
951
+ reset: {
952
+ rects: !0
953
+ }
954
+ } : {};
955
+ }
956
+ };
957
+ };
958
+ function Mr(e) {
959
+ const t = Ee(e);
960
+ let n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0;
961
+ const o = re(e), i = o ? e.offsetWidth : n, s = o ? e.offsetHeight : r, c = Dt(n) !== i || Dt(r) !== s;
962
+ return c && (n = i, r = s), {
963
+ width: n,
964
+ height: r,
965
+ $: c
966
+ };
967
+ }
968
+ function On(e) {
969
+ return J(e) ? e : e.contextElement;
970
+ }
971
+ function nt(e) {
972
+ const t = On(e);
973
+ if (!re(t))
974
+ return Ae(1);
975
+ const n = t.getBoundingClientRect(), {
976
+ width: r,
977
+ height: o,
978
+ $: i
979
+ } = Mr(t);
980
+ let s = (i ? Dt(n.width) : n.width) / r, c = (i ? Dt(n.height) : n.height) / o;
981
+ return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
982
+ x: s,
983
+ y: c
984
+ };
985
+ }
986
+ const Fi = /* @__PURE__ */ Ae(0);
987
+ function _r(e) {
988
+ const t = Ce(e);
989
+ return !In() || !t.visualViewport ? Fi : {
990
+ x: t.visualViewport.offsetLeft,
991
+ y: t.visualViewport.offsetTop
992
+ };
993
+ }
994
+ function Mi(e, t, n) {
995
+ return t === void 0 && (t = !1), !n || t && n !== Ce(e) ? !1 : t;
996
+ }
997
+ function Qe(e, t, n, r) {
998
+ t === void 0 && (t = !1), n === void 0 && (n = !1);
999
+ const o = e.getBoundingClientRect(), i = On(e);
1000
+ let s = Ae(1);
1001
+ t && (r ? J(r) && (s = nt(r)) : s = nt(e));
1002
+ const c = Mi(i, n, r) ? _r(i) : Ae(0);
1003
+ let l = (o.left + c.x) / s.x, a = (o.top + c.y) / s.y, m = o.width / s.x, u = o.height / s.y;
1004
+ if (i) {
1005
+ const d = Ce(i), f = r && J(r) ? Ce(r) : r;
1006
+ let p = d, h = pn(p);
1007
+ for (; h && r && f !== p; ) {
1008
+ const b = nt(h), x = h.getBoundingClientRect(), w = Ee(h), g = x.left + (h.clientLeft + parseFloat(w.paddingLeft)) * b.x, C = x.top + (h.clientTop + parseFloat(w.paddingTop)) * b.y;
1009
+ l *= b.x, a *= b.y, m *= b.x, u *= b.y, l += g, a += C, p = Ce(h), h = pn(p);
1010
+ }
1011
+ }
1012
+ return Lt({
1013
+ width: m,
1014
+ height: u,
1015
+ x: l,
1016
+ y: a
1017
+ });
1018
+ }
1019
+ function Tn(e, t) {
1020
+ const n = Wt(e).scrollLeft;
1021
+ return t ? t.left + n : Qe(Ne(e)).left + n;
1022
+ }
1023
+ function Br(e, t, n) {
1024
+ n === void 0 && (n = !1);
1025
+ const r = e.getBoundingClientRect(), o = r.left + t.scrollLeft - (n ? 0 : (
1026
+ // RTL <body> scrollbar.
1027
+ Tn(e, r)
1028
+ )), i = r.top + t.scrollTop;
1029
+ return {
1030
+ x: o,
1031
+ y: i
1032
+ };
1033
+ }
1034
+ function _i(e) {
1035
+ let {
1036
+ elements: t,
1037
+ rect: n,
1038
+ offsetParent: r,
1039
+ strategy: o
1040
+ } = e;
1041
+ const i = o === "fixed", s = Ne(r), c = t ? Kt(t.floating) : !1;
1042
+ if (r === s || c && i)
1043
+ return n;
1044
+ let l = {
1045
+ scrollLeft: 0,
1046
+ scrollTop: 0
1047
+ }, a = Ae(1);
1048
+ const m = Ae(0), u = re(r);
1049
+ if ((u || !u && !i) && ((Ke(r) !== "body" || vt(s)) && (l = Wt(r)), re(r))) {
1050
+ const f = Qe(r);
1051
+ a = nt(r), m.x = f.x + r.clientLeft, m.y = f.y + r.clientTop;
1052
+ }
1053
+ const d = s && !u && !i ? Br(s, l, !0) : Ae(0);
1054
+ return {
1055
+ width: n.width * a.x,
1056
+ height: n.height * a.y,
1057
+ x: n.x * a.x - l.scrollLeft * a.x + m.x + d.x,
1058
+ y: n.y * a.y - l.scrollTop * a.y + m.y + d.y
1059
+ };
1060
+ }
1061
+ function Bi(e) {
1062
+ return Array.from(e.getClientRects());
1063
+ }
1064
+ function $i(e) {
1065
+ const t = Ne(e), n = Wt(e), r = e.ownerDocument.body, o = we(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), i = we(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight);
1066
+ let s = -n.scrollLeft + Tn(e);
1067
+ const c = -n.scrollTop;
1068
+ return Ee(r).direction === "rtl" && (s += we(t.clientWidth, r.clientWidth) - o), {
1069
+ width: o,
1070
+ height: i,
1071
+ x: s,
1072
+ y: c
1073
+ };
1074
+ }
1075
+ function Vi(e, t) {
1076
+ const n = Ce(e), r = Ne(e), o = n.visualViewport;
1077
+ let i = r.clientWidth, s = r.clientHeight, c = 0, l = 0;
1078
+ if (o) {
1079
+ i = o.width, s = o.height;
1080
+ const a = In();
1081
+ (!a || a && t === "fixed") && (c = o.offsetLeft, l = o.offsetTop);
1082
+ }
1083
+ return {
1084
+ width: i,
1085
+ height: s,
1086
+ x: c,
1087
+ y: l
1088
+ };
1089
+ }
1090
+ function zi(e, t) {
1091
+ const n = Qe(e, !0, t === "fixed"), r = n.top + e.clientTop, o = n.left + e.clientLeft, i = re(e) ? nt(e) : Ae(1), s = e.clientWidth * i.x, c = e.clientHeight * i.y, l = o * i.x, a = r * i.y;
1092
+ return {
1093
+ width: s,
1094
+ height: c,
1095
+ x: l,
1096
+ y: a
1097
+ };
1098
+ }
1099
+ function Zn(e, t, n) {
1100
+ let r;
1101
+ if (t === "viewport")
1102
+ r = Vi(e, n);
1103
+ else if (t === "document")
1104
+ r = $i(Ne(e));
1105
+ else if (J(t))
1106
+ r = zi(t, n);
1107
+ else {
1108
+ const o = _r(e);
1109
+ r = {
1110
+ x: t.x - o.x,
1111
+ y: t.y - o.y,
1112
+ width: t.width,
1113
+ height: t.height
1114
+ };
1115
+ }
1116
+ return Lt(r);
1117
+ }
1118
+ function $r(e, t) {
1119
+ const n = Fe(e);
1120
+ return n === t || !J(n) || Ve(n) ? !1 : Ee(n).position === "fixed" || $r(n, t);
1121
+ }
1122
+ function ji(e, t) {
1123
+ const n = t.get(e);
1124
+ if (n)
1125
+ return n;
1126
+ let r = $e(e, [], !1).filter((c) => J(c) && Ke(c) !== "body"), o = null;
1127
+ const i = Ee(e).position === "fixed";
1128
+ let s = i ? Fe(e) : e;
1129
+ for (; J(s) && !Ve(s); ) {
1130
+ const c = Ee(s), l = Rn(s);
1131
+ !l && c.position === "fixed" && (o = null), (i ? !l && !o : !l && c.position === "static" && !!o && ["absolute", "fixed"].includes(o.position) || vt(s) && !l && $r(e, s)) ? r = r.filter((m) => m !== s) : o = c, s = Fe(s);
1132
+ }
1133
+ return t.set(e, r), r;
1134
+ }
1135
+ function Ki(e) {
1136
+ let {
1137
+ element: t,
1138
+ boundary: n,
1139
+ rootBoundary: r,
1140
+ strategy: o
1141
+ } = e;
1142
+ const s = [...n === "clippingAncestors" ? Kt(t) ? [] : ji(t, this._c) : [].concat(n), r], c = s[0], l = s.reduce((a, m) => {
1143
+ const u = Zn(t, m, o);
1144
+ return a.top = we(u.top, a.top), a.right = ot(u.right, a.right), a.bottom = ot(u.bottom, a.bottom), a.left = we(u.left, a.left), a;
1145
+ }, Zn(t, c, o));
1146
+ return {
1147
+ width: l.right - l.left,
1148
+ height: l.bottom - l.top,
1149
+ x: l.left,
1150
+ y: l.top
1151
+ };
1152
+ }
1153
+ function Wi(e) {
1154
+ const {
1155
+ width: t,
1156
+ height: n
1157
+ } = Mr(e);
1158
+ return {
1159
+ width: t,
1160
+ height: n
1161
+ };
1162
+ }
1163
+ function Hi(e, t, n) {
1164
+ const r = re(t), o = Ne(t), i = n === "fixed", s = Qe(e, !0, i, t);
1165
+ let c = {
1166
+ scrollLeft: 0,
1167
+ scrollTop: 0
1168
+ };
1169
+ const l = Ae(0);
1170
+ if (r || !r && !i)
1171
+ if ((Ke(t) !== "body" || vt(o)) && (c = Wt(t)), r) {
1172
+ const d = Qe(t, !0, i, t);
1173
+ l.x = d.x + t.clientLeft, l.y = d.y + t.clientTop;
1174
+ } else o && (l.x = Tn(o));
1175
+ const a = o && !r && !i ? Br(o, c) : Ae(0), m = s.left + c.scrollLeft - l.x - a.x, u = s.top + c.scrollTop - l.y - a.y;
1176
+ return {
1177
+ x: m,
1178
+ y: u,
1179
+ width: s.width,
1180
+ height: s.height
1181
+ };
1182
+ }
1183
+ function Jt(e) {
1184
+ return Ee(e).position === "static";
1185
+ }
1186
+ function Jn(e, t) {
1187
+ if (!re(e) || Ee(e).position === "fixed")
1188
+ return null;
1189
+ if (t)
1190
+ return t(e);
1191
+ let n = e.offsetParent;
1192
+ return Ne(e) === n && (n = n.ownerDocument.body), n;
1193
+ }
1194
+ function Vr(e, t) {
1195
+ const n = Ce(e);
1196
+ if (Kt(e))
1197
+ return n;
1198
+ if (!re(e)) {
1199
+ let o = Fe(e);
1200
+ for (; o && !Ve(o); ) {
1201
+ if (J(o) && !Jt(o))
1202
+ return o;
1203
+ o = Fe(o);
1204
+ }
1205
+ return n;
1206
+ }
1207
+ let r = Jn(e, t);
1208
+ for (; r && Yo(r) && Jt(r); )
1209
+ r = Jn(r, t);
1210
+ return r && Ve(r) && Jt(r) && !Rn(r) ? n : r || Xo(e) || n;
1211
+ }
1212
+ const qi = async function(e) {
1213
+ const t = this.getOffsetParent || Vr, n = this.getDimensions, r = await n(e.floating);
1214
+ return {
1215
+ reference: Hi(e.reference, await t(e.floating), e.strategy),
1216
+ floating: {
1217
+ x: 0,
1218
+ y: 0,
1219
+ width: r.width,
1220
+ height: r.height
1221
+ }
1222
+ };
1223
+ };
1224
+ function Ui(e) {
1225
+ return Ee(e).direction === "rtl";
1226
+ }
1227
+ const Yi = {
1228
+ convertOffsetParentRelativeRectToViewportRelativeRect: _i,
1229
+ getDocumentElement: Ne,
1230
+ getClippingRect: Ki,
1231
+ getOffsetParent: Vr,
1232
+ getElementRects: qi,
1233
+ getClientRects: Bi,
1234
+ getDimensions: Wi,
1235
+ getScale: nt,
1236
+ isElement: J,
1237
+ isRTL: Ui
1238
+ };
1239
+ function zr(e, t) {
1240
+ return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
1241
+ }
1242
+ function Xi(e, t) {
1243
+ let n = null, r;
1244
+ const o = Ne(e);
1245
+ function i() {
1246
+ var c;
1247
+ clearTimeout(r), (c = n) == null || c.disconnect(), n = null;
1248
+ }
1249
+ function s(c, l) {
1250
+ c === void 0 && (c = !1), l === void 0 && (l = 1), i();
1251
+ const a = e.getBoundingClientRect(), {
1252
+ left: m,
1253
+ top: u,
1254
+ width: d,
1255
+ height: f
1256
+ } = a;
1257
+ if (c || t(), !d || !f)
1258
+ return;
1259
+ const p = tt(u), h = tt(o.clientWidth - (m + d)), b = tt(o.clientHeight - (u + f)), x = tt(m), g = {
1260
+ rootMargin: -p + "px " + -h + "px " + -b + "px " + -x + "px",
1261
+ threshold: we(0, ot(1, l)) || 1
1262
+ };
1263
+ let C = !0;
1264
+ function S(k) {
1265
+ const _ = k[0].intersectionRatio;
1266
+ if (_ !== l) {
1267
+ if (!C)
1268
+ return s();
1269
+ _ ? s(!1, _) : r = setTimeout(() => {
1270
+ s(!1, 1e-7);
1271
+ }, 1e3);
1272
+ }
1273
+ _ === 1 && !zr(a, e.getBoundingClientRect()) && s(), C = !1;
1274
+ }
1275
+ try {
1276
+ n = new IntersectionObserver(S, {
1277
+ ...g,
1278
+ // Handle <iframe>s
1279
+ root: o.ownerDocument
1280
+ });
1281
+ } catch {
1282
+ n = new IntersectionObserver(S, g);
1283
+ }
1284
+ n.observe(e);
1285
+ }
1286
+ return s(!0), i;
1287
+ }
1288
+ function jr(e, t, n, r) {
1289
+ r === void 0 && (r = {});
1290
+ const {
1291
+ ancestorScroll: o = !0,
1292
+ ancestorResize: i = !0,
1293
+ elementResize: s = typeof ResizeObserver == "function",
1294
+ layoutShift: c = typeof IntersectionObserver == "function",
1295
+ animationFrame: l = !1
1296
+ } = r, a = On(e), m = o || i ? [...a ? $e(a) : [], ...$e(t)] : [];
1297
+ m.forEach((x) => {
1298
+ o && x.addEventListener("scroll", n, {
1299
+ passive: !0
1300
+ }), i && x.addEventListener("resize", n);
1301
+ });
1302
+ const u = a && c ? Xi(a, n) : null;
1303
+ let d = -1, f = null;
1304
+ s && (f = new ResizeObserver((x) => {
1305
+ let [w] = x;
1306
+ w && w.target === a && f && (f.unobserve(t), cancelAnimationFrame(d), d = requestAnimationFrame(() => {
1307
+ var g;
1308
+ (g = f) == null || g.observe(t);
1309
+ })), n();
1310
+ }), a && !l && f.observe(a), f.observe(t));
1311
+ let p, h = l ? Qe(e) : null;
1312
+ l && b();
1313
+ function b() {
1314
+ const x = Qe(e);
1315
+ h && !zr(h, x) && n(), h = x, p = requestAnimationFrame(b);
1316
+ }
1317
+ return n(), () => {
1318
+ var x;
1319
+ m.forEach((w) => {
1320
+ o && w.removeEventListener("scroll", n), i && w.removeEventListener("resize", n);
1321
+ }), u == null || u(), (x = f) == null || x.disconnect(), f = null, l && cancelAnimationFrame(p);
1322
+ };
1323
+ }
1324
+ const Kr = Di, Gi = Pi, Wr = ki, Zi = Li, Hr = (e, t, n) => {
1325
+ const r = /* @__PURE__ */ new Map(), o = {
1326
+ platform: Yi,
1327
+ ...n
1328
+ }, i = {
1329
+ ...o.platform,
1330
+ _c: r
1331
+ };
1332
+ return Ai(e, t, {
1333
+ ...o,
1334
+ platform: i
1335
+ });
1336
+ };
1337
+ var kt = typeof document < "u" ? Cn : ie;
1338
+ function Bt(e, t) {
1339
+ if (e === t)
1340
+ return !0;
1341
+ if (typeof e != typeof t)
1342
+ return !1;
1343
+ if (typeof e == "function" && e.toString() === t.toString())
1344
+ return !0;
1345
+ let n, r, o;
1346
+ if (e && t && typeof e == "object") {
1347
+ if (Array.isArray(e)) {
1348
+ if (n = e.length, n !== t.length) return !1;
1349
+ for (r = n; r-- !== 0; )
1350
+ if (!Bt(e[r], t[r]))
1351
+ return !1;
1352
+ return !0;
1353
+ }
1354
+ if (o = Object.keys(e), n = o.length, n !== Object.keys(t).length)
1355
+ return !1;
1356
+ for (r = n; r-- !== 0; )
1357
+ if (!{}.hasOwnProperty.call(t, o[r]))
1358
+ return !1;
1359
+ for (r = n; r-- !== 0; ) {
1360
+ const i = o[r];
1361
+ if (!(i === "_owner" && e.$$typeof) && !Bt(e[i], t[i]))
1362
+ return !1;
1363
+ }
1364
+ return !0;
1365
+ }
1366
+ return e !== e && t !== t;
1367
+ }
1368
+ function qr(e) {
1369
+ return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
1370
+ }
1371
+ function Qn(e, t) {
1372
+ const n = qr(e);
1373
+ return Math.round(t * n) / n;
1374
+ }
1375
+ function Qt(e) {
1376
+ const t = y.useRef(e);
1377
+ return kt(() => {
1378
+ t.current = e;
1379
+ }), t;
1380
+ }
1381
+ function Ji(e) {
1382
+ e === void 0 && (e = {});
1383
+ const {
1384
+ placement: t = "bottom",
1385
+ strategy: n = "absolute",
1386
+ middleware: r = [],
1387
+ platform: o,
1388
+ elements: {
1389
+ reference: i,
1390
+ floating: s
1391
+ } = {},
1392
+ transform: c = !0,
1393
+ whileElementsMounted: l,
1394
+ open: a
1395
+ } = e, [m, u] = y.useState({
1396
+ x: 0,
1397
+ y: 0,
1398
+ strategy: n,
1399
+ placement: t,
1400
+ middlewareData: {},
1401
+ isPositioned: !1
1402
+ }), [d, f] = y.useState(r);
1403
+ Bt(d, r) || f(r);
1404
+ const [p, h] = y.useState(null), [b, x] = y.useState(null), w = y.useCallback((T) => {
1405
+ T !== k.current && (k.current = T, h(T));
1406
+ }, []), g = y.useCallback((T) => {
1407
+ T !== _.current && (_.current = T, x(T));
1408
+ }, []), C = i || p, S = s || b, k = y.useRef(null), _ = y.useRef(null), B = y.useRef(m), U = l != null, H = Qt(l), W = Qt(o), O = Qt(a), N = y.useCallback(() => {
1409
+ if (!k.current || !_.current)
1410
+ return;
1411
+ const T = {
1412
+ placement: t,
1413
+ strategy: n,
1414
+ middleware: d
1415
+ };
1416
+ W.current && (T.platform = W.current), Hr(k.current, _.current, T).then((I) => {
1417
+ const X = {
1418
+ ...I,
1419
+ // The floating element's position may be recomputed while it's closed
1420
+ // but still mounted (such as when transitioning out). To ensure
1421
+ // `isPositioned` will be `false` initially on the next open, avoid
1422
+ // setting it to `true` when `open === false` (must be specified).
1423
+ isPositioned: O.current !== !1
1424
+ };
1425
+ D.current && !Bt(B.current, X) && (B.current = X, xr.flushSync(() => {
1426
+ u(X);
1427
+ }));
1428
+ });
1429
+ }, [d, t, n, W, O]);
1430
+ kt(() => {
1431
+ a === !1 && B.current.isPositioned && (B.current.isPositioned = !1, u((T) => ({
1432
+ ...T,
1433
+ isPositioned: !1
1434
+ })));
1435
+ }, [a]);
1436
+ const D = y.useRef(!1);
1437
+ kt(() => (D.current = !0, () => {
1438
+ D.current = !1;
1439
+ }), []), kt(() => {
1440
+ if (C && (k.current = C), S && (_.current = S), C && S) {
1441
+ if (H.current)
1442
+ return H.current(C, S, N);
1443
+ N();
1444
+ }
1445
+ }, [C, S, N, H, U]);
1446
+ const E = y.useMemo(() => ({
1447
+ reference: k,
1448
+ floating: _,
1449
+ setReference: w,
1450
+ setFloating: g
1451
+ }), [w, g]), A = y.useMemo(() => ({
1452
+ reference: C,
1453
+ floating: S
1454
+ }), [C, S]), M = y.useMemo(() => {
1455
+ const T = {
1456
+ position: n,
1457
+ left: 0,
1458
+ top: 0
1459
+ };
1460
+ if (!A.floating)
1461
+ return T;
1462
+ const I = Qn(A.floating, m.x), X = Qn(A.floating, m.y);
1463
+ return c ? {
1464
+ ...T,
1465
+ transform: "translate(" + I + "px, " + X + "px)",
1466
+ ...qr(A.floating) >= 1.5 && {
1467
+ willChange: "transform"
1468
+ }
1469
+ } : {
1470
+ position: n,
1471
+ left: I,
1472
+ top: X
1473
+ };
1474
+ }, [n, c, A.floating, m.x, m.y]);
1475
+ return y.useMemo(() => ({
1476
+ ...m,
1477
+ update: N,
1478
+ refs: E,
1479
+ elements: A,
1480
+ floatingStyles: M
1481
+ }), [m, N, E, A, M]);
1482
+ }
1483
+ const Qi = (e, t) => ({
1484
+ ...Kr(e),
1485
+ options: [e, t]
1486
+ }), es = (e, t) => ({
1487
+ ...Wr(e),
1488
+ options: [e, t]
1489
+ }), ts = (e, t) => ({
1490
+ ...Zi(e),
1491
+ options: [e, t]
1492
+ });
1493
+ function Re(e) {
1494
+ return y.useMemo(() => e.every((t) => t == null) ? null : (t) => {
1495
+ e.forEach((n) => {
1496
+ typeof n == "function" ? n(t) : n != null && (n.current = t);
1497
+ });
1498
+ }, e);
1499
+ }
1500
+ const Ur = {
1501
+ ...y
1502
+ }, ns = Ur.useInsertionEffect, rs = ns || ((e) => e());
1503
+ function Oe(e) {
1504
+ const t = y.useRef(() => {
1505
+ if (process.env.NODE_ENV !== "production")
1506
+ throw new Error("Cannot call an event handler while rendering.");
1507
+ });
1508
+ return rs(() => {
1509
+ t.current = e;
1510
+ }), y.useCallback(function() {
1511
+ for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++)
1512
+ r[o] = arguments[o];
1513
+ return t.current == null ? void 0 : t.current(...r);
1514
+ }, []);
1515
+ }
1516
+ const An = "ArrowUp", Ct = "ArrowDown", st = "ArrowLeft", dt = "ArrowRight";
1517
+ function St(e, t, n) {
1518
+ return Math.floor(e / t) !== n;
1519
+ }
1520
+ function bt(e, t) {
1521
+ return t < 0 || t >= e.current.length;
1522
+ }
1523
+ function en(e, t) {
1524
+ return me(e, {
1525
+ disabledIndices: t
1526
+ });
1527
+ }
1528
+ function er(e, t) {
1529
+ return me(e, {
1530
+ decrement: !0,
1531
+ startingIndex: e.current.length,
1532
+ disabledIndices: t
1533
+ });
1534
+ }
1535
+ function me(e, t) {
1536
+ let {
1537
+ startingIndex: n = -1,
1538
+ decrement: r = !1,
1539
+ disabledIndices: o,
1540
+ amount: i = 1
1541
+ } = t === void 0 ? {} : t;
1542
+ const s = e.current;
1543
+ let c = n;
1544
+ do
1545
+ c += r ? -i : i;
1546
+ while (c >= 0 && c <= s.length - 1 && Nt(s, c, o));
1547
+ return c;
1548
+ }
1549
+ function os(e, t) {
1550
+ let {
1551
+ event: n,
1552
+ orientation: r,
1553
+ loop: o,
1554
+ cols: i,
1555
+ disabledIndices: s,
1556
+ minIndex: c,
1557
+ maxIndex: l,
1558
+ prevIndex: a,
1559
+ stopEvent: m = !1
1560
+ } = t, u = a;
1561
+ if (n.key === An) {
1562
+ if (m && be(n), a === -1)
1563
+ u = l;
1564
+ else if (u = me(e, {
1565
+ startingIndex: u,
1566
+ amount: i,
1567
+ decrement: !0,
1568
+ disabledIndices: s
1569
+ }), o && (a - i < c || u < 0)) {
1570
+ const d = a % i, f = l % i, p = l - (f - d);
1571
+ f === d ? u = l : u = f > d ? p : p - i;
1572
+ }
1573
+ bt(e, u) && (u = a);
1574
+ }
1575
+ if (n.key === Ct && (m && be(n), a === -1 ? u = c : (u = me(e, {
1576
+ startingIndex: a,
1577
+ amount: i,
1578
+ disabledIndices: s
1579
+ }), o && a + i > l && (u = me(e, {
1580
+ startingIndex: a % i - i,
1581
+ amount: i,
1582
+ disabledIndices: s
1583
+ }))), bt(e, u) && (u = a)), r === "both") {
1584
+ const d = tt(a / i);
1585
+ n.key === dt && (m && be(n), a % i !== i - 1 ? (u = me(e, {
1586
+ startingIndex: a,
1587
+ disabledIndices: s
1588
+ }), o && St(u, i, d) && (u = me(e, {
1589
+ startingIndex: a - a % i - 1,
1590
+ disabledIndices: s
1591
+ }))) : o && (u = me(e, {
1592
+ startingIndex: a - a % i - 1,
1593
+ disabledIndices: s
1594
+ })), St(u, i, d) && (u = a)), n.key === st && (m && be(n), a % i !== 0 ? (u = me(e, {
1595
+ startingIndex: a,
1596
+ decrement: !0,
1597
+ disabledIndices: s
1598
+ }), o && St(u, i, d) && (u = me(e, {
1599
+ startingIndex: a + (i - a % i),
1600
+ decrement: !0,
1601
+ disabledIndices: s
1602
+ }))) : o && (u = me(e, {
1603
+ startingIndex: a + (i - a % i),
1604
+ decrement: !0,
1605
+ disabledIndices: s
1606
+ })), St(u, i, d) && (u = a));
1607
+ const f = tt(l / i) === d;
1608
+ bt(e, u) && (o && f ? u = n.key === st ? l : me(e, {
1609
+ startingIndex: a - a % i - 1,
1610
+ disabledIndices: s
1611
+ }) : u = a);
1612
+ }
1613
+ return u;
1614
+ }
1615
+ function is(e, t, n) {
1616
+ const r = [];
1617
+ let o = 0;
1618
+ return e.forEach((i, s) => {
1619
+ let {
1620
+ width: c,
1621
+ height: l
1622
+ } = i;
1623
+ if (c > t && process.env.NODE_ENV !== "production")
1624
+ throw new Error("[Floating UI]: Invalid grid - item width at index " + s + " is greater than grid columns");
1625
+ let a = !1;
1626
+ for (n && (o = 0); !a; ) {
1627
+ const m = [];
1628
+ for (let u = 0; u < c; u++)
1629
+ for (let d = 0; d < l; d++)
1630
+ m.push(o + u + d * t);
1631
+ o % t + c <= t && m.every((u) => r[u] == null) ? (m.forEach((u) => {
1632
+ r[u] = s;
1633
+ }), a = !0) : o++;
1634
+ }
1635
+ }), [...r];
1636
+ }
1637
+ function ss(e, t, n, r, o) {
1638
+ if (e === -1) return -1;
1639
+ const i = n.indexOf(e), s = t[e];
1640
+ switch (o) {
1641
+ case "tl":
1642
+ return i;
1643
+ case "tr":
1644
+ return s ? i + s.width - 1 : i;
1645
+ case "bl":
1646
+ return s ? i + (s.height - 1) * r : i;
1647
+ case "br":
1648
+ return n.lastIndexOf(e);
1649
+ }
1650
+ }
1651
+ function cs(e, t) {
1652
+ return t.flatMap((n, r) => e.includes(n) ? [r] : []);
1653
+ }
1654
+ function Nt(e, t, n) {
1655
+ if (n)
1656
+ return n.includes(t);
1657
+ const r = e[t];
1658
+ return r == null || r.hasAttribute("disabled") || r.getAttribute("aria-disabled") === "true";
1659
+ }
1660
+ let tr = 0;
1661
+ function _e(e, t) {
1662
+ t === void 0 && (t = {});
1663
+ const {
1664
+ preventScroll: n = !1,
1665
+ cancelPrevious: r = !0,
1666
+ sync: o = !1
1667
+ } = t;
1668
+ r && cancelAnimationFrame(tr);
1669
+ const i = () => e == null ? void 0 : e.focus({
1670
+ preventScroll: n
1671
+ });
1672
+ o ? i() : tr = requestAnimationFrame(i);
1673
+ }
1674
+ var te = typeof document < "u" ? Cn : ie;
1675
+ function $t() {
1676
+ return $t = Object.assign ? Object.assign.bind() : function(e) {
1677
+ for (var t = 1; t < arguments.length; t++) {
1678
+ var n = arguments[t];
1679
+ for (var r in n)
1680
+ Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
1681
+ }
1682
+ return e;
1683
+ }, $t.apply(this, arguments);
1684
+ }
1685
+ let nr = !1, as = 0;
1686
+ const rr = () => (
1687
+ // Ensure the id is unique with multiple independent versions of Floating UI
1688
+ // on <React 18
1689
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + as++
1690
+ );
1691
+ function ls() {
1692
+ const [e, t] = y.useState(() => nr ? rr() : void 0);
1693
+ return te(() => {
1694
+ e == null && t(rr());
1695
+ }, []), y.useEffect(() => {
1696
+ nr = !0;
1697
+ }, []), e;
1698
+ }
1699
+ const us = Ur.useId, kn = us || ls;
1700
+ let yt;
1701
+ process.env.NODE_ENV !== "production" && (yt = /* @__PURE__ */ new Set());
1702
+ function tn() {
1703
+ for (var e, t = arguments.length, n = new Array(t), r = 0; r < t; r++)
1704
+ n[r] = arguments[r];
1705
+ const o = "Floating UI: " + n.join(" ");
1706
+ if (!((e = yt) != null && e.has(o))) {
1707
+ var i;
1708
+ (i = yt) == null || i.add(o), console.warn(o);
1709
+ }
1710
+ }
1711
+ function fs() {
1712
+ for (var e, t = arguments.length, n = new Array(t), r = 0; r < t; r++)
1713
+ n[r] = arguments[r];
1714
+ const o = "Floating UI: " + n.join(" ");
1715
+ if (!((e = yt) != null && e.has(o))) {
1716
+ var i;
1717
+ (i = yt) == null || i.add(o), console.error(o);
1718
+ }
1719
+ }
1720
+ function ds() {
1721
+ const e = /* @__PURE__ */ new Map();
1722
+ return {
1723
+ emit(t, n) {
1724
+ var r;
1725
+ (r = e.get(t)) == null || r.forEach((o) => o(n));
1726
+ },
1727
+ on(t, n) {
1728
+ e.set(t, [...e.get(t) || [], n]);
1729
+ },
1730
+ off(t, n) {
1731
+ var r;
1732
+ e.set(t, ((r = e.get(t)) == null ? void 0 : r.filter((o) => o !== n)) || []);
1733
+ }
1734
+ };
1735
+ }
1736
+ const ms = /* @__PURE__ */ y.createContext(null), ps = /* @__PURE__ */ y.createContext(null), Nn = () => {
1737
+ var e;
1738
+ return ((e = y.useContext(ms)) == null ? void 0 : e.id) || null;
1739
+ }, Ht = () => y.useContext(ps);
1740
+ function ct(e) {
1741
+ return "data-floating-ui-" + e;
1742
+ }
1743
+ function Be(e) {
1744
+ const t = oe(e);
1745
+ return te(() => {
1746
+ t.current = e;
1747
+ }), t;
1748
+ }
1749
+ function bs(e, t) {
1750
+ var n;
1751
+ let r = [], o = (n = e.find((i) => i.id === t)) == null ? void 0 : n.parentId;
1752
+ for (; o; ) {
1753
+ const i = e.find((s) => s.id === o);
1754
+ o = i == null ? void 0 : i.parentId, i && (r = r.concat(i));
1755
+ }
1756
+ return r;
1757
+ }
1758
+ function rt(e, t) {
1759
+ let n = e.filter((o) => {
1760
+ var i;
1761
+ return o.parentId === t && ((i = o.context) == null ? void 0 : i.open);
1762
+ }), r = n;
1763
+ for (; r.length; )
1764
+ r = e.filter((o) => {
1765
+ var i;
1766
+ return (i = r) == null ? void 0 : i.some((s) => {
1767
+ var c;
1768
+ return o.parentId === s.id && ((c = o.context) == null ? void 0 : c.open);
1769
+ });
1770
+ }), n = n.concat(r);
1771
+ return n;
1772
+ }
1773
+ function hs(e, t) {
1774
+ let n, r = -1;
1775
+ function o(i, s) {
1776
+ s > r && (n = i, r = s), rt(e, i).forEach((l) => {
1777
+ o(l.id, s + 1);
1778
+ });
1779
+ }
1780
+ return o(t, 0), e.find((i) => i.id === n);
1781
+ }
1782
+ let et = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakSet(), Tt = {}, nn = 0;
1783
+ const gs = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype, Yr = (e) => e && (e.host || Yr(e.parentNode)), ys = (e, t) => t.map((n) => {
1784
+ if (e.contains(n))
1785
+ return n;
1786
+ const r = Yr(n);
1787
+ return e.contains(r) ? r : null;
1788
+ }).filter((n) => n != null);
1789
+ function vs(e, t, n, r) {
1790
+ const o = "data-floating-ui-inert", i = r ? "inert" : n ? "aria-hidden" : null, s = ys(t, e), c = /* @__PURE__ */ new Set(), l = new Set(s), a = [];
1791
+ Tt[o] || (Tt[o] = /* @__PURE__ */ new WeakMap());
1792
+ const m = Tt[o];
1793
+ s.forEach(u), d(t), c.clear();
1794
+ function u(f) {
1795
+ !f || c.has(f) || (c.add(f), f.parentNode && u(f.parentNode));
1796
+ }
1797
+ function d(f) {
1798
+ !f || l.has(f) || [].forEach.call(f.children, (p) => {
1799
+ if (Ke(p) !== "script")
1800
+ if (c.has(p))
1801
+ d(p);
1802
+ else {
1803
+ const h = i ? p.getAttribute(i) : null, b = h !== null && h !== "false", x = (et.get(p) || 0) + 1, w = (m.get(p) || 0) + 1;
1804
+ et.set(p, x), m.set(p, w), a.push(p), x === 1 && b && Ot.add(p), w === 1 && p.setAttribute(o, ""), !b && i && p.setAttribute(i, "true");
1805
+ }
1806
+ });
1807
+ }
1808
+ return nn++, () => {
1809
+ a.forEach((f) => {
1810
+ const p = (et.get(f) || 0) - 1, h = (m.get(f) || 0) - 1;
1811
+ et.set(f, p), m.set(f, h), p || (!Ot.has(f) && i && f.removeAttribute(i), Ot.delete(f)), h || f.removeAttribute(o);
1812
+ }), nn--, nn || (et = /* @__PURE__ */ new WeakMap(), et = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakSet(), Tt = {});
1813
+ };
1814
+ }
1815
+ function or(e, t, n) {
1816
+ t === void 0 && (t = !1), n === void 0 && (n = !1);
1817
+ const r = xe(e[0]).body;
1818
+ return vs(e.concat(Array.from(r.querySelectorAll("[aria-live]"))), r, t, n);
1819
+ }
1820
+ const at = () => ({
1821
+ getShadowRoot: !0,
1822
+ displayCheck: (
1823
+ // JSDOM does not support the `tabbable` library. To solve this we can
1824
+ // check if `ResizeObserver` is a real function (not polyfilled), which
1825
+ // determines if the current environment is JSDOM-like.
1826
+ typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
1827
+ )
1828
+ });
1829
+ function Xr(e, t) {
1830
+ const n = gt(e, at());
1831
+ t === "prev" && n.reverse();
1832
+ const r = n.indexOf(Le(xe(e)));
1833
+ return n.slice(r + 1)[0];
1834
+ }
1835
+ function Gr() {
1836
+ return Xr(document.body, "next");
1837
+ }
1838
+ function Zr() {
1839
+ return Xr(document.body, "prev");
1840
+ }
1841
+ function ht(e, t) {
1842
+ const n = t || e.currentTarget, r = e.relatedTarget;
1843
+ return !r || !pe(n, r);
1844
+ }
1845
+ function xs(e) {
1846
+ gt(e, at()).forEach((n) => {
1847
+ n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
1848
+ });
1849
+ }
1850
+ function ir(e) {
1851
+ e.querySelectorAll("[data-tabindex]").forEach((n) => {
1852
+ const r = n.dataset.tabindex;
1853
+ delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
1854
+ });
1855
+ }
1856
+ function ws(e, t, n) {
1857
+ const r = e.indexOf(t);
1858
+ function o(s) {
1859
+ const c = ct("focus-guard");
1860
+ let l = r + (s ? 1 : 0), a = e[l];
1861
+ for (; a && (!a.isConnected || a.hasAttribute(c) || pe(n, a)); )
1862
+ s ? l++ : l--, a = e[l];
1863
+ return a;
1864
+ }
1865
+ const i = o(!0);
1866
+ return i || o(!1);
1867
+ }
1868
+ const Dn = {
1869
+ border: 0,
1870
+ clip: "rect(0 0 0 0)",
1871
+ height: "1px",
1872
+ margin: "-1px",
1873
+ overflow: "hidden",
1874
+ padding: 0,
1875
+ position: "fixed",
1876
+ whiteSpace: "nowrap",
1877
+ width: "1px",
1878
+ top: 0,
1879
+ left: 0
1880
+ };
1881
+ let Cs;
1882
+ function sr(e) {
1883
+ e.key === "Tab" && (e.target, clearTimeout(Cs));
1884
+ }
1885
+ const Vt = /* @__PURE__ */ y.forwardRef(function(t, n) {
1886
+ const [r, o] = y.useState();
1887
+ te(() => (Or() && o("button"), document.addEventListener("keydown", sr), () => {
1888
+ document.removeEventListener("keydown", sr);
1889
+ }), []);
1890
+ const i = {
1891
+ ref: n,
1892
+ tabIndex: 0,
1893
+ // Role is only for VoiceOver
1894
+ role: r,
1895
+ "aria-hidden": r ? void 0 : !0,
1896
+ [ct("focus-guard")]: "",
1897
+ style: Dn
1898
+ };
1899
+ return /* @__PURE__ */ y.createElement("span", $t({}, t, i));
1900
+ }), Jr = /* @__PURE__ */ y.createContext(null), cr = /* @__PURE__ */ ct("portal");
1901
+ function Es(e) {
1902
+ e === void 0 && (e = {});
1903
+ const {
1904
+ id: t,
1905
+ root: n
1906
+ } = e, r = kn(), o = Qr(), [i, s] = y.useState(null), c = y.useRef(null);
1907
+ return te(() => () => {
1908
+ i == null || i.remove(), queueMicrotask(() => {
1909
+ c.current = null;
1910
+ });
1911
+ }, [i]), te(() => {
1912
+ if (!r || c.current) return;
1913
+ const l = t ? document.getElementById(t) : null;
1914
+ if (!l) return;
1915
+ const a = document.createElement("div");
1916
+ a.id = r, a.setAttribute(cr, ""), l.appendChild(a), c.current = a, s(a);
1917
+ }, [t, r]), te(() => {
1918
+ if (!r || c.current) return;
1919
+ let l = n || (o == null ? void 0 : o.portalNode);
1920
+ l && !J(l) && (l = l.current), l = l || document.body;
1921
+ let a = null;
1922
+ t && (a = document.createElement("div"), a.id = t, l.appendChild(a));
1923
+ const m = document.createElement("div");
1924
+ m.id = r, m.setAttribute(cr, ""), l = a || l, l.appendChild(m), c.current = m, s(m);
1925
+ }, [t, n, r, o]), i;
1926
+ }
1927
+ function Rs(e) {
1928
+ const {
1929
+ children: t,
1930
+ id: n,
1931
+ root: r = null,
1932
+ preserveTabOrder: o = !0
1933
+ } = e, i = Es({
1934
+ id: n,
1935
+ root: r
1936
+ }), [s, c] = y.useState(null), l = y.useRef(null), a = y.useRef(null), m = y.useRef(null), u = y.useRef(null), d = s == null ? void 0 : s.modal, f = s == null ? void 0 : s.open, p = (
1937
+ // The FocusManager and therefore floating element are currently open/
1938
+ // rendered.
1939
+ !!s && // Guards are only for non-modal focus management.
1940
+ !s.modal && // Don't render if unmount is transitioning.
1941
+ s.open && o && !!(r || i)
1942
+ );
1943
+ return y.useEffect(() => {
1944
+ if (!i || !o || d)
1945
+ return;
1946
+ function h(b) {
1947
+ i && ht(b) && (b.type === "focusin" ? ir : xs)(i);
1948
+ }
1949
+ return i.addEventListener("focusin", h, !0), i.addEventListener("focusout", h, !0), () => {
1950
+ i.removeEventListener("focusin", h, !0), i.removeEventListener("focusout", h, !0);
1951
+ };
1952
+ }, [i, o, d]), y.useEffect(() => {
1953
+ i && (f || ir(i));
1954
+ }, [f, i]), /* @__PURE__ */ y.createElement(Jr.Provider, {
1955
+ value: y.useMemo(() => ({
1956
+ preserveTabOrder: o,
1957
+ beforeOutsideRef: l,
1958
+ afterOutsideRef: a,
1959
+ beforeInsideRef: m,
1960
+ afterInsideRef: u,
1961
+ portalNode: i,
1962
+ setFocusManagerState: c
1963
+ }), [o, i])
1964
+ }, p && i && /* @__PURE__ */ y.createElement(Vt, {
1965
+ "data-type": "outside",
1966
+ ref: l,
1967
+ onFocus: (h) => {
1968
+ if (ht(h, i)) {
1969
+ var b;
1970
+ (b = m.current) == null || b.focus();
1971
+ } else {
1972
+ const x = Zr() || (s == null ? void 0 : s.refs.domReference.current);
1973
+ x == null || x.focus();
1974
+ }
1975
+ }
1976
+ }), p && i && /* @__PURE__ */ y.createElement("span", {
1977
+ "aria-owns": i.id,
1978
+ style: Dn
1979
+ }), i && /* @__PURE__ */ xr.createPortal(t, i), p && i && /* @__PURE__ */ y.createElement(Vt, {
1980
+ "data-type": "outside",
1981
+ ref: a,
1982
+ onFocus: (h) => {
1983
+ if (ht(h, i)) {
1984
+ var b;
1985
+ (b = u.current) == null || b.focus();
1986
+ } else {
1987
+ const x = Gr() || (s == null ? void 0 : s.refs.domReference.current);
1988
+ x == null || x.focus(), s != null && s.closeOnFocusOut && (s == null || s.onOpenChange(!1, h.nativeEvent, "focus-out"));
1989
+ }
1990
+ }
1991
+ }));
1992
+ }
1993
+ const Qr = () => y.useContext(Jr), yn = "data-floating-ui-focusable";
1994
+ function eo(e) {
1995
+ return e ? e.hasAttribute(yn) ? e : e.querySelector("[" + yn + "]") || e : null;
1996
+ }
1997
+ const Is = 20;
1998
+ let Ue = [];
1999
+ function rn(e) {
2000
+ Ue = Ue.filter((n) => n.isConnected);
2001
+ let t = e;
2002
+ if (!(!t || Ke(t) === "body")) {
2003
+ if (!Ti(t, at())) {
2004
+ const n = gt(t, at())[0];
2005
+ n && (t = n);
2006
+ }
2007
+ Ue.push(t), Ue.length > Is && (Ue = Ue.slice(-20));
2008
+ }
2009
+ }
2010
+ function ar() {
2011
+ return Ue.slice().reverse().find((e) => e.isConnected);
2012
+ }
2013
+ const Ss = /* @__PURE__ */ y.forwardRef(function(t, n) {
2014
+ return /* @__PURE__ */ y.createElement("button", $t({}, t, {
2015
+ type: "button",
2016
+ ref: n,
2017
+ tabIndex: -1,
2018
+ style: Dn
2019
+ }));
2020
+ });
2021
+ function Os(e) {
2022
+ const {
2023
+ context: t,
2024
+ children: n,
2025
+ disabled: r = !1,
2026
+ order: o = ["content"],
2027
+ guards: i = !0,
2028
+ initialFocus: s = 0,
2029
+ returnFocus: c = !0,
2030
+ restoreFocus: l = !1,
2031
+ modal: a = !0,
2032
+ visuallyHiddenDismiss: m = !1,
2033
+ closeOnFocusOut: u = !0
2034
+ } = e, {
2035
+ open: d,
2036
+ refs: f,
2037
+ nodeId: p,
2038
+ onOpenChange: h,
2039
+ events: b,
2040
+ dataRef: x,
2041
+ floatingId: w,
2042
+ elements: {
2043
+ domReference: g,
2044
+ floating: C
2045
+ }
2046
+ } = t, S = typeof s == "number" && s < 0, k = Tr(g) && S, _ = gs() ? i : !0, B = Be(o), U = Be(s), H = Be(c), W = Ht(), O = Qr(), N = y.useRef(null), D = y.useRef(null), E = y.useRef(!1), A = y.useRef(!1), M = y.useRef(-1), T = O != null, I = eo(C), X = Oe(function(j) {
2047
+ return j === void 0 && (j = I), j ? gt(j, at()) : [];
2048
+ }), se = Oe((j) => {
2049
+ const F = X(j);
2050
+ return B.current.map((L) => g && L === "reference" ? g : I && L === "floating" ? I : F).filter(Boolean).flat();
2051
+ });
2052
+ y.useEffect(() => {
2053
+ E.current = !1;
2054
+ }, [r]), y.useEffect(() => {
2055
+ if (r || !a) return;
2056
+ function j(L) {
2057
+ if (L.key === "Tab") {
2058
+ pe(I, Le(xe(I))) && X().length === 0 && !k && be(L);
2059
+ const $ = se(), G = Ye(L);
2060
+ B.current[0] === "reference" && G === g && (be(L), L.shiftKey ? _e($[$.length - 1]) : _e($[1])), B.current[1] === "floating" && G === I && L.shiftKey && (be(L), _e($[0]));
2061
+ }
2062
+ }
2063
+ const F = xe(I);
2064
+ return F.addEventListener("keydown", j), () => {
2065
+ F.removeEventListener("keydown", j);
2066
+ };
2067
+ }, [r, g, I, a, B, k, X, se]), y.useEffect(() => {
2068
+ if (r || !C) return;
2069
+ function j(F) {
2070
+ const L = Ye(F), G = X().indexOf(L);
2071
+ G !== -1 && (M.current = G);
2072
+ }
2073
+ return C.addEventListener("focusin", j), () => {
2074
+ C.removeEventListener("focusin", j);
2075
+ };
2076
+ }, [r, C, X]), y.useEffect(() => {
2077
+ if (r || !u) return;
2078
+ function j() {
2079
+ A.current = !0, setTimeout(() => {
2080
+ A.current = !1;
2081
+ });
2082
+ }
2083
+ function F(L) {
2084
+ const $ = L.relatedTarget;
2085
+ queueMicrotask(() => {
2086
+ const G = !(pe(g, $) || pe(C, $) || pe($, C) || pe(O == null ? void 0 : O.portalNode, $) || $ != null && $.hasAttribute(ct("focus-guard")) || W && (rt(W.nodesRef.current, p).find((ne) => {
2087
+ var ce, Z;
2088
+ return pe((ce = ne.context) == null ? void 0 : ce.elements.floating, $) || pe((Z = ne.context) == null ? void 0 : Z.elements.domReference, $);
2089
+ }) || bs(W.nodesRef.current, p).find((ne) => {
2090
+ var ce, Z;
2091
+ return ((ce = ne.context) == null ? void 0 : ce.elements.floating) === $ || ((Z = ne.context) == null ? void 0 : Z.elements.domReference) === $;
2092
+ })));
2093
+ if (l && G && Le(xe(I)) === xe(I).body) {
2094
+ re(I) && I.focus();
2095
+ const ne = M.current, ce = X(), Z = ce[ne] || ce[ce.length - 1] || I;
2096
+ re(Z) && Z.focus();
2097
+ }
2098
+ (k || !a) && $ && G && !A.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
2099
+ $ !== ar() && (E.current = !0, h(!1, L, "focus-out"));
2100
+ });
2101
+ }
2102
+ if (C && re(g))
2103
+ return g.addEventListener("focusout", F), g.addEventListener("pointerdown", j), C.addEventListener("focusout", F), () => {
2104
+ g.removeEventListener("focusout", F), g.removeEventListener("pointerdown", j), C.removeEventListener("focusout", F);
2105
+ };
2106
+ }, [r, g, C, I, a, p, W, O, h, u, l, X, k]), y.useEffect(() => {
2107
+ var j;
2108
+ if (r) return;
2109
+ const F = Array.from((O == null || (j = O.portalNode) == null ? void 0 : j.querySelectorAll("[" + ct("portal") + "]")) || []);
2110
+ if (C) {
2111
+ const L = [C, ...F, N.current, D.current, B.current.includes("reference") || k ? g : null].filter((G) => G != null), $ = a || k ? or(L, _, !_) : or(L);
2112
+ return () => {
2113
+ $();
2114
+ };
2115
+ }
2116
+ }, [r, g, C, a, B, O, k, _]), te(() => {
2117
+ if (r || !re(I)) return;
2118
+ const j = xe(I), F = Le(j);
2119
+ queueMicrotask(() => {
2120
+ const L = se(I), $ = U.current, G = (typeof $ == "number" ? L[$] : $.current) || I, ne = pe(I, F);
2121
+ !S && !ne && d && _e(G, {
2122
+ preventScroll: G === I
2123
+ });
2124
+ });
2125
+ }, [r, d, I, S, se, U]), te(() => {
2126
+ if (r || !I) return;
2127
+ let j = !1;
2128
+ const F = xe(I), L = Le(F);
2129
+ let G = x.current.openEvent;
2130
+ const ne = f.domReference.current;
2131
+ rn(L);
2132
+ function ce(Z) {
2133
+ let {
2134
+ open: De,
2135
+ reason: Te,
2136
+ event: ee,
2137
+ nested: Pe
2138
+ } = Z;
2139
+ De && (G = ee), Te === "escape-key" && f.domReference.current && rn(f.domReference.current), Te === "hover" && ee.type === "mouseleave" && (E.current = !0), Te === "outside-press" && (Pe ? (E.current = !1, j = !0) : E.current = !(Ir(ee) || Sr(ee)));
2140
+ }
2141
+ return b.on("openchange", ce), () => {
2142
+ b.off("openchange", ce);
2143
+ const Z = Le(F), De = pe(C, Z) || W && rt(W.nodesRef.current, p).some((ge) => {
2144
+ var He;
2145
+ return pe((He = ge.context) == null ? void 0 : He.elements.floating, Z);
2146
+ });
2147
+ (De || G && ["click", "mousedown"].includes(G.type)) && f.domReference.current && rn(f.domReference.current);
2148
+ const ee = ne || L, Pe = gt(xe(ee).body, at());
2149
+ queueMicrotask(() => {
2150
+ let ge = ar();
2151
+ !ge && re(ee) && C && (ge = ws(Pe, ee, C)), // eslint-disable-next-line react-hooks/exhaustive-deps
2152
+ H.current && !E.current && re(ge) && // If the focus moved somewhere else after mount, avoid returning focus
2153
+ // since it likely entered a different element which should be
2154
+ // respected: https://github.com/floating-ui/floating-ui/issues/2607
2155
+ (!(ge !== Z && Z !== F.body) || De) && ge.focus({
2156
+ preventScroll: j
2157
+ });
2158
+ });
2159
+ };
2160
+ }, [r, C, I, H, x, f, b, W, p]), te(() => {
2161
+ if (!r && O)
2162
+ return O.setFocusManagerState({
2163
+ modal: a,
2164
+ closeOnFocusOut: u,
2165
+ open: d,
2166
+ onOpenChange: h,
2167
+ refs: f
2168
+ }), () => {
2169
+ O.setFocusManagerState(null);
2170
+ };
2171
+ }, [r, O, a, d, h, f, u]), te(() => {
2172
+ if (r || !I || typeof MutationObserver != "function" || S) return;
2173
+ const j = () => {
2174
+ const L = I.getAttribute("tabindex"), $ = X(), G = Le(xe(C)), ne = $.indexOf(G);
2175
+ ne !== -1 && (M.current = ne), B.current.includes("floating") || G !== f.domReference.current && $.length === 0 ? L !== "0" && I.setAttribute("tabindex", "0") : L !== "-1" && I.setAttribute("tabindex", "-1");
2176
+ };
2177
+ j();
2178
+ const F = new MutationObserver(j);
2179
+ return F.observe(I, {
2180
+ childList: !0,
2181
+ subtree: !0,
2182
+ attributes: !0
2183
+ }), () => {
2184
+ F.disconnect();
2185
+ };
2186
+ }, [r, C, I, f, B, X, S]);
2187
+ function Ie(j) {
2188
+ return r || !m || !a ? null : /* @__PURE__ */ y.createElement(Ss, {
2189
+ ref: j === "start" ? N : D,
2190
+ onClick: (F) => h(!1, F.nativeEvent)
2191
+ }, typeof m == "string" ? m : "Dismiss");
2192
+ }
2193
+ const he = !r && _ && (a ? !k : !0) && (T || a);
2194
+ return /* @__PURE__ */ y.createElement(y.Fragment, null, he && /* @__PURE__ */ y.createElement(Vt, {
2195
+ "data-type": "inside",
2196
+ ref: O == null ? void 0 : O.beforeInsideRef,
2197
+ onFocus: (j) => {
2198
+ if (a) {
2199
+ const L = se();
2200
+ _e(o[0] === "reference" ? L[0] : L[L.length - 1]);
2201
+ } else if (O != null && O.preserveTabOrder && O.portalNode)
2202
+ if (E.current = !1, ht(j, O.portalNode)) {
2203
+ const L = Gr() || g;
2204
+ L == null || L.focus();
2205
+ } else {
2206
+ var F;
2207
+ (F = O.beforeOutsideRef.current) == null || F.focus();
2208
+ }
2209
+ }
2210
+ }), !k && Ie("start"), n, Ie("end"), he && /* @__PURE__ */ y.createElement(Vt, {
2211
+ "data-type": "inside",
2212
+ ref: O == null ? void 0 : O.afterInsideRef,
2213
+ onFocus: (j) => {
2214
+ if (a)
2215
+ _e(se()[0]);
2216
+ else if (O != null && O.preserveTabOrder && O.portalNode)
2217
+ if (u && (E.current = !0), ht(j, O.portalNode)) {
2218
+ const L = Zr() || g;
2219
+ L == null || L.focus();
2220
+ } else {
2221
+ var F;
2222
+ (F = O.afterOutsideRef.current) == null || F.focus();
2223
+ }
2224
+ }
2225
+ }));
2226
+ }
2227
+ const Ts = {
2228
+ pointerdown: "onPointerDown",
2229
+ mousedown: "onMouseDown",
2230
+ click: "onClick"
2231
+ }, As = {
2232
+ pointerdown: "onPointerDownCapture",
2233
+ mousedown: "onMouseDownCapture",
2234
+ click: "onClickCapture"
2235
+ }, lr = (e) => {
2236
+ var t, n;
2237
+ return {
2238
+ escapeKey: typeof e == "boolean" ? e : (t = e == null ? void 0 : e.escapeKey) != null ? t : !1,
2239
+ outsidePress: typeof e == "boolean" ? e : (n = e == null ? void 0 : e.outsidePress) != null ? n : !0
2240
+ };
2241
+ };
2242
+ function ks(e, t) {
2243
+ t === void 0 && (t = {});
2244
+ const {
2245
+ open: n,
2246
+ onOpenChange: r,
2247
+ elements: o,
2248
+ dataRef: i
2249
+ } = e, {
2250
+ enabled: s = !0,
2251
+ escapeKey: c = !0,
2252
+ outsidePress: l = !0,
2253
+ outsidePressEvent: a = "pointerdown",
2254
+ referencePress: m = !1,
2255
+ referencePressEvent: u = "pointerdown",
2256
+ ancestorScroll: d = !1,
2257
+ bubbles: f,
2258
+ capture: p
2259
+ } = t, h = Ht(), b = Oe(typeof l == "function" ? l : () => !1), x = typeof l == "function" ? b : l, w = y.useRef(!1), g = y.useRef(!1), {
2260
+ escapeKey: C,
2261
+ outsidePress: S
2262
+ } = lr(f), {
2263
+ escapeKey: k,
2264
+ outsidePress: _
2265
+ } = lr(p), B = Oe((D) => {
2266
+ var E;
2267
+ if (!n || !s || !c || D.key !== "Escape")
2268
+ return;
2269
+ const A = (E = i.current.floatingContext) == null ? void 0 : E.nodeId, M = h ? rt(h.nodesRef.current, A) : [];
2270
+ if (!C && (D.stopPropagation(), M.length > 0)) {
2271
+ let T = !0;
2272
+ if (M.forEach((I) => {
2273
+ var X;
2274
+ if ((X = I.context) != null && X.open && !I.context.dataRef.current.__escapeKeyBubbles) {
2275
+ T = !1;
2276
+ return;
2277
+ }
2278
+ }), !T)
2279
+ return;
2280
+ }
2281
+ r(!1, Jo(D) ? D.nativeEvent : D, "escape-key");
2282
+ }), U = Oe((D) => {
2283
+ var E;
2284
+ const A = () => {
2285
+ var M;
2286
+ B(D), (M = Ye(D)) == null || M.removeEventListener("keydown", A);
2287
+ };
2288
+ (E = Ye(D)) == null || E.addEventListener("keydown", A);
2289
+ }), H = Oe((D) => {
2290
+ var E;
2291
+ const A = w.current;
2292
+ w.current = !1;
2293
+ const M = g.current;
2294
+ if (g.current = !1, a === "click" && M || A || typeof x == "function" && !x(D))
2295
+ return;
2296
+ const T = Ye(D), I = "[" + ct("inert") + "]", X = xe(o.floating).querySelectorAll(I);
2297
+ let se = J(T) ? T : null;
2298
+ for (; se && !Ve(se); ) {
2299
+ const F = Fe(se);
2300
+ if (Ve(F) || !J(F))
2301
+ break;
2302
+ se = F;
2303
+ }
2304
+ if (X.length && J(T) && !Qo(T) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
2305
+ !pe(T, o.floating) && // If the target root element contains none of the markers, then the
2306
+ // element was injected after the floating element rendered.
2307
+ Array.from(X).every((F) => !pe(se, F)))
2308
+ return;
2309
+ if (re(T) && N) {
2310
+ const F = T.clientWidth > 0 && T.scrollWidth > T.clientWidth, L = T.clientHeight > 0 && T.scrollHeight > T.clientHeight;
2311
+ let $ = L && D.offsetX > T.clientWidth;
2312
+ if (L && Ee(T).direction === "rtl" && ($ = D.offsetX <= T.offsetWidth - T.clientWidth), $ || F && D.offsetY > T.clientHeight)
2313
+ return;
2314
+ }
2315
+ const Ie = (E = i.current.floatingContext) == null ? void 0 : E.nodeId, he = h && rt(h.nodesRef.current, Ie).some((F) => {
2316
+ var L;
2317
+ return Zt(D, (L = F.context) == null ? void 0 : L.elements.floating);
2318
+ });
2319
+ if (Zt(D, o.floating) || Zt(D, o.domReference) || he)
2320
+ return;
2321
+ const j = h ? rt(h.nodesRef.current, Ie) : [];
2322
+ if (j.length > 0) {
2323
+ let F = !0;
2324
+ if (j.forEach((L) => {
2325
+ var $;
2326
+ if (($ = L.context) != null && $.open && !L.context.dataRef.current.__outsidePressBubbles) {
2327
+ F = !1;
2328
+ return;
2329
+ }
2330
+ }), !F)
2331
+ return;
2332
+ }
2333
+ r(!1, D, "outside-press");
2334
+ }), W = Oe((D) => {
2335
+ var E;
2336
+ const A = () => {
2337
+ var M;
2338
+ H(D), (M = Ye(D)) == null || M.removeEventListener(a, A);
2339
+ };
2340
+ (E = Ye(D)) == null || E.addEventListener(a, A);
2341
+ });
2342
+ y.useEffect(() => {
2343
+ if (!n || !s)
2344
+ return;
2345
+ i.current.__escapeKeyBubbles = C, i.current.__outsidePressBubbles = S;
2346
+ function D(M) {
2347
+ r(!1, M, "ancestor-scroll");
2348
+ }
2349
+ const E = xe(o.floating);
2350
+ c && E.addEventListener("keydown", k ? U : B, k), x && E.addEventListener(a, _ ? W : H, _);
2351
+ let A = [];
2352
+ return d && (J(o.domReference) && (A = $e(o.domReference)), J(o.floating) && (A = A.concat($e(o.floating))), !J(o.reference) && o.reference && o.reference.contextElement && (A = A.concat($e(o.reference.contextElement)))), A = A.filter((M) => {
2353
+ var T;
2354
+ return M !== ((T = E.defaultView) == null ? void 0 : T.visualViewport);
2355
+ }), A.forEach((M) => {
2356
+ M.addEventListener("scroll", D, {
2357
+ passive: !0
2358
+ });
2359
+ }), () => {
2360
+ c && E.removeEventListener("keydown", k ? U : B, k), x && E.removeEventListener(a, _ ? W : H, _), A.forEach((M) => {
2361
+ M.removeEventListener("scroll", D);
2362
+ });
2363
+ };
2364
+ }, [i, o, c, x, a, n, r, d, s, C, S, B, k, U, H, _, W]), y.useEffect(() => {
2365
+ w.current = !1;
2366
+ }, [x, a]);
2367
+ const O = y.useMemo(() => ({
2368
+ onKeyDown: B,
2369
+ [Ts[u]]: (D) => {
2370
+ m && r(!1, D.nativeEvent, "reference-press");
2371
+ }
2372
+ }), [B, r, m, u]), N = y.useMemo(() => ({
2373
+ onKeyDown: B,
2374
+ onMouseDown() {
2375
+ g.current = !0;
2376
+ },
2377
+ onMouseUp() {
2378
+ g.current = !0;
2379
+ },
2380
+ [As[a]]: () => {
2381
+ w.current = !0;
2382
+ }
2383
+ }), [B, a]);
2384
+ return y.useMemo(() => s ? {
2385
+ reference: O,
2386
+ floating: N
2387
+ } : {}, [s, O, N]);
2388
+ }
2389
+ function Ns(e) {
2390
+ const {
2391
+ open: t = !1,
2392
+ onOpenChange: n,
2393
+ elements: r
2394
+ } = e, o = kn(), i = y.useRef({}), [s] = y.useState(() => ds()), c = Nn() != null;
2395
+ if (process.env.NODE_ENV !== "production") {
2396
+ const f = r.reference;
2397
+ f && !J(f) && fs("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
2398
+ }
2399
+ const [l, a] = y.useState(r.reference), m = Oe((f, p, h) => {
2400
+ i.current.openEvent = f ? p : void 0, s.emit("openchange", {
2401
+ open: f,
2402
+ event: p,
2403
+ reason: h,
2404
+ nested: c
2405
+ }), n == null || n(f, p, h);
2406
+ }), u = y.useMemo(() => ({
2407
+ setPositionReference: a
2408
+ }), []), d = y.useMemo(() => ({
2409
+ reference: l || r.reference || null,
2410
+ floating: r.floating || null,
2411
+ domReference: r.reference
2412
+ }), [l, r.reference, r.floating]);
2413
+ return y.useMemo(() => ({
2414
+ dataRef: i,
2415
+ open: t,
2416
+ onOpenChange: m,
2417
+ elements: d,
2418
+ events: s,
2419
+ floatingId: o,
2420
+ refs: u
2421
+ }), [t, m, d, s, o, u]);
2422
+ }
2423
+ function Ds(e) {
2424
+ e === void 0 && (e = {});
2425
+ const {
2426
+ nodeId: t
2427
+ } = e, n = Ns({
2428
+ ...e,
2429
+ elements: {
2430
+ reference: null,
2431
+ floating: null,
2432
+ ...e.elements
2433
+ }
2434
+ }), r = e.rootContext || n, o = r.elements, [i, s] = y.useState(null), [c, l] = y.useState(null), m = (o == null ? void 0 : o.reference) || i, u = y.useRef(null), d = Ht();
2435
+ te(() => {
2436
+ m && (u.current = m);
2437
+ }, [m]);
2438
+ const f = Ji({
2439
+ ...e,
2440
+ elements: {
2441
+ ...o,
2442
+ ...c && {
2443
+ reference: c
2444
+ }
2445
+ }
2446
+ }), p = y.useCallback((g) => {
2447
+ const C = J(g) ? {
2448
+ getBoundingClientRect: () => g.getBoundingClientRect(),
2449
+ contextElement: g
2450
+ } : g;
2451
+ l(C), f.refs.setReference(C);
2452
+ }, [f.refs]), h = y.useCallback((g) => {
2453
+ (J(g) || g === null) && (u.current = g, s(g)), (J(f.refs.reference.current) || f.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
2454
+ // `null` to support `positionReference` + an unstable `reference`
2455
+ // callback ref.
2456
+ g !== null && !J(g)) && f.refs.setReference(g);
2457
+ }, [f.refs]), b = y.useMemo(() => ({
2458
+ ...f.refs,
2459
+ setReference: h,
2460
+ setPositionReference: p,
2461
+ domReference: u
2462
+ }), [f.refs, h, p]), x = y.useMemo(() => ({
2463
+ ...f.elements,
2464
+ domReference: m
2465
+ }), [f.elements, m]), w = y.useMemo(() => ({
2466
+ ...f,
2467
+ ...r,
2468
+ refs: b,
2469
+ elements: x,
2470
+ nodeId: t
2471
+ }), [f, b, x, t, r]);
2472
+ return te(() => {
2473
+ r.dataRef.current.floatingContext = w;
2474
+ const g = d == null ? void 0 : d.nodesRef.current.find((C) => C.id === t);
2475
+ g && (g.context = w);
2476
+ }), y.useMemo(() => ({
2477
+ ...f,
2478
+ context: w,
2479
+ refs: b,
2480
+ elements: x
2481
+ }), [f, b, x, w]);
2482
+ }
2483
+ const ur = "active", fr = "selected";
2484
+ function on(e, t, n) {
2485
+ const r = /* @__PURE__ */ new Map(), o = n === "item";
2486
+ let i = e;
2487
+ if (o && e) {
2488
+ const {
2489
+ [ur]: s,
2490
+ [fr]: c,
2491
+ ...l
2492
+ } = e;
2493
+ i = l;
2494
+ }
2495
+ return {
2496
+ ...n === "floating" && {
2497
+ tabIndex: -1,
2498
+ [yn]: ""
2499
+ },
2500
+ ...i,
2501
+ ...t.map((s) => {
2502
+ const c = s ? s[n] : null;
2503
+ return typeof c == "function" ? e ? c(e) : null : c;
2504
+ }).concat(e).reduce((s, c) => (c && Object.entries(c).forEach((l) => {
2505
+ let [a, m] = l;
2506
+ if (!(o && [ur, fr].includes(a)))
2507
+ if (a.indexOf("on") === 0) {
2508
+ if (r.has(a) || r.set(a, []), typeof m == "function") {
2509
+ var u;
2510
+ (u = r.get(a)) == null || u.push(m), s[a] = function() {
2511
+ for (var d, f = arguments.length, p = new Array(f), h = 0; h < f; h++)
2512
+ p[h] = arguments[h];
2513
+ return (d = r.get(a)) == null ? void 0 : d.map((b) => b(...p)).find((b) => b !== void 0);
2514
+ };
2515
+ }
2516
+ } else
2517
+ s[a] = m;
2518
+ }), s), {})
2519
+ };
2520
+ }
2521
+ function Ps(e) {
2522
+ e === void 0 && (e = []);
2523
+ const t = e.map((c) => c == null ? void 0 : c.reference), n = e.map((c) => c == null ? void 0 : c.floating), r = e.map((c) => c == null ? void 0 : c.item), o = y.useCallback(
2524
+ (c) => on(c, e, "reference"),
2525
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2526
+ t
2527
+ ), i = y.useCallback(
2528
+ (c) => on(c, e, "floating"),
2529
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2530
+ n
2531
+ ), s = y.useCallback(
2532
+ (c) => on(c, e, "item"),
2533
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2534
+ r
2535
+ );
2536
+ return y.useMemo(() => ({
2537
+ getReferenceProps: o,
2538
+ getFloatingProps: i,
2539
+ getItemProps: s
2540
+ }), [o, i, s]);
2541
+ }
2542
+ let dr = !1;
2543
+ function qt(e, t, n) {
2544
+ switch (e) {
2545
+ case "vertical":
2546
+ return t;
2547
+ case "horizontal":
2548
+ return n;
2549
+ default:
2550
+ return t || n;
2551
+ }
2552
+ }
2553
+ function mr(e, t) {
2554
+ return qt(t, e === An || e === Ct, e === st || e === dt);
2555
+ }
2556
+ function sn(e, t, n) {
2557
+ return qt(t, e === Ct, n ? e === st : e === dt) || e === "Enter" || e === " " || e === "";
2558
+ }
2559
+ function Ls(e, t, n) {
2560
+ return qt(t, n ? e === st : e === dt, e === Ct);
2561
+ }
2562
+ function pr(e, t, n) {
2563
+ return qt(t, n ? e === dt : e === st, e === An);
2564
+ }
2565
+ function Fs(e, t) {
2566
+ const {
2567
+ open: n,
2568
+ onOpenChange: r,
2569
+ elements: o
2570
+ } = e, {
2571
+ listRef: i,
2572
+ activeIndex: s,
2573
+ onNavigate: c = () => {
2574
+ },
2575
+ enabled: l = !0,
2576
+ selectedIndex: a = null,
2577
+ allowEscape: m = !1,
2578
+ loop: u = !1,
2579
+ nested: d = !1,
2580
+ rtl: f = !1,
2581
+ virtual: p = !1,
2582
+ focusItemOnOpen: h = "auto",
2583
+ focusItemOnHover: b = !0,
2584
+ openOnArrowKeyDown: x = !0,
2585
+ disabledIndices: w = void 0,
2586
+ orientation: g = "vertical",
2587
+ cols: C = 1,
2588
+ scrollItemIntoView: S = !0,
2589
+ virtualItemRef: k,
2590
+ itemSizes: _,
2591
+ dense: B = !1
2592
+ } = t;
2593
+ process.env.NODE_ENV !== "production" && (m && (u || tn("`useListNavigation` looping must be enabled to allow escaping."), p || tn("`useListNavigation` must be virtual to allow escaping.")), g === "vertical" && C > 1 && tn("In grid list navigation mode (`cols` > 1), the `orientation` should", 'be either "horizontal" or "both".'));
2594
+ const U = eo(o.floating), H = Be(U), W = Nn(), O = Ht(), N = Oe(c), D = y.useRef(h), E = y.useRef(a ?? -1), A = y.useRef(null), M = y.useRef(!0), T = y.useRef(N), I = y.useRef(!!o.floating), X = y.useRef(n), se = y.useRef(!1), Ie = y.useRef(!1), he = Be(w), j = Be(n), F = Be(S), L = Be(a), [$, G] = y.useState(), [ne, ce] = y.useState(), Z = Oe(function(V, z, R) {
2595
+ R === void 0 && (R = !1);
2596
+ function Y(q) {
2597
+ p ? (G(q.id), O == null || O.events.emit("virtualfocus", q), k && (k.current = q)) : _e(q, {
2598
+ preventScroll: !0,
2599
+ // Mac Safari does not move the virtual cursor unless the focus call
2600
+ // is sync. However, for the very first focus call, we need to wait
2601
+ // for the position to be ready in order to prevent unwanted
2602
+ // scrolling. This means the virtual cursor will not move to the first
2603
+ // item when first opening the floating element, but will on
2604
+ // subsequent calls. `preventScroll` is supported in modern Safari,
2605
+ // so we can use that instead.
2606
+ // iOS Safari must be async or the first item will not be focused.
2607
+ sync: Go() && Or() ? dr || se.current : !1
2608
+ });
2609
+ }
2610
+ const ue = V.current[z.current];
2611
+ ue && Y(ue), requestAnimationFrame(() => {
2612
+ const q = V.current[z.current] || ue;
2613
+ if (!q) return;
2614
+ ue || Y(q);
2615
+ const ve = F.current;
2616
+ ve && Te && (R || !M.current) && (q.scrollIntoView == null || q.scrollIntoView(typeof ve == "boolean" ? {
2617
+ block: "nearest",
2618
+ inline: "nearest"
2619
+ } : ve));
2620
+ });
2621
+ });
2622
+ te(() => {
2623
+ document.createElement("div").focus({
2624
+ get preventScroll() {
2625
+ return dr = !0, !1;
2626
+ }
2627
+ });
2628
+ }, []), te(() => {
2629
+ l && (n && o.floating ? D.current && a != null && (Ie.current = !0, E.current = a, N(a)) : I.current && (E.current = -1, T.current(null)));
2630
+ }, [l, n, o.floating, a, N]), te(() => {
2631
+ if (l && n && o.floating)
2632
+ if (s == null) {
2633
+ if (se.current = !1, L.current != null)
2634
+ return;
2635
+ if (I.current && (E.current = -1, Z(i, E)), (!X.current || !I.current) && D.current && (A.current != null || D.current === !0 && A.current == null)) {
2636
+ let V = 0;
2637
+ const z = () => {
2638
+ i.current[0] == null ? (V < 2 && (V ? requestAnimationFrame : queueMicrotask)(z), V++) : (E.current = A.current == null || sn(A.current, g, f) || d ? en(i, he.current) : er(i, he.current), A.current = null, N(E.current));
2639
+ };
2640
+ z();
2641
+ }
2642
+ } else bt(i, s) || (E.current = s, Z(i, E, Ie.current), Ie.current = !1);
2643
+ }, [l, n, o.floating, s, L, d, i, g, f, N, Z, he]), te(() => {
2644
+ var V;
2645
+ if (!l || o.floating || !O || p || !I.current)
2646
+ return;
2647
+ const z = O.nodesRef.current, R = (V = z.find((q) => q.id === W)) == null || (V = V.context) == null ? void 0 : V.elements.floating, Y = Le(xe(o.floating)), ue = z.some((q) => q.context && pe(q.context.elements.floating, Y));
2648
+ R && !ue && M.current && R.focus({
2649
+ preventScroll: !0
2650
+ });
2651
+ }, [l, o.floating, O, W, p]), te(() => {
2652
+ if (!l || !O || !p || W) return;
2653
+ function V(z) {
2654
+ ce(z.id), k && (k.current = z);
2655
+ }
2656
+ return O.events.on("virtualfocus", V), () => {
2657
+ O.events.off("virtualfocus", V);
2658
+ };
2659
+ }, [l, O, p, W, k]), te(() => {
2660
+ T.current = N, I.current = !!o.floating;
2661
+ }), te(() => {
2662
+ n || (A.current = null);
2663
+ }, [n]), te(() => {
2664
+ X.current = n;
2665
+ }, [n]);
2666
+ const De = s != null, Te = y.useMemo(() => {
2667
+ function V(R) {
2668
+ if (!n) return;
2669
+ const Y = i.current.indexOf(R);
2670
+ Y !== -1 && N(Y);
2671
+ }
2672
+ return {
2673
+ onFocus(R) {
2674
+ let {
2675
+ currentTarget: Y
2676
+ } = R;
2677
+ V(Y);
2678
+ },
2679
+ onClick: (R) => {
2680
+ let {
2681
+ currentTarget: Y
2682
+ } = R;
2683
+ return Y.focus({
2684
+ preventScroll: !0
2685
+ });
2686
+ },
2687
+ // Safari
2688
+ ...b && {
2689
+ onMouseMove(R) {
2690
+ let {
2691
+ currentTarget: Y
2692
+ } = R;
2693
+ V(Y);
2694
+ },
2695
+ onPointerLeave(R) {
2696
+ let {
2697
+ pointerType: Y
2698
+ } = R;
2699
+ !M.current || Y === "touch" || (E.current = -1, Z(i, E), N(null), p || _e(H.current, {
2700
+ preventScroll: !0
2701
+ }));
2702
+ }
2703
+ }
2704
+ };
2705
+ }, [n, H, Z, b, i, N, p]), ee = Oe((V) => {
2706
+ if (M.current = !1, se.current = !0, !j.current && V.currentTarget === H.current)
2707
+ return;
2708
+ if (d && pr(V.key, g, f)) {
2709
+ be(V), r(!1, V.nativeEvent, "list-navigation"), re(o.domReference) && !p && o.domReference.focus();
2710
+ return;
2711
+ }
2712
+ const z = E.current, R = en(i, w), Y = er(i, w);
2713
+ if (V.key === "Home" && (be(V), E.current = R, N(E.current)), V.key === "End" && (be(V), E.current = Y, N(E.current)), C > 1) {
2714
+ const ue = _ || Array.from({
2715
+ length: i.current.length
2716
+ }, () => ({
2717
+ width: 1,
2718
+ height: 1
2719
+ })), q = is(ue, C, B), ve = q.findIndex((de) => de != null && !Nt(i.current, de, w)), qe = q.reduce((de, Se, Rt) => Se != null && !Nt(i.current, Se, w) ? Rt : de, -1), fe = q[os({
2720
+ current: q.map((de) => de != null ? i.current[de] : null)
2721
+ }, {
2722
+ event: V,
2723
+ orientation: g,
2724
+ loop: u,
2725
+ cols: C,
2726
+ // treat undefined (empty grid spaces) as disabled indices so we
2727
+ // don't end up in them
2728
+ disabledIndices: cs([...w || i.current.map((de, Se) => Nt(i.current, Se) ? Se : void 0), void 0], q),
2729
+ minIndex: ve,
2730
+ maxIndex: qe,
2731
+ prevIndex: ss(
2732
+ E.current > Y ? R : E.current,
2733
+ ue,
2734
+ q,
2735
+ C,
2736
+ // use a corner matching the edge closest to the direction
2737
+ // we're moving in so we don't end up in the same item. Prefer
2738
+ // top/left over bottom/right.
2739
+ V.key === Ct ? "bl" : V.key === dt ? "tr" : "tl"
2740
+ ),
2741
+ stopEvent: !0
2742
+ })];
2743
+ if (fe != null && (E.current = fe, N(E.current)), g === "both")
2744
+ return;
2745
+ }
2746
+ if (mr(V.key, g)) {
2747
+ if (be(V), n && !p && Le(V.currentTarget.ownerDocument) === V.currentTarget) {
2748
+ E.current = sn(V.key, g, f) ? R : Y, N(E.current);
2749
+ return;
2750
+ }
2751
+ sn(V.key, g, f) ? u ? E.current = z >= Y ? m && z !== i.current.length ? -1 : R : me(i, {
2752
+ startingIndex: z,
2753
+ disabledIndices: w
2754
+ }) : E.current = Math.min(Y, me(i, {
2755
+ startingIndex: z,
2756
+ disabledIndices: w
2757
+ })) : u ? E.current = z <= R ? m && z !== -1 ? i.current.length : Y : me(i, {
2758
+ startingIndex: z,
2759
+ decrement: !0,
2760
+ disabledIndices: w
2761
+ }) : E.current = Math.max(R, me(i, {
2762
+ startingIndex: z,
2763
+ decrement: !0,
2764
+ disabledIndices: w
2765
+ })), bt(i, E.current) ? N(null) : N(E.current);
2766
+ }
2767
+ }), Pe = y.useMemo(() => p && n && De && {
2768
+ "aria-activedescendant": ne || $
2769
+ }, [p, n, De, ne, $]), ge = y.useMemo(() => ({
2770
+ "aria-orientation": g === "both" ? void 0 : g,
2771
+ ...!Tr(o.domReference) && Pe,
2772
+ onKeyDown: ee,
2773
+ onPointerMove() {
2774
+ M.current = !0;
2775
+ }
2776
+ }), [Pe, ee, o.domReference, g]), He = y.useMemo(() => {
2777
+ function V(R) {
2778
+ h === "auto" && Ir(R.nativeEvent) && (D.current = !0);
2779
+ }
2780
+ function z(R) {
2781
+ D.current = h, h === "auto" && Sr(R.nativeEvent) && (D.current = !0);
2782
+ }
2783
+ return {
2784
+ ...Pe,
2785
+ onKeyDown(R) {
2786
+ M.current = !1;
2787
+ const Y = R.key.indexOf("Arrow") === 0, ue = Ls(R.key, g, f), q = pr(R.key, g, f), ve = mr(R.key, g), qe = (d ? ue : ve) || R.key === "Enter" || R.key.trim() === "";
2788
+ if (p && n) {
2789
+ const Rt = O == null ? void 0 : O.nodesRef.current.find((It) => It.parentId == null), Me = O && Rt ? hs(O.nodesRef.current, Rt.id) : null;
2790
+ if (Y && Me && k) {
2791
+ const It = new KeyboardEvent("keydown", {
2792
+ key: R.key,
2793
+ bubbles: !0
2794
+ });
2795
+ if (ue || q) {
2796
+ var fe, de;
2797
+ const ko = ((fe = Me.context) == null ? void 0 : fe.elements.domReference) === R.currentTarget, Wn = q && !ko ? (de = Me.context) == null ? void 0 : de.elements.domReference : ue ? i.current.find((Hn) => (Hn == null ? void 0 : Hn.id) === $) : null;
2798
+ Wn && (be(R), Wn.dispatchEvent(It), ce(void 0));
2799
+ }
2800
+ if (ve && Me.context && Me.context.open && Me.parentId && R.currentTarget !== Me.context.elements.domReference) {
2801
+ var Se;
2802
+ be(R), (Se = Me.context.elements.domReference) == null || Se.dispatchEvent(It);
2803
+ return;
2804
+ }
2805
+ }
2806
+ return ee(R);
2807
+ }
2808
+ if (!(!n && !x && Y)) {
2809
+ if (qe && (A.current = d && ve ? null : R.key), d) {
2810
+ ue && (be(R), n ? (E.current = en(i, he.current), N(E.current)) : r(!0, R.nativeEvent, "list-navigation"));
2811
+ return;
2812
+ }
2813
+ ve && (a != null && (E.current = a), be(R), !n && x ? r(!0, R.nativeEvent, "list-navigation") : ee(R), n && N(E.current));
2814
+ }
2815
+ },
2816
+ onFocus() {
2817
+ n && !p && N(null);
2818
+ },
2819
+ onPointerDown: z,
2820
+ onMouseDown: V,
2821
+ onClick: V
2822
+ };
2823
+ }, [$, Pe, ee, he, h, i, d, N, r, n, x, g, f, a, O, p, k]);
2824
+ return y.useMemo(() => l ? {
2825
+ reference: He,
2826
+ floating: ge,
2827
+ item: Te
2828
+ } : {}, [l, He, ge, Te]);
2829
+ }
2830
+ const Ms = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
2831
+ function _s(e, t) {
2832
+ var n;
2833
+ t === void 0 && (t = {});
2834
+ const {
2835
+ open: r,
2836
+ floatingId: o
2837
+ } = e, {
2838
+ enabled: i = !0,
2839
+ role: s = "dialog"
2840
+ } = t, c = (n = Ms.get(s)) != null ? n : s, l = kn(), m = Nn() != null, u = y.useMemo(() => c === "tooltip" || s === "label" ? {
2841
+ ["aria-" + (s === "label" ? "labelledby" : "describedby")]: r ? o : void 0
2842
+ } : {
2843
+ "aria-expanded": r ? "true" : "false",
2844
+ "aria-haspopup": c === "alertdialog" ? "dialog" : c,
2845
+ "aria-controls": r ? o : void 0,
2846
+ ...c === "listbox" && {
2847
+ role: "combobox"
2848
+ },
2849
+ ...c === "menu" && {
2850
+ id: l
2851
+ },
2852
+ ...c === "menu" && m && {
2853
+ role: "menuitem"
2854
+ },
2855
+ ...s === "select" && {
2856
+ "aria-autocomplete": "none"
2857
+ },
2858
+ ...s === "combobox" && {
2859
+ "aria-autocomplete": "list"
2860
+ }
2861
+ }, [c, o, m, r, l, s]), d = y.useMemo(() => {
2862
+ const p = {
2863
+ id: o,
2864
+ ...c && {
2865
+ role: c
2866
+ }
2867
+ };
2868
+ return c === "tooltip" || s === "label" ? p : {
2869
+ ...p,
2870
+ ...c === "menu" && {
2871
+ "aria-labelledby": l
2872
+ }
2873
+ };
2874
+ }, [c, o, l, s]), f = y.useCallback((p) => {
2875
+ let {
2876
+ active: h,
2877
+ selected: b
2878
+ } = p;
2879
+ const x = {
2880
+ role: "option",
2881
+ ...h && {
2882
+ id: o + "-option"
2883
+ }
2884
+ };
2885
+ switch (s) {
2886
+ case "select":
2887
+ return {
2888
+ ...x,
2889
+ "aria-selected": h && b
2890
+ };
2891
+ case "combobox":
2892
+ return {
2893
+ ...x,
2894
+ ...h && {
2895
+ "aria-selected": !0
2896
+ }
2897
+ };
2898
+ }
2899
+ return {};
2900
+ }, [o, s]);
2901
+ return y.useMemo(() => i ? {
2902
+ reference: u,
2903
+ floating: d,
2904
+ item: f
2905
+ } : {}, [i, u, d, f]);
2906
+ }
2907
+ const Bs = typeof window < "u" ? Cn : ie;
2908
+ function vn(e) {
2909
+ const t = oe(null);
2910
+ return Bs(() => {
2911
+ const n = document.getAnimations().filter((i) => "animationName" in i && i.animationName === e), r = n.find((i) => "animationName" in i && i.animationName === e), o = n.find((i) => {
2912
+ var s;
2913
+ return ((s = i.effect) == null ? void 0 : s.target) === t.current;
2914
+ });
2915
+ return o && o === r && (o.currentTime = 0), o && (r != null && r.currentTime) && o !== r && (o.currentTime = r.currentTime), () => {
2916
+ o && (r != null && r.currentTime) && (o.currentTime = r.currentTime);
2917
+ };
2918
+ }, [e]), t;
2919
+ }
2920
+ const to = P(function({ "aria-label": t, className: n, ...r }, o) {
2921
+ const i = vn("ds-spinner-rotate-animation"), s = vn("ds-spinner-stroke-animation"), c = Re([i, o]);
2922
+ return le("svg", { "aria-label": t, className: K("ds-spinner", n), ref: c, role: "img", viewBox: "0 0 50 50", ...r, children: [v("circle", { className: K("ds-spinner__background"), cx: "25", cy: "25", r: "20", fill: "none", strokeWidth: "5" }), v("circle", { className: K("ds-spinner__circle"), cx: "25", cy: "25", r: "20", fill: "none", strokeWidth: "5", ref: s })] });
2923
+ }), mt = P(function({ asChild: t, className: n, children: r, icon: o = !1, loading: i = !1, variant: s = "primary", ...c }, l) {
2924
+ return le(t ? Q : "button", {
2925
+ "aria-busy": !!i || void 0,
2926
+ "aria-disabled": !!i || void 0,
2927
+ className: K("ds-button", n),
2928
+ "data-icon": o || void 0,
2929
+ "data-variant": s,
2930
+ ref: l,
2931
+ /* don't set type when we use `asChild` */
2932
+ type: t ? void 0 : "button",
2933
+ ...c,
2934
+ children: [i === !0 ? v(to, { "aria-hidden": "true" }) : i, v(En, { children: r })]
2935
+ });
2936
+ }), $s = P(function({ className: t, count: n, maxCount: r, variant: o = "base", ...i }, s) {
2937
+ return v("span", { className: K("ds-badge", t), "data-count": n && r && n > r ? `${r}+` : n, "data-variant": o, ref: s, ...i });
2938
+ }), Vs = P(function({ className: t, overlap: n = "rectangle", placement: r = "top-right", ...o }, i) {
2939
+ return v("span", { className: K("ds-badge--position", t), "data-overlap": n, "data-placement": r, ref: i, ...o });
2940
+ }), zs = Object.assign($s, { Position: Vs });
2941
+ zs.Position.displayName = "Badge.Position";
2942
+ const js = P(({ asChild: e, className: t, ...n }, r) => v(e ? Q : "a", { className: K("ds-link", t), ref: r, ...n }));
2943
+ js.displayName = "Link";
2944
+ const Xc = P(function({ asChild: t, className: n, height: r, style: o, variant: i = "rectangle", width: s, ...c }, l) {
2945
+ const a = t ? Q : "span", m = i === "text", u = vn("ds-skeleton-opacity-fade"), d = Re([u, l]);
2946
+ return v(a, { "aria-hidden": "true", className: K("ds-skeleton", n), "data-text": m ? "-".repeat(Number(s) || 1) : void 0, "data-variant": i, ref: d, style: m ? o : { width: s, height: r, ...o }, ...c });
2947
+ }), Gc = P(function({ asChild: t, ...n }, r) {
2948
+ return v(t ? Q : "li", { ...n, ref: r });
2949
+ }), no = (e, { asChild: t, className: n, ...r }, o) => v(t ? Q : e, { className: K("ds-list", n), ref: o, ...r }), Zc = P(function(t, n) {
2950
+ return no("ul", t, n);
2951
+ });
2952
+ P(function(t, n) {
2953
+ return no("ol", t, n);
2954
+ });
2955
+ const Ze = P(function({ className: t, weight: n = "medium", asChild: r, ...o }, i) {
2956
+ return v(r ? Q : "label", { ref: i, className: K("ds-label", t), "data-weight": n, ...o });
2957
+ }), Jc = P(function({ level: t = 2, className: n, asChild: r, ...o }, i) {
2958
+ const s = r ? Q : `h${t}`;
2959
+ return v(s, { className: K("ds-heading", n), ref: i, ...o });
2960
+ }), zt = P(function({ className: t, asChild: n, variant: r = "default", ...o }, i) {
2961
+ return v(n ? Q : "p", { ref: i, className: K("ds-paragraph", t), "data-variant": r, ...o });
2962
+ }), Pn = P(function({ className: t, asChild: n, ...r }, o) {
2963
+ return v(n ? Q : "p", { className: K("ds-validation-message", t), "data-field": "validation", ref: o, ...r });
2964
+ });
2965
+ var ro = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", br;
2966
+ ro && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
2967
+ /^Mac/i.test(((br = navigator.userAgentData) == null ? void 0 : br.platform) || navigator.platform);
2968
+ var Ks = ":host(:not([hidden])) { display: block }", oo = typeof HTMLElement > "u" ? class {
2969
+ } : HTMLElement;
2970
+ function Xe(e, t, n) {
2971
+ var r;
2972
+ return n === void 0 ? (r = e.getAttribute(t)) != null ? r : null : (n === null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n), null);
2973
+ }
2974
+ var io = (e, t, n) => {
2975
+ for (const r of n[0].split(","))
2976
+ n[0] = r, Element.prototype[`${e}EventListener`].apply(t, n);
2977
+ }, hr = (e, ...t) => io("add", e, t), gr = (e, ...t) => io("remove", e, t), Ws = (e) => {
2978
+ const t = "key" in e && (e.key === " " || e.key === "Enter");
2979
+ return t && e.preventDefault(), t && e.target instanceof HTMLElement && e.target.click(), t;
2980
+ }, Hs = (e) => {
2981
+ var t;
2982
+ const n = ((t = e.getRootNode) == null ? void 0 : t.call(e)) || e.ownerDocument;
2983
+ return n instanceof Document || n instanceof ShadowRoot ? n : document;
2984
+ }, cn = (e, t, n) => {
2985
+ const r = document.createElement(e);
2986
+ if (t && (r.textContent = t), n) for (const [o, i] of Object.entries(n)) Xe(r, o, i);
2987
+ return r;
2988
+ }, so = {
2989
+ define: (e, t) => !ro || window.customElements.get(e) || window.customElements.define(e, t)
2990
+ }, qs = class extends oo {
2991
+ constructor() {
2992
+ super(), this._content = null, this.attachShadow({ mode: "open" }).append(
2993
+ cn("slot", null, { name: "summary" }),
2994
+ cn("slot", null, { part: "details-content" }),
2995
+ cn(
2996
+ "style",
2997
+ `${Ks}
2998
+ ::slotted(u-summary) { cursor: pointer; display: block }
2999
+ ::slotted(u-summary)::before { content: ''; display: inline-block; vertical-align: middle; margin-inline: .05em .3125em; border-block: .3125em solid transparent; border-inline-start: .5em solid }
3000
+ ::slotted(u-summary[aria-expanded="true"])::before { rotate: 90deg }
3001
+ :host > [part="details-content"]:not([hidden=""]) { display: block }`
3002
+ )
3003
+ );
3004
+ }
3005
+ // Using ES2015 syntax for backwards compatibility
3006
+ static get observedAttributes() {
3007
+ return ["open"];
3008
+ }
3009
+ connectedCallback() {
3010
+ var e;
3011
+ this._content = (e = this.shadowRoot) == null ? void 0 : e.children[1], hr(this._content, "beforematch", this), hr(this, "click,keydown", this), this.attributeChangedCallback();
3012
+ }
3013
+ disconnectedCallback() {
3014
+ this._content && gr(this._content, "beforematch", this), gr(this, "click,keydown", this), this._content = null;
3015
+ }
3016
+ attributeChangedCallback(e, t, n) {
3017
+ const r = "onbeforematch" in this ? "until-found" : !0, o = this.open;
3018
+ for (const i of this.children)
3019
+ i.nodeName === "U-SUMMARY" && Xe(i, "aria-expanded", `${o}`);
3020
+ if (this._content && (Xe(this._content, "aria-hidden", `${!o}`), this._content.hidden = o ? !1 : r), o && this.name) {
3021
+ const i = Hs(this).querySelectorAll(
3022
+ `${this.nodeName}[name="${this.name}"]`
3023
+ );
3024
+ for (const s of i)
3025
+ s !== this && (s.open = !1);
3026
+ }
3027
+ e === "open" && t === null != (n === null) && this.dispatchEvent(new Event("toggle"));
3028
+ }
3029
+ handleEvent(e) {
3030
+ const t = this.querySelector(":scope > u-summary"), n = t == null ? void 0 : t.contains(e.target);
3031
+ e.defaultPrevented || (e.type === "beforematch" && (this.open = !0), n && e.type === "keydown" && Ws(e), n && e.type === "click" && (this.open = !this.open));
3032
+ }
3033
+ get open() {
3034
+ return this.hasAttribute("open");
3035
+ }
3036
+ set open(e) {
3037
+ Xe(this, "open", e ? "" : null);
3038
+ }
3039
+ get name() {
3040
+ return Xe(this, "name") || "";
3041
+ }
3042
+ set name(e) {
3043
+ Xe(this, "name", e);
3044
+ }
3045
+ }, Us = class extends oo {
3046
+ connectedCallback() {
3047
+ Xe(this, "role", "button"), this.slot = "summary", this.tabIndex = 0;
3048
+ }
3049
+ };
3050
+ so.define("u-details", qs);
3051
+ so.define("u-summary", Us);
3052
+ const Ys = P(function({ className: t, open: n, defaultOpen: r = !1, variant: o = "default", onToggle: i, ...s }, c) {
3053
+ const l = oe(null), a = oe(r), m = Re([l, c]), u = oe(i), d = oe(n);
3054
+ return u.current = i, d.current = n, ie(() => {
3055
+ const f = l.current, p = (h) => {
3056
+ var b;
3057
+ !f || (f == null ? void 0 : f.open) === d.current || ((b = u.current) == null || b.call(u, h), d.current !== void 0 && (f.open = d.current));
3058
+ };
3059
+ return f == null || f.addEventListener("toggle", p, !0), () => f == null ? void 0 : f.removeEventListener("toggle", p, !0);
3060
+ }, []), v("u-details", { class: K("ds-details", t), open: (n ?? a.current) || void 0, "data-variant": o, ref: m, ...s });
3061
+ }), Xs = P(function(t, n) {
3062
+ return v("div", { ref: n, ...t });
3063
+ }), Gs = P(function({ className: t, ...n }, r) {
3064
+ return v("u-summary", { ref: r, class: t, ...n });
3065
+ }), co = Object.assign(Ys, {
3066
+ Summary: Gs,
3067
+ Content: Xs
3068
+ });
3069
+ co.Summary.displayName = "Details.Summary";
3070
+ co.Content.displayName = "Details.Content";
3071
+ const Qc = P(function({ "data-color": t = "info", className: n, ...r }, o) {
3072
+ return v("div", { className: K("ds-alert", n), "data-color": t, ref: o, ...r });
3073
+ }), Ln = P(function({ type: t = "text", className: n, onChange: r, onClick: o, ...i }, s) {
3074
+ return v("input", { className: K("ds-input", n), ref: s, type: t, onChange: (c) => i.readOnly || (r == null ? void 0 : r(c)), onClick: (c) => {
3075
+ i.readOnly && c.preventDefault(), o == null || o(c);
3076
+ }, ...i });
3077
+ }), ao = P(function({ asChild: t, className: n, ...r }, o) {
3078
+ return v(t ? Q : "button", { className: K("ds-chip", n), type: t ? void 0 : "button", ref: o, ...r });
3079
+ }), lo = P(function(t, n) {
3080
+ return v(ao, { "data-removable": !0, ref: n, ...t });
3081
+ }), uo = P(function({ asChild: t, children: n, className: r, "data-size": o, "data-color": i, ...s }, c) {
3082
+ const l = s.type ?? "checkbox";
3083
+ return le(t ? Q : "label", { className: K("ds-chip", r), "data-size": o, "data-color": i, ref: c, children: [v(Ln, { ...s, type: l }), v(En, { children: n })] });
3084
+ }), Zs = P(function(t, n) {
3085
+ return v(uo, { ref: n, type: "radio", ...t });
3086
+ }), Ut = {
3087
+ Button: ao,
3088
+ Checkbox: uo,
3089
+ Radio: Zs,
3090
+ Removable: lo
3091
+ };
3092
+ Ut.Button.displayName = "Chip.Button";
3093
+ Ut.Checkbox.displayName = "Chip.Checkbox";
3094
+ Ut.Radio.displayName = "Chip.Radio";
3095
+ Ut.Removable.displayName = "Chip.Removable";
3096
+ const Js = P(function({ "aria-label": t = "Sidenavigering", asChild: n, className: r, ...o }, i) {
3097
+ return v(n ? Q : "nav", { "aria-label": t, className: K("ds-pagination", r), ref: i, ...o });
3098
+ }), Qs = P(function(t, n) {
3099
+ return v(mt, { ref: n, ...t });
3100
+ }), ec = P(function({ asChild: t, className: n, ...r }, o) {
3101
+ return v(t ? Q : "li", { ref: o, ...r });
3102
+ }), tc = P(function({ asChild: t, ...n }, r) {
3103
+ return v(t ? Q : "ul", { ref: r, ...n });
3104
+ }), Fn = Object.assign(Js, {
3105
+ List: tc,
3106
+ Item: ec,
3107
+ Button: Qs
3108
+ });
3109
+ Fn.List.displayName = "Pagination.List";
3110
+ Fn.Item.displayName = "Pagination.Item";
3111
+ Fn.Button.displayName = "Pagination.Button";
3112
+ function nc(e) {
3113
+ if (!e)
3114
+ return;
3115
+ const t = /* @__PURE__ */ new Map(), n = `:${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
3116
+ let r = null, o = "";
3117
+ const i = (c) => {
3118
+ const l = [], a = [];
3119
+ for (const d of c)
3120
+ d.attributeName && l.push(d.target ?? e), l.push(...d.addedNodes || []), a.push(...d.removedNodes || []);
3121
+ for (const d of l)
3122
+ yr(d) && (an(d) ? t.set(d, d.htmlFor) : d.hasAttribute("data-field") ? t.set(d, d.id) : xn(d) && (r = d, o = d.getAttribute("aria-describedby") || ""));
3123
+ for (const d of a)
3124
+ yr(d) && (r === d && (r = null), t.has(d) && (At(d, an(d) ? "for" : "id", t.get(d)), t.delete(d)));
3125
+ const m = [o], u = (r == null ? void 0 : r.id) || n;
3126
+ for (const [d, f] of t) {
3127
+ const p = d.getAttribute("data-field"), h = p ? `${u}:${p}` : u;
3128
+ f || At(d, an(d) ? "for" : "id", h), p === "validation" ? m.unshift(d.id) : p && m.push(d.id);
3129
+ }
3130
+ At(r, "id", u), At(r, "aria-describedby", m.join(" ").trim());
3131
+ }, s = rc(i);
3132
+ return s.observe(e, {
3133
+ attributeFilter: ["id", "for", "aria-describedby"],
3134
+ attributes: !0,
3135
+ childList: !0,
3136
+ subtree: !0
3137
+ }), i([{ addedNodes: e.querySelectorAll("*") }]), s.takeRecords(), () => s.disconnect();
3138
+ }
3139
+ const yr = (e) => e instanceof Element, an = (e) => e instanceof HTMLLabelElement, xn = (e) => e instanceof HTMLElement && "validity" in e && !(e instanceof HTMLButtonElement), At = (e, t, n) => n ? e == null ? void 0 : e.setAttribute(t, n) : e == null ? void 0 : e.removeAttribute(t);
3140
+ function rc(e) {
3141
+ const t = [], n = new MutationObserver((o) => {
3142
+ t.length || requestAnimationFrame(r), t.push(...o);
3143
+ }), r = () => {
3144
+ e(t, n), t.length = 0, n.takeRecords();
3145
+ };
3146
+ return n;
3147
+ }
3148
+ const oc = P(function({ className: t, position: n, ...r }, o) {
3149
+ const i = oe(null), s = Re([i, o]);
3150
+ return ie(() => nc(i.current), []), v("div", { className: K("ds-field", t), "data-position": n, ref: s, ...r });
3151
+ }), ic = P(function({ className: t, ...n }, r) {
3152
+ return v("div", { className: K("ds-field-affixes", t), ref: r, ...n });
3153
+ }), sc = P(function({ className: t, ...n }, r) {
3154
+ return v("span", { className: K("ds-field-affix", t), "aria-hidden": "true", ref: r, ...n });
3155
+ }), ln = (e, t) => e.replace("%d", Math.abs(t).toString()), cc = P(function({ limit: t, under: n = "%d tegn igjen", over: r = "%d tegn for mye", ...o }, i) {
3156
+ const [s, c] = ke(0), l = oe(null), a = s > t, m = t - s;
3157
+ return ie(() => {
3158
+ var p;
3159
+ const u = (p = l.current) == null ? void 0 : p.closest(".ds-field"), d = Array.from((u == null ? void 0 : u.getElementsByTagName("*")) || []).find(xn), f = ({ target: h }) => {
3160
+ xn(h) && c(h.value.length);
3161
+ };
3162
+ return d && f({ target: d }), u == null || u.addEventListener("input", f), () => u == null ? void 0 : u.removeEventListener("input", f);
3163
+ }, [c]), le(ut, { children: [v("div", { "data-field": "description", className: "ds-sr-only", "aria-live": "polite", ref: l, children: a && ln(r, m) }), a ? v(Pn, { ref: i, ...o, children: ln(r, m) }) : v(zt, { ref: i, ...o, "data-field": "validation", children: ln(n, m) })] });
3164
+ }), ac = P(function(t, n) {
3165
+ return v("div", { "data-field": "description", ref: n, ...t });
3166
+ }), Et = Object.assign(oc, {
3167
+ Description: ac,
3168
+ Affixes: ic,
3169
+ Affix: sc,
3170
+ Counter: cc
3171
+ });
3172
+ Et.Description.displayName = "Field.Description";
3173
+ Et.Affixes.displayName = "Field.Affixes";
3174
+ Et.Affix.displayName = "Field.Affix";
3175
+ Et.Counter.displayName = "Field.Counter";
3176
+ const ea = P(function({ "data-size": t, className: n, style: r, children: o, label: i, description: s, error: c, ...l }, a) {
3177
+ return le(Et, { "data-size": t, className: n, style: r, children: [v(Ln, { type: "checkbox", ref: a, ...l }), !!i && v(Ze, { weight: "regular", children: i }), !!s && v("div", { "data-field": "description", children: s }), !!c && v(Pn, { children: c })] });
3178
+ }), Yt = je({}), lc = P(function({ value: t, defaultValue: n, className: r, onChange: o, ...i }, s) {
3179
+ const c = t !== void 0, [l, a] = ke(n);
3180
+ let m = o;
3181
+ return c || (m = (u) => {
3182
+ a(u), o == null || o(u);
3183
+ }, t = l), v(Yt.Provider, { value: {
3184
+ value: t,
3185
+ defaultValue: n,
3186
+ onChange: m
3187
+ }, children: v("div", { className: K("ds-tabs", r), ref: s, ...i }) });
3188
+ }), fo = je({
3189
+ elements: { current: /* @__PURE__ */ new Map() },
3190
+ getOrderedItems: () => [],
3191
+ setFocusableValue: () => {
3192
+ },
3193
+ onShiftTab: () => {
3194
+ },
3195
+ focusableValue: null,
3196
+ orientation: "horizontal"
3197
+ }), uc = P(({ activeValue: e, asChild: t, orientation: n = "horizontal", onBlur: r, onFocus: o, ...i }, s) => {
3198
+ const c = t ? Q : "div", [l, a] = ke(null), [m, u] = ke(!1), d = oe(/* @__PURE__ */ new Map()), f = oe(null), p = Re([s, f]), h = () => {
3199
+ if (!f.current)
3200
+ return [];
3201
+ const b = Array.from(f.current.querySelectorAll("[data-roving-tabindex-item]"));
3202
+ return Array.from(d.current).sort((x, w) => b.indexOf(x[1]) - b.indexOf(w[1])).map(([x, w]) => ({ value: x, element: w }));
3203
+ };
3204
+ return ie(() => {
3205
+ a(e ?? null);
3206
+ }, [e]), v(fo.Provider, { value: {
3207
+ elements: d,
3208
+ getOrderedItems: h,
3209
+ focusableValue: l,
3210
+ setFocusableValue: a,
3211
+ onShiftTab: () => {
3212
+ u(!0);
3213
+ },
3214
+ orientation: n
3215
+ }, children: v(c, { ...i, tabIndex: m ? -1 : 0, onBlur: (b) => {
3216
+ r == null || r(b), u(!1), a(e ?? null);
3217
+ }, onFocus: (b) => {
3218
+ var w, g, C;
3219
+ if (o == null || o(b), b.target !== b.currentTarget)
3220
+ return;
3221
+ const x = h();
3222
+ x.length !== 0 && (l != null ? (w = d.current.get(l)) == null || w.focus() : e != null ? (g = d.current.get(e)) == null || g.focus() : (C = x.at(0)) == null || C.element.focus());
3223
+ }, ref: p }) });
3224
+ }), fc = P(function({ children: t, ...n }, r) {
3225
+ const { value: o } = ae(Yt);
3226
+ return v(uc, { role: "tablist", activeValue: o, orientation: "ambiguous", ref: r, ...n, children: t });
3227
+ }), dc = P(function({ children: t, value: n, ...r }, o) {
3228
+ const { value: i } = ae(Yt), s = n === i, [c, l] = ke(!1), a = oe(null), m = Re([o, a]);
3229
+ return ie(() => {
3230
+ if (!a.current)
3231
+ return;
3232
+ const u = a.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
3233
+ l(u.length > 0);
3234
+ }, [t]), v(ut, { children: s && v("div", { ref: m, role: "tabpanel", tabIndex: c ? void 0 : 0, ...r, children: t }) });
3235
+ }), mc = (e) => {
3236
+ const { elements: t, getOrderedItems: n, setFocusableValue: r, focusableValue: o, onShiftTab: i, orientation: s } = ae(fo);
3237
+ return {
3238
+ getOrderedItems: n,
3239
+ isFocusable: o === e,
3240
+ orientation: s,
3241
+ getRovingProps: (c) => ({
3242
+ ...c,
3243
+ ref: (l) => {
3244
+ l ? t.current.set(e, l) : t.current.delete(e);
3245
+ },
3246
+ onKeyDown: (l) => {
3247
+ var a;
3248
+ if ((a = c == null ? void 0 : c.onKeyDown) == null || a.call(c, l), l.shiftKey && l.key === "Tab") {
3249
+ i();
3250
+ return;
3251
+ }
3252
+ },
3253
+ onFocus: (l) => {
3254
+ var a;
3255
+ (a = c == null ? void 0 : c.onFocus) == null || a.call(c, l), r(e);
3256
+ },
3257
+ "data-roving-tabindex-item": !0,
3258
+ tabIndex: o === e ? 0 : -1
3259
+ })
3260
+ };
3261
+ };
3262
+ function un(e, t) {
3263
+ const n = e.findIndex((r) => r.value === t);
3264
+ return e.at(n === e.length - 1 ? 0 : n + 1);
3265
+ }
3266
+ function fn(e, t) {
3267
+ const n = e.findIndex((r) => r.value === t);
3268
+ return e.at(n === 0 ? -1 : n - 1);
3269
+ }
3270
+ const pc = P(({ value: e, asChild: t, ...n }, r) => {
3271
+ const o = t ? Q : "div", i = e ?? (typeof n.children == "string" ? n.children : ""), { getOrderedItems: s, getRovingProps: c, orientation: l } = mc(i), a = c({
3272
+ onKeyDown: (u) => {
3273
+ var p;
3274
+ (p = n == null ? void 0 : n.onKeyDown) == null || p.call(n, u);
3275
+ const d = s();
3276
+ let f;
3277
+ switch (l) {
3278
+ case "horizontal":
3279
+ u.key === "ArrowRight" && (f = un(d, i)), u.key === "ArrowLeft" && (f = fn(d, i));
3280
+ break;
3281
+ case "vertical":
3282
+ u.key === "ArrowDown" && (f = un(d, i)), u.key === "ArrowUp" && (f = fn(d, i));
3283
+ break;
3284
+ case "ambiguous":
3285
+ ["ArrowRight", "ArrowDown"].includes(u.key) && (f = un(d, i)), ["ArrowLeft", "ArrowUp"].includes(u.key) && (f = fn(d, i));
3286
+ }
3287
+ u.key === "Home" && (f = d[0]), u.key === "End" && (f = d[d.length - 1]), f && (u.preventDefault(), f.element.focus());
3288
+ }
3289
+ }), m = Re([r, a.ref]);
3290
+ return v(o, { ...n, ...a, ref: m, children: n.children });
3291
+ }), bc = P(function({ value: t, id: n, ...r }, o) {
3292
+ const i = ae(Yt), s = n ?? `tab-${ft()}`;
3293
+ return v(pc, { value: t, ...r, asChild: !0, children: v("button", { ...r, "aria-selected": i.value === t, id: s, onClick: () => {
3294
+ var c;
3295
+ return (c = i.onChange) == null ? void 0 : c.call(i, t);
3296
+ }, ref: o, role: "tab", type: "button" }) });
3297
+ }), Mn = Object.assign(lc, {
3298
+ List: fc,
3299
+ Tab: bc,
3300
+ Panel: dc
3301
+ });
3302
+ Mn.Tab.displayName = "Tabs.Tab";
3303
+ Mn.List.displayName = "Tabs.List";
3304
+ Mn.Panel.displayName = "Tabs.Panel";
3305
+ const mo = ({ children: e }) => {
3306
+ const t = ft(), [n, r] = ke(t);
3307
+ return v(_n.Provider, { value: { popoverId: n, setPopoverId: r }, children: e });
3308
+ };
3309
+ mo.displayName = "PopoverTriggerContext";
3310
+ const _n = je({}), hc = P(function({ id: t, className: n, onClose: r, onOpen: o, open: i, variant: s = "default", placement: c = "top", autoPlacement: l = !0, asChild: a = !1, ...m }, u) {
3311
+ const d = a ? Q : "div", f = oe(null), p = Re([f, u]), { popoverId: h, setPopoverId: b } = ae(_n), [x, w] = ke(!1), g = i ?? x;
3312
+ return ie(() => {
3313
+ var _;
3314
+ const C = f.current, S = (B) => {
3315
+ var O;
3316
+ const U = B.target, H = (O = U == null ? void 0 : U.closest) == null ? void 0 : O.call(U, `[popovertarget="${C == null ? void 0 : C.id}"]`), W = !H && !(C != null && C.contains(U));
3317
+ H && (B.preventDefault(), w((N) => !N), o == null || o()), W && (w(!1), r == null || r());
3318
+ }, k = (B) => {
3319
+ B.key !== "Escape" || !g || (B.preventDefault(), w(!1), r == null || r());
3320
+ };
3321
+ return (_ = C == null ? void 0 : C.togglePopover) == null || _.call(C, g), document.addEventListener("click", S, !0), document.addEventListener("keydown", k), () => {
3322
+ document.removeEventListener("click", S, !0), document.removeEventListener("keydown", k);
3323
+ };
3324
+ }, [g]), ie(() => {
3325
+ const C = f.current, S = document.querySelector(`[popovertarget="${C == null ? void 0 : C.id}"]`);
3326
+ if (C && S && g)
3327
+ return jr(S, C, () => {
3328
+ Hr(S, C, {
3329
+ placement: c,
3330
+ strategy: "fixed",
3331
+ middleware: [
3332
+ Kr((k) => {
3333
+ const _ = getComputedStyle(k.elements.floating, "::before");
3334
+ return parseFloat(_.height);
3335
+ }),
3336
+ ...l ? [Wr({ fallbackAxisSideDirection: "start" }), Gi()] : [],
3337
+ gc
3338
+ ]
3339
+ }).then(({ x: k, y: _ }) => {
3340
+ C.style.translate = `${k}px ${_}px`;
3341
+ });
3342
+ });
3343
+ }, [g, c, t, l]), ie(() => {
3344
+ t && (b == null || b(t));
3345
+ }, [t]), v(d, {
3346
+ className: K("ds-popover", n),
3347
+ id: t || h,
3348
+ // @ts-ignore @types/react-dom does not understand popover yet
3349
+ popover: "manual",
3350
+ "data-variant": s,
3351
+ ref: p,
3352
+ ...m
3353
+ });
3354
+ }), gc = {
3355
+ name: "ArrowPseudoElement",
3356
+ fn(e) {
3357
+ const { elements: t, rects: n, placement: r } = e;
3358
+ let o = `${Math.round(n.reference.width / 2 + n.reference.x - e.x)}px`, i = `${Math.round(n.reference.height / 2 + n.reference.y - e.y)}px`;
3359
+ switch (n.reference.width > n.floating.width && (o = `${Math.round(n.floating.width / 2)}px`), n.reference.height > n.floating.height && (i = `${Math.round(n.floating.height / 2)}px`), r.split("-")[0]) {
3360
+ case "top":
3361
+ i = "100%";
3362
+ break;
3363
+ case "right":
3364
+ o = "0";
3365
+ break;
3366
+ case "bottom":
3367
+ i = "0";
3368
+ break;
3369
+ case "left":
3370
+ o = "100%";
3371
+ break;
3372
+ }
3373
+ return t.floating.setAttribute("data-placement", r.split("-")[0]), t.floating.style.setProperty("--ds-popover-arrow-x", o), t.floating.style.setProperty("--ds-popover-arrow-y", i), e;
3374
+ }
3375
+ }, yc = P(function({ id: t, inline: n, asChild: r, ...o }, i) {
3376
+ const { popoverId: s } = ae(_n), c = r ? Q : n ? "button" : mt, l = Object.assign({
3377
+ [No.startsWith("19") ? "popoverTarget" : "popovertarget"]: s,
3378
+ ...n ? {
3379
+ "data-popover": "inline"
3380
+ } : {}
3381
+ }, o);
3382
+ return v(c, { ref: i, ...l });
3383
+ }), po = Object.assign(hc, {
3384
+ TriggerContext: mo,
3385
+ Trigger: yc
3386
+ });
3387
+ po.TriggerContext.displayName = "Popover.TriggerContext";
3388
+ po.Trigger.displayName = "Popover.Trigger";
3389
+ const Bn = je({
3390
+ current: null
3391
+ }), bo = ({ children: e }) => {
3392
+ const t = oe(null);
3393
+ return v(Bn.Provider, { value: t, children: e });
3394
+ };
3395
+ bo.displayName = "DialogTriggerContext";
3396
+ const vc = P(function({ asChild: t, children: n, className: r, closeButton: o = "Lukk dialogvindu", closedby: i = "closerequest", modal: s = !0, onClose: c, open: l, ...a }, m) {
3397
+ const u = ae(Bn), d = oe(null), f = t ? Q : "dialog", p = Re([u, m, d]), h = s ? "showModal" : "show";
3398
+ return ie(() => {
3399
+ var b;
3400
+ return (b = d.current) == null ? void 0 : b[l ? h : "close"]();
3401
+ }, [l]), ie(() => {
3402
+ const b = d.current, x = (g) => {
3403
+ var _;
3404
+ const { clientY: C, clientX: S, target: k } = g;
3405
+ if (g instanceof KeyboardEvent)
3406
+ return i === "none" && g.key === "Escape" && g.preventDefault();
3407
+ if (!((_ = window.getSelection()) != null && _.toString()) && b && k === b && i === "any") {
3408
+ const { top: B, left: U, right: H, bottom: W } = b.getBoundingClientRect();
3409
+ B <= C && C <= W && U <= S && S <= H || b == null || b.close();
3410
+ }
3411
+ }, w = () => {
3412
+ const g = b == null ? void 0 : b.querySelector("[autofocus]");
3413
+ document.activeElement !== g && (g == null || g.focus());
3414
+ };
3415
+ return b == null || b.addEventListener("animationend", w), b == null || b.addEventListener("click", x), b == null || b.addEventListener("keydown", x), () => {
3416
+ b == null || b.removeEventListener("animationend", w), b == null || b.removeEventListener("click", x), b == null || b.removeEventListener("keydown", x);
3417
+ };
3418
+ }, [i]), ie(() => {
3419
+ var x;
3420
+ const b = (w) => c == null ? void 0 : c(w);
3421
+ return (x = d.current) == null || x.addEventListener("close", b), () => {
3422
+ var w;
3423
+ return (w = d.current) == null ? void 0 : w.removeEventListener("close", b);
3424
+ };
3425
+ }, [c]), le(f, { className: K("ds-dialog", r), ref: p, "data-modal": s, ...a, children: [o !== !1 && v("form", { method: "dialog", children: v(mt, { "aria-label": o, autoFocus: !0, "data-color": "neutral", icon: !0, name: "close", type: "submit", variant: "tertiary" }) }), n] });
3426
+ }), xc = P(function({ asChild: t, className: n, ...r }, o) {
3427
+ return v(t ? Q : "div", { className: K("ds-dialog__block", n), ref: o, ...r });
3428
+ }), wc = P(function({ asChild: t, ...n }, r) {
3429
+ const o = ae(Bn);
3430
+ return v(t ? Q : mt, { "aria-haspopup": "dialog", onClick: () => {
3431
+ var c, l, a;
3432
+ ((c = o.current) == null ? void 0 : c.getAttribute("data-modal")) === "true" ? (l = o.current) == null || l.showModal() : (a = o.current) == null || a.show();
3433
+ }, ref: r, ...n });
3434
+ }), $n = Object.assign(vc, {
3435
+ Block: xc,
3436
+ TriggerContext: bo,
3437
+ Trigger: wc
3438
+ });
3439
+ $n.Block.displayName = "Dialog.Block";
3440
+ $n.TriggerContext.displayName = "Dialog.TriggerContext";
3441
+ $n.Trigger.displayName = "Dialog.Trigger";
3442
+ const We = je(void 0), ho = je({
3443
+ activeIndex: 0
3444
+ }), Cc = (e, t) => {
3445
+ switch (t.type) {
3446
+ case "SET_ACTIVE_INDEX":
3447
+ return {
3448
+ ...e,
3449
+ activeIndex: t.payload
3450
+ };
3451
+ default:
3452
+ return e;
3453
+ }
3454
+ }, go = je(() => {
3455
+ throw new Error("ComboboxIdDispatch must be used within a provider");
3456
+ }), Ec = ({ children: e }) => {
3457
+ const [t, n] = Do(Cc, {
3458
+ activeIndex: 0
3459
+ });
3460
+ return v(ho.Provider, { value: t, children: v(go.Provider, { value: n, children: e }) });
3461
+ };
3462
+ function Vn() {
3463
+ return ae(go);
3464
+ }
3465
+ function Xt() {
3466
+ return ae(ho);
3467
+ }
3468
+ const lt = (e, t) => {
3469
+ const n = {}, r = {};
3470
+ let o = 0;
3471
+ const i = e.length;
3472
+ for (; o < i; )
3473
+ r[e[o]] = 1, o += 1;
3474
+ for (const s in t)
3475
+ Object.prototype.hasOwnProperty.call(r, s) || (n[s] = t[s]);
3476
+ return n;
3477
+ }, yo = P(({ asChild: e, interactive: t, id: n, className: r, ...o }, i) => {
3478
+ if (t && !n)
3479
+ throw new Error("If ComboboxCustom is interactive, it must have an id");
3480
+ const s = e ? Q : "div", c = ft(), { activeIndex: l } = Xt(), a = ae(We);
3481
+ if (!a)
3482
+ throw new Error("ComboboxCustom must be used within a Combobox");
3483
+ const { customIds: m, setListRef: u, getItemProps: d, size: f } = a, p = Ge(() => n && m.indexOf(n) || 0, [n, m]), h = Re([
3484
+ (b) => {
3485
+ u(p, b);
3486
+ },
3487
+ i
3488
+ ]);
3489
+ return v(Ze, { "data-size": f, asChild: !0, children: v(s, { ref: h, tabIndex: -1, className: K("ds-combobox__custom", r), id: n || c, role: "option", "aria-selected": l === p, "data-active": l === p, ...lt(["interactive"], o), ...lt(["onClick", "onPointerLeave"], d()) }) });
3490
+ });
3491
+ function Rc(e) {
3492
+ return vr(e) && e.type === yo;
3493
+ }
3494
+ function Ic(e) {
3495
+ return Rc(e) && e.props.interactive === !0;
3496
+ }
3497
+ const vo = "internal-option-", ye = (e) => vo + e, wn = (e) => e.slice(vo.length), pt = (e, t) => {
3498
+ const n = e.value;
3499
+ e.value = t;
3500
+ const r = e._valueTracker;
3501
+ typeof r < "u" && r.setValue(n), e.dispatchEvent(new Event("change", { bubbles: !0 }));
3502
+ }, Sc = P(function({ "aria-label": t = "Tøm", onClick: n, ...r }, o) {
3503
+ return v(mt, { ref: o, variant: "tertiary", type: "reset", "aria-label": t, onClick: (s) => {
3504
+ var a;
3505
+ const c = s.target;
3506
+ let l = null;
3507
+ if (c instanceof HTMLElement && (l = (a = c.closest(".ds-search")) == null ? void 0 : a.querySelector("input")), !l)
3508
+ throw new Error("Input is missing");
3509
+ if (!(l instanceof HTMLInputElement))
3510
+ throw new Error("Input is not an input element");
3511
+ s.preventDefault(), pt(l, ""), l.focus(), n == null || n(s);
3512
+ }, icon: !0, ...r });
3513
+ }), Oc = P(function({ children: t = "Søk", ...n }, r) {
3514
+ return v(mt, { ref: r, type: "submit", ...n, children: t });
3515
+ }), Tc = P(function({ ...t }, n) {
3516
+ return v(Ln, {
3517
+ ref: n,
3518
+ type: "search",
3519
+ /* We need an empty placeholder for the clear button to be able to show/hide */
3520
+ placeholder: "",
3521
+ ...t
3522
+ });
3523
+ }), Ac = P(function({ className: t, ...n }, r) {
3524
+ return v("div", { ref: r, className: K("ds-search", t), ...n });
3525
+ }), zn = Object.assign(Ac, {
3526
+ Clear: Sc,
3527
+ Button: Oc,
3528
+ Input: Tc
3529
+ });
3530
+ zn.Clear.displayName = "Search.Clear";
3531
+ zn.Button.displayName = "Search.Button";
3532
+ zn.Input.displayName = "Search.Input";
3533
+ const kc = je(null), Nc = (e, t) => {
3534
+ const n = ae(kc), r = ft(), o = e.id ?? `${t}-${r}`, i = e.errorId ?? `${t}-error-${r}`, s = `${t}-description-${r}`, c = e.size ?? (n == null ? void 0 : n.size) ?? "md", l = (n == null ? void 0 : n.disabled) || (e == null ? void 0 : e.disabled), a = !l && !!(e.error || n != null && n.error);
3535
+ return {
3536
+ hasError: a,
3537
+ errorId: i,
3538
+ descriptionId: s,
3539
+ size: c,
3540
+ inputProps: {
3541
+ id: o,
3542
+ disabled: l,
3543
+ "aria-invalid": a ? !0 : void 0,
3544
+ "aria-describedby": K(e["aria-describedby"], !!(e != null && e.description) && typeof (e == null ? void 0 : e.description) == "string" && s, a && !(n != null && n.error) && i, a && !!(n != null && n.error) && (n == null ? void 0 : n.errorId)) || void 0
3545
+ }
3546
+ };
3547
+ }, xo = ({ size: e, error: t, formFieldProps: n }) => v("div", { className: "ds-combobox__error-message", id: n.errorId, "aria-live": "polite", "aria-relevant": "additions removals", children: t && v(Pn, { "data-size": e, children: t }) });
3548
+ xo.displayName = "ComboboxError";
3549
+ const wo = () => {
3550
+ const e = ae(We);
3551
+ if (!e)
3552
+ throw new Error("ComboboxContext is missing");
3553
+ const { size: t, readOnly: n, disabled: r, selectedOptions: o, chipSrLabel: i, handleSelectOption: s, inputRef: c } = e;
3554
+ return v(ut, { children: Object.keys(o).map((l) => v(lo, { "data-size": t, disabled: r, onKeyDown: (a) => {
3555
+ var m;
3556
+ n || r || a.key === "Enter" && (a.stopPropagation(), s({
3557
+ option: o[l],
3558
+ remove: !0
3559
+ }), (m = c == null ? void 0 : c.current) == null || m.focus());
3560
+ }, onClick: () => {
3561
+ n || r || s({
3562
+ option: o[l],
3563
+ remove: !0
3564
+ });
3565
+ }, "aria-label": i(o[l]), children: o[l].label }, l)) });
3566
+ };
3567
+ wo.displayName = "ComboboxChips";
3568
+ const Co = P((e, t) => {
3569
+ const n = ae(We);
3570
+ if (!n)
3571
+ throw new Error("ComboboxContext is missing");
3572
+ const { readOnly: r, disabled: o, clearButtonLabel: i, handleSelectOption: s } = n;
3573
+ return v("button", { ...e, ref: t, disabled: o, className: K("ds-combobox__clear-button", "ds-focus"), onClick: () => {
3574
+ r || o || s({ option: null, clear: !0 });
3575
+ }, onKeyDown: (c) => {
3576
+ r || o || c.key === "Enter" && (c.stopPropagation(), s({ option: null, clear: !0 }));
3577
+ }, type: "button", "aria-label": i, children: v(_o, { fontSize: "1.5em", title: "Clear selection" }) });
3578
+ });
3579
+ Co.displayName = "ComboboxClearButton";
3580
+ const Eo = ({ hideClearButton: e, listId: t, error: n, hideChips: r, handleKeyDown: o, ...i }) => {
3581
+ const s = ae(We), c = Vn(), l = oe(null);
3582
+ if (!s)
3583
+ throw new Error("ComboboxContext is missing");
3584
+ const a = (E) => {
3585
+ c == null || c({ type: "SET_ACTIVE_INDEX", payload: E });
3586
+ }, { forwareddRef: m, readOnly: u, disabled: d, open: f, inputRef: p, refs: h, inputValue: b, multiple: x, selectedOptions: w, formFieldProps: g, htmlSize: C, options: S, setOpen: k, getReferenceProps: _, setInputValue: B, handleSelectOption: U, size: H } = s, W = Re([m, p]), O = (E) => {
3587
+ const A = E.target.value;
3588
+ B(A), a(0);
3589
+ for (const M of Object.values(S))
3590
+ if (M.label.toLowerCase() === A.toLowerCase()) {
3591
+ if (w[ye(M.value)])
3592
+ continue;
3593
+ U({ option: M });
3594
+ }
3595
+ }, N = !e && Object.keys(w).length > 0, D = _({
3596
+ ref: h == null ? void 0 : h.setReference,
3597
+ role: null,
3598
+ "aria-controls": null,
3599
+ "aria-expanded": null,
3600
+ "aria-haspopup": null,
3601
+ /* If we click the wrapper, toggle open, set index to first option, and focus the input */
3602
+ onClick(E) {
3603
+ var A, M;
3604
+ d || u || (A = l.current) != null && A.contains(E.target) || (k(!f), a(0), (M = p.current) == null || M.focus());
3605
+ },
3606
+ /* Handles list navigation */
3607
+ onKeyDown: o,
3608
+ // preventDefault on keydown to avoid sending in form
3609
+ onKeyPress(E) {
3610
+ E.key === "Enter" && E.preventDefault();
3611
+ }
3612
+ });
3613
+ return v(zt, { "data-size": H, asChild: !0, children: le("div", { ...D, "aria-disabled": d ? "true" : void 0, className: K("ds-textfield__input", "ds-combobox__input__wrapper", u && "ds-combobox--readonly", n && "ds-combobox--error"), children: [le("div", { className: "ds-combobox__chip-and-input", children: [x && !r && v(wo, {}), v(zt, { "data-size": H, asChild: !0, children: v("input", { ref: W, "aria-activedescendant": D["aria-activedescendant"], readOnly: u, "aria-autocomplete": "list", role: "combobox", "aria-expanded": f, "aria-controls": f ? t : void 0, autoComplete: "off", size: C, value: b, ...lt(["style", "className"], i), ...g.inputProps, className: "ds-combobox__input", onChange: (E) => {
3614
+ var A;
3615
+ O(E), !f && k(!0), (A = i.onChange) == null || A.call(i, E);
3616
+ } }) })] }), N && v(Co, { ref: l }), v("div", { className: "ds-combobox__arrow", children: f ? v(Bo, { title: "arrow up", fontSize: "1.5em" }) : v($o, { title: "arrow down", fontSize: "1.5em" }) })] }) });
3617
+ };
3618
+ Eo.displayName = "ComboboxInput";
3619
+ const Ro = ({ label: e, description: t, hideLabel: n, size: r, readOnly: o, formFieldProps: i }) => le(ut, { children: [e && le(Ze, { "data-size": r, htmlFor: i.inputProps.id, className: K("ds-combobox__label", n && "ds-sr-only"), children: [o && v(Ko, { "aria-hidden": !0, className: "ds-combobox__readonly__icon" }), e] }), t && v(zt, { asChild: !0, "data-size": r, children: v("div", { id: i.descriptionId, className: K("ds-combobox__description", n && "ds-sr-only"), children: t }) })] });
3620
+ Ro.displayName = "ComboboxLabel";
3621
+ const Io = ({ selectedOptions: e, multiple: t, name: n }) => {
3622
+ const r = Object.keys(e).map((o) => wn(o));
3623
+ return v("select", { name: n, multiple: t, style: { display: "none" }, value: t ? r : r[0], onChange: () => {
3624
+ }, children: r.map((o) => v("option", { value: o }, o)) });
3625
+ };
3626
+ Io.displayName = "ComboboxNative";
3627
+ const So = P(({ children: e, className: t, ...n }, r) => v("span", { className: K("ds-combobox__option__description", t), ref: r, ...n, children: e }));
3628
+ So.displayName = "ComboboxOptionDescription";
3629
+ const Oo = ({ multiple: e, selected: t }) => v("div", { className: K(e && "ds-combobox__option__icon-wrapper", t && "ds-combobox__option__icon-wrapper--selected"), children: t && v(zo, { className: "ds-combobox__option__icon-wrapper__icon", "aria-hidden": !0 }) });
3630
+ Oo.displayName = "SelectedIcon";
3631
+ function jn(e, t = 50) {
3632
+ const n = oe(null);
3633
+ return ie(() => () => {
3634
+ n.current && clearTimeout(n.current);
3635
+ }, []), (...o) => {
3636
+ n.current && clearTimeout(n.current), n.current = window.setTimeout(() => {
3637
+ e(...o);
3638
+ }, t);
3639
+ };
3640
+ }
3641
+ const Dc = ({ id: e, ref: t, value: n }) => {
3642
+ const r = ft(), o = e || r, i = ae(We), { activeIndex: s } = Xt(), c = Vn();
3643
+ if (!i)
3644
+ throw new Error("ComboboxOption must be used within a Combobox");
3645
+ const { selectedOptions: l, onOptionClick: a, setListRef: m, customIds: u, filteredOptions: d } = i, f = Ge(() => d.indexOf(ye(String(n))) + u.length, [u.length, d, n]), p = Re([
3646
+ (w) => {
3647
+ m(f, w);
3648
+ },
3649
+ t
3650
+ ]);
3651
+ if (f === -1)
3652
+ throw new Error("Internal error: ComboboxOption did not find index");
3653
+ const h = l[ye(n)], b = s === f;
3654
+ ie(() => {
3655
+ b && (c == null || c({ type: "SET_ACTIVE_INDEX", payload: f }));
3656
+ }, [r, e, c, b, f]);
3657
+ const x = jn(() => a(n), 50);
3658
+ return {
3659
+ id: o,
3660
+ ref: p,
3661
+ selected: h,
3662
+ active: b,
3663
+ onOptionClick: x
3664
+ };
3665
+ }, Kn = Po(P(({ value: e, description: t, children: n, className: r, ...o }, i) => {
3666
+ const s = ft(), { id: c, ref: l, selected: a, active: m, onOptionClick: u } = Dc({
3667
+ id: o.id,
3668
+ ref: i,
3669
+ value: e
3670
+ }), d = ae(We);
3671
+ if (!d)
3672
+ throw new Error("ComboboxOption must be used within a Combobox");
3673
+ const { size: f, multiple: p, getItemProps: h } = d, b = h();
3674
+ return v(Ze, { "data-size": "md", asChild: !0, children: le("button", {
3675
+ ref: l,
3676
+ id: c,
3677
+ // biome-ignore lint/a11y/useSemanticElements: biome wants me to use the <option> element
3678
+ role: "option",
3679
+ type: "button",
3680
+ "aria-selected": !!a,
3681
+ "aria-labelledby": s,
3682
+ tabIndex: -1,
3683
+ onClick: (x) => {
3684
+ var w;
3685
+ u(), (w = o.onClick) == null || w.call(o, x);
3686
+ },
3687
+ className: K("ds-combobox__option", m && "ds-combobox__option--active", p && "ds-combobox__option--multiple", r),
3688
+ ...lt(["displayValue"], o),
3689
+ ...lt(["onClick", "onPointerLeave"], b),
3690
+ children: [v(Ze, { asChild: !0, "data-size": f, children: v("span", { children: v(Oo, { multiple: p, selected: !!a }) }) }), le(Ze, { className: "ds-combobox__option__label", "data-size": f, id: s, children: [n, t && v(So, { children: t })] })]
3691
+ }) });
3692
+ }));
3693
+ Kn.displayName = "ComboboxOption";
3694
+ function Pc(e) {
3695
+ return vr(e) && e.type === Kn;
3696
+ }
3697
+ const Lc = (e) => !!e;
3698
+ function Fc({ children: e, inputValue: t, multiple: n, filter: r = (i, s) => s.label.toLowerCase().startsWith(i.toLowerCase()), initialValue: o }) {
3699
+ const i = Lo(r, [r]), { optionsChildren: s, customIds: c, restChildren: l, interactiveChildren: a } = Ge(() => qn.toArray(e).reduce((w, g) => {
3700
+ if (Pc(g))
3701
+ w.optionsChildren.push(g);
3702
+ else if (w.restChildren.push(g), Ic(g)) {
3703
+ const C = g;
3704
+ if (w.interactiveChildren.push(C), !C.props.id)
3705
+ throw new Error("If ComboboxCustom is interactive, it must have an id");
3706
+ w.customIds.push(C.props.id);
3707
+ }
3708
+ return w;
3709
+ }, {
3710
+ optionsChildren: [],
3711
+ customIds: [],
3712
+ restChildren: [],
3713
+ interactiveChildren: []
3714
+ }), [e]), m = Ge(() => {
3715
+ const b = [], x = {};
3716
+ return s.map((w) => {
3717
+ const g = w.props;
3718
+ let C = g.displayValue || "";
3719
+ if (!g.displayValue) {
3720
+ let S = "";
3721
+ qn.forEach(g.children, (k) => {
3722
+ if (typeof k == "string")
3723
+ S += k;
3724
+ else
3725
+ throw new Error("If ComboboxOption is not a string, it must have a displayValue prop");
3726
+ }), C = S;
3727
+ }
3728
+ b.includes(g.value) && console.warn(`Combobox has multiple options with the same value: ${g.value}`), b.push(g.value), x[ye(String(g.value))] = {
3729
+ value: String(g.value),
3730
+ label: C,
3731
+ displayValue: g.displayValue,
3732
+ description: g.description
3733
+ };
3734
+ }), x;
3735
+ }, [s]), u = Ge(() => ((o == null ? void 0 : o.map((b) => ye(b))) || []).reduce((b, x) => {
3736
+ const w = m[x];
3737
+ return Lc(w) && (b[x] = w), b;
3738
+ }, {}), [o, m]), [d, f] = ke(u), { filteredOptions: p, filteredOptionsChildren: h } = Ge(() => {
3739
+ const b = [], x = Object.keys(m).map((w, g) => {
3740
+ if (!n && Object.keys(d).length === 1 || n && d[w] || i(t, m[w]))
3741
+ return b.push(w), s[g];
3742
+ }).filter((w) => w);
3743
+ return { filteredOptions: b, filteredOptionsChildren: x };
3744
+ }, [
3745
+ i,
3746
+ t,
3747
+ n,
3748
+ m,
3749
+ s,
3750
+ d
3751
+ ]);
3752
+ return {
3753
+ filteredOptionsChildren: h,
3754
+ filteredOptions: p,
3755
+ restChildren: l,
3756
+ options: m,
3757
+ customIds: c,
3758
+ selectedOptions: d,
3759
+ interactiveChildren: a,
3760
+ setSelectedOptions: f
3761
+ };
3762
+ }
3763
+ const Mc = ({ readOnly: e, disabled: t, interactiveChildren: n, filteredOptions: r, inputValue: o, selectedOptions: i, multiple: s, open: c, options: l, setOpen: a, handleSelectOption: m }) => {
3764
+ const { activeIndex: u } = Xt();
3765
+ return jn((p) => {
3766
+ if (!(e || t) && p)
3767
+ switch (p.key) {
3768
+ case "ArrowDown":
3769
+ if (p.preventDefault(), c)
3770
+ break;
3771
+ a(!0);
3772
+ break;
3773
+ case "ArrowUp":
3774
+ if (p.preventDefault(), u !== 0)
3775
+ break;
3776
+ a(!1);
3777
+ break;
3778
+ case "Enter": {
3779
+ if (p.preventDefault(), !c)
3780
+ break;
3781
+ if (u <= n.length - 1) {
3782
+ const x = n[u];
3783
+ if (x.props.onSelect) {
3784
+ x == null || x.props.onSelect();
3785
+ return;
3786
+ }
3787
+ }
3788
+ const h = u - n.length, b = r[h];
3789
+ m({ option: l[b] });
3790
+ break;
3791
+ }
3792
+ case "Backspace":
3793
+ if (!s) {
3794
+ const h = Object.keys(i).pop();
3795
+ h && m({
3796
+ option: i[h],
3797
+ remove: !0
3798
+ });
3799
+ break;
3800
+ }
3801
+ if (o === "" && s) {
3802
+ const h = Object.keys(i).pop();
3803
+ h && m({
3804
+ option: i[h],
3805
+ remove: !0
3806
+ });
3807
+ }
3808
+ break;
3809
+ }
3810
+ }, 20);
3811
+ }, _c = ({ listRef: e }) => {
3812
+ const [t, n] = ke(!1), { activeIndex: r } = Xt(), o = Vn(), { refs: i, floatingStyles: s, context: c } = Ds({
3813
+ open: t,
3814
+ onOpenChange: (p) => {
3815
+ p || o == null || o({ type: "SET_ACTIVE_INDEX", payload: 0 }), Fo(() => {
3816
+ i.floating.current && !p && (i.floating.current.scrollTop = 0), setTimeout(() => {
3817
+ n(p);
3818
+ }, 1);
3819
+ });
3820
+ },
3821
+ whileElementsMounted: (p, h, b) => (jr(p, h, b), () => {
3822
+ h.scrollTop = 0;
3823
+ }),
3824
+ middleware: [
3825
+ es({ padding: 10 }),
3826
+ ts({
3827
+ apply({ rects: p, elements: h }) {
3828
+ requestAnimationFrame(() => {
3829
+ Object.assign(h.floating.style, {
3830
+ width: `${p.reference.width}px`,
3831
+ maxHeight: "200px"
3832
+ });
3833
+ });
3834
+ }
3835
+ }),
3836
+ Qi(10)
3837
+ ]
3838
+ }), l = _s(c, { role: "listbox" }), a = ks(c), m = Fs(c, {
3839
+ listRef: e,
3840
+ activeIndex: r,
3841
+ virtual: !0,
3842
+ scrollItemIntoView: !0,
3843
+ enabled: t,
3844
+ focusItemOnHover: !0,
3845
+ onNavigate: (p) => {
3846
+ o == null || o({ type: "SET_ACTIVE_INDEX", payload: p || 0 });
3847
+ }
3848
+ }), { getReferenceProps: u, getFloatingProps: d, getItemProps: f } = Ps([l, a, m]);
3849
+ return {
3850
+ open: t,
3851
+ setOpen: n,
3852
+ activeIndex: r,
3853
+ refs: i,
3854
+ floatingStyles: s,
3855
+ context: c,
3856
+ getReferenceProps: u,
3857
+ getFloatingProps: d,
3858
+ getItemProps: f
3859
+ };
3860
+ }, Bc = P(({ value: e, initialValue: t = [], onValueChange: n, label: r, hideLabel: o = !1, description: i, multiple: s = !1, disabled: c = !1, readOnly: l = !1, hideChips: a = !1, clearButtonLabel: m = "Fjern alt", hideClearButton: u = !1, error: d, errorId: f, id: p, name: h, portal: b = !0, htmlSize: x = 0, virtual: w = !1, children: g, style: C, size: S = "md", loading: k, loadingLabel: _ = "Laster...", filter: B, chipSrLabel: U = (N) => "Slett " + N.label, className: H, ...W }, O) => {
3861
+ const N = oe(null), D = oe(null), E = oe([]), [A, M] = ke(W.inputValue || "");
3862
+ ie(() => {
3863
+ typeof W.inputValue == "string" && M(W.inputValue);
3864
+ }, [W.inputValue]);
3865
+ const { selectedOptions: T, options: I, restChildren: X, interactiveChildren: se, customIds: Ie, filteredOptionsChildren: he, filteredOptions: j, setSelectedOptions: F } = Fc({
3866
+ children: g,
3867
+ inputValue: A,
3868
+ filter: B,
3869
+ multiple: s,
3870
+ initialValue: t
3871
+ }), { open: L, setOpen: $, refs: G, floatingStyles: ne, context: ce, getReferenceProps: Z, getFloatingProps: De, getItemProps: Te } = _c({
3872
+ listRef: E
3873
+ }), ee = Nc({
3874
+ disabled: c,
3875
+ error: d,
3876
+ errorId: f,
3877
+ size: S,
3878
+ description: i,
3879
+ id: p
3880
+ }, "combobox");
3881
+ ie(() => {
3882
+ if (e && e.length > 0 && !s) {
3883
+ const z = I[ye(e[0])];
3884
+ N.current && pt(N.current, (z == null ? void 0 : z.label) || "");
3885
+ }
3886
+ }, [s, e, I]), ie(() => {
3887
+ if (e && Object.keys(I).length >= 0) {
3888
+ const z = e.map((R) => I[ye(R)]);
3889
+ F(z.reduce((R, Y) => (R[ye(Y.value)] = Y, R), {}));
3890
+ }
3891
+ }, [s, e, I, F]);
3892
+ const ge = jn((z) => {
3893
+ var ve, qe;
3894
+ const { option: R, clear: Y, remove: ue } = z;
3895
+ if (Y) {
3896
+ F({}), N.current && pt(N.current, ""), n == null || n([]);
3897
+ return;
3898
+ }
3899
+ if (!R)
3900
+ return;
3901
+ if (ue) {
3902
+ const fe = { ...T };
3903
+ delete fe[ye(R.value)], F(fe), n == null || n(Object.keys(fe).map((de) => wn(de)));
3904
+ return;
3905
+ }
3906
+ const q = { ...T };
3907
+ if (s)
3908
+ q[ye(R.value)] ? delete q[ye(R.value)] : q[ye(R.value)] = R, N.current && pt(N.current, ""), (ve = N.current) == null || ve.focus();
3909
+ else {
3910
+ for (const fe of Object.keys(q))
3911
+ delete q[fe];
3912
+ q[ye(R.value)] = R, N.current && pt(N.current, (R == null ? void 0 : R.label) || ""), setTimeout(() => {
3913
+ var fe, de, Se;
3914
+ (Se = N.current) == null || Se.setSelectionRange(((fe = R == null ? void 0 : R.label) == null ? void 0 : fe.length) || 0, ((de = R == null ? void 0 : R.label) == null ? void 0 : de.length) || 0);
3915
+ }, 0);
3916
+ }
3917
+ F(q), n == null || n(Object.keys(q).map((fe) => wn(fe))), !s && $(!1), (qe = G.domReference.current) == null || qe.focus();
3918
+ }, 50), He = Mc({
3919
+ filteredOptions: j,
3920
+ selectedOptions: T,
3921
+ readOnly: ee.readOnly || !1,
3922
+ disabled: c,
3923
+ multiple: s,
3924
+ inputValue: A,
3925
+ options: I,
3926
+ open: L,
3927
+ interactiveChildren: se,
3928
+ setOpen: $,
3929
+ handleSelectOption: ge
3930
+ }), V = Mo({
3931
+ count: Object.keys(he).length,
3932
+ getScrollElement: () => w ? G.floating.current : null,
3933
+ estimateSize: () => 70,
3934
+ measureElement: (z) => z.getBoundingClientRect().height,
3935
+ overscan: 7
3936
+ });
3937
+ return le(We.Provider, { value: {
3938
+ size: S,
3939
+ options: I,
3940
+ selectedOptions: T,
3941
+ multiple: s,
3942
+ disabled: c,
3943
+ readOnly: l,
3944
+ open: L,
3945
+ inputRef: N,
3946
+ refs: G,
3947
+ inputValue: A,
3948
+ formFieldProps: ee,
3949
+ htmlSize: x,
3950
+ clearButtonLabel: m,
3951
+ customIds: Ie,
3952
+ filteredOptions: j,
3953
+ setInputValue: M,
3954
+ setOpen: $,
3955
+ getReferenceProps: Z,
3956
+ getItemProps: Te,
3957
+ /* Recieves the value of the option, and searches for it in our values lookup */
3958
+ onOptionClick: (z) => {
3959
+ if (l || c)
3960
+ return;
3961
+ const R = I[ye(z)];
3962
+ ge({ option: R });
3963
+ },
3964
+ handleSelectOption: ge,
3965
+ chipSrLabel: U,
3966
+ listRef: E,
3967
+ forwareddRef: O,
3968
+ setListRef: (z, R) => {
3969
+ E.current[z] = R;
3970
+ }
3971
+ }, children: [le("div", { className: K("ds-combobox", `ds-combobox--${S}`, c && "ds-combobox__disabled", H), style: C, ref: D, children: [h && v(Io, { name: h, selectedOptions: T, multiple: s }), v(Ro, { label: r, description: i, size: S, readOnly: l, hideLabel: o, formFieldProps: ee }), v(Eo, { ...lt(["inputValue"], W), hideClearButton: u, listId: ce.floatingId || "", error: d, hideChips: a, handleKeyDown: He, "aria-busy": k }), v(xo, { size: S, error: d, formFieldProps: ee })] }), L && v(Rs, { root: b ? null : D, children: v(Os, { context: ce, initialFocus: -1, visuallyHiddenDismiss: !0, children: le("div", { "aria-labelledby": ee.inputProps.id, "aria-autocomplete": "list", tabIndex: -1, ...De({
3972
+ ref: G.setFloating,
3973
+ style: {
3974
+ ...ne
3975
+ }
3976
+ }), className: K("ds-combobox__options-wrapper", `ds-combobox--${S}`), children: [w && v("div", { style: {
3977
+ height: `${V.getTotalSize()}px`,
3978
+ width: "100%",
3979
+ position: "relative"
3980
+ }, children: V.getVirtualItems().map((z) => v("div", { ref: V.measureElement, "data-index": z.index, style: {
3981
+ position: "absolute",
3982
+ top: 0,
3983
+ left: 0,
3984
+ width: "100%",
3985
+ transform: `translateY(${z.start}px)`
3986
+ }, children: he[z.index] }, z.index)) }), k ? le(yo, { className: "ds-combobox__loading", children: [v(to, { "aria-label": "Laster", "data-size": "sm" }), _] }) : le(ut, { children: [X, !w && he] })] }) }) })] });
3987
+ }), To = P((e, t) => v(Ec, { children: v(Bc, { ...e, ref: t }) }));
3988
+ To.displayName = "Combobox";
3989
+ const Ao = P(({ children: e, className: t, ...n }, r) => {
3990
+ const o = ae(We);
3991
+ if (!o)
3992
+ throw new Error("ComboboxEmpty must be used within a Combobox");
3993
+ const { filteredOptions: i, size: s } = o;
3994
+ return i.length === 0 && v(Ze, { "data-size": s, asChild: !0, children: v("div", { ref: r, className: K("ds-combobox__empty", t), ...n, children: e }) });
3995
+ });
3996
+ Ao.displayName = "ComboboxEmpty";
3997
+ const Gt = To;
3998
+ Gt.Option = Kn;
3999
+ Gt.Empty = Ao;
4000
+ Gt.Option.displayName = "Combobox.Option";
4001
+ Gt.Empty.displayName = "Combobox.Empty";
4002
+ const $c = (e, t, n) => {
4003
+ const r = (n - 1) / 2, o = Math.min(Math.max(e - Math.floor(r), 1), t - n + 1), i = Math.min(Math.max(e + Math.ceil(r), n), t), s = Array.from({ length: i + 1 - o }, (c, l) => l + o);
4004
+ return n > 4 && o > 1 && s.splice(0, 2, 1, 0), n > 3 && i < t && s.splice(-2, 2, 0, t), s;
4005
+ }, ta = ({ currentPage: e = 1, setCurrentPage: t, onChange: n, totalPages: r = 1, showPages: o = 7 }) => Ge(() => {
4006
+ const i = e < r, s = e !== 1, c = (l) => (a) => {
4007
+ if (l < 1 || l > r)
4008
+ return a.preventDefault();
4009
+ n == null || n(a, l), a.defaultPrevented || t == null || t(l);
4010
+ };
4011
+ return {
4012
+ /** Number of steps */
4013
+ pages: $c(e, r, o).map((l, a) => ({
4014
+ /**
4015
+ * Page number or "ellipsis" for the ellipsis item
4016
+ */
4017
+ page: l || "ellipsis",
4018
+ /**
4019
+ * Unique key for the item
4020
+ */
4021
+ itemKey: l ? `page-${l}` : `ellipsis-${a}`,
4022
+ // React key utility
4023
+ /**
4024
+ * Properties to spread on Pagination.Button
4025
+ */
4026
+ buttonProps: l ? {
4027
+ "aria-current": l === e ? "page" : void 0,
4028
+ onClick: c(l),
4029
+ variant: l === e ? "primary" : "tertiary"
4030
+ } : null
4031
+ })),
4032
+ /** Properties to spread on Pagination.Button used for previous naviagation */
4033
+ prevButtonProps: {
4034
+ "aria-disabled": !s,
4035
+ // Using aria-disabled to support all HTML elements because of potential asChild
4036
+ onClick: c(e - 1),
4037
+ variant: "tertiary"
4038
+ },
4039
+ /** Properties to spread on Pagination.Button used for next naviagation */
4040
+ nextButtonProps: {
4041
+ "aria-disabled": !i,
4042
+ // Using aria-disabled to support all HTML elements because of potential asChild
4043
+ onClick: c(e + 1),
4044
+ variant: "tertiary"
4045
+ },
4046
+ /** Indication if previous page action should be shown or not */
4047
+ hasPrev: s,
4048
+ /** Indication if next page action should be shown or not */
4049
+ hasNext: i
4050
+ };
4051
+ }, [e, r, o]);
4052
+ export {
4053
+ Qc as A,
4054
+ zs as B,
4055
+ ea as C,
4056
+ co as D,
4057
+ Jc as H,
4058
+ js as L,
4059
+ Fn as P,
4060
+ zn as S,
4061
+ Mn as T,
4062
+ mt as a,
4063
+ Ut as b,
4064
+ Gt as c,
4065
+ $n as d,
4066
+ Gc as e,
4067
+ Zc as f,
4068
+ zt as g,
4069
+ po as h,
4070
+ Xc as i,
4071
+ to as j,
4072
+ ta as u
4073
+ };