@eightshift/ui-components 0.0.1

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 (112) hide show
  1. package/README.md +27 -0
  2. package/dist/Checkbox-BLcVbhiO.js +178 -0
  3. package/dist/ColorSwatch-Cmlex_kT.js +66 -0
  4. package/dist/FieldError-wtMA4667.js +42 -0
  5. package/dist/FocusScope-1u9yyfIN.js +725 -0
  6. package/dist/Form-Cq3fu75_.js +5 -0
  7. package/dist/GridList-BZPXp3_O.js +1256 -0
  8. package/dist/Group-DyqpTRPe.js +49 -0
  9. package/dist/Input-jsbb4ugq.js +130 -0
  10. package/dist/Label-BPzS-sR7.js +17 -0
  11. package/dist/ListBox-w9gDaJkV.js +4423 -0
  12. package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
  13. package/dist/NumberFormatter-LzoKy975.js +160 -0
  14. package/dist/RSPContexts-CrNYmadY.js +14 -0
  15. package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
  16. package/dist/SelectionManager-mefd0ThJ.js +2155 -0
  17. package/dist/Separator-DHn0CwdK.js +325 -0
  18. package/dist/Slider-Pyh2V4bY.js +885 -0
  19. package/dist/Text-BM136LvS.js +17 -0
  20. package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
  21. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  22. package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
  23. package/dist/assets/style.css +1 -0
  24. package/dist/button-BkkdyHfJ.js +307 -0
  25. package/dist/components/animated-visibility/animated-visibility.js +7165 -0
  26. package/dist/components/base-control/base-control.js +97 -0
  27. package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
  28. package/dist/components/button/button.js +10 -0
  29. package/dist/components/checkbox/checkbox.js +119 -0
  30. package/dist/components/color-pickers/color-picker.js +242 -0
  31. package/dist/components/color-pickers/color-swatch.js +62 -0
  32. package/dist/components/color-pickers/gradient-editor.js +516 -0
  33. package/dist/components/color-pickers/solid-color-picker.js +1633 -0
  34. package/dist/components/component-toggle/component-toggle.js +71 -0
  35. package/dist/components/container-panel/container-panel.js +39 -0
  36. package/dist/components/expandable/expandable.js +144 -0
  37. package/dist/components/input-field/input-field.js +224 -0
  38. package/dist/components/link-input/link-input.js +937 -0
  39. package/dist/components/list-box/list-box.js +152 -0
  40. package/dist/components/matrix-align/matrix-align.js +185 -0
  41. package/dist/components/menu/menu.js +1608 -0
  42. package/dist/components/notice/notice.js +119 -0
  43. package/dist/components/number-picker/number-picker.js +277 -0
  44. package/dist/components/popover/popover.js +9 -0
  45. package/dist/components/radio/radio.js +552 -0
  46. package/dist/components/repeater/repeater-item.js +127 -0
  47. package/dist/components/repeater/repeater.js +248 -0
  48. package/dist/components/responsive/responsive-legacy.js +326 -0
  49. package/dist/components/responsive/responsive.js +499 -0
  50. package/dist/components/responsive-preview/responsive-preview.js +119 -0
  51. package/dist/components/rich-label/rich-label.js +56 -0
  52. package/dist/components/select/async-multi-select.js +144 -0
  53. package/dist/components/select/async-single-select.js +126 -0
  54. package/dist/components/select/custom-select-default-components.js +38 -0
  55. package/dist/components/select/multi-select-components.js +8 -0
  56. package/dist/components/select/multi-select.js +134 -0
  57. package/dist/components/select/react-select-component-wrappers.js +90 -0
  58. package/dist/components/select/shared.js +45 -0
  59. package/dist/components/select/single-select.js +116 -0
  60. package/dist/components/select/styles.js +55 -0
  61. package/dist/components/slider/column-config-slider.js +225 -0
  62. package/dist/components/slider/slider.js +362 -0
  63. package/dist/components/slider/utils.js +45 -0
  64. package/dist/components/spacer/spacer.js +93 -0
  65. package/dist/components/tabs/tabs.js +626 -0
  66. package/dist/components/toggle/switch.js +140 -0
  67. package/dist/components/toggle/toggle.js +58 -0
  68. package/dist/components/toggle-button/toggle-button.js +206 -0
  69. package/dist/components/tooltip/tooltip.js +10 -0
  70. package/dist/context-jMy6xdVq.js +98 -0
  71. package/dist/default-i18n-BhE-OUmt.js +873 -0
  72. package/dist/filterDOMProps-DG2RfOUr.js +30 -0
  73. package/dist/focusSafely-C3K8zAKj.js +743 -0
  74. package/dist/hooks/use-cell-edit-mode.js +35 -0
  75. package/dist/icons/block-icon.js +42 -0
  76. package/dist/icons/generic-color-swatch.js +21 -0
  77. package/dist/icons/icons.js +3636 -0
  78. package/dist/index-Bfb9bWcb.js +28844 -0
  79. package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
  80. package/dist/index.js +109 -0
  81. package/dist/intlStrings-CUhoK9EN.js +2484 -0
  82. package/dist/isScrollable-PcyglExV.js +10 -0
  83. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  84. package/dist/multi-select-components-CjVpCNko.js +3677 -0
  85. package/dist/number-rWqELA8W.js +39 -0
  86. package/dist/popover-Dx3vKXUX.js +1061 -0
  87. package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
  88. package/dist/react-select.esm-BjRWqf0E.js +15 -0
  89. package/dist/style.js +1 -0
  90. package/dist/textSelection-BosCCRVE.js +89 -0
  91. package/dist/tooltip-CkCndvTI.js +1094 -0
  92. package/dist/useButton-CuG5UzUw.js +74 -0
  93. package/dist/useEvent-DHv-yhOH.js +24 -0
  94. package/dist/useFocusRing-Cc-4eouh.js +41 -0
  95. package/dist/useFocusable-5q1Gek1J.js +81 -0
  96. package/dist/useFormReset-Buc9YJcv.js +23 -0
  97. package/dist/useFormValidationState-BAPPNXic.js +238 -0
  98. package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
  99. package/dist/useLabel-CGlkoFG0.js +28 -0
  100. package/dist/useLabels-Dg62M_3P.js +25 -0
  101. package/dist/useListData-BelKu4kx.js +211 -0
  102. package/dist/useListState-Domq0blV.js +137 -0
  103. package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
  104. package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
  105. package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
  106. package/dist/usePress-BQgVor4T.js +698 -0
  107. package/dist/useToggle-C9ETOBaZ.js +58 -0
  108. package/dist/useToggleState-DJ_z5E2S.js +21 -0
  109. package/dist/utilities/classnames.js +16 -0
  110. package/dist/utilities/text-helpers.js +79 -0
  111. package/dist/utils-BsiH7-5Y.js +488 -0
  112. package/package.json +71 -0
