@eightshift/ui-components 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/Button-BpwTmkAe.js +185 -0
  2. package/dist/Collection-n5d0zIgb.js +2398 -0
  3. package/dist/Color-lVhk8V_G.js +2452 -0
  4. package/dist/ColorSwatch-DntWEAC3.js +64 -0
  5. package/dist/ComboBox-BJpTEATT.js +1915 -0
  6. package/dist/Dialog-O9uw63D7.js +2317 -0
  7. package/dist/FieldError-DHrSdE_Q.js +42 -0
  8. package/dist/FocusScope-BEPI2m7u.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-DDPhPPTQ.js +48 -0
  11. package/dist/Heading-ba38ScjJ.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input-BmDS8Juy.js +133 -0
  14. package/dist/Label-JS_ob-kh.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-BTxlCGcc.js +664 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-5aDgmImj.js +637 -0
  19. package/dist/RSPContexts-2lR5GG9p.js +14 -0
  20. package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
  21. package/dist/Separator-CaTBkETC.js +332 -0
  22. package/dist/Slider-C-S1oEH9.js +853 -0
  23. package/dist/Text-BuJgePCv.js +16 -0
  24. package/dist/VisuallyHidden-BYi0pekx.js +48 -0
  25. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  26. package/dist/assets/index.css +57 -0
  27. package/dist/assets/style-admin.css +5908 -0
  28. package/dist/assets/style-editor.css +5908 -0
  29. package/dist/assets/style.css +5914 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +396 -0
  32. package/dist/components/animated-visibility/animated-visibility.js +105 -0
  33. package/dist/components/base-control/base-control.js +86 -0
  34. package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
  35. package/dist/components/button/button.js +387 -0
  36. package/dist/components/checkbox/checkbox.js +323 -0
  37. package/dist/components/color-pickers/color-picker.js +272 -0
  38. package/dist/components/color-pickers/color-swatch.js +59 -0
  39. package/dist/components/color-pickers/gradient-editor.js +534 -0
  40. package/dist/components/color-pickers/solid-color-picker.js +1567 -0
  41. package/dist/components/component-toggle/component-toggle.js +161 -0
  42. package/dist/components/container-panel/container-panel.js +131 -0
  43. package/dist/components/draggable/draggable-context.js +5 -0
  44. package/dist/components/draggable/draggable-handle.js +46 -0
  45. package/dist/components/draggable/draggable.js +7320 -0
  46. package/dist/components/draggable-list/draggable-list-context.js +5 -0
  47. package/dist/components/draggable-list/draggable-list-item.js +77 -0
  48. package/dist/components/draggable-list/draggable-list.js +151 -0
  49. package/dist/components/expandable/expandable.js +342 -0
  50. package/dist/components/index.js +137 -0
  51. package/dist/components/input-field/input-field.js +231 -0
  52. package/dist/components/item-collection/item-collection.js +59 -0
  53. package/dist/components/layout/hstack.js +30 -0
  54. package/dist/components/layout/vstack.js +30 -0
  55. package/dist/components/link-input/link-input.js +284 -0
  56. package/dist/components/matrix-align/matrix-align.js +134 -0
  57. package/dist/components/menu/menu.js +285 -0
  58. package/dist/components/modal/modal.js +305 -0
  59. package/dist/components/notice/notice.js +123 -0
  60. package/dist/components/number-picker/number-picker.js +292 -0
  61. package/dist/components/option-select/option-select.js +264 -0
  62. package/dist/components/options-panel/options-panel.js +158 -0
  63. package/dist/components/placeholders/file-placeholder.js +42 -0
  64. package/dist/components/placeholders/image-placeholder.js +88 -0
  65. package/dist/components/placeholders/media-placeholder.js +63 -0
  66. package/dist/components/popover/popover.js +207 -0
  67. package/dist/components/radio/radio.js +582 -0
  68. package/dist/components/repeater/repeater-context.js +5 -0
  69. package/dist/components/repeater/repeater-item.js +119 -0
  70. package/dist/components/repeater/repeater.js +280 -0
  71. package/dist/components/responsive/mini-responsive.js +498 -0
  72. package/dist/components/responsive/responsive-legacy.js +343 -0
  73. package/dist/components/responsive/responsive.js +583 -0
  74. package/dist/components/responsive-preview/responsive-preview.js +123 -0
  75. package/dist/components/rich-label/rich-label.js +66 -0
  76. package/dist/components/select/async-multi-select.js +157 -0
  77. package/dist/components/select/async-single-select.js +137 -0
  78. package/dist/components/select/custom-select-default-components.js +38 -0
  79. package/dist/components/select/multi-select-components.js +8 -0
  80. package/dist/components/select/multi-select.js +151 -0
  81. package/dist/components/select/react-select-component-wrappers.js +90 -0
  82. package/dist/components/select/shared.js +26 -0
  83. package/dist/components/select/single-select.js +131 -0
  84. package/dist/components/select/styles.js +49 -0
  85. package/dist/components/select/v2/async-select.js +297 -0
  86. package/dist/components/select/v2/shared.js +24 -0
  87. package/dist/components/select/v2/single-select.js +1004 -0
  88. package/dist/components/slider/column-config-slider.js +210 -0
  89. package/dist/components/slider/slider.js +345 -0
  90. package/dist/components/slider/utils.js +94 -0
  91. package/dist/components/spacer/spacer.js +97 -0
  92. package/dist/components/tabs/tabs.js +703 -0
  93. package/dist/components/toggle/switch.js +156 -0
  94. package/dist/components/toggle/toggle.js +64 -0
  95. package/dist/components/toggle-button/toggle-button.js +343 -0
  96. package/dist/components/tooltip/tooltip.js +527 -0
  97. package/dist/context-BbYZoHvX.js +92 -0
  98. package/dist/default-i18n-CT_oS1Fy.js +922 -0
  99. package/dist/filterDOMProps-EDDcM64A.js +28 -0
  100. package/dist/icons/block-icon.js +42 -0
  101. package/dist/icons/generic-color-swatch.js +113 -0
  102. package/dist/icons/icons.js +30495 -0
  103. package/dist/icons/index.js +11 -0
  104. package/dist/icons/jsx-svg.js +50 -0
  105. package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
  106. package/dist/index-BljRBEr_.js +44 -0
  107. package/dist/index-CFozsmNS.js +28321 -0
  108. package/dist/index.js +139 -0
  109. package/dist/lite-DVmmD_-j.js +7 -0
  110. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  111. package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
  112. package/dist/number-GajL10e1.js +36 -0
  113. package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
  114. package/dist/react-select-async.esm-D937XTWW.js +107 -0
  115. package/dist/react-select.esm-Ciai3aKf.js +15 -0
  116. package/dist/style-admin.js +1 -0
  117. package/dist/style-editor.js +1 -0
  118. package/dist/style.js +1 -0
  119. package/dist/textSelection-8DpK8fJl.js +46 -0
  120. package/dist/useButton-Bt3BffJm.js +50 -0
  121. package/dist/useEvent-ICdlokG-.js +23 -0
  122. package/dist/useFocusRing-Bv0UJQl8.js +107 -0
  123. package/dist/useFormReset-D2YaWRIA.js +22 -0
  124. package/dist/useFormValidation-Dy0PXJg5.js +224 -0
  125. package/dist/useHover-C2SkI1Fn.js +895 -0
  126. package/dist/useLabel-BPCd5c7-.js +27 -0
  127. package/dist/useLabels-B7-lUnAF.js +23 -0
  128. package/dist/useListState-DkyH7elT.js +168 -0
  129. package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
  130. package/dist/useNumberField-CU1_u8ze.js +1215 -0
  131. package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
  132. package/dist/usePress-BrJylgPR.js +688 -0
  133. package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
  134. package/dist/useToggle-CDa3YAZI.js +59 -0
  135. package/dist/useToggleState-ibcBUHnB.js +19 -0
  136. package/dist/utilities/array-helpers.js +56 -0
  137. package/dist/utilities/debounce-throttle.js +123 -0
  138. package/dist/utilities/es-dash.js +382 -0
  139. package/dist/utilities/index.js +27 -0
  140. package/dist/utilities/text-helpers.js +136 -0
  141. package/dist/utils-CZt7LCbO.js +403 -0
  142. package/dist/wp/wp-font-enhancements.js +1 -0
  143. package/dist/wp/wp-ui-enhancements.js +1 -0
  144. package/package.json +24 -24
