@vritti/quantum-ui 0.1.23 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/Button.d.ts +10 -3
  2. package/dist/Button.js +21 -36
  3. package/dist/Button.js.map +1 -1
  4. package/dist/Button2.js +42 -0
  5. package/dist/Button2.js.map +1 -0
  6. package/dist/Card.d.ts +8 -8
  7. package/dist/Card.js.map +1 -1
  8. package/dist/Checkbox.d.ts +5 -8
  9. package/dist/Checkbox.js +41 -30
  10. package/dist/Checkbox.js.map +1 -1
  11. package/dist/DatePicker.d.ts +4 -4
  12. package/dist/DatePicker.js +4055 -246
  13. package/dist/DatePicker.js.map +1 -1
  14. package/dist/Form.d.ts +70 -88
  15. package/dist/Form.js +34 -30
  16. package/dist/Form.js.map +1 -1
  17. package/dist/Label.js.map +1 -1
  18. package/dist/OTPField.js +2 -12
  19. package/dist/OTPField.js.map +1 -1
  20. package/dist/PasswordField.js.map +1 -1
  21. package/dist/PhoneField.js +6 -12
  22. package/dist/PhoneField.js.map +1 -1
  23. package/dist/Skeleton.d.ts +1 -1
  24. package/dist/Skeleton.js +2 -11
  25. package/dist/Skeleton.js.map +1 -1
  26. package/dist/Spinner.d.ts +14 -0
  27. package/dist/Spinner.js +31 -0
  28. package/dist/Spinner.js.map +1 -0
  29. package/dist/TextArea.js +4 -10
  30. package/dist/TextArea.js.map +1 -1
  31. package/dist/TextField.js +18 -2
  32. package/dist/TextField.js.map +1 -1
  33. package/dist/ThemeToggle.js.map +1 -1
  34. package/dist/Typography.js.map +1 -1
  35. package/dist/assets/quantum-ui.css +47 -31
  36. package/dist/axios.d.ts +1 -1
  37. package/dist/axios.js +11 -16
  38. package/dist/axios.js.map +1 -1
  39. package/dist/components/Button.js +2 -1
  40. package/dist/components/Button.js.map +1 -1
  41. package/dist/components/Form.js +1 -1
  42. package/dist/components/Progress.js +2 -5
  43. package/dist/components/Progress.js.map +1 -1
  44. package/dist/components/{DataTable.d.ts → Spinner.d.ts} +1 -1
  45. package/dist/components/Spinner.js +2 -0
  46. package/dist/components/Spinner.js.map +1 -0
  47. package/dist/createLucideIcon.js.map +1 -1
  48. package/dist/field.js +25 -143
  49. package/dist/field.js.map +1 -1
  50. package/dist/index.d.ts +107 -134
  51. package/dist/index.js +4 -3
  52. package/dist/index.js.map +1 -1
  53. package/dist/index2.js +54 -116
  54. package/dist/index2.js.map +1 -1
  55. package/dist/index3.js +103 -1
  56. package/dist/index3.js.map +1 -1
  57. package/dist/index4.js +31 -55
  58. package/dist/index4.js.map +1 -1
  59. package/dist/index5.js +86 -2
  60. package/dist/index5.js.map +1 -1
  61. package/dist/index6.js +1 -1
  62. package/dist/index6.js.map +1 -1
  63. package/dist/utils/axios.d.ts +1 -1
  64. package/dist/utils/axios.js +1 -1
  65. package/dist/utils.js.map +1 -1
  66. package/package.json +21 -19
  67. package/dist/Combination.js +0 -3869
  68. package/dist/Combination.js.map +0 -1
  69. package/dist/DataTable.d.ts +0 -31
  70. package/dist/DataTable.js +0 -4989
  71. package/dist/DataTable.js.map +0 -1
  72. package/dist/Input.js +0 -22
  73. package/dist/Input.js.map +0 -1
  74. package/dist/check.js +0 -15
  75. package/dist/check.js.map +0 -1
  76. package/dist/components/DataTable.js +0 -2
  77. package/dist/components/DataTable.js.map +0 -1
@@ -3,12 +3,13 @@ import * as React from 'react';
3
3
  import React__default, { createContext, useContext, useCallback, useRef, useLayoutEffect, useState, useEffect, useMemo } from 'react';
4
4
  import { c as cn } from './utils.js';
5
5
  import { L as Label } from './Label.js';
6
- import { u as useControllableState, c as composeEventHandlers, P as Presence } from './index6.js';
7
- import { u as useComposedRefs, c as createSlot } from './index2.js';
8
- import { c as createContextScope } from './index4.js';
9
- import { f as ChevronRight, c as createPopperScope, R as Root2$1, u as useId, A as Anchor, P as Portal$1, h as hideOthers, d as ReactRemoveScroll, b as useFocusGuards, F as FocusScope, D as DismissableLayer, C as Content, e as Arrow } from './Combination.js';
10
- import { P as Primitive } from './index5.js';
11
- import { b as buttonVariants, B as Button$1 } from './Button.js';
6
+ import { c as composeEventHandlers, b as useLayoutEffect2, a as useSize, u as useControllableState, P as Presence } from './index6.js';
7
+ import { u as useComposedRefs } from './index4.js';
8
+ import { c as createContextScope } from './index2.js';
9
+ import { P as Primitive, d as dispatchDiscreteCustomEvent, c as createSlot } from './index5.js';
10
+ import * as ReactDOM from 'react-dom';
11
+ import ReactDOM__default from 'react-dom';
12
+ import { b as buttonVariants, B as Button$1 } from './Button2.js';
12
13
  import { c as createLucideIcon } from './createLucideIcon.js';
13
14
 
14
15
  /**
@@ -19,8 +20,8 @@ import { c as createLucideIcon } from './createLucideIcon.js';
19
20
  */
20
21
 
21
22
 
22
- const __iconNode$1 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
23
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$1);
23
+ const __iconNode$2 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
24
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$2);
24
25
 
25
26
  /**
26
27
  * @license lucide-react v0.544.0 - ISC
@@ -30,8 +31,19 @@ const ChevronDown = createLucideIcon("chevron-down", __iconNode$1);
30
31
  */
31
32
 
32
33
 
33
- const __iconNode = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
34
- const ChevronLeft = createLucideIcon("chevron-left", __iconNode);
34
+ const __iconNode$1 = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
35
+ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$1);
36
+
37
+ /**
38
+ * @license lucide-react v0.544.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */
43
+
44
+
45
+ const __iconNode = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
46
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode);
35
47
 
36
48
  /**
37
49
  * Time zone name format.
@@ -1051,7 +1063,7 @@ function addYears(date, amount, options) {
1051
1063
  * ])
1052
1064
  * //=> Sun Jul 02 1995 00:00:00
1053
1065
  */
