@vritti/quantum-ui 0.1.21 → 0.1.23

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 (69) hide show
  1. package/dist/Checkbox.js +2 -253
  2. package/dist/Checkbox.js.map +1 -1
  3. package/dist/Combination.js +3869 -0
  4. package/dist/Combination.js.map +1 -0
  5. package/dist/DataTable.d.ts +31 -0
  6. package/dist/DataTable.js +4989 -0
  7. package/dist/DataTable.js.map +1 -0
  8. package/dist/DatePicker.d.ts +68 -0
  9. package/dist/DatePicker.js +8229 -0
  10. package/dist/DatePicker.js.map +1 -0
  11. package/dist/Input.js +22 -0
  12. package/dist/Input.js.map +1 -0
  13. package/dist/Label.js +40 -0
  14. package/dist/Label.js.map +1 -0
  15. package/dist/PhoneField.js +2 -2
  16. package/dist/PhoneField.js.map +1 -1
  17. package/dist/Skeleton.d.ts +6 -0
  18. package/dist/Skeleton.js +18 -0
  19. package/dist/Skeleton.js.map +1 -0
  20. package/dist/TextField.js +2 -18
  21. package/dist/TextField.js.map +1 -1
  22. package/dist/ThemeToggle.js +15 -3
  23. package/dist/ThemeToggle.js.map +1 -1
  24. package/dist/assets/quantum-ui.css +186 -108
  25. package/dist/axios.d.ts +11 -6
  26. package/dist/axios.js +191 -147
  27. package/dist/axios.js.map +1 -1
  28. package/dist/check.js +15 -0
  29. package/dist/check.js.map +1 -0
  30. package/dist/components/Button.d.ts +7 -0
  31. package/dist/components/Card.d.ts +7 -0
  32. package/dist/components/Checkbox.d.ts +7 -0
  33. package/dist/components/DataTable.d.ts +9 -0
  34. package/dist/components/DataTable.js +2 -0
  35. package/dist/components/DataTable.js.map +1 -0
  36. package/dist/components/DatePicker.d.ts +9 -0
  37. package/dist/components/DatePicker.js +2 -0
  38. package/dist/components/DatePicker.js.map +1 -0
  39. package/dist/components/Form.d.ts +7 -0
  40. package/dist/components/OTPField.d.ts +7 -0
  41. package/dist/components/PasswordField.d.ts +7 -0
  42. package/dist/components/PhoneField.d.ts +7 -0
  43. package/dist/components/Progress.d.ts +7 -0
  44. package/dist/components/Skeleton.d.ts +9 -0
  45. package/dist/components/Skeleton.js +2 -0
  46. package/dist/components/Skeleton.js.map +1 -0
  47. package/dist/components/TextArea.d.ts +7 -0
  48. package/dist/components/TextField.d.ts +7 -0
  49. package/dist/components/ThemeToggle.d.ts +7 -0
  50. package/dist/components/Typography.d.ts +7 -0
  51. package/dist/field.js +1 -34
  52. package/dist/field.js.map +1 -1
  53. package/dist/index.d.ts +69 -38
  54. package/dist/index.js +8 -6
  55. package/dist/index.js.map +1 -1
  56. package/dist/index5.js +5 -2
  57. package/dist/index5.js.map +1 -1
  58. package/dist/index6.js +246 -0
  59. package/dist/index6.js.map +1 -0
  60. package/dist/shadcn/shadcnField.d.ts +7 -0
  61. package/dist/utils/axios.d.ts +21 -6
  62. package/dist/utils/axios.js +1 -1
  63. package/package.json +27 -13
  64. package/dist/AuthProvider.d.ts +0 -34
  65. package/dist/OnboardingProvider.js +0 -113
  66. package/dist/OnboardingProvider.js.map +0 -1
  67. package/dist/context/AuthProvider.d.ts +0 -2
  68. package/dist/context/AuthProvider.js +0 -2
  69. package/dist/context/AuthProvider.js.map +0 -1
