@altinn/altinn-components 0.63.3 → 0.63.5

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