@@ -0,0 +1,2155 @@
1
+ import React__default, { useState, useRef, useEffect, useMemo, forwardRef, useCallback, useContext, cloneElement, createContext } from "react";
2
+ import { r as reactDomExports } from "./index-Bfb9bWcb.js";
3
+ import { a as $9bf71ea28793e738$export$2d6ec8fc375ceafa } from "./FocusScope-1u9yyfIN.js";
4
+ import { v as $c87311424ea30a05$export$e1865c3bedcd822b, o as $c87311424ea30a05$export$9ac100e40613ea10, h as $6a99195332edec8b$export$80f3e147d781571c, t as $507fabe10e71c6fb$export$630ff653c5ada6a9, m as $7215afc6de606d6b$export$de79e2c695e052f3, e as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "./focusSafely-C3K8zAKj.js";
5
+ import { g as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, d as $3ef42575df84b30b$export$9d1611c77c2fe928, o as $b5e257d569688ac6$export$535bd6ca7f90a273 } from "./utils-BsiH7-5Y.js";
6
+ import { $ as $f6c31cce2adf654f$export$45712eceda6fad21, b as $ea8dcbcb9ea1b556$export$9a302a45f65d0572, c as $ea8dcbcb9ea1b556$export$95185d699e05d4d7 } from "./usePress-BQgVor4T.js";
7
+ import { $ as $e9faafb641e167db$export$90fc3a17d93f704c } from "./useEvent-DHv-yhOH.js";
8
+ import { $ as $cc38e7bd3fc7b213$export$2bb74740c4e19def } from "./isScrollable-PcyglExV.js";
9
+ import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-jMy6xdVq.js";
10
+ import { $ as $03deb23ff14920c4$export$4eaf04e54aa8eed6 } from "./textSelection-BosCCRVE.js";
11
+ function $a40c673dc9f6d9c7$export$94ed1c92c7beeb22(node, checkForOverflow) {
12
+ const scrollParents = [];
13
+ while (node && node !== document.documentElement) {
14
+ if ($cc38e7bd3fc7b213$export$2bb74740c4e19def(node, checkForOverflow))
15
+ scrollParents.push(node);
16
+ node = node.parentElement;
17
+ }
18
+ return scrollParents;
19
+ }
20
+ let $ef06256079686ba0$var$descriptionId = 0;
21
+ const $ef06256079686ba0$var$descriptionNodes = /* @__PURE__ */ new Map();
22
+ function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
23
+ let [id, setId] = useState();
24
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
25
+ if (!description)
26
+ return;
27
+ let desc = $ef06256079686ba0$var$descriptionNodes.get(description);
28
+ if (!desc) {
29
+ let id2 = `react-aria-description-${$ef06256079686ba0$var$descriptionId++}`;
30
+ setId(id2);
31
+ let node = document.createElement("div");
32
+ node.id = id2;
33
+ node.style.display = "none";
34
+ node.textContent = description;
35
+ document.body.appendChild(node);
36
+ desc = {
37
+ refCount: 0,
38
+ element: node
39
+ };
40
+ $ef06256079686ba0$var$descriptionNodes.set(description, desc);
41
+ } else
42
+ setId(desc.element.id);
43
+ desc.refCount++;
44
+ return () => {
45
+ if (desc && --desc.refCount === 0) {
46
+ desc.element.remove();
47
+ $ef06256079686ba0$var$descriptionNodes.delete(description);
48
+ }
49
+ };
50
+ }, [
51
+ description
52
+ ]);
53
+ return {
54
+ "aria-describedby": description ? id : void 0
55
+ };
56
+ }
57
+ function $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollView, element) {
58
+ let offsetX = $2f04cbc44ee30ce0$var$relativeOffset(scrollView, element, "left");
59
+ let offsetY = $2f04cbc44ee30ce0$var$relativeOffset(scrollView, element, "top");
60
+ let width = element.offsetWidth;
61
+ let height = element.offsetHeight;
62
+ let x = scrollView.scrollLeft;
63
+ let y = scrollView.scrollTop;
64
+ let { borderTopWidth, borderLeftWidth } = getComputedStyle(scrollView);
65
+ let borderAdjustedX = scrollView.scrollLeft + parseInt(borderLeftWidth, 10);
66
+ let borderAdjustedY = scrollView.scrollTop + parseInt(borderTopWidth, 10);
67
+ let maxX = borderAdjustedX + scrollView.clientWidth;
68
+ let maxY = borderAdjustedY + scrollView.clientHeight;
69
+ if (offsetX <= x)
70
+ x = offsetX - parseInt(borderLeftWidth, 10);
71
+ else if (offsetX + width > maxX)
72
+ x += offsetX + width - maxX;
73
+ if (offsetY <= borderAdjustedY)
74
+ y = offsetY - parseInt(borderTopWidth, 10);
75
+ else if (offsetY + height > maxY)
76
+ y += offsetY + height - maxY;
77
+ scrollView.scrollLeft = x;
78
+ scrollView.scrollTop = y;
79
+ }
80
+ function $2f04cbc44ee30ce0$var$relativeOffset(ancestor, child, axis) {
81
+ const prop = axis === "left" ? "offsetLeft" : "offsetTop";
82
+ let sum = 0;
83
+ while (child.offsetParent) {
84
+ sum += child[prop];
85
+ if (child.offsetParent === ancestor)
86
+ break;
87
+ else if (child.offsetParent.contains(ancestor)) {
88
+ sum -= ancestor[prop];
89
+ break;
90
+ }
91
+ child = child.offsetParent;
92
+ }
93
+ return sum;
94
+ }
95
+ function $2f04cbc44ee30ce0$export$c826860796309d1b(targetElement, opts) {
96
+ if (document.contains(targetElement)) {
97
+ let root = document.scrollingElement || document.documentElement;
98
+ let isScrollPrevented = window.getComputedStyle(root).overflow === "hidden";
99
+ if (!isScrollPrevented) {
100
+ var _targetElement_scrollIntoView;
101
+ let { left: originalLeft, top: originalTop } = targetElement.getBoundingClientRect();
102
+ targetElement === null || targetElement === void 0 ? void 0 : (_targetElement_scrollIntoView = targetElement.scrollIntoView) === null || _targetElement_scrollIntoView === void 0 ? void 0 : _targetElement_scrollIntoView.call(targetElement, {
103
+ block: "nearest"
104
+ });
105
+ let { left: newLeft, top: newTop } = targetElement.getBoundingClientRect();
106
+ if (Math.abs(originalLeft - newLeft) > 1 || Math.abs(originalTop - newTop) > 1) {
107
+ var _opts_containingElement_scrollIntoView, _opts_containingElement, _targetElement_scrollIntoView1;
108
+ opts === null || opts === void 0 ? void 0 : (_opts_containingElement = opts.containingElement) === null || _opts_containingElement === void 0 ? void 0 : (_opts_containingElement_scrollIntoView = _opts_containingElement.scrollIntoView) === null || _opts_containingElement_scrollIntoView === void 0 ? void 0 : _opts_containingElement_scrollIntoView.call(_opts_containingElement, {
109
+ block: "center",
110
+ inline: "center"
111
+ });
112
+ (_targetElement_scrollIntoView1 = targetElement.scrollIntoView) === null || _targetElement_scrollIntoView1 === void 0 ? void 0 : _targetElement_scrollIntoView1.call(targetElement, {
113
+ block: "nearest"
114
+ });
115
+ }
116
+ } else {
117
+ let scrollParents = $a40c673dc9f6d9c7$export$94ed1c92c7beeb22(targetElement);
118
+ for (let scrollParent of scrollParents)
119
+ $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollParent, targetElement);
120
+ }
121
+ }
122
+ }
123
+ const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
124
+ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
125
+ let { isDisabled, onLongPressStart, onLongPressEnd, onLongPress, threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD, accessibilityDescription } = props;
126
+ const timeRef = useRef();
127
+ let { addGlobalListener, removeGlobalListener } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
128
+ let { pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
129
+ isDisabled,
130
+ onPressStart(e) {
131
+ e.continuePropagation();
132
+ if (e.pointerType === "mouse" || e.pointerType === "touch") {
133
+ if (onLongPressStart)
134
+ onLongPressStart({
135
+ ...e,
136
+ type: "longpressstart"
137
+ });
138
+ timeRef.current = setTimeout(() => {
139
+ e.target.dispatchEvent(new PointerEvent("pointercancel", {
140
+ bubbles: true
141
+ }));
142
+ if (onLongPress)
143
+ onLongPress({
144
+ ...e,
145
+ type: "longpress"
146
+ });
147
+ timeRef.current = void 0;
148
+ }, threshold);
149
+ if (e.pointerType === "touch") {
150
+ let onContextMenu = (e2) => {
151
+ e2.preventDefault();
152
+ };
153
+ addGlobalListener(e.target, "contextmenu", onContextMenu, {
154
+ once: true
155
+ });
156
+ addGlobalListener(window, "pointerup", () => {
157
+ setTimeout(() => {
158
+ removeGlobalListener(e.target, "contextmenu", onContextMenu);
159
+ }, 30);
160
+ }, {
161
+ once: true
162
+ });
163
+ }
164
+ }
165
+ },
166
+ onPressEnd(e) {
167
+ if (timeRef.current)
168
+ clearTimeout(timeRef.current);
169
+ if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch"))
170
+ onLongPressEnd({
171
+ ...e,
172
+ type: "longpressend"
173
+ });
174
+ }
175
+ });
176
+ let descriptionProps = $ef06256079686ba0$export$f8aeda7b10753fa1(onLongPress && !isDisabled ? accessibilityDescription : void 0);
177
+ return {
178
+ longPressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, descriptionProps)
179
+ };
180
+ }
181
+ function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
182
+ return $c87311424ea30a05$export$e1865c3bedcd822b() ? e.altKey : e.ctrlKey;
183
+ }
184
+ function $feb5ffebff200149$export$16792effe837dba3(e) {
185
+ if ($c87311424ea30a05$export$9ac100e40613ea10())
186
+ return e.metaKey;
187
+ return e.ctrlKey;
188
+ }
189
+ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1e3;
190
+ function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
191
+ let { keyboardDelegate, selectionManager, onTypeSelect } = options;
192
+ let state = useRef({
193
+ search: "",
194
+ timeout: null
195
+ }).current;
196
+ let onKeyDown = (e) => {
197
+ let character = $fb3050f43d946246$var$getStringForKey(e.key);
198
+ if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target))
199
+ return;
200
+ if (character === " " && state.search.trim().length > 0) {
201
+ e.preventDefault();
202
+ if (!("continuePropagation" in e))
203
+ e.stopPropagation();
204
+ }
205
+ state.search += character;
206
+ let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
207
+ if (key == null)
208
+ key = keyboardDelegate.getKeyForSearch(state.search);
209
+ if (key != null) {
210
+ selectionManager.setFocusedKey(key);
211
+ if (onTypeSelect)
212
+ onTypeSelect(key);
213
+ }
214
+ clearTimeout(state.timeout);
215
+ state.timeout = setTimeout(() => {
216
+ state.search = "";
217
+ }, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
218
+ };
219
+ return {
220
+ typeSelectProps: {
221
+ // Using a capturing listener to catch the keydown event before
222
+ // other hooks in order to handle the Spacebar event.
223
+ onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
224
+ }
225
+ };
226
+ }
227
+ function $fb3050f43d946246$var$getStringForKey(key) {
228
+ if (key.length === 1 || !/^[A-Z]/i.test(key))
229
+ return key;
230
+ return "";
231
+ }
232
+ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
233
+ let { selectionManager: manager, keyboardDelegate: delegate, ref, autoFocus = false, shouldFocusWrap = false, disallowEmptySelection = false, disallowSelectAll = false, selectOnFocus = manager.selectionBehavior === "replace", disallowTypeAhead = false, shouldUseVirtualFocus, allowsTabNavigation = false, isVirtualized, scrollRef = ref, linkBehavior = "action" } = options;
234
+ let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
235
+ let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
236
+ let onKeyDown = (e) => {
237
+ if (e.altKey && e.key === "Tab")
238
+ e.preventDefault();
239
+ if (!ref.current.contains(e.target))
240
+ return;
241
+ const navigateToKey = (key, childFocus) => {
242
+ if (key != null) {
243
+ if (manager.isLink(key) && linkBehavior === "selection" && selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) {
244
+ reactDomExports.flushSync(() => {
245
+ manager.setFocusedKey(key, childFocus);
246
+ });
247
+ let item = scrollRef.current.querySelector(`[data-key="${CSS.escape(key.toString())}"]`);
248
+ let itemProps = manager.getItemProps(key);
249
+ router.open(item, e, itemProps.href, itemProps.routerOptions);
250
+ return;
251
+ }
252
+ manager.setFocusedKey(key, childFocus);
253
+ if (manager.isLink(key) && linkBehavior === "override")
254
+ return;
255
+ if (e.shiftKey && manager.selectionMode === "multiple")
256
+ manager.extendSelection(key);
257
+ else if (selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e))
258
+ manager.replaceSelection(key);
259
+ }
260
+ };
261
+ switch (e.key) {
262
+ case "ArrowDown":
263
+ if (delegate.getKeyBelow) {
264
+ var _delegate_getFirstKey, _delegate_getFirstKey1;
265
+ e.preventDefault();
266
+ let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate);
267
+ if (nextKey == null && shouldFocusWrap)
268
+ nextKey = (_delegate_getFirstKey1 = delegate.getFirstKey) === null || _delegate_getFirstKey1 === void 0 ? void 0 : _delegate_getFirstKey1.call(delegate, manager.focusedKey);
269
+ navigateToKey(nextKey);
270
+ }
271
+ break;
272
+ case "ArrowUp":
273
+ if (delegate.getKeyAbove) {
274
+ var _delegate_getLastKey, _delegate_getLastKey1;
275
+ e.preventDefault();
276
+ let nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate);
277
+ if (nextKey == null && shouldFocusWrap)
278
+ nextKey = (_delegate_getLastKey1 = delegate.getLastKey) === null || _delegate_getLastKey1 === void 0 ? void 0 : _delegate_getLastKey1.call(delegate, manager.focusedKey);
279
+ navigateToKey(nextKey);
280
+ }
281
+ break;
282
+ case "ArrowLeft":
283
+ if (delegate.getKeyLeftOf) {
284
+ var _delegate_getFirstKey2, _delegate_getLastKey2;
285
+ e.preventDefault();
286
+ let nextKey = delegate.getKeyLeftOf(manager.focusedKey);
287
+ if (nextKey == null && shouldFocusWrap)
288
+ nextKey = direction === "rtl" ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
289
+ navigateToKey(nextKey, direction === "rtl" ? "first" : "last");
290
+ }
291
+ break;
292
+ case "ArrowRight":
293
+ if (delegate.getKeyRightOf) {
294
+ var _delegate_getLastKey3, _delegate_getFirstKey3;
295
+ e.preventDefault();
296
+ let nextKey = delegate.getKeyRightOf(manager.focusedKey);
297
+ if (nextKey == null && shouldFocusWrap)
298
+ nextKey = direction === "rtl" ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
299
+ navigateToKey(nextKey, direction === "rtl" ? "last" : "first");
300
+ }
301
+ break;
302
+ case "Home":
303
+ if (delegate.getFirstKey) {
304
+ e.preventDefault();
305
+ let firstKey = delegate.getFirstKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
306
+ manager.setFocusedKey(firstKey);
307
+ if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === "multiple")
308
+ manager.extendSelection(firstKey);
309
+ else if (selectOnFocus)
310
+ manager.replaceSelection(firstKey);
311
+ }
312
+ break;
313
+ case "End":
314
+ if (delegate.getLastKey) {
315
+ e.preventDefault();
316
+ let lastKey = delegate.getLastKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
317
+ manager.setFocusedKey(lastKey);
318
+ if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === "multiple")
319
+ manager.extendSelection(lastKey);
320
+ else if (selectOnFocus)
321
+ manager.replaceSelection(lastKey);
322
+ }
323
+ break;
324
+ case "PageDown":
325
+ if (delegate.getKeyPageBelow) {
326
+ e.preventDefault();
327
+ let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
328
+ navigateToKey(nextKey);
329
+ }
330
+ break;
331
+ case "PageUp":
332
+ if (delegate.getKeyPageAbove) {
333
+ e.preventDefault();
334
+ let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
335
+ navigateToKey(nextKey);
336
+ }
337
+ break;
338
+ case "a":
339
+ if ($feb5ffebff200149$export$16792effe837dba3(e) && manager.selectionMode === "multiple" && disallowSelectAll !== true) {
340
+ e.preventDefault();
341
+ manager.selectAll();
342
+ }
343
+ break;
344
+ case "Escape":
345
+ if (!disallowEmptySelection && manager.selectedKeys.size !== 0) {
346
+ e.stopPropagation();
347
+ e.preventDefault();
348
+ manager.clearSelection();
349
+ }
350
+ break;
351
+ case "Tab":
352
+ if (!allowsTabNavigation) {
353
+ if (e.shiftKey)
354
+ ref.current.focus();
355
+ else {
356
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ref.current, {
357
+ tabbable: true
358
+ });
359
+ let next;
360
+ let last;
361
+ do {
362
+ last = walker.lastChild();
363
+ if (last)
364
+ next = last;
365
+ } while (last);
366
+ if (next && !next.contains(document.activeElement))
367
+ $7215afc6de606d6b$export$de79e2c695e052f3(next);
368
+ }
369
+ break;
370
+ }
371
+ }
372
+ };
373
+ let scrollPos = useRef({
374
+ top: 0,
375
+ left: 0
376
+ });
377
+ $e9faafb641e167db$export$90fc3a17d93f704c(scrollRef, "scroll", isVirtualized ? null : () => {
378
+ scrollPos.current = {
379
+ top: scrollRef.current.scrollTop,
380
+ left: scrollRef.current.scrollLeft
381
+ };
382
+ });
383
+ let onFocus = (e) => {
384
+ if (manager.isFocused) {
385
+ if (!e.currentTarget.contains(e.target))
386
+ manager.setFocused(false);
387
+ return;
388
+ }
389
+ if (!e.currentTarget.contains(e.target))
390
+ return;
391
+ manager.setFocused(true);
392
+ if (manager.focusedKey == null) {
393
+ let navigateToFirstKey = (key) => {
394
+ if (key != null) {
395
+ manager.setFocusedKey(key);
396
+ if (selectOnFocus)
397
+ manager.replaceSelection(key);
398
+ }
399
+ };
400
+ let relatedTarget = e.relatedTarget;
401
+ var _manager_lastSelectedKey, _manager_firstSelectedKey;
402
+ if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING)
403
+ navigateToFirstKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : delegate.getLastKey());
404
+ else
405
+ navigateToFirstKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : delegate.getFirstKey());
406
+ } else if (!isVirtualized) {
407
+ scrollRef.current.scrollTop = scrollPos.current.top;
408
+ scrollRef.current.scrollLeft = scrollPos.current.left;
409
+ }
410
+ if (!isVirtualized && manager.focusedKey != null) {
411
+ let element = scrollRef.current.querySelector(`[data-key="${CSS.escape(manager.focusedKey.toString())}"]`);
412
+ if (element) {
413
+ if (!element.contains(document.activeElement))
414
+ $7215afc6de606d6b$export$de79e2c695e052f3(element);
415
+ let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
416
+ if (modality === "keyboard")
417
+ $2f04cbc44ee30ce0$export$c826860796309d1b(element, {
418
+ containingElement: ref.current
419
+ });
420
+ }
421
+ }
422
+ };
423
+ let onBlur = (e) => {
424
+ if (!e.currentTarget.contains(e.relatedTarget))
425
+ manager.setFocused(false);
426
+ };
427
+ const autoFocusRef = useRef(autoFocus);
428
+ useEffect(() => {
429
+ if (autoFocusRef.current) {
430
+ let focusedKey = null;
431
+ if (autoFocus === "first")
432
+ focusedKey = delegate.getFirstKey();
433
+ if (autoFocus === "last")
434
+ focusedKey = delegate.getLastKey();
435
+ let selectedKeys = manager.selectedKeys;
436
+ if (selectedKeys.size) {
437
+ for (let key of selectedKeys)
438
+ if (manager.canSelectItem(key)) {
439
+ focusedKey = key;
440
+ break;
441
+ }
442
+ }
443
+ manager.setFocused(true);
444
+ manager.setFocusedKey(focusedKey);
445
+ if (focusedKey == null && !shouldUseVirtualFocus)
446
+ $6a99195332edec8b$export$80f3e147d781571c(ref.current);
447
+ }
448
+ }, []);
449
+ let lastFocusedKey = useRef(manager.focusedKey);
450
+ useEffect(() => {
451
+ let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
452
+ if (manager.isFocused && manager.focusedKey != null && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
453
+ let element = scrollRef.current.querySelector(`[data-key="${CSS.escape(manager.focusedKey.toString())}"]`);
454
+ if (element && (modality === "keyboard" || autoFocusRef.current)) {
455
+ if (!isVirtualized)
456
+ $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollRef.current, element);
457
+ if (modality !== "virtual")
458
+ $2f04cbc44ee30ce0$export$c826860796309d1b(element, {
459
+ containingElement: ref.current
460
+ });
461
+ }
462
+ }
463
+ if (manager.isFocused && manager.focusedKey == null && lastFocusedKey.current != null)
464
+ $6a99195332edec8b$export$80f3e147d781571c(ref.current);
465
+ lastFocusedKey.current = manager.focusedKey;
466
+ autoFocusRef.current = false;
467
+ }, [
468
+ isVirtualized,
469
+ scrollRef,
470
+ manager.focusedKey,
471
+ manager.isFocused,
472
+ ref
473
+ ]);
474
+ let handlers = {
475
+ onKeyDown,
476
+ onFocus,
477
+ onBlur,
478
+ onMouseDown(e) {
479
+ if (scrollRef.current === e.target)
480
+ e.preventDefault();
481
+ }
482
+ };
483
+ let { typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
484
+ keyboardDelegate: delegate,
485
+ selectionManager: manager
486
+ });
487
+ if (!disallowTypeAhead)
488
+ handlers = $3ef42575df84b30b$export$9d1611c77c2fe928(typeSelectProps, handlers);
489
+ let tabIndex;
490
+ if (!shouldUseVirtualFocus)
491
+ tabIndex = manager.focusedKey == null ? 0 : -1;
492
+ return {
493
+ collectionProps: {
494
+ ...handlers,
495
+ tabIndex
496
+ }
497
+ };
498
+ }
499
+ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
500
+ let { selectionManager: manager, key, ref, shouldSelectOnPressUp, shouldUseVirtualFocus, focus, isDisabled, onAction, allowsDifferentPressOrigin, linkBehavior = "action" } = options;
501
+ let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
502
+ let onSelect = (e) => {
503
+ if (e.pointerType === "keyboard" && $feb5ffebff200149$export$d3e3bd3e26688c04(e))
504
+ manager.toggleSelection(key);
505
+ else {
506
+ if (manager.selectionMode === "none")
507
+ return;
508
+ if (manager.isLink(key)) {
509
+ if (linkBehavior === "selection") {
510
+ let itemProps2 = manager.getItemProps(key);
511
+ router.open(ref.current, e, itemProps2.href, itemProps2.routerOptions);
512
+ manager.setSelectedKeys(manager.selectedKeys);
513
+ return;
514
+ } else if (linkBehavior === "override" || linkBehavior === "none")
515
+ return;
516
+ }
517
+ if (manager.selectionMode === "single") {
518
+ if (manager.isSelected(key) && !manager.disallowEmptySelection)
519
+ manager.toggleSelection(key);
520
+ else
521
+ manager.replaceSelection(key);
522
+ } else if (e && e.shiftKey)
523
+ manager.extendSelection(key);
524
+ else if (manager.selectionBehavior === "toggle" || e && ($feb5ffebff200149$export$16792effe837dba3(e) || e.pointerType === "touch" || e.pointerType === "virtual"))
525
+ manager.toggleSelection(key);
526
+ else
527
+ manager.replaceSelection(key);
528
+ }
529
+ };
530
+ useEffect(() => {
531
+ let isFocused = key === manager.focusedKey;
532
+ if (isFocused && manager.isFocused && !shouldUseVirtualFocus) {
533
+ if (focus)
534
+ focus();
535
+ else if (document.activeElement !== ref.current)
536
+ $6a99195332edec8b$export$80f3e147d781571c(ref.current);
537
+ }
538
+ }, [
539
+ ref,
540
+ key,
541
+ manager.focusedKey,
542
+ manager.childFocusStrategy,
543
+ manager.isFocused,
544
+ shouldUseVirtualFocus
545
+ ]);
546
+ isDisabled = isDisabled || manager.isDisabled(key);
547
+ let itemProps = {};
548
+ if (!shouldUseVirtualFocus && !isDisabled)
549
+ itemProps = {
550
+ tabIndex: key === manager.focusedKey ? 0 : -1,
551
+ onFocus(e) {
552
+ if (e.target === ref.current)
553
+ manager.setFocusedKey(key);
554
+ }
555
+ };
556
+ else if (isDisabled)
557
+ itemProps.onMouseDown = (e) => {
558
+ e.preventDefault();
559
+ };
560
+ let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
561
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
562
+ let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
563
+ let allowsActions = (onAction || hasLinkAction) && !isDisabled;
564
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
565
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
566
+ let hasAction = hasPrimaryAction || hasSecondaryAction;
567
+ let modality = useRef(null);
568
+ let longPressEnabled = hasAction && allowsSelection;
569
+ let longPressEnabledOnPressStart = useRef(false);
570
+ let hadPrimaryActionOnPressStart = useRef(false);
571
+ let performAction = (e) => {
572
+ if (onAction)
573
+ onAction();
574
+ if (hasLinkAction) {
575
+ let itemProps2 = manager.getItemProps(key);
576
+ router.open(ref.current, e, itemProps2.href, itemProps2.routerOptions);
577
+ }
578
+ };
579
+ let itemPressProps = {};
580
+ if (shouldSelectOnPressUp) {
581
+ itemPressProps.onPressStart = (e) => {
582
+ modality.current = e.pointerType;
583
+ longPressEnabledOnPressStart.current = longPressEnabled;
584
+ if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey()))
585
+ onSelect(e);
586
+ };
587
+ if (!allowsDifferentPressOrigin)
588
+ itemPressProps.onPress = (e) => {
589
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
590
+ if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey())
591
+ return;
592
+ performAction(e);
593
+ } else if (e.pointerType !== "keyboard" && allowsSelection)
594
+ onSelect(e);
595
+ };
596
+ else {
597
+ itemPressProps.onPressUp = hasPrimaryAction ? null : (e) => {
598
+ if (e.pointerType !== "keyboard" && allowsSelection)
599
+ onSelect(e);
600
+ };
601
+ itemPressProps.onPress = hasPrimaryAction ? performAction : null;
602
+ }
603
+ } else {
604
+ itemPressProps.onPressStart = (e) => {
605
+ modality.current = e.pointerType;
606
+ longPressEnabledOnPressStart.current = longPressEnabled;
607
+ hadPrimaryActionOnPressStart.current = hasPrimaryAction;
608
+ if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey())))
609
+ onSelect(e);
610
+ };
611
+ itemPressProps.onPress = (e) => {
612
+ if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
613
+ if (hasAction)
614
+ performAction(e);
615
+ else if (allowsSelection)
616
+ onSelect(e);
617
+ }
618
+ };
619
+ }
620
+ itemProps["data-key"] = key;
621
+ itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
622
+ let { pressProps, isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21(itemPressProps);
623
+ let onDoubleClick = hasSecondaryAction ? (e) => {
624
+ if (modality.current === "mouse") {
625
+ e.stopPropagation();
626
+ e.preventDefault();
627
+ performAction(e);
628
+ }
629
+ } : void 0;
630
+ let { longPressProps } = $8a26561d2877236e$export$c24ed0104d07eab9({
631
+ isDisabled: !longPressEnabled,
632
+ onLongPress(e) {
633
+ if (e.pointerType === "touch") {
634
+ onSelect(e);
635
+ manager.setSelectionBehavior("toggle");
636
+ }
637
+ }
638
+ });
639
+ let onDragStartCapture = (e) => {
640
+ if (modality.current === "touch" && longPressEnabledOnPressStart.current)
641
+ e.preventDefault();
642
+ };
643
+ let onClick = manager.isLink(key) ? (e) => {
644
+ if (!$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening)
645
+ e.preventDefault();
646
+ } : void 0;
647
+ return {
648
+ itemProps: $3ef42575df84b30b$export$9d1611c77c2fe928(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
649
+ onDoubleClick,
650
+ onDragStartCapture,
651
+ onClick
652
+ }),
653
+ isPressed,
654
+ isSelected: manager.isSelected(key),
655
+ isFocused: manager.isFocused && manager.focusedKey === key,
656
+ isDisabled,
657
+ allowsSelection,
658
+ hasAction
659
+ };
660
+ }
661
+ function $880e95eb8b93ba9a$var$isActionKey() {
662
+ let event = window.event;
663
+ return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
664
+ }
665
+ function $880e95eb8b93ba9a$var$isSelectionKey() {
666
+ let event = window.event;
667
+ return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
668
+ }
669
+ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
670
+ build(props, context) {
671
+ this.context = context;
672
+ return $eb2240fc39a57fa5$var$iterable(() => this.iterateCollection(props));
673
+ }
674
+ *iterateCollection(props) {
675
+ let { children, items } = props;
676
+ if (typeof children === "function") {
677
+ if (!items)
678
+ throw new Error("props.children was a function but props.items is missing");
679
+ for (let item of props.items)
680
+ yield* this.getFullNode({
681
+ value: item
682
+ }, {
683
+ renderer: children
684
+ });
685
+ } else {
686
+ let items2 = [];
687
+ React__default.Children.forEach(children, (child) => {
688
+ items2.push(child);
689
+ });
690
+ let index = 0;
691
+ for (let item of items2) {
692
+ let nodes = this.getFullNode({
693
+ element: item,
694
+ index
695
+ }, {});
696
+ for (let node of nodes) {
697
+ index++;
698
+ yield node;
699
+ }
700
+ }
701
+ }
702
+ }
703
+ getKey(item, partialNode, state, parentKey) {
704
+ if (item.key != null)
705
+ return item.key;
706
+ if (partialNode.type === "cell" && partialNode.key != null)
707
+ return `${parentKey}${partialNode.key}`;
708
+ let v = partialNode.value;
709
+ if (v != null) {
710
+ var _v_key;
711
+ let key = (_v_key = v.key) !== null && _v_key !== void 0 ? _v_key : v.id;
712
+ if (key == null)
713
+ throw new Error("No key found for item");
714
+ return key;
715
+ }
716
+ return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
717
+ }
718
+ getChildState(state, partialNode) {
719
+ return {
720
+ renderer: partialNode.renderer || state.renderer
721
+ };
722
+ }
723
+ *getFullNode(partialNode, state, parentKey, parentNode) {
724
+ let element = partialNode.element;
725
+ if (!element && partialNode.value && state && state.renderer) {
726
+ let cached = this.cache.get(partialNode.value);
727
+ if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
728
+ cached.index = partialNode.index;
729
+ cached.parentKey = parentNode ? parentNode.key : null;
730
+ yield cached;
731
+ return;
732
+ }
733
+ element = state.renderer(partialNode.value);
734
+ }
735
+ if (React__default.isValidElement(element)) {
736
+ let type = element.type;
737
+ if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
738
+ let name = typeof element.type === "function" ? element.type.name : element.type;
739
+ throw new Error(`Unknown element <${name}> in collection.`);
740
+ }
741
+ let childNodes = type.getCollectionNode(element.props, this.context);
742
+ let index = partialNode.index;
743
+ let result = childNodes.next();
744
+ while (!result.done && result.value) {
745
+ let childNode = result.value;
746
+ partialNode.index = index;
747
+ let nodeKey = childNode.key;
748
+ if (!nodeKey)
749
+ nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
750
+ let nodes = this.getFullNode({
751
+ ...childNode,
752
+ key: nodeKey,
753
+ index,
754
+ wrapper: $eb2240fc39a57fa5$var$compose(partialNode.wrapper, childNode.wrapper)
755
+ }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
756
+ let children = [
757
+ ...nodes
758
+ ];
759
+ for (let node2 of children) {
760
+ node2.value = childNode.value || partialNode.value;
761
+ if (node2.value)
762
+ this.cache.set(node2.value, node2);
763
+ if (partialNode.type && node2.type !== partialNode.type)
764
+ throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node2.type)}> in <${$eb2240fc39a57fa5$var$capitalize(parentNode.type)}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
765
+ index++;
766
+ yield node2;
767
+ }
768
+ result = childNodes.next(children);
769
+ }
770
+ return;
771
+ }
772
+ if (partialNode.key == null)
773
+ return;
774
+ let builder = this;
775
+ let node = {
776
+ type: partialNode.type,
777
+ props: partialNode.props,
778
+ key: partialNode.key,
779
+ parentKey: parentNode ? parentNode.key : null,
780
+ value: partialNode.value,
781
+ level: parentNode ? parentNode.level + 1 : 0,
782
+ index: partialNode.index,
783
+ rendered: partialNode.rendered,
784
+ textValue: partialNode.textValue,
785
+ "aria-label": partialNode["aria-label"],
786
+ wrapper: partialNode.wrapper,
787
+ shouldInvalidate: partialNode.shouldInvalidate,
788
+ hasChildNodes: partialNode.hasChildNodes,
789
+ childNodes: $eb2240fc39a57fa5$var$iterable(function* () {
790
+ if (!partialNode.hasChildNodes)
791
+ return;
792
+ let index = 0;
793
+ for (let child of partialNode.childNodes()) {
794
+ if (child.key != null)
795
+ child.key = `${node.key}${child.key}`;
796
+ child.index = index;
797
+ let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
798
+ for (let node2 of nodes) {
799
+ index++;
800
+ yield node2;
801
+ }
802
+ }
803
+ })
804
+ };
805
+ yield node;
806
+ }
807
+ constructor() {
808
+ this.cache = /* @__PURE__ */ new WeakMap();
809
+ }
810
+ }
811
+ function $eb2240fc39a57fa5$var$iterable(iterator) {
812
+ let cache = [];
813
+ let iterable = null;
814
+ return {
815
+ *[Symbol.iterator]() {
816
+ for (let item of cache)
817
+ yield item;
818
+ if (!iterable)
819
+ iterable = iterator();
820
+ for (let item of iterable) {
821
+ cache.push(item);
822
+ yield item;
823
+ }
824
+ }
825
+ };
826
+ }
827
+ function $eb2240fc39a57fa5$var$compose(outer, inner) {
828
+ if (outer && inner)
829
+ return (element) => outer(inner(element));
830
+ if (outer)
831
+ return outer;
832
+ if (inner)
833
+ return inner;
834
+ }
835
+ function $eb2240fc39a57fa5$var$capitalize(str) {
836
+ return str[0].toUpperCase() + str.slice(1);
837
+ }
838
+ function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context) {
839
+ let builder = useMemo(() => new $eb2240fc39a57fa5$export$bf788dd355e3a401(), []);
840
+ let { children, items, collection } = props;
841
+ let result = useMemo(() => {
842
+ if (collection)
843
+ return collection;
844
+ let nodes = builder.build({
845
+ children,
846
+ items
847
+ }, context);
848
+ return factory(nodes);
849
+ }, [
850
+ builder,
851
+ children,
852
+ items,
853
+ collection,
854
+ context,
855
+ factory
856
+ ]);
857
+ return result;
858
+ }
859
+ function $c5a24bc478652b5f$export$1005530eda016c13(node, collection) {
860
+ if (typeof collection.getChildren === "function")
861
+ return collection.getChildren(node.key);
862
+ return node.childNodes;
863
+ }
864
+ function $c5a24bc478652b5f$export$fbdeaa6a76694f71(iterable) {
865
+ return $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable);
866
+ }
867
+ function $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, index) {
868
+ for (let item of iterable) {
869
+ return item;
870
+ }
871
+ }
872
+ function $c5a24bc478652b5f$export$7475b2c64539e4cf(iterable) {
873
+ let lastItem = void 0;
874
+ for (let value of iterable)
875
+ lastItem = value;
876
+ return lastItem;
877
+ }
878
+ function $c5a24bc478652b5f$export$8c434b3a7a4dad6(collection, a, b) {
879
+ if (a.parentKey === b.parentKey)
880
+ return a.index - b.index;
881
+ let aAncestors = [
882
+ ...$c5a24bc478652b5f$var$getAncestors(collection, a),
883
+ a
884
+ ];
885
+ let bAncestors = [
886
+ ...$c5a24bc478652b5f$var$getAncestors(collection, b),
887
+ b
888
+ ];
889
+ let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a2, i) => a2 !== bAncestors[i]);
890
+ if (firstNonMatchingAncestor !== -1) {
891
+ a = aAncestors[firstNonMatchingAncestor];
892
+ b = bAncestors[firstNonMatchingAncestor];
893
+ return a.index - b.index;
894
+ }
895
+ if (aAncestors.findIndex((node) => node === b) >= 0)
896
+ return 1;
897
+ else if (bAncestors.findIndex((node) => node === a) >= 0)
898
+ return -1;
899
+ return -1;
900
+ }
901
+ function $c5a24bc478652b5f$var$getAncestors(collection, node) {
902
+ let parents = [];
903
+ while ((node === null || node === void 0 ? void 0 : node.parentKey) != null) {
904
+ node = collection.getItem(node.parentKey);
905
+ parents.unshift(node);
906
+ }
907
+ return parents;
908
+ }
909
+ var shim = { exports: {} };
910
+ var useSyncExternalStoreShim_production_min = {};
911
+ /**
912
+ * @license React
913
+ * use-sync-external-store-shim.production.min.js
914
+ *
915
+ * Copyright (c) Facebook, Inc. and its affiliates.
916
+ *
917
+ * This source code is licensed under the MIT license found in the
918
+ * LICENSE file in the root directory of this source tree.
919
+ */
920
+ var hasRequiredUseSyncExternalStoreShim_production_min;
921
+ function requireUseSyncExternalStoreShim_production_min() {
922
+ if (hasRequiredUseSyncExternalStoreShim_production_min)
923
+ return useSyncExternalStoreShim_production_min;
924
+ hasRequiredUseSyncExternalStoreShim_production_min = 1;
925
+ var e = React__default;
926
+ function h(a, b) {
927
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
928
+ }
929
+ var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
930
+ function q(a, b) {
931
+ var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
932
+ n(function() {
933
+ c.value = d;
934
+ c.getSnapshot = b;
935
+ r(c) && g({ inst: c });
936
+ }, [a, d, b]);
937
+ m(function() {
938
+ r(c) && g({ inst: c });
939
+ return a(function() {
940
+ r(c) && g({ inst: c });
941
+ });
942
+ }, [a]);
943
+ p(d);
944
+ return d;
945
+ }
946
+ function r(a) {
947
+ var b = a.getSnapshot;
948
+ a = a.value;
949
+ try {
950
+ var d = b();
951
+ return !k(a, d);
952
+ } catch (f) {
953
+ return true;
954
+ }
955
+ }
956
+ function t(a, b) {
957
+ return b();
958
+ }
959
+ var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
960
+ useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
961
+ return useSyncExternalStoreShim_production_min;
962
+ }
963
+ var useSyncExternalStoreShim_development = {};
964
+ /**
965
+ * @license React
966
+ * use-sync-external-store-shim.development.js
967
+ *
968
+ * Copyright (c) Facebook, Inc. and its affiliates.
969
+ *
970
+ * This source code is licensed under the MIT license found in the
971
+ * LICENSE file in the root directory of this source tree.
972
+ */
973
+ var hasRequiredUseSyncExternalStoreShim_development;
974
+ function requireUseSyncExternalStoreShim_development() {
975
+ if (hasRequiredUseSyncExternalStoreShim_development)
976
+ return useSyncExternalStoreShim_development;
977
+ hasRequiredUseSyncExternalStoreShim_development = 1;
978
+ if (process.env.NODE_ENV !== "production") {
979
+ (function() {
980
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
981
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
982
+ }
983
+ var React = React__default;
984
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
985
+ function error(format) {
986
+ {
987
+ {
988
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
989
+ args[_key2 - 1] = arguments[_key2];
990
+ }
991
+ printWarning("error", format, args);
992
+ }
993
+ }
994
+ }
995
+ function printWarning(level, format, args) {
996
+ {
997
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
998
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
999
+ if (stack !== "") {
1000
+ format += "%s";
1001
+ args = args.concat([stack]);
1002
+ }
1003
+ var argsWithFormat = args.map(function(item) {
1004
+ return String(item);
1005
+ });
1006
+ argsWithFormat.unshift("Warning: " + format);
1007
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
1008
+ }
1009
+ }
1010
+ function is(x, y) {
1011
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
1012
+ }
1013
+ var objectIs = typeof Object.is === "function" ? Object.is : is;
1014
+ var useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
1015
+ var didWarnOld18Alpha = false;
1016
+ var didWarnUncachedGetSnapshot = false;
1017
+ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
1018
+ {
1019
+ if (!didWarnOld18Alpha) {
1020
+ if (React.startTransition !== void 0) {
1021
+ didWarnOld18Alpha = true;
1022
+ error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
1023
+ }
1024
+ }
1025
+ }
1026
+ var value = getSnapshot();
1027
+ {
1028
+ if (!didWarnUncachedGetSnapshot) {
1029
+ var cachedValue = getSnapshot();
1030
+ if (!objectIs(value, cachedValue)) {
1031
+ error("The result of getSnapshot should be cached to avoid an infinite loop");
1032
+ didWarnUncachedGetSnapshot = true;
1033
+ }
1034
+ }
1035
+ }
1036
+ var _useState = useState2({
1037
+ inst: {
1038
+ value,
1039
+ getSnapshot
1040
+ }
1041
+ }), inst = _useState[0].inst, forceUpdate = _useState[1];
1042
+ useLayoutEffect(function() {
1043
+ inst.value = value;
1044
+ inst.getSnapshot = getSnapshot;
1045
+ if (checkIfSnapshotChanged(inst)) {
1046
+ forceUpdate({
1047
+ inst
1048
+ });
1049
+ }
1050
+ }, [subscribe, value, getSnapshot]);
1051
+ useEffect2(function() {
1052
+ if (checkIfSnapshotChanged(inst)) {
1053
+ forceUpdate({
1054
+ inst
1055
+ });
1056
+ }
1057
+ var handleStoreChange = function() {
1058
+ if (checkIfSnapshotChanged(inst)) {
1059
+ forceUpdate({
1060
+ inst
1061
+ });
1062
+ }
1063
+ };
1064
+ return subscribe(handleStoreChange);
1065
+ }, [subscribe]);
1066
+ useDebugValue(value);
1067
+ return value;
1068
+ }
1069
+ function checkIfSnapshotChanged(inst) {
1070
+ var latestGetSnapshot = inst.getSnapshot;
1071
+ var prevValue = inst.value;
1072
+ try {
1073
+ var nextValue = latestGetSnapshot();
1074
+ return !objectIs(prevValue, nextValue);
1075
+ } catch (error2) {
1076
+ return true;
1077
+ }
1078
+ }
1079
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
1080
+ return getSnapshot();
1081
+ }
1082
+ var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
1083
+ var isServerEnvironment = !canUseDOM;
1084
+ var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
1085
+ var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
1086
+ useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
1087
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
1088
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
1089
+ }
1090
+ })();
1091
+ }
1092
+ return useSyncExternalStoreShim_development;
1093
+ }
1094
+ if (process.env.NODE_ENV === "production") {
1095
+ shim.exports = requireUseSyncExternalStoreShim_production_min();
1096
+ } else {
1097
+ shim.exports = requireUseSyncExternalStoreShim_development();
1098
+ }
1099
+ var shimExports = shim.exports;
1100
+ class $7135fc7d473fd974$export$f5d856d854e74713 {
1101
+ get childNodes() {
1102
+ throw new Error("childNodes is not supported");
1103
+ }
1104
+ clone() {
1105
+ let node = new $7135fc7d473fd974$export$f5d856d854e74713(this.type, this.key);
1106
+ node.value = this.value;
1107
+ node.level = this.level;
1108
+ node.hasChildNodes = this.hasChildNodes;
1109
+ node.rendered = this.rendered;
1110
+ node.textValue = this.textValue;
1111
+ node["aria-label"] = this["aria-label"];
1112
+ node.index = this.index;
1113
+ node.parentKey = this.parentKey;
1114
+ node.prevKey = this.prevKey;
1115
+ node.nextKey = this.nextKey;
1116
+ node.firstChildKey = this.firstChildKey;
1117
+ node.lastChildKey = this.lastChildKey;
1118
+ node.props = this.props;
1119
+ return node;
1120
+ }
1121
+ constructor(type, key) {
1122
+ this.value = null;
1123
+ this.level = 0;
1124
+ this.hasChildNodes = false;
1125
+ this.rendered = null;
1126
+ this.textValue = "";
1127
+ this["aria-label"] = void 0;
1128
+ this.index = 0;
1129
+ this.parentKey = null;
1130
+ this.prevKey = null;
1131
+ this.nextKey = null;
1132
+ this.firstChildKey = null;
1133
+ this.lastChildKey = null;
1134
+ this.props = {};
1135
+ this.type = type;
1136
+ this.key = key;
1137
+ }
1138
+ }
1139
+ class $7135fc7d473fd974$var$BaseNode {
1140
+ *[Symbol.iterator]() {
1141
+ let node = this.firstChild;
1142
+ while (node) {
1143
+ yield node;
1144
+ node = node.nextSibling;
1145
+ }
1146
+ }
1147
+ get firstChild() {
1148
+ return this._firstChild;
1149
+ }
1150
+ set firstChild(firstChild) {
1151
+ this._firstChild = firstChild;
1152
+ this.ownerDocument.markDirty(this);
1153
+ }
1154
+ get lastChild() {
1155
+ return this._lastChild;
1156
+ }
1157
+ set lastChild(lastChild) {
1158
+ this._lastChild = lastChild;
1159
+ this.ownerDocument.markDirty(this);
1160
+ }
1161
+ get previousSibling() {
1162
+ return this._previousSibling;
1163
+ }
1164
+ set previousSibling(previousSibling) {
1165
+ this._previousSibling = previousSibling;
1166
+ this.ownerDocument.markDirty(this);
1167
+ }
1168
+ get nextSibling() {
1169
+ return this._nextSibling;
1170
+ }
1171
+ set nextSibling(nextSibling) {
1172
+ this._nextSibling = nextSibling;
1173
+ this.ownerDocument.markDirty(this);
1174
+ }
1175
+ get parentNode() {
1176
+ return this._parentNode;
1177
+ }
1178
+ set parentNode(parentNode) {
1179
+ this._parentNode = parentNode;
1180
+ this.ownerDocument.markDirty(this);
1181
+ }
1182
+ get isConnected() {
1183
+ var _this_parentNode;
1184
+ return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
1185
+ }
1186
+ appendChild(child) {
1187
+ this.ownerDocument.startTransaction();
1188
+ if (child.parentNode)
1189
+ child.parentNode.removeChild(child);
1190
+ if (this.firstChild == null)
1191
+ this.firstChild = child;
1192
+ if (this.lastChild) {
1193
+ this.lastChild.nextSibling = child;
1194
+ child.index = this.lastChild.index + 1;
1195
+ child.previousSibling = this.lastChild;
1196
+ } else {
1197
+ child.previousSibling = null;
1198
+ child.index = 0;
1199
+ }
1200
+ child.parentNode = this;
1201
+ child.nextSibling = null;
1202
+ this.lastChild = child;
1203
+ this.ownerDocument.markDirty(this);
1204
+ if (child.hasSetProps)
1205
+ this.ownerDocument.addNode(child);
1206
+ this.ownerDocument.endTransaction();
1207
+ this.ownerDocument.queueUpdate();
1208
+ }
1209
+ insertBefore(newNode, referenceNode) {
1210
+ if (referenceNode == null)
1211
+ return this.appendChild(newNode);
1212
+ this.ownerDocument.startTransaction();
1213
+ if (newNode.parentNode)
1214
+ newNode.parentNode.removeChild(newNode);
1215
+ newNode.nextSibling = referenceNode;
1216
+ newNode.previousSibling = referenceNode.previousSibling;
1217
+ newNode.index = referenceNode.index;
1218
+ if (this.firstChild === referenceNode)
1219
+ this.firstChild = newNode;
1220
+ else if (referenceNode.previousSibling)
1221
+ referenceNode.previousSibling.nextSibling = newNode;
1222
+ referenceNode.previousSibling = newNode;
1223
+ newNode.parentNode = referenceNode.parentNode;
1224
+ let node = referenceNode;
1225
+ while (node) {
1226
+ node.index++;
1227
+ node = node.nextSibling;
1228
+ }
1229
+ if (newNode.hasSetProps)
1230
+ this.ownerDocument.addNode(newNode);
1231
+ this.ownerDocument.endTransaction();
1232
+ this.ownerDocument.queueUpdate();
1233
+ }
1234
+ removeChild(child) {
1235
+ if (child.parentNode !== this)
1236
+ return;
1237
+ this.ownerDocument.startTransaction();
1238
+ let node = child.nextSibling;
1239
+ while (node) {
1240
+ node.index--;
1241
+ node = node.nextSibling;
1242
+ }
1243
+ if (child.nextSibling)
1244
+ child.nextSibling.previousSibling = child.previousSibling;
1245
+ if (child.previousSibling)
1246
+ child.previousSibling.nextSibling = child.nextSibling;
1247
+ if (this.firstChild === child)
1248
+ this.firstChild = child.nextSibling;
1249
+ if (this.lastChild === child)
1250
+ this.lastChild = child.previousSibling;
1251
+ child.parentNode = null;
1252
+ child.nextSibling = null;
1253
+ child.previousSibling = null;
1254
+ child.index = 0;
1255
+ this.ownerDocument.removeNode(child);
1256
+ this.ownerDocument.endTransaction();
1257
+ this.ownerDocument.queueUpdate();
1258
+ }
1259
+ addEventListener() {
1260
+ }
1261
+ removeEventListener() {
1262
+ }
1263
+ constructor(ownerDocument) {
1264
+ this._firstChild = null;
1265
+ this._lastChild = null;
1266
+ this._previousSibling = null;
1267
+ this._nextSibling = null;
1268
+ this._parentNode = null;
1269
+ this.ownerDocument = ownerDocument;
1270
+ }
1271
+ }
1272
+ class $7135fc7d473fd974$export$dc064fe9e59310fd extends $7135fc7d473fd974$var$BaseNode {
1273
+ get index() {
1274
+ return this._index;
1275
+ }
1276
+ set index(index) {
1277
+ this._index = index;
1278
+ this.ownerDocument.markDirty(this);
1279
+ }
1280
+ get level() {
1281
+ if (this.parentNode instanceof $7135fc7d473fd974$export$dc064fe9e59310fd)
1282
+ return this.parentNode.level + (this.node.type === "item" ? 1 : 0);
1283
+ return 0;
1284
+ }
1285
+ updateNode() {
1286
+ var _this_previousSibling, _this_nextSibling, _this_firstChild, _this_lastChild;
1287
+ let node = this.ownerDocument.getMutableNode(this);
1288
+ node.index = this.index;
1289
+ node.level = this.level;
1290
+ node.parentKey = this.parentNode instanceof $7135fc7d473fd974$export$dc064fe9e59310fd ? this.parentNode.node.key : null;
1291
+ var _this_previousSibling_node_key;
1292
+ node.prevKey = (_this_previousSibling_node_key = (_this_previousSibling = this.previousSibling) === null || _this_previousSibling === void 0 ? void 0 : _this_previousSibling.node.key) !== null && _this_previousSibling_node_key !== void 0 ? _this_previousSibling_node_key : null;
1293
+ var _this_nextSibling_node_key;
1294
+ node.nextKey = (_this_nextSibling_node_key = (_this_nextSibling = this.nextSibling) === null || _this_nextSibling === void 0 ? void 0 : _this_nextSibling.node.key) !== null && _this_nextSibling_node_key !== void 0 ? _this_nextSibling_node_key : null;
1295
+ node.hasChildNodes = !!this.firstChild;
1296
+ var _this_firstChild_node_key;
1297
+ node.firstChildKey = (_this_firstChild_node_key = (_this_firstChild = this.firstChild) === null || _this_firstChild === void 0 ? void 0 : _this_firstChild.node.key) !== null && _this_firstChild_node_key !== void 0 ? _this_firstChild_node_key : null;
1298
+ var _this_lastChild_node_key;
1299
+ node.lastChildKey = (_this_lastChild_node_key = (_this_lastChild = this.lastChild) === null || _this_lastChild === void 0 ? void 0 : _this_lastChild.node.key) !== null && _this_lastChild_node_key !== void 0 ? _this_lastChild_node_key : null;
1300
+ }
1301
+ setProps(obj, ref, rendered) {
1302
+ let node = this.ownerDocument.getMutableNode(this);
1303
+ let { value, textValue, id, ...props } = obj;
1304
+ props.ref = ref;
1305
+ node.props = props;
1306
+ node.rendered = rendered;
1307
+ node.value = value;
1308
+ node.textValue = textValue || (typeof rendered === "string" ? rendered : "") || obj["aria-label"] || "";
1309
+ if (id != null && id !== node.key) {
1310
+ if (this.hasSetProps)
1311
+ throw new Error("Cannot change the id of an item");
1312
+ node.key = id;
1313
+ }
1314
+ if (!this.hasSetProps) {
1315
+ this.ownerDocument.addNode(this);
1316
+ this.ownerDocument.endTransaction();
1317
+ this.hasSetProps = true;
1318
+ }
1319
+ this.ownerDocument.queueUpdate();
1320
+ }
1321
+ get style() {
1322
+ return {};
1323
+ }
1324
+ hasAttribute() {
1325
+ }
1326
+ setAttribute() {
1327
+ }
1328
+ setAttributeNS() {
1329
+ }
1330
+ removeAttribute() {
1331
+ }
1332
+ constructor(type, ownerDocument) {
1333
+ super(ownerDocument);
1334
+ this.nodeType = 8;
1335
+ this._index = 0;
1336
+ this.hasSetProps = false;
1337
+ this.node = new $7135fc7d473fd974$export$f5d856d854e74713(type, `react-aria-${++ownerDocument.nodeId}`);
1338
+ this.ownerDocument.startTransaction();
1339
+ }
1340
+ }
1341
+ class $7135fc7d473fd974$export$408d25a4e12db025 {
1342
+ get size() {
1343
+ return this.keyMap.size;
1344
+ }
1345
+ getKeys() {
1346
+ return this.keyMap.keys();
1347
+ }
1348
+ *[Symbol.iterator]() {
1349
+ let node = this.firstKey != null ? this.keyMap.get(this.firstKey) : void 0;
1350
+ while (node) {
1351
+ yield node;
1352
+ node = node.nextKey != null ? this.keyMap.get(node.nextKey) : void 0;
1353
+ }
1354
+ }
1355
+ getChildren(key) {
1356
+ let keyMap = this.keyMap;
1357
+ return {
1358
+ *[Symbol.iterator]() {
1359
+ let parent = keyMap.get(key);
1360
+ let node = (parent === null || parent === void 0 ? void 0 : parent.firstChildKey) != null ? keyMap.get(parent.firstChildKey) : null;
1361
+ while (node) {
1362
+ yield node;
1363
+ node = node.nextKey != null ? keyMap.get(node.nextKey) : void 0;
1364
+ }
1365
+ }
1366
+ };
1367
+ }
1368
+ getKeyBefore(key) {
1369
+ let node = this.keyMap.get(key);
1370
+ if (!node)
1371
+ return null;
1372
+ if (node.prevKey != null) {
1373
+ node = this.keyMap.get(node.prevKey);
1374
+ while (node && node.type !== "item" && node.lastChildKey != null)
1375
+ node = this.keyMap.get(node.lastChildKey);
1376
+ var _node_key;
1377
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
1378
+ }
1379
+ return node.parentKey;
1380
+ }
1381
+ getKeyAfter(key) {
1382
+ let node = this.keyMap.get(key);
1383
+ if (!node)
1384
+ return null;
1385
+ if (node.type !== "item" && node.firstChildKey != null)
1386
+ return node.firstChildKey;
1387
+ while (node) {
1388
+ if (node.nextKey != null)
1389
+ return node.nextKey;
1390
+ if (node.parentKey != null)
1391
+ node = this.keyMap.get(node.parentKey);
1392
+ else
1393
+ return null;
1394
+ }
1395
+ return null;
1396
+ }
1397
+ getFirstKey() {
1398
+ return this.firstKey;
1399
+ }
1400
+ getLastKey() {
1401
+ let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;
1402
+ while ((node === null || node === void 0 ? void 0 : node.lastChildKey) != null)
1403
+ node = this.keyMap.get(node.lastChildKey);
1404
+ var _node_key;
1405
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
1406
+ }
1407
+ getItem(key) {
1408
+ var _this_keyMap_get;
1409
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
1410
+ }
1411
+ at() {
1412
+ throw new Error("Not implemented");
1413
+ }
1414
+ clone() {
1415
+ let Constructor = this.constructor;
1416
+ let collection = new Constructor();
1417
+ collection.keyMap = new Map(this.keyMap);
1418
+ collection.firstKey = this.firstKey;
1419
+ collection.lastKey = this.lastKey;
1420
+ return collection;
1421
+ }
1422
+ addNode(node) {
1423
+ if (this.frozen)
1424
+ throw new Error("Cannot add a node to a frozen collection");
1425
+ this.keyMap.set(node.key, node);
1426
+ }
1427
+ removeNode(key) {
1428
+ if (this.frozen)
1429
+ throw new Error("Cannot remove a node to a frozen collection");
1430
+ this.keyMap.delete(key);
1431
+ }
1432
+ commit(firstKey, lastKey, isSSR = false) {
1433
+ if (this.frozen)
1434
+ throw new Error("Cannot commit a frozen collection");
1435
+ this.firstKey = firstKey;
1436
+ this.lastKey = lastKey;
1437
+ this.frozen = !isSSR;
1438
+ }
1439
+ constructor() {
1440
+ this.keyMap = /* @__PURE__ */ new Map();
1441
+ this.firstKey = null;
1442
+ this.lastKey = null;
1443
+ this.frozen = false;
1444
+ }
1445
+ }
1446
+ class $7135fc7d473fd974$export$b34a105447964f9f extends $7135fc7d473fd974$var$BaseNode {
1447
+ get isConnected() {
1448
+ return true;
1449
+ }
1450
+ createElement(type) {
1451
+ return new $7135fc7d473fd974$export$dc064fe9e59310fd(type, this);
1452
+ }
1453
+ /**
1454
+ * Lazily gets a mutable instance of a Node. If the node has already
1455
+ * been cloned during this update cycle, it just returns the existing one.
1456
+ */
1457
+ getMutableNode(element) {
1458
+ let node = element.node;
1459
+ if (!this.mutatedNodes.has(element)) {
1460
+ node = element.node.clone();
1461
+ this.mutatedNodes.add(element);
1462
+ element.node = node;
1463
+ }
1464
+ this.markDirty(element);
1465
+ return node;
1466
+ }
1467
+ getMutableCollection() {
1468
+ if (!this.isSSR && !this.collectionMutated) {
1469
+ this.collection = this.collection.clone();
1470
+ this.collectionMutated = true;
1471
+ }
1472
+ return this.collection;
1473
+ }
1474
+ markDirty(node) {
1475
+ this.dirtyNodes.add(node);
1476
+ }
1477
+ startTransaction() {
1478
+ this.transactionCount++;
1479
+ }
1480
+ endTransaction() {
1481
+ this.transactionCount--;
1482
+ }
1483
+ addNode(element) {
1484
+ let collection = this.getMutableCollection();
1485
+ if (!collection.getItem(element.node.key)) {
1486
+ collection.addNode(element.node);
1487
+ for (let child of element)
1488
+ this.addNode(child);
1489
+ }
1490
+ this.markDirty(element);
1491
+ }
1492
+ removeNode(node) {
1493
+ for (let child of node)
1494
+ this.removeNode(child);
1495
+ let collection = this.getMutableCollection();
1496
+ collection.removeNode(node.node.key);
1497
+ this.markDirty(node);
1498
+ }
1499
+ /** Finalizes the collection update, updating all nodes and freezing the collection. */
1500
+ getCollection() {
1501
+ if (this.transactionCount > 0)
1502
+ return this.collection;
1503
+ this.updateCollection();
1504
+ return this.collection;
1505
+ }
1506
+ updateCollection() {
1507
+ for (let element of this.dirtyNodes)
1508
+ if (element instanceof $7135fc7d473fd974$export$dc064fe9e59310fd && element.isConnected)
1509
+ element.updateNode();
1510
+ this.dirtyNodes.clear();
1511
+ if (this.mutatedNodes.size || this.collectionMutated) {
1512
+ var _this_firstChild, _this_lastChild;
1513
+ let collection = this.getMutableCollection();
1514
+ for (let element of this.mutatedNodes)
1515
+ if (element.isConnected)
1516
+ collection.addNode(element.node);
1517
+ var _this_firstChild_node_key, _this_lastChild_node_key;
1518
+ collection.commit((_this_firstChild_node_key = (_this_firstChild = this.firstChild) === null || _this_firstChild === void 0 ? void 0 : _this_firstChild.node.key) !== null && _this_firstChild_node_key !== void 0 ? _this_firstChild_node_key : null, (_this_lastChild_node_key = (_this_lastChild = this.lastChild) === null || _this_lastChild === void 0 ? void 0 : _this_lastChild.node.key) !== null && _this_lastChild_node_key !== void 0 ? _this_lastChild_node_key : null, this.isSSR);
1519
+ this.mutatedNodes.clear();
1520
+ }
1521
+ this.collectionMutated = false;
1522
+ }
1523
+ queueUpdate() {
1524
+ if (this.dirtyNodes.size === 0 || this.transactionCount > 0)
1525
+ return;
1526
+ for (let fn of this.subscriptions)
1527
+ fn();
1528
+ }
1529
+ subscribe(fn) {
1530
+ this.subscriptions.add(fn);
1531
+ return () => this.subscriptions.delete(fn);
1532
+ }
1533
+ resetAfterSSR() {
1534
+ if (this.isSSR) {
1535
+ this.isSSR = false;
1536
+ this.firstChild = null;
1537
+ this.lastChild = null;
1538
+ this.nodeId = 0;
1539
+ }
1540
+ }
1541
+ constructor(collection) {
1542
+ super(null);
1543
+ this.nodeType = 11;
1544
+ this.ownerDocument = this;
1545
+ this.dirtyNodes = /* @__PURE__ */ new Set();
1546
+ this.isSSR = false;
1547
+ this.nodeId = 0;
1548
+ this.nodesByProps = /* @__PURE__ */ new WeakMap();
1549
+ this.mutatedNodes = /* @__PURE__ */ new Set();
1550
+ this.subscriptions = /* @__PURE__ */ new Set();
1551
+ this.transactionCount = 0;
1552
+ this.collection = collection;
1553
+ this.collectionMutated = true;
1554
+ }
1555
+ }
1556
+ function $7135fc7d473fd974$export$727c8fc270210f13(props) {
1557
+ let { children, items, idScope, addIdAndValue, dependencies = [] } = props;
1558
+ let cache = useMemo(() => /* @__PURE__ */ new WeakMap(), dependencies);
1559
+ return useMemo(() => {
1560
+ if (items && typeof children === "function") {
1561
+ let res = [];
1562
+ for (let item of items) {
1563
+ let rendered = cache.get(item);
1564
+ if (!rendered) {
1565
+ rendered = children(item);
1566
+ var _rendered_props_id, _ref;
1567
+ let key = (_ref = (_rendered_props_id = rendered.props.id) !== null && _rendered_props_id !== void 0 ? _rendered_props_id : item.key) !== null && _ref !== void 0 ? _ref : item.id;
1568
+ if (key == null)
1569
+ throw new Error("Could not determine key for item");
1570
+ if (idScope)
1571
+ key = idScope + ":" + key;
1572
+ rendered = /* @__PURE__ */ cloneElement(rendered, addIdAndValue ? {
1573
+ key,
1574
+ id: key,
1575
+ value: item
1576
+ } : {
1577
+ key
1578
+ });
1579
+ cache.set(item, rendered);
1580
+ }
1581
+ res.push(rendered);
1582
+ }
1583
+ return res;
1584
+ } else if (typeof children !== "function")
1585
+ return children;
1586
+ }, [
1587
+ children,
1588
+ items,
1589
+ cache,
1590
+ idScope,
1591
+ addIdAndValue
1592
+ ]);
1593
+ }
1594
+ function $7135fc7d473fd974$export$901dbff4e54a6dd0(props) {
1595
+ return $7135fc7d473fd974$export$727c8fc270210f13({
1596
+ ...props,
1597
+ addIdAndValue: true
1598
+ });
1599
+ }
1600
+ const $7135fc7d473fd974$var$ShallowRenderContext = /* @__PURE__ */ createContext(false);
1601
+ function $7135fc7d473fd974$export$6cd28814d92fa9c9(props, initialCollection) {
1602
+ let { collection, document: document2 } = $7135fc7d473fd974$export$7cd71aa5ddd6dc4e(initialCollection);
1603
+ let portal = $7135fc7d473fd974$export$ad42d5efb4461b31(props, document2);
1604
+ return {
1605
+ portal,
1606
+ collection
1607
+ };
1608
+ }
1609
+ function $7135fc7d473fd974$var$useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
1610
+ let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
1611
+ let isSSRRef = useRef(isSSR);
1612
+ isSSRRef.current = isSSR;
1613
+ let getSnapshotWrapper = useCallback(() => {
1614
+ return isSSRRef.current ? getServerSnapshot() : getSnapshot();
1615
+ }, [
1616
+ getSnapshot,
1617
+ getServerSnapshot
1618
+ ]);
1619
+ return shimExports.useSyncExternalStore(subscribe, getSnapshotWrapper);
1620
+ }
1621
+ const $7135fc7d473fd974$var$useSyncExternalStore = typeof React__default["useSyncExternalStore"] === "function" ? React__default["useSyncExternalStore"] : $7135fc7d473fd974$var$useSyncExternalStoreFallback;
1622
+ function $7135fc7d473fd974$export$7cd71aa5ddd6dc4e(initialCollection) {
1623
+ let document2 = useMemo(() => new $7135fc7d473fd974$export$b34a105447964f9f(initialCollection || new $7135fc7d473fd974$export$408d25a4e12db025()), [
1624
+ initialCollection
1625
+ ]);
1626
+ let subscribe = useCallback((fn) => document2.subscribe(fn), [
1627
+ document2
1628
+ ]);
1629
+ let getSnapshot = useCallback(() => {
1630
+ let collection2 = document2.getCollection();
1631
+ if (document2.isSSR)
1632
+ document2.resetAfterSSR();
1633
+ return collection2;
1634
+ }, [
1635
+ document2
1636
+ ]);
1637
+ let getServerSnapshot = useCallback(() => {
1638
+ document2.isSSR = true;
1639
+ return document2.getCollection();
1640
+ }, [
1641
+ document2
1642
+ ]);
1643
+ let collection = $7135fc7d473fd974$var$useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
1644
+ return {
1645
+ collection,
1646
+ document: document2
1647
+ };
1648
+ }
1649
+ const $7135fc7d473fd974$var$SSRContext = /* @__PURE__ */ createContext(null);
1650
+ const $7135fc7d473fd974$export$8c25dea96356a8b6 = /* @__PURE__ */ createContext(null);
1651
+ function $7135fc7d473fd974$export$ad42d5efb4461b31(props, document2) {
1652
+ let ctx = useContext($7135fc7d473fd974$export$8c25dea96356a8b6);
1653
+ let doc = document2 !== null && document2 !== void 0 ? document2 : ctx;
1654
+ let children = $7135fc7d473fd974$export$901dbff4e54a6dd0(props);
1655
+ let wrappedChildren = useMemo(() => /* @__PURE__ */ React__default.createElement($7135fc7d473fd974$var$ShallowRenderContext.Provider, {
1656
+ value: true
1657
+ }, children), [
1658
+ children
1659
+ ]);
1660
+ return $b5e257d569688ac6$export$535bd6ca7f90a273() ? /* @__PURE__ */ React__default.createElement($7135fc7d473fd974$var$SSRContext.Provider, {
1661
+ value: doc
1662
+ }, wrappedChildren) : /* @__PURE__ */ reactDomExports.createPortal(wrappedChildren, doc);
1663
+ }
1664
+ function $7135fc7d473fd974$export$813b5978dd974d8(props) {
1665
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, $7135fc7d473fd974$export$ad42d5efb4461b31(props));
1666
+ }
1667
+ function $7135fc7d473fd974$export$aeba0b1fb3dcd8b8(type, props, ref) {
1668
+ let isShallow = useContext($7135fc7d473fd974$var$ShallowRenderContext);
1669
+ var _useSSRCollectionNode;
1670
+ if (isShallow)
1671
+ return (_useSSRCollectionNode = $7135fc7d473fd974$export$e7c29ae2353b16ea(type, props, ref, "children" in props ? props.children : null)) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
1672
+ return null;
1673
+ }
1674
+ function $7135fc7d473fd974$export$636783d3732b5559(props, ref, rendered) {
1675
+ return useCallback((element) => {
1676
+ element === null || element === void 0 ? void 0 : element.setProps(props, ref, rendered);
1677
+ }, [
1678
+ props,
1679
+ ref,
1680
+ rendered
1681
+ ]);
1682
+ }
1683
+ function $7135fc7d473fd974$export$e7c29ae2353b16ea(Type, props, ref, rendered, children) {
1684
+ let itemRef = $7135fc7d473fd974$export$636783d3732b5559(props, ref, rendered);
1685
+ let parentNode = useContext($7135fc7d473fd974$var$SSRContext);
1686
+ if (parentNode) {
1687
+ let element = parentNode.ownerDocument.nodesByProps.get(props);
1688
+ if (!element) {
1689
+ element = parentNode.ownerDocument.createElement(Type);
1690
+ element.setProps(props, ref, rendered);
1691
+ parentNode.appendChild(element);
1692
+ parentNode.ownerDocument.updateCollection();
1693
+ parentNode.ownerDocument.nodesByProps.set(props, element);
1694
+ }
1695
+ return children ? /* @__PURE__ */ React__default.createElement($7135fc7d473fd974$var$SSRContext.Provider, {
1696
+ value: element
1697
+ }, children) : null;
1698
+ }
1699
+ return /* @__PURE__ */ React__default.createElement(Type, {
1700
+ ref: itemRef
1701
+ }, children);
1702
+ }
1703
+ function $7135fc7d473fd974$var$Section(props, ref) {
1704
+ let children = $7135fc7d473fd974$export$901dbff4e54a6dd0(props);
1705
+ return $7135fc7d473fd974$export$e7c29ae2353b16ea("section", props, ref, null, children);
1706
+ }
1707
+ const $7135fc7d473fd974$export$6e2c8f0811a474ce = /* @__PURE__ */ forwardRef($7135fc7d473fd974$var$Section);
1708
+ class $e40ea825a81a3709$export$52baac22726c72bf extends Set {
1709
+ constructor(keys, anchorKey, currentKey) {
1710
+ super(keys);
1711
+ if (keys instanceof $e40ea825a81a3709$export$52baac22726c72bf) {
1712
+ this.anchorKey = anchorKey || keys.anchorKey;
1713
+ this.currentKey = currentKey || keys.currentKey;
1714
+ } else {
1715
+ this.anchorKey = anchorKey;
1716
+ this.currentKey = currentKey;
1717
+ }
1718
+ }
1719
+ }
1720
+ function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
1721
+ if (setA.size !== setB.size)
1722
+ return false;
1723
+ for (let item of setA) {
1724
+ if (!setB.has(item))
1725
+ return false;
1726
+ }
1727
+ return true;
1728
+ }
1729
+ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
1730
+ let { selectionMode = "none", disallowEmptySelection, allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior = "all" } = props;
1731
+ let isFocusedRef = useRef(false);
1732
+ let [, setFocused] = useState(false);
1733
+ let focusedKeyRef = useRef(null);
1734
+ let childFocusStrategyRef = useRef(null);
1735
+ let [, setFocusedKey] = useState(null);
1736
+ let selectedKeysProp = useMemo(() => $7af3f5b51489e0b5$var$convertSelection(props.selectedKeys), [
1737
+ props.selectedKeys
1738
+ ]);
1739
+ let defaultSelectedKeys = useMemo(() => $7af3f5b51489e0b5$var$convertSelection(props.defaultSelectedKeys, new $e40ea825a81a3709$export$52baac22726c72bf()), [
1740
+ props.defaultSelectedKeys
1741
+ ]);
1742
+ let [selectedKeys, setSelectedKeys] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
1743
+ let disabledKeysProp = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
1744
+ props.disabledKeys
1745
+ ]);
1746
+ let [selectionBehavior, setSelectionBehavior] = useState(selectionBehaviorProp);
1747
+ if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0)
1748
+ setSelectionBehavior("replace");
1749
+ let lastSelectionBehavior = useRef(selectionBehaviorProp);
1750
+ useEffect(() => {
1751
+ if (selectionBehaviorProp !== lastSelectionBehavior.current) {
1752
+ setSelectionBehavior(selectionBehaviorProp);
1753
+ lastSelectionBehavior.current = selectionBehaviorProp;
1754
+ }
1755
+ }, [
1756
+ selectionBehaviorProp
1757
+ ]);
1758
+ return {
1759
+ selectionMode,
1760
+ disallowEmptySelection,
1761
+ selectionBehavior,
1762
+ setSelectionBehavior,
1763
+ get isFocused() {
1764
+ return isFocusedRef.current;
1765
+ },
1766
+ setFocused(f) {
1767
+ isFocusedRef.current = f;
1768
+ setFocused(f);
1769
+ },
1770
+ get focusedKey() {
1771
+ return focusedKeyRef.current;
1772
+ },
1773
+ get childFocusStrategy() {
1774
+ return childFocusStrategyRef.current;
1775
+ },
1776
+ setFocusedKey(k, childFocusStrategy = "first") {
1777
+ focusedKeyRef.current = k;
1778
+ childFocusStrategyRef.current = childFocusStrategy;
1779
+ setFocusedKey(k);
1780
+ },
1781
+ selectedKeys,
1782
+ setSelectedKeys(keys) {
1783
+ if (allowDuplicateSelectionEvents || !$7af3f5b51489e0b5$var$equalSets(keys, selectedKeys))
1784
+ setSelectedKeys(keys);
1785
+ },
1786
+ disabledKeys: disabledKeysProp,
1787
+ disabledBehavior
1788
+ };
1789
+ }
1790
+ function $7af3f5b51489e0b5$var$convertSelection(selection, defaultValue) {
1791
+ if (!selection)
1792
+ return defaultValue;
1793
+ return selection === "all" ? "all" : new $e40ea825a81a3709$export$52baac22726c72bf(selection);
1794
+ }
1795
+ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
1796
+ /**
1797
+ * The type of selection that is allowed in the collection.
1798
+ */
1799
+ get selectionMode() {
1800
+ return this.state.selectionMode;
1801
+ }
1802
+ /**
1803
+ * Whether the collection allows empty selection.
1804
+ */
1805
+ get disallowEmptySelection() {
1806
+ return this.state.disallowEmptySelection;
1807
+ }
1808
+ /**
1809
+ * The selection behavior for the collection.
1810
+ */
1811
+ get selectionBehavior() {
1812
+ return this.state.selectionBehavior;
1813
+ }
1814
+ /**
1815
+ * Sets the selection behavior for the collection.
1816
+ */
1817
+ setSelectionBehavior(selectionBehavior) {
1818
+ this.state.setSelectionBehavior(selectionBehavior);
1819
+ }
1820
+ /**
1821
+ * Whether the collection is currently focused.
1822
+ */
1823
+ get isFocused() {
1824
+ return this.state.isFocused;
1825
+ }
1826
+ /**
1827
+ * Sets whether the collection is focused.
1828
+ */
1829
+ setFocused(isFocused) {
1830
+ this.state.setFocused(isFocused);
1831
+ }
1832
+ /**
1833
+ * The current focused key in the collection.
1834
+ */
1835
+ get focusedKey() {
1836
+ return this.state.focusedKey;
1837
+ }
1838
+ /** Whether the first or last child of the focused key should receive focus. */
1839
+ get childFocusStrategy() {
1840
+ return this.state.childFocusStrategy;
1841
+ }
1842
+ /**
1843
+ * Sets the focused key.
1844
+ */
1845
+ setFocusedKey(key, childFocusStrategy) {
1846
+ if (key == null || this.collection.getItem(key))
1847
+ this.state.setFocusedKey(key, childFocusStrategy);
1848
+ }
1849
+ /**
1850
+ * The currently selected keys in the collection.
1851
+ */
1852
+ get selectedKeys() {
1853
+ return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
1854
+ }
1855
+ /**
1856
+ * The raw selection value for the collection.
1857
+ * Either 'all' for select all, or a set of keys.
1858
+ */
1859
+ get rawSelection() {
1860
+ return this.state.selectedKeys;
1861
+ }
1862
+ /**
1863
+ * Returns whether a key is selected.
1864
+ */
1865
+ isSelected(key) {
1866
+ if (this.state.selectionMode === "none")
1867
+ return false;
1868
+ key = this.getKey(key);
1869
+ return this.state.selectedKeys === "all" ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
1870
+ }
1871
+ /**
1872
+ * Whether the selection is empty.
1873
+ */
1874
+ get isEmpty() {
1875
+ return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
1876
+ }
1877
+ /**
1878
+ * Whether all items in the collection are selected.
1879
+ */
1880
+ get isSelectAll() {
1881
+ if (this.isEmpty)
1882
+ return false;
1883
+ if (this.state.selectedKeys === "all")
1884
+ return true;
1885
+ if (this._isSelectAll != null)
1886
+ return this._isSelectAll;
1887
+ let allKeys = this.getSelectAllKeys();
1888
+ let selectedKeys = this.state.selectedKeys;
1889
+ this._isSelectAll = allKeys.every((k) => selectedKeys.has(k));
1890
+ return this._isSelectAll;
1891
+ }
1892
+ get firstSelectedKey() {
1893
+ let first = null;
1894
+ for (let key of this.state.selectedKeys) {
1895
+ let item = this.collection.getItem(key);
1896
+ if (!first || item && $c5a24bc478652b5f$export$8c434b3a7a4dad6(this.collection, item, first) < 0)
1897
+ first = item;
1898
+ }
1899
+ return first === null || first === void 0 ? void 0 : first.key;
1900
+ }
1901
+ get lastSelectedKey() {
1902
+ let last = null;
1903
+ for (let key of this.state.selectedKeys) {
1904
+ let item = this.collection.getItem(key);
1905
+ if (!last || item && $c5a24bc478652b5f$export$8c434b3a7a4dad6(this.collection, item, last) > 0)
1906
+ last = item;
1907
+ }
1908
+ return last === null || last === void 0 ? void 0 : last.key;
1909
+ }
1910
+ get disabledKeys() {
1911
+ return this.state.disabledKeys;
1912
+ }
1913
+ get disabledBehavior() {
1914
+ return this.state.disabledBehavior;
1915
+ }
1916
+ /**
1917
+ * Extends the selection to the given key.
1918
+ */
1919
+ extendSelection(toKey) {
1920
+ if (this.selectionMode === "none")
1921
+ return;
1922
+ if (this.selectionMode === "single") {
1923
+ this.replaceSelection(toKey);
1924
+ return;
1925
+ }
1926
+ toKey = this.getKey(toKey);
1927
+ let selection;
1928
+ if (this.state.selectedKeys === "all")
1929
+ selection = new $e40ea825a81a3709$export$52baac22726c72bf([
1930
+ toKey
1931
+ ], toKey, toKey);
1932
+ else {
1933
+ let selectedKeys = this.state.selectedKeys;
1934
+ let anchorKey = selectedKeys.anchorKey || toKey;
1935
+ selection = new $e40ea825a81a3709$export$52baac22726c72bf(selectedKeys, anchorKey, toKey);
1936
+ for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))
1937
+ selection.delete(key);
1938
+ for (let key of this.getKeyRange(toKey, anchorKey))
1939
+ if (this.canSelectItem(key))
1940
+ selection.add(key);
1941
+ }
1942
+ this.state.setSelectedKeys(selection);
1943
+ }
1944
+ getKeyRange(from, to) {
1945
+ let fromItem = this.collection.getItem(from);
1946
+ let toItem = this.collection.getItem(to);
1947
+ if (fromItem && toItem) {
1948
+ if ($c5a24bc478652b5f$export$8c434b3a7a4dad6(this.collection, fromItem, toItem) <= 0)
1949
+ return this.getKeyRangeInternal(from, to);
1950
+ return this.getKeyRangeInternal(to, from);
1951
+ }
1952
+ return [];
1953
+ }
1954
+ getKeyRangeInternal(from, to) {
1955
+ let keys = [];
1956
+ let key = from;
1957
+ while (key) {
1958
+ let item = this.collection.getItem(key);
1959
+ if (item && item.type === "item" || item.type === "cell" && this.allowsCellSelection)
1960
+ keys.push(key);
1961
+ if (key === to)
1962
+ return keys;
1963
+ key = this.collection.getKeyAfter(key);
1964
+ }
1965
+ return [];
1966
+ }
1967
+ getKey(key) {
1968
+ let item = this.collection.getItem(key);
1969
+ if (!item)
1970
+ return key;
1971
+ if (item.type === "cell" && this.allowsCellSelection)
1972
+ return key;
1973
+ while (item.type !== "item" && item.parentKey != null)
1974
+ item = this.collection.getItem(item.parentKey);
1975
+ if (!item || item.type !== "item")
1976
+ return null;
1977
+ return item.key;
1978
+ }
1979
+ /**
1980
+ * Toggles whether the given key is selected.
1981
+ */
1982
+ toggleSelection(key) {
1983
+ if (this.selectionMode === "none")
1984
+ return;
1985
+ if (this.selectionMode === "single" && !this.isSelected(key)) {
1986
+ this.replaceSelection(key);
1987
+ return;
1988
+ }
1989
+ key = this.getKey(key);
1990
+ if (key == null)
1991
+ return;
1992
+ let keys = new $e40ea825a81a3709$export$52baac22726c72bf(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
1993
+ if (keys.has(key))
1994
+ keys.delete(key);
1995
+ else if (this.canSelectItem(key)) {
1996
+ keys.add(key);
1997
+ keys.anchorKey = key;
1998
+ keys.currentKey = key;
1999
+ }
2000
+ if (this.disallowEmptySelection && keys.size === 0)
2001
+ return;
2002
+ this.state.setSelectedKeys(keys);
2003
+ }
2004
+ /**
2005
+ * Replaces the selection with only the given key.
2006
+ */
2007
+ replaceSelection(key) {
2008
+ if (this.selectionMode === "none")
2009
+ return;
2010
+ key = this.getKey(key);
2011
+ if (key == null)
2012
+ return;
2013
+ let selection = this.canSelectItem(key) ? new $e40ea825a81a3709$export$52baac22726c72bf([
2014
+ key
2015
+ ], key, key) : new $e40ea825a81a3709$export$52baac22726c72bf();
2016
+ this.state.setSelectedKeys(selection);
2017
+ }
2018
+ /**
2019
+ * Replaces the selection with the given keys.
2020
+ */
2021
+ setSelectedKeys(keys) {
2022
+ if (this.selectionMode === "none")
2023
+ return;
2024
+ let selection = new $e40ea825a81a3709$export$52baac22726c72bf();
2025
+ for (let key of keys) {
2026
+ key = this.getKey(key);
2027
+ if (key != null) {
2028
+ selection.add(key);
2029
+ if (this.selectionMode === "single")
2030
+ break;
2031
+ }
2032
+ }
2033
+ this.state.setSelectedKeys(selection);
2034
+ }
2035
+ getSelectAllKeys() {
2036
+ let keys = [];
2037
+ let addKeys = (key) => {
2038
+ while (key) {
2039
+ if (this.canSelectItem(key)) {
2040
+ let item = this.collection.getItem(key);
2041
+ if (item.type === "item")
2042
+ keys.push(key);
2043
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== "item"))
2044
+ addKeys($c5a24bc478652b5f$export$fbdeaa6a76694f71($c5a24bc478652b5f$export$1005530eda016c13(item, this.collection)).key);
2045
+ }
2046
+ key = this.collection.getKeyAfter(key);
2047
+ }
2048
+ };
2049
+ addKeys(this.collection.getFirstKey());
2050
+ return keys;
2051
+ }
2052
+ /**
2053
+ * Selects all items in the collection.
2054
+ */
2055
+ selectAll() {
2056
+ if (!this.isSelectAll && this.selectionMode === "multiple")
2057
+ this.state.setSelectedKeys("all");
2058
+ }
2059
+ /**
2060
+ * Removes all keys from the selection.
2061
+ */
2062
+ clearSelection() {
2063
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0))
2064
+ this.state.setSelectedKeys(new $e40ea825a81a3709$export$52baac22726c72bf());
2065
+ }
2066
+ /**
2067
+ * Toggles between select all and an empty selection.
2068
+ */
2069
+ toggleSelectAll() {
2070
+ if (this.isSelectAll)
2071
+ this.clearSelection();
2072
+ else
2073
+ this.selectAll();
2074
+ }
2075
+ select(key, e) {
2076
+ if (this.selectionMode === "none")
2077
+ return;
2078
+ if (this.selectionMode === "single") {
2079
+ if (this.isSelected(key) && !this.disallowEmptySelection)
2080
+ this.toggleSelection(key);
2081
+ else
2082
+ this.replaceSelection(key);
2083
+ } else if (this.selectionBehavior === "toggle" || e && (e.pointerType === "touch" || e.pointerType === "virtual"))
2084
+ this.toggleSelection(key);
2085
+ else
2086
+ this.replaceSelection(key);
2087
+ }
2088
+ /**
2089
+ * Returns whether the current selection is equal to the given selection.
2090
+ */
2091
+ isSelectionEqual(selection) {
2092
+ if (selection === this.state.selectedKeys)
2093
+ return true;
2094
+ let selectedKeys = this.selectedKeys;
2095
+ if (selection.size !== selectedKeys.size)
2096
+ return false;
2097
+ for (let key of selection) {
2098
+ if (!selectedKeys.has(key))
2099
+ return false;
2100
+ }
2101
+ for (let key of selectedKeys) {
2102
+ if (!selection.has(key))
2103
+ return false;
2104
+ }
2105
+ return true;
2106
+ }
2107
+ canSelectItem(key) {
2108
+ var _item_props;
2109
+ if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key))
2110
+ return false;
2111
+ let item = this.collection.getItem(key);
2112
+ if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === "cell" && !this.allowsCellSelection)
2113
+ return false;
2114
+ return true;
2115
+ }
2116
+ isDisabled(key) {
2117
+ var _this_collection_getItem_props, _this_collection_getItem;
2118
+ return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
2119
+ }
2120
+ isLink(key) {
2121
+ var _this_collection_getItem_props, _this_collection_getItem;
2122
+ return !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.href);
2123
+ }
2124
+ getItemProps(key) {
2125
+ var _this_collection_getItem;
2126
+ return (_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : _this_collection_getItem.props;
2127
+ }
2128
+ constructor(collection, state, options) {
2129
+ this.collection = collection;
2130
+ this.state = state;
2131
+ var _options_allowsCellSelection;
2132
+ this.allowsCellSelection = (_options_allowsCellSelection = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && _options_allowsCellSelection !== void 0 ? _options_allowsCellSelection : false;
2133
+ this._isSelectAll = null;
2134
+ }
2135
+ }
2136
+ export {
2137
+ $7af3f5b51489e0b5$export$253fe78d46329472 as $,
2138
+ $7613b1592d41b092$export$6cd28814d92fa9c9 as a,
2139
+ $d496c0a20b6e58ec$export$6c8a5aaad13c9852 as b,
2140
+ $ae20dd8cbca75726$export$d6daf82dcd84e87c as c,
2141
+ $c5a24bc478652b5f$export$1005530eda016c13 as d,
2142
+ $7135fc7d473fd974$export$aeba0b1fb3dcd8b8 as e,
2143
+ $880e95eb8b93ba9a$export$ecf600387e221c37 as f,
2144
+ $7135fc7d473fd974$export$7cd71aa5ddd6dc4e as g,
2145
+ $7135fc7d473fd974$export$8c25dea96356a8b6 as h,
2146
+ $7135fc7d473fd974$export$813b5978dd974d8 as i,
2147
+ $7135fc7d473fd974$export$e7c29ae2353b16ea as j,
2148
+ $ef06256079686ba0$export$f8aeda7b10753fa1 as k,
2149
+ $c5a24bc478652b5f$export$7475b2c64539e4cf as l,
2150
+ $2f04cbc44ee30ce0$export$c826860796309d1b as m,
2151
+ $7135fc7d473fd974$export$6cd28814d92fa9c9 as n,
2152
+ $7135fc7d473fd974$export$727c8fc270210f13 as o,
2153
+ $8a26561d2877236e$export$c24ed0104d07eab9 as p,
2154
+ $7135fc7d473fd974$export$6e2c8f0811a474ce as q
2155
+ };