@@ -0,0 +1,831 @@
1
+ import { r as $f4e2df6bd15f8569$export$98658e8c59125e6a, k as $d4ee10de306f2510$export$4282f70798064fe0, f as $431fbd86ca7dc216$export$f21a1ffae260145a, i as $d4ee10de306f2510$export$cd4e5573fbe2b576, d as $431fbd86ca7dc216$export$b204af158042fbac, s as $b4b717babfbb907b$export$bebd5a1431fec25d, t as $b4b717babfbb907b$export$4c063cf1350e6fed, u as $3ad3f6e1647bc98d$export$80f3e147d781571c, j as $d4ee10de306f2510$export$e58f029f0fbfdb29, v as $c87311424ea30a05$export$a11b0059900ceec8, w as $c87311424ea30a05$export$6446a186d09e379e, x as $507fabe10e71c6fb$export$630ff653c5ada6a9 } from "./useHover-C2SkI1Fn.js";
2
+ import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c } from "./utils-CZt7LCbO.js";
3
+ import React__default, { useRef, useContext, useMemo, useEffect } from "react";
4
+ class $dfc540311bf7f109$export$63eb3ababa9c55c4 {
5
+ get currentNode() {
6
+ return this._currentNode;
7
+ }
8
+ set currentNode(node) {
9
+ if (!$d4ee10de306f2510$export$4282f70798064fe0(this.root, node)) throw new Error("Cannot set currentNode to a node that is not contained by the root node.");
10
+ const walkers = [];
11
+ let curNode = node;
12
+ let currentWalkerCurrentNode = node;
13
+ this._currentNode = node;
14
+ while (curNode && curNode !== this.root) if (curNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
15
+ const shadowRoot = curNode;
16
+ const walker2 = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
17
+ acceptNode: this._acceptNode
18
+ });
19
+ walkers.push(walker2);
20
+ walker2.currentNode = currentWalkerCurrentNode;
21
+ this._currentSetFor.add(walker2);
22
+ curNode = currentWalkerCurrentNode = shadowRoot.host;
23
+ } else curNode = curNode.parentNode;
24
+ const walker = this._doc.createTreeWalker(this.root, this.whatToShow, {
25
+ acceptNode: this._acceptNode
26
+ });
27
+ walkers.push(walker);
28
+ walker.currentNode = currentWalkerCurrentNode;
29
+ this._currentSetFor.add(walker);
30
+ this._walkerStack = walkers;
31
+ }
32
+ get doc() {
33
+ return this._doc;
34
+ }
35
+ firstChild() {
36
+ let currentNode = this.currentNode;
37
+ let newNode = this.nextNode();
38
+ if (!$d4ee10de306f2510$export$4282f70798064fe0(currentNode, newNode)) {
39
+ this.currentNode = currentNode;
40
+ return null;
41
+ }
42
+ if (newNode) this.currentNode = newNode;
43
+ return newNode;
44
+ }
45
+ lastChild() {
46
+ let walker = this._walkerStack[0];
47
+ let newNode = walker.lastChild();
48
+ if (newNode) this.currentNode = newNode;
49
+ return newNode;
50
+ }
51
+ nextNode() {
52
+ const nextNode = this._walkerStack[0].nextNode();
53
+ if (nextNode) {
54
+ const shadowRoot = nextNode.shadowRoot;
55
+ if (shadowRoot) {
56
+ var _this_filter;
57
+ let nodeResult;
58
+ if (typeof this.filter === "function") nodeResult = this.filter(nextNode);
59
+ else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) nodeResult = this.filter.acceptNode(nextNode);
60
+ if (nodeResult === NodeFilter.FILTER_ACCEPT) {
61
+ this.currentNode = nextNode;
62
+ return nextNode;
63
+ }
64
+ let newNode = this.nextNode();
65
+ if (newNode) this.currentNode = newNode;
66
+ return newNode;
67
+ }
68
+ if (nextNode) this.currentNode = nextNode;
69
+ return nextNode;
70
+ } else {
71
+ if (this._walkerStack.length > 1) {
72
+ this._walkerStack.shift();
73
+ let newNode = this.nextNode();
74
+ if (newNode) this.currentNode = newNode;
75
+ return newNode;
76
+ } else return null;
77
+ }
78
+ }
79
+ previousNode() {
80
+ const currentWalker = this._walkerStack[0];
81
+ if (currentWalker.currentNode === currentWalker.root) {
82
+ if (this._currentSetFor.has(currentWalker)) {
83
+ this._currentSetFor.delete(currentWalker);
84
+ if (this._walkerStack.length > 1) {
85
+ this._walkerStack.shift();
86
+ let newNode = this.previousNode();
87
+ if (newNode) this.currentNode = newNode;
88
+ return newNode;
89
+ } else return null;
90
+ }
91
+ return null;
92
+ }
93
+ const previousNode = currentWalker.previousNode();
94
+ if (previousNode) {
95
+ const shadowRoot = previousNode.shadowRoot;
96
+ if (shadowRoot) {
97
+ var _this_filter;
98
+ let nodeResult;
99
+ if (typeof this.filter === "function") nodeResult = this.filter(previousNode);
100
+ else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) nodeResult = this.filter.acceptNode(previousNode);
101
+ if (nodeResult === NodeFilter.FILTER_ACCEPT) {
102
+ if (previousNode) this.currentNode = previousNode;
103
+ return previousNode;
104
+ }
105
+ let newNode = this.lastChild();
106
+ if (newNode) this.currentNode = newNode;
107
+ return newNode;
108
+ }
109
+ if (previousNode) this.currentNode = previousNode;
110
+ return previousNode;
111
+ } else {
112
+ if (this._walkerStack.length > 1) {
113
+ this._walkerStack.shift();
114
+ let newNode = this.previousNode();
115
+ if (newNode) this.currentNode = newNode;
116
+ return newNode;
117
+ } else return null;
118
+ }
119
+ }
120
+ /**
121
+ * @deprecated
122
+ */
123
+ nextSibling() {
124
+ return null;
125
+ }
126
+ /**
127
+ * @deprecated
128
+ */
129
+ previousSibling() {
130
+ return null;
131
+ }
132
+ /**
133
+ * @deprecated
134
+ */
135
+ parentNode() {
136
+ return null;
137
+ }
138
+ constructor(doc, root, whatToShow, filter) {
139
+ this._walkerStack = [];
140
+ this._currentSetFor = /* @__PURE__ */ new Set();
141
+ this._acceptNode = (node) => {
142
+ if (node.nodeType === Node.ELEMENT_NODE) {
143
+ const shadowRoot2 = node.shadowRoot;
144
+ if (shadowRoot2) {
145
+ const walker = this._doc.createTreeWalker(shadowRoot2, this.whatToShow, {
146
+ acceptNode: this._acceptNode
147
+ });
148
+ this._walkerStack.unshift(walker);
149
+ return NodeFilter.FILTER_ACCEPT;
150
+ } else {
151
+ var _this_filter;
152
+ if (typeof this.filter === "function") return this.filter(node);
153
+ else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) return this.filter.acceptNode(node);
154
+ else if (this.filter === null) return NodeFilter.FILTER_ACCEPT;
155
+ }
156
+ }
157
+ return NodeFilter.FILTER_SKIP;
158
+ };
159
+ this._doc = doc;
160
+ this.root = root;
161
+ this.filter = filter !== null && filter !== void 0 ? filter : null;
162
+ this.whatToShow = whatToShow !== null && whatToShow !== void 0 ? whatToShow : NodeFilter.SHOW_ALL;
163
+ this._currentNode = root;
164
+ this._walkerStack.unshift(doc.createTreeWalker(root, whatToShow, this._acceptNode));
165
+ const shadowRoot = root.shadowRoot;
166
+ if (shadowRoot) {
167
+ const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
168
+ acceptNode: this._acceptNode
169
+ });
170
+ this._walkerStack.unshift(walker);
171
+ }
172
+ }
173
+ }
174
+ function $dfc540311bf7f109$export$4d0f8be8b12a7ef6(doc, root, whatToShow, filter) {
175
+ if ($f4e2df6bd15f8569$export$98658e8c59125e6a()) return new $dfc540311bf7f109$export$63eb3ababa9c55c4(doc, root, whatToShow, filter);
176
+ return doc.createTreeWalker(root, whatToShow, filter);
177
+ }
178
+ function $645f2e67b85a24c9$var$isStyleVisible(element) {
179
+ const windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
180
+ if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return false;
181
+ let { display, visibility } = element.style;
182
+ let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
183
+ if (isVisible) {
184
+ const { getComputedStyle } = element.ownerDocument.defaultView;
185
+ let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
186
+ isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
187
+ }
188
+ return isVisible;
189
+ }
190
+ function $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) {
191
+ return !element.hasAttribute("hidden") && // Ignore HiddenSelect when tree walking.
192
+ !element.hasAttribute("data-react-aria-prevent-focus") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : true);
193
+ }
194
+ function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
195
+ return element.nodeName !== "#comment" && $645f2e67b85a24c9$var$isStyleVisible(element) && $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) && (!element.parentElement || $645f2e67b85a24c9$export$e989c0fffaa6b27a(element.parentElement, element));
196
+ }
197
+ const $9bf71ea28793e738$var$FocusContext = /* @__PURE__ */ React__default.createContext(null);
198
+ const $9bf71ea28793e738$var$RESTORE_FOCUS_EVENT = "react-aria-focus-scope-restore";
199
+ let $9bf71ea28793e738$var$activeScope = null;
200
+ function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
201
+ let { children, contain, restoreFocus, autoFocus } = props;
202
+ let startRef = useRef(null);
203
+ let endRef = useRef(null);
204
+ let scopeRef = useRef([]);
205
+ let { parentNode } = useContext($9bf71ea28793e738$var$FocusContext) || {};
206
+ let node = useMemo(() => new $9bf71ea28793e738$var$TreeNode({
207
+ scopeRef
208
+ }), [
209
+ scopeRef
210
+ ]);
211
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
212
+ let parent = parentNode || $9bf71ea28793e738$export$d06fae2ee68b101e.root;
213
+ if ($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parent.scopeRef) && $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, parent.scopeRef)) {
214
+ let activeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
215
+ if (activeNode) parent = activeNode;
216
+ }
217
+ parent.addChild(node);
218
+ $9bf71ea28793e738$export$d06fae2ee68b101e.addNode(node);
219
+ }, [
220
+ node,
221
+ parentNode
222
+ ]);
223
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
224
+ let node2 = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
225
+ if (node2) node2.contain = !!contain;
226
+ }, [
227
+ contain
228
+ ]);
229
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
230
+ var _startRef_current;
231
+ let node2 = (_startRef_current = startRef.current) === null || _startRef_current === void 0 ? void 0 : _startRef_current.nextSibling;
232
+ let nodes = [];
233
+ let stopPropagation = (e) => e.stopPropagation();
234
+ while (node2 && node2 !== endRef.current) {
235
+ nodes.push(node2);
236
+ node2.addEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
237
+ node2 = node2.nextSibling;
238
+ }
239
+ scopeRef.current = nodes;
240
+ return () => {
241
+ for (let node3 of nodes) node3.removeEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
242
+ };
243
+ }, [
244
+ children
245
+ ]);
246
+ $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
247
+ $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain);
248
+ $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain);
249
+ $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus);
250
+ useEffect(() => {
251
+ const activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0));
252
+ let scope = null;
253
+ if ($9bf71ea28793e738$var$isElementInScope(activeElement, scopeRef.current)) {
254
+ for (let node2 of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse()) if (node2.scopeRef && $9bf71ea28793e738$var$isElementInScope(activeElement, node2.scopeRef.current)) scope = node2;
255
+ if (scope === $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) $9bf71ea28793e738$var$activeScope = scope.scopeRef;
256
+ }
257
+ }, [
258
+ scopeRef
259
+ ]);
260
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
261
+ return () => {
262
+ var _focusScopeTree_getTreeNode_parent, _focusScopeTree_getTreeNode;
263
+ var _focusScopeTree_getTreeNode_parent_scopeRef;
264
+ let parentScope = (_focusScopeTree_getTreeNode_parent_scopeRef = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : (_focusScopeTree_getTreeNode_parent = _focusScopeTree_getTreeNode.parent) === null || _focusScopeTree_getTreeNode_parent === void 0 ? void 0 : _focusScopeTree_getTreeNode_parent.scopeRef) !== null && _focusScopeTree_getTreeNode_parent_scopeRef !== void 0 ? _focusScopeTree_getTreeNode_parent_scopeRef : null;
265
+ if ((scopeRef === $9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope(scopeRef, $9bf71ea28793e738$var$activeScope)) && (!parentScope || $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parentScope))) $9bf71ea28793e738$var$activeScope = parentScope;
266
+ $9bf71ea28793e738$export$d06fae2ee68b101e.removeTreeNode(scopeRef);
267
+ };
268
+ }, [
269
+ scopeRef
270
+ ]);
271
+ let focusManager = useMemo(() => $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef), []);
272
+ let value = useMemo(() => ({
273
+ focusManager,
274
+ parentNode: node
275
+ }), [
276
+ node,
277
+ focusManager
278
+ ]);
279
+ return /* @__PURE__ */ React__default.createElement($9bf71ea28793e738$var$FocusContext.Provider, {
280
+ value
281
+ }, /* @__PURE__ */ React__default.createElement("span", {
282
+ "data-focus-scope-start": true,
283
+ hidden: true,
284
+ ref: startRef
285
+ }), children, /* @__PURE__ */ React__default.createElement("span", {
286
+ "data-focus-scope-end": true,
287
+ hidden: true,
288
+ ref: endRef
289
+ }));
290
+ }
291
+ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
292
+ return {
293
+ focusNext(opts = {}) {
294
+ let scope = scopeRef.current;
295
+ let { from, tabbable, wrap, accept } = opts;
296
+ var _scope_;
297
+ let node = from || $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : void 0));
298
+ let sentinel = scope[0].previousElementSibling;
299
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
300
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
301
+ tabbable,
302
+ accept
303
+ }, scope);
304
+ walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
305
+ let nextNode = walker.nextNode();
306
+ if (!nextNode && wrap) {
307
+ walker.currentNode = sentinel;
308
+ nextNode = walker.nextNode();
309
+ }
310
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
311
+ return nextNode;
312
+ },
313
+ focusPrevious(opts = {}) {
314
+ let scope = scopeRef.current;
315
+ let { from, tabbable, wrap, accept } = opts;
316
+ var _scope_;
317
+ let node = from || $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : void 0));
318
+ let sentinel = scope[scope.length - 1].nextElementSibling;
319
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
320
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
321
+ tabbable,
322
+ accept
323
+ }, scope);
324
+ walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
325
+ let previousNode = walker.previousNode();
326
+ if (!previousNode && wrap) {
327
+ walker.currentNode = sentinel;
328
+ previousNode = walker.previousNode();
329
+ }
330
+ if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
331
+ return previousNode;
332
+ },
333
+ focusFirst(opts = {}) {
334
+ let scope = scopeRef.current;
335
+ let { tabbable, accept } = opts;
336
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
337
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
338
+ tabbable,
339
+ accept
340
+ }, scope);
341
+ walker.currentNode = scope[0].previousElementSibling;
342
+ let nextNode = walker.nextNode();
343
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
344
+ return nextNode;
345
+ },
346
+ focusLast(opts = {}) {
347
+ let scope = scopeRef.current;
348
+ let { tabbable, accept } = opts;
349
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
350
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
351
+ tabbable,
352
+ accept
353
+ }, scope);
354
+ walker.currentNode = scope[scope.length - 1].nextElementSibling;
355
+ let previousNode = walker.previousNode();
356
+ if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
357
+ return previousNode;
358
+ }
359
+ };
360
+ }
361
+ function $9bf71ea28793e738$var$getScopeRoot(scope) {
362
+ return scope[0].parentElement;
363
+ }
364
+ function $9bf71ea28793e738$var$shouldContainFocus(scopeRef) {
365
+ let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
366
+ while (scope && scope.scopeRef !== scopeRef) {
367
+ if (scope.contain) return false;
368
+ scope = scope.parent;
369
+ }
370
+ return true;
371
+ }
372
+ function $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain) {
373
+ let focusedNode = useRef(void 0);
374
+ let raf = useRef(void 0);
375
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
376
+ let scope = scopeRef.current;
377
+ if (!contain) {
378
+ if (raf.current) {
379
+ cancelAnimationFrame(raf.current);
380
+ raf.current = void 0;
381
+ }
382
+ return;
383
+ }
384
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
385
+ let onKeyDown = (e) => {
386
+ if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
387
+ let focusedElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
388
+ let scope2 = scopeRef.current;
389
+ if (!scope2 || !$9bf71ea28793e738$var$isElementInScope(focusedElement, scope2)) return;
390
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope2);
391
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
392
+ tabbable: true
393
+ }, scope2);
394
+ if (!focusedElement) return;
395
+ walker.currentNode = focusedElement;
396
+ let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
397
+ if (!nextElement) {
398
+ walker.currentNode = e.shiftKey ? scope2[scope2.length - 1].nextElementSibling : scope2[0].previousElementSibling;
399
+ nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
400
+ }
401
+ e.preventDefault();
402
+ if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
403
+ };
404
+ let onFocus = (e) => {
405
+ if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope($d4ee10de306f2510$export$e58f029f0fbfdb29(e), scopeRef.current)) {
406
+ $9bf71ea28793e738$var$activeScope = scopeRef;
407
+ focusedNode.current = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
408
+ } else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope($d4ee10de306f2510$export$e58f029f0fbfdb29(e), scopeRef)) {
409
+ if (focusedNode.current) focusedNode.current.focus();
410
+ else if ($9bf71ea28793e738$var$activeScope && $9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
411
+ } else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef)) focusedNode.current = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
412
+ };
413
+ let onBlur = (e) => {
414
+ if (raf.current) cancelAnimationFrame(raf.current);
415
+ raf.current = requestAnimationFrame(() => {
416
+ let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
417
+ let shouldSkipFocusRestore = (modality === "virtual" || modality === null) && $c87311424ea30a05$export$a11b0059900ceec8() && $c87311424ea30a05$export$6446a186d09e379e();
418
+ let activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
419
+ if (!shouldSkipFocusRestore && activeElement && $9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef)) {
420
+ $9bf71ea28793e738$var$activeScope = scopeRef;
421
+ let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
422
+ if (target && target.isConnected) {
423
+ var _focusedNode_current;
424
+ focusedNode.current = target;
425
+ (_focusedNode_current = focusedNode.current) === null || _focusedNode_current === void 0 ? void 0 : _focusedNode_current.focus();
426
+ } else if ($9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
427
+ }
428
+ });
429
+ };
430
+ ownerDocument.addEventListener("keydown", onKeyDown, false);
431
+ ownerDocument.addEventListener("focusin", onFocus, false);
432
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
433
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusout", onBlur, false));
434
+ return () => {
435
+ ownerDocument.removeEventListener("keydown", onKeyDown, false);
436
+ ownerDocument.removeEventListener("focusin", onFocus, false);
437
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
438
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusout", onBlur, false));
439
+ };
440
+ }, [
441
+ scopeRef,
442
+ contain
443
+ ]);
444
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
445
+ return () => {
446
+ if (raf.current) cancelAnimationFrame(raf.current);
447
+ };
448
+ }, [
449
+ raf
450
+ ]);
451
+ }
452
+ function $9bf71ea28793e738$var$isElementInAnyScope(element) {
453
+ return $9bf71ea28793e738$var$isElementInChildScope(element);
454
+ }
455
+ function $9bf71ea28793e738$var$isElementInScope(element, scope) {
456
+ if (!element) return false;
457
+ if (!scope) return false;
458
+ return scope.some((node) => node.contains(element));
459
+ }
460
+ function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
461
+ if (element instanceof Element && element.closest("[data-react-aria-top-layer]")) return true;
462
+ for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))) {
463
+ if (s && $9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
464
+ }
465
+ return false;
466
+ }
467
+ function $9bf71ea28793e738$export$1258395f99bf9cbf(element) {
468
+ return $9bf71ea28793e738$var$isElementInChildScope(element, $9bf71ea28793e738$var$activeScope);
469
+ }
470
+ function $9bf71ea28793e738$var$isAncestorScope(ancestor, scope) {
471
+ var _focusScopeTree_getTreeNode;
472
+ let parent = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
473
+ while (parent) {
474
+ if (parent.scopeRef === ancestor) return true;
475
+ parent = parent.parent;
476
+ }
477
+ return false;
478
+ }
479
+ function $9bf71ea28793e738$var$focusElement(element, scroll = false) {
480
+ if (element != null && !scroll) try {
481
+ (0, $3ad3f6e1647bc98d$export$80f3e147d781571c)(element);
482
+ } catch {
483
+ }
484
+ else if (element != null) try {
485
+ element.focus();
486
+ } catch {
487
+ }
488
+ }
489
+ function $9bf71ea28793e738$var$getFirstInScope(scope, tabbable = true) {
490
+ let sentinel = scope[0].previousElementSibling;
491
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
492
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
493
+ tabbable
494
+ }, scope);
495
+ walker.currentNode = sentinel;
496
+ let nextNode = walker.nextNode();
497
+ if (tabbable && !nextNode) {
498
+ scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
499
+ walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
500
+ tabbable: false
501
+ }, scope);
502
+ walker.currentNode = sentinel;
503
+ nextNode = walker.nextNode();
504
+ }
505
+ return nextNode;
506
+ }
507
+ function $9bf71ea28793e738$var$focusFirstInScope(scope, tabbable = true) {
508
+ $9bf71ea28793e738$var$focusElement($9bf71ea28793e738$var$getFirstInScope(scope, tabbable));
509
+ }
510
+ function $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus) {
511
+ const autoFocusRef = React__default.useRef(autoFocus);
512
+ useEffect(() => {
513
+ if (autoFocusRef.current) {
514
+ $9bf71ea28793e738$var$activeScope = scopeRef;
515
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
516
+ if (!$9bf71ea28793e738$var$isElementInScope($d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument), $9bf71ea28793e738$var$activeScope.current) && scopeRef.current) $9bf71ea28793e738$var$focusFirstInScope(scopeRef.current);
517
+ }
518
+ autoFocusRef.current = false;
519
+ }, [
520
+ scopeRef
521
+ ]);
522
+ }
523
+ function $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restore, contain) {
524
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
525
+ if (restore || contain) return;
526
+ let scope = scopeRef.current;
527
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
528
+ let onFocus = (e) => {
529
+ let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
530
+ if ($9bf71ea28793e738$var$isElementInScope(target, scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
531
+ else if (!$9bf71ea28793e738$var$isElementInAnyScope(target)) $9bf71ea28793e738$var$activeScope = null;
532
+ };
533
+ ownerDocument.addEventListener("focusin", onFocus, false);
534
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
535
+ return () => {
536
+ ownerDocument.removeEventListener("focusin", onFocus, false);
537
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
538
+ };
539
+ }, [
540
+ scopeRef,
541
+ restore,
542
+ contain
543
+ ]);
544
+ }
545
+ function $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef) {
546
+ let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
547
+ while (scope && scope.scopeRef !== scopeRef) {
548
+ if (scope.nodeToRestore) return false;
549
+ scope = scope.parent;
550
+ }
551
+ return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
552
+ }
553
+ function $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
554
+ const nodeToRestoreRef = useRef(typeof document !== "undefined" ? $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0)) : null);
555
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
556
+ let scope = scopeRef.current;
557
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
558
+ if (!restoreFocus || contain) return;
559
+ let onFocus = () => {
560
+ if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope($d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument), scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
561
+ };
562
+ ownerDocument.addEventListener("focusin", onFocus, false);
563
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
564
+ return () => {
565
+ ownerDocument.removeEventListener("focusin", onFocus, false);
566
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
567
+ };
568
+ }, [
569
+ scopeRef,
570
+ contain
571
+ ]);
572
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
573
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
574
+ if (!restoreFocus) return;
575
+ let onKeyDown = (e) => {
576
+ if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
577
+ let focusedElement = ownerDocument.activeElement;
578
+ if (!$9bf71ea28793e738$var$isElementInChildScope(focusedElement, scopeRef) || !$9bf71ea28793e738$var$shouldRestoreFocus(scopeRef)) return;
579
+ let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
580
+ if (!treeNode) return;
581
+ let nodeToRestore = treeNode.nodeToRestore;
582
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ownerDocument.body, {
583
+ tabbable: true
584
+ });
585
+ walker.currentNode = focusedElement;
586
+ let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
587
+ if (!nodeToRestore || !nodeToRestore.isConnected || nodeToRestore === ownerDocument.body) {
588
+ nodeToRestore = void 0;
589
+ treeNode.nodeToRestore = void 0;
590
+ }
591
+ if ((!nextElement || !$9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef)) && nodeToRestore) {
592
+ walker.currentNode = nodeToRestore;
593
+ do
594
+ nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
595
+ while ($9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef));
596
+ e.preventDefault();
597
+ e.stopPropagation();
598
+ if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
599
+ else if (!$9bf71ea28793e738$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
600
+ else $9bf71ea28793e738$var$focusElement(nodeToRestore, true);
601
+ }
602
+ };
603
+ if (!contain) ownerDocument.addEventListener("keydown", onKeyDown, true);
604
+ return () => {
605
+ if (!contain) ownerDocument.removeEventListener("keydown", onKeyDown, true);
606
+ };
607
+ }, [
608
+ scopeRef,
609
+ restoreFocus,
610
+ contain
611
+ ]);
612
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
613
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
614
+ if (!restoreFocus) return;
615
+ let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
616
+ if (!treeNode) return;
617
+ var _nodeToRestoreRef_current;
618
+ treeNode.nodeToRestore = (_nodeToRestoreRef_current = nodeToRestoreRef.current) !== null && _nodeToRestoreRef_current !== void 0 ? _nodeToRestoreRef_current : void 0;
619
+ return () => {
620
+ let treeNode2 = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
621
+ if (!treeNode2) return;
622
+ let nodeToRestore = treeNode2.nodeToRestore;
623
+ let activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
624
+ if (restoreFocus && nodeToRestore && (activeElement && $9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef) || activeElement === ownerDocument.body && $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef))) {
625
+ let clonedTree = $9bf71ea28793e738$export$d06fae2ee68b101e.clone();
626
+ requestAnimationFrame(() => {
627
+ if (ownerDocument.activeElement === ownerDocument.body) {
628
+ let treeNode3 = clonedTree.getTreeNode(scopeRef);
629
+ while (treeNode3) {
630
+ if (treeNode3.nodeToRestore && treeNode3.nodeToRestore.isConnected) {
631
+ $9bf71ea28793e738$var$restoreFocusToElement(treeNode3.nodeToRestore);
632
+ return;
633
+ }
634
+ treeNode3 = treeNode3.parent;
635
+ }
636
+ treeNode3 = clonedTree.getTreeNode(scopeRef);
637
+ while (treeNode3) {
638
+ if (treeNode3.scopeRef && treeNode3.scopeRef.current && $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(treeNode3.scopeRef)) {
639
+ let node = $9bf71ea28793e738$var$getFirstInScope(treeNode3.scopeRef.current, true);
640
+ $9bf71ea28793e738$var$restoreFocusToElement(node);
641
+ return;
642
+ }
643
+ treeNode3 = treeNode3.parent;
644
+ }
645
+ }
646
+ });
647
+ }
648
+ };
649
+ }, [
650
+ scopeRef,
651
+ restoreFocus
652
+ ]);
653
+ }
654
+ function $9bf71ea28793e738$var$restoreFocusToElement(node) {
655
+ if (node.dispatchEvent(new CustomEvent($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, {
656
+ bubbles: true,
657
+ cancelable: true
658
+ }))) $9bf71ea28793e738$var$focusElement(node);
659
+ }
660
+ function $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, opts, scope) {
661
+ let filter = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $b4b717babfbb907b$export$bebd5a1431fec25d : $b4b717babfbb907b$export$4c063cf1350e6fed;
662
+ let rootElement = (root === null || root === void 0 ? void 0 : root.nodeType) === Node.ELEMENT_NODE ? root : null;
663
+ let doc = $431fbd86ca7dc216$export$b204af158042fbac(rootElement);
664
+ let walker = $dfc540311bf7f109$export$4d0f8be8b12a7ef6(doc, root || doc, NodeFilter.SHOW_ELEMENT, {
665
+ acceptNode(node) {
666
+ var _opts_from;
667
+ if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node)) return NodeFilter.FILTER_REJECT;
668
+ if (filter(node) && $645f2e67b85a24c9$export$e989c0fffaa6b27a(node) && (!scope || $9bf71ea28793e738$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
669
+ return NodeFilter.FILTER_SKIP;
670
+ }
671
+ });
672
+ if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
673
+ return walker;
674
+ }
675
+ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
676
+ return {
677
+ focusNext(opts = {}) {
678
+ let root = ref.current;
679
+ if (!root) return null;
680
+ let { from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept } = opts;
681
+ let node = from || $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac(root));
682
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
683
+ tabbable,
684
+ accept
685
+ });
686
+ if (root.contains(node)) walker.currentNode = node;
687
+ let nextNode = walker.nextNode();
688
+ if (!nextNode && wrap) {
689
+ walker.currentNode = root;
690
+ nextNode = walker.nextNode();
691
+ }
692
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
693
+ return nextNode;
694
+ },
695
+ focusPrevious(opts = defaultOptions) {
696
+ let root = ref.current;
697
+ if (!root) return null;
698
+ let { from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept } = opts;
699
+ let node = from || $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac(root));
700
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
701
+ tabbable,
702
+ accept
703
+ });
704
+ if (root.contains(node)) walker.currentNode = node;
705
+ else {
706
+ let next = $9bf71ea28793e738$var$last(walker);
707
+ if (next) $9bf71ea28793e738$var$focusElement(next, true);
708
+ return next !== null && next !== void 0 ? next : null;
709
+ }
710
+ let previousNode = walker.previousNode();
711
+ if (!previousNode && wrap) {
712
+ walker.currentNode = root;
713
+ let lastNode = $9bf71ea28793e738$var$last(walker);
714
+ if (!lastNode)
715
+ return null;
716
+ previousNode = lastNode;
717
+ }
718
+ if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
719
+ return previousNode !== null && previousNode !== void 0 ? previousNode : null;
720
+ },
721
+ focusFirst(opts = defaultOptions) {
722
+ let root = ref.current;
723
+ if (!root) return null;
724
+ let { tabbable = defaultOptions.tabbable, accept = defaultOptions.accept } = opts;
725
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
726
+ tabbable,
727
+ accept
728
+ });
729
+ let nextNode = walker.nextNode();
730
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
731
+ return nextNode;
732
+ },
733
+ focusLast(opts = defaultOptions) {
734
+ let root = ref.current;
735
+ if (!root) return null;
736
+ let { tabbable = defaultOptions.tabbable, accept = defaultOptions.accept } = opts;
737
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
738
+ tabbable,
739
+ accept
740
+ });
741
+ let next = $9bf71ea28793e738$var$last(walker);
742
+ if (next) $9bf71ea28793e738$var$focusElement(next, true);
743
+ return next !== null && next !== void 0 ? next : null;
744
+ }
745
+ };
746
+ }
747
+ function $9bf71ea28793e738$var$last(walker) {
748
+ let next = void 0;
749
+ let last;
750
+ do {
751
+ last = walker.lastChild();
752
+ if (last) next = last;
753
+ } while (last);
754
+ return next;
755
+ }
756
+ class $9bf71ea28793e738$var$Tree {
757
+ get size() {
758
+ return this.fastMap.size;
759
+ }
760
+ getTreeNode(data) {
761
+ return this.fastMap.get(data);
762
+ }
763
+ addTreeNode(scopeRef, parent, nodeToRestore) {
764
+ let parentNode = this.fastMap.get(parent !== null && parent !== void 0 ? parent : null);
765
+ if (!parentNode) return;
766
+ let node = new $9bf71ea28793e738$var$TreeNode({
767
+ scopeRef
768
+ });
769
+ parentNode.addChild(node);
770
+ node.parent = parentNode;
771
+ this.fastMap.set(scopeRef, node);
772
+ if (nodeToRestore) node.nodeToRestore = nodeToRestore;
773
+ }
774
+ addNode(node) {
775
+ this.fastMap.set(node.scopeRef, node);
776
+ }
777
+ removeTreeNode(scopeRef) {
778
+ if (scopeRef === null) return;
779
+ let node = this.fastMap.get(scopeRef);
780
+ if (!node) return;
781
+ let parentNode = node.parent;
782
+ for (let current of this.traverse()) if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $9bf71ea28793e738$var$isElementInScope(current.nodeToRestore, node.scopeRef.current)) current.nodeToRestore = node.nodeToRestore;
783
+ let children = node.children;
784
+ if (parentNode) {
785
+ parentNode.removeChild(node);
786
+ if (children.size > 0) children.forEach((child) => parentNode && parentNode.addChild(child));
787
+ }
788
+ this.fastMap.delete(node.scopeRef);
789
+ }
790
+ // Pre Order Depth First
791
+ *traverse(node = this.root) {
792
+ if (node.scopeRef != null) yield node;
793
+ if (node.children.size > 0) for (let child of node.children) yield* this.traverse(child);
794
+ }
795
+ clone() {
796
+ var _node_parent;
797
+ let newTree = new $9bf71ea28793e738$var$Tree();
798
+ var _node_parent_scopeRef;
799
+ for (let node of this.traverse()) newTree.addTreeNode(node.scopeRef, (_node_parent_scopeRef = (_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.scopeRef) !== null && _node_parent_scopeRef !== void 0 ? _node_parent_scopeRef : null, node.nodeToRestore);
800
+ return newTree;
801
+ }
802
+ constructor() {
803
+ this.fastMap = /* @__PURE__ */ new Map();
804
+ this.root = new $9bf71ea28793e738$var$TreeNode({
805
+ scopeRef: null
806
+ });
807
+ this.fastMap.set(null, this.root);
808
+ }
809
+ }
810
+ class $9bf71ea28793e738$var$TreeNode {
811
+ addChild(node) {
812
+ this.children.add(node);
813
+ node.parent = this;
814
+ }
815
+ removeChild(node) {
816
+ this.children.delete(node);
817
+ node.parent = void 0;
818
+ }
819
+ constructor(props) {
820
+ this.children = /* @__PURE__ */ new Set();
821
+ this.contain = false;
822
+ this.scopeRef = props.scopeRef;
823
+ }
824
+ }
825
+ let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
826
+ export {
827
+ $9bf71ea28793e738$export$c5251b9e124bf29 as $,
828
+ $9bf71ea28793e738$export$2d6ec8fc375ceafa as a,
829
+ $9bf71ea28793e738$export$20e40289641fbbb6 as b,
830
+ $9bf71ea28793e738$export$1258395f99bf9cbf as c
831
+ };