1054
- function max(dates, options) {
1066
+ function max$1(dates, options) {
1055
1067
  let result;
1056
1068
  let context = options?.in;
1057
1069
 
@@ -1096,7 +1108,7 @@ function max(dates, options) {
1096
1108
  * ])
1097
1109
  * //=> Wed Feb 11 1987 00:00:00
1098
1110
  */
1099
- function min(dates, options) {
1111
+ function min$1(dates, options) {
1100
1112
  let result;
1101
1113
  let context = options?.in;
1102
1114
 
@@ -4559,7 +4571,7 @@ class DateLib {
4559
4571
  * @returns The latest date.
4560
4572
  */
4561
4573
  this.max = (dates) => {
4562
- return this.overrides?.max ? this.overrides.max(dates) : max(dates);
4574
+ return this.overrides?.max ? this.overrides.max(dates) : max$1(dates);
4563
4575
  };
4564
4576
  /**
4565
4577
  * Returns the earliest date in the given array of dates.
@@ -4568,7 +4580,7 @@ class DateLib {
4568
4580
  * @returns The earliest date.
4569
4581
  */
4570
4582
  this.min = (dates) => {
4571
- return this.overrides?.min ? this.overrides.min(dates) : min(dates);
4583
+ return this.overrides?.min ? this.overrides.min(dates) : min$1(dates);
4572
4584
  };
4573
4585
  /**
4574
4586
  * Sets the month of the given date.
@@ -5189,7 +5201,7 @@ function PreviousMonthButton(props) {
5189
5201
  * @group Components
5190
5202
  * @see https://daypicker.dev/guides/custom-components
5191
5203
  */
5192
- function Root(props) {
5204
+ function Root$1(props) {
5193
5205
  const { rootRef, ...rest } = props;
5194
5206
  return React__default.createElement("div", { ...rest, ref: rootRef });
5195
5207
  }
@@ -5297,7 +5309,7 @@ const components = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
5297
5309
  NextMonthButton,
5298
5310
  Option,
5299
5311
  PreviousMonthButton,
5300
- Root,
5312
+ Root: Root$1,
5301
5313
  Select,
5302
5314
  Week,
5303
5315
  WeekNumber,
@@ -7692,15 +7704,9 @@ function Calendar({
7692
7704
  },
7693
7705
  classNames: {
7694
7706
  root: cn("w-fit", defaultClassNames.root),
7695
- months: cn(
7696
- "relative flex flex-col gap-4 md:flex-row",
7697
- defaultClassNames.months
7698
- ),
7707
+ months: cn("relative flex flex-col gap-4 md:flex-row", defaultClassNames.months),
7699
7708
  month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
7700
- nav: cn(
7701
- "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
7702
- defaultClassNames.nav
7703
- ),
7709
+ nav: cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", defaultClassNames.nav),
7704
7710
  button_previous: cn(
7705
7711
  buttonVariants({ variant: buttonVariant }),
7706
7712
  "h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",
@@ -7736,64 +7742,35 @@ function Calendar({
7736
7742
  defaultClassNames.weekday
7737
7743
  ),
7738
7744
  week: cn("mt-2 flex w-full", defaultClassNames.week),
7739
- week_number_header: cn(
7740
- "w-[--cell-size] select-none",
7741
- defaultClassNames.week_number_header
7742
- ),
7743
- week_number: cn(
7744
- "text-muted-foreground select-none text-[0.8rem]",
7745
- defaultClassNames.week_number
7746
- ),
7745
+ week_number_header: cn("w-[--cell-size] select-none", defaultClassNames.week_number_header),
7746
+ week_number: cn("text-muted-foreground select-none text-[0.8rem]", defaultClassNames.week_number),
7747
7747
  day: cn(
7748
7748
  "relative w-full h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
7749
7749
  props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md" : "[&:first-child[data-selected=true]_button]:rounded-l-md",
7750
7750
  defaultClassNames.day
7751
7751
  ),
7752
- range_start: cn(
7753
- "bg-accent rounded-l-md",
7754
- defaultClassNames.range_start
7755
- ),
7752
+ range_start: cn("bg-accent rounded-l-md", defaultClassNames.range_start),
7756
7753
  range_middle: cn("rounded-none", defaultClassNames.range_middle),
7757
7754
  range_end: cn("bg-accent rounded-r-md", defaultClassNames.range_end),
7758
7755
  today: cn(
7759
7756
  "bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
7760
7757
  defaultClassNames.today
7761
7758
  ),
7762
- outside: cn(
7763
- "text-muted-foreground aria-selected:text-muted-foreground",
7764
- defaultClassNames.outside
7765
- ),
7766
- disabled: cn(
7767
- "text-muted-foreground opacity-50",
7768
- defaultClassNames.disabled
7769
- ),
7759
+ outside: cn("text-muted-foreground aria-selected:text-muted-foreground", defaultClassNames.outside),
7760
+ disabled: cn("text-muted-foreground opacity-50", defaultClassNames.disabled),
7770
7761
  hidden: cn("invisible", defaultClassNames.hidden),
7771
7762
  ...classNames
7772
7763
  },
7773
7764
  components: {
7774
7765
  Root: ({ className: className2, rootRef, ...props2 }) => {
7775
- return /* @__PURE__ */ jsx(
7776
- "div",
7777
- {
7778
- "data-slot": "calendar",
7779
- ref: rootRef,
7780
- className: cn(className2),
7781
- ...props2
7782
- }
7783
- );
7766
+ return /* @__PURE__ */ jsx("div", { "data-slot": "calendar", ref: rootRef, className: cn(className2), ...props2 });
7784
7767
  },
7785
7768
  Chevron: ({ className: className2, orientation, ...props2 }) => {
7786
7769
  if (orientation === "left") {
7787
7770
  return /* @__PURE__ */ jsx(ChevronLeft, { className: cn("size-4", className2), ...props2 });
7788
7771
  }
7789
7772
  if (orientation === "right") {
7790
- return /* @__PURE__ */ jsx(
7791
- ChevronRight,
7792
- {
7793
- className: cn("size-4", className2),
7794
- ...props2
7795
- }
7796
- );
7773
+ return /* @__PURE__ */ jsx(ChevronRight, { className: cn("size-4", className2), ...props2 });
7797
7774
  }
7798
7775
  return /* @__PURE__ */ jsx(ChevronDown, { className: cn("size-4", className2), ...props2 });
7799
7776
  },
@@ -7810,12 +7787,7 @@ function Calendar({
7810
7787
  }
7811
7788
  );
7812
7789
  }
7813
- function CalendarDayButton({
7814
- className,
7815
- day,
7816
- modifiers,
7817
- ...props
7818
- }) {
7790
+ function CalendarDayButton({ className, day, modifiers, ...props }) {
7819
7791
  const defaultClassNames = getDefaultClassNames();
7820
7792
  const ref = React.useRef(null);
7821
7793
  React.useEffect(() => {
@@ -7843,194 +7815,4039 @@ function CalendarDayButton({
7843
7815
  }
7844
7816
  Calendar.displayName = "Calendar";
7845
7817
 
7846
- var POPOVER_NAME = "Popover";
7847
- var [createPopoverContext] = createContextScope(POPOVER_NAME, [
7848
- createPopperScope
7849
- ]);
7850
- var usePopperScope = createPopperScope();
7851
- var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
7852
- var Popover$1 = (props) => {
7853
- const {
7854
- __scopePopover,
7855
- children,
7856
- open: openProp,
7857
- defaultOpen,
7858
- onOpenChange,
7859
- modal = false
7860
- } = props;
7861
- const popperScope = usePopperScope(__scopePopover);
7862
- const triggerRef = React.useRef(null);
7863
- const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
7864
- const [open, setOpen] = useControllableState({
7865
- prop: openProp,
7866
- defaultProp: defaultOpen ?? false,
7867
- onChange: onOpenChange,
7868
- caller: POPOVER_NAME
7818
+ // packages/react/use-callback-ref/src/use-callback-ref.tsx
7819
+ function useCallbackRef$1(callback) {
7820
+ const callbackRef = React.useRef(callback);
7821
+ React.useEffect(() => {
7822
+ callbackRef.current = callback;
7869
7823
  });
7870
- return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
7871
- PopoverProvider,
7872
- {
7873
- scope: __scopePopover,
7874
- contentId: useId(),
7875
- triggerRef,
7876
- open,
7877
- onOpenChange: setOpen,
7878
- onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
7879
- hasCustomAnchor,
7880
- onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
7881
- onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
7882
- modal,
7883
- children
7884
- }
7885
- ) });
7886
- };
7887
- Popover$1.displayName = POPOVER_NAME;
7888
- var ANCHOR_NAME = "PopoverAnchor";
7889
- var PopoverAnchor = React.forwardRef(
7890
- (props, forwardedRef) => {
7891
- const { __scopePopover, ...anchorProps } = props;
7892
- const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
7893
- const popperScope = usePopperScope(__scopePopover);
7894
- const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
7895
- React.useEffect(() => {
7896
- onCustomAnchorAdd();
7897
- return () => onCustomAnchorRemove();
7898
- }, [onCustomAnchorAdd, onCustomAnchorRemove]);
7899
- return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
7900
- }
7901
- );
7902
- PopoverAnchor.displayName = ANCHOR_NAME;
7903
- var TRIGGER_NAME = "PopoverTrigger";
7904
- var PopoverTrigger$1 = React.forwardRef(
7905
- (props, forwardedRef) => {
7906
- const { __scopePopover, ...triggerProps } = props;
7907
- const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
7908
- const popperScope = usePopperScope(__scopePopover);
7909
- const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
7910
- const trigger = /* @__PURE__ */ jsx(
7911
- Primitive.button,
7912
- {
7913
- type: "button",
7914
- "aria-haspopup": "dialog",
7915
- "aria-expanded": context.open,
7916
- "aria-controls": context.contentId,
7917
- "data-state": getState(context.open),
7918
- ...triggerProps,
7919
- ref: composedTriggerRef,
7920
- onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
7824
+ return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
7825
+ }
7826
+
7827
+ // packages/react/use-escape-keydown/src/use-escape-keydown.tsx
7828
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
7829
+ const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
7830
+ React.useEffect(() => {
7831
+ const handleKeyDown = (event) => {
7832
+ if (event.key === "Escape") {
7833
+ onEscapeKeyDown(event);
7921
7834
  }
7922
- );
7923
- return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: trigger });
7924
- }
7925
- );
7926
- PopoverTrigger$1.displayName = TRIGGER_NAME;
7927
- var PORTAL_NAME = "PopoverPortal";
7928
- var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
7929
- forceMount: void 0
7835
+ };
7836
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
7837
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
7838
+ }, [onEscapeKeyDown, ownerDocument]);
7839
+ }
7840
+
7841
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
7842
+ var CONTEXT_UPDATE = "dismissableLayer.update";
7843
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
7844
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
7845
+ var originalBodyPointerEvents;
7846
+ var DismissableLayerContext = React.createContext({
7847
+ layers: /* @__PURE__ */ new Set(),
7848
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
7849
+ branches: /* @__PURE__ */ new Set()
7930
7850
  });
7931
- var PopoverPortal = (props) => {
7932
- const { __scopePopover, forceMount, children, container } = props;
7933
- const context = usePopoverContext(PORTAL_NAME, __scopePopover);
7934
- return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
7935
- };
7936
- PopoverPortal.displayName = PORTAL_NAME;
7937
- var CONTENT_NAME = "PopoverContent";
7938
- var PopoverContent$1 = React.forwardRef(
7939
- (props, forwardedRef) => {
7940
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
7941
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
7942
- const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
7943
- return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
7944
- }
7945
- );
7946
- PopoverContent$1.displayName = CONTENT_NAME;
7947
- var Slot = createSlot("PopoverContent.RemoveScroll");
7948
- var PopoverContentModal = React.forwardRef(
7851
+ var DismissableLayer = React.forwardRef(
7949
7852
  (props, forwardedRef) => {
7950
- const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
7951
- const contentRef = React.useRef(null);
7952
- const composedRefs = useComposedRefs(forwardedRef, contentRef);
7953
- const isRightClickOutsideRef = React.useRef(false);
7853
+ const {
7854
+ disableOutsidePointerEvents = false,
7855
+ onEscapeKeyDown,
7856
+ onPointerDownOutside,
7857
+ onFocusOutside,
7858
+ onInteractOutside,
7859
+ onDismiss,
7860
+ ...layerProps
7861
+ } = props;
7862
+ const context = React.useContext(DismissableLayerContext);
7863
+ const [node, setNode] = React.useState(null);
7864
+ const ownerDocument = node?.ownerDocument ?? globalThis?.document;
7865
+ const [, force] = React.useState({});
7866
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
7867
+ const layers = Array.from(context.layers);
7868
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
7869
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
7870
+ const index = node ? layers.indexOf(node) : -1;
7871
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
7872
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
7873
+ const pointerDownOutside = usePointerDownOutside((event) => {
7874
+ const target = event.target;
7875
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
7876
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
7877
+ onPointerDownOutside?.(event);
7878
+ onInteractOutside?.(event);
7879
+ if (!event.defaultPrevented) onDismiss?.();
7880
+ }, ownerDocument);
7881
+ const focusOutside = useFocusOutside((event) => {
7882
+ const target = event.target;
7883
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
7884
+ if (isFocusInBranch) return;
7885
+ onFocusOutside?.(event);
7886
+ onInteractOutside?.(event);
7887
+ if (!event.defaultPrevented) onDismiss?.();
7888
+ }, ownerDocument);
7889
+ useEscapeKeydown((event) => {
7890
+ const isHighestLayer = index === context.layers.size - 1;
7891
+ if (!isHighestLayer) return;
7892
+ onEscapeKeyDown?.(event);
7893
+ if (!event.defaultPrevented && onDismiss) {
7894
+ event.preventDefault();
7895
+ onDismiss();
7896
+ }
7897
+ }, ownerDocument);
7954
7898
  React.useEffect(() => {
7955
- const content = contentRef.current;
7956
- if (content) return hideOthers(content);
7899
+ if (!node) return;
7900
+ if (disableOutsidePointerEvents) {
7901
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
7902
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
7903
+ ownerDocument.body.style.pointerEvents = "none";
7904
+ }
7905
+ context.layersWithOutsidePointerEventsDisabled.add(node);
7906
+ }
7907
+ context.layers.add(node);
7908
+ dispatchUpdate();
7909
+ return () => {
7910
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
7911
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
7912
+ }
7913
+ };
7914
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
7915
+ React.useEffect(() => {
7916
+ return () => {
7917
+ if (!node) return;
7918
+ context.layers.delete(node);
7919
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
7920
+ dispatchUpdate();
7921
+ };
7922
+ }, [node, context]);
7923
+ React.useEffect(() => {
7924
+ const handleUpdate = () => force({});
7925
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
7926
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
7957
7927
  }, []);
7958
- return /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
7959
- PopoverContentImpl,
7928
+ return /* @__PURE__ */ jsx(
7929
+ Primitive.div,
7960
7930
  {
7961
- ...props,
7931
+ ...layerProps,
7962
7932
  ref: composedRefs,
7963
- trapFocus: context.open,
7964
- disableOutsidePointerEvents: true,
7965
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
7966
- event.preventDefault();
7967
- if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
7968
- }),
7969
- onPointerDownOutside: composeEventHandlers(
7970
- props.onPointerDownOutside,
7971
- (event) => {
7972
- const originalEvent = event.detail.originalEvent;
7973
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
7974
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
7975
- isRightClickOutsideRef.current = isRightClick;
7976
- },
7977
- { checkForDefaultPrevented: false }
7978
- ),
7979
- onFocusOutside: composeEventHandlers(
7980
- props.onFocusOutside,
7981
- (event) => event.preventDefault(),
7982
- { checkForDefaultPrevented: false }
7933
+ style: {
7934
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
7935
+ ...props.style
7936
+ },
7937
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
7938
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
7939
+ onPointerDownCapture: composeEventHandlers(
7940
+ props.onPointerDownCapture,
7941
+ pointerDownOutside.onPointerDownCapture
7983
7942
  )
7984
7943
  }
7985
- ) });
7944
+ );
7986
7945
  }
7987
7946
  );
7988
- var PopoverContentNonModal = React.forwardRef(
7989
- (props, forwardedRef) => {
7990
- const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
7991
- const hasInteractedOutsideRef = React.useRef(false);
7992
- const hasPointerDownOutsideRef = React.useRef(false);
7993
- return /* @__PURE__ */ jsx(
7994
- PopoverContentImpl,
7995
- {
7996
- ...props,
7997
- ref: forwardedRef,
7998
- trapFocus: false,
7999
- disableOutsidePointerEvents: false,
8000
- onCloseAutoFocus: (event) => {
8001
- props.onCloseAutoFocus?.(event);
8002
- if (!event.defaultPrevented) {
8003
- if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
8004
- event.preventDefault();
7947
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
7948
+ var BRANCH_NAME = "DismissableLayerBranch";
7949
+ var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
7950
+ const context = React.useContext(DismissableLayerContext);
7951
+ const ref = React.useRef(null);
7952
+ const composedRefs = useComposedRefs(forwardedRef, ref);
7953
+ React.useEffect(() => {
7954
+ const node = ref.current;
7955
+ if (node) {
7956
+ context.branches.add(node);
7957
+ return () => {
7958
+ context.branches.delete(node);
7959
+ };
7960
+ }
7961
+ }, [context.branches]);
7962
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
7963
+ });
7964
+ DismissableLayerBranch.displayName = BRANCH_NAME;
7965
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
7966
+ const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
7967
+ const isPointerInsideReactTreeRef = React.useRef(false);
7968
+ const handleClickRef = React.useRef(() => {
7969
+ });
7970
+ React.useEffect(() => {
7971
+ const handlePointerDown = (event) => {
7972
+ if (event.target && !isPointerInsideReactTreeRef.current) {
7973
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
7974
+ handleAndDispatchCustomEvent(
7975
+ POINTER_DOWN_OUTSIDE,
7976
+ handlePointerDownOutside,
7977
+ eventDetail,
7978
+ { discrete: true }
7979
+ );
7980
+ };
7981
+ const eventDetail = { originalEvent: event };
7982
+ if (event.pointerType === "touch") {
7983
+ ownerDocument.removeEventListener("click", handleClickRef.current);
7984
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
7985
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
7986
+ } else {
7987
+ handleAndDispatchPointerDownOutsideEvent2();
7988
+ }
7989
+ } else {
7990
+ ownerDocument.removeEventListener("click", handleClickRef.current);
7991
+ }
7992
+ isPointerInsideReactTreeRef.current = false;
7993
+ };
7994
+ const timerId = window.setTimeout(() => {
7995
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
7996
+ }, 0);
7997
+ return () => {
7998
+ window.clearTimeout(timerId);
7999
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
8000
+ ownerDocument.removeEventListener("click", handleClickRef.current);
8001
+ };
8002
+ }, [ownerDocument, handlePointerDownOutside]);
8003
+ return {
8004
+ // ensures we check React component tree (not just DOM tree)
8005
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
8006
+ };
8007
+ }
8008
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
8009
+ const handleFocusOutside = useCallbackRef$1(onFocusOutside);
8010
+ const isFocusInsideReactTreeRef = React.useRef(false);
8011
+ React.useEffect(() => {
8012
+ const handleFocus = (event) => {
8013
+ if (event.target && !isFocusInsideReactTreeRef.current) {
8014
+ const eventDetail = { originalEvent: event };
8015
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
8016
+ discrete: false
8017
+ });
8018
+ }
8019
+ };
8020
+ ownerDocument.addEventListener("focusin", handleFocus);
8021
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
8022
+ }, [ownerDocument, handleFocusOutside]);
8023
+ return {
8024
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
8025
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
8026
+ };
8027
+ }
8028
+ function dispatchUpdate() {
8029
+ const event = new CustomEvent(CONTEXT_UPDATE);
8030
+ document.dispatchEvent(event);
8031
+ }
8032
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
8033
+ const target = detail.originalEvent.target;
8034
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
8035
+ if (handler) target.addEventListener(name, handler, { once: true });
8036
+ if (discrete) {
8037
+ dispatchDiscreteCustomEvent(target, event);
8038
+ } else {
8039
+ target.dispatchEvent(event);
8040
+ }
8041
+ }
8042
+
8043
+ var count$1 = 0;
8044
+ function useFocusGuards() {
8045
+ React.useEffect(() => {
8046
+ const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
8047
+ document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
8048
+ document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
8049
+ count$1++;
8050
+ return () => {
8051
+ if (count$1 === 1) {
8052
+ document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
8053
+ }
8054
+ count$1--;
8055
+ };
8056
+ }, []);
8057
+ }
8058
+ function createFocusGuard() {
8059
+ const element = document.createElement("span");
8060
+ element.setAttribute("data-radix-focus-guard", "");
8061
+ element.tabIndex = 0;
8062
+ element.style.outline = "none";
8063
+ element.style.opacity = "0";
8064
+ element.style.position = "fixed";
8065
+ element.style.pointerEvents = "none";
8066
+ return element;
8067
+ }
8068
+
8069
+ var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
8070
+ var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
8071
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
8072
+ var FOCUS_SCOPE_NAME = "FocusScope";
8073
+ var FocusScope = React.forwardRef((props, forwardedRef) => {
8074
+ const {
8075
+ loop = false,
8076
+ trapped = false,
8077
+ onMountAutoFocus: onMountAutoFocusProp,
8078
+ onUnmountAutoFocus: onUnmountAutoFocusProp,
8079
+ ...scopeProps
8080
+ } = props;
8081
+ const [container, setContainer] = React.useState(null);
8082
+ const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
8083
+ const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
8084
+ const lastFocusedElementRef = React.useRef(null);
8085
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
8086
+ const focusScope = React.useRef({
8087
+ paused: false,
8088
+ pause() {
8089
+ this.paused = true;
8090
+ },
8091
+ resume() {
8092
+ this.paused = false;
8093
+ }
8094
+ }).current;
8095
+ React.useEffect(() => {
8096
+ if (trapped) {
8097
+ let handleFocusIn2 = function(event) {
8098
+ if (focusScope.paused || !container) return;
8099
+ const target = event.target;
8100
+ if (container.contains(target)) {
8101
+ lastFocusedElementRef.current = target;
8102
+ } else {
8103
+ focus(lastFocusedElementRef.current, { select: true });
8104
+ }
8105
+ }, handleFocusOut2 = function(event) {
8106
+ if (focusScope.paused || !container) return;
8107
+ const relatedTarget = event.relatedTarget;
8108
+ if (relatedTarget === null) return;
8109
+ if (!container.contains(relatedTarget)) {
8110
+ focus(lastFocusedElementRef.current, { select: true });
8111
+ }
8112
+ }, handleMutations2 = function(mutations) {
8113
+ const focusedElement = document.activeElement;
8114
+ if (focusedElement !== document.body) return;
8115
+ for (const mutation of mutations) {
8116
+ if (mutation.removedNodes.length > 0) focus(container);
8117
+ }
8118
+ };
8119
+ document.addEventListener("focusin", handleFocusIn2);
8120
+ document.addEventListener("focusout", handleFocusOut2);
8121
+ const mutationObserver = new MutationObserver(handleMutations2);
8122
+ if (container) mutationObserver.observe(container, { childList: true, subtree: true });
8123
+ return () => {
8124
+ document.removeEventListener("focusin", handleFocusIn2);
8125
+ document.removeEventListener("focusout", handleFocusOut2);
8126
+ mutationObserver.disconnect();
8127
+ };
8128
+ }
8129
+ }, [trapped, container, focusScope.paused]);
8130
+ React.useEffect(() => {
8131
+ if (container) {
8132
+ focusScopesStack.add(focusScope);
8133
+ const previouslyFocusedElement = document.activeElement;
8134
+ const hasFocusedCandidate = container.contains(previouslyFocusedElement);
8135
+ if (!hasFocusedCandidate) {
8136
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
8137
+ container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
8138
+ container.dispatchEvent(mountEvent);
8139
+ if (!mountEvent.defaultPrevented) {
8140
+ focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
8141
+ if (document.activeElement === previouslyFocusedElement) {
8142
+ focus(container);
8005
8143
  }
8006
- hasInteractedOutsideRef.current = false;
8007
- hasPointerDownOutsideRef.current = false;
8008
- },
8009
- onInteractOutside: (event) => {
8010
- props.onInteractOutside?.(event);
8011
- if (!event.defaultPrevented) {
8012
- hasInteractedOutsideRef.current = true;
8013
- if (event.detail.originalEvent.type === "pointerdown") {
8014
- hasPointerDownOutsideRef.current = true;
8015
- }
8144
+ }
8145
+ }
8146
+ return () => {
8147
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
8148
+ setTimeout(() => {
8149
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
8150
+ container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
8151
+ container.dispatchEvent(unmountEvent);
8152
+ if (!unmountEvent.defaultPrevented) {
8153
+ focus(previouslyFocusedElement ?? document.body, { select: true });
8016
8154
  }
8017
- const target = event.target;
8018
- const targetIsTrigger = context.triggerRef.current?.contains(target);
8019
- if (targetIsTrigger) event.preventDefault();
8020
- if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
8155
+ container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
8156
+ focusScopesStack.remove(focusScope);
8157
+ }, 0);
8158
+ };
8159
+ }
8160
+ }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
8161
+ const handleKeyDown = React.useCallback(
8162
+ (event) => {
8163
+ if (!loop && !trapped) return;
8164
+ if (focusScope.paused) return;
8165
+ const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
8166
+ const focusedElement = document.activeElement;
8167
+ if (isTabKey && focusedElement) {
8168
+ const container2 = event.currentTarget;
8169
+ const [first, last] = getTabbableEdges(container2);
8170
+ const hasTabbableElementsInside = first && last;
8171
+ if (!hasTabbableElementsInside) {
8172
+ if (focusedElement === container2) event.preventDefault();
8173
+ } else {
8174
+ if (!event.shiftKey && focusedElement === last) {
8175
+ event.preventDefault();
8176
+ if (loop) focus(first, { select: true });
8177
+ } else if (event.shiftKey && focusedElement === first) {
8021
8178
  event.preventDefault();
8179
+ if (loop) focus(last, { select: true });
8022
8180
  }
8023
8181
  }
8024
8182
  }
8025
- );
8183
+ },
8184
+ [loop, trapped, focusScope.paused]
8185
+ );
8186
+ return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
8187
+ });
8188
+ FocusScope.displayName = FOCUS_SCOPE_NAME;
8189
+ function focusFirst(candidates, { select = false } = {}) {
8190
+ const previouslyFocusedElement = document.activeElement;
8191
+ for (const candidate of candidates) {
8192
+ focus(candidate, { select });
8193
+ if (document.activeElement !== previouslyFocusedElement) return;
8026
8194
  }
8027
- );
8028
- var PopoverContentImpl = React.forwardRef(
8029
- (props, forwardedRef) => {
8030
- const {
8031
- __scopePopover,
8032
- trapFocus,
8033
- onOpenAutoFocus,
8195
+ }
8196
+ function getTabbableEdges(container) {
8197
+ const candidates = getTabbableCandidates(container);
8198
+ const first = findVisible(candidates, container);
8199
+ const last = findVisible(candidates.reverse(), container);
8200
+ return [first, last];
8201
+ }
8202
+ function getTabbableCandidates(container) {
8203
+ const nodes = [];
8204
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
8205
+ acceptNode: (node) => {
8206
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
8207
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
8208
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
8209
+ }
8210
+ });
8211
+ while (walker.nextNode()) nodes.push(walker.currentNode);
8212
+ return nodes;
8213
+ }
8214
+ function findVisible(elements, container) {
8215
+ for (const element of elements) {
8216
+ if (!isHidden(element, { upTo: container })) return element;
8217
+ }
8218
+ }
8219
+ function isHidden(node, { upTo }) {
8220
+ if (getComputedStyle(node).visibility === "hidden") return true;
8221
+ while (node) {
8222
+ if (upTo !== void 0 && node === upTo) return false;
8223
+ if (getComputedStyle(node).display === "none") return true;
8224
+ node = node.parentElement;
8225
+ }
8226
+ return false;
8227
+ }
8228
+ function isSelectableInput(element) {
8229
+ return element instanceof HTMLInputElement && "select" in element;
8230
+ }
8231
+ function focus(element, { select = false } = {}) {
8232
+ if (element && element.focus) {
8233
+ const previouslyFocusedElement = document.activeElement;
8234
+ element.focus({ preventScroll: true });
8235
+ if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
8236
+ element.select();
8237
+ }
8238
+ }
8239
+ var focusScopesStack = createFocusScopesStack();
8240
+ function createFocusScopesStack() {
8241
+ let stack = [];
8242
+ return {
8243
+ add(focusScope) {
8244
+ const activeFocusScope = stack[0];
8245
+ if (focusScope !== activeFocusScope) {
8246
+ activeFocusScope?.pause();
8247
+ }
8248
+ stack = arrayRemove(stack, focusScope);
8249
+ stack.unshift(focusScope);
8250
+ },
8251
+ remove(focusScope) {
8252
+ stack = arrayRemove(stack, focusScope);
8253
+ stack[0]?.resume();
8254
+ }
8255
+ };
8256
+ }
8257
+ function arrayRemove(array, item) {
8258
+ const updatedArray = [...array];
8259
+ const index = updatedArray.indexOf(item);
8260
+ if (index !== -1) {
8261
+ updatedArray.splice(index, 1);
8262
+ }
8263
+ return updatedArray;
8264
+ }
8265
+ function removeLinks(items) {
8266
+ return items.filter((item) => item.tagName !== "A");
8267
+ }
8268
+
8269
+ // packages/react/id/src/id.tsx
8270
+ var useReactId = React[" useId ".trim().toString()] || (() => void 0);
8271
+ var count = 0;
8272
+ function useId(deterministicId) {
8273
+ const [id, setId] = React.useState(useReactId());
8274
+ useLayoutEffect2(() => {
8275
+ setId((reactId) => reactId ?? String(count++));
8276
+ }, [deterministicId]);
8277
+ return deterministicId || (id ? `radix-${id}` : "");
8278
+ }
8279
+
8280
+ /**
8281
+ * Custom positioning reference element.
8282
+ * @see https://floating-ui.com/docs/virtual-elements
8283
+ */
8284
+
8285
+ const sides = ['top', 'right', 'bottom', 'left'];
8286
+ const min = Math.min;
8287
+ const max = Math.max;
8288
+ const round = Math.round;
8289
+ const floor = Math.floor;
8290
+ const createCoords = v => ({
8291
+ x: v,
8292
+ y: v
8293
+ });
8294
+ const oppositeSideMap = {
8295
+ left: 'right',
8296
+ right: 'left',
8297
+ bottom: 'top',
8298
+ top: 'bottom'
8299
+ };
8300
+ const oppositeAlignmentMap = {
8301
+ start: 'end',
8302
+ end: 'start'
8303
+ };
8304
+ function clamp(start, value, end) {
8305
+ return max(start, min(value, end));
8306
+ }
8307
+ function evaluate(value, param) {
8308
+ return typeof value === 'function' ? value(param) : value;
8309
+ }
8310
+ function getSide(placement) {
8311
+ return placement.split('-')[0];
8312
+ }
8313
+ function getAlignment(placement) {
8314
+ return placement.split('-')[1];
8315
+ }
8316
+ function getOppositeAxis(axis) {
8317
+ return axis === 'x' ? 'y' : 'x';
8318
+ }
8319
+ function getAxisLength(axis) {
8320
+ return axis === 'y' ? 'height' : 'width';
8321
+ }
8322
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
8323
+ function getSideAxis(placement) {
8324
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
8325
+ }
8326
+ function getAlignmentAxis(placement) {
8327
+ return getOppositeAxis(getSideAxis(placement));
8328
+ }
8329
+ function getAlignmentSides(placement, rects, rtl) {
8330
+ if (rtl === void 0) {
8331
+ rtl = false;
8332
+ }
8333
+ const alignment = getAlignment(placement);
8334
+ const alignmentAxis = getAlignmentAxis(placement);
8335
+ const length = getAxisLength(alignmentAxis);
8336
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
8337
+ if (rects.reference[length] > rects.floating[length]) {
8338
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
8339
+ }
8340
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
8341
+ }
8342
+ function getExpandedPlacements(placement) {
8343
+ const oppositePlacement = getOppositePlacement(placement);
8344
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
8345
+ }
8346
+ function getOppositeAlignmentPlacement(placement) {
8347
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
8348
+ }
8349
+ const lrPlacement = ['left', 'right'];
8350
+ const rlPlacement = ['right', 'left'];
8351
+ const tbPlacement = ['top', 'bottom'];
8352
+ const btPlacement = ['bottom', 'top'];
8353
+ function getSideList(side, isStart, rtl) {
8354
+ switch (side) {
8355
+ case 'top':
8356
+ case 'bottom':
8357
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
8358
+ return isStart ? lrPlacement : rlPlacement;
8359
+ case 'left':
8360
+ case 'right':
8361
+ return isStart ? tbPlacement : btPlacement;
8362
+ default:
8363
+ return [];
8364
+ }
8365
+ }
8366
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
8367
+ const alignment = getAlignment(placement);
8368
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
8369
+ if (alignment) {
8370
+ list = list.map(side => side + "-" + alignment);
8371
+ if (flipAlignment) {
8372
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
8373
+ }
8374
+ }
8375
+ return list;
8376
+ }
8377
+ function getOppositePlacement(placement) {
8378
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
8379
+ }
8380
+ function expandPaddingObject(padding) {
8381
+ return {
8382
+ top: 0,
8383
+ right: 0,
8384
+ bottom: 0,
8385
+ left: 0,
8386
+ ...padding
8387
+ };
8388
+ }
8389
+ function getPaddingObject(padding) {
8390
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
8391
+ top: padding,
8392
+ right: padding,
8393
+ bottom: padding,
8394
+ left: padding
8395
+ };
8396
+ }
8397
+ function rectToClientRect(rect) {
8398
+ const {
8399
+ x,
8400
+ y,
8401
+ width,
8402
+ height
8403
+ } = rect;
8404
+ return {
8405
+ width,
8406
+ height,
8407
+ top: y,
8408
+ left: x,
8409
+ right: x + width,
8410
+ bottom: y + height,
8411
+ x,
8412
+ y
8413
+ };
8414
+ }
8415
+
8416
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
8417
+ let {
8418
+ reference,
8419
+ floating
8420
+ } = _ref;
8421
+ const sideAxis = getSideAxis(placement);
8422
+ const alignmentAxis = getAlignmentAxis(placement);
8423
+ const alignLength = getAxisLength(alignmentAxis);
8424
+ const side = getSide(placement);
8425
+ const isVertical = sideAxis === 'y';
8426
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
8427
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
8428
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
8429
+ let coords;
8430
+ switch (side) {
8431
+ case 'top':
8432
+ coords = {
8433
+ x: commonX,
8434
+ y: reference.y - floating.height
8435
+ };
8436
+ break;
8437
+ case 'bottom':
8438
+ coords = {
8439
+ x: commonX,
8440
+ y: reference.y + reference.height
8441
+ };
8442
+ break;
8443
+ case 'right':
8444
+ coords = {
8445
+ x: reference.x + reference.width,
8446
+ y: commonY
8447
+ };
8448
+ break;
8449
+ case 'left':
8450
+ coords = {
8451
+ x: reference.x - floating.width,
8452
+ y: commonY
8453
+ };
8454
+ break;
8455
+ default:
8456
+ coords = {
8457
+ x: reference.x,
8458
+ y: reference.y
8459
+ };
8460
+ }
8461
+ switch (getAlignment(placement)) {
8462
+ case 'start':
8463
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
8464
+ break;
8465
+ case 'end':
8466
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
8467
+ break;
8468
+ }
8469
+ return coords;
8470
+ }
8471
+
8472
+ /**
8473
+ * Computes the `x` and `y` coordinates that will place the floating element
8474
+ * next to a given reference element.
8475
+ *
8476
+ * This export does not have any `platform` interface logic. You will need to
8477
+ * write one for the platform you are using Floating UI with.
8478
+ */
8479
+ const computePosition$1 = async (reference, floating, config) => {
8480
+ const {
8481
+ placement = 'bottom',
8482
+ strategy = 'absolute',
8483
+ middleware = [],
8484
+ platform
8485
+ } = config;
8486
+ const validMiddleware = middleware.filter(Boolean);
8487
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
8488
+ let rects = await platform.getElementRects({
8489
+ reference,
8490
+ floating,
8491
+ strategy
8492
+ });
8493
+ let {
8494
+ x,
8495
+ y
8496
+ } = computeCoordsFromPlacement(rects, placement, rtl);
8497
+ let statefulPlacement = placement;
8498
+ let middlewareData = {};
8499
+ let resetCount = 0;
8500
+ for (let i = 0; i < validMiddleware.length; i++) {
8501
+ const {
8502
+ name,
8503
+ fn
8504
+ } = validMiddleware[i];
8505
+ const {
8506
+ x: nextX,
8507
+ y: nextY,
8508
+ data,
8509
+ reset
8510
+ } = await fn({
8511
+ x,
8512
+ y,
8513
+ initialPlacement: placement,
8514
+ placement: statefulPlacement,
8515
+ strategy,
8516
+ middlewareData,
8517
+ rects,
8518
+ platform,
8519
+ elements: {
8520
+ reference,
8521
+ floating
8522
+ }
8523
+ });
8524
+ x = nextX != null ? nextX : x;
8525
+ y = nextY != null ? nextY : y;
8526
+ middlewareData = {
8527
+ ...middlewareData,
8528
+ [name]: {
8529
+ ...middlewareData[name],
8530
+ ...data
8531
+ }
8532
+ };
8533
+ if (reset && resetCount <= 50) {
8534
+ resetCount++;
8535
+ if (typeof reset === 'object') {
8536
+ if (reset.placement) {
8537
+ statefulPlacement = reset.placement;
8538
+ }
8539
+ if (reset.rects) {
8540
+ rects = reset.rects === true ? await platform.getElementRects({
8541
+ reference,
8542
+ floating,
8543
+ strategy
8544
+ }) : reset.rects;
8545
+ }
8546
+ ({
8547
+ x,
8548
+ y
8549
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
8550
+ }
8551
+ i = -1;
8552
+ }
8553
+ }
8554
+ return {
8555
+ x,
8556
+ y,
8557
+ placement: statefulPlacement,
8558
+ strategy,
8559
+ middlewareData
8560
+ };
8561
+ };
8562
+
8563
+ /**
8564
+ * Resolves with an object of overflow side offsets that determine how much the
8565
+ * element is overflowing a given clipping boundary on each side.
8566
+ * - positive = overflowing the boundary by that number of pixels
8567
+ * - negative = how many pixels left before it will overflow
8568
+ * - 0 = lies flush with the boundary
8569
+ * @see https://floating-ui.com/docs/detectOverflow
8570
+ */
8571
+ async function detectOverflow(state, options) {
8572
+ var _await$platform$isEle;
8573
+ if (options === void 0) {
8574
+ options = {};
8575
+ }
8576
+ const {
8577
+ x,
8578
+ y,
8579
+ platform,
8580
+ rects,
8581
+ elements,
8582
+ strategy
8583
+ } = state;
8584
+ const {
8585
+ boundary = 'clippingAncestors',
8586
+ rootBoundary = 'viewport',
8587
+ elementContext = 'floating',
8588
+ altBoundary = false,
8589
+ padding = 0
8590
+ } = evaluate(options, state);
8591
+ const paddingObject = getPaddingObject(padding);
8592
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
8593
+ const element = elements[altBoundary ? altContext : elementContext];
8594
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
8595
+ 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))),
8596
+ boundary,
8597
+ rootBoundary,
8598
+ strategy
8599
+ }));
8600
+ const rect = elementContext === 'floating' ? {
8601
+ x,
8602
+ y,
8603
+ width: rects.floating.width,
8604
+ height: rects.floating.height
8605
+ } : rects.reference;
8606
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
8607
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
8608
+ x: 1,
8609
+ y: 1
8610
+ } : {
8611
+ x: 1,
8612
+ y: 1
8613
+ };
8614
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
8615
+ elements,
8616
+ rect,
8617
+ offsetParent,
8618
+ strategy
8619
+ }) : rect);
8620
+ return {
8621
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
8622
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
8623
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
8624
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
8625
+ };
8626
+ }
8627
+
8628
+ /**
8629
+ * Provides data to position an inner element of the floating element so that it
8630
+ * appears centered to the reference element.
8631
+ * @see https://floating-ui.com/docs/arrow
8632
+ */
8633
+ const arrow$3 = options => ({
8634
+ name: 'arrow',
8635
+ options,
8636
+ async fn(state) {
8637
+ const {
8638
+ x,
8639
+ y,
8640
+ placement,
8641
+ rects,
8642
+ platform,
8643
+ elements,
8644
+ middlewareData
8645
+ } = state;
8646
+ // Since `element` is required, we don't Partial<> the type.
8647
+ const {
8648
+ element,
8649
+ padding = 0
8650
+ } = evaluate(options, state) || {};
8651
+ if (element == null) {
8652
+ return {};
8653
+ }
8654
+ const paddingObject = getPaddingObject(padding);
8655
+ const coords = {
8656
+ x,
8657
+ y
8658
+ };
8659
+ const axis = getAlignmentAxis(placement);
8660
+ const length = getAxisLength(axis);
8661
+ const arrowDimensions = await platform.getDimensions(element);
8662
+ const isYAxis = axis === 'y';
8663
+ const minProp = isYAxis ? 'top' : 'left';
8664
+ const maxProp = isYAxis ? 'bottom' : 'right';
8665
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
8666
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
8667
+ const startDiff = coords[axis] - rects.reference[axis];
8668
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
8669
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
8670
+
8671
+ // DOM platform can return `window` as the `offsetParent`.
8672
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
8673
+ clientSize = elements.floating[clientProp] || rects.floating[length];
8674
+ }
8675
+ const centerToReference = endDiff / 2 - startDiff / 2;
8676
+
8677
+ // If the padding is large enough that it causes the arrow to no longer be
8678
+ // centered, modify the padding so that it is centered.
8679
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
8680
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
8681
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
8682
+
8683
+ // Make sure the arrow doesn't overflow the floating element if the center
8684
+ // point is outside the floating element's bounds.
8685
+ const min$1 = minPadding;
8686
+ const max = clientSize - arrowDimensions[length] - maxPadding;
8687
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
8688
+ const offset = clamp(min$1, center, max);
8689
+
8690
+ // If the reference is small enough that the arrow's padding causes it to
8691
+ // to point to nothing for an aligned placement, adjust the offset of the
8692
+ // floating element itself. To ensure `shift()` continues to take action,
8693
+ // a single reset is performed when this is true.
8694
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
8695
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
8696
+ return {
8697
+ [axis]: coords[axis] + alignmentOffset,
8698
+ data: {
8699
+ [axis]: offset,
8700
+ centerOffset: center - offset - alignmentOffset,
8701
+ ...(shouldAddOffset && {
8702
+ alignmentOffset
8703
+ })
8704
+ },
8705
+ reset: shouldAddOffset
8706
+ };
8707
+ }
8708
+ });
8709
+
8710
+ /**
8711
+ * Optimizes the visibility of the floating element by flipping the `placement`
8712
+ * in order to keep it in view when the preferred placement(s) will overflow the
8713
+ * clipping boundary. Alternative to `autoPlacement`.
8714
+ * @see https://floating-ui.com/docs/flip
8715
+ */
8716
+ const flip$2 = function (options) {
8717
+ if (options === void 0) {
8718
+ options = {};
8719
+ }
8720
+ return {
8721
+ name: 'flip',
8722
+ options,
8723
+ async fn(state) {
8724
+ var _middlewareData$arrow, _middlewareData$flip;
8725
+ const {
8726
+ placement,
8727
+ middlewareData,
8728
+ rects,
8729
+ initialPlacement,
8730
+ platform,
8731
+ elements
8732
+ } = state;
8733
+ const {
8734
+ mainAxis: checkMainAxis = true,
8735
+ crossAxis: checkCrossAxis = true,
8736
+ fallbackPlacements: specifiedFallbackPlacements,
8737
+ fallbackStrategy = 'bestFit',
8738
+ fallbackAxisSideDirection = 'none',
8739
+ flipAlignment = true,
8740
+ ...detectOverflowOptions
8741
+ } = evaluate(options, state);
8742
+
8743
+ // If a reset by the arrow was caused due to an alignment offset being
8744
+ // added, we should skip any logic now since `flip()` has already done its
8745
+ // work.
8746
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
8747
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
8748
+ return {};
8749
+ }
8750
+ const side = getSide(placement);
8751
+ const initialSideAxis = getSideAxis(initialPlacement);
8752
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
8753
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
8754
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
8755
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
8756
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
8757
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
8758
+ }
8759
+ const placements = [initialPlacement, ...fallbackPlacements];
8760
+ const overflow = await detectOverflow(state, detectOverflowOptions);
8761
+ const overflows = [];
8762
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
8763
+ if (checkMainAxis) {
8764
+ overflows.push(overflow[side]);
8765
+ }
8766
+ if (checkCrossAxis) {
8767
+ const sides = getAlignmentSides(placement, rects, rtl);
8768
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
8769
+ }
8770
+ overflowsData = [...overflowsData, {
8771
+ placement,
8772
+ overflows
8773
+ }];
8774
+
8775
+ // One or more sides is overflowing.
8776
+ if (!overflows.every(side => side <= 0)) {
8777
+ var _middlewareData$flip2, _overflowsData$filter;
8778
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
8779
+ const nextPlacement = placements[nextIndex];
8780
+ if (nextPlacement) {
8781
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
8782
+ if (!ignoreCrossAxisOverflow ||
8783
+ // We leave the current main axis only if every placement on that axis
8784
+ // overflows the main axis.
8785
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
8786
+ // Try next placement and re-run the lifecycle.
8787
+ return {
8788
+ data: {
8789
+ index: nextIndex,
8790
+ overflows: overflowsData
8791
+ },
8792
+ reset: {
8793
+ placement: nextPlacement
8794
+ }
8795
+ };
8796
+ }
8797
+ }
8798
+
8799
+ // First, find the candidates that fit on the mainAxis side of overflow,
8800
+ // then find the placement that fits the best on the main crossAxis side.
8801
+ 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;
8802
+
8803
+ // Otherwise fallback.
8804
+ if (!resetPlacement) {
8805
+ switch (fallbackStrategy) {
8806
+ case 'bestFit':
8807
+ {
8808
+ var _overflowsData$filter2;
8809
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
8810
+ if (hasFallbackAxisSideDirection) {
8811
+ const currentSideAxis = getSideAxis(d.placement);
8812
+ return currentSideAxis === initialSideAxis ||
8813
+ // Create a bias to the `y` side axis due to horizontal
8814
+ // reading directions favoring greater width.
8815
+ currentSideAxis === 'y';
8816
+ }
8817
+ return true;
8818
+ }).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];
8819
+ if (placement) {
8820
+ resetPlacement = placement;
8821
+ }
8822
+ break;
8823
+ }
8824
+ case 'initialPlacement':
8825
+ resetPlacement = initialPlacement;
8826
+ break;
8827
+ }
8828
+ }
8829
+ if (placement !== resetPlacement) {
8830
+ return {
8831
+ reset: {
8832
+ placement: resetPlacement
8833
+ }
8834
+ };
8835
+ }
8836
+ }
8837
+ return {};
8838
+ }
8839
+ };
8840
+ };
8841
+
8842
+ function getSideOffsets(overflow, rect) {
8843
+ return {
8844
+ top: overflow.top - rect.height,
8845
+ right: overflow.right - rect.width,
8846
+ bottom: overflow.bottom - rect.height,
8847
+ left: overflow.left - rect.width
8848
+ };
8849
+ }
8850
+ function isAnySideFullyClipped(overflow) {
8851
+ return sides.some(side => overflow[side] >= 0);
8852
+ }
8853
+ /**
8854
+ * Provides data to hide the floating element in applicable situations, such as
8855
+ * when it is not in the same clipping context as the reference element.
8856
+ * @see https://floating-ui.com/docs/hide
8857
+ */
8858
+ const hide$2 = function (options) {
8859
+ if (options === void 0) {
8860
+ options = {};
8861
+ }
8862
+ return {
8863
+ name: 'hide',
8864
+ options,
8865
+ async fn(state) {
8866
+ const {
8867
+ rects
8868
+ } = state;
8869
+ const {
8870
+ strategy = 'referenceHidden',
8871
+ ...detectOverflowOptions
8872
+ } = evaluate(options, state);
8873
+ switch (strategy) {
8874
+ case 'referenceHidden':
8875
+ {
8876
+ const overflow = await detectOverflow(state, {
8877
+ ...detectOverflowOptions,
8878
+ elementContext: 'reference'
8879
+ });
8880
+ const offsets = getSideOffsets(overflow, rects.reference);
8881
+ return {
8882
+ data: {
8883
+ referenceHiddenOffsets: offsets,
8884
+ referenceHidden: isAnySideFullyClipped(offsets)
8885
+ }
8886
+ };
8887
+ }
8888
+ case 'escaped':
8889
+ {
8890
+ const overflow = await detectOverflow(state, {
8891
+ ...detectOverflowOptions,
8892
+ altBoundary: true
8893
+ });
8894
+ const offsets = getSideOffsets(overflow, rects.floating);
8895
+ return {
8896
+ data: {
8897
+ escapedOffsets: offsets,
8898
+ escaped: isAnySideFullyClipped(offsets)
8899
+ }
8900
+ };
8901
+ }
8902
+ default:
8903
+ {
8904
+ return {};
8905
+ }
8906
+ }
8907
+ }
8908
+ };
8909
+ };
8910
+
8911
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
8912
+
8913
+ // For type backwards-compatibility, the `OffsetOptions` type was also
8914
+ // Derivable.
8915
+
8916
+ async function convertValueToCoords(state, options) {
8917
+ const {
8918
+ placement,
8919
+ platform,
8920
+ elements
8921
+ } = state;
8922
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
8923
+ const side = getSide(placement);
8924
+ const alignment = getAlignment(placement);
8925
+ const isVertical = getSideAxis(placement) === 'y';
8926
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
8927
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
8928
+ const rawValue = evaluate(options, state);
8929
+
8930
+ // eslint-disable-next-line prefer-const
8931
+ let {
8932
+ mainAxis,
8933
+ crossAxis,
8934
+ alignmentAxis
8935
+ } = typeof rawValue === 'number' ? {
8936
+ mainAxis: rawValue,
8937
+ crossAxis: 0,
8938
+ alignmentAxis: null
8939
+ } : {
8940
+ mainAxis: rawValue.mainAxis || 0,
8941
+ crossAxis: rawValue.crossAxis || 0,
8942
+ alignmentAxis: rawValue.alignmentAxis
8943
+ };
8944
+ if (alignment && typeof alignmentAxis === 'number') {
8945
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
8946
+ }
8947
+ return isVertical ? {
8948
+ x: crossAxis * crossAxisMulti,
8949
+ y: mainAxis * mainAxisMulti
8950
+ } : {
8951
+ x: mainAxis * mainAxisMulti,
8952
+ y: crossAxis * crossAxisMulti
8953
+ };
8954
+ }
8955
+
8956
+ /**
8957
+ * Modifies the placement by translating the floating element along the
8958
+ * specified axes.
8959
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
8960
+ * object may be passed.
8961
+ * @see https://floating-ui.com/docs/offset
8962
+ */
8963
+ const offset$2 = function (options) {
8964
+ if (options === void 0) {
8965
+ options = 0;
8966
+ }
8967
+ return {
8968
+ name: 'offset',
8969
+ options,
8970
+ async fn(state) {
8971
+ var _middlewareData$offse, _middlewareData$arrow;
8972
+ const {
8973
+ x,
8974
+ y,
8975
+ placement,
8976
+ middlewareData
8977
+ } = state;
8978
+ const diffCoords = await convertValueToCoords(state, options);
8979
+
8980
+ // If the placement is the same and the arrow caused an alignment offset
8981
+ // then we don't need to change the positioning coordinates.
8982
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
8983
+ return {};
8984
+ }
8985
+ return {
8986
+ x: x + diffCoords.x,
8987
+ y: y + diffCoords.y,
8988
+ data: {
8989
+ ...diffCoords,
8990
+ placement
8991
+ }
8992
+ };
8993
+ }
8994
+ };
8995
+ };
8996
+
8997
+ /**
8998
+ * Optimizes the visibility of the floating element by shifting it in order to
8999
+ * keep it in view when it will overflow the clipping boundary.
9000
+ * @see https://floating-ui.com/docs/shift
9001
+ */
9002
+ const shift$2 = function (options) {
9003
+ if (options === void 0) {
9004
+ options = {};
9005
+ }
9006
+ return {
9007
+ name: 'shift',
9008
+ options,
9009
+ async fn(state) {
9010
+ const {
9011
+ x,
9012
+ y,
9013
+ placement
9014
+ } = state;
9015
+ const {
9016
+ mainAxis: checkMainAxis = true,
9017
+ crossAxis: checkCrossAxis = false,
9018
+ limiter = {
9019
+ fn: _ref => {
9020
+ let {
9021
+ x,
9022
+ y
9023
+ } = _ref;
9024
+ return {
9025
+ x,
9026
+ y
9027
+ };
9028
+ }
9029
+ },
9030
+ ...detectOverflowOptions
9031
+ } = evaluate(options, state);
9032
+ const coords = {
9033
+ x,
9034
+ y
9035
+ };
9036
+ const overflow = await detectOverflow(state, detectOverflowOptions);
9037
+ const crossAxis = getSideAxis(getSide(placement));
9038
+ const mainAxis = getOppositeAxis(crossAxis);
9039
+ let mainAxisCoord = coords[mainAxis];
9040
+ let crossAxisCoord = coords[crossAxis];
9041
+ if (checkMainAxis) {
9042
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
9043
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
9044
+ const min = mainAxisCoord + overflow[minSide];
9045
+ const max = mainAxisCoord - overflow[maxSide];
9046
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
9047
+ }
9048
+ if (checkCrossAxis) {
9049
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
9050
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
9051
+ const min = crossAxisCoord + overflow[minSide];
9052
+ const max = crossAxisCoord - overflow[maxSide];
9053
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
9054
+ }
9055
+ const limitedCoords = limiter.fn({
9056
+ ...state,
9057
+ [mainAxis]: mainAxisCoord,
9058
+ [crossAxis]: crossAxisCoord
9059
+ });
9060
+ return {
9061
+ ...limitedCoords,
9062
+ data: {
9063
+ x: limitedCoords.x - x,
9064
+ y: limitedCoords.y - y,
9065
+ enabled: {
9066
+ [mainAxis]: checkMainAxis,
9067
+ [crossAxis]: checkCrossAxis
9068
+ }
9069
+ }
9070
+ };
9071
+ }
9072
+ };
9073
+ };
9074
+ /**
9075
+ * Built-in `limiter` that will stop `shift()` at a certain point.
9076
+ */
9077
+ const limitShift$2 = function (options) {
9078
+ if (options === void 0) {
9079
+ options = {};
9080
+ }
9081
+ return {
9082
+ options,
9083
+ fn(state) {
9084
+ const {
9085
+ x,
9086
+ y,
9087
+ placement,
9088
+ rects,
9089
+ middlewareData
9090
+ } = state;
9091
+ const {
9092
+ offset = 0,
9093
+ mainAxis: checkMainAxis = true,
9094
+ crossAxis: checkCrossAxis = true
9095
+ } = evaluate(options, state);
9096
+ const coords = {
9097
+ x,
9098
+ y
9099
+ };
9100
+ const crossAxis = getSideAxis(placement);
9101
+ const mainAxis = getOppositeAxis(crossAxis);
9102
+ let mainAxisCoord = coords[mainAxis];
9103
+ let crossAxisCoord = coords[crossAxis];
9104
+ const rawOffset = evaluate(offset, state);
9105
+ const computedOffset = typeof rawOffset === 'number' ? {
9106
+ mainAxis: rawOffset,
9107
+ crossAxis: 0
9108
+ } : {
9109
+ mainAxis: 0,
9110
+ crossAxis: 0,
9111
+ ...rawOffset
9112
+ };
9113
+ if (checkMainAxis) {
9114
+ const len = mainAxis === 'y' ? 'height' : 'width';
9115
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
9116
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
9117
+ if (mainAxisCoord < limitMin) {
9118
+ mainAxisCoord = limitMin;
9119
+ } else if (mainAxisCoord > limitMax) {
9120
+ mainAxisCoord = limitMax;
9121
+ }
9122
+ }
9123
+ if (checkCrossAxis) {
9124
+ var _middlewareData$offse, _middlewareData$offse2;
9125
+ const len = mainAxis === 'y' ? 'width' : 'height';
9126
+ const isOriginSide = originSides.has(getSide(placement));
9127
+ 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);
9128
+ 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);
9129
+ if (crossAxisCoord < limitMin) {
9130
+ crossAxisCoord = limitMin;
9131
+ } else if (crossAxisCoord > limitMax) {
9132
+ crossAxisCoord = limitMax;
9133
+ }
9134
+ }
9135
+ return {
9136
+ [mainAxis]: mainAxisCoord,
9137
+ [crossAxis]: crossAxisCoord
9138
+ };
9139
+ }
9140
+ };
9141
+ };
9142
+
9143
+ /**
9144
+ * Provides data that allows you to change the size of the floating element —
9145
+ * for instance, prevent it from overflowing the clipping boundary or match the
9146
+ * width of the reference element.
9147
+ * @see https://floating-ui.com/docs/size
9148
+ */
9149
+ const size$2 = function (options) {
9150
+ if (options === void 0) {
9151
+ options = {};
9152
+ }
9153
+ return {
9154
+ name: 'size',
9155
+ options,
9156
+ async fn(state) {
9157
+ var _state$middlewareData, _state$middlewareData2;
9158
+ const {
9159
+ placement,
9160
+ rects,
9161
+ platform,
9162
+ elements
9163
+ } = state;
9164
+ const {
9165
+ apply = () => {},
9166
+ ...detectOverflowOptions
9167
+ } = evaluate(options, state);
9168
+ const overflow = await detectOverflow(state, detectOverflowOptions);
9169
+ const side = getSide(placement);
9170
+ const alignment = getAlignment(placement);
9171
+ const isYAxis = getSideAxis(placement) === 'y';
9172
+ const {
9173
+ width,
9174
+ height
9175
+ } = rects.floating;
9176
+ let heightSide;
9177
+ let widthSide;
9178
+ if (side === 'top' || side === 'bottom') {
9179
+ heightSide = side;
9180
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
9181
+ } else {
9182
+ widthSide = side;
9183
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
9184
+ }
9185
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
9186
+ const maximumClippingWidth = width - overflow.left - overflow.right;
9187
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
9188
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
9189
+ const noShift = !state.middlewareData.shift;
9190
+ let availableHeight = overflowAvailableHeight;
9191
+ let availableWidth = overflowAvailableWidth;
9192
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
9193
+ availableWidth = maximumClippingWidth;
9194
+ }
9195
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
9196
+ availableHeight = maximumClippingHeight;
9197
+ }
9198
+ if (noShift && !alignment) {
9199
+ const xMin = max(overflow.left, 0);
9200
+ const xMax = max(overflow.right, 0);
9201
+ const yMin = max(overflow.top, 0);
9202
+ const yMax = max(overflow.bottom, 0);
9203
+ if (isYAxis) {
9204
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
9205
+ } else {
9206
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
9207
+ }
9208
+ }
9209
+ await apply({
9210
+ ...state,
9211
+ availableWidth,
9212
+ availableHeight
9213
+ });
9214
+ const nextDimensions = await platform.getDimensions(elements.floating);
9215
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
9216
+ return {
9217
+ reset: {
9218
+ rects: true
9219
+ }
9220
+ };
9221
+ }
9222
+ return {};
9223
+ }
9224
+ };
9225
+ };
9226
+
9227
+ function hasWindow() {
9228
+ return typeof window !== 'undefined';
9229
+ }
9230
+ function getNodeName(node) {
9231
+ if (isNode(node)) {
9232
+ return (node.nodeName || '').toLowerCase();
9233
+ }
9234
+ // Mocked nodes in testing environments may not be instances of Node. By
9235
+ // returning `#document` an infinite loop won't occur.
9236
+ // https://github.com/floating-ui/floating-ui/issues/2317
9237
+ return '#document';
9238
+ }
9239
+ function getWindow(node) {
9240
+ var _node$ownerDocument;
9241
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
9242
+ }
9243
+ function getDocumentElement(node) {
9244
+ var _ref;
9245
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
9246
+ }
9247
+ function isNode(value) {
9248
+ if (!hasWindow()) {
9249
+ return false;
9250
+ }
9251
+ return value instanceof Node || value instanceof getWindow(value).Node;
9252
+ }
9253
+ function isElement(value) {
9254
+ if (!hasWindow()) {
9255
+ return false;
9256
+ }
9257
+ return value instanceof Element || value instanceof getWindow(value).Element;
9258
+ }
9259
+ function isHTMLElement(value) {
9260
+ if (!hasWindow()) {
9261
+ return false;
9262
+ }
9263
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
9264
+ }
9265
+ function isShadowRoot(value) {
9266
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
9267
+ return false;
9268
+ }
9269
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
9270
+ }
9271
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
9272
+ function isOverflowElement(element) {
9273
+ const {
9274
+ overflow,
9275
+ overflowX,
9276
+ overflowY,
9277
+ display
9278
+ } = getComputedStyle$1(element);
9279
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
9280
+ }
9281
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
9282
+ function isTableElement(element) {
9283
+ return tableElements.has(getNodeName(element));
9284
+ }
9285
+ const topLayerSelectors = [':popover-open', ':modal'];
9286
+ function isTopLayer(element) {
9287
+ return topLayerSelectors.some(selector => {
9288
+ try {
9289
+ return element.matches(selector);
9290
+ } catch (_e) {
9291
+ return false;
9292
+ }
9293
+ });
9294
+ }
9295
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
9296
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
9297
+ const containValues = ['paint', 'layout', 'strict', 'content'];
9298
+ function isContainingBlock(elementOrCss) {
9299
+ const webkit = isWebKit();
9300
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
9301
+
9302
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
9303
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
9304
+ 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));
9305
+ }
9306
+ function getContainingBlock(element) {
9307
+ let currentNode = getParentNode(element);
9308
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
9309
+ if (isContainingBlock(currentNode)) {
9310
+ return currentNode;
9311
+ } else if (isTopLayer(currentNode)) {
9312
+ return null;
9313
+ }
9314
+ currentNode = getParentNode(currentNode);
9315
+ }
9316
+ return null;
9317
+ }
9318
+ function isWebKit() {
9319
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
9320
+ return CSS.supports('-webkit-backdrop-filter', 'none');
9321
+ }
9322
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
9323
+ function isLastTraversableNode(node) {
9324
+ return lastTraversableNodeNames.has(getNodeName(node));
9325
+ }
9326
+ function getComputedStyle$1(element) {
9327
+ return getWindow(element).getComputedStyle(element);
9328
+ }
9329
+ function getNodeScroll(element) {
9330
+ if (isElement(element)) {
9331
+ return {
9332
+ scrollLeft: element.scrollLeft,
9333
+ scrollTop: element.scrollTop
9334
+ };
9335
+ }
9336
+ return {
9337
+ scrollLeft: element.scrollX,
9338
+ scrollTop: element.scrollY
9339
+ };
9340
+ }
9341
+ function getParentNode(node) {
9342
+ if (getNodeName(node) === 'html') {
9343
+ return node;
9344
+ }
9345
+ const result =
9346
+ // Step into the shadow DOM of the parent of a slotted node.
9347
+ node.assignedSlot ||
9348
+ // DOM Element detected.
9349
+ node.parentNode ||
9350
+ // ShadowRoot detected.
9351
+ isShadowRoot(node) && node.host ||
9352
+ // Fallback.
9353
+ getDocumentElement(node);
9354
+ return isShadowRoot(result) ? result.host : result;
9355
+ }
9356
+ function getNearestOverflowAncestor(node) {
9357
+ const parentNode = getParentNode(node);
9358
+ if (isLastTraversableNode(parentNode)) {
9359
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
9360
+ }
9361
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
9362
+ return parentNode;
9363
+ }
9364
+ return getNearestOverflowAncestor(parentNode);
9365
+ }
9366
+ function getOverflowAncestors(node, list, traverseIframes) {
9367
+ var _node$ownerDocument2;
9368
+ if (list === void 0) {
9369
+ list = [];
9370
+ }
9371
+ if (traverseIframes === void 0) {
9372
+ traverseIframes = true;
9373
+ }
9374
+ const scrollableAncestor = getNearestOverflowAncestor(node);
9375
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
9376
+ const win = getWindow(scrollableAncestor);
9377
+ if (isBody) {
9378
+ const frameElement = getFrameElement(win);
9379
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
9380
+ }
9381
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
9382
+ }
9383
+ function getFrameElement(win) {
9384
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
9385
+ }
9386
+
9387
+ function getCssDimensions(element) {
9388
+ const css = getComputedStyle$1(element);
9389
+ // In testing environments, the `width` and `height` properties are empty
9390
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
9391
+ let width = parseFloat(css.width) || 0;
9392
+ let height = parseFloat(css.height) || 0;
9393
+ const hasOffset = isHTMLElement(element);
9394
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
9395
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
9396
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
9397
+ if (shouldFallback) {
9398
+ width = offsetWidth;
9399
+ height = offsetHeight;
9400
+ }
9401
+ return {
9402
+ width,
9403
+ height,
9404
+ $: shouldFallback
9405
+ };
9406
+ }
9407
+
9408
+ function unwrapElement(element) {
9409
+ return !isElement(element) ? element.contextElement : element;
9410
+ }
9411
+
9412
+ function getScale(element) {
9413
+ const domElement = unwrapElement(element);
9414
+ if (!isHTMLElement(domElement)) {
9415
+ return createCoords(1);
9416
+ }
9417
+ const rect = domElement.getBoundingClientRect();
9418
+ const {
9419
+ width,
9420
+ height,
9421
+ $
9422
+ } = getCssDimensions(domElement);
9423
+ let x = ($ ? round(rect.width) : rect.width) / width;
9424
+ let y = ($ ? round(rect.height) : rect.height) / height;
9425
+
9426
+ // 0, NaN, or Infinity should always fallback to 1.
9427
+
9428
+ if (!x || !Number.isFinite(x)) {
9429
+ x = 1;
9430
+ }
9431
+ if (!y || !Number.isFinite(y)) {
9432
+ y = 1;
9433
+ }
9434
+ return {
9435
+ x,
9436
+ y
9437
+ };
9438
+ }
9439
+
9440
+ const noOffsets = /*#__PURE__*/createCoords(0);
9441
+ function getVisualOffsets(element) {
9442
+ const win = getWindow(element);
9443
+ if (!isWebKit() || !win.visualViewport) {
9444
+ return noOffsets;
9445
+ }
9446
+ return {
9447
+ x: win.visualViewport.offsetLeft,
9448
+ y: win.visualViewport.offsetTop
9449
+ };
9450
+ }
9451
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
9452
+ if (isFixed === void 0) {
9453
+ isFixed = false;
9454
+ }
9455
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
9456
+ return false;
9457
+ }
9458
+ return isFixed;
9459
+ }
9460
+
9461
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
9462
+ if (includeScale === void 0) {
9463
+ includeScale = false;
9464
+ }
9465
+ if (isFixedStrategy === void 0) {
9466
+ isFixedStrategy = false;
9467
+ }
9468
+ const clientRect = element.getBoundingClientRect();
9469
+ const domElement = unwrapElement(element);
9470
+ let scale = createCoords(1);
9471
+ if (includeScale) {
9472
+ if (offsetParent) {
9473
+ if (isElement(offsetParent)) {
9474
+ scale = getScale(offsetParent);
9475
+ }
9476
+ } else {
9477
+ scale = getScale(element);
9478
+ }
9479
+ }
9480
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
9481
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
9482
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
9483
+ let width = clientRect.width / scale.x;
9484
+ let height = clientRect.height / scale.y;
9485
+ if (domElement) {
9486
+ const win = getWindow(domElement);
9487
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
9488
+ let currentWin = win;
9489
+ let currentIFrame = getFrameElement(currentWin);
9490
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
9491
+ const iframeScale = getScale(currentIFrame);
9492
+ const iframeRect = currentIFrame.getBoundingClientRect();
9493
+ const css = getComputedStyle$1(currentIFrame);
9494
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
9495
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
9496
+ x *= iframeScale.x;
9497
+ y *= iframeScale.y;
9498
+ width *= iframeScale.x;
9499
+ height *= iframeScale.y;
9500
+ x += left;
9501
+ y += top;
9502
+ currentWin = getWindow(currentIFrame);
9503
+ currentIFrame = getFrameElement(currentWin);
9504
+ }
9505
+ }
9506
+ return rectToClientRect({
9507
+ width,
9508
+ height,
9509
+ x,
9510
+ y
9511
+ });
9512
+ }
9513
+
9514
+ // If <html> has a CSS width greater than the viewport, then this will be
9515
+ // incorrect for RTL.
9516
+ function getWindowScrollBarX(element, rect) {
9517
+ const leftScroll = getNodeScroll(element).scrollLeft;
9518
+ if (!rect) {
9519
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
9520
+ }
9521
+ return rect.left + leftScroll;
9522
+ }
9523
+
9524
+ function getHTMLOffset(documentElement, scroll) {
9525
+ const htmlRect = documentElement.getBoundingClientRect();
9526
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
9527
+ const y = htmlRect.top + scroll.scrollTop;
9528
+ return {
9529
+ x,
9530
+ y
9531
+ };
9532
+ }
9533
+
9534
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
9535
+ let {
9536
+ elements,
9537
+ rect,
9538
+ offsetParent,
9539
+ strategy
9540
+ } = _ref;
9541
+ const isFixed = strategy === 'fixed';
9542
+ const documentElement = getDocumentElement(offsetParent);
9543
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
9544
+ if (offsetParent === documentElement || topLayer && isFixed) {
9545
+ return rect;
9546
+ }
9547
+ let scroll = {
9548
+ scrollLeft: 0,
9549
+ scrollTop: 0
9550
+ };
9551
+ let scale = createCoords(1);
9552
+ const offsets = createCoords(0);
9553
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
9554
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
9555
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
9556
+ scroll = getNodeScroll(offsetParent);
9557
+ }
9558
+ if (isHTMLElement(offsetParent)) {
9559
+ const offsetRect = getBoundingClientRect(offsetParent);
9560
+ scale = getScale(offsetParent);
9561
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
9562
+ offsets.y = offsetRect.y + offsetParent.clientTop;
9563
+ }
9564
+ }
9565
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
9566
+ return {
9567
+ width: rect.width * scale.x,
9568
+ height: rect.height * scale.y,
9569
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
9570
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
9571
+ };
9572
+ }
9573
+
9574
+ function getClientRects(element) {
9575
+ return Array.from(element.getClientRects());
9576
+ }
9577
+
9578
+ // Gets the entire size of the scrollable document area, even extending outside
9579
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
9580
+ function getDocumentRect(element) {
9581
+ const html = getDocumentElement(element);
9582
+ const scroll = getNodeScroll(element);
9583
+ const body = element.ownerDocument.body;
9584
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
9585
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
9586
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
9587
+ const y = -scroll.scrollTop;
9588
+ if (getComputedStyle$1(body).direction === 'rtl') {
9589
+ x += max(html.clientWidth, body.clientWidth) - width;
9590
+ }
9591
+ return {
9592
+ width,
9593
+ height,
9594
+ x,
9595
+ y
9596
+ };
9597
+ }
9598
+
9599
+ // Safety check: ensure the scrollbar space is reasonable in case this
9600
+ // calculation is affected by unusual styles.
9601
+ // Most scrollbars leave 15-18px of space.
9602
+ const SCROLLBAR_MAX = 25;
9603
+ function getViewportRect(element, strategy) {
9604
+ const win = getWindow(element);
9605
+ const html = getDocumentElement(element);
9606
+ const visualViewport = win.visualViewport;
9607
+ let width = html.clientWidth;
9608
+ let height = html.clientHeight;
9609
+ let x = 0;
9610
+ let y = 0;
9611
+ if (visualViewport) {
9612
+ width = visualViewport.width;
9613
+ height = visualViewport.height;
9614
+ const visualViewportBased = isWebKit();
9615
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
9616
+ x = visualViewport.offsetLeft;
9617
+ y = visualViewport.offsetTop;
9618
+ }
9619
+ }
9620
+ const windowScrollbarX = getWindowScrollBarX(html);
9621
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
9622
+ // visual width of the <html> but this is not considered in the size
9623
+ // of `html.clientWidth`.
9624
+ if (windowScrollbarX <= 0) {
9625
+ const doc = html.ownerDocument;
9626
+ const body = doc.body;
9627
+ const bodyStyles = getComputedStyle(body);
9628
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
9629
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
9630
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
9631
+ width -= clippingStableScrollbarWidth;
9632
+ }
9633
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
9634
+ // If the <body> scrollbar is on the left, the width needs to be extended
9635
+ // by the scrollbar amount so there isn't extra space on the right.
9636
+ width += windowScrollbarX;
9637
+ }
9638
+ return {
9639
+ width,
9640
+ height,
9641
+ x,
9642
+ y
9643
+ };
9644
+ }
9645
+
9646
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
9647
+ // Returns the inner client rect, subtracting scrollbars if present.
9648
+ function getInnerBoundingClientRect(element, strategy) {
9649
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
9650
+ const top = clientRect.top + element.clientTop;
9651
+ const left = clientRect.left + element.clientLeft;
9652
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
9653
+ const width = element.clientWidth * scale.x;
9654
+ const height = element.clientHeight * scale.y;
9655
+ const x = left * scale.x;
9656
+ const y = top * scale.y;
9657
+ return {
9658
+ width,
9659
+ height,
9660
+ x,
9661
+ y
9662
+ };
9663
+ }
9664
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
9665
+ let rect;
9666
+ if (clippingAncestor === 'viewport') {
9667
+ rect = getViewportRect(element, strategy);
9668
+ } else if (clippingAncestor === 'document') {
9669
+ rect = getDocumentRect(getDocumentElement(element));
9670
+ } else if (isElement(clippingAncestor)) {
9671
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
9672
+ } else {
9673
+ const visualOffsets = getVisualOffsets(element);
9674
+ rect = {
9675
+ x: clippingAncestor.x - visualOffsets.x,
9676
+ y: clippingAncestor.y - visualOffsets.y,
9677
+ width: clippingAncestor.width,
9678
+ height: clippingAncestor.height
9679
+ };
9680
+ }
9681
+ return rectToClientRect(rect);
9682
+ }
9683
+ function hasFixedPositionAncestor(element, stopNode) {
9684
+ const parentNode = getParentNode(element);
9685
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
9686
+ return false;
9687
+ }
9688
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
9689
+ }
9690
+
9691
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
9692
+ // clipping (or hiding) child elements. This returns all clipping ancestors
9693
+ // of the given element up the tree.
9694
+ function getClippingElementAncestors(element, cache) {
9695
+ const cachedResult = cache.get(element);
9696
+ if (cachedResult) {
9697
+ return cachedResult;
9698
+ }
9699
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
9700
+ let currentContainingBlockComputedStyle = null;
9701
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
9702
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
9703
+
9704
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
9705
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
9706
+ const computedStyle = getComputedStyle$1(currentNode);
9707
+ const currentNodeIsContaining = isContainingBlock(currentNode);
9708
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
9709
+ currentContainingBlockComputedStyle = null;
9710
+ }
9711
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
9712
+ if (shouldDropCurrentNode) {
9713
+ // Drop non-containing blocks.
9714
+ result = result.filter(ancestor => ancestor !== currentNode);
9715
+ } else {
9716
+ // Record last containing block for next iteration.
9717
+ currentContainingBlockComputedStyle = computedStyle;
9718
+ }
9719
+ currentNode = getParentNode(currentNode);
9720
+ }
9721
+ cache.set(element, result);
9722
+ return result;
9723
+ }
9724
+
9725
+ // Gets the maximum area that the element is visible in due to any number of
9726
+ // clipping ancestors.
9727
+ function getClippingRect(_ref) {
9728
+ let {
9729
+ element,
9730
+ boundary,
9731
+ rootBoundary,
9732
+ strategy
9733
+ } = _ref;
9734
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
9735
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
9736
+ const firstClippingAncestor = clippingAncestors[0];
9737
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
9738
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
9739
+ accRect.top = max(rect.top, accRect.top);
9740
+ accRect.right = min(rect.right, accRect.right);
9741
+ accRect.bottom = min(rect.bottom, accRect.bottom);
9742
+ accRect.left = max(rect.left, accRect.left);
9743
+ return accRect;
9744
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
9745
+ return {
9746
+ width: clippingRect.right - clippingRect.left,
9747
+ height: clippingRect.bottom - clippingRect.top,
9748
+ x: clippingRect.left,
9749
+ y: clippingRect.top
9750
+ };
9751
+ }
9752
+
9753
+ function getDimensions(element) {
9754
+ const {
9755
+ width,
9756
+ height
9757
+ } = getCssDimensions(element);
9758
+ return {
9759
+ width,
9760
+ height
9761
+ };
9762
+ }
9763
+
9764
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
9765
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
9766
+ const documentElement = getDocumentElement(offsetParent);
9767
+ const isFixed = strategy === 'fixed';
9768
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
9769
+ let scroll = {
9770
+ scrollLeft: 0,
9771
+ scrollTop: 0
9772
+ };
9773
+ const offsets = createCoords(0);
9774
+
9775
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
9776
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
9777
+ function setLeftRTLScrollbarOffset() {
9778
+ offsets.x = getWindowScrollBarX(documentElement);
9779
+ }
9780
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
9781
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
9782
+ scroll = getNodeScroll(offsetParent);
9783
+ }
9784
+ if (isOffsetParentAnElement) {
9785
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
9786
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
9787
+ offsets.y = offsetRect.y + offsetParent.clientTop;
9788
+ } else if (documentElement) {
9789
+ setLeftRTLScrollbarOffset();
9790
+ }
9791
+ }
9792
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
9793
+ setLeftRTLScrollbarOffset();
9794
+ }
9795
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
9796
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
9797
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
9798
+ return {
9799
+ x,
9800
+ y,
9801
+ width: rect.width,
9802
+ height: rect.height
9803
+ };
9804
+ }
9805
+
9806
+ function isStaticPositioned(element) {
9807
+ return getComputedStyle$1(element).position === 'static';
9808
+ }
9809
+
9810
+ function getTrueOffsetParent(element, polyfill) {
9811
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
9812
+ return null;
9813
+ }
9814
+ if (polyfill) {
9815
+ return polyfill(element);
9816
+ }
9817
+ let rawOffsetParent = element.offsetParent;
9818
+
9819
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
9820
+ // while Chrome and Safari return the <body> element. The <body> element must
9821
+ // be used to perform the correct calculations even if the <html> element is
9822
+ // non-static.
9823
+ if (getDocumentElement(element) === rawOffsetParent) {
9824
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
9825
+ }
9826
+ return rawOffsetParent;
9827
+ }
9828
+
9829
+ // Gets the closest ancestor positioned element. Handles some edge cases,
9830
+ // such as table ancestors and cross browser bugs.
9831
+ function getOffsetParent(element, polyfill) {
9832
+ const win = getWindow(element);
9833
+ if (isTopLayer(element)) {
9834
+ return win;
9835
+ }
9836
+ if (!isHTMLElement(element)) {
9837
+ let svgOffsetParent = getParentNode(element);
9838
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
9839
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
9840
+ return svgOffsetParent;
9841
+ }
9842
+ svgOffsetParent = getParentNode(svgOffsetParent);
9843
+ }
9844
+ return win;
9845
+ }
9846
+ let offsetParent = getTrueOffsetParent(element, polyfill);
9847
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
9848
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
9849
+ }
9850
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
9851
+ return win;
9852
+ }
9853
+ return offsetParent || getContainingBlock(element) || win;
9854
+ }
9855
+
9856
+ const getElementRects = async function (data) {
9857
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
9858
+ const getDimensionsFn = this.getDimensions;
9859
+ const floatingDimensions = await getDimensionsFn(data.floating);
9860
+ return {
9861
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
9862
+ floating: {
9863
+ x: 0,
9864
+ y: 0,
9865
+ width: floatingDimensions.width,
9866
+ height: floatingDimensions.height
9867
+ }
9868
+ };
9869
+ };
9870
+
9871
+ function isRTL(element) {
9872
+ return getComputedStyle$1(element).direction === 'rtl';
9873
+ }
9874
+
9875
+ const platform = {
9876
+ convertOffsetParentRelativeRectToViewportRelativeRect,
9877
+ getDocumentElement,
9878
+ getClippingRect,
9879
+ getOffsetParent,
9880
+ getElementRects,
9881
+ getClientRects,
9882
+ getDimensions,
9883
+ getScale,
9884
+ isElement,
9885
+ isRTL
9886
+ };
9887
+
9888
+ function rectsAreEqual(a, b) {
9889
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
9890
+ }
9891
+
9892
+ // https://samthor.au/2021/observing-dom/
9893
+ function observeMove(element, onMove) {
9894
+ let io = null;
9895
+ let timeoutId;
9896
+ const root = getDocumentElement(element);
9897
+ function cleanup() {
9898
+ var _io;
9899
+ clearTimeout(timeoutId);
9900
+ (_io = io) == null || _io.disconnect();
9901
+ io = null;
9902
+ }
9903
+ function refresh(skip, threshold) {
9904
+ if (skip === void 0) {
9905
+ skip = false;
9906
+ }
9907
+ if (threshold === void 0) {
9908
+ threshold = 1;
9909
+ }
9910
+ cleanup();
9911
+ const elementRectForRootMargin = element.getBoundingClientRect();
9912
+ const {
9913
+ left,
9914
+ top,
9915
+ width,
9916
+ height
9917
+ } = elementRectForRootMargin;
9918
+ if (!skip) {
9919
+ onMove();
9920
+ }
9921
+ if (!width || !height) {
9922
+ return;
9923
+ }
9924
+ const insetTop = floor(top);
9925
+ const insetRight = floor(root.clientWidth - (left + width));
9926
+ const insetBottom = floor(root.clientHeight - (top + height));
9927
+ const insetLeft = floor(left);
9928
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
9929
+ const options = {
9930
+ rootMargin,
9931
+ threshold: max(0, min(1, threshold)) || 1
9932
+ };
9933
+ let isFirstUpdate = true;
9934
+ function handleObserve(entries) {
9935
+ const ratio = entries[0].intersectionRatio;
9936
+ if (ratio !== threshold) {
9937
+ if (!isFirstUpdate) {
9938
+ return refresh();
9939
+ }
9940
+ if (!ratio) {
9941
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
9942
+ // to prevent an infinite loop of updates.
9943
+ timeoutId = setTimeout(() => {
9944
+ refresh(false, 1e-7);
9945
+ }, 1000);
9946
+ } else {
9947
+ refresh(false, ratio);
9948
+ }
9949
+ }
9950
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
9951
+ // It's possible that even though the ratio is reported as 1, the
9952
+ // element is not actually fully within the IntersectionObserver's root
9953
+ // area anymore. This can happen under performance constraints. This may
9954
+ // be a bug in the browser's IntersectionObserver implementation. To
9955
+ // work around this, we compare the element's bounding rect now with
9956
+ // what it was at the time we created the IntersectionObserver. If they
9957
+ // are not equal then the element moved, so we refresh.
9958
+ refresh();
9959
+ }
9960
+ isFirstUpdate = false;
9961
+ }
9962
+
9963
+ // Older browsers don't support a `document` as the root and will throw an
9964
+ // error.
9965
+ try {
9966
+ io = new IntersectionObserver(handleObserve, {
9967
+ ...options,
9968
+ // Handle <iframe>s
9969
+ root: root.ownerDocument
9970
+ });
9971
+ } catch (_e) {
9972
+ io = new IntersectionObserver(handleObserve, options);
9973
+ }
9974
+ io.observe(element);
9975
+ }
9976
+ refresh(true);
9977
+ return cleanup;
9978
+ }
9979
+
9980
+ /**
9981
+ * Automatically updates the position of the floating element when necessary.
9982
+ * Should only be called when the floating element is mounted on the DOM or
9983
+ * visible on the screen.
9984
+ * @returns cleanup function that should be invoked when the floating element is
9985
+ * removed from the DOM or hidden from the screen.
9986
+ * @see https://floating-ui.com/docs/autoUpdate
9987
+ */
9988
+ function autoUpdate(reference, floating, update, options) {
9989
+ if (options === void 0) {
9990
+ options = {};
9991
+ }
9992
+ const {
9993
+ ancestorScroll = true,
9994
+ ancestorResize = true,
9995
+ elementResize = typeof ResizeObserver === 'function',
9996
+ layoutShift = typeof IntersectionObserver === 'function',
9997
+ animationFrame = false
9998
+ } = options;
9999
+ const referenceEl = unwrapElement(reference);
10000
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
10001
+ ancestors.forEach(ancestor => {
10002
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
10003
+ passive: true
10004
+ });
10005
+ ancestorResize && ancestor.addEventListener('resize', update);
10006
+ });
10007
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
10008
+ let reobserveFrame = -1;
10009
+ let resizeObserver = null;
10010
+ if (elementResize) {
10011
+ resizeObserver = new ResizeObserver(_ref => {
10012
+ let [firstEntry] = _ref;
10013
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
10014
+ // Prevent update loops when using the `size` middleware.
10015
+ // https://github.com/floating-ui/floating-ui/issues/1740
10016
+ resizeObserver.unobserve(floating);
10017
+ cancelAnimationFrame(reobserveFrame);
10018
+ reobserveFrame = requestAnimationFrame(() => {
10019
+ var _resizeObserver;
10020
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
10021
+ });
10022
+ }
10023
+ update();
10024
+ });
10025
+ if (referenceEl && !animationFrame) {
10026
+ resizeObserver.observe(referenceEl);
10027
+ }
10028
+ resizeObserver.observe(floating);
10029
+ }
10030
+ let frameId;
10031
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
10032
+ if (animationFrame) {
10033
+ frameLoop();
10034
+ }
10035
+ function frameLoop() {
10036
+ const nextRefRect = getBoundingClientRect(reference);
10037
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
10038
+ update();
10039
+ }
10040
+ prevRefRect = nextRefRect;
10041
+ frameId = requestAnimationFrame(frameLoop);
10042
+ }
10043
+ update();
10044
+ return () => {
10045
+ var _resizeObserver2;
10046
+ ancestors.forEach(ancestor => {
10047
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
10048
+ ancestorResize && ancestor.removeEventListener('resize', update);
10049
+ });
10050
+ cleanupIo == null || cleanupIo();
10051
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
10052
+ resizeObserver = null;
10053
+ if (animationFrame) {
10054
+ cancelAnimationFrame(frameId);
10055
+ }
10056
+ };
10057
+ }
10058
+
10059
+ /**
10060
+ * Modifies the placement by translating the floating element along the
10061
+ * specified axes.
10062
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
10063
+ * object may be passed.
10064
+ * @see https://floating-ui.com/docs/offset
10065
+ */
10066
+ const offset$1 = offset$2;
10067
+
10068
+ /**
10069
+ * Optimizes the visibility of the floating element by shifting it in order to
10070
+ * keep it in view when it will overflow the clipping boundary.
10071
+ * @see https://floating-ui.com/docs/shift
10072
+ */
10073
+ const shift$1 = shift$2;
10074
+
10075
+ /**
10076
+ * Optimizes the visibility of the floating element by flipping the `placement`
10077
+ * in order to keep it in view when the preferred placement(s) will overflow the
10078
+ * clipping boundary. Alternative to `autoPlacement`.
10079
+ * @see https://floating-ui.com/docs/flip
10080
+ */
10081
+ const flip$1 = flip$2;
10082
+
10083
+ /**
10084
+ * Provides data that allows you to change the size of the floating element —
10085
+ * for instance, prevent it from overflowing the clipping boundary or match the
10086
+ * width of the reference element.
10087
+ * @see https://floating-ui.com/docs/size
10088
+ */
10089
+ const size$1 = size$2;
10090
+
10091
+ /**
10092
+ * Provides data to hide the floating element in applicable situations, such as
10093
+ * when it is not in the same clipping context as the reference element.
10094
+ * @see https://floating-ui.com/docs/hide
10095
+ */
10096
+ const hide$1 = hide$2;
10097
+
10098
+ /**
10099
+ * Provides data to position an inner element of the floating element so that it
10100
+ * appears centered to the reference element.
10101
+ * @see https://floating-ui.com/docs/arrow
10102
+ */
10103
+ const arrow$2 = arrow$3;
10104
+
10105
+ /**
10106
+ * Built-in `limiter` that will stop `shift()` at a certain point.
10107
+ */
10108
+ const limitShift$1 = limitShift$2;
10109
+
10110
+ /**
10111
+ * Computes the `x` and `y` coordinates that will place the floating element
10112
+ * next to a given reference element.
10113
+ */
10114
+ const computePosition = (reference, floating, options) => {
10115
+ // This caches the expensive `getClippingElementAncestors` function so that
10116
+ // multiple lifecycle resets re-use the same result. It only lives for a
10117
+ // single call. If other functions become expensive, we can add them as well.
10118
+ const cache = new Map();
10119
+ const mergedOptions = {
10120
+ platform,
10121
+ ...options
10122
+ };
10123
+ const platformWithCache = {
10124
+ ...mergedOptions.platform,
10125
+ _c: cache
10126
+ };
10127
+ return computePosition$1(reference, floating, {
10128
+ ...mergedOptions,
10129
+ platform: platformWithCache
10130
+ });
10131
+ };
10132
+
10133
+ var isClient = typeof document !== 'undefined';
10134
+
10135
+ var noop = function noop() {};
10136
+ var index = isClient ? useLayoutEffect : noop;
10137
+
10138
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
10139
+ // functions
10140
+ function deepEqual(a, b) {
10141
+ if (a === b) {
10142
+ return true;
10143
+ }
10144
+ if (typeof a !== typeof b) {
10145
+ return false;
10146
+ }
10147
+ if (typeof a === 'function' && a.toString() === b.toString()) {
10148
+ return true;
10149
+ }
10150
+ let length;
10151
+ let i;
10152
+ let keys;
10153
+ if (a && b && typeof a === 'object') {
10154
+ if (Array.isArray(a)) {
10155
+ length = a.length;
10156
+ if (length !== b.length) return false;
10157
+ for (i = length; i-- !== 0;) {
10158
+ if (!deepEqual(a[i], b[i])) {
10159
+ return false;
10160
+ }
10161
+ }
10162
+ return true;
10163
+ }
10164
+ keys = Object.keys(a);
10165
+ length = keys.length;
10166
+ if (length !== Object.keys(b).length) {
10167
+ return false;
10168
+ }
10169
+ for (i = length; i-- !== 0;) {
10170
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
10171
+ return false;
10172
+ }
10173
+ }
10174
+ for (i = length; i-- !== 0;) {
10175
+ const key = keys[i];
10176
+ if (key === '_owner' && a.$$typeof) {
10177
+ continue;
10178
+ }
10179
+ if (!deepEqual(a[key], b[key])) {
10180
+ return false;
10181
+ }
10182
+ }
10183
+ return true;
10184
+ }
10185
+ return a !== a && b !== b;
10186
+ }
10187
+
10188
+ function getDPR(element) {
10189
+ if (typeof window === 'undefined') {
10190
+ return 1;
10191
+ }
10192
+ const win = element.ownerDocument.defaultView || window;
10193
+ return win.devicePixelRatio || 1;
10194
+ }
10195
+
10196
+ function roundByDPR(element, value) {
10197
+ const dpr = getDPR(element);
10198
+ return Math.round(value * dpr) / dpr;
10199
+ }
10200
+
10201
+ function useLatestRef(value) {
10202
+ const ref = React.useRef(value);
10203
+ index(() => {
10204
+ ref.current = value;
10205
+ });
10206
+ return ref;
10207
+ }
10208
+
10209
+ /**
10210
+ * Provides data to position a floating element.
10211
+ * @see https://floating-ui.com/docs/useFloating
10212
+ */
10213
+ function useFloating(options) {
10214
+ if (options === void 0) {
10215
+ options = {};
10216
+ }
10217
+ const {
10218
+ placement = 'bottom',
10219
+ strategy = 'absolute',
10220
+ middleware = [],
10221
+ platform,
10222
+ elements: {
10223
+ reference: externalReference,
10224
+ floating: externalFloating
10225
+ } = {},
10226
+ transform = true,
10227
+ whileElementsMounted,
10228
+ open
10229
+ } = options;
10230
+ const [data, setData] = React.useState({
10231
+ x: 0,
10232
+ y: 0,
10233
+ strategy,
10234
+ placement,
10235
+ middlewareData: {},
10236
+ isPositioned: false
10237
+ });
10238
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
10239
+ if (!deepEqual(latestMiddleware, middleware)) {
10240
+ setLatestMiddleware(middleware);
10241
+ }
10242
+ const [_reference, _setReference] = React.useState(null);
10243
+ const [_floating, _setFloating] = React.useState(null);
10244
+ const setReference = React.useCallback(node => {
10245
+ if (node !== referenceRef.current) {
10246
+ referenceRef.current = node;
10247
+ _setReference(node);
10248
+ }
10249
+ }, []);
10250
+ const setFloating = React.useCallback(node => {
10251
+ if (node !== floatingRef.current) {
10252
+ floatingRef.current = node;
10253
+ _setFloating(node);
10254
+ }
10255
+ }, []);
10256
+ const referenceEl = externalReference || _reference;
10257
+ const floatingEl = externalFloating || _floating;
10258
+ const referenceRef = React.useRef(null);
10259
+ const floatingRef = React.useRef(null);
10260
+ const dataRef = React.useRef(data);
10261
+ const hasWhileElementsMounted = whileElementsMounted != null;
10262
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
10263
+ const platformRef = useLatestRef(platform);
10264
+ const openRef = useLatestRef(open);
10265
+ const update = React.useCallback(() => {
10266
+ if (!referenceRef.current || !floatingRef.current) {
10267
+ return;
10268
+ }
10269
+ const config = {
10270
+ placement,
10271
+ strategy,
10272
+ middleware: latestMiddleware
10273
+ };
10274
+ if (platformRef.current) {
10275
+ config.platform = platformRef.current;
10276
+ }
10277
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
10278
+ const fullData = {
10279
+ ...data,
10280
+ // The floating element's position may be recomputed while it's closed
10281
+ // but still mounted (such as when transitioning out). To ensure
10282
+ // `isPositioned` will be `false` initially on the next open, avoid
10283
+ // setting it to `true` when `open === false` (must be specified).
10284
+ isPositioned: openRef.current !== false
10285
+ };
10286
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
10287
+ dataRef.current = fullData;
10288
+ ReactDOM.flushSync(() => {
10289
+ setData(fullData);
10290
+ });
10291
+ }
10292
+ });
10293
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
10294
+ index(() => {
10295
+ if (open === false && dataRef.current.isPositioned) {
10296
+ dataRef.current.isPositioned = false;
10297
+ setData(data => ({
10298
+ ...data,
10299
+ isPositioned: false
10300
+ }));
10301
+ }
10302
+ }, [open]);
10303
+ const isMountedRef = React.useRef(false);
10304
+ index(() => {
10305
+ isMountedRef.current = true;
10306
+ return () => {
10307
+ isMountedRef.current = false;
10308
+ };
10309
+ }, []);
10310
+ index(() => {
10311
+ if (referenceEl) referenceRef.current = referenceEl;
10312
+ if (floatingEl) floatingRef.current = floatingEl;
10313
+ if (referenceEl && floatingEl) {
10314
+ if (whileElementsMountedRef.current) {
10315
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
10316
+ }
10317
+ update();
10318
+ }
10319
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
10320
+ const refs = React.useMemo(() => ({
10321
+ reference: referenceRef,
10322
+ floating: floatingRef,
10323
+ setReference,
10324
+ setFloating
10325
+ }), [setReference, setFloating]);
10326
+ const elements = React.useMemo(() => ({
10327
+ reference: referenceEl,
10328
+ floating: floatingEl
10329
+ }), [referenceEl, floatingEl]);
10330
+ const floatingStyles = React.useMemo(() => {
10331
+ const initialStyles = {
10332
+ position: strategy,
10333
+ left: 0,
10334
+ top: 0
10335
+ };
10336
+ if (!elements.floating) {
10337
+ return initialStyles;
10338
+ }
10339
+ const x = roundByDPR(elements.floating, data.x);
10340
+ const y = roundByDPR(elements.floating, data.y);
10341
+ if (transform) {
10342
+ return {
10343
+ ...initialStyles,
10344
+ transform: "translate(" + x + "px, " + y + "px)",
10345
+ ...(getDPR(elements.floating) >= 1.5 && {
10346
+ willChange: 'transform'
10347
+ })
10348
+ };
10349
+ }
10350
+ return {
10351
+ position: strategy,
10352
+ left: x,
10353
+ top: y
10354
+ };
10355
+ }, [strategy, transform, elements.floating, data.x, data.y]);
10356
+ return React.useMemo(() => ({
10357
+ ...data,
10358
+ update,
10359
+ refs,
10360
+ elements,
10361
+ floatingStyles
10362
+ }), [data, update, refs, elements, floatingStyles]);
10363
+ }
10364
+
10365
+ /**
10366
+ * Provides data to position an inner element of the floating element so that it
10367
+ * appears centered to the reference element.
10368
+ * This wraps the core `arrow` middleware to allow React refs as the element.
10369
+ * @see https://floating-ui.com/docs/arrow
10370
+ */
10371
+ const arrow$1 = options => {
10372
+ function isRef(value) {
10373
+ return {}.hasOwnProperty.call(value, 'current');
10374
+ }
10375
+ return {
10376
+ name: 'arrow',
10377
+ options,
10378
+ fn(state) {
10379
+ const {
10380
+ element,
10381
+ padding
10382
+ } = typeof options === 'function' ? options(state) : options;
10383
+ if (element && isRef(element)) {
10384
+ if (element.current != null) {
10385
+ return arrow$2({
10386
+ element: element.current,
10387
+ padding
10388
+ }).fn(state);
10389
+ }
10390
+ return {};
10391
+ }
10392
+ if (element) {
10393
+ return arrow$2({
10394
+ element,
10395
+ padding
10396
+ }).fn(state);
10397
+ }
10398
+ return {};
10399
+ }
10400
+ };
10401
+ };
10402
+
10403
+ /**
10404
+ * Modifies the placement by translating the floating element along the
10405
+ * specified axes.
10406
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
10407
+ * object may be passed.
10408
+ * @see https://floating-ui.com/docs/offset
10409
+ */
10410
+ const offset = (options, deps) => ({
10411
+ ...offset$1(options),
10412
+ options: [options, deps]
10413
+ });
10414
+
10415
+ /**
10416
+ * Optimizes the visibility of the floating element by shifting it in order to
10417
+ * keep it in view when it will overflow the clipping boundary.
10418
+ * @see https://floating-ui.com/docs/shift
10419
+ */
10420
+ const shift = (options, deps) => ({
10421
+ ...shift$1(options),
10422
+ options: [options, deps]
10423
+ });
10424
+
10425
+ /**
10426
+ * Built-in `limiter` that will stop `shift()` at a certain point.
10427
+ */
10428
+ const limitShift = (options, deps) => ({
10429
+ ...limitShift$1(options),
10430
+ options: [options, deps]
10431
+ });
10432
+
10433
+ /**
10434
+ * Optimizes the visibility of the floating element by flipping the `placement`
10435
+ * in order to keep it in view when the preferred placement(s) will overflow the
10436
+ * clipping boundary. Alternative to `autoPlacement`.
10437
+ * @see https://floating-ui.com/docs/flip
10438
+ */
10439
+ const flip = (options, deps) => ({
10440
+ ...flip$1(options),
10441
+ options: [options, deps]
10442
+ });
10443
+
10444
+ /**
10445
+ * Provides data that allows you to change the size of the floating element —
10446
+ * for instance, prevent it from overflowing the clipping boundary or match the
10447
+ * width of the reference element.
10448
+ * @see https://floating-ui.com/docs/size
10449
+ */
10450
+ const size = (options, deps) => ({
10451
+ ...size$1(options),
10452
+ options: [options, deps]
10453
+ });
10454
+
10455
+ /**
10456
+ * Provides data to hide the floating element in applicable situations, such as
10457
+ * when it is not in the same clipping context as the reference element.
10458
+ * @see https://floating-ui.com/docs/hide
10459
+ */
10460
+ const hide = (options, deps) => ({
10461
+ ...hide$1(options),
10462
+ options: [options, deps]
10463
+ });
10464
+
10465
+ /**
10466
+ * Provides data to position an inner element of the floating element so that it
10467
+ * appears centered to the reference element.
10468
+ * This wraps the core `arrow` middleware to allow React refs as the element.
10469
+ * @see https://floating-ui.com/docs/arrow
10470
+ */
10471
+ const arrow = (options, deps) => ({
10472
+ ...arrow$1(options),
10473
+ options: [options, deps]
10474
+ });
10475
+
10476
+ // src/arrow.tsx
10477
+ var NAME = "Arrow";
10478
+ var Arrow$1 = React.forwardRef((props, forwardedRef) => {
10479
+ const { children, width = 10, height = 5, ...arrowProps } = props;
10480
+ return /* @__PURE__ */ jsx(
10481
+ Primitive.svg,
10482
+ {
10483
+ ...arrowProps,
10484
+ ref: forwardedRef,
10485
+ width,
10486
+ height,
10487
+ viewBox: "0 0 30 10",
10488
+ preserveAspectRatio: "none",
10489
+ children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
10490
+ }
10491
+ );
10492
+ });
10493
+ Arrow$1.displayName = NAME;
10494
+ var Root = Arrow$1;
10495
+
10496
+ var POPPER_NAME = "Popper";
10497
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
10498
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
10499
+ var Popper = (props) => {
10500
+ const { __scopePopper, children } = props;
10501
+ const [anchor, setAnchor] = React.useState(null);
10502
+ return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
10503
+ };
10504
+ Popper.displayName = POPPER_NAME;
10505
+ var ANCHOR_NAME$1 = "PopperAnchor";
10506
+ var PopperAnchor = React.forwardRef(
10507
+ (props, forwardedRef) => {
10508
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
10509
+ const context = usePopperContext(ANCHOR_NAME$1, __scopePopper);
10510
+ const ref = React.useRef(null);
10511
+ const composedRefs = useComposedRefs(forwardedRef, ref);
10512
+ const anchorRef = React.useRef(null);
10513
+ React.useEffect(() => {
10514
+ const previousAnchor = anchorRef.current;
10515
+ anchorRef.current = virtualRef?.current || ref.current;
10516
+ if (previousAnchor !== anchorRef.current) {
10517
+ context.onAnchorChange(anchorRef.current);
10518
+ }
10519
+ });
10520
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
10521
+ }
10522
+ );
10523
+ PopperAnchor.displayName = ANCHOR_NAME$1;
10524
+ var CONTENT_NAME$1 = "PopperContent";
10525
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$1);
10526
+ var PopperContent = React.forwardRef(
10527
+ (props, forwardedRef) => {
10528
+ const {
10529
+ __scopePopper,
10530
+ side = "bottom",
10531
+ sideOffset = 0,
10532
+ align = "center",
10533
+ alignOffset = 0,
10534
+ arrowPadding = 0,
10535
+ avoidCollisions = true,
10536
+ collisionBoundary = [],
10537
+ collisionPadding: collisionPaddingProp = 0,
10538
+ sticky = "partial",
10539
+ hideWhenDetached = false,
10540
+ updatePositionStrategy = "optimized",
10541
+ onPlaced,
10542
+ ...contentProps
10543
+ } = props;
10544
+ const context = usePopperContext(CONTENT_NAME$1, __scopePopper);
10545
+ const [content, setContent] = React.useState(null);
10546
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
10547
+ const [arrow$1, setArrow] = React.useState(null);
10548
+ const arrowSize = useSize(arrow$1);
10549
+ const arrowWidth = arrowSize?.width ?? 0;
10550
+ const arrowHeight = arrowSize?.height ?? 0;
10551
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
10552
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
10553
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
10554
+ const hasExplicitBoundaries = boundary.length > 0;
10555
+ const detectOverflowOptions = {
10556
+ padding: collisionPadding,
10557
+ boundary: boundary.filter(isNotNull),
10558
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
10559
+ altBoundary: hasExplicitBoundaries
10560
+ };
10561
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
10562
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
10563
+ strategy: "fixed",
10564
+ placement: desiredPlacement,
10565
+ whileElementsMounted: (...args) => {
10566
+ const cleanup = autoUpdate(...args, {
10567
+ animationFrame: updatePositionStrategy === "always"
10568
+ });
10569
+ return cleanup;
10570
+ },
10571
+ elements: {
10572
+ reference: context.anchor
10573
+ },
10574
+ middleware: [
10575
+ offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
10576
+ avoidCollisions && shift({
10577
+ mainAxis: true,
10578
+ crossAxis: false,
10579
+ limiter: sticky === "partial" ? limitShift() : void 0,
10580
+ ...detectOverflowOptions
10581
+ }),
10582
+ avoidCollisions && flip({ ...detectOverflowOptions }),
10583
+ size({
10584
+ ...detectOverflowOptions,
10585
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
10586
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
10587
+ const contentStyle = elements.floating.style;
10588
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
10589
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
10590
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
10591
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
10592
+ }
10593
+ }),
10594
+ arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
10595
+ transformOrigin({ arrowWidth, arrowHeight }),
10596
+ hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
10597
+ ]
10598
+ });
10599
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
10600
+ const handlePlaced = useCallbackRef$1(onPlaced);
10601
+ useLayoutEffect2(() => {
10602
+ if (isPositioned) {
10603
+ handlePlaced?.();
10604
+ }
10605
+ }, [isPositioned, handlePlaced]);
10606
+ const arrowX = middlewareData.arrow?.x;
10607
+ const arrowY = middlewareData.arrow?.y;
10608
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
10609
+ const [contentZIndex, setContentZIndex] = React.useState();
10610
+ useLayoutEffect2(() => {
10611
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
10612
+ }, [content]);
10613
+ return /* @__PURE__ */ jsx(
10614
+ "div",
10615
+ {
10616
+ ref: refs.setFloating,
10617
+ "data-radix-popper-content-wrapper": "",
10618
+ style: {
10619
+ ...floatingStyles,
10620
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
10621
+ // keep off the page when measuring
10622
+ minWidth: "max-content",
10623
+ zIndex: contentZIndex,
10624
+ ["--radix-popper-transform-origin"]: [
10625
+ middlewareData.transformOrigin?.x,
10626
+ middlewareData.transformOrigin?.y
10627
+ ].join(" "),
10628
+ // hide the content if using the hide middleware and should be hidden
10629
+ // set visibility to hidden and disable pointer events so the UI behaves
10630
+ // as if the PopperContent isn't there at all
10631
+ ...middlewareData.hide?.referenceHidden && {
10632
+ visibility: "hidden",
10633
+ pointerEvents: "none"
10634
+ }
10635
+ },
10636
+ dir: props.dir,
10637
+ children: /* @__PURE__ */ jsx(
10638
+ PopperContentProvider,
10639
+ {
10640
+ scope: __scopePopper,
10641
+ placedSide,
10642
+ onArrowChange: setArrow,
10643
+ arrowX,
10644
+ arrowY,
10645
+ shouldHideArrow: cannotCenterArrow,
10646
+ children: /* @__PURE__ */ jsx(
10647
+ Primitive.div,
10648
+ {
10649
+ "data-side": placedSide,
10650
+ "data-align": placedAlign,
10651
+ ...contentProps,
10652
+ ref: composedRefs,
10653
+ style: {
10654
+ ...contentProps.style,
10655
+ // if the PopperContent hasn't been placed yet (not all measurements done)
10656
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
10657
+ animation: !isPositioned ? "none" : void 0
10658
+ }
10659
+ }
10660
+ )
10661
+ }
10662
+ )
10663
+ }
10664
+ );
10665
+ }
10666
+ );
10667
+ PopperContent.displayName = CONTENT_NAME$1;
10668
+ var ARROW_NAME$1 = "PopperArrow";
10669
+ var OPPOSITE_SIDE = {
10670
+ top: "bottom",
10671
+ right: "left",
10672
+ bottom: "top",
10673
+ left: "right"
10674
+ };
10675
+ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
10676
+ const { __scopePopper, ...arrowProps } = props;
10677
+ const contentContext = useContentContext(ARROW_NAME$1, __scopePopper);
10678
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
10679
+ return (
10680
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
10681
+ // doesn't report size as we'd expect on SVG elements.
10682
+ // it reports their bounding box which is effectively the largest path inside the SVG.
10683
+ /* @__PURE__ */ jsx(
10684
+ "span",
10685
+ {
10686
+ ref: contentContext.onArrowChange,
10687
+ style: {
10688
+ position: "absolute",
10689
+ left: contentContext.arrowX,
10690
+ top: contentContext.arrowY,
10691
+ [baseSide]: 0,
10692
+ transformOrigin: {
10693
+ top: "",
10694
+ right: "0 0",
10695
+ bottom: "center 0",
10696
+ left: "100% 0"
10697
+ }[contentContext.placedSide],
10698
+ transform: {
10699
+ top: "translateY(100%)",
10700
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
10701
+ bottom: `rotate(180deg)`,
10702
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
10703
+ }[contentContext.placedSide],
10704
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
10705
+ },
10706
+ children: /* @__PURE__ */ jsx(
10707
+ Root,
10708
+ {
10709
+ ...arrowProps,
10710
+ ref: forwardedRef,
10711
+ style: {
10712
+ ...arrowProps.style,
10713
+ // ensures the element can be measured correctly (mostly for if SVG)
10714
+ display: "block"
10715
+ }
10716
+ }
10717
+ )
10718
+ }
10719
+ )
10720
+ );
10721
+ });
10722
+ PopperArrow.displayName = ARROW_NAME$1;
10723
+ function isNotNull(value) {
10724
+ return value !== null;
10725
+ }
10726
+ var transformOrigin = (options) => ({
10727
+ name: "transformOrigin",
10728
+ options,
10729
+ fn(data) {
10730
+ const { placement, rects, middlewareData } = data;
10731
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
10732
+ const isArrowHidden = cannotCenterArrow;
10733
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
10734
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
10735
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
10736
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
10737
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
10738
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
10739
+ let x = "";
10740
+ let y = "";
10741
+ if (placedSide === "bottom") {
10742
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
10743
+ y = `${-arrowHeight}px`;
10744
+ } else if (placedSide === "top") {
10745
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
10746
+ y = `${rects.floating.height + arrowHeight}px`;
10747
+ } else if (placedSide === "right") {
10748
+ x = `${-arrowHeight}px`;
10749
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
10750
+ } else if (placedSide === "left") {
10751
+ x = `${rects.floating.width + arrowHeight}px`;
10752
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
10753
+ }
10754
+ return { data: { x, y } };
10755
+ }
10756
+ });
10757
+ function getSideAndAlignFromPlacement(placement) {
10758
+ const [side, align = "center"] = placement.split("-");
10759
+ return [side, align];
10760
+ }
10761
+ var Root2$1 = Popper;
10762
+ var Anchor = PopperAnchor;
10763
+ var Content = PopperContent;
10764
+ var Arrow = PopperArrow;
10765
+
10766
+ var PORTAL_NAME$1 = "Portal";
10767
+ var Portal$1 = React.forwardRef((props, forwardedRef) => {
10768
+ const { container: containerProp, ...portalProps } = props;
10769
+ const [mounted, setMounted] = React.useState(false);
10770
+ useLayoutEffect2(() => setMounted(true), []);
10771
+ const container = containerProp || mounted && globalThis?.document?.body;
10772
+ return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
10773
+ });
10774
+ Portal$1.displayName = PORTAL_NAME$1;
10775
+
10776
+ var getDefaultParent = function (originalTarget) {
10777
+ if (typeof document === 'undefined') {
10778
+ return null;
10779
+ }
10780
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
10781
+ return sampleTarget.ownerDocument.body;
10782
+ };
10783
+ var counterMap = new WeakMap();
10784
+ var uncontrolledNodes = new WeakMap();
10785
+ var markerMap = {};
10786
+ var lockCount = 0;
10787
+ var unwrapHost = function (node) {
10788
+ return node && (node.host || unwrapHost(node.parentNode));
10789
+ };
10790
+ var correctTargets = function (parent, targets) {
10791
+ return targets
10792
+ .map(function (target) {
10793
+ if (parent.contains(target)) {
10794
+ return target;
10795
+ }
10796
+ var correctedTarget = unwrapHost(target);
10797
+ if (correctedTarget && parent.contains(correctedTarget)) {
10798
+ return correctedTarget;
10799
+ }
10800
+ console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
10801
+ return null;
10802
+ })
10803
+ .filter(function (x) { return Boolean(x); });
10804
+ };
10805
+ /**
10806
+ * Marks everything except given node(or nodes) as aria-hidden
10807
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
10808
+ * @param [parentNode] - top element, defaults to document.body
10809
+ * @param {String} [markerName] - a special attribute to mark every node
10810
+ * @param {String} [controlAttribute] - html Attribute to control
10811
+ * @return {Undo} undo command
10812
+ */
10813
+ var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
10814
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
10815
+ if (!markerMap[markerName]) {
10816
+ markerMap[markerName] = new WeakMap();
10817
+ }
10818
+ var markerCounter = markerMap[markerName];
10819
+ var hiddenNodes = [];
10820
+ var elementsToKeep = new Set();
10821
+ var elementsToStop = new Set(targets);
10822
+ var keep = function (el) {
10823
+ if (!el || elementsToKeep.has(el)) {
10824
+ return;
10825
+ }
10826
+ elementsToKeep.add(el);
10827
+ keep(el.parentNode);
10828
+ };
10829
+ targets.forEach(keep);
10830
+ var deep = function (parent) {
10831
+ if (!parent || elementsToStop.has(parent)) {
10832
+ return;
10833
+ }
10834
+ Array.prototype.forEach.call(parent.children, function (node) {
10835
+ if (elementsToKeep.has(node)) {
10836
+ deep(node);
10837
+ }
10838
+ else {
10839
+ try {
10840
+ var attr = node.getAttribute(controlAttribute);
10841
+ var alreadyHidden = attr !== null && attr !== 'false';
10842
+ var counterValue = (counterMap.get(node) || 0) + 1;
10843
+ var markerValue = (markerCounter.get(node) || 0) + 1;
10844
+ counterMap.set(node, counterValue);
10845
+ markerCounter.set(node, markerValue);
10846
+ hiddenNodes.push(node);
10847
+ if (counterValue === 1 && alreadyHidden) {
10848
+ uncontrolledNodes.set(node, true);
10849
+ }
10850
+ if (markerValue === 1) {
10851
+ node.setAttribute(markerName, 'true');
10852
+ }
10853
+ if (!alreadyHidden) {
10854
+ node.setAttribute(controlAttribute, 'true');
10855
+ }
10856
+ }
10857
+ catch (e) {
10858
+ console.error('aria-hidden: cannot operate on ', node, e);
10859
+ }
10860
+ }
10861
+ });
10862
+ };
10863
+ deep(parentNode);
10864
+ elementsToKeep.clear();
10865
+ lockCount++;
10866
+ return function () {
10867
+ hiddenNodes.forEach(function (node) {
10868
+ var counterValue = counterMap.get(node) - 1;
10869
+ var markerValue = markerCounter.get(node) - 1;
10870
+ counterMap.set(node, counterValue);
10871
+ markerCounter.set(node, markerValue);
10872
+ if (!counterValue) {
10873
+ if (!uncontrolledNodes.has(node)) {
10874
+ node.removeAttribute(controlAttribute);
10875
+ }
10876
+ uncontrolledNodes.delete(node);
10877
+ }
10878
+ if (!markerValue) {
10879
+ node.removeAttribute(markerName);
10880
+ }
10881
+ });
10882
+ lockCount--;
10883
+ if (!lockCount) {
10884
+ // clear
10885
+ counterMap = new WeakMap();
10886
+ counterMap = new WeakMap();
10887
+ uncontrolledNodes = new WeakMap();
10888
+ markerMap = {};
10889
+ }
10890
+ };
10891
+ };
10892
+ /**
10893
+ * Marks everything except given node(or nodes) as aria-hidden
10894
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
10895
+ * @param [parentNode] - top element, defaults to document.body
10896
+ * @param {String} [markerName] - a special attribute to mark every node
10897
+ * @return {Undo} undo command
10898
+ */
10899
+ var hideOthers = function (originalTarget, parentNode, markerName) {
10900
+ if (markerName === void 0) { markerName = 'data-aria-hidden'; }
10901
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
10902
+ var activeParentNode = getDefaultParent(originalTarget);
10903
+ if (!activeParentNode) {
10904
+ return function () { return null; };
10905
+ }
10906
+ // we should not hide aria-live elements - https://github.com/theKashey/aria-hidden/issues/10
10907
+ // and script elements, as they have no impact on accessibility.
10908
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live], script')));
10909
+ return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
10910
+ };
10911
+
10912
+ /******************************************************************************
10913
+ Copyright (c) Microsoft Corporation.
10914
+
10915
+ Permission to use, copy, modify, and/or distribute this software for any
10916
+ purpose with or without fee is hereby granted.
10917
+
10918
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10919
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10920
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10921
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10922
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
10923
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10924
+ PERFORMANCE OF THIS SOFTWARE.
10925
+ ***************************************************************************** */
10926
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
10927
+
10928
+
10929
+ var __assign = function() {
10930
+ __assign = Object.assign || function __assign(t) {
10931
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
10932
+ s = arguments[i];
10933
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10934
+ }
10935
+ return t;
10936
+ };
10937
+ return __assign.apply(this, arguments);
10938
+ };
10939
+
10940
+ function __rest(s, e) {
10941
+ var t = {};
10942
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
10943
+ t[p] = s[p];
10944
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
10945
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
10946
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10947
+ t[p[i]] = s[p[i]];
10948
+ }
10949
+ return t;
10950
+ }
10951
+
10952
+ function __spreadArray(to, from, pack) {
10953
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
10954
+ if (ar || !(i in from)) {
10955
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
10956
+ ar[i] = from[i];
10957
+ }
10958
+ }
10959
+ return to.concat(ar || Array.prototype.slice.call(from));
10960
+ }
10961
+
10962
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
10963
+ var e = new Error(message);
10964
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
10965
+ };
10966
+
10967
+ var zeroRightClassName = 'right-scroll-bar-position';
10968
+ var fullWidthClassName = 'width-before-scroll-bar';
10969
+ var noScrollbarsClassName = 'with-scroll-bars-hidden';
10970
+ /**
10971
+ * Name of a CSS variable containing the amount of "hidden" scrollbar
10972
+ * ! might be undefined ! use will fallback!
10973
+ */
10974
+ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
10975
+
10976
+ /**
10977
+ * Assigns a value for a given ref, no matter of the ref format
10978
+ * @param {RefObject} ref - a callback function or ref object
10979
+ * @param value - a new value
10980
+ *
10981
+ * @see https://github.com/theKashey/use-callback-ref#assignref
10982
+ * @example
10983
+ * const refObject = useRef();
10984
+ * const refFn = (ref) => {....}
10985
+ *
10986
+ * assignRef(refObject, "refValue");
10987
+ * assignRef(refFn, "refValue");
10988
+ */
10989
+ function assignRef(ref, value) {
10990
+ if (typeof ref === 'function') {
10991
+ ref(value);
10992
+ }
10993
+ else if (ref) {
10994
+ ref.current = value;
10995
+ }
10996
+ return ref;
10997
+ }
10998
+
10999
+ /**
11000
+ * creates a MutableRef with ref change callback
11001
+ * @param initialValue - initial ref value
11002
+ * @param {Function} callback - a callback to run when value changes
11003
+ *
11004
+ * @example
11005
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
11006
+ * ref.current = 1;
11007
+ * // prints 0 -> 1
11008
+ *
11009
+ * @see https://reactjs.org/docs/hooks-reference.html#useref
11010
+ * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
11011
+ * @returns {MutableRefObject}
11012
+ */
11013
+ function useCallbackRef(initialValue, callback) {
11014
+ var ref = useState(function () { return ({
11015
+ // value
11016
+ value: initialValue,
11017
+ // last callback
11018
+ callback: callback,
11019
+ // "memoized" public interface
11020
+ facade: {
11021
+ get current() {
11022
+ return ref.value;
11023
+ },
11024
+ set current(value) {
11025
+ var last = ref.value;
11026
+ if (last !== value) {
11027
+ ref.value = value;
11028
+ ref.callback(value, last);
11029
+ }
11030
+ },
11031
+ },
11032
+ }); })[0];
11033
+ // update callback
11034
+ ref.callback = callback;
11035
+ return ref.facade;
11036
+ }
11037
+
11038
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
11039
+ var currentValues = new WeakMap();
11040
+ /**
11041
+ * Merges two or more refs together providing a single interface to set their value
11042
+ * @param {RefObject|Ref} refs
11043
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
11044
+ *
11045
+ * @see {@link mergeRefs} a version without buit-in memoization
11046
+ * @see https://github.com/theKashey/use-callback-ref#usemergerefs
11047
+ * @example
11048
+ * const Component = React.forwardRef((props, ref) => {
11049
+ * const ownRef = useRef();
11050
+ * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
11051
+ * return <div ref={domRef}>...</div>
11052
+ * }
11053
+ */
11054
+ function useMergeRefs(refs, defaultValue) {
11055
+ var callbackRef = useCallbackRef(null, function (newValue) {
11056
+ return refs.forEach(function (ref) { return assignRef(ref, newValue); });
11057
+ });
11058
+ // handle refs changes - added or removed
11059
+ useIsomorphicLayoutEffect(function () {
11060
+ var oldValue = currentValues.get(callbackRef);
11061
+ if (oldValue) {
11062
+ var prevRefs_1 = new Set(oldValue);
11063
+ var nextRefs_1 = new Set(refs);
11064
+ var current_1 = callbackRef.current;
11065
+ prevRefs_1.forEach(function (ref) {
11066
+ if (!nextRefs_1.has(ref)) {
11067
+ assignRef(ref, null);
11068
+ }
11069
+ });
11070
+ nextRefs_1.forEach(function (ref) {
11071
+ if (!prevRefs_1.has(ref)) {
11072
+ assignRef(ref, current_1);
11073
+ }
11074
+ });
11075
+ }
11076
+ currentValues.set(callbackRef, refs);
11077
+ }, [refs]);
11078
+ return callbackRef;
11079
+ }
11080
+
11081
+ function ItoI(a) {
11082
+ return a;
11083
+ }
11084
+ function innerCreateMedium(defaults, middleware) {
11085
+ if (middleware === void 0) { middleware = ItoI; }
11086
+ var buffer = [];
11087
+ var assigned = false;
11088
+ var medium = {
11089
+ read: function () {
11090
+ if (assigned) {
11091
+ throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
11092
+ }
11093
+ if (buffer.length) {
11094
+ return buffer[buffer.length - 1];
11095
+ }
11096
+ return defaults;
11097
+ },
11098
+ useMedium: function (data) {
11099
+ var item = middleware(data, assigned);
11100
+ buffer.push(item);
11101
+ return function () {
11102
+ buffer = buffer.filter(function (x) { return x !== item; });
11103
+ };
11104
+ },
11105
+ assignSyncMedium: function (cb) {
11106
+ assigned = true;
11107
+ while (buffer.length) {
11108
+ var cbs = buffer;
11109
+ buffer = [];
11110
+ cbs.forEach(cb);
11111
+ }
11112
+ buffer = {
11113
+ push: function (x) { return cb(x); },
11114
+ filter: function () { return buffer; },
11115
+ };
11116
+ },
11117
+ assignMedium: function (cb) {
11118
+ assigned = true;
11119
+ var pendingQueue = [];
11120
+ if (buffer.length) {
11121
+ var cbs = buffer;
11122
+ buffer = [];
11123
+ cbs.forEach(cb);
11124
+ pendingQueue = buffer;
11125
+ }
11126
+ var executeQueue = function () {
11127
+ var cbs = pendingQueue;
11128
+ pendingQueue = [];
11129
+ cbs.forEach(cb);
11130
+ };
11131
+ var cycle = function () { return Promise.resolve().then(executeQueue); };
11132
+ cycle();
11133
+ buffer = {
11134
+ push: function (x) {
11135
+ pendingQueue.push(x);
11136
+ cycle();
11137
+ },
11138
+ filter: function (filter) {
11139
+ pendingQueue = pendingQueue.filter(filter);
11140
+ return buffer;
11141
+ },
11142
+ };
11143
+ },
11144
+ };
11145
+ return medium;
11146
+ }
11147
+ // eslint-disable-next-line @typescript-eslint/ban-types
11148
+ function createSidecarMedium(options) {
11149
+ if (options === void 0) { options = {}; }
11150
+ var medium = innerCreateMedium(null);
11151
+ medium.options = __assign({ async: true, ssr: false }, options);
11152
+ return medium;
11153
+ }
11154
+
11155
+ var SideCar$1 = function (_a) {
11156
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
11157
+ if (!sideCar) {
11158
+ throw new Error('Sidecar: please provide `sideCar` property to import the right car');
11159
+ }
11160
+ var Target = sideCar.read();
11161
+ if (!Target) {
11162
+ throw new Error('Sidecar medium not found');
11163
+ }
11164
+ return React.createElement(Target, __assign({}, rest));
11165
+ };
11166
+ SideCar$1.isSideCarExport = true;
11167
+ function exportSidecar(medium, exported) {
11168
+ medium.useMedium(exported);
11169
+ return SideCar$1;
11170
+ }
11171
+
11172
+ var effectCar = createSidecarMedium();
11173
+
11174
+ var nothing = function () {
11175
+ return;
11176
+ };
11177
+ /**
11178
+ * Removes scrollbar from the page and contain the scroll within the Lock
11179
+ */
11180
+ var RemoveScroll = React.forwardRef(function (props, parentRef) {
11181
+ var ref = React.useRef(null);
11182
+ var _a = React.useState({
11183
+ onScrollCapture: nothing,
11184
+ onWheelCapture: nothing,
11185
+ onTouchMoveCapture: nothing,
11186
+ }), callbacks = _a[0], setCallbacks = _a[1];
11187
+ 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"]);
11188
+ var SideCar = sideCar;
11189
+ var containerRef = useMergeRefs([ref, parentRef]);
11190
+ var containerProps = __assign(__assign({}, rest), callbacks);
11191
+ return (React.createElement(React.Fragment, null,
11192
+ enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noRelative: noRelative, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
11193
+ forwardProps ? (React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef }))) : (React.createElement(Container, __assign({}, containerProps, { className: className, ref: containerRef }), children))));
11194
+ });
11195
+ RemoveScroll.defaultProps = {
11196
+ enabled: true,
11197
+ removeScrollBar: true,
11198
+ inert: false,
11199
+ };
11200
+ RemoveScroll.classNames = {
11201
+ fullWidth: fullWidthClassName,
11202
+ zeroRight: zeroRightClassName,
11203
+ };
11204
+
11205
+ var getNonce = function () {
11206
+ if (typeof __webpack_nonce__ !== 'undefined') {
11207
+ return __webpack_nonce__;
11208
+ }
11209
+ return undefined;
11210
+ };
11211
+
11212
+ function makeStyleTag() {
11213
+ if (!document)
11214
+ return null;
11215
+ var tag = document.createElement('style');
11216
+ tag.type = 'text/css';
11217
+ var nonce = getNonce();
11218
+ if (nonce) {
11219
+ tag.setAttribute('nonce', nonce);
11220
+ }
11221
+ return tag;
11222
+ }
11223
+ function injectStyles(tag, css) {
11224
+ // @ts-ignore
11225
+ if (tag.styleSheet) {
11226
+ // @ts-ignore
11227
+ tag.styleSheet.cssText = css;
11228
+ }
11229
+ else {
11230
+ tag.appendChild(document.createTextNode(css));
11231
+ }
11232
+ }
11233
+ function insertStyleTag(tag) {
11234
+ var head = document.head || document.getElementsByTagName('head')[0];
11235
+ head.appendChild(tag);
11236
+ }
11237
+ var stylesheetSingleton = function () {
11238
+ var counter = 0;
11239
+ var stylesheet = null;
11240
+ return {
11241
+ add: function (style) {
11242
+ if (counter == 0) {
11243
+ if ((stylesheet = makeStyleTag())) {
11244
+ injectStyles(stylesheet, style);
11245
+ insertStyleTag(stylesheet);
11246
+ }
11247
+ }
11248
+ counter++;
11249
+ },
11250
+ remove: function () {
11251
+ counter--;
11252
+ if (!counter && stylesheet) {
11253
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
11254
+ stylesheet = null;
11255
+ }
11256
+ },
11257
+ };
11258
+ };
11259
+
11260
+ /**
11261
+ * creates a hook to control style singleton
11262
+ * @see {@link styleSingleton} for a safer component version
11263
+ * @example
11264
+ * ```tsx
11265
+ * const useStyle = styleHookSingleton();
11266
+ * ///
11267
+ * useStyle('body { overflow: hidden}');
11268
+ */
11269
+ var styleHookSingleton = function () {
11270
+ var sheet = stylesheetSingleton();
11271
+ return function (styles, isDynamic) {
11272
+ React.useEffect(function () {
11273
+ sheet.add(styles);
11274
+ return function () {
11275
+ sheet.remove();
11276
+ };
11277
+ }, [styles && isDynamic]);
11278
+ };
11279
+ };
11280
+
11281
+ /**
11282
+ * create a Component to add styles on demand
11283
+ * - styles are added when first instance is mounted
11284
+ * - styles are removed when the last instance is unmounted
11285
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
11286
+ */
11287
+ var styleSingleton = function () {
11288
+ var useStyle = styleHookSingleton();
11289
+ var Sheet = function (_a) {
11290
+ var styles = _a.styles, dynamic = _a.dynamic;
11291
+ useStyle(styles, dynamic);
11292
+ return null;
11293
+ };
11294
+ return Sheet;
11295
+ };
11296
+
11297
+ var zeroGap = {
11298
+ left: 0,
11299
+ top: 0,
11300
+ right: 0,
11301
+ gap: 0,
11302
+ };
11303
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
11304
+ var getOffset = function (gapMode) {
11305
+ var cs = window.getComputedStyle(document.body);
11306
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
11307
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
11308
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
11309
+ return [parse(left), parse(top), parse(right)];
11310
+ };
11311
+ var getGapWidth = function (gapMode) {
11312
+ if (gapMode === void 0) { gapMode = 'margin'; }
11313
+ if (typeof window === 'undefined') {
11314
+ return zeroGap;
11315
+ }
11316
+ var offsets = getOffset(gapMode);
11317
+ var documentWidth = document.documentElement.clientWidth;
11318
+ var windowWidth = window.innerWidth;
11319
+ return {
11320
+ left: offsets[0],
11321
+ top: offsets[1],
11322
+ right: offsets[2],
11323
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
11324
+ };
11325
+ };
11326
+
11327
+ var Style = styleSingleton();
11328
+ var lockAttribute = 'data-scroll-locked';
11329
+ // important tip - once we measure scrollBar width and remove them
11330
+ // we could not repeat this operation
11331
+ // thus we are using style-singleton - only the first "yet correct" style will be applied.
11332
+ var getStyles = function (_a, allowRelative, gapMode, important) {
11333
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
11334
+ if (gapMode === void 0) { gapMode = 'margin'; }
11335
+ 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([
11336
+ allowRelative && "position: relative ".concat(important, ";"),
11337
+ gapMode === 'margin' &&
11338
+ "\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 "),
11339
+ gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
11340
+ ]
11341
+ .filter(Boolean)
11342
+ .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");
11343
+ };
11344
+ var getCurrentUseCounter = function () {
11345
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
11346
+ return isFinite(counter) ? counter : 0;
11347
+ };
11348
+ var useLockAttribute = function () {
11349
+ React.useEffect(function () {
11350
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
11351
+ return function () {
11352
+ var newCounter = getCurrentUseCounter() - 1;
11353
+ if (newCounter <= 0) {
11354
+ document.body.removeAttribute(lockAttribute);
11355
+ }
11356
+ else {
11357
+ document.body.setAttribute(lockAttribute, newCounter.toString());
11358
+ }
11359
+ };
11360
+ }, []);
11361
+ };
11362
+ /**
11363
+ * Removes page scrollbar and blocks page scroll when mounted
11364
+ */
11365
+ var RemoveScrollBar = function (_a) {
11366
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
11367
+ useLockAttribute();
11368
+ /*
11369
+ gap will be measured on every component mount
11370
+ however it will be used only by the "first" invocation
11371
+ due to singleton nature of <Style
11372
+ */
11373
+ var gap = React.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
11374
+ return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
11375
+ };
11376
+
11377
+ var passiveSupported = false;
11378
+ if (typeof window !== 'undefined') {
11379
+ try {
11380
+ var options = Object.defineProperty({}, 'passive', {
11381
+ get: function () {
11382
+ passiveSupported = true;
11383
+ return true;
11384
+ },
11385
+ });
11386
+ // @ts-ignore
11387
+ window.addEventListener('test', options, options);
11388
+ // @ts-ignore
11389
+ window.removeEventListener('test', options, options);
11390
+ }
11391
+ catch (err) {
11392
+ passiveSupported = false;
11393
+ }
11394
+ }
11395
+ var nonPassive = passiveSupported ? { passive: false } : false;
11396
+
11397
+ var alwaysContainsScroll = function (node) {
11398
+ // textarea will always _contain_ scroll inside self. It only can be hidden
11399
+ return node.tagName === 'TEXTAREA';
11400
+ };
11401
+ var elementCanBeScrolled = function (node, overflow) {
11402
+ if (!(node instanceof Element)) {
11403
+ return false;
11404
+ }
11405
+ var styles = window.getComputedStyle(node);
11406
+ return (
11407
+ // not-not-scrollable
11408
+ styles[overflow] !== 'hidden' &&
11409
+ // contains scroll inside self
11410
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
11411
+ };
11412
+ var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
11413
+ var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
11414
+ var locationCouldBeScrolled = function (axis, node) {
11415
+ var ownerDocument = node.ownerDocument;
11416
+ var current = node;
11417
+ do {
11418
+ // Skip over shadow root
11419
+ if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
11420
+ current = current.host;
11421
+ }
11422
+ var isScrollable = elementCouldBeScrolled(axis, current);
11423
+ if (isScrollable) {
11424
+ var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
11425
+ if (scrollHeight > clientHeight) {
11426
+ return true;
11427
+ }
11428
+ }
11429
+ current = current.parentNode;
11430
+ } while (current && current !== ownerDocument.body);
11431
+ return false;
11432
+ };
11433
+ var getVScrollVariables = function (_a) {
11434
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
11435
+ return [
11436
+ scrollTop,
11437
+ scrollHeight,
11438
+ clientHeight,
11439
+ ];
11440
+ };
11441
+ var getHScrollVariables = function (_a) {
11442
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
11443
+ return [
11444
+ scrollLeft,
11445
+ scrollWidth,
11446
+ clientWidth,
11447
+ ];
11448
+ };
11449
+ var elementCouldBeScrolled = function (axis, node) {
11450
+ return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
11451
+ };
11452
+ var getScrollVariables = function (axis, node) {
11453
+ return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
11454
+ };
11455
+ var getDirectionFactor = function (axis, direction) {
11456
+ /**
11457
+ * If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
11458
+ * and then increasingly negative as you scroll towards the end of the content.
11459
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
11460
+ */
11461
+ return axis === 'h' && direction === 'rtl' ? -1 : 1;
11462
+ };
11463
+ var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
11464
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
11465
+ var delta = directionFactor * sourceDelta;
11466
+ // find scrollable target
11467
+ var target = event.target;
11468
+ var targetInLock = endTarget.contains(target);
11469
+ var shouldCancelScroll = false;
11470
+ var isDeltaPositive = delta > 0;
11471
+ var availableScroll = 0;
11472
+ var availableScrollTop = 0;
11473
+ do {
11474
+ if (!target) {
11475
+ break;
11476
+ }
11477
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
11478
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
11479
+ if (position || elementScroll) {
11480
+ if (elementCouldBeScrolled(axis, target)) {
11481
+ availableScroll += elementScroll;
11482
+ availableScrollTop += position;
11483
+ }
11484
+ }
11485
+ var parent_1 = target.parentNode;
11486
+ // we will "bubble" from ShadowDom in case we are, or just to the parent in normal case
11487
+ // this is the same logic used in focus-lock
11488
+ target = (parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1);
11489
+ } while (
11490
+ // portaled content
11491
+ (!targetInLock && target !== document.body) ||
11492
+ // self content
11493
+ (targetInLock && (endTarget.contains(target) || endTarget === target)));
11494
+ // handle epsilon around 0 (non standard zoom levels)
11495
+ if (isDeltaPositive &&
11496
+ ((Math.abs(availableScroll) < 1) || (false))) {
11497
+ shouldCancelScroll = true;
11498
+ }
11499
+ else if (!isDeltaPositive &&
11500
+ ((Math.abs(availableScrollTop) < 1) || (false))) {
11501
+ shouldCancelScroll = true;
11502
+ }
11503
+ return shouldCancelScroll;
11504
+ };
11505
+
11506
+ var getTouchXY = function (event) {
11507
+ return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
11508
+ };
11509
+ var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
11510
+ var extractRef = function (ref) {
11511
+ return ref && 'current' in ref ? ref.current : ref;
11512
+ };
11513
+ var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
11514
+ var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
11515
+ var idCounter = 0;
11516
+ var lockStack = [];
11517
+ function RemoveScrollSideCar(props) {
11518
+ var shouldPreventQueue = React.useRef([]);
11519
+ var touchStartRef = React.useRef([0, 0]);
11520
+ var activeAxis = React.useRef();
11521
+ var id = React.useState(idCounter++)[0];
11522
+ var Style = React.useState(styleSingleton)[0];
11523
+ var lastProps = React.useRef(props);
11524
+ React.useEffect(function () {
11525
+ lastProps.current = props;
11526
+ }, [props]);
11527
+ React.useEffect(function () {
11528
+ if (props.inert) {
11529
+ document.body.classList.add("block-interactivity-".concat(id));
11530
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
11531
+ allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
11532
+ return function () {
11533
+ document.body.classList.remove("block-interactivity-".concat(id));
11534
+ allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
11535
+ };
11536
+ }
11537
+ return;
11538
+ }, [props.inert, props.lockRef.current, props.shards]);
11539
+ var shouldCancelEvent = React.useCallback(function (event, parent) {
11540
+ if (('touches' in event && event.touches.length === 2) || (event.type === 'wheel' && event.ctrlKey)) {
11541
+ return !lastProps.current.allowPinchZoom;
11542
+ }
11543
+ var touch = getTouchXY(event);
11544
+ var touchStart = touchStartRef.current;
11545
+ var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
11546
+ var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
11547
+ var currentAxis;
11548
+ var target = event.target;
11549
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
11550
+ // allow horizontal touch move on Range inputs. They will not cause any scroll
11551
+ if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
11552
+ return false;
11553
+ }
11554
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
11555
+ if (!canBeScrolledInMainDirection) {
11556
+ return true;
11557
+ }
11558
+ if (canBeScrolledInMainDirection) {
11559
+ currentAxis = moveDirection;
11560
+ }
11561
+ else {
11562
+ currentAxis = moveDirection === 'v' ? 'h' : 'v';
11563
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
11564
+ // other axis might be not scrollable
11565
+ }
11566
+ if (!canBeScrolledInMainDirection) {
11567
+ return false;
11568
+ }
11569
+ if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
11570
+ activeAxis.current = currentAxis;
11571
+ }
11572
+ if (!currentAxis) {
11573
+ return true;
11574
+ }
11575
+ var cancelingAxis = activeAxis.current || currentAxis;
11576
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY);
11577
+ }, []);
11578
+ var shouldPrevent = React.useCallback(function (_event) {
11579
+ var event = _event;
11580
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
11581
+ // not the last active
11582
+ return;
11583
+ }
11584
+ var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
11585
+ 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];
11586
+ // self event, and should be canceled
11587
+ if (sourceEvent && sourceEvent.should) {
11588
+ if (event.cancelable) {
11589
+ event.preventDefault();
11590
+ }
11591
+ return;
11592
+ }
11593
+ // outside or shard event
11594
+ if (!sourceEvent) {
11595
+ var shardNodes = (lastProps.current.shards || [])
11596
+ .map(extractRef)
11597
+ .filter(Boolean)
11598
+ .filter(function (node) { return node.contains(event.target); });
11599
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
11600
+ if (shouldStop) {
11601
+ if (event.cancelable) {
11602
+ event.preventDefault();
11603
+ }
11604
+ }
11605
+ }
11606
+ }, []);
11607
+ var shouldCancel = React.useCallback(function (name, delta, target, should) {
11608
+ var event = { name: name, delta: delta, target: target, should: should, shadowParent: getOutermostShadowParent(target) };
11609
+ shouldPreventQueue.current.push(event);
11610
+ setTimeout(function () {
11611
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
11612
+ }, 1);
11613
+ }, []);
11614
+ var scrollTouchStart = React.useCallback(function (event) {
11615
+ touchStartRef.current = getTouchXY(event);
11616
+ activeAxis.current = undefined;
11617
+ }, []);
11618
+ var scrollWheel = React.useCallback(function (event) {
11619
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
11620
+ }, []);
11621
+ var scrollTouchMove = React.useCallback(function (event) {
11622
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
11623
+ }, []);
11624
+ React.useEffect(function () {
11625
+ lockStack.push(Style);
11626
+ props.setCallbacks({
11627
+ onScrollCapture: scrollWheel,
11628
+ onWheelCapture: scrollWheel,
11629
+ onTouchMoveCapture: scrollTouchMove,
11630
+ });
11631
+ document.addEventListener('wheel', shouldPrevent, nonPassive);
11632
+ document.addEventListener('touchmove', shouldPrevent, nonPassive);
11633
+ document.addEventListener('touchstart', scrollTouchStart, nonPassive);
11634
+ return function () {
11635
+ lockStack = lockStack.filter(function (inst) { return inst !== Style; });
11636
+ document.removeEventListener('wheel', shouldPrevent, nonPassive);
11637
+ document.removeEventListener('touchmove', shouldPrevent, nonPassive);
11638
+ document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
11639
+ };
11640
+ }, []);
11641
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
11642
+ return (React.createElement(React.Fragment, null,
11643
+ inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
11644
+ removeScrollBar ? React.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null));
11645
+ }
11646
+ function getOutermostShadowParent(node) {
11647
+ var shadowParent = null;
11648
+ while (node !== null) {
11649
+ if (node instanceof ShadowRoot) {
11650
+ shadowParent = node.host;
11651
+ node = node.host;
11652
+ }
11653
+ node = node.parentNode;
11654
+ }
11655
+ return shadowParent;
11656
+ }
11657
+
11658
+ const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
11659
+
11660
+ var ReactRemoveScroll = React.forwardRef(function (props, ref) { return (React.createElement(RemoveScroll, __assign({}, props, { ref: ref, sideCar: SideCar }))); });
11661
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
11662
+
11663
+ var POPOVER_NAME = "Popover";
11664
+ var [createPopoverContext] = createContextScope(POPOVER_NAME, [
11665
+ createPopperScope
11666
+ ]);
11667
+ var usePopperScope = createPopperScope();
11668
+ var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
11669
+ var Popover$1 = (props) => {
11670
+ const {
11671
+ __scopePopover,
11672
+ children,
11673
+ open: openProp,
11674
+ defaultOpen,
11675
+ onOpenChange,
11676
+ modal = false
11677
+ } = props;
11678
+ const popperScope = usePopperScope(__scopePopover);
11679
+ const triggerRef = React.useRef(null);
11680
+ const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
11681
+ const [open, setOpen] = useControllableState({
11682
+ prop: openProp,
11683
+ defaultProp: defaultOpen ?? false,
11684
+ onChange: onOpenChange,
11685
+ caller: POPOVER_NAME
11686
+ });
11687
+ return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
11688
+ PopoverProvider,
11689
+ {
11690
+ scope: __scopePopover,
11691
+ contentId: useId(),
11692
+ triggerRef,
11693
+ open,
11694
+ onOpenChange: setOpen,
11695
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
11696
+ hasCustomAnchor,
11697
+ onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
11698
+ onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
11699
+ modal,
11700
+ children
11701
+ }
11702
+ ) });
11703
+ };
11704
+ Popover$1.displayName = POPOVER_NAME;
11705
+ var ANCHOR_NAME = "PopoverAnchor";
11706
+ var PopoverAnchor = React.forwardRef(
11707
+ (props, forwardedRef) => {
11708
+ const { __scopePopover, ...anchorProps } = props;
11709
+ const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
11710
+ const popperScope = usePopperScope(__scopePopover);
11711
+ const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
11712
+ React.useEffect(() => {
11713
+ onCustomAnchorAdd();
11714
+ return () => onCustomAnchorRemove();
11715
+ }, [onCustomAnchorAdd, onCustomAnchorRemove]);
11716
+ return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
11717
+ }
11718
+ );
11719
+ PopoverAnchor.displayName = ANCHOR_NAME;
11720
+ var TRIGGER_NAME = "PopoverTrigger";
11721
+ var PopoverTrigger$1 = React.forwardRef(
11722
+ (props, forwardedRef) => {
11723
+ const { __scopePopover, ...triggerProps } = props;
11724
+ const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
11725
+ const popperScope = usePopperScope(__scopePopover);
11726
+ const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
11727
+ const trigger = /* @__PURE__ */ jsx(
11728
+ Primitive.button,
11729
+ {
11730
+ type: "button",
11731
+ "aria-haspopup": "dialog",
11732
+ "aria-expanded": context.open,
11733
+ "aria-controls": context.contentId,
11734
+ "data-state": getState(context.open),
11735
+ ...triggerProps,
11736
+ ref: composedTriggerRef,
11737
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
11738
+ }
11739
+ );
11740
+ return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: trigger });
11741
+ }
11742
+ );
11743
+ PopoverTrigger$1.displayName = TRIGGER_NAME;
11744
+ var PORTAL_NAME = "PopoverPortal";
11745
+ var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
11746
+ forceMount: void 0
11747
+ });
11748
+ var PopoverPortal = (props) => {
11749
+ const { __scopePopover, forceMount, children, container } = props;
11750
+ const context = usePopoverContext(PORTAL_NAME, __scopePopover);
11751
+ return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
11752
+ };
11753
+ PopoverPortal.displayName = PORTAL_NAME;
11754
+ var CONTENT_NAME = "PopoverContent";
11755
+ var PopoverContent$1 = React.forwardRef(
11756
+ (props, forwardedRef) => {
11757
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
11758
+ const { forceMount = portalContext.forceMount, ...contentProps } = props;
11759
+ const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
11760
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
11761
+ }
11762
+ );
11763
+ PopoverContent$1.displayName = CONTENT_NAME;
11764
+ var Slot = createSlot("PopoverContent.RemoveScroll");
11765
+ var PopoverContentModal = React.forwardRef(
11766
+ (props, forwardedRef) => {
11767
+ const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
11768
+ const contentRef = React.useRef(null);
11769
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
11770
+ const isRightClickOutsideRef = React.useRef(false);
11771
+ React.useEffect(() => {
11772
+ const content = contentRef.current;
11773
+ if (content) return hideOthers(content);
11774
+ }, []);
11775
+ return /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
11776
+ PopoverContentImpl,
11777
+ {
11778
+ ...props,
11779
+ ref: composedRefs,
11780
+ trapFocus: context.open,
11781
+ disableOutsidePointerEvents: true,
11782
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
11783
+ event.preventDefault();
11784
+ if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
11785
+ }),
11786
+ onPointerDownOutside: composeEventHandlers(
11787
+ props.onPointerDownOutside,
11788
+ (event) => {
11789
+ const originalEvent = event.detail.originalEvent;
11790
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
11791
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
11792
+ isRightClickOutsideRef.current = isRightClick;
11793
+ },
11794
+ { checkForDefaultPrevented: false }
11795
+ ),
11796
+ onFocusOutside: composeEventHandlers(
11797
+ props.onFocusOutside,
11798
+ (event) => event.preventDefault(),
11799
+ { checkForDefaultPrevented: false }
11800
+ )
11801
+ }
11802
+ ) });
11803
+ }
11804
+ );
11805
+ var PopoverContentNonModal = React.forwardRef(
11806
+ (props, forwardedRef) => {
11807
+ const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
11808
+ const hasInteractedOutsideRef = React.useRef(false);
11809
+ const hasPointerDownOutsideRef = React.useRef(false);
11810
+ return /* @__PURE__ */ jsx(
11811
+ PopoverContentImpl,
11812
+ {
11813
+ ...props,
11814
+ ref: forwardedRef,
11815
+ trapFocus: false,
11816
+ disableOutsidePointerEvents: false,
11817
+ onCloseAutoFocus: (event) => {
11818
+ props.onCloseAutoFocus?.(event);
11819
+ if (!event.defaultPrevented) {
11820
+ if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
11821
+ event.preventDefault();
11822
+ }
11823
+ hasInteractedOutsideRef.current = false;
11824
+ hasPointerDownOutsideRef.current = false;
11825
+ },
11826
+ onInteractOutside: (event) => {
11827
+ props.onInteractOutside?.(event);
11828
+ if (!event.defaultPrevented) {
11829
+ hasInteractedOutsideRef.current = true;
11830
+ if (event.detail.originalEvent.type === "pointerdown") {
11831
+ hasPointerDownOutsideRef.current = true;
11832
+ }
11833
+ }
11834
+ const target = event.target;
11835
+ const targetIsTrigger = context.triggerRef.current?.contains(target);
11836
+ if (targetIsTrigger) event.preventDefault();
11837
+ if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
11838
+ event.preventDefault();
11839
+ }
11840
+ }
11841
+ }
11842
+ );
11843
+ }
11844
+ );
11845
+ var PopoverContentImpl = React.forwardRef(
11846
+ (props, forwardedRef) => {
11847
+ const {
11848
+ __scopePopover,
11849
+ trapFocus,
11850
+ onOpenAutoFocus,
8034
11851
  onCloseAutoFocus,
8035
11852
  disableOutsidePointerEvents,
8036
11853
  onEscapeKeyDown,
@@ -8122,14 +11939,10 @@ var Trigger = PopoverTrigger$1;
8122
11939
  var Portal = PopoverPortal;
8123
11940
  var Content2 = PopoverContent$1;
8124
11941
 
8125
- function Popover({
8126
- ...props
8127
- }) {
11942
+ function Popover({ ...props }) {
8128
11943
  return /* @__PURE__ */ jsx(Root2, { "data-slot": "popover", ...props });
8129
11944
  }
8130
- function PopoverTrigger({
8131
- ...props
8132
- }) {
11945
+ function PopoverTrigger({ ...props }) {
8133
11946
  return /* @__PURE__ */ jsx(Trigger, { "data-slot": "popover-trigger", ...props });
8134
11947
  }
8135
11948
  function PopoverContent({
@@ -8195,11 +12008,7 @@ const DatePicker = React.forwardRef(
8195
12008
  variant: "outline",
8196
12009
  id,
8197
12010
  "aria-invalid": !!error,
8198
- className: cn(
8199
- "w-48 justify-between font-normal",
8200
- !displayDate && "text-muted-foreground",
8201
- className
8202
- ),
12011
+ className: cn("w-48 justify-between font-normal", !displayDate && "text-muted-foreground", className),
8203
12012
  ...props,
8204
12013
  children: [
8205
12014
  displayDate ? displayDate.toLocaleDateString() : placeholder,