@@ -0,0 +1,3869 @@
1
+ import { c as createLucideIcon } from './createLucideIcon.js';
2
+ import * as React from 'react';
3
+ import { useLayoutEffect, useState } from 'react';
4
+ import { c as composeEventHandlers, b as useLayoutEffect2, a as useSize } from './index6.js';
5
+ import { P as Primitive, d as dispatchDiscreteCustomEvent } from './index5.js';
6
+ import { u as useComposedRefs } from './index2.js';
7
+ import { jsx } from 'react/jsx-runtime';
8
+ import * as ReactDOM from 'react-dom';
9
+ import ReactDOM__default from 'react-dom';
10
+ import { c as createContextScope } from './index4.js';
11
+
12
+ /**
13
+ * @license lucide-react v0.544.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */
18
+
19
+
20
+ const __iconNode = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
21
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode);
22
+
23
+ // packages/react/use-callback-ref/src/use-callback-ref.tsx
24
+ function useCallbackRef$1(callback) {
25
+ const callbackRef = React.useRef(callback);
26
+ React.useEffect(() => {
27
+ callbackRef.current = callback;
28
+ });
29
+ return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
30
+ }
31
+
32
+ // packages/react/use-escape-keydown/src/use-escape-keydown.tsx
33
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
34
+ const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
35
+ React.useEffect(() => {
36
+ const handleKeyDown = (event) => {
37
+ if (event.key === "Escape") {
38
+ onEscapeKeyDown(event);
39
+ }
40
+ };
41
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
42
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
43
+ }, [onEscapeKeyDown, ownerDocument]);
44
+ }
45
+
46
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
47
+ var CONTEXT_UPDATE = "dismissableLayer.update";
48
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
49
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
50
+ var originalBodyPointerEvents;
51
+ var DismissableLayerContext = React.createContext({
52
+ layers: /* @__PURE__ */ new Set(),
53
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
54
+ branches: /* @__PURE__ */ new Set()
55
+ });
56
+ var DismissableLayer = React.forwardRef(
57
+ (props, forwardedRef) => {
58
+ const {
59
+ disableOutsidePointerEvents = false,
60
+ onEscapeKeyDown,
61
+ onPointerDownOutside,
62
+ onFocusOutside,
63
+ onInteractOutside,
64
+ onDismiss,
65
+ ...layerProps
66
+ } = props;
67
+ const context = React.useContext(DismissableLayerContext);
68
+ const [node, setNode] = React.useState(null);
69
+ const ownerDocument = node?.ownerDocument ?? globalThis?.document;
70
+ const [, force] = React.useState({});
71
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
72
+ const layers = Array.from(context.layers);
73
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
74
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
75
+ const index = node ? layers.indexOf(node) : -1;
76
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
77
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
78
+ const pointerDownOutside = usePointerDownOutside((event) => {
79
+ const target = event.target;
80
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
81
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
82
+ onPointerDownOutside?.(event);
83
+ onInteractOutside?.(event);
84
+ if (!event.defaultPrevented) onDismiss?.();
85
+ }, ownerDocument);
86
+ const focusOutside = useFocusOutside((event) => {
87
+ const target = event.target;
88
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
89
+ if (isFocusInBranch) return;
90
+ onFocusOutside?.(event);
91
+ onInteractOutside?.(event);
92
+ if (!event.defaultPrevented) onDismiss?.();
93
+ }, ownerDocument);
94
+ useEscapeKeydown((event) => {
95
+ const isHighestLayer = index === context.layers.size - 1;
96
+ if (!isHighestLayer) return;
97
+ onEscapeKeyDown?.(event);
98
+ if (!event.defaultPrevented && onDismiss) {
99
+ event.preventDefault();
100
+ onDismiss();
101
+ }
102
+ }, ownerDocument);
103
+ React.useEffect(() => {
104
+ if (!node) return;
105
+ if (disableOutsidePointerEvents) {
106
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
107
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
108
+ ownerDocument.body.style.pointerEvents = "none";
109
+ }
110
+ context.layersWithOutsidePointerEventsDisabled.add(node);
111
+ }
112
+ context.layers.add(node);
113
+ dispatchUpdate();
114
+ return () => {
115
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
116
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
117
+ }
118
+ };
119
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
120
+ React.useEffect(() => {
121
+ return () => {
122
+ if (!node) return;
123
+ context.layers.delete(node);
124
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
125
+ dispatchUpdate();
126
+ };
127
+ }, [node, context]);
128
+ React.useEffect(() => {
129
+ const handleUpdate = () => force({});
130
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
131
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
132
+ }, []);
133
+ return /* @__PURE__ */ jsx(
134
+ Primitive.div,
135
+ {
136
+ ...layerProps,
137
+ ref: composedRefs,
138
+ style: {
139
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
140
+ ...props.style
141
+ },
142
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
143
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
144
+ onPointerDownCapture: composeEventHandlers(
145
+ props.onPointerDownCapture,
146
+ pointerDownOutside.onPointerDownCapture
147
+ )
148
+ }
149
+ );
150
+ }
151
+ );
152
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
153
+ var BRANCH_NAME = "DismissableLayerBranch";
154
+ var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
155
+ const context = React.useContext(DismissableLayerContext);
156
+ const ref = React.useRef(null);
157
+ const composedRefs = useComposedRefs(forwardedRef, ref);
158
+ React.useEffect(() => {
159
+ const node = ref.current;
160
+ if (node) {
161
+ context.branches.add(node);
162
+ return () => {
163
+ context.branches.delete(node);
164
+ };
165
+ }
166
+ }, [context.branches]);
167
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
168
+ });
169
+ DismissableLayerBranch.displayName = BRANCH_NAME;
170
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
171
+ const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
172
+ const isPointerInsideReactTreeRef = React.useRef(false);
173
+ const handleClickRef = React.useRef(() => {
174
+ });
175
+ React.useEffect(() => {
176
+ const handlePointerDown = (event) => {
177
+ if (event.target && !isPointerInsideReactTreeRef.current) {
178
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
179
+ handleAndDispatchCustomEvent(
180
+ POINTER_DOWN_OUTSIDE,
181
+ handlePointerDownOutside,
182
+ eventDetail,
183
+ { discrete: true }
184
+ );
185
+ };
186
+ const eventDetail = { originalEvent: event };
187
+ if (event.pointerType === "touch") {
188
+ ownerDocument.removeEventListener("click", handleClickRef.current);
189
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
190
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
191
+ } else {
192
+ handleAndDispatchPointerDownOutsideEvent2();
193
+ }
194
+ } else {
195
+ ownerDocument.removeEventListener("click", handleClickRef.current);
196
+ }
197
+ isPointerInsideReactTreeRef.current = false;
198
+ };
199
+ const timerId = window.setTimeout(() => {
200
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
201
+ }, 0);
202
+ return () => {
203
+ window.clearTimeout(timerId);
204
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
205
+ ownerDocument.removeEventListener("click", handleClickRef.current);
206
+ };
207
+ }, [ownerDocument, handlePointerDownOutside]);
208
+ return {
209
+ // ensures we check React component tree (not just DOM tree)
210
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
211
+ };
212
+ }
213
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
214
+ const handleFocusOutside = useCallbackRef$1(onFocusOutside);
215
+ const isFocusInsideReactTreeRef = React.useRef(false);
216
+ React.useEffect(() => {
217
+ const handleFocus = (event) => {
218
+ if (event.target && !isFocusInsideReactTreeRef.current) {
219
+ const eventDetail = { originalEvent: event };
220
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
221
+ discrete: false
222
+ });
223
+ }
224
+ };
225
+ ownerDocument.addEventListener("focusin", handleFocus);
226
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
227
+ }, [ownerDocument, handleFocusOutside]);
228
+ return {
229
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
230
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
231
+ };
232
+ }
233
+ function dispatchUpdate() {
234
+ const event = new CustomEvent(CONTEXT_UPDATE);
235
+ document.dispatchEvent(event);
236
+ }
237
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
238
+ const target = detail.originalEvent.target;
239
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
240
+ if (handler) target.addEventListener(name, handler, { once: true });
241
+ if (discrete) {
242
+ dispatchDiscreteCustomEvent(target, event);
243
+ } else {
244
+ target.dispatchEvent(event);
245
+ }
246
+ }
247
+
248
+ var count$1 = 0;
249
+ function useFocusGuards() {
250
+ React.useEffect(() => {
251
+ const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
252
+ document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
253
+ document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
254
+ count$1++;
255
+ return () => {
256
+ if (count$1 === 1) {
257
+ document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
258
+ }
259
+ count$1--;
260
+ };
261
+ }, []);
262
+ }
263
+ function createFocusGuard() {
264
+ const element = document.createElement("span");
265
+ element.setAttribute("data-radix-focus-guard", "");
266
+ element.tabIndex = 0;
267
+ element.style.outline = "none";
268
+ element.style.opacity = "0";
269
+ element.style.position = "fixed";
270
+ element.style.pointerEvents = "none";
271
+ return element;
272
+ }
273
+
274
+ var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
275
+ var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
276
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
277
+ var FOCUS_SCOPE_NAME = "FocusScope";
278
+ var FocusScope = React.forwardRef((props, forwardedRef) => {
279
+ const {
280
+ loop = false,
281
+ trapped = false,
282
+ onMountAutoFocus: onMountAutoFocusProp,
283
+ onUnmountAutoFocus: onUnmountAutoFocusProp,
284
+ ...scopeProps
285
+ } = props;
286
+ const [container, setContainer] = React.useState(null);
287
+ const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
288
+ const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
289
+ const lastFocusedElementRef = React.useRef(null);
290
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
291
+ const focusScope = React.useRef({
292
+ paused: false,
293
+ pause() {
294
+ this.paused = true;
295
+ },
296
+ resume() {
297
+ this.paused = false;
298
+ }
299
+ }).current;
300
+ React.useEffect(() => {
301
+ if (trapped) {
302
+ let handleFocusIn2 = function(event) {
303
+ if (focusScope.paused || !container) return;
304
+ const target = event.target;
305
+ if (container.contains(target)) {
306
+ lastFocusedElementRef.current = target;
307
+ } else {
308
+ focus(lastFocusedElementRef.current, { select: true });
309
+ }
310
+ }, handleFocusOut2 = function(event) {
311
+ if (focusScope.paused || !container) return;
312
+ const relatedTarget = event.relatedTarget;
313
+ if (relatedTarget === null) return;
314
+ if (!container.contains(relatedTarget)) {
315
+ focus(lastFocusedElementRef.current, { select: true });
316
+ }
317
+ }, handleMutations2 = function(mutations) {
318
+ const focusedElement = document.activeElement;
319
+ if (focusedElement !== document.body) return;
320
+ for (const mutation of mutations) {
321
+ if (mutation.removedNodes.length > 0) focus(container);
322
+ }
323
+ };
324
+ document.addEventListener("focusin", handleFocusIn2);
325
+ document.addEventListener("focusout", handleFocusOut2);
326
+ const mutationObserver = new MutationObserver(handleMutations2);
327
+ if (container) mutationObserver.observe(container, { childList: true, subtree: true });
328
+ return () => {
329
+ document.removeEventListener("focusin", handleFocusIn2);
330
+ document.removeEventListener("focusout", handleFocusOut2);
331
+ mutationObserver.disconnect();
332
+ };
333
+ }
334
+ }, [trapped, container, focusScope.paused]);
335
+ React.useEffect(() => {
336
+ if (container) {
337
+ focusScopesStack.add(focusScope);
338
+ const previouslyFocusedElement = document.activeElement;
339
+ const hasFocusedCandidate = container.contains(previouslyFocusedElement);
340
+ if (!hasFocusedCandidate) {
341
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
342
+ container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
343
+ container.dispatchEvent(mountEvent);
344
+ if (!mountEvent.defaultPrevented) {
345
+ focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
346
+ if (document.activeElement === previouslyFocusedElement) {
347
+ focus(container);
348
+ }
349
+ }
350
+ }
351
+ return () => {
352
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
353
+ setTimeout(() => {
354
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
355
+ container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
356
+ container.dispatchEvent(unmountEvent);
357
+ if (!unmountEvent.defaultPrevented) {
358
+ focus(previouslyFocusedElement ?? document.body, { select: true });
359
+ }
360
+ container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
361
+ focusScopesStack.remove(focusScope);
362
+ }, 0);
363
+ };
364
+ }
365
+ }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
366
+ const handleKeyDown = React.useCallback(
367
+ (event) => {
368
+ if (!loop && !trapped) return;
369
+ if (focusScope.paused) return;
370
+ const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
371
+ const focusedElement = document.activeElement;
372
+ if (isTabKey && focusedElement) {
373
+ const container2 = event.currentTarget;
374
+ const [first, last] = getTabbableEdges(container2);
375
+ const hasTabbableElementsInside = first && last;
376
+ if (!hasTabbableElementsInside) {
377
+ if (focusedElement === container2) event.preventDefault();
378
+ } else {
379
+ if (!event.shiftKey && focusedElement === last) {
380
+ event.preventDefault();
381
+ if (loop) focus(first, { select: true });
382
+ } else if (event.shiftKey && focusedElement === first) {
383
+ event.preventDefault();
384
+ if (loop) focus(last, { select: true });
385
+ }
386
+ }
387
+ }
388
+ },
389
+ [loop, trapped, focusScope.paused]
390
+ );
391
+ return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
392
+ });
393
+ FocusScope.displayName = FOCUS_SCOPE_NAME;
394
+ function focusFirst(candidates, { select = false } = {}) {
395
+ const previouslyFocusedElement = document.activeElement;
396
+ for (const candidate of candidates) {
397
+ focus(candidate, { select });
398
+ if (document.activeElement !== previouslyFocusedElement) return;
399
+ }
400
+ }
401
+ function getTabbableEdges(container) {
402
+ const candidates = getTabbableCandidates(container);
403
+ const first = findVisible(candidates, container);
404
+ const last = findVisible(candidates.reverse(), container);
405
+ return [first, last];
406
+ }
407
+ function getTabbableCandidates(container) {
408
+ const nodes = [];
409
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
410
+ acceptNode: (node) => {
411
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
412
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
413
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
414
+ }
415
+ });
416
+ while (walker.nextNode()) nodes.push(walker.currentNode);
417
+ return nodes;
418
+ }
419
+ function findVisible(elements, container) {
420
+ for (const element of elements) {
421
+ if (!isHidden(element, { upTo: container })) return element;
422
+ }
423
+ }
424
+ function isHidden(node, { upTo }) {
425
+ if (getComputedStyle(node).visibility === "hidden") return true;
426
+ while (node) {
427
+ if (upTo !== void 0 && node === upTo) return false;
428
+ if (getComputedStyle(node).display === "none") return true;
429
+ node = node.parentElement;
430
+ }
431
+ return false;
432
+ }
433
+ function isSelectableInput(element) {
434
+ return element instanceof HTMLInputElement && "select" in element;
435
+ }
436
+ function focus(element, { select = false } = {}) {
437
+ if (element && element.focus) {
438
+ const previouslyFocusedElement = document.activeElement;
439
+ element.focus({ preventScroll: true });
440
+ if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
441
+ element.select();
442
+ }
443
+ }
444
+ var focusScopesStack = createFocusScopesStack();
445
+ function createFocusScopesStack() {
446
+ let stack = [];
447
+ return {
448
+ add(focusScope) {
449
+ const activeFocusScope = stack[0];
450
+ if (focusScope !== activeFocusScope) {
451
+ activeFocusScope?.pause();
452
+ }
453
+ stack = arrayRemove(stack, focusScope);
454
+ stack.unshift(focusScope);
455
+ },
456
+ remove(focusScope) {
457
+ stack = arrayRemove(stack, focusScope);
458
+ stack[0]?.resume();
459
+ }
460
+ };
461
+ }
462
+ function arrayRemove(array, item) {
463
+ const updatedArray = [...array];
464
+ const index = updatedArray.indexOf(item);
465
+ if (index !== -1) {
466
+ updatedArray.splice(index, 1);
467
+ }
468
+ return updatedArray;
469
+ }
470
+ function removeLinks(items) {
471
+ return items.filter((item) => item.tagName !== "A");
472
+ }
473
+
474
+ // packages/react/id/src/id.tsx
475
+ var useReactId = React[" useId ".trim().toString()] || (() => void 0);
476
+ var count = 0;
477
+ function useId(deterministicId) {
478
+ const [id, setId] = React.useState(useReactId());
479
+ useLayoutEffect2(() => {
480
+ setId((reactId) => reactId ?? String(count++));
481
+ }, [deterministicId]);
482
+ return deterministicId || (id ? `radix-${id}` : "");
483
+ }
484
+
485
+ /**
486
+ * Custom positioning reference element.
487
+ * @see https://floating-ui.com/docs/virtual-elements
488
+ */
489
+
490
+ const sides = ['top', 'right', 'bottom', 'left'];
491
+ const min = Math.min;
492
+ const max = Math.max;
493
+ const round = Math.round;
494
+ const floor = Math.floor;
495
+ const createCoords = v => ({
496
+ x: v,
497
+ y: v
498
+ });
499
+ const oppositeSideMap = {
500
+ left: 'right',
501
+ right: 'left',
502
+ bottom: 'top',
503
+ top: 'bottom'
504
+ };
505
+ const oppositeAlignmentMap = {
506
+ start: 'end',
507
+ end: 'start'
508
+ };
509
+ function clamp(start, value, end) {
510
+ return max(start, min(value, end));
511
+ }
512
+ function evaluate(value, param) {
513
+ return typeof value === 'function' ? value(param) : value;
514
+ }
515
+ function getSide(placement) {
516
+ return placement.split('-')[0];
517
+ }
518
+ function getAlignment(placement) {
519
+ return placement.split('-')[1];
520
+ }
521
+ function getOppositeAxis(axis) {
522
+ return axis === 'x' ? 'y' : 'x';
523
+ }
524
+ function getAxisLength(axis) {
525
+ return axis === 'y' ? 'height' : 'width';
526
+ }
527
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
528
+ function getSideAxis(placement) {
529
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
530
+ }
531
+ function getAlignmentAxis(placement) {
532
+ return getOppositeAxis(getSideAxis(placement));
533
+ }
534
+ function getAlignmentSides(placement, rects, rtl) {
535
+ if (rtl === void 0) {
536
+ rtl = false;
537
+ }
538
+ const alignment = getAlignment(placement);
539
+ const alignmentAxis = getAlignmentAxis(placement);
540
+ const length = getAxisLength(alignmentAxis);
541
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
542
+ if (rects.reference[length] > rects.floating[length]) {
543
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
544
+ }
545
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
546
+ }
547
+ function getExpandedPlacements(placement) {
548
+ const oppositePlacement = getOppositePlacement(placement);
549
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
550
+ }
551
+ function getOppositeAlignmentPlacement(placement) {
552
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
553
+ }
554
+ const lrPlacement = ['left', 'right'];
555
+ const rlPlacement = ['right', 'left'];
556
+ const tbPlacement = ['top', 'bottom'];
557
+ const btPlacement = ['bottom', 'top'];
558
+ function getSideList(side, isStart, rtl) {
559
+ switch (side) {
560
+ case 'top':
561
+ case 'bottom':
562
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
563
+ return isStart ? lrPlacement : rlPlacement;
564
+ case 'left':
565
+ case 'right':
566
+ return isStart ? tbPlacement : btPlacement;
567
+ default:
568
+ return [];
569
+ }
570
+ }
571
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
572
+ const alignment = getAlignment(placement);
573
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
574
+ if (alignment) {
575
+ list = list.map(side => side + "-" + alignment);
576
+ if (flipAlignment) {
577
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
578
+ }
579
+ }
580
+ return list;
581
+ }
582
+ function getOppositePlacement(placement) {
583
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
584
+ }
585
+ function expandPaddingObject(padding) {
586
+ return {
587
+ top: 0,
588
+ right: 0,
589
+ bottom: 0,
590
+ left: 0,
591
+ ...padding
592
+ };
593
+ }
594
+ function getPaddingObject(padding) {
595
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
596
+ top: padding,
597
+ right: padding,
598
+ bottom: padding,
599
+ left: padding
600
+ };
601
+ }
602
+ function rectToClientRect(rect) {
603
+ const {
604
+ x,
605
+ y,
606
+ width,
607
+ height
608
+ } = rect;
609
+ return {
610
+ width,
611
+ height,
612
+ top: y,
613
+ left: x,
614
+ right: x + width,
615
+ bottom: y + height,
616
+ x,
617
+ y
618
+ };
619
+ }
620
+
621
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
622
+ let {
623
+ reference,
624
+ floating
625
+ } = _ref;
626
+ const sideAxis = getSideAxis(placement);
627
+ const alignmentAxis = getAlignmentAxis(placement);
628
+ const alignLength = getAxisLength(alignmentAxis);
629
+ const side = getSide(placement);
630
+ const isVertical = sideAxis === 'y';
631
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
632
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
633
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
634
+ let coords;
635
+ switch (side) {
636
+ case 'top':
637
+ coords = {
638
+ x: commonX,
639
+ y: reference.y - floating.height
640
+ };
641
+ break;
642
+ case 'bottom':
643
+ coords = {
644
+ x: commonX,
645
+ y: reference.y + reference.height
646
+ };
647
+ break;
648
+ case 'right':
649
+ coords = {
650
+ x: reference.x + reference.width,
651
+ y: commonY
652
+ };
653
+ break;
654
+ case 'left':
655
+ coords = {
656
+ x: reference.x - floating.width,
657
+ y: commonY
658
+ };
659
+ break;
660
+ default:
661
+ coords = {
662
+ x: reference.x,
663
+ y: reference.y
664
+ };
665
+ }
666
+ switch (getAlignment(placement)) {
667
+ case 'start':
668
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
669
+ break;
670
+ case 'end':
671
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
672
+ break;
673
+ }
674
+ return coords;
675
+ }
676
+
677
+ /**
678
+ * Computes the `x` and `y` coordinates that will place the floating element
679
+ * next to a given reference element.
680
+ *
681
+ * This export does not have any `platform` interface logic. You will need to
682
+ * write one for the platform you are using Floating UI with.
683
+ */
684
+ const computePosition$1 = async (reference, floating, config) => {
685
+ const {
686
+ placement = 'bottom',
687
+ strategy = 'absolute',
688
+ middleware = [],
689
+ platform
690
+ } = config;
691
+ const validMiddleware = middleware.filter(Boolean);
692
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
693
+ let rects = await platform.getElementRects({
694
+ reference,
695
+ floating,
696
+ strategy
697
+ });
698
+ let {
699
+ x,
700
+ y
701
+ } = computeCoordsFromPlacement(rects, placement, rtl);
702
+ let statefulPlacement = placement;
703
+ let middlewareData = {};
704
+ let resetCount = 0;
705
+ for (let i = 0; i < validMiddleware.length; i++) {
706
+ const {
707
+ name,
708
+ fn
709
+ } = validMiddleware[i];
710
+ const {
711
+ x: nextX,
712
+ y: nextY,
713
+ data,
714
+ reset
715
+ } = await fn({
716
+ x,
717
+ y,
718
+ initialPlacement: placement,
719
+ placement: statefulPlacement,
720
+ strategy,
721
+ middlewareData,
722
+ rects,
723
+ platform,
724
+ elements: {
725
+ reference,
726
+ floating
727
+ }
728
+ });
729
+ x = nextX != null ? nextX : x;
730
+ y = nextY != null ? nextY : y;
731
+ middlewareData = {
732
+ ...middlewareData,
733
+ [name]: {
734
+ ...middlewareData[name],
735
+ ...data
736
+ }
737
+ };
738
+ if (reset && resetCount <= 50) {
739
+ resetCount++;
740
+ if (typeof reset === 'object') {
741
+ if (reset.placement) {
742
+ statefulPlacement = reset.placement;
743
+ }
744
+ if (reset.rects) {
745
+ rects = reset.rects === true ? await platform.getElementRects({
746
+ reference,
747
+ floating,
748
+ strategy
749
+ }) : reset.rects;
750
+ }
751
+ ({
752
+ x,
753
+ y
754
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
755
+ }
756
+ i = -1;
757
+ }
758
+ }
759
+ return {
760
+ x,
761
+ y,
762
+ placement: statefulPlacement,
763
+ strategy,
764
+ middlewareData
765
+ };
766
+ };
767
+
768
+ /**
769
+ * Resolves with an object of overflow side offsets that determine how much the
770
+ * element is overflowing a given clipping boundary on each side.
771
+ * - positive = overflowing the boundary by that number of pixels
772
+ * - negative = how many pixels left before it will overflow
773
+ * - 0 = lies flush with the boundary
774
+ * @see https://floating-ui.com/docs/detectOverflow
775
+ */
776
+ async function detectOverflow(state, options) {
777
+ var _await$platform$isEle;
778
+ if (options === void 0) {
779
+ options = {};
780
+ }
781
+ const {
782
+ x,
783
+ y,
784
+ platform,
785
+ rects,
786
+ elements,
787
+ strategy
788
+ } = state;
789
+ const {
790
+ boundary = 'clippingAncestors',
791
+ rootBoundary = 'viewport',
792
+ elementContext = 'floating',
793
+ altBoundary = false,
794
+ padding = 0
795
+ } = evaluate(options, state);
796
+ const paddingObject = getPaddingObject(padding);
797
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
798
+ const element = elements[altBoundary ? altContext : elementContext];
799
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
800
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
801
+ boundary,
802
+ rootBoundary,
803
+ strategy
804
+ }));
805
+ const rect = elementContext === 'floating' ? {
806
+ x,
807
+ y,
808
+ width: rects.floating.width,
809
+ height: rects.floating.height
810
+ } : rects.reference;
811
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
812
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
813
+ x: 1,
814
+ y: 1
815
+ } : {
816
+ x: 1,
817
+ y: 1
818
+ };
819
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
820
+ elements,
821
+ rect,
822
+ offsetParent,
823
+ strategy
824
+ }) : rect);
825
+ return {
826
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
827
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
828
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
829
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
830
+ };
831
+ }
832
+
833
+ /**
834
+ * Provides data to position an inner element of the floating element so that it
835
+ * appears centered to the reference element.
836
+ * @see https://floating-ui.com/docs/arrow
837
+ */
838
+ const arrow$3 = options => ({
839
+ name: 'arrow',
840
+ options,
841
+ async fn(state) {
842
+ const {
843
+ x,
844
+ y,
845
+ placement,
846
+ rects,
847
+ platform,
848
+ elements,
849
+ middlewareData
850
+ } = state;
851
+ // Since `element` is required, we don't Partial<> the type.
852
+ const {
853
+ element,
854
+ padding = 0
855
+ } = evaluate(options, state) || {};
856
+ if (element == null) {
857
+ return {};
858
+ }
859
+ const paddingObject = getPaddingObject(padding);
860
+ const coords = {
861
+ x,
862
+ y
863
+ };
864
+ const axis = getAlignmentAxis(placement);
865
+ const length = getAxisLength(axis);
866
+ const arrowDimensions = await platform.getDimensions(element);
867
+ const isYAxis = axis === 'y';
868
+ const minProp = isYAxis ? 'top' : 'left';
869
+ const maxProp = isYAxis ? 'bottom' : 'right';
870
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
871
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
872
+ const startDiff = coords[axis] - rects.reference[axis];
873
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
874
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
875
+
876
+ // DOM platform can return `window` as the `offsetParent`.
877
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
878
+ clientSize = elements.floating[clientProp] || rects.floating[length];
879
+ }
880
+ const centerToReference = endDiff / 2 - startDiff / 2;
881
+
882
+ // If the padding is large enough that it causes the arrow to no longer be
883
+ // centered, modify the padding so that it is centered.
884
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
885
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
886
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
887
+
888
+ // Make sure the arrow doesn't overflow the floating element if the center
889
+ // point is outside the floating element's bounds.
890
+ const min$1 = minPadding;
891
+ const max = clientSize - arrowDimensions[length] - maxPadding;
892
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
893
+ const offset = clamp(min$1, center, max);
894
+
895
+ // If the reference is small enough that the arrow's padding causes it to
896
+ // to point to nothing for an aligned placement, adjust the offset of the
897
+ // floating element itself. To ensure `shift()` continues to take action,
898
+ // a single reset is performed when this is true.
899
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
900
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
901
+ return {
902
+ [axis]: coords[axis] + alignmentOffset,
903
+ data: {
904
+ [axis]: offset,
905
+ centerOffset: center - offset - alignmentOffset,
906
+ ...(shouldAddOffset && {
907
+ alignmentOffset
908
+ })
909
+ },
910
+ reset: shouldAddOffset
911
+ };
912
+ }
913
+ });
914
+
915
+ /**
916
+ * Optimizes the visibility of the floating element by flipping the `placement`
917
+ * in order to keep it in view when the preferred placement(s) will overflow the
918
+ * clipping boundary. Alternative to `autoPlacement`.
919
+ * @see https://floating-ui.com/docs/flip
920
+ */
921
+ const flip$2 = function (options) {
922
+ if (options === void 0) {
923
+ options = {};
924
+ }
925
+ return {
926
+ name: 'flip',
927
+ options,
928
+ async fn(state) {
929
+ var _middlewareData$arrow, _middlewareData$flip;
930
+ const {
931
+ placement,
932
+ middlewareData,
933
+ rects,
934
+ initialPlacement,
935
+ platform,
936
+ elements
937
+ } = state;
938
+ const {
939
+ mainAxis: checkMainAxis = true,
940
+ crossAxis: checkCrossAxis = true,
941
+ fallbackPlacements: specifiedFallbackPlacements,
942
+ fallbackStrategy = 'bestFit',
943
+ fallbackAxisSideDirection = 'none',
944
+ flipAlignment = true,
945
+ ...detectOverflowOptions
946
+ } = evaluate(options, state);
947
+
948
+ // If a reset by the arrow was caused due to an alignment offset being
949
+ // added, we should skip any logic now since `flip()` has already done its
950
+ // work.
951
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
952
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
953
+ return {};
954
+ }
955
+ const side = getSide(placement);
956
+ const initialSideAxis = getSideAxis(initialPlacement);
957
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
958
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
959
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
960
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
961
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
962
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
963
+ }
964
+ const placements = [initialPlacement, ...fallbackPlacements];
965
+ const overflow = await detectOverflow(state, detectOverflowOptions);
966
+ const overflows = [];
967
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
968
+ if (checkMainAxis) {
969
+ overflows.push(overflow[side]);
970
+ }
971
+ if (checkCrossAxis) {
972
+ const sides = getAlignmentSides(placement, rects, rtl);
973
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
974
+ }
975
+ overflowsData = [...overflowsData, {
976
+ placement,
977
+ overflows
978
+ }];
979
+
980
+ // One or more sides is overflowing.
981
+ if (!overflows.every(side => side <= 0)) {
982
+ var _middlewareData$flip2, _overflowsData$filter;
983
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
984
+ const nextPlacement = placements[nextIndex];
985
+ if (nextPlacement) {
986
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
987
+ if (!ignoreCrossAxisOverflow ||
988
+ // We leave the current main axis only if every placement on that axis
989
+ // overflows the main axis.
990
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
991
+ // Try next placement and re-run the lifecycle.
992
+ return {
993
+ data: {
994
+ index: nextIndex,
995
+ overflows: overflowsData
996
+ },
997
+ reset: {
998
+ placement: nextPlacement
999
+ }
1000
+ };
1001
+ }
1002
+ }
1003
+
1004
+ // First, find the candidates that fit on the mainAxis side of overflow,
1005
+ // then find the placement that fits the best on the main crossAxis side.
1006
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1007
+
1008
+ // Otherwise fallback.
1009
+ if (!resetPlacement) {
1010
+ switch (fallbackStrategy) {
1011
+ case 'bestFit':
1012
+ {
1013
+ var _overflowsData$filter2;
1014
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
1015
+ if (hasFallbackAxisSideDirection) {
1016
+ const currentSideAxis = getSideAxis(d.placement);
1017
+ return currentSideAxis === initialSideAxis ||
1018
+ // Create a bias to the `y` side axis due to horizontal
1019
+ // reading directions favoring greater width.
1020
+ currentSideAxis === 'y';
1021
+ }
1022
+ return true;
1023
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
1024
+ if (placement) {
1025
+ resetPlacement = placement;
1026
+ }
1027
+ break;
1028
+ }
1029
+ case 'initialPlacement':
1030
+ resetPlacement = initialPlacement;
1031
+ break;
1032
+ }
1033
+ }
1034
+ if (placement !== resetPlacement) {
1035
+ return {
1036
+ reset: {
1037
+ placement: resetPlacement
1038
+ }
1039
+ };
1040
+ }
1041
+ }
1042
+ return {};
1043
+ }
1044
+ };
1045
+ };
1046
+
1047
+ function getSideOffsets(overflow, rect) {
1048
+ return {
1049
+ top: overflow.top - rect.height,
1050
+ right: overflow.right - rect.width,
1051
+ bottom: overflow.bottom - rect.height,
1052
+ left: overflow.left - rect.width
1053
+ };
1054
+ }
1055
+ function isAnySideFullyClipped(overflow) {
1056
+ return sides.some(side => overflow[side] >= 0);
1057
+ }
1058
+ /**
1059
+ * Provides data to hide the floating element in applicable situations, such as
1060
+ * when it is not in the same clipping context as the reference element.
1061
+ * @see https://floating-ui.com/docs/hide
1062
+ */
1063
+ const hide$2 = function (options) {
1064
+ if (options === void 0) {
1065
+ options = {};
1066
+ }
1067
+ return {
1068
+ name: 'hide',
1069
+ options,
1070
+ async fn(state) {
1071
+ const {
1072
+ rects
1073
+ } = state;
1074
+ const {
1075
+ strategy = 'referenceHidden',
1076
+ ...detectOverflowOptions
1077
+ } = evaluate(options, state);
1078
+ switch (strategy) {
1079
+ case 'referenceHidden':
1080
+ {
1081
+ const overflow = await detectOverflow(state, {
1082
+ ...detectOverflowOptions,
1083
+ elementContext: 'reference'
1084
+ });
1085
+ const offsets = getSideOffsets(overflow, rects.reference);
1086
+ return {
1087
+ data: {
1088
+ referenceHiddenOffsets: offsets,
1089
+ referenceHidden: isAnySideFullyClipped(offsets)
1090
+ }
1091
+ };
1092
+ }
1093
+ case 'escaped':
1094
+ {
1095
+ const overflow = await detectOverflow(state, {
1096
+ ...detectOverflowOptions,
1097
+ altBoundary: true
1098
+ });
1099
+ const offsets = getSideOffsets(overflow, rects.floating);
1100
+ return {
1101
+ data: {
1102
+ escapedOffsets: offsets,
1103
+ escaped: isAnySideFullyClipped(offsets)
1104
+ }
1105
+ };
1106
+ }
1107
+ default:
1108
+ {
1109
+ return {};
1110
+ }
1111
+ }
1112
+ }
1113
+ };
1114
+ };
1115
+
1116
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
1117
+
1118
+ // For type backwards-compatibility, the `OffsetOptions` type was also
1119
+ // Derivable.
1120
+
1121
+ async function convertValueToCoords(state, options) {
1122
+ const {
1123
+ placement,
1124
+ platform,
1125
+ elements
1126
+ } = state;
1127
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1128
+ const side = getSide(placement);
1129
+ const alignment = getAlignment(placement);
1130
+ const isVertical = getSideAxis(placement) === 'y';
1131
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
1132
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1133
+ const rawValue = evaluate(options, state);
1134
+
1135
+ // eslint-disable-next-line prefer-const
1136
+ let {
1137
+ mainAxis,
1138
+ crossAxis,
1139
+ alignmentAxis
1140
+ } = typeof rawValue === 'number' ? {
1141
+ mainAxis: rawValue,
1142
+ crossAxis: 0,
1143
+ alignmentAxis: null
1144
+ } : {
1145
+ mainAxis: rawValue.mainAxis || 0,
1146
+ crossAxis: rawValue.crossAxis || 0,
1147
+ alignmentAxis: rawValue.alignmentAxis
1148
+ };
1149
+ if (alignment && typeof alignmentAxis === 'number') {
1150
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1151
+ }
1152
+ return isVertical ? {
1153
+ x: crossAxis * crossAxisMulti,
1154
+ y: mainAxis * mainAxisMulti
1155
+ } : {
1156
+ x: mainAxis * mainAxisMulti,
1157
+ y: crossAxis * crossAxisMulti
1158
+ };
1159
+ }
1160
+
1161
+ /**
1162
+ * Modifies the placement by translating the floating element along the
1163
+ * specified axes.
1164
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1165
+ * object may be passed.
1166
+ * @see https://floating-ui.com/docs/offset
1167
+ */
1168
+ const offset$2 = function (options) {
1169
+ if (options === void 0) {
1170
+ options = 0;
1171
+ }
1172
+ return {
1173
+ name: 'offset',
1174
+ options,
1175
+ async fn(state) {
1176
+ var _middlewareData$offse, _middlewareData$arrow;
1177
+ const {
1178
+ x,
1179
+ y,
1180
+ placement,
1181
+ middlewareData
1182
+ } = state;
1183
+ const diffCoords = await convertValueToCoords(state, options);
1184
+
1185
+ // If the placement is the same and the arrow caused an alignment offset
1186
+ // then we don't need to change the positioning coordinates.
1187
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1188
+ return {};
1189
+ }
1190
+ return {
1191
+ x: x + diffCoords.x,
1192
+ y: y + diffCoords.y,
1193
+ data: {
1194
+ ...diffCoords,
1195
+ placement
1196
+ }
1197
+ };
1198
+ }
1199
+ };
1200
+ };
1201
+
1202
+ /**
1203
+ * Optimizes the visibility of the floating element by shifting it in order to
1204
+ * keep it in view when it will overflow the clipping boundary.
1205
+ * @see https://floating-ui.com/docs/shift
1206
+ */
1207
+ const shift$2 = function (options) {
1208
+ if (options === void 0) {
1209
+ options = {};
1210
+ }
1211
+ return {
1212
+ name: 'shift',
1213
+ options,
1214
+ async fn(state) {
1215
+ const {
1216
+ x,
1217
+ y,
1218
+ placement
1219
+ } = state;
1220
+ const {
1221
+ mainAxis: checkMainAxis = true,
1222
+ crossAxis: checkCrossAxis = false,
1223
+ limiter = {
1224
+ fn: _ref => {
1225
+ let {
1226
+ x,
1227
+ y
1228
+ } = _ref;
1229
+ return {
1230
+ x,
1231
+ y
1232
+ };
1233
+ }
1234
+ },
1235
+ ...detectOverflowOptions
1236
+ } = evaluate(options, state);
1237
+ const coords = {
1238
+ x,
1239
+ y
1240
+ };
1241
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1242
+ const crossAxis = getSideAxis(getSide(placement));
1243
+ const mainAxis = getOppositeAxis(crossAxis);
1244
+ let mainAxisCoord = coords[mainAxis];
1245
+ let crossAxisCoord = coords[crossAxis];
1246
+ if (checkMainAxis) {
1247
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
1248
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1249
+ const min = mainAxisCoord + overflow[minSide];
1250
+ const max = mainAxisCoord - overflow[maxSide];
1251
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
1252
+ }
1253
+ if (checkCrossAxis) {
1254
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
1255
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1256
+ const min = crossAxisCoord + overflow[minSide];
1257
+ const max = crossAxisCoord - overflow[maxSide];
1258
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
1259
+ }
1260
+ const limitedCoords = limiter.fn({
1261
+ ...state,
1262
+ [mainAxis]: mainAxisCoord,
1263
+ [crossAxis]: crossAxisCoord
1264
+ });
1265
+ return {
1266
+ ...limitedCoords,
1267
+ data: {
1268
+ x: limitedCoords.x - x,
1269
+ y: limitedCoords.y - y,
1270
+ enabled: {
1271
+ [mainAxis]: checkMainAxis,
1272
+ [crossAxis]: checkCrossAxis
1273
+ }
1274
+ }
1275
+ };
1276
+ }
1277
+ };
1278
+ };
1279
+ /**
1280
+ * Built-in `limiter` that will stop `shift()` at a certain point.
1281
+ */
1282
+ const limitShift$2 = function (options) {
1283
+ if (options === void 0) {
1284
+ options = {};
1285
+ }
1286
+ return {
1287
+ options,
1288
+ fn(state) {
1289
+ const {
1290
+ x,
1291
+ y,
1292
+ placement,
1293
+ rects,
1294
+ middlewareData
1295
+ } = state;
1296
+ const {
1297
+ offset = 0,
1298
+ mainAxis: checkMainAxis = true,
1299
+ crossAxis: checkCrossAxis = true
1300
+ } = evaluate(options, state);
1301
+ const coords = {
1302
+ x,
1303
+ y
1304
+ };
1305
+ const crossAxis = getSideAxis(placement);
1306
+ const mainAxis = getOppositeAxis(crossAxis);
1307
+ let mainAxisCoord = coords[mainAxis];
1308
+ let crossAxisCoord = coords[crossAxis];
1309
+ const rawOffset = evaluate(offset, state);
1310
+ const computedOffset = typeof rawOffset === 'number' ? {
1311
+ mainAxis: rawOffset,
1312
+ crossAxis: 0
1313
+ } : {
1314
+ mainAxis: 0,
1315
+ crossAxis: 0,
1316
+ ...rawOffset
1317
+ };
1318
+ if (checkMainAxis) {
1319
+ const len = mainAxis === 'y' ? 'height' : 'width';
1320
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1321
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1322
+ if (mainAxisCoord < limitMin) {
1323
+ mainAxisCoord = limitMin;
1324
+ } else if (mainAxisCoord > limitMax) {
1325
+ mainAxisCoord = limitMax;
1326
+ }
1327
+ }
1328
+ if (checkCrossAxis) {
1329
+ var _middlewareData$offse, _middlewareData$offse2;
1330
+ const len = mainAxis === 'y' ? 'width' : 'height';
1331
+ const isOriginSide = originSides.has(getSide(placement));
1332
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1333
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1334
+ if (crossAxisCoord < limitMin) {
1335
+ crossAxisCoord = limitMin;
1336
+ } else if (crossAxisCoord > limitMax) {
1337
+ crossAxisCoord = limitMax;
1338
+ }
1339
+ }
1340
+ return {
1341
+ [mainAxis]: mainAxisCoord,
1342
+ [crossAxis]: crossAxisCoord
1343
+ };
1344
+ }
1345
+ };
1346
+ };
1347
+
1348
+ /**
1349
+ * Provides data that allows you to change the size of the floating element —
1350
+ * for instance, prevent it from overflowing the clipping boundary or match the
1351
+ * width of the reference element.
1352
+ * @see https://floating-ui.com/docs/size
1353
+ */
1354
+ const size$2 = function (options) {
1355
+ if (options === void 0) {
1356
+ options = {};
1357
+ }
1358
+ return {
1359
+ name: 'size',
1360
+ options,
1361
+ async fn(state) {
1362
+ var _state$middlewareData, _state$middlewareData2;
1363
+ const {
1364
+ placement,
1365
+ rects,
1366
+ platform,
1367
+ elements
1368
+ } = state;
1369
+ const {
1370
+ apply = () => {},
1371
+ ...detectOverflowOptions
1372
+ } = evaluate(options, state);
1373
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1374
+ const side = getSide(placement);
1375
+ const alignment = getAlignment(placement);
1376
+ const isYAxis = getSideAxis(placement) === 'y';
1377
+ const {
1378
+ width,
1379
+ height
1380
+ } = rects.floating;
1381
+ let heightSide;
1382
+ let widthSide;
1383
+ if (side === 'top' || side === 'bottom') {
1384
+ heightSide = side;
1385
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
1386
+ } else {
1387
+ widthSide = side;
1388
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
1389
+ }
1390
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1391
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1392
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1393
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1394
+ const noShift = !state.middlewareData.shift;
1395
+ let availableHeight = overflowAvailableHeight;
1396
+ let availableWidth = overflowAvailableWidth;
1397
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1398
+ availableWidth = maximumClippingWidth;
1399
+ }
1400
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1401
+ availableHeight = maximumClippingHeight;
1402
+ }
1403
+ if (noShift && !alignment) {
1404
+ const xMin = max(overflow.left, 0);
1405
+ const xMax = max(overflow.right, 0);
1406
+ const yMin = max(overflow.top, 0);
1407
+ const yMax = max(overflow.bottom, 0);
1408
+ if (isYAxis) {
1409
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1410
+ } else {
1411
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1412
+ }
1413
+ }
1414
+ await apply({
1415
+ ...state,
1416
+ availableWidth,
1417
+ availableHeight
1418
+ });
1419
+ const nextDimensions = await platform.getDimensions(elements.floating);
1420
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1421
+ return {
1422
+ reset: {
1423
+ rects: true
1424
+ }
1425
+ };
1426
+ }
1427
+ return {};
1428
+ }
1429
+ };
1430
+ };
1431
+
1432
+ function hasWindow() {
1433
+ return typeof window !== 'undefined';
1434
+ }
1435
+ function getNodeName(node) {
1436
+ if (isNode(node)) {
1437
+ return (node.nodeName || '').toLowerCase();
1438
+ }
1439
+ // Mocked nodes in testing environments may not be instances of Node. By
1440
+ // returning `#document` an infinite loop won't occur.
1441
+ // https://github.com/floating-ui/floating-ui/issues/2317
1442
+ return '#document';
1443
+ }
1444
+ function getWindow(node) {
1445
+ var _node$ownerDocument;
1446
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1447
+ }
1448
+ function getDocumentElement(node) {
1449
+ var _ref;
1450
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1451
+ }
1452
+ function isNode(value) {
1453
+ if (!hasWindow()) {
1454
+ return false;
1455
+ }
1456
+ return value instanceof Node || value instanceof getWindow(value).Node;
1457
+ }
1458
+ function isElement(value) {
1459
+ if (!hasWindow()) {
1460
+ return false;
1461
+ }
1462
+ return value instanceof Element || value instanceof getWindow(value).Element;
1463
+ }
1464
+ function isHTMLElement(value) {
1465
+ if (!hasWindow()) {
1466
+ return false;
1467
+ }
1468
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1469
+ }
1470
+ function isShadowRoot(value) {
1471
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1472
+ return false;
1473
+ }
1474
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1475
+ }
1476
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
1477
+ function isOverflowElement(element) {
1478
+ const {
1479
+ overflow,
1480
+ overflowX,
1481
+ overflowY,
1482
+ display
1483
+ } = getComputedStyle$1(element);
1484
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
1485
+ }
1486
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
1487
+ function isTableElement(element) {
1488
+ return tableElements.has(getNodeName(element));
1489
+ }
1490
+ const topLayerSelectors = [':popover-open', ':modal'];
1491
+ function isTopLayer(element) {
1492
+ return topLayerSelectors.some(selector => {
1493
+ try {
1494
+ return element.matches(selector);
1495
+ } catch (_e) {
1496
+ return false;
1497
+ }
1498
+ });
1499
+ }
1500
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
1501
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
1502
+ const containValues = ['paint', 'layout', 'strict', 'content'];
1503
+ function isContainingBlock(elementOrCss) {
1504
+ const webkit = isWebKit();
1505
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
1506
+
1507
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1508
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
1509
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
1510
+ }
1511
+ function getContainingBlock(element) {
1512
+ let currentNode = getParentNode(element);
1513
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1514
+ if (isContainingBlock(currentNode)) {
1515
+ return currentNode;
1516
+ } else if (isTopLayer(currentNode)) {
1517
+ return null;
1518
+ }
1519
+ currentNode = getParentNode(currentNode);
1520
+ }
1521
+ return null;
1522
+ }
1523
+ function isWebKit() {
1524
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1525
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1526
+ }
1527
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
1528
+ function isLastTraversableNode(node) {
1529
+ return lastTraversableNodeNames.has(getNodeName(node));
1530
+ }
1531
+ function getComputedStyle$1(element) {
1532
+ return getWindow(element).getComputedStyle(element);
1533
+ }
1534
+ function getNodeScroll(element) {
1535
+ if (isElement(element)) {
1536
+ return {
1537
+ scrollLeft: element.scrollLeft,
1538
+ scrollTop: element.scrollTop
1539
+ };
1540
+ }
1541
+ return {
1542
+ scrollLeft: element.scrollX,
1543
+ scrollTop: element.scrollY
1544
+ };
1545
+ }
1546
+ function getParentNode(node) {
1547
+ if (getNodeName(node) === 'html') {
1548
+ return node;
1549
+ }
1550
+ const result =
1551
+ // Step into the shadow DOM of the parent of a slotted node.
1552
+ node.assignedSlot ||
1553
+ // DOM Element detected.
1554
+ node.parentNode ||
1555
+ // ShadowRoot detected.
1556
+ isShadowRoot(node) && node.host ||
1557
+ // Fallback.
1558
+ getDocumentElement(node);
1559
+ return isShadowRoot(result) ? result.host : result;
1560
+ }
1561
+ function getNearestOverflowAncestor(node) {
1562
+ const parentNode = getParentNode(node);
1563
+ if (isLastTraversableNode(parentNode)) {
1564
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1565
+ }
1566
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1567
+ return parentNode;
1568
+ }
1569
+ return getNearestOverflowAncestor(parentNode);
1570
+ }
1571
+ function getOverflowAncestors(node, list, traverseIframes) {
1572
+ var _node$ownerDocument2;
1573
+ if (list === void 0) {
1574
+ list = [];
1575
+ }
1576
+ if (traverseIframes === void 0) {
1577
+ traverseIframes = true;
1578
+ }
1579
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1580
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1581
+ const win = getWindow(scrollableAncestor);
1582
+ if (isBody) {
1583
+ const frameElement = getFrameElement(win);
1584
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1585
+ }
1586
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1587
+ }
1588
+ function getFrameElement(win) {
1589
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1590
+ }
1591
+
1592
+ function getCssDimensions(element) {
1593
+ const css = getComputedStyle$1(element);
1594
+ // In testing environments, the `width` and `height` properties are empty
1595
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1596
+ let width = parseFloat(css.width) || 0;
1597
+ let height = parseFloat(css.height) || 0;
1598
+ const hasOffset = isHTMLElement(element);
1599
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1600
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1601
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1602
+ if (shouldFallback) {
1603
+ width = offsetWidth;
1604
+ height = offsetHeight;
1605
+ }
1606
+ return {
1607
+ width,
1608
+ height,
1609
+ $: shouldFallback
1610
+ };
1611
+ }
1612
+
1613
+ function unwrapElement(element) {
1614
+ return !isElement(element) ? element.contextElement : element;
1615
+ }
1616
+
1617
+ function getScale(element) {
1618
+ const domElement = unwrapElement(element);
1619
+ if (!isHTMLElement(domElement)) {
1620
+ return createCoords(1);
1621
+ }
1622
+ const rect = domElement.getBoundingClientRect();
1623
+ const {
1624
+ width,
1625
+ height,
1626
+ $
1627
+ } = getCssDimensions(domElement);
1628
+ let x = ($ ? round(rect.width) : rect.width) / width;
1629
+ let y = ($ ? round(rect.height) : rect.height) / height;
1630
+
1631
+ // 0, NaN, or Infinity should always fallback to 1.
1632
+
1633
+ if (!x || !Number.isFinite(x)) {
1634
+ x = 1;
1635
+ }
1636
+ if (!y || !Number.isFinite(y)) {
1637
+ y = 1;
1638
+ }
1639
+ return {
1640
+ x,
1641
+ y
1642
+ };
1643
+ }
1644
+
1645
+ const noOffsets = /*#__PURE__*/createCoords(0);
1646
+ function getVisualOffsets(element) {
1647
+ const win = getWindow(element);
1648
+ if (!isWebKit() || !win.visualViewport) {
1649
+ return noOffsets;
1650
+ }
1651
+ return {
1652
+ x: win.visualViewport.offsetLeft,
1653
+ y: win.visualViewport.offsetTop
1654
+ };
1655
+ }
1656
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1657
+ if (isFixed === void 0) {
1658
+ isFixed = false;
1659
+ }
1660
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1661
+ return false;
1662
+ }
1663
+ return isFixed;
1664
+ }
1665
+
1666
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1667
+ if (includeScale === void 0) {
1668
+ includeScale = false;
1669
+ }
1670
+ if (isFixedStrategy === void 0) {
1671
+ isFixedStrategy = false;
1672
+ }
1673
+ const clientRect = element.getBoundingClientRect();
1674
+ const domElement = unwrapElement(element);
1675
+ let scale = createCoords(1);
1676
+ if (includeScale) {
1677
+ if (offsetParent) {
1678
+ if (isElement(offsetParent)) {
1679
+ scale = getScale(offsetParent);
1680
+ }
1681
+ } else {
1682
+ scale = getScale(element);
1683
+ }
1684
+ }
1685
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1686
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1687
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1688
+ let width = clientRect.width / scale.x;
1689
+ let height = clientRect.height / scale.y;
1690
+ if (domElement) {
1691
+ const win = getWindow(domElement);
1692
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1693
+ let currentWin = win;
1694
+ let currentIFrame = getFrameElement(currentWin);
1695
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1696
+ const iframeScale = getScale(currentIFrame);
1697
+ const iframeRect = currentIFrame.getBoundingClientRect();
1698
+ const css = getComputedStyle$1(currentIFrame);
1699
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1700
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1701
+ x *= iframeScale.x;
1702
+ y *= iframeScale.y;
1703
+ width *= iframeScale.x;
1704
+ height *= iframeScale.y;
1705
+ x += left;
1706
+ y += top;
1707
+ currentWin = getWindow(currentIFrame);
1708
+ currentIFrame = getFrameElement(currentWin);
1709
+ }
1710
+ }
1711
+ return rectToClientRect({
1712
+ width,
1713
+ height,
1714
+ x,
1715
+ y
1716
+ });
1717
+ }
1718
+
1719
+ // If <html> has a CSS width greater than the viewport, then this will be
1720
+ // incorrect for RTL.
1721
+ function getWindowScrollBarX(element, rect) {
1722
+ const leftScroll = getNodeScroll(element).scrollLeft;
1723
+ if (!rect) {
1724
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1725
+ }
1726
+ return rect.left + leftScroll;
1727
+ }
1728
+
1729
+ function getHTMLOffset(documentElement, scroll) {
1730
+ const htmlRect = documentElement.getBoundingClientRect();
1731
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1732
+ const y = htmlRect.top + scroll.scrollTop;
1733
+ return {
1734
+ x,
1735
+ y
1736
+ };
1737
+ }
1738
+
1739
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1740
+ let {
1741
+ elements,
1742
+ rect,
1743
+ offsetParent,
1744
+ strategy
1745
+ } = _ref;
1746
+ const isFixed = strategy === 'fixed';
1747
+ const documentElement = getDocumentElement(offsetParent);
1748
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1749
+ if (offsetParent === documentElement || topLayer && isFixed) {
1750
+ return rect;
1751
+ }
1752
+ let scroll = {
1753
+ scrollLeft: 0,
1754
+ scrollTop: 0
1755
+ };
1756
+ let scale = createCoords(1);
1757
+ const offsets = createCoords(0);
1758
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1759
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1760
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1761
+ scroll = getNodeScroll(offsetParent);
1762
+ }
1763
+ if (isHTMLElement(offsetParent)) {
1764
+ const offsetRect = getBoundingClientRect(offsetParent);
1765
+ scale = getScale(offsetParent);
1766
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1767
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1768
+ }
1769
+ }
1770
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1771
+ return {
1772
+ width: rect.width * scale.x,
1773
+ height: rect.height * scale.y,
1774
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1775
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1776
+ };
1777
+ }
1778
+
1779
+ function getClientRects(element) {
1780
+ return Array.from(element.getClientRects());
1781
+ }
1782
+
1783
+ // Gets the entire size of the scrollable document area, even extending outside
1784
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1785
+ function getDocumentRect(element) {
1786
+ const html = getDocumentElement(element);
1787
+ const scroll = getNodeScroll(element);
1788
+ const body = element.ownerDocument.body;
1789
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1790
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1791
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1792
+ const y = -scroll.scrollTop;
1793
+ if (getComputedStyle$1(body).direction === 'rtl') {
1794
+ x += max(html.clientWidth, body.clientWidth) - width;
1795
+ }
1796
+ return {
1797
+ width,
1798
+ height,
1799
+ x,
1800
+ y
1801
+ };
1802
+ }
1803
+
1804
+ // Safety check: ensure the scrollbar space is reasonable in case this
1805
+ // calculation is affected by unusual styles.
1806
+ // Most scrollbars leave 15-18px of space.
1807
+ const SCROLLBAR_MAX = 25;
1808
+ function getViewportRect(element, strategy) {
1809
+ const win = getWindow(element);
1810
+ const html = getDocumentElement(element);
1811
+ const visualViewport = win.visualViewport;
1812
+ let width = html.clientWidth;
1813
+ let height = html.clientHeight;
1814
+ let x = 0;
1815
+ let y = 0;
1816
+ if (visualViewport) {
1817
+ width = visualViewport.width;
1818
+ height = visualViewport.height;
1819
+ const visualViewportBased = isWebKit();
1820
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1821
+ x = visualViewport.offsetLeft;
1822
+ y = visualViewport.offsetTop;
1823
+ }
1824
+ }
1825
+ const windowScrollbarX = getWindowScrollBarX(html);
1826
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1827
+ // visual width of the <html> but this is not considered in the size
1828
+ // of `html.clientWidth`.
1829
+ if (windowScrollbarX <= 0) {
1830
+ const doc = html.ownerDocument;
1831
+ const body = doc.body;
1832
+ const bodyStyles = getComputedStyle(body);
1833
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1834
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1835
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1836
+ width -= clippingStableScrollbarWidth;
1837
+ }
1838
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1839
+ // If the <body> scrollbar is on the left, the width needs to be extended
1840
+ // by the scrollbar amount so there isn't extra space on the right.
1841
+ width += windowScrollbarX;
1842
+ }
1843
+ return {
1844
+ width,
1845
+ height,
1846
+ x,
1847
+ y
1848
+ };
1849
+ }
1850
+
1851
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1852
+ // Returns the inner client rect, subtracting scrollbars if present.
1853
+ function getInnerBoundingClientRect(element, strategy) {
1854
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1855
+ const top = clientRect.top + element.clientTop;
1856
+ const left = clientRect.left + element.clientLeft;
1857
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1858
+ const width = element.clientWidth * scale.x;
1859
+ const height = element.clientHeight * scale.y;
1860
+ const x = left * scale.x;
1861
+ const y = top * scale.y;
1862
+ return {
1863
+ width,
1864
+ height,
1865
+ x,
1866
+ y
1867
+ };
1868
+ }
1869
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1870
+ let rect;
1871
+ if (clippingAncestor === 'viewport') {
1872
+ rect = getViewportRect(element, strategy);
1873
+ } else if (clippingAncestor === 'document') {
1874
+ rect = getDocumentRect(getDocumentElement(element));
1875
+ } else if (isElement(clippingAncestor)) {
1876
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1877
+ } else {
1878
+ const visualOffsets = getVisualOffsets(element);
1879
+ rect = {
1880
+ x: clippingAncestor.x - visualOffsets.x,
1881
+ y: clippingAncestor.y - visualOffsets.y,
1882
+ width: clippingAncestor.width,
1883
+ height: clippingAncestor.height
1884
+ };
1885
+ }
1886
+ return rectToClientRect(rect);
1887
+ }
1888
+ function hasFixedPositionAncestor(element, stopNode) {
1889
+ const parentNode = getParentNode(element);
1890
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1891
+ return false;
1892
+ }
1893
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1894
+ }
1895
+
1896
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1897
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1898
+ // of the given element up the tree.
1899
+ function getClippingElementAncestors(element, cache) {
1900
+ const cachedResult = cache.get(element);
1901
+ if (cachedResult) {
1902
+ return cachedResult;
1903
+ }
1904
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1905
+ let currentContainingBlockComputedStyle = null;
1906
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1907
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1908
+
1909
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1910
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1911
+ const computedStyle = getComputedStyle$1(currentNode);
1912
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1913
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1914
+ currentContainingBlockComputedStyle = null;
1915
+ }
1916
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1917
+ if (shouldDropCurrentNode) {
1918
+ // Drop non-containing blocks.
1919
+ result = result.filter(ancestor => ancestor !== currentNode);
1920
+ } else {
1921
+ // Record last containing block for next iteration.
1922
+ currentContainingBlockComputedStyle = computedStyle;
1923
+ }
1924
+ currentNode = getParentNode(currentNode);
1925
+ }
1926
+ cache.set(element, result);
1927
+ return result;
1928
+ }
1929
+
1930
+ // Gets the maximum area that the element is visible in due to any number of
1931
+ // clipping ancestors.
1932
+ function getClippingRect(_ref) {
1933
+ let {
1934
+ element,
1935
+ boundary,
1936
+ rootBoundary,
1937
+ strategy
1938
+ } = _ref;
1939
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1940
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1941
+ const firstClippingAncestor = clippingAncestors[0];
1942
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1943
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1944
+ accRect.top = max(rect.top, accRect.top);
1945
+ accRect.right = min(rect.right, accRect.right);
1946
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1947
+ accRect.left = max(rect.left, accRect.left);
1948
+ return accRect;
1949
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1950
+ return {
1951
+ width: clippingRect.right - clippingRect.left,
1952
+ height: clippingRect.bottom - clippingRect.top,
1953
+ x: clippingRect.left,
1954
+ y: clippingRect.top
1955
+ };
1956
+ }
1957
+
1958
+ function getDimensions(element) {
1959
+ const {
1960
+ width,
1961
+ height
1962
+ } = getCssDimensions(element);
1963
+ return {
1964
+ width,
1965
+ height
1966
+ };
1967
+ }
1968
+
1969
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1970
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1971
+ const documentElement = getDocumentElement(offsetParent);
1972
+ const isFixed = strategy === 'fixed';
1973
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1974
+ let scroll = {
1975
+ scrollLeft: 0,
1976
+ scrollTop: 0
1977
+ };
1978
+ const offsets = createCoords(0);
1979
+
1980
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1981
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1982
+ function setLeftRTLScrollbarOffset() {
1983
+ offsets.x = getWindowScrollBarX(documentElement);
1984
+ }
1985
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1986
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1987
+ scroll = getNodeScroll(offsetParent);
1988
+ }
1989
+ if (isOffsetParentAnElement) {
1990
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1991
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1992
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1993
+ } else if (documentElement) {
1994
+ setLeftRTLScrollbarOffset();
1995
+ }
1996
+ }
1997
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1998
+ setLeftRTLScrollbarOffset();
1999
+ }
2000
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2001
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2002
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2003
+ return {
2004
+ x,
2005
+ y,
2006
+ width: rect.width,
2007
+ height: rect.height
2008
+ };
2009
+ }
2010
+
2011
+ function isStaticPositioned(element) {
2012
+ return getComputedStyle$1(element).position === 'static';
2013
+ }
2014
+
2015
+ function getTrueOffsetParent(element, polyfill) {
2016
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
2017
+ return null;
2018
+ }
2019
+ if (polyfill) {
2020
+ return polyfill(element);
2021
+ }
2022
+ let rawOffsetParent = element.offsetParent;
2023
+
2024
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
2025
+ // while Chrome and Safari return the <body> element. The <body> element must
2026
+ // be used to perform the correct calculations even if the <html> element is
2027
+ // non-static.
2028
+ if (getDocumentElement(element) === rawOffsetParent) {
2029
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
2030
+ }
2031
+ return rawOffsetParent;
2032
+ }
2033
+
2034
+ // Gets the closest ancestor positioned element. Handles some edge cases,
2035
+ // such as table ancestors and cross browser bugs.
2036
+ function getOffsetParent(element, polyfill) {
2037
+ const win = getWindow(element);
2038
+ if (isTopLayer(element)) {
2039
+ return win;
2040
+ }
2041
+ if (!isHTMLElement(element)) {
2042
+ let svgOffsetParent = getParentNode(element);
2043
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2044
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2045
+ return svgOffsetParent;
2046
+ }
2047
+ svgOffsetParent = getParentNode(svgOffsetParent);
2048
+ }
2049
+ return win;
2050
+ }
2051
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2052
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2053
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2054
+ }
2055
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2056
+ return win;
2057
+ }
2058
+ return offsetParent || getContainingBlock(element) || win;
2059
+ }
2060
+
2061
+ const getElementRects = async function (data) {
2062
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2063
+ const getDimensionsFn = this.getDimensions;
2064
+ const floatingDimensions = await getDimensionsFn(data.floating);
2065
+ return {
2066
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2067
+ floating: {
2068
+ x: 0,
2069
+ y: 0,
2070
+ width: floatingDimensions.width,
2071
+ height: floatingDimensions.height
2072
+ }
2073
+ };
2074
+ };
2075
+
2076
+ function isRTL(element) {
2077
+ return getComputedStyle$1(element).direction === 'rtl';
2078
+ }
2079
+
2080
+ const platform = {
2081
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2082
+ getDocumentElement,
2083
+ getClippingRect,
2084
+ getOffsetParent,
2085
+ getElementRects,
2086
+ getClientRects,
2087
+ getDimensions,
2088
+ getScale,
2089
+ isElement,
2090
+ isRTL
2091
+ };
2092
+
2093
+ function rectsAreEqual(a, b) {
2094
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
2095
+ }
2096
+
2097
+ // https://samthor.au/2021/observing-dom/
2098
+ function observeMove(element, onMove) {
2099
+ let io = null;
2100
+ let timeoutId;
2101
+ const root = getDocumentElement(element);
2102
+ function cleanup() {
2103
+ var _io;
2104
+ clearTimeout(timeoutId);
2105
+ (_io = io) == null || _io.disconnect();
2106
+ io = null;
2107
+ }
2108
+ function refresh(skip, threshold) {
2109
+ if (skip === void 0) {
2110
+ skip = false;
2111
+ }
2112
+ if (threshold === void 0) {
2113
+ threshold = 1;
2114
+ }
2115
+ cleanup();
2116
+ const elementRectForRootMargin = element.getBoundingClientRect();
2117
+ const {
2118
+ left,
2119
+ top,
2120
+ width,
2121
+ height
2122
+ } = elementRectForRootMargin;
2123
+ if (!skip) {
2124
+ onMove();
2125
+ }
2126
+ if (!width || !height) {
2127
+ return;
2128
+ }
2129
+ const insetTop = floor(top);
2130
+ const insetRight = floor(root.clientWidth - (left + width));
2131
+ const insetBottom = floor(root.clientHeight - (top + height));
2132
+ const insetLeft = floor(left);
2133
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2134
+ const options = {
2135
+ rootMargin,
2136
+ threshold: max(0, min(1, threshold)) || 1
2137
+ };
2138
+ let isFirstUpdate = true;
2139
+ function handleObserve(entries) {
2140
+ const ratio = entries[0].intersectionRatio;
2141
+ if (ratio !== threshold) {
2142
+ if (!isFirstUpdate) {
2143
+ return refresh();
2144
+ }
2145
+ if (!ratio) {
2146
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
2147
+ // to prevent an infinite loop of updates.
2148
+ timeoutId = setTimeout(() => {
2149
+ refresh(false, 1e-7);
2150
+ }, 1000);
2151
+ } else {
2152
+ refresh(false, ratio);
2153
+ }
2154
+ }
2155
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
2156
+ // It's possible that even though the ratio is reported as 1, the
2157
+ // element is not actually fully within the IntersectionObserver's root
2158
+ // area anymore. This can happen under performance constraints. This may
2159
+ // be a bug in the browser's IntersectionObserver implementation. To
2160
+ // work around this, we compare the element's bounding rect now with
2161
+ // what it was at the time we created the IntersectionObserver. If they
2162
+ // are not equal then the element moved, so we refresh.
2163
+ refresh();
2164
+ }
2165
+ isFirstUpdate = false;
2166
+ }
2167
+
2168
+ // Older browsers don't support a `document` as the root and will throw an
2169
+ // error.
2170
+ try {
2171
+ io = new IntersectionObserver(handleObserve, {
2172
+ ...options,
2173
+ // Handle <iframe>s
2174
+ root: root.ownerDocument
2175
+ });
2176
+ } catch (_e) {
2177
+ io = new IntersectionObserver(handleObserve, options);
2178
+ }
2179
+ io.observe(element);
2180
+ }
2181
+ refresh(true);
2182
+ return cleanup;
2183
+ }
2184
+
2185
+ /**
2186
+ * Automatically updates the position of the floating element when necessary.
2187
+ * Should only be called when the floating element is mounted on the DOM or
2188
+ * visible on the screen.
2189
+ * @returns cleanup function that should be invoked when the floating element is
2190
+ * removed from the DOM or hidden from the screen.
2191
+ * @see https://floating-ui.com/docs/autoUpdate
2192
+ */
2193
+ function autoUpdate(reference, floating, update, options) {
2194
+ if (options === void 0) {
2195
+ options = {};
2196
+ }
2197
+ const {
2198
+ ancestorScroll = true,
2199
+ ancestorResize = true,
2200
+ elementResize = typeof ResizeObserver === 'function',
2201
+ layoutShift = typeof IntersectionObserver === 'function',
2202
+ animationFrame = false
2203
+ } = options;
2204
+ const referenceEl = unwrapElement(reference);
2205
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2206
+ ancestors.forEach(ancestor => {
2207
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
2208
+ passive: true
2209
+ });
2210
+ ancestorResize && ancestor.addEventListener('resize', update);
2211
+ });
2212
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2213
+ let reobserveFrame = -1;
2214
+ let resizeObserver = null;
2215
+ if (elementResize) {
2216
+ resizeObserver = new ResizeObserver(_ref => {
2217
+ let [firstEntry] = _ref;
2218
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2219
+ // Prevent update loops when using the `size` middleware.
2220
+ // https://github.com/floating-ui/floating-ui/issues/1740
2221
+ resizeObserver.unobserve(floating);
2222
+ cancelAnimationFrame(reobserveFrame);
2223
+ reobserveFrame = requestAnimationFrame(() => {
2224
+ var _resizeObserver;
2225
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2226
+ });
2227
+ }
2228
+ update();
2229
+ });
2230
+ if (referenceEl && !animationFrame) {
2231
+ resizeObserver.observe(referenceEl);
2232
+ }
2233
+ resizeObserver.observe(floating);
2234
+ }
2235
+ let frameId;
2236
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2237
+ if (animationFrame) {
2238
+ frameLoop();
2239
+ }
2240
+ function frameLoop() {
2241
+ const nextRefRect = getBoundingClientRect(reference);
2242
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
2243
+ update();
2244
+ }
2245
+ prevRefRect = nextRefRect;
2246
+ frameId = requestAnimationFrame(frameLoop);
2247
+ }
2248
+ update();
2249
+ return () => {
2250
+ var _resizeObserver2;
2251
+ ancestors.forEach(ancestor => {
2252
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
2253
+ ancestorResize && ancestor.removeEventListener('resize', update);
2254
+ });
2255
+ cleanupIo == null || cleanupIo();
2256
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2257
+ resizeObserver = null;
2258
+ if (animationFrame) {
2259
+ cancelAnimationFrame(frameId);
2260
+ }
2261
+ };
2262
+ }
2263
+
2264
+ /**
2265
+ * Modifies the placement by translating the floating element along the
2266
+ * specified axes.
2267
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2268
+ * object may be passed.
2269
+ * @see https://floating-ui.com/docs/offset
2270
+ */
2271
+ const offset$1 = offset$2;
2272
+
2273
+ /**
2274
+ * Optimizes the visibility of the floating element by shifting it in order to
2275
+ * keep it in view when it will overflow the clipping boundary.
2276
+ * @see https://floating-ui.com/docs/shift
2277
+ */
2278
+ const shift$1 = shift$2;
2279
+
2280
+ /**
2281
+ * Optimizes the visibility of the floating element by flipping the `placement`
2282
+ * in order to keep it in view when the preferred placement(s) will overflow the
2283
+ * clipping boundary. Alternative to `autoPlacement`.
2284
+ * @see https://floating-ui.com/docs/flip
2285
+ */
2286
+ const flip$1 = flip$2;
2287
+
2288
+ /**
2289
+ * Provides data that allows you to change the size of the floating element —
2290
+ * for instance, prevent it from overflowing the clipping boundary or match the
2291
+ * width of the reference element.
2292
+ * @see https://floating-ui.com/docs/size
2293
+ */
2294
+ const size$1 = size$2;
2295
+
2296
+ /**
2297
+ * Provides data to hide the floating element in applicable situations, such as
2298
+ * when it is not in the same clipping context as the reference element.
2299
+ * @see https://floating-ui.com/docs/hide
2300
+ */
2301
+ const hide$1 = hide$2;
2302
+
2303
+ /**
2304
+ * Provides data to position an inner element of the floating element so that it
2305
+ * appears centered to the reference element.
2306
+ * @see https://floating-ui.com/docs/arrow
2307
+ */
2308
+ const arrow$2 = arrow$3;
2309
+
2310
+ /**
2311
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2312
+ */
2313
+ const limitShift$1 = limitShift$2;
2314
+
2315
+ /**
2316
+ * Computes the `x` and `y` coordinates that will place the floating element
2317
+ * next to a given reference element.
2318
+ */
2319
+ const computePosition = (reference, floating, options) => {
2320
+ // This caches the expensive `getClippingElementAncestors` function so that
2321
+ // multiple lifecycle resets re-use the same result. It only lives for a
2322
+ // single call. If other functions become expensive, we can add them as well.
2323
+ const cache = new Map();
2324
+ const mergedOptions = {
2325
+ platform,
2326
+ ...options
2327
+ };
2328
+ const platformWithCache = {
2329
+ ...mergedOptions.platform,
2330
+ _c: cache
2331
+ };
2332
+ return computePosition$1(reference, floating, {
2333
+ ...mergedOptions,
2334
+ platform: platformWithCache
2335
+ });
2336
+ };
2337
+
2338
+ var isClient = typeof document !== 'undefined';
2339
+
2340
+ var noop = function noop() {};
2341
+ var index = isClient ? useLayoutEffect : noop;
2342
+
2343
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
2344
+ // functions
2345
+ function deepEqual(a, b) {
2346
+ if (a === b) {
2347
+ return true;
2348
+ }
2349
+ if (typeof a !== typeof b) {
2350
+ return false;
2351
+ }
2352
+ if (typeof a === 'function' && a.toString() === b.toString()) {
2353
+ return true;
2354
+ }
2355
+ let length;
2356
+ let i;
2357
+ let keys;
2358
+ if (a && b && typeof a === 'object') {
2359
+ if (Array.isArray(a)) {
2360
+ length = a.length;
2361
+ if (length !== b.length) return false;
2362
+ for (i = length; i-- !== 0;) {
2363
+ if (!deepEqual(a[i], b[i])) {
2364
+ return false;
2365
+ }
2366
+ }
2367
+ return true;
2368
+ }
2369
+ keys = Object.keys(a);
2370
+ length = keys.length;
2371
+ if (length !== Object.keys(b).length) {
2372
+ return false;
2373
+ }
2374
+ for (i = length; i-- !== 0;) {
2375
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2376
+ return false;
2377
+ }
2378
+ }
2379
+ for (i = length; i-- !== 0;) {
2380
+ const key = keys[i];
2381
+ if (key === '_owner' && a.$$typeof) {
2382
+ continue;
2383
+ }
2384
+ if (!deepEqual(a[key], b[key])) {
2385
+ return false;
2386
+ }
2387
+ }
2388
+ return true;
2389
+ }
2390
+ return a !== a && b !== b;
2391
+ }
2392
+
2393
+ function getDPR(element) {
2394
+ if (typeof window === 'undefined') {
2395
+ return 1;
2396
+ }
2397
+ const win = element.ownerDocument.defaultView || window;
2398
+ return win.devicePixelRatio || 1;
2399
+ }
2400
+
2401
+ function roundByDPR(element, value) {
2402
+ const dpr = getDPR(element);
2403
+ return Math.round(value * dpr) / dpr;
2404
+ }
2405
+
2406
+ function useLatestRef(value) {
2407
+ const ref = React.useRef(value);
2408
+ index(() => {
2409
+ ref.current = value;
2410
+ });
2411
+ return ref;
2412
+ }
2413
+
2414
+ /**
2415
+ * Provides data to position a floating element.
2416
+ * @see https://floating-ui.com/docs/useFloating
2417
+ */
2418
+ function useFloating(options) {
2419
+ if (options === void 0) {
2420
+ options = {};
2421
+ }
2422
+ const {
2423
+ placement = 'bottom',
2424
+ strategy = 'absolute',
2425
+ middleware = [],
2426
+ platform,
2427
+ elements: {
2428
+ reference: externalReference,
2429
+ floating: externalFloating
2430
+ } = {},
2431
+ transform = true,
2432
+ whileElementsMounted,
2433
+ open
2434
+ } = options;
2435
+ const [data, setData] = React.useState({
2436
+ x: 0,
2437
+ y: 0,
2438
+ strategy,
2439
+ placement,
2440
+ middlewareData: {},
2441
+ isPositioned: false
2442
+ });
2443
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2444
+ if (!deepEqual(latestMiddleware, middleware)) {
2445
+ setLatestMiddleware(middleware);
2446
+ }
2447
+ const [_reference, _setReference] = React.useState(null);
2448
+ const [_floating, _setFloating] = React.useState(null);
2449
+ const setReference = React.useCallback(node => {
2450
+ if (node !== referenceRef.current) {
2451
+ referenceRef.current = node;
2452
+ _setReference(node);
2453
+ }
2454
+ }, []);
2455
+ const setFloating = React.useCallback(node => {
2456
+ if (node !== floatingRef.current) {
2457
+ floatingRef.current = node;
2458
+ _setFloating(node);
2459
+ }
2460
+ }, []);
2461
+ const referenceEl = externalReference || _reference;
2462
+ const floatingEl = externalFloating || _floating;
2463
+ const referenceRef = React.useRef(null);
2464
+ const floatingRef = React.useRef(null);
2465
+ const dataRef = React.useRef(data);
2466
+ const hasWhileElementsMounted = whileElementsMounted != null;
2467
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2468
+ const platformRef = useLatestRef(platform);
2469
+ const openRef = useLatestRef(open);
2470
+ const update = React.useCallback(() => {
2471
+ if (!referenceRef.current || !floatingRef.current) {
2472
+ return;
2473
+ }
2474
+ const config = {
2475
+ placement,
2476
+ strategy,
2477
+ middleware: latestMiddleware
2478
+ };
2479
+ if (platformRef.current) {
2480
+ config.platform = platformRef.current;
2481
+ }
2482
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2483
+ const fullData = {
2484
+ ...data,
2485
+ // The floating element's position may be recomputed while it's closed
2486
+ // but still mounted (such as when transitioning out). To ensure
2487
+ // `isPositioned` will be `false` initially on the next open, avoid
2488
+ // setting it to `true` when `open === false` (must be specified).
2489
+ isPositioned: openRef.current !== false
2490
+ };
2491
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2492
+ dataRef.current = fullData;
2493
+ ReactDOM.flushSync(() => {
2494
+ setData(fullData);
2495
+ });
2496
+ }
2497
+ });
2498
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2499
+ index(() => {
2500
+ if (open === false && dataRef.current.isPositioned) {
2501
+ dataRef.current.isPositioned = false;
2502
+ setData(data => ({
2503
+ ...data,
2504
+ isPositioned: false
2505
+ }));
2506
+ }
2507
+ }, [open]);
2508
+ const isMountedRef = React.useRef(false);
2509
+ index(() => {
2510
+ isMountedRef.current = true;
2511
+ return () => {
2512
+ isMountedRef.current = false;
2513
+ };
2514
+ }, []);
2515
+ index(() => {
2516
+ if (referenceEl) referenceRef.current = referenceEl;
2517
+ if (floatingEl) floatingRef.current = floatingEl;
2518
+ if (referenceEl && floatingEl) {
2519
+ if (whileElementsMountedRef.current) {
2520
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2521
+ }
2522
+ update();
2523
+ }
2524
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2525
+ const refs = React.useMemo(() => ({
2526
+ reference: referenceRef,
2527
+ floating: floatingRef,
2528
+ setReference,
2529
+ setFloating
2530
+ }), [setReference, setFloating]);
2531
+ const elements = React.useMemo(() => ({
2532
+ reference: referenceEl,
2533
+ floating: floatingEl
2534
+ }), [referenceEl, floatingEl]);
2535
+ const floatingStyles = React.useMemo(() => {
2536
+ const initialStyles = {
2537
+ position: strategy,
2538
+ left: 0,
2539
+ top: 0
2540
+ };
2541
+ if (!elements.floating) {
2542
+ return initialStyles;
2543
+ }
2544
+ const x = roundByDPR(elements.floating, data.x);
2545
+ const y = roundByDPR(elements.floating, data.y);
2546
+ if (transform) {
2547
+ return {
2548
+ ...initialStyles,
2549
+ transform: "translate(" + x + "px, " + y + "px)",
2550
+ ...(getDPR(elements.floating) >= 1.5 && {
2551
+ willChange: 'transform'
2552
+ })
2553
+ };
2554
+ }
2555
+ return {
2556
+ position: strategy,
2557
+ left: x,
2558
+ top: y
2559
+ };
2560
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2561
+ return React.useMemo(() => ({
2562
+ ...data,
2563
+ update,
2564
+ refs,
2565
+ elements,
2566
+ floatingStyles
2567
+ }), [data, update, refs, elements, floatingStyles]);
2568
+ }
2569
+
2570
+ /**
2571
+ * Provides data to position an inner element of the floating element so that it
2572
+ * appears centered to the reference element.
2573
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2574
+ * @see https://floating-ui.com/docs/arrow
2575
+ */
2576
+ const arrow$1 = options => {
2577
+ function isRef(value) {
2578
+ return {}.hasOwnProperty.call(value, 'current');
2579
+ }
2580
+ return {
2581
+ name: 'arrow',
2582
+ options,
2583
+ fn(state) {
2584
+ const {
2585
+ element,
2586
+ padding
2587
+ } = typeof options === 'function' ? options(state) : options;
2588
+ if (element && isRef(element)) {
2589
+ if (element.current != null) {
2590
+ return arrow$2({
2591
+ element: element.current,
2592
+ padding
2593
+ }).fn(state);
2594
+ }
2595
+ return {};
2596
+ }
2597
+ if (element) {
2598
+ return arrow$2({
2599
+ element,
2600
+ padding
2601
+ }).fn(state);
2602
+ }
2603
+ return {};
2604
+ }
2605
+ };
2606
+ };
2607
+
2608
+ /**
2609
+ * Modifies the placement by translating the floating element along the
2610
+ * specified axes.
2611
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2612
+ * object may be passed.
2613
+ * @see https://floating-ui.com/docs/offset
2614
+ */
2615
+ const offset = (options, deps) => ({
2616
+ ...offset$1(options),
2617
+ options: [options, deps]
2618
+ });
2619
+
2620
+ /**
2621
+ * Optimizes the visibility of the floating element by shifting it in order to
2622
+ * keep it in view when it will overflow the clipping boundary.
2623
+ * @see https://floating-ui.com/docs/shift
2624
+ */
2625
+ const shift = (options, deps) => ({
2626
+ ...shift$1(options),
2627
+ options: [options, deps]
2628
+ });
2629
+
2630
+ /**
2631
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2632
+ */
2633
+ const limitShift = (options, deps) => ({
2634
+ ...limitShift$1(options),
2635
+ options: [options, deps]
2636
+ });
2637
+
2638
+ /**
2639
+ * Optimizes the visibility of the floating element by flipping the `placement`
2640
+ * in order to keep it in view when the preferred placement(s) will overflow the
2641
+ * clipping boundary. Alternative to `autoPlacement`.
2642
+ * @see https://floating-ui.com/docs/flip
2643
+ */
2644
+ const flip = (options, deps) => ({
2645
+ ...flip$1(options),
2646
+ options: [options, deps]
2647
+ });
2648
+
2649
+ /**
2650
+ * Provides data that allows you to change the size of the floating element —
2651
+ * for instance, prevent it from overflowing the clipping boundary or match the
2652
+ * width of the reference element.
2653
+ * @see https://floating-ui.com/docs/size
2654
+ */
2655
+ const size = (options, deps) => ({
2656
+ ...size$1(options),
2657
+ options: [options, deps]
2658
+ });
2659
+
2660
+ /**
2661
+ * Provides data to hide the floating element in applicable situations, such as
2662
+ * when it is not in the same clipping context as the reference element.
2663
+ * @see https://floating-ui.com/docs/hide
2664
+ */
2665
+ const hide = (options, deps) => ({
2666
+ ...hide$1(options),
2667
+ options: [options, deps]
2668
+ });
2669
+
2670
+ /**
2671
+ * Provides data to position an inner element of the floating element so that it
2672
+ * appears centered to the reference element.
2673
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2674
+ * @see https://floating-ui.com/docs/arrow
2675
+ */
2676
+ const arrow = (options, deps) => ({
2677
+ ...arrow$1(options),
2678
+ options: [options, deps]
2679
+ });
2680
+
2681
+ // src/arrow.tsx
2682
+ var NAME = "Arrow";
2683
+ var Arrow$1 = React.forwardRef((props, forwardedRef) => {
2684
+ const { children, width = 10, height = 5, ...arrowProps } = props;
2685
+ return /* @__PURE__ */ jsx(
2686
+ Primitive.svg,
2687
+ {
2688
+ ...arrowProps,
2689
+ ref: forwardedRef,
2690
+ width,
2691
+ height,
2692
+ viewBox: "0 0 30 10",
2693
+ preserveAspectRatio: "none",
2694
+ children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
2695
+ }
2696
+ );
2697
+ });
2698
+ Arrow$1.displayName = NAME;
2699
+ var Root = Arrow$1;
2700
+
2701
+ var POPPER_NAME = "Popper";
2702
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
2703
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
2704
+ var Popper = (props) => {
2705
+ const { __scopePopper, children } = props;
2706
+ const [anchor, setAnchor] = React.useState(null);
2707
+ return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
2708
+ };
2709
+ Popper.displayName = POPPER_NAME;
2710
+ var ANCHOR_NAME = "PopperAnchor";
2711
+ var PopperAnchor = React.forwardRef(
2712
+ (props, forwardedRef) => {
2713
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
2714
+ const context = usePopperContext(ANCHOR_NAME, __scopePopper);
2715
+ const ref = React.useRef(null);
2716
+ const composedRefs = useComposedRefs(forwardedRef, ref);
2717
+ const anchorRef = React.useRef(null);
2718
+ React.useEffect(() => {
2719
+ const previousAnchor = anchorRef.current;
2720
+ anchorRef.current = virtualRef?.current || ref.current;
2721
+ if (previousAnchor !== anchorRef.current) {
2722
+ context.onAnchorChange(anchorRef.current);
2723
+ }
2724
+ });
2725
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
2726
+ }
2727
+ );
2728
+ PopperAnchor.displayName = ANCHOR_NAME;
2729
+ var CONTENT_NAME = "PopperContent";
2730
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
2731
+ var PopperContent = React.forwardRef(
2732
+ (props, forwardedRef) => {
2733
+ const {
2734
+ __scopePopper,
2735
+ side = "bottom",
2736
+ sideOffset = 0,
2737
+ align = "center",
2738
+ alignOffset = 0,
2739
+ arrowPadding = 0,
2740
+ avoidCollisions = true,
2741
+ collisionBoundary = [],
2742
+ collisionPadding: collisionPaddingProp = 0,
2743
+ sticky = "partial",
2744
+ hideWhenDetached = false,
2745
+ updatePositionStrategy = "optimized",
2746
+ onPlaced,
2747
+ ...contentProps
2748
+ } = props;
2749
+ const context = usePopperContext(CONTENT_NAME, __scopePopper);
2750
+ const [content, setContent] = React.useState(null);
2751
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
2752
+ const [arrow$1, setArrow] = React.useState(null);
2753
+ const arrowSize = useSize(arrow$1);
2754
+ const arrowWidth = arrowSize?.width ?? 0;
2755
+ const arrowHeight = arrowSize?.height ?? 0;
2756
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
2757
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
2758
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
2759
+ const hasExplicitBoundaries = boundary.length > 0;
2760
+ const detectOverflowOptions = {
2761
+ padding: collisionPadding,
2762
+ boundary: boundary.filter(isNotNull),
2763
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2764
+ altBoundary: hasExplicitBoundaries
2765
+ };
2766
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
2767
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2768
+ strategy: "fixed",
2769
+ placement: desiredPlacement,
2770
+ whileElementsMounted: (...args) => {
2771
+ const cleanup = autoUpdate(...args, {
2772
+ animationFrame: updatePositionStrategy === "always"
2773
+ });
2774
+ return cleanup;
2775
+ },
2776
+ elements: {
2777
+ reference: context.anchor
2778
+ },
2779
+ middleware: [
2780
+ offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
2781
+ avoidCollisions && shift({
2782
+ mainAxis: true,
2783
+ crossAxis: false,
2784
+ limiter: sticky === "partial" ? limitShift() : void 0,
2785
+ ...detectOverflowOptions
2786
+ }),
2787
+ avoidCollisions && flip({ ...detectOverflowOptions }),
2788
+ size({
2789
+ ...detectOverflowOptions,
2790
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
2791
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
2792
+ const contentStyle = elements.floating.style;
2793
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
2794
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
2795
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
2796
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
2797
+ }
2798
+ }),
2799
+ arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
2800
+ transformOrigin({ arrowWidth, arrowHeight }),
2801
+ hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
2802
+ ]
2803
+ });
2804
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
2805
+ const handlePlaced = useCallbackRef$1(onPlaced);
2806
+ useLayoutEffect2(() => {
2807
+ if (isPositioned) {
2808
+ handlePlaced?.();
2809
+ }
2810
+ }, [isPositioned, handlePlaced]);
2811
+ const arrowX = middlewareData.arrow?.x;
2812
+ const arrowY = middlewareData.arrow?.y;
2813
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
2814
+ const [contentZIndex, setContentZIndex] = React.useState();
2815
+ useLayoutEffect2(() => {
2816
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2817
+ }, [content]);
2818
+ return /* @__PURE__ */ jsx(
2819
+ "div",
2820
+ {
2821
+ ref: refs.setFloating,
2822
+ "data-radix-popper-content-wrapper": "",
2823
+ style: {
2824
+ ...floatingStyles,
2825
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
2826
+ // keep off the page when measuring
2827
+ minWidth: "max-content",
2828
+ zIndex: contentZIndex,
2829
+ ["--radix-popper-transform-origin"]: [
2830
+ middlewareData.transformOrigin?.x,
2831
+ middlewareData.transformOrigin?.y
2832
+ ].join(" "),
2833
+ // hide the content if using the hide middleware and should be hidden
2834
+ // set visibility to hidden and disable pointer events so the UI behaves
2835
+ // as if the PopperContent isn't there at all
2836
+ ...middlewareData.hide?.referenceHidden && {
2837
+ visibility: "hidden",
2838
+ pointerEvents: "none"
2839
+ }
2840
+ },
2841
+ dir: props.dir,
2842
+ children: /* @__PURE__ */ jsx(
2843
+ PopperContentProvider,
2844
+ {
2845
+ scope: __scopePopper,
2846
+ placedSide,
2847
+ onArrowChange: setArrow,
2848
+ arrowX,
2849
+ arrowY,
2850
+ shouldHideArrow: cannotCenterArrow,
2851
+ children: /* @__PURE__ */ jsx(
2852
+ Primitive.div,
2853
+ {
2854
+ "data-side": placedSide,
2855
+ "data-align": placedAlign,
2856
+ ...contentProps,
2857
+ ref: composedRefs,
2858
+ style: {
2859
+ ...contentProps.style,
2860
+ // if the PopperContent hasn't been placed yet (not all measurements done)
2861
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
2862
+ animation: !isPositioned ? "none" : void 0
2863
+ }
2864
+ }
2865
+ )
2866
+ }
2867
+ )
2868
+ }
2869
+ );
2870
+ }
2871
+ );
2872
+ PopperContent.displayName = CONTENT_NAME;
2873
+ var ARROW_NAME = "PopperArrow";
2874
+ var OPPOSITE_SIDE = {
2875
+ top: "bottom",
2876
+ right: "left",
2877
+ bottom: "top",
2878
+ left: "right"
2879
+ };
2880
+ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
2881
+ const { __scopePopper, ...arrowProps } = props;
2882
+ const contentContext = useContentContext(ARROW_NAME, __scopePopper);
2883
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
2884
+ return (
2885
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
2886
+ // doesn't report size as we'd expect on SVG elements.
2887
+ // it reports their bounding box which is effectively the largest path inside the SVG.
2888
+ /* @__PURE__ */ jsx(
2889
+ "span",
2890
+ {
2891
+ ref: contentContext.onArrowChange,
2892
+ style: {
2893
+ position: "absolute",
2894
+ left: contentContext.arrowX,
2895
+ top: contentContext.arrowY,
2896
+ [baseSide]: 0,
2897
+ transformOrigin: {
2898
+ top: "",
2899
+ right: "0 0",
2900
+ bottom: "center 0",
2901
+ left: "100% 0"
2902
+ }[contentContext.placedSide],
2903
+ transform: {
2904
+ top: "translateY(100%)",
2905
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
2906
+ bottom: `rotate(180deg)`,
2907
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
2908
+ }[contentContext.placedSide],
2909
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
2910
+ },
2911
+ children: /* @__PURE__ */ jsx(
2912
+ Root,
2913
+ {
2914
+ ...arrowProps,
2915
+ ref: forwardedRef,
2916
+ style: {
2917
+ ...arrowProps.style,
2918
+ // ensures the element can be measured correctly (mostly for if SVG)
2919
+ display: "block"
2920
+ }
2921
+ }
2922
+ )
2923
+ }
2924
+ )
2925
+ );
2926
+ });
2927
+ PopperArrow.displayName = ARROW_NAME;
2928
+ function isNotNull(value) {
2929
+ return value !== null;
2930
+ }
2931
+ var transformOrigin = (options) => ({
2932
+ name: "transformOrigin",
2933
+ options,
2934
+ fn(data) {
2935
+ const { placement, rects, middlewareData } = data;
2936
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
2937
+ const isArrowHidden = cannotCenterArrow;
2938
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2939
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2940
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
2941
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
2942
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
2943
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
2944
+ let x = "";
2945
+ let y = "";
2946
+ if (placedSide === "bottom") {
2947
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2948
+ y = `${-arrowHeight}px`;
2949
+ } else if (placedSide === "top") {
2950
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2951
+ y = `${rects.floating.height + arrowHeight}px`;
2952
+ } else if (placedSide === "right") {
2953
+ x = `${-arrowHeight}px`;
2954
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2955
+ } else if (placedSide === "left") {
2956
+ x = `${rects.floating.width + arrowHeight}px`;
2957
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2958
+ }
2959
+ return { data: { x, y } };
2960
+ }
2961
+ });
2962
+ function getSideAndAlignFromPlacement(placement) {
2963
+ const [side, align = "center"] = placement.split("-");
2964
+ return [side, align];
2965
+ }
2966
+ var Root2 = Popper;
2967
+ var Anchor = PopperAnchor;
2968
+ var Content = PopperContent;
2969
+ var Arrow = PopperArrow;
2970
+
2971
+ var PORTAL_NAME = "Portal";
2972
+ var Portal = React.forwardRef((props, forwardedRef) => {
2973
+ const { container: containerProp, ...portalProps } = props;
2974
+ const [mounted, setMounted] = React.useState(false);
2975
+ useLayoutEffect2(() => setMounted(true), []);
2976
+ const container = containerProp || mounted && globalThis?.document?.body;
2977
+ return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
2978
+ });
2979
+ Portal.displayName = PORTAL_NAME;
2980
+
2981
+ var getDefaultParent = function (originalTarget) {
2982
+ if (typeof document === 'undefined') {
2983
+ return null;
2984
+ }
2985
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
2986
+ return sampleTarget.ownerDocument.body;
2987
+ };
2988
+ var counterMap = new WeakMap();
2989
+ var uncontrolledNodes = new WeakMap();
2990
+ var markerMap = {};
2991
+ var lockCount = 0;
2992
+ var unwrapHost = function (node) {
2993
+ return node && (node.host || unwrapHost(node.parentNode));
2994
+ };
2995
+ var correctTargets = function (parent, targets) {
2996
+ return targets
2997
+ .map(function (target) {
2998
+ if (parent.contains(target)) {
2999
+ return target;
3000
+ }
3001
+ var correctedTarget = unwrapHost(target);
3002
+ if (correctedTarget && parent.contains(correctedTarget)) {
3003
+ return correctedTarget;
3004
+ }
3005
+ console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
3006
+ return null;
3007
+ })
3008
+ .filter(function (x) { return Boolean(x); });
3009
+ };
3010
+ /**
3011
+ * Marks everything except given node(or nodes) as aria-hidden
3012
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
3013
+ * @param [parentNode] - top element, defaults to document.body
3014
+ * @param {String} [markerName] - a special attribute to mark every node
3015
+ * @param {String} [controlAttribute] - html Attribute to control
3016
+ * @return {Undo} undo command
3017
+ */
3018
+ var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
3019
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
3020
+ if (!markerMap[markerName]) {
3021
+ markerMap[markerName] = new WeakMap();
3022
+ }
3023
+ var markerCounter = markerMap[markerName];
3024
+ var hiddenNodes = [];
3025
+ var elementsToKeep = new Set();
3026
+ var elementsToStop = new Set(targets);
3027
+ var keep = function (el) {
3028
+ if (!el || elementsToKeep.has(el)) {
3029
+ return;
3030
+ }
3031
+ elementsToKeep.add(el);
3032
+ keep(el.parentNode);
3033
+ };
3034
+ targets.forEach(keep);
3035
+ var deep = function (parent) {
3036
+ if (!parent || elementsToStop.has(parent)) {
3037
+ return;
3038
+ }
3039
+ Array.prototype.forEach.call(parent.children, function (node) {
3040
+ if (elementsToKeep.has(node)) {
3041
+ deep(node);
3042
+ }
3043
+ else {
3044
+ try {
3045
+ var attr = node.getAttribute(controlAttribute);
3046
+ var alreadyHidden = attr !== null && attr !== 'false';
3047
+ var counterValue = (counterMap.get(node) || 0) + 1;
3048
+ var markerValue = (markerCounter.get(node) || 0) + 1;
3049
+ counterMap.set(node, counterValue);
3050
+ markerCounter.set(node, markerValue);
3051
+ hiddenNodes.push(node);
3052
+ if (counterValue === 1 && alreadyHidden) {
3053
+ uncontrolledNodes.set(node, true);
3054
+ }
3055
+ if (markerValue === 1) {
3056
+ node.setAttribute(markerName, 'true');
3057
+ }
3058
+ if (!alreadyHidden) {
3059
+ node.setAttribute(controlAttribute, 'true');
3060
+ }
3061
+ }
3062
+ catch (e) {
3063
+ console.error('aria-hidden: cannot operate on ', node, e);
3064
+ }
3065
+ }
3066
+ });
3067
+ };
3068
+ deep(parentNode);
3069
+ elementsToKeep.clear();
3070
+ lockCount++;
3071
+ return function () {
3072
+ hiddenNodes.forEach(function (node) {
3073
+ var counterValue = counterMap.get(node) - 1;
3074
+ var markerValue = markerCounter.get(node) - 1;
3075
+ counterMap.set(node, counterValue);
3076
+ markerCounter.set(node, markerValue);
3077
+ if (!counterValue) {
3078
+ if (!uncontrolledNodes.has(node)) {
3079
+ node.removeAttribute(controlAttribute);
3080
+ }
3081
+ uncontrolledNodes.delete(node);
3082
+ }
3083
+ if (!markerValue) {
3084
+ node.removeAttribute(markerName);
3085
+ }
3086
+ });
3087
+ lockCount--;
3088
+ if (!lockCount) {
3089
+ // clear
3090
+ counterMap = new WeakMap();
3091
+ counterMap = new WeakMap();
3092
+ uncontrolledNodes = new WeakMap();
3093
+ markerMap = {};
3094
+ }
3095
+ };
3096
+ };
3097
+ /**
3098
+ * Marks everything except given node(or nodes) as aria-hidden
3099
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
3100
+ * @param [parentNode] - top element, defaults to document.body
3101
+ * @param {String} [markerName] - a special attribute to mark every node
3102
+ * @return {Undo} undo command
3103
+ */
3104
+ var hideOthers = function (originalTarget, parentNode, markerName) {
3105
+ if (markerName === void 0) { markerName = 'data-aria-hidden'; }
3106
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
3107
+ var activeParentNode = getDefaultParent(originalTarget);
3108
+ if (!activeParentNode) {
3109
+ return function () { return null; };
3110
+ }
3111
+ // we should not hide aria-live elements - https://github.com/theKashey/aria-hidden/issues/10
3112
+ // and script elements, as they have no impact on accessibility.
3113
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live], script')));
3114
+ return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
3115
+ };
3116
+
3117
+ /******************************************************************************
3118
+ Copyright (c) Microsoft Corporation.
3119
+
3120
+ Permission to use, copy, modify, and/or distribute this software for any
3121
+ purpose with or without fee is hereby granted.
3122
+
3123
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3124
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3125
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3126
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3127
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3128
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3129
+ PERFORMANCE OF THIS SOFTWARE.
3130
+ ***************************************************************************** */
3131
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
3132
+
3133
+
3134
+ var __assign = function() {
3135
+ __assign = Object.assign || function __assign(t) {
3136
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3137
+ s = arguments[i];
3138
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3139
+ }
3140
+ return t;
3141
+ };
3142
+ return __assign.apply(this, arguments);
3143
+ };
3144
+
3145
+ function __rest(s, e) {
3146
+ var t = {};
3147
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3148
+ t[p] = s[p];
3149
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
3150
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3151
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3152
+ t[p[i]] = s[p[i]];
3153
+ }
3154
+ return t;
3155
+ }
3156
+
3157
+ function __spreadArray(to, from, pack) {
3158
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3159
+ if (ar || !(i in from)) {
3160
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3161
+ ar[i] = from[i];
3162
+ }
3163
+ }
3164
+ return to.concat(ar || Array.prototype.slice.call(from));
3165
+ }
3166
+
3167
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
3168
+ var e = new Error(message);
3169
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3170
+ };
3171
+
3172
+ var zeroRightClassName = 'right-scroll-bar-position';
3173
+ var fullWidthClassName = 'width-before-scroll-bar';
3174
+ var noScrollbarsClassName = 'with-scroll-bars-hidden';
3175
+ /**
3176
+ * Name of a CSS variable containing the amount of "hidden" scrollbar
3177
+ * ! might be undefined ! use will fallback!
3178
+ */
3179
+ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
3180
+
3181
+ /**
3182
+ * Assigns a value for a given ref, no matter of the ref format
3183
+ * @param {RefObject} ref - a callback function or ref object
3184
+ * @param value - a new value
3185
+ *
3186
+ * @see https://github.com/theKashey/use-callback-ref#assignref
3187
+ * @example
3188
+ * const refObject = useRef();
3189
+ * const refFn = (ref) => {....}
3190
+ *
3191
+ * assignRef(refObject, "refValue");
3192
+ * assignRef(refFn, "refValue");
3193
+ */
3194
+ function assignRef(ref, value) {
3195
+ if (typeof ref === 'function') {
3196
+ ref(value);
3197
+ }
3198
+ else if (ref) {
3199
+ ref.current = value;
3200
+ }
3201
+ return ref;
3202
+ }
3203
+
3204
+ /**
3205
+ * creates a MutableRef with ref change callback
3206
+ * @param initialValue - initial ref value
3207
+ * @param {Function} callback - a callback to run when value changes
3208
+ *
3209
+ * @example
3210
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
3211
+ * ref.current = 1;
3212
+ * // prints 0 -> 1
3213
+ *
3214
+ * @see https://reactjs.org/docs/hooks-reference.html#useref
3215
+ * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
3216
+ * @returns {MutableRefObject}
3217
+ */
3218
+ function useCallbackRef(initialValue, callback) {
3219
+ var ref = useState(function () { return ({
3220
+ // value
3221
+ value: initialValue,
3222
+ // last callback
3223
+ callback: callback,
3224
+ // "memoized" public interface
3225
+ facade: {
3226
+ get current() {
3227
+ return ref.value;
3228
+ },
3229
+ set current(value) {
3230
+ var last = ref.value;
3231
+ if (last !== value) {
3232
+ ref.value = value;
3233
+ ref.callback(value, last);
3234
+ }
3235
+ },
3236
+ },
3237
+ }); })[0];
3238
+ // update callback
3239
+ ref.callback = callback;
3240
+ return ref.facade;
3241
+ }
3242
+
3243
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
3244
+ var currentValues = new WeakMap();
3245
+ /**
3246
+ * Merges two or more refs together providing a single interface to set their value
3247
+ * @param {RefObject|Ref} refs
3248
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
3249
+ *
3250
+ * @see {@link mergeRefs} a version without buit-in memoization
3251
+ * @see https://github.com/theKashey/use-callback-ref#usemergerefs
3252
+ * @example
3253
+ * const Component = React.forwardRef((props, ref) => {
3254
+ * const ownRef = useRef();
3255
+ * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
3256
+ * return <div ref={domRef}>...</div>
3257
+ * }
3258
+ */
3259
+ function useMergeRefs(refs, defaultValue) {
3260
+ var callbackRef = useCallbackRef(null, function (newValue) {
3261
+ return refs.forEach(function (ref) { return assignRef(ref, newValue); });
3262
+ });
3263
+ // handle refs changes - added or removed
3264
+ useIsomorphicLayoutEffect(function () {
3265
+ var oldValue = currentValues.get(callbackRef);
3266
+ if (oldValue) {
3267
+ var prevRefs_1 = new Set(oldValue);
3268
+ var nextRefs_1 = new Set(refs);
3269
+ var current_1 = callbackRef.current;
3270
+ prevRefs_1.forEach(function (ref) {
3271
+ if (!nextRefs_1.has(ref)) {
3272
+ assignRef(ref, null);
3273
+ }
3274
+ });
3275
+ nextRefs_1.forEach(function (ref) {
3276
+ if (!prevRefs_1.has(ref)) {
3277
+ assignRef(ref, current_1);
3278
+ }
3279
+ });
3280
+ }
3281
+ currentValues.set(callbackRef, refs);
3282
+ }, [refs]);
3283
+ return callbackRef;
3284
+ }
3285
+
3286
+ function ItoI(a) {
3287
+ return a;
3288
+ }
3289
+ function innerCreateMedium(defaults, middleware) {
3290
+ if (middleware === void 0) { middleware = ItoI; }
3291
+ var buffer = [];
3292
+ var assigned = false;
3293
+ var medium = {
3294
+ read: function () {
3295
+ if (assigned) {
3296
+ throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
3297
+ }
3298
+ if (buffer.length) {
3299
+ return buffer[buffer.length - 1];
3300
+ }
3301
+ return defaults;
3302
+ },
3303
+ useMedium: function (data) {
3304
+ var item = middleware(data, assigned);
3305
+ buffer.push(item);
3306
+ return function () {
3307
+ buffer = buffer.filter(function (x) { return x !== item; });
3308
+ };
3309
+ },
3310
+ assignSyncMedium: function (cb) {
3311
+ assigned = true;
3312
+ while (buffer.length) {
3313
+ var cbs = buffer;
3314
+ buffer = [];
3315
+ cbs.forEach(cb);
3316
+ }
3317
+ buffer = {
3318
+ push: function (x) { return cb(x); },
3319
+ filter: function () { return buffer; },
3320
+ };
3321
+ },
3322
+ assignMedium: function (cb) {
3323
+ assigned = true;
3324
+ var pendingQueue = [];
3325
+ if (buffer.length) {
3326
+ var cbs = buffer;
3327
+ buffer = [];
3328
+ cbs.forEach(cb);
3329
+ pendingQueue = buffer;
3330
+ }
3331
+ var executeQueue = function () {
3332
+ var cbs = pendingQueue;
3333
+ pendingQueue = [];
3334
+ cbs.forEach(cb);
3335
+ };
3336
+ var cycle = function () { return Promise.resolve().then(executeQueue); };
3337
+ cycle();
3338
+ buffer = {
3339
+ push: function (x) {
3340
+ pendingQueue.push(x);
3341
+ cycle();
3342
+ },
3343
+ filter: function (filter) {
3344
+ pendingQueue = pendingQueue.filter(filter);
3345
+ return buffer;
3346
+ },
3347
+ };
3348
+ },
3349
+ };
3350
+ return medium;
3351
+ }
3352
+ // eslint-disable-next-line @typescript-eslint/ban-types
3353
+ function createSidecarMedium(options) {
3354
+ if (options === void 0) { options = {}; }
3355
+ var medium = innerCreateMedium(null);
3356
+ medium.options = __assign({ async: true, ssr: false }, options);
3357
+ return medium;
3358
+ }
3359
+
3360
+ var SideCar$1 = function (_a) {
3361
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
3362
+ if (!sideCar) {
3363
+ throw new Error('Sidecar: please provide `sideCar` property to import the right car');
3364
+ }
3365
+ var Target = sideCar.read();
3366
+ if (!Target) {
3367
+ throw new Error('Sidecar medium not found');
3368
+ }
3369
+ return React.createElement(Target, __assign({}, rest));
3370
+ };
3371
+ SideCar$1.isSideCarExport = true;
3372
+ function exportSidecar(medium, exported) {
3373
+ medium.useMedium(exported);
3374
+ return SideCar$1;
3375
+ }
3376
+
3377
+ var effectCar = createSidecarMedium();
3378
+
3379
+ var nothing = function () {
3380
+ return;
3381
+ };
3382
+ /**
3383
+ * Removes scrollbar from the page and contain the scroll within the Lock
3384
+ */
3385
+ var RemoveScroll = React.forwardRef(function (props, parentRef) {
3386
+ var ref = React.useRef(null);
3387
+ var _a = React.useState({
3388
+ onScrollCapture: nothing,
3389
+ onWheelCapture: nothing,
3390
+ onTouchMoveCapture: nothing,
3391
+ }), callbacks = _a[0], setCallbacks = _a[1];
3392
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
3393
+ var SideCar = sideCar;
3394
+ var containerRef = useMergeRefs([ref, parentRef]);
3395
+ var containerProps = __assign(__assign({}, rest), callbacks);
3396
+ return (React.createElement(React.Fragment, null,
3397
+ enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noRelative: noRelative, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
3398
+ forwardProps ? (React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef }))) : (React.createElement(Container, __assign({}, containerProps, { className: className, ref: containerRef }), children))));
3399
+ });
3400
+ RemoveScroll.defaultProps = {
3401
+ enabled: true,
3402
+ removeScrollBar: true,
3403
+ inert: false,
3404
+ };
3405
+ RemoveScroll.classNames = {
3406
+ fullWidth: fullWidthClassName,
3407
+ zeroRight: zeroRightClassName,
3408
+ };
3409
+
3410
+ var getNonce = function () {
3411
+ if (typeof __webpack_nonce__ !== 'undefined') {
3412
+ return __webpack_nonce__;
3413
+ }
3414
+ return undefined;
3415
+ };
3416
+
3417
+ function makeStyleTag() {
3418
+ if (!document)
3419
+ return null;
3420
+ var tag = document.createElement('style');
3421
+ tag.type = 'text/css';
3422
+ var nonce = getNonce();
3423
+ if (nonce) {
3424
+ tag.setAttribute('nonce', nonce);
3425
+ }
3426
+ return tag;
3427
+ }
3428
+ function injectStyles(tag, css) {
3429
+ // @ts-ignore
3430
+ if (tag.styleSheet) {
3431
+ // @ts-ignore
3432
+ tag.styleSheet.cssText = css;
3433
+ }
3434
+ else {
3435
+ tag.appendChild(document.createTextNode(css));
3436
+ }
3437
+ }
3438
+ function insertStyleTag(tag) {
3439
+ var head = document.head || document.getElementsByTagName('head')[0];
3440
+ head.appendChild(tag);
3441
+ }
3442
+ var stylesheetSingleton = function () {
3443
+ var counter = 0;
3444
+ var stylesheet = null;
3445
+ return {
3446
+ add: function (style) {
3447
+ if (counter == 0) {
3448
+ if ((stylesheet = makeStyleTag())) {
3449
+ injectStyles(stylesheet, style);
3450
+ insertStyleTag(stylesheet);
3451
+ }
3452
+ }
3453
+ counter++;
3454
+ },
3455
+ remove: function () {
3456
+ counter--;
3457
+ if (!counter && stylesheet) {
3458
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
3459
+ stylesheet = null;
3460
+ }
3461
+ },
3462
+ };
3463
+ };
3464
+
3465
+ /**
3466
+ * creates a hook to control style singleton
3467
+ * @see {@link styleSingleton} for a safer component version
3468
+ * @example
3469
+ * ```tsx
3470
+ * const useStyle = styleHookSingleton();
3471
+ * ///
3472
+ * useStyle('body { overflow: hidden}');
3473
+ */
3474
+ var styleHookSingleton = function () {
3475
+ var sheet = stylesheetSingleton();
3476
+ return function (styles, isDynamic) {
3477
+ React.useEffect(function () {
3478
+ sheet.add(styles);
3479
+ return function () {
3480
+ sheet.remove();
3481
+ };
3482
+ }, [styles && isDynamic]);
3483
+ };
3484
+ };
3485
+
3486
+ /**
3487
+ * create a Component to add styles on demand
3488
+ * - styles are added when first instance is mounted
3489
+ * - styles are removed when the last instance is unmounted
3490
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
3491
+ */
3492
+ var styleSingleton = function () {
3493
+ var useStyle = styleHookSingleton();
3494
+ var Sheet = function (_a) {
3495
+ var styles = _a.styles, dynamic = _a.dynamic;
3496
+ useStyle(styles, dynamic);
3497
+ return null;
3498
+ };
3499
+ return Sheet;
3500
+ };
3501
+
3502
+ var zeroGap = {
3503
+ left: 0,
3504
+ top: 0,
3505
+ right: 0,
3506
+ gap: 0,
3507
+ };
3508
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
3509
+ var getOffset = function (gapMode) {
3510
+ var cs = window.getComputedStyle(document.body);
3511
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
3512
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
3513
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
3514
+ return [parse(left), parse(top), parse(right)];
3515
+ };
3516
+ var getGapWidth = function (gapMode) {
3517
+ if (gapMode === void 0) { gapMode = 'margin'; }
3518
+ if (typeof window === 'undefined') {
3519
+ return zeroGap;
3520
+ }
3521
+ var offsets = getOffset(gapMode);
3522
+ var documentWidth = document.documentElement.clientWidth;
3523
+ var windowWidth = window.innerWidth;
3524
+ return {
3525
+ left: offsets[0],
3526
+ top: offsets[1],
3527
+ right: offsets[2],
3528
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
3529
+ };
3530
+ };
3531
+
3532
+ var Style = styleSingleton();
3533
+ var lockAttribute = 'data-scroll-locked';
3534
+ // important tip - once we measure scrollBar width and remove them
3535
+ // we could not repeat this operation
3536
+ // thus we are using style-singleton - only the first "yet correct" style will be applied.
3537
+ var getStyles = function (_a, allowRelative, gapMode, important) {
3538
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
3539
+ if (gapMode === void 0) { gapMode = 'margin'; }
3540
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
3541
+ allowRelative && "position: relative ".concat(important, ";"),
3542
+ gapMode === 'margin' &&
3543
+ "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
3544
+ gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
3545
+ ]
3546
+ .filter(Boolean)
3547
+ .join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
3548
+ };
3549
+ var getCurrentUseCounter = function () {
3550
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
3551
+ return isFinite(counter) ? counter : 0;
3552
+ };
3553
+ var useLockAttribute = function () {
3554
+ React.useEffect(function () {
3555
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
3556
+ return function () {
3557
+ var newCounter = getCurrentUseCounter() - 1;
3558
+ if (newCounter <= 0) {
3559
+ document.body.removeAttribute(lockAttribute);
3560
+ }
3561
+ else {
3562
+ document.body.setAttribute(lockAttribute, newCounter.toString());
3563
+ }
3564
+ };
3565
+ }, []);
3566
+ };
3567
+ /**
3568
+ * Removes page scrollbar and blocks page scroll when mounted
3569
+ */
3570
+ var RemoveScrollBar = function (_a) {
3571
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
3572
+ useLockAttribute();
3573
+ /*
3574
+ gap will be measured on every component mount
3575
+ however it will be used only by the "first" invocation
3576
+ due to singleton nature of <Style
3577
+ */
3578
+ var gap = React.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
3579
+ return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
3580
+ };
3581
+
3582
+ var passiveSupported = false;
3583
+ if (typeof window !== 'undefined') {
3584
+ try {
3585
+ var options = Object.defineProperty({}, 'passive', {
3586
+ get: function () {
3587
+ passiveSupported = true;
3588
+ return true;
3589
+ },
3590
+ });
3591
+ // @ts-ignore
3592
+ window.addEventListener('test', options, options);
3593
+ // @ts-ignore
3594
+ window.removeEventListener('test', options, options);
3595
+ }
3596
+ catch (err) {
3597
+ passiveSupported = false;
3598
+ }
3599
+ }
3600
+ var nonPassive = passiveSupported ? { passive: false } : false;
3601
+
3602
+ var alwaysContainsScroll = function (node) {
3603
+ // textarea will always _contain_ scroll inside self. It only can be hidden
3604
+ return node.tagName === 'TEXTAREA';
3605
+ };
3606
+ var elementCanBeScrolled = function (node, overflow) {
3607
+ if (!(node instanceof Element)) {
3608
+ return false;
3609
+ }
3610
+ var styles = window.getComputedStyle(node);
3611
+ return (
3612
+ // not-not-scrollable
3613
+ styles[overflow] !== 'hidden' &&
3614
+ // contains scroll inside self
3615
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
3616
+ };
3617
+ var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
3618
+ var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
3619
+ var locationCouldBeScrolled = function (axis, node) {
3620
+ var ownerDocument = node.ownerDocument;
3621
+ var current = node;
3622
+ do {
3623
+ // Skip over shadow root
3624
+ if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
3625
+ current = current.host;
3626
+ }
3627
+ var isScrollable = elementCouldBeScrolled(axis, current);
3628
+ if (isScrollable) {
3629
+ var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
3630
+ if (scrollHeight > clientHeight) {
3631
+ return true;
3632
+ }
3633
+ }
3634
+ current = current.parentNode;
3635
+ } while (current && current !== ownerDocument.body);
3636
+ return false;
3637
+ };
3638
+ var getVScrollVariables = function (_a) {
3639
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
3640
+ return [
3641
+ scrollTop,
3642
+ scrollHeight,
3643
+ clientHeight,
3644
+ ];
3645
+ };
3646
+ var getHScrollVariables = function (_a) {
3647
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
3648
+ return [
3649
+ scrollLeft,
3650
+ scrollWidth,
3651
+ clientWidth,
3652
+ ];
3653
+ };
3654
+ var elementCouldBeScrolled = function (axis, node) {
3655
+ return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
3656
+ };
3657
+ var getScrollVariables = function (axis, node) {
3658
+ return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
3659
+ };
3660
+ var getDirectionFactor = function (axis, direction) {
3661
+ /**
3662
+ * If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
3663
+ * and then increasingly negative as you scroll towards the end of the content.
3664
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
3665
+ */
3666
+ return axis === 'h' && direction === 'rtl' ? -1 : 1;
3667
+ };
3668
+ var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
3669
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
3670
+ var delta = directionFactor * sourceDelta;
3671
+ // find scrollable target
3672
+ var target = event.target;
3673
+ var targetInLock = endTarget.contains(target);
3674
+ var shouldCancelScroll = false;
3675
+ var isDeltaPositive = delta > 0;
3676
+ var availableScroll = 0;
3677
+ var availableScrollTop = 0;
3678
+ do {
3679
+ if (!target) {
3680
+ break;
3681
+ }
3682
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
3683
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
3684
+ if (position || elementScroll) {
3685
+ if (elementCouldBeScrolled(axis, target)) {
3686
+ availableScroll += elementScroll;
3687
+ availableScrollTop += position;
3688
+ }
3689
+ }
3690
+ var parent_1 = target.parentNode;
3691
+ // we will "bubble" from ShadowDom in case we are, or just to the parent in normal case
3692
+ // this is the same logic used in focus-lock
3693
+ target = (parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1);
3694
+ } while (
3695
+ // portaled content
3696
+ (!targetInLock && target !== document.body) ||
3697
+ // self content
3698
+ (targetInLock && (endTarget.contains(target) || endTarget === target)));
3699
+ // handle epsilon around 0 (non standard zoom levels)
3700
+ if (isDeltaPositive &&
3701
+ ((Math.abs(availableScroll) < 1) || (false))) {
3702
+ shouldCancelScroll = true;
3703
+ }
3704
+ else if (!isDeltaPositive &&
3705
+ ((Math.abs(availableScrollTop) < 1) || (false))) {
3706
+ shouldCancelScroll = true;
3707
+ }
3708
+ return shouldCancelScroll;
3709
+ };
3710
+
3711
+ var getTouchXY = function (event) {
3712
+ return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
3713
+ };
3714
+ var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
3715
+ var extractRef = function (ref) {
3716
+ return ref && 'current' in ref ? ref.current : ref;
3717
+ };
3718
+ var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
3719
+ var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
3720
+ var idCounter = 0;
3721
+ var lockStack = [];
3722
+ function RemoveScrollSideCar(props) {
3723
+ var shouldPreventQueue = React.useRef([]);
3724
+ var touchStartRef = React.useRef([0, 0]);
3725
+ var activeAxis = React.useRef();
3726
+ var id = React.useState(idCounter++)[0];
3727
+ var Style = React.useState(styleSingleton)[0];
3728
+ var lastProps = React.useRef(props);
3729
+ React.useEffect(function () {
3730
+ lastProps.current = props;
3731
+ }, [props]);
3732
+ React.useEffect(function () {
3733
+ if (props.inert) {
3734
+ document.body.classList.add("block-interactivity-".concat(id));
3735
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
3736
+ allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
3737
+ return function () {
3738
+ document.body.classList.remove("block-interactivity-".concat(id));
3739
+ allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
3740
+ };
3741
+ }
3742
+ return;
3743
+ }, [props.inert, props.lockRef.current, props.shards]);
3744
+ var shouldCancelEvent = React.useCallback(function (event, parent) {
3745
+ if (('touches' in event && event.touches.length === 2) || (event.type === 'wheel' && event.ctrlKey)) {
3746
+ return !lastProps.current.allowPinchZoom;
3747
+ }
3748
+ var touch = getTouchXY(event);
3749
+ var touchStart = touchStartRef.current;
3750
+ var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
3751
+ var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
3752
+ var currentAxis;
3753
+ var target = event.target;
3754
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
3755
+ // allow horizontal touch move on Range inputs. They will not cause any scroll
3756
+ if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
3757
+ return false;
3758
+ }
3759
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
3760
+ if (!canBeScrolledInMainDirection) {
3761
+ return true;
3762
+ }
3763
+ if (canBeScrolledInMainDirection) {
3764
+ currentAxis = moveDirection;
3765
+ }
3766
+ else {
3767
+ currentAxis = moveDirection === 'v' ? 'h' : 'v';
3768
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
3769
+ // other axis might be not scrollable
3770
+ }
3771
+ if (!canBeScrolledInMainDirection) {
3772
+ return false;
3773
+ }
3774
+ if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
3775
+ activeAxis.current = currentAxis;
3776
+ }
3777
+ if (!currentAxis) {
3778
+ return true;
3779
+ }
3780
+ var cancelingAxis = activeAxis.current || currentAxis;
3781
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY);
3782
+ }, []);
3783
+ var shouldPrevent = React.useCallback(function (_event) {
3784
+ var event = _event;
3785
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
3786
+ // not the last active
3787
+ return;
3788
+ }
3789
+ var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
3790
+ var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta); })[0];
3791
+ // self event, and should be canceled
3792
+ if (sourceEvent && sourceEvent.should) {
3793
+ if (event.cancelable) {
3794
+ event.preventDefault();
3795
+ }
3796
+ return;
3797
+ }
3798
+ // outside or shard event
3799
+ if (!sourceEvent) {
3800
+ var shardNodes = (lastProps.current.shards || [])
3801
+ .map(extractRef)
3802
+ .filter(Boolean)
3803
+ .filter(function (node) { return node.contains(event.target); });
3804
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
3805
+ if (shouldStop) {
3806
+ if (event.cancelable) {
3807
+ event.preventDefault();
3808
+ }
3809
+ }
3810
+ }
3811
+ }, []);
3812
+ var shouldCancel = React.useCallback(function (name, delta, target, should) {
3813
+ var event = { name: name, delta: delta, target: target, should: should, shadowParent: getOutermostShadowParent(target) };
3814
+ shouldPreventQueue.current.push(event);
3815
+ setTimeout(function () {
3816
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
3817
+ }, 1);
3818
+ }, []);
3819
+ var scrollTouchStart = React.useCallback(function (event) {
3820
+ touchStartRef.current = getTouchXY(event);
3821
+ activeAxis.current = undefined;
3822
+ }, []);
3823
+ var scrollWheel = React.useCallback(function (event) {
3824
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
3825
+ }, []);
3826
+ var scrollTouchMove = React.useCallback(function (event) {
3827
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
3828
+ }, []);
3829
+ React.useEffect(function () {
3830
+ lockStack.push(Style);
3831
+ props.setCallbacks({
3832
+ onScrollCapture: scrollWheel,
3833
+ onWheelCapture: scrollWheel,
3834
+ onTouchMoveCapture: scrollTouchMove,
3835
+ });
3836
+ document.addEventListener('wheel', shouldPrevent, nonPassive);
3837
+ document.addEventListener('touchmove', shouldPrevent, nonPassive);
3838
+ document.addEventListener('touchstart', scrollTouchStart, nonPassive);
3839
+ return function () {
3840
+ lockStack = lockStack.filter(function (inst) { return inst !== Style; });
3841
+ document.removeEventListener('wheel', shouldPrevent, nonPassive);
3842
+ document.removeEventListener('touchmove', shouldPrevent, nonPassive);
3843
+ document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
3844
+ };
3845
+ }, []);
3846
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
3847
+ return (React.createElement(React.Fragment, null,
3848
+ inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
3849
+ removeScrollBar ? React.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null));
3850
+ }
3851
+ function getOutermostShadowParent(node) {
3852
+ var shadowParent = null;
3853
+ while (node !== null) {
3854
+ if (node instanceof ShadowRoot) {
3855
+ shadowParent = node.host;
3856
+ node = node.host;
3857
+ }
3858
+ node = node.parentNode;
3859
+ }
3860
+ return shadowParent;
3861
+ }
3862
+
3863
+ const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
3864
+
3865
+ var ReactRemoveScroll = React.forwardRef(function (props, ref) { return (React.createElement(RemoveScroll, __assign({}, props, { ref: ref, sideCar: SideCar }))); });
3866
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
3867
+
3868
+ export { Anchor as A, Content as C, DismissableLayer as D, FocusScope as F, Portal as P, Root2 as R, useCallbackRef$1 as a, useFocusGuards as b, createPopperScope as c, ReactRemoveScroll as d, Arrow as e, ChevronRight as f, hideOthers as h, useId as u };
3869
+ //# sourceMappingURL=Combination.js.map