@altinn/altinn-components 0.44.4 → 0.45.0

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