@sarunyu/system-one 4.9.30 → 4.9.33

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.
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import React__default, { forwardRef, useState, useRef, useEffect, useCallback, useId, useMemo, useLayoutEffect, useContext, createContext } from "react";
4
+ import React__default, { forwardRef, useState, useRef, useEffect, useCallback, useId as useId$1, useMemo, useLayoutEffect, useContext, createContext } from "react";
5
5
  import { clsx } from "clsx";
6
6
  import { twMerge } from "tailwind-merge";
7
7
  import { BellSimple, FunnelSimple, CheckCircle, Warning, XCircle, Info, BookmarkSimpleIcon, BroadcastIcon as BroadcastIcon$1, CalendarBlank, MapPin, Users, Lock, Check, Plus, Circle, Minus, CaretLeft, CaretRight, CaretDoubleLeft, CaretDoubleRight, CaretUp, CaretDown, X, ImageSquare, Gift, MegaphoneSimple, GearSix, MagnifyingGlass, ArrowUp, ArrowDown, ArrowsDownUp, Clock } from "@phosphor-icons/react";
8
8
  import { DayPicker, useDayPicker } from "react-day-picker";
9
- import * as Popover from "@radix-ui/react-popover";
9
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
10
10
  import { Drawer as Drawer$1 } from "vaul";
11
- import { createPortal } from "react-dom";
11
+ import * as ReactDOM from "react-dom";
12
+ import ReactDOM__default, { createPortal } from "react-dom";
12
13
  function cn(...inputs) {
13
14
  return twMerge(clsx(inputs));
14
15
  }
@@ -55,7 +56,7 @@ const heightClass = {
55
56
  xl: "h-10"
56
57
  // 40px
57
58
  };
58
- function getPaddingClasses(size, hasLeft, hasRight) {
59
+ function getPaddingClasses(size2, hasLeft, hasRight) {
59
60
  const pxMap = {
60
61
  xs: { l: "pl-1.5", r: "pr-1.5" },
61
62
  // 6px
@@ -76,8 +77,8 @@ function getPaddingClasses(size, hasLeft, hasRight) {
76
77
  xl: { l: "pl-3", r: "pr-3" }
77
78
  };
78
79
  return [
79
- hasLeft ? reducedMap[size].l : pxMap[size].l,
80
- hasRight ? reducedMap[size].r : pxMap[size].r
80
+ hasLeft ? reducedMap[size2].l : pxMap[size2].l,
81
+ hasRight ? reducedMap[size2].r : pxMap[size2].r
81
82
  ];
82
83
  }
83
84
  const iconSizeSpec = {
@@ -104,7 +105,7 @@ function getVariantClasses(variant, isDisabled) {
104
105
  return "bg-primary-action text-on-primary-action border border-transparent hover:bg-primary-action-hover active:bg-primary-action-active";
105
106
  }
106
107
  const Button = forwardRef(function Button2({
107
- size = "md",
108
+ size: size2 = "md",
108
109
  variant = "primary",
109
110
  children,
110
111
  leftIcon,
@@ -119,7 +120,7 @@ const Button = forwardRef(function Button2({
119
120
  }, ref) {
120
121
  const isDisabled = variant === "disabled" || !!disabled;
121
122
  const isGhost = variant === "outline-black" || variant === "plain-black";
122
- const isIconOnly = size.startsWith("icon-");
123
+ const isIconOnly = size2.startsWith("icon-");
123
124
  const [ghostPressed, setGhostPressed] = useState(false);
124
125
  const needsGhostPress = isGhost && isIconOnly && !isDisabled;
125
126
  const ghostPressStyle = needsGhostPress && ghostPressed ? { backgroundColor: "var(--disabled-bg)", color: "var(--disabled)" } : void 0;
@@ -139,7 +140,7 @@ const Button = forwardRef(function Button2({
139
140
  const cursorClass = isDisabled ? "cursor-not-allowed" : "cursor-pointer";
140
141
  const baseClasses = "inline-flex items-center justify-center font-medium whitespace-nowrap transition-colors duration-150 select-none";
141
142
  if (isIconOnly) {
142
- const spec = iconSizeSpec[size];
143
+ const spec = iconSizeSpec[size2];
143
144
  return /* @__PURE__ */ jsx(
144
145
  "button",
145
146
  {
@@ -172,7 +173,7 @@ const Button = forwardRef(function Button2({
172
173
  }
173
174
  );
174
175
  }
175
- const labelSize = size;
176
+ const labelSize = size2;
176
177
  const hasLeft = Boolean(leftIcon);
177
178
  const hasRight = Boolean(rightIcon);
178
179
  const paddingParts = getPaddingClasses(labelSize, hasLeft, hasRight);
@@ -226,13 +227,13 @@ const Button = forwardRef(function Button2({
226
227
  );
227
228
  });
228
229
  Button.displayName = "Button";
229
- function formatCount(count, maxCount) {
230
- if (count > maxCount) return `${maxCount}+`;
231
- return String(count);
230
+ function formatCount(count2, maxCount) {
231
+ if (count2 > maxCount) return `${maxCount}+`;
232
+ return String(count2);
232
233
  }
233
234
  function Badge({
234
235
  variant = "button",
235
- count = 0,
236
+ count: count2 = 0,
236
237
  maxCount = 99,
237
238
  label = "Filter",
238
239
  iconOnly = false,
@@ -241,7 +242,7 @@ function Badge({
241
242
  className,
242
243
  ...props
243
244
  }) {
244
- const hasCount = count > 0;
245
+ const hasCount = count2 > 0;
245
246
  const resolvedNotificationState = notificationState ?? (hasCount ? "noti" : "default");
246
247
  const notificationIsFilled = resolvedNotificationState === "active" || resolvedNotificationState === "noti";
247
248
  const showNotificationDot = resolvedNotificationState === "noti" && hasCount;
@@ -285,7 +286,7 @@ function Badge({
285
286
  "absolute flex h-[14px] min-h-[14px] min-w-[14px] items-center justify-center rounded-[60px]",
286
287
  variant === "notification" ? "-right-0.5 -top-0.5 bg-destructive px-[2.5px]" : "-right-1 -top-[7px] h-4 min-w-4 bg-primary-action"
287
288
  ),
288
- children: /* @__PURE__ */ jsx("p", { className: "text-center text-xs leading-4 font-normal text-text-default-white", children: formatCount(count, maxCount) })
289
+ children: /* @__PURE__ */ jsx("p", { className: "text-center text-xs leading-4 font-normal text-text-default-white", children: formatCount(count2, maxCount) })
289
290
  }
290
291
  )
291
292
  ] });
@@ -399,7 +400,7 @@ function BannerMedia({ src, alt }) {
399
400
  }
400
401
  function DurationBadge({
401
402
  duration,
402
- size
403
+ size: size2
403
404
  }) {
404
405
  const isUpcoming = duration === "upcoming";
405
406
  return /* @__PURE__ */ jsxs(
@@ -407,7 +408,7 @@ function DurationBadge({
407
408
  {
408
409
  className: cn(
409
410
  "absolute flex items-center gap-[4px] rounded-[4px] bg-black/60",
410
- size === "lg" ? "bottom-[6px] right-[6px] h-[20px] px-[4px]" : "bottom-[4px] right-[4px] h-[16px] px-[2px]"
411
+ size2 === "lg" ? "bottom-[6px] right-[6px] h-[20px] px-[4px]" : "bottom-[4px] right-[4px] h-[16px] px-[2px]"
411
412
  ),
412
413
  children: [
413
414
  isUpcoming && /* @__PURE__ */ jsx(BroadcastIcon$1, { size: 14, className: "text-white" }),
@@ -416,7 +417,7 @@ function DurationBadge({
416
417
  {
417
418
  className: cn(
418
419
  "whitespace-nowrap font-normal text-white",
419
- size === "lg" ? "text-[14px] leading-[20px]" : "text-[12px] leading-[16px]"
420
+ size2 === "lg" ? "text-[14px] leading-[20px]" : "text-[12px] leading-[16px]"
420
421
  ),
421
422
  children: isUpcoming ? "Up Coming" : duration
422
423
  }
@@ -456,15 +457,15 @@ function LockBadgeChip({ flush = false }) {
456
457
  function LockBadge({
457
458
  align = "left",
458
459
  flush = false,
459
- size = "desktop"
460
+ size: size2 = "desktop"
460
461
  }) {
461
462
  return /* @__PURE__ */ jsx(
462
463
  "div",
463
464
  {
464
465
  className: cn(
465
466
  "absolute z-10",
466
- flush ? "top-0" : size === "mobile" ? "top-[6px]" : "top-[8px]",
467
- align === "left" ? flush ? "left-0" : size === "mobile" ? "left-[6px]" : "left-[8px]" : flush ? "right-0" : size === "mobile" ? "right-[6px]" : "right-[8px]"
467
+ flush ? "top-0" : size2 === "mobile" ? "top-[6px]" : "top-[8px]",
468
+ align === "left" ? flush ? "left-0" : size2 === "mobile" ? "left-[6px]" : "left-[8px]" : flush ? "right-0" : size2 === "mobile" ? "right-[6px]" : "right-[8px]"
468
469
  ),
469
470
  children: /* @__PURE__ */ jsx(LockBadgeChip, { flush })
470
471
  }
@@ -503,7 +504,7 @@ const Card = forwardRef(function Card2({
503
504
  location,
504
505
  showLocation = true,
505
506
  showAudience = true,
506
- count = "200/200",
507
+ count: count2 = "200/200",
507
508
  tagStatus = "not-registered",
508
509
  // news
509
510
  category,
@@ -516,11 +517,11 @@ const Card = forwardRef(function Card2({
516
517
  duration
517
518
  }, ref) {
518
519
  const isMobile = useIsMobile();
519
- const size = sizeProp ?? (isMobile ? "mobile" : "desktop");
520
+ const size2 = sizeProp ?? (isMobile ? "mobile" : "desktop");
520
521
  const bannerSrc = image ?? "";
521
522
  if (variant === "default") {
522
- const shellPadding = size === "desktop" ? "p-4" : "p-3";
523
- const shellRadius = size === "mobile" ? "rounded-[6px]" : "rounded-[8px]";
523
+ const shellPadding = size2 === "desktop" ? "p-4" : "p-3";
524
+ const shellRadius = size2 === "mobile" ? "rounded-[6px]" : "rounded-[8px]";
524
525
  return /* @__PURE__ */ jsx(
525
526
  "div",
526
527
  {
@@ -536,7 +537,7 @@ const Card = forwardRef(function Card2({
536
537
  );
537
538
  }
538
539
  if (variant === "social") {
539
- const isDesktop = size === "desktop";
540
+ const isDesktop = size2 === "desktop";
540
541
  const cardWidth = isDesktop ? "w-[587px]" : "w-[343px]";
541
542
  const cardPadding = isDesktop ? "p-4" : "p-3";
542
543
  const cardGap = isDesktop ? "gap-3" : "gap-2";
@@ -639,7 +640,7 @@ const Card = forwardRef(function Card2({
639
640
  );
640
641
  }
641
642
  if (variant === "live") {
642
- const isDesktop = size === "desktop";
643
+ const isDesktop = size2 === "desktop";
643
644
  const cardWidth = isDesktop ? "w-[704px]" : "w-[343px]";
644
645
  const imgWidth = isDesktop ? "w-[212px]" : "w-[149px]";
645
646
  const imgHeight = isDesktop ? "h-[119px]" : "h-[84px]";
@@ -715,7 +716,7 @@ const Card = forwardRef(function Card2({
715
716
  }
716
717
  );
717
718
  }
718
- if (variant === "news" && size === "desktop") {
719
+ if (variant === "news" && size2 === "desktop") {
719
720
  return /* @__PURE__ */ jsxs(
720
721
  "div",
721
722
  {
@@ -745,7 +746,7 @@ const Card = forwardRef(function Card2({
745
746
  }
746
747
  );
747
748
  }
748
- if (variant === "news" && size === "mobile") {
749
+ if (variant === "news" && size2 === "mobile") {
749
750
  return /* @__PURE__ */ jsxs(
750
751
  "div",
751
752
  {
@@ -775,9 +776,9 @@ const Card = forwardRef(function Card2({
775
776
  }
776
777
  );
777
778
  }
778
- const widthClass = size === "desktop" ? "w-[308px]" : size === "tablet" ? "w-[224px]" : "w-[163px]";
779
- const padding = size === "desktop" ? "p-4" : size === "tablet" ? "p-3" : "p-2.5";
780
- const bannerClass = size === "desktop" ? "h-[173px]" : "aspect-video w-full";
779
+ const widthClass = size2 === "desktop" ? "w-[308px]" : size2 === "tablet" ? "w-[224px]" : "w-[163px]";
780
+ const padding = size2 === "desktop" ? "p-4" : size2 === "tablet" ? "p-3" : "p-2.5";
781
+ const bannerClass = size2 === "desktop" ? "h-[173px]" : "aspect-video w-full";
781
782
  return /* @__PURE__ */ jsxs(
782
783
  "div",
783
784
  {
@@ -800,7 +801,7 @@ const Card = forwardRef(function Card2({
800
801
  alt: variant === "news" ? "news banner" : "event banner"
801
802
  }
802
803
  ),
803
- locked && /* @__PURE__ */ jsx(LockBadge, { size })
804
+ locked && /* @__PURE__ */ jsx(LockBadge, { size: size2 })
804
805
  ]
805
806
  }
806
807
  ),
@@ -818,7 +819,7 @@ const Card = forwardRef(function Card2({
818
819
  ) : /* @__PURE__ */ jsx(
819
820
  EventContent,
820
821
  {
821
- size,
822
+ size: size2,
822
823
  padding,
823
824
  title: title ?? "Lorem ipsum dolor sit amet consectetur. Lectus viverraasdasd",
824
825
  date: date ?? "23 มิ.ย. 2567",
@@ -826,7 +827,7 @@ const Card = forwardRef(function Card2({
826
827
  location: location ?? "ณ หอประชุมศาสตราจารย์สังเวียน อินทรวิชัย ชั้น 7 ตลาดหลักทรัพย์แห่งประเทศไทย",
827
828
  showLocation,
828
829
  showAudience,
829
- count,
830
+ count: count2,
830
831
  tagStatus
831
832
  }
832
833
  )
@@ -836,7 +837,7 @@ const Card = forwardRef(function Card2({
836
837
  });
837
838
  Card.displayName = "Card";
838
839
  function EventContent({
839
- size,
840
+ size: size2,
840
841
  padding,
841
842
  title,
842
843
  date,
@@ -844,10 +845,10 @@ function EventContent({
844
845
  location,
845
846
  showLocation,
846
847
  showAudience,
847
- count,
848
+ count: count2,
848
849
  tagStatus
849
850
  }) {
850
- const titleGap = size === "desktop" ? "gap-1.5" : "gap-1";
851
+ const titleGap = size2 === "desktop" ? "gap-1.5" : "gap-1";
851
852
  const tag = tagConfig[tagStatus];
852
853
  return /* @__PURE__ */ jsx("div", { className: cn("w-full shrink-0 bg-card", padding), children: /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col items-start", titleGap), children: [
853
854
  /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-start gap-1", children: [
@@ -874,7 +875,7 @@ function EventContent({
874
875
  showAudience && /* @__PURE__ */ jsxs("div", { className: "flex h-[22px] w-full items-center gap-1", children: [
875
876
  /* @__PURE__ */ jsx(Users, { size: 16, weight: "regular", color: "var(--subtle-text)" }),
876
877
  /* @__PURE__ */ jsx("p", { className: "shrink-0 whitespace-nowrap text-xs leading-4 text-subtle-text", children: "ผู้เข้าร่วม" }),
877
- /* @__PURE__ */ jsx("p", { className: "shrink-0 whitespace-nowrap text-xs leading-4 text-primary-action", children: count })
878
+ /* @__PURE__ */ jsx("p", { className: "shrink-0 whitespace-nowrap text-xs leading-4 text-primary-action", children: count2 })
878
879
  ] })
879
880
  ] }),
880
881
  /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-start", children: /* @__PURE__ */ jsxs(
@@ -1181,11 +1182,11 @@ const Toggle = forwardRef(function Toggle2({
1181
1182
  ariaLabel,
1182
1183
  className
1183
1184
  }, ref) {
1184
- const generatedId = useId();
1185
+ const generatedId = useId$1();
1185
1186
  const switchId = idProp ?? generatedId;
1186
1187
  const hasText = label !== void 0 || description !== void 0;
1187
1188
  const hasDescription = description !== void 0;
1188
- const size = sizeProp ?? (hasText ? "sm" : "md");
1189
+ const size2 = sizeProp ?? (hasText ? "sm" : "md");
1189
1190
  const trackBg = disabled ? checked ? "bg-switch-on-disabled" : "bg-switch-background" : checked ? "bg-primary-action" : "bg-switch-background";
1190
1191
  const thumbBg = disabled && !checked ? "bg-switch-background" : "bg-[var(--fill-white-1000)]";
1191
1192
  const switchEl = /* @__PURE__ */ jsx(
@@ -1203,7 +1204,7 @@ const Toggle = forwardRef(function Toggle2({
1203
1204
  "relative shrink-0 rounded-full p-0 transition-colors duration-200 ease-out",
1204
1205
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
1205
1206
  disabled ? "cursor-not-allowed" : "cursor-pointer",
1206
- trackClass[size],
1207
+ trackClass[size2],
1207
1208
  trackBg
1208
1209
  ),
1209
1210
  children: /* @__PURE__ */ jsx(
@@ -1213,9 +1214,9 @@ const Toggle = forwardRef(function Toggle2({
1213
1214
  className: cn(
1214
1215
  "pointer-events-none absolute rounded-full transition-transform duration-200 ease-out",
1215
1216
  "shadow-[var(--toggle-knob-shadow)]",
1216
- thumbClass[size],
1217
+ thumbClass[size2],
1217
1218
  thumbBg,
1218
- checked && thumbTranslate[size]
1219
+ checked && thumbTranslate[size2]
1219
1220
  )
1220
1221
  }
1221
1222
  )
@@ -1383,13 +1384,13 @@ const multiplePaddingBySize = {
1383
1384
  const Chip = forwardRef(function Chip2({
1384
1385
  label = "Chips Text",
1385
1386
  type = "single",
1386
- size = "large",
1387
+ size: size2 = "large",
1387
1388
  selected = false,
1388
1389
  disabled = false,
1389
1390
  onClick,
1390
1391
  className
1391
1392
  }, ref) {
1392
- const s = sizeStyles$1[size];
1393
+ const s = sizeStyles$1[size2];
1393
1394
  const isMultiple = type === "multiple";
1394
1395
  const state = disabled ? selected ? "selected-disabled" : "disabled" : selected ? "selected" : "default";
1395
1396
  const containerClass = state === "selected" ? "bg-primary-action border border-primary-action" : state === "selected-disabled" ? "bg-selected-light-bg border border-transparent" : state === "disabled" ? "bg-disabled-bg border border-transparent" : "bg-background border border-border";
@@ -1407,7 +1408,7 @@ const Chip = forwardRef(function Chip2({
1407
1408
  className: cn(
1408
1409
  "inline-flex items-center justify-center rounded-full whitespace-nowrap border transition-colors",
1409
1410
  s.container,
1410
- isMultiple && multiplePaddingBySize[size],
1411
+ isMultiple && multiplePaddingBySize[size2],
1411
1412
  containerClass,
1412
1413
  disabled ? "cursor-not-allowed" : "cursor-pointer",
1413
1414
  className
@@ -1420,6 +1421,51 @@ const Chip = forwardRef(function Chip2({
1420
1421
  );
1421
1422
  });
1422
1423
  Chip.displayName = "Chip";
1424
+ const PopoverContent = forwardRef(({ className, sideOffset, children, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1425
+ PopoverPrimitive.Content,
1426
+ {
1427
+ ref,
1428
+ sideOffset,
1429
+ className: cn(
1430
+ "z-50 rounded-lg border border-border bg-popover p-3 outline-none shadow-popover text-popover-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
1431
+ className
1432
+ ),
1433
+ onOpenAutoFocus: (e) => e.preventDefault(),
1434
+ ...props,
1435
+ children
1436
+ }
1437
+ ) }));
1438
+ PopoverContent.displayName = "PopoverContent";
1439
+ function Popover({
1440
+ children,
1441
+ content,
1442
+ side = "bottom",
1443
+ align = "start",
1444
+ alignOffset,
1445
+ avoidCollisions,
1446
+ sideOffset = 4,
1447
+ open,
1448
+ onOpenChange,
1449
+ className,
1450
+ contentStyle
1451
+ }) {
1452
+ return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, { open, onOpenChange, children: [
1453
+ /* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { asChild: true, children }),
1454
+ /* @__PURE__ */ jsx(
1455
+ PopoverContent,
1456
+ {
1457
+ side,
1458
+ align,
1459
+ alignOffset,
1460
+ avoidCollisions,
1461
+ sideOffset,
1462
+ className,
1463
+ style: contentStyle,
1464
+ children: content
1465
+ }
1466
+ )
1467
+ ] });
1468
+ }
1423
1469
  function Drawer({
1424
1470
  ...props
1425
1471
  }) {
@@ -2612,36 +2658,23 @@ const DateInput = forwardRef(
2612
2658
  showHeader: false,
2613
2659
  rightSide: "none",
2614
2660
  contentClassName: "pt-0",
2615
- children: /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full", children: [
2661
+ children: /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: [
2616
2662
  /* @__PURE__ */ jsx(DrawerRangeCtx.Provider, { value: mode === "range", children: calendarContent }),
2617
2663
  actionButtons
2618
2664
  ] })
2619
2665
  }
2620
- ) : /* @__PURE__ */ jsxs(
2621
- Popover.Root,
2666
+ ) : /* @__PURE__ */ jsx(
2667
+ Popover,
2622
2668
  {
2623
2669
  open,
2624
2670
  onOpenChange: handleOpenChange,
2625
- children: [
2626
- /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: triggerButton }),
2627
- /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsxs(
2628
- Popover.Content,
2629
- {
2630
- align: "start",
2631
- sideOffset: 4,
2632
- className: "z-50 rounded-[8px] bg-popover p-3 outline-none text-popover-foreground",
2633
- style: {
2634
- boxShadow: "var(--elevation-popover)",
2635
- border: "1px solid var(--border-default)"
2636
- },
2637
- onOpenAutoFocus: (e) => e.preventDefault(),
2638
- children: [
2639
- calendarContent,
2640
- actionButtons
2641
- ]
2642
- }
2643
- ) })
2644
- ]
2671
+ align: "start",
2672
+ sideOffset: 4,
2673
+ content: /* @__PURE__ */ jsxs(Fragment, { children: [
2674
+ calendarContent,
2675
+ actionButtons
2676
+ ] }),
2677
+ children: triggerButton
2645
2678
  }
2646
2679
  ),
2647
2680
  belowMessage
@@ -2933,7 +2966,7 @@ const Dropdown = forwardRef(
2933
2966
  ref: menuRef,
2934
2967
  className: cn(
2935
2968
  "bg-popover rounded-lg overflow-clip p-2 flex flex-col items-start text-popover-foreground",
2936
- filteredOptions.length > 10 && "overflow-y-auto"
2969
+ filteredOptions.length > 10 && "overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
2937
2970
  ),
2938
2971
  style: {
2939
2972
  ...menuStyle,
@@ -3050,7 +3083,7 @@ function StaticTag({
3050
3083
  );
3051
3084
  }
3052
3085
  function OverflowBadge({
3053
- count,
3086
+ count: count2,
3054
3087
  disabled
3055
3088
  }) {
3056
3089
  const bg = disabled ? "bg-surface-chip-disabled" : "bg-selected-bg";
@@ -3069,7 +3102,7 @@ function OverflowBadge({
3069
3102
  style: { color: textColor },
3070
3103
  children: [
3071
3104
  "+",
3072
- count
3105
+ count2
3073
3106
  ]
3074
3107
  }
3075
3108
  )
@@ -3100,36 +3133,36 @@ function useChipLayout(selectedOptions, measureRef, containerRef) {
3100
3133
  const RIGHT_SECTION_WIDTH = 60;
3101
3134
  const budget = containerWidth * 0.72 - RIGHT_SECTION_WIDTH;
3102
3135
  let used = 0;
3103
- let count = 0;
3136
+ let count2 = 0;
3104
3137
  for (let i = 0; i < tagEls.length; i++) {
3105
3138
  const w = tagEls[i].offsetWidth;
3106
- const gap = count > 0 ? TAG_GAP : 0;
3139
+ const gap = count2 > 0 ? TAG_GAP : 0;
3107
3140
  const nextUsed = used + gap + w;
3108
3141
  if (nextUsed <= budget) {
3109
3142
  used = nextUsed;
3110
- count++;
3143
+ count2++;
3111
3144
  } else {
3112
- count++;
3145
+ count2++;
3113
3146
  break;
3114
3147
  }
3115
3148
  }
3116
- count = Math.max(1, count);
3117
- const overflowCount = total - count;
3149
+ count2 = Math.max(1, count2);
3150
+ const overflowCount = total - count2;
3118
3151
  const isFullWidth = used >= budget * 0.98;
3119
3152
  let lastTagMaxWidth;
3120
3153
  if (overflowCount > 0 || isFullWidth) {
3121
- const prevTagsWidth = tagEls.slice(0, count - 1).reduce(
3154
+ const prevTagsWidth = tagEls.slice(0, count2 - 1).reduce(
3122
3155
  (sum, el, i) => sum + el.offsetWidth + (i > 0 ? TAG_GAP : 0),
3123
3156
  0
3124
3157
  );
3125
- const gapBeforeLast = count > 1 ? TAG_GAP : 0;
3158
+ const gapBeforeLast = count2 > 1 ? TAG_GAP : 0;
3126
3159
  const remaining = budget - prevTagsWidth - gapBeforeLast;
3127
- ((_b2 = tagEls[count - 1]) == null ? void 0 : _b2.offsetWidth) ?? 0;
3160
+ ((_b2 = tagEls[count2 - 1]) == null ? void 0 : _b2.offsetWidth) ?? 0;
3128
3161
  if (remaining > 0) {
3129
3162
  lastTagMaxWidth = remaining;
3130
3163
  }
3131
3164
  }
3132
- setLayout({ visibleCount: count, lastTagMaxWidth });
3165
+ setLayout({ visibleCount: count2, lastTagMaxWidth });
3133
3166
  };
3134
3167
  calculate();
3135
3168
  (_b = (_a = document.fonts) == null ? void 0 : _a.ready) == null ? void 0 : _b.then(calculate);
@@ -3515,7 +3548,7 @@ const DropdownMultiple = forwardRef(
3515
3548
  {
3516
3549
  className: cn(
3517
3550
  "w-full flex flex-col",
3518
- filteredOptions.length > 10 && "overflow-y-auto"
3551
+ filteredOptions.length > 10 && "overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
3519
3552
  ),
3520
3553
  style: filteredOptions.length > 10 ? { maxHeight: 10 * 48 } : void 0,
3521
3554
  children: filteredOptions.length > 0 ? filteredOptions.map((opt) => {
@@ -4100,45 +4133,43 @@ const Notification = forwardRef(
4100
4133
  });
4101
4134
  onItemClick == null ? void 0 : onItemClick(item);
4102
4135
  };
4103
- return /* @__PURE__ */ jsxs(Popover.Root, { open: resolvedOpen, onOpenChange: handleOpenChange, children: [
4104
- /* @__PURE__ */ jsx("div", { ref, className: cn("inline-flex", className), children: /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { ref: triggerRef, className: "relative", children: /* @__PURE__ */ jsx(
4105
- Badge,
4106
- {
4107
- variant: "notification",
4108
- count: displayCount,
4109
- maxCount: 99,
4110
- notificationState: displayCount > 0 ? "noti" : resolvedOpen ? "active" : "default",
4111
- "aria-label": "Open notifications"
4112
- }
4113
- ) }) }) }),
4114
- /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
4115
- Popover.Content,
4116
- {
4117
- align: mobileAlign ? "start" : "end",
4118
- alignOffset: (mobileAlign == null ? void 0 : mobileAlign.alignOffset) ?? 0,
4119
- avoidCollisions: !mobileAlign,
4120
- sideOffset: 10,
4121
- className: cn(
4122
- "z-50 overflow-hidden rounded-lg border border-border bg-background shadow-lg",
4123
- panelClassName
4124
- ),
4125
- style: { width: (mobileAlign == null ? void 0 : mobileAlign.width) ?? panelWidth },
4126
- children: /* @__PURE__ */ jsxs("div", { className: "max-h-[480px] overflow-y-auto", children: [
4127
- !hasItems && /* @__PURE__ */ jsx("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: emptyText }),
4128
- groups.map((group, gi) => /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx("div", { children: group.items.map((item, ii) => /* @__PURE__ */ jsx(
4129
- NotificationRow,
4130
- {
4131
- item,
4132
- onItemClick: handleItemClick,
4133
- hideIndicator: item.id ? clickedItemIds.has(item.id) : false,
4134
- demoteNewBackground: wasDismissed
4135
- },
4136
- item.id ?? `${gi}-${ii}`
4137
- )) }) }, group.label ?? gi))
4138
- ] })
4139
- }
4140
- ) })
4141
- ] });
4136
+ return /* @__PURE__ */ jsx("div", { ref, className: cn("inline-flex", className), children: /* @__PURE__ */ jsx(
4137
+ Popover,
4138
+ {
4139
+ open: resolvedOpen,
4140
+ onOpenChange: handleOpenChange,
4141
+ side: "bottom",
4142
+ align: mobileAlign ? "start" : "end",
4143
+ alignOffset: (mobileAlign == null ? void 0 : mobileAlign.alignOffset) ?? 0,
4144
+ avoidCollisions: !mobileAlign,
4145
+ sideOffset: 10,
4146
+ className: cn("overflow-hidden bg-background shadow-lg p-0", panelClassName),
4147
+ contentStyle: { width: (mobileAlign == null ? void 0 : mobileAlign.width) ?? panelWidth },
4148
+ content: /* @__PURE__ */ jsxs("div", { className: "max-h-[480px] overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: [
4149
+ !hasItems && /* @__PURE__ */ jsx("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: emptyText }),
4150
+ groups.map((group, gi) => /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx("div", { children: group.items.map((item, ii) => /* @__PURE__ */ jsx(
4151
+ NotificationRow,
4152
+ {
4153
+ item,
4154
+ onItemClick: handleItemClick,
4155
+ hideIndicator: item.id ? clickedItemIds.has(item.id) : false,
4156
+ demoteNewBackground: wasDismissed
4157
+ },
4158
+ item.id ?? `${gi}-${ii}`
4159
+ )) }) }, group.label ?? gi))
4160
+ ] }),
4161
+ children: /* @__PURE__ */ jsx("div", { ref: triggerRef, className: "relative", children: /* @__PURE__ */ jsx(
4162
+ Badge,
4163
+ {
4164
+ variant: "notification",
4165
+ count: displayCount,
4166
+ maxCount: 99,
4167
+ notificationState: displayCount > 0 ? "noti" : resolvedOpen ? "active" : "default",
4168
+ "aria-label": "Open notifications"
4169
+ }
4170
+ ) })
4171
+ }
4172
+ ) });
4142
4173
  }
4143
4174
  );
4144
4175
  Notification.displayName = "Notification";
@@ -4410,7 +4441,7 @@ const SearchInput = forwardRef(
4410
4441
  placeholder = "Placeholder",
4411
4442
  value,
4412
4443
  onChange,
4413
- size = "lg",
4444
+ size: size2 = "lg",
4414
4445
  className,
4415
4446
  onClear
4416
4447
  }, ref) {
@@ -4420,9 +4451,9 @@ const SearchInput = forwardRef(
4420
4451
  const controlled = value !== void 0;
4421
4452
  const currentValue = controlled ? value : internalValue;
4422
4453
  const isFilled = currentValue.length > 0;
4423
- const iconSize = size === "lg" ? 24 : 22;
4424
- const minHeight = size === "sm" ? "h-[38px]" : "";
4425
- const padding = size === "sm" ? "px-3.5 py-2" : "px-3.5 py-3";
4454
+ const iconSize = size2 === "lg" ? 24 : 22;
4455
+ const minHeight = size2 === "sm" ? "h-[38px]" : "";
4456
+ const padding = size2 === "sm" ? "px-3.5 py-2" : "px-3.5 py-3";
4426
4457
  const borderInset = focused ? "-1px" : "0px";
4427
4458
  const borderRad = focused ? "9px" : "8px";
4428
4459
  const borderColor = focused ? "var(--primary-action)" : "var(--border-default)";
@@ -4557,7 +4588,7 @@ function DefaultTabIcon({ className }) {
4557
4588
  }
4558
4589
  const Tab = forwardRef(function Tab2({
4559
4590
  title = "Tab",
4560
- size = "md",
4591
+ size: size2 = "md",
4561
4592
  active = false,
4562
4593
  disabled = false,
4563
4594
  onClick,
@@ -4565,7 +4596,7 @@ const Tab = forwardRef(function Tab2({
4565
4596
  icon,
4566
4597
  notification
4567
4598
  }, ref) {
4568
- const s = sizeClasses[size] ?? sizeClasses.md;
4599
+ const s = sizeClasses[size2] ?? sizeClasses.md;
4569
4600
  const hasIcon = Boolean(icon);
4570
4601
  const hasNotification = notification !== void 0 && notification !== null;
4571
4602
  const renderedIcon = icon === true ? /* @__PURE__ */ jsx(DefaultTabIcon, { className: s.iconSize }) : icon;
@@ -4642,12 +4673,12 @@ const Tab = forwardRef(function Tab2({
4642
4673
  });
4643
4674
  Tab.displayName = "Tab";
4644
4675
  const TabGroup = forwardRef(
4645
- function TabGroup2({ items = [], activeId, size = "md", onChange, className }, ref) {
4676
+ function TabGroup2({ items = [], activeId, size: size2 = "md", onChange, className }, ref) {
4646
4677
  return /* @__PURE__ */ jsx("div", { ref, role: "tablist", className: cn("flex", className), children: items.map((item) => /* @__PURE__ */ jsx(
4647
4678
  Tab,
4648
4679
  {
4649
4680
  title: item.title,
4650
- size,
4681
+ size: size2,
4651
4682
  active: item.id === activeId,
4652
4683
  disabled: item.disabled,
4653
4684
  icon: item.icon,
@@ -4729,7 +4760,7 @@ function CloseIcon({ disabled, className }) {
4729
4760
  }
4730
4761
  const Tag = forwardRef(function Tag2({
4731
4762
  text = "Tag",
4732
- size = "large",
4763
+ size: size2 = "large",
4733
4764
  state = "default",
4734
4765
  variant = "gray",
4735
4766
  icon = false,
@@ -4737,7 +4768,7 @@ const Tag = forwardRef(function Tag2({
4737
4768
  className
4738
4769
  }, ref) {
4739
4770
  const isDisabled = state === "disabled";
4740
- const s = sizeStyles[size] ?? sizeStyles.large;
4771
+ const s = sizeStyles[size2] ?? sizeStyles.large;
4741
4772
  const v = variantStyles[variant] ?? variantStyles.gray;
4742
4773
  const bgClass = state === "disabled" ? "bg-disabled-bg" : state === "hover" ? "bg-hover-bg" : v.bg;
4743
4774
  const textClass = isDisabled ? "text-disabled" : v.text;
@@ -4896,7 +4927,7 @@ const Table = forwardRef(function Table2({ className, responsive = true, ...prop
4896
4927
  }
4897
4928
  );
4898
4929
  if (!responsive) return table;
4899
- return /* @__PURE__ */ jsx(TableScrollShadowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { ref: scrollRef, className: "w-full overflow-x-auto", children: table }) });
4930
+ return /* @__PURE__ */ jsx(TableScrollShadowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { ref: scrollRef, className: "w-full overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: table }) });
4900
4931
  });
4901
4932
  const TableRow = forwardRef(
4902
4933
  function TableRow2({
@@ -5481,7 +5512,7 @@ function RangeSlotPicker({
5481
5512
  return /* @__PURE__ */ jsx(
5482
5513
  "div",
5483
5514
  {
5484
- className: "overflow-y-auto [&::-webkit-scrollbar]:hidden",
5515
+ className: "overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
5485
5516
  style: { maxHeight: 320, scrollbarWidth: "none", minWidth: 300 },
5486
5517
  children: /* @__PURE__ */ jsx(
5487
5518
  "div",
@@ -5930,37 +5961,24 @@ const TimeInput = forwardRef(
5930
5961
  showHeader: false,
5931
5962
  rightSide: "none",
5932
5963
  contentClassName: "pt-0",
5933
- children: /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full", children: [
5964
+ children: /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: [
5934
5965
  pickerContent,
5935
5966
  actionButtons
5936
5967
  ] })
5937
5968
  }
5938
- ) : /* @__PURE__ */ jsxs(
5939
- Popover.Root,
5969
+ ) : /* @__PURE__ */ jsx(
5970
+ Popover,
5940
5971
  {
5941
5972
  open,
5942
5973
  onOpenChange: handleOpenChange,
5943
- children: [
5944
- /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: triggerButton }),
5945
- /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsxs(
5946
- Popover.Content,
5947
- {
5948
- align: "start",
5949
- sideOffset: 4,
5950
- className: "z-50 rounded-[8px] bg-popover p-3 outline-none max-w-[340px] text-popover-foreground",
5951
- style: {
5952
- boxShadow: "var(--elevation-popover)",
5953
- border: "1px solid var(--border-default)",
5954
- minWidth: mode === "single" ? 327 : void 0
5955
- },
5956
- onOpenAutoFocus: (e) => e.preventDefault(),
5957
- children: [
5958
- pickerContent,
5959
- actionButtons
5960
- ]
5961
- }
5962
- ) })
5963
- ]
5974
+ align: "start",
5975
+ sideOffset: 4,
5976
+ className: cn("max-w-[340px]", mode === "single" && "min-w-[327px]"),
5977
+ content: /* @__PURE__ */ jsxs(Fragment, { children: [
5978
+ pickerContent,
5979
+ actionButtons
5980
+ ] }),
5981
+ children: triggerButton
5964
5982
  }
5965
5983
  ),
5966
5984
  belowMsg
@@ -5984,14 +6002,14 @@ const SIZE_CONFIG = {
5984
6002
  };
5985
6003
  function Avatar({
5986
6004
  type = "photo",
5987
- size = "m",
6005
+ size: size2 = "m",
5988
6006
  status = false,
5989
6007
  src,
5990
6008
  alt = "",
5991
6009
  initials,
5992
6010
  className
5993
6011
  }) {
5994
- const { container, fontSize, dotSize, dotRing } = SIZE_CONFIG[size];
6012
+ const { container, fontSize, dotSize, dotRing } = SIZE_CONFIG[size2];
5995
6013
  return /* @__PURE__ */ jsxs("div", { className: cn("relative inline-flex shrink-0", container, className), children: [
5996
6014
  type === "photo" && /* @__PURE__ */ jsx(
5997
6015
  "img",
@@ -6067,12 +6085,12 @@ function subtractMask(avatarPx, overlapPx) {
6067
6085
  }
6068
6086
  function AvatarStack({
6069
6087
  items,
6070
- size = "small",
6071
- max = 5,
6088
+ size: size2 = "small",
6089
+ max: max2 = 5,
6072
6090
  className
6073
6091
  }) {
6074
- const { avatarSize, avatarPx, overlapPx } = STACK_CONFIG[size];
6075
- const visible = items.slice(0, max);
6092
+ const { avatarSize, avatarPx, overlapPx } = STACK_CONFIG[size2];
6093
+ const visible = items.slice(0, max2);
6076
6094
  return /* @__PURE__ */ jsx("div", { className: cn("flex shrink-0", className), children: visible.map((item, i) => {
6077
6095
  const isLast = i === visible.length - 1;
6078
6096
  return /* @__PURE__ */ jsx(
@@ -6102,6 +6120,3416 @@ function AvatarStack({
6102
6120
  );
6103
6121
  }) });
6104
6122
  }
6123
+ function BreadcrumbLabel({ item, isLast }) {
6124
+ const base = "shrink-0 text-sm leading-5";
6125
+ if (isLast) {
6126
+ return /* @__PURE__ */ jsx("span", { "aria-current": "page", className: `${base} text-text-brand-secondary`, children: item.label });
6127
+ }
6128
+ if (item.href) {
6129
+ return /* @__PURE__ */ jsx("a", { href: item.href, className: `${base} text-text-default-secondary hover:text-foreground transition-colors`, children: item.label });
6130
+ }
6131
+ return /* @__PURE__ */ jsx("span", { className: `${base} text-text-default-secondary`, children: item.label });
6132
+ }
6133
+ function Breadcrumb({ items, className }) {
6134
+ return /* @__PURE__ */ jsx("nav", { "aria-label": "Breadcrumb", className: cn("flex items-center gap-1", className), children: items.map((item, index2) => {
6135
+ const isLast = index2 === items.length - 1;
6136
+ return /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
6137
+ /* @__PURE__ */ jsx(BreadcrumbLabel, { item, isLast }),
6138
+ !isLast && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "shrink-0 text-sm leading-5 text-text-default-placeholder select-none", children: "/" })
6139
+ ] }, index2);
6140
+ }) });
6141
+ }
6142
+ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
6143
+ return function handleEvent(event) {
6144
+ originalEventHandler == null ? void 0 : originalEventHandler(event);
6145
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) {
6146
+ return ourEventHandler == null ? void 0 : ourEventHandler(event);
6147
+ }
6148
+ };
6149
+ }
6150
+ function setRef(ref, value) {
6151
+ if (typeof ref === "function") {
6152
+ return ref(value);
6153
+ } else if (ref !== null && ref !== void 0) {
6154
+ ref.current = value;
6155
+ }
6156
+ }
6157
+ function composeRefs(...refs) {
6158
+ return (node) => {
6159
+ let hasCleanup = false;
6160
+ const cleanups = refs.map((ref) => {
6161
+ const cleanup = setRef(ref, node);
6162
+ if (!hasCleanup && typeof cleanup == "function") {
6163
+ hasCleanup = true;
6164
+ }
6165
+ return cleanup;
6166
+ });
6167
+ if (hasCleanup) {
6168
+ return () => {
6169
+ for (let i = 0; i < cleanups.length; i++) {
6170
+ const cleanup = cleanups[i];
6171
+ if (typeof cleanup == "function") {
6172
+ cleanup();
6173
+ } else {
6174
+ setRef(refs[i], null);
6175
+ }
6176
+ }
6177
+ };
6178
+ }
6179
+ };
6180
+ }
6181
+ function useComposedRefs(...refs) {
6182
+ return React.useCallback(composeRefs(...refs), refs);
6183
+ }
6184
+ function createContextScope(scopeName, createContextScopeDeps = []) {
6185
+ let defaultContexts = [];
6186
+ function createContext3(rootComponentName, defaultContext) {
6187
+ const BaseContext = React.createContext(defaultContext);
6188
+ const index2 = defaultContexts.length;
6189
+ defaultContexts = [...defaultContexts, defaultContext];
6190
+ const Provider2 = (props) => {
6191
+ var _a;
6192
+ const { scope, children, ...context } = props;
6193
+ const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index2]) || BaseContext;
6194
+ const value = React.useMemo(() => context, Object.values(context));
6195
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
6196
+ };
6197
+ Provider2.displayName = rootComponentName + "Provider";
6198
+ function useContext2(consumerName, scope) {
6199
+ var _a;
6200
+ const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index2]) || BaseContext;
6201
+ const context = React.useContext(Context);
6202
+ if (context) return context;
6203
+ if (defaultContext !== void 0) return defaultContext;
6204
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
6205
+ }
6206
+ return [Provider2, useContext2];
6207
+ }
6208
+ const createScope = () => {
6209
+ const scopeContexts = defaultContexts.map((defaultContext) => {
6210
+ return React.createContext(defaultContext);
6211
+ });
6212
+ return function useScope(scope) {
6213
+ const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
6214
+ return React.useMemo(
6215
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
6216
+ [scope, contexts]
6217
+ );
6218
+ };
6219
+ };
6220
+ createScope.scopeName = scopeName;
6221
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
6222
+ }
6223
+ function composeContextScopes(...scopes) {
6224
+ const baseScope = scopes[0];
6225
+ if (scopes.length === 1) return baseScope;
6226
+ const createScope = () => {
6227
+ const scopeHooks = scopes.map((createScope2) => ({
6228
+ useScope: createScope2(),
6229
+ scopeName: createScope2.scopeName
6230
+ }));
6231
+ return function useComposedScopes(overrideScopes) {
6232
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
6233
+ const scopeProps = useScope(overrideScopes);
6234
+ const currentScope = scopeProps[`__scope${scopeName}`];
6235
+ return { ...nextScopes2, ...currentScope };
6236
+ }, {});
6237
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
6238
+ };
6239
+ };
6240
+ createScope.scopeName = baseScope.scopeName;
6241
+ return createScope;
6242
+ }
6243
+ var Slot = React.forwardRef((props, forwardedRef) => {
6244
+ const { children, ...slotProps } = props;
6245
+ const childrenArray = React.Children.toArray(children);
6246
+ const slottable = childrenArray.find(isSlottable);
6247
+ if (slottable) {
6248
+ const newElement = slottable.props.children;
6249
+ const newChildren = childrenArray.map((child) => {
6250
+ if (child === slottable) {
6251
+ if (React.Children.count(newElement) > 1) return React.Children.only(null);
6252
+ return React.isValidElement(newElement) ? newElement.props.children : null;
6253
+ } else {
6254
+ return child;
6255
+ }
6256
+ });
6257
+ return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
6258
+ }
6259
+ return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
6260
+ });
6261
+ Slot.displayName = "Slot";
6262
+ var SlotClone = React.forwardRef((props, forwardedRef) => {
6263
+ const { children, ...slotProps } = props;
6264
+ if (React.isValidElement(children)) {
6265
+ const childrenRef = getElementRef$1(children);
6266
+ const props2 = mergeProps(slotProps, children.props);
6267
+ if (children.type !== React.Fragment) {
6268
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
6269
+ }
6270
+ return React.cloneElement(children, props2);
6271
+ }
6272
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
6273
+ });
6274
+ SlotClone.displayName = "SlotClone";
6275
+ var Slottable = ({ children }) => {
6276
+ return /* @__PURE__ */ jsx(Fragment, { children });
6277
+ };
6278
+ function isSlottable(child) {
6279
+ return React.isValidElement(child) && child.type === Slottable;
6280
+ }
6281
+ function mergeProps(slotProps, childProps) {
6282
+ const overrideProps = { ...childProps };
6283
+ for (const propName in childProps) {
6284
+ const slotPropValue = slotProps[propName];
6285
+ const childPropValue = childProps[propName];
6286
+ const isHandler = /^on[A-Z]/.test(propName);
6287
+ if (isHandler) {
6288
+ if (slotPropValue && childPropValue) {
6289
+ overrideProps[propName] = (...args) => {
6290
+ childPropValue(...args);
6291
+ slotPropValue(...args);
6292
+ };
6293
+ } else if (slotPropValue) {
6294
+ overrideProps[propName] = slotPropValue;
6295
+ }
6296
+ } else if (propName === "style") {
6297
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
6298
+ } else if (propName === "className") {
6299
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
6300
+ }
6301
+ }
6302
+ return { ...slotProps, ...overrideProps };
6303
+ }
6304
+ function getElementRef$1(element) {
6305
+ var _a, _b;
6306
+ let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
6307
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
6308
+ if (mayWarn) {
6309
+ return element.ref;
6310
+ }
6311
+ getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
6312
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
6313
+ if (mayWarn) {
6314
+ return element.props.ref;
6315
+ }
6316
+ return element.props.ref || element.ref;
6317
+ }
6318
+ var NODES = [
6319
+ "a",
6320
+ "button",
6321
+ "div",
6322
+ "form",
6323
+ "h2",
6324
+ "h3",
6325
+ "img",
6326
+ "input",
6327
+ "label",
6328
+ "li",
6329
+ "nav",
6330
+ "ol",
6331
+ "p",
6332
+ "span",
6333
+ "svg",
6334
+ "ul"
6335
+ ];
6336
+ var Primitive = NODES.reduce((primitive, node) => {
6337
+ const Node2 = React.forwardRef((props, forwardedRef) => {
6338
+ const { asChild, ...primitiveProps } = props;
6339
+ const Comp = asChild ? Slot : node;
6340
+ if (typeof window !== "undefined") {
6341
+ window[Symbol.for("radix-ui")] = true;
6342
+ }
6343
+ return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
6344
+ });
6345
+ Node2.displayName = `Primitive.${node}`;
6346
+ return { ...primitive, [node]: Node2 };
6347
+ }, {});
6348
+ function dispatchDiscreteCustomEvent(target, event) {
6349
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
6350
+ }
6351
+ function useCallbackRef(callback) {
6352
+ const callbackRef = React.useRef(callback);
6353
+ React.useEffect(() => {
6354
+ callbackRef.current = callback;
6355
+ });
6356
+ return React.useMemo(() => (...args) => {
6357
+ var _a;
6358
+ return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
6359
+ }, []);
6360
+ }
6361
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
6362
+ const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
6363
+ React.useEffect(() => {
6364
+ const handleKeyDown = (event) => {
6365
+ if (event.key === "Escape") {
6366
+ onEscapeKeyDown(event);
6367
+ }
6368
+ };
6369
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
6370
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
6371
+ }, [onEscapeKeyDown, ownerDocument]);
6372
+ }
6373
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
6374
+ var CONTEXT_UPDATE = "dismissableLayer.update";
6375
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
6376
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
6377
+ var originalBodyPointerEvents;
6378
+ var DismissableLayerContext = React.createContext({
6379
+ layers: /* @__PURE__ */ new Set(),
6380
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
6381
+ branches: /* @__PURE__ */ new Set()
6382
+ });
6383
+ var DismissableLayer = React.forwardRef(
6384
+ (props, forwardedRef) => {
6385
+ const {
6386
+ disableOutsidePointerEvents = false,
6387
+ onEscapeKeyDown,
6388
+ onPointerDownOutside,
6389
+ onFocusOutside,
6390
+ onInteractOutside,
6391
+ onDismiss,
6392
+ ...layerProps
6393
+ } = props;
6394
+ const context = React.useContext(DismissableLayerContext);
6395
+ const [node, setNode] = React.useState(null);
6396
+ const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
6397
+ const [, force] = React.useState({});
6398
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
6399
+ const layers = Array.from(context.layers);
6400
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
6401
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
6402
+ const index2 = node ? layers.indexOf(node) : -1;
6403
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
6404
+ const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex;
6405
+ const pointerDownOutside = usePointerDownOutside((event) => {
6406
+ const target = event.target;
6407
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
6408
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
6409
+ onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
6410
+ onInteractOutside == null ? void 0 : onInteractOutside(event);
6411
+ if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
6412
+ }, ownerDocument);
6413
+ const focusOutside = useFocusOutside((event) => {
6414
+ const target = event.target;
6415
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
6416
+ if (isFocusInBranch) return;
6417
+ onFocusOutside == null ? void 0 : onFocusOutside(event);
6418
+ onInteractOutside == null ? void 0 : onInteractOutside(event);
6419
+ if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
6420
+ }, ownerDocument);
6421
+ useEscapeKeydown((event) => {
6422
+ const isHighestLayer = index2 === context.layers.size - 1;
6423
+ if (!isHighestLayer) return;
6424
+ onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
6425
+ if (!event.defaultPrevented && onDismiss) {
6426
+ event.preventDefault();
6427
+ onDismiss();
6428
+ }
6429
+ }, ownerDocument);
6430
+ React.useEffect(() => {
6431
+ if (!node) return;
6432
+ if (disableOutsidePointerEvents) {
6433
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
6434
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
6435
+ ownerDocument.body.style.pointerEvents = "none";
6436
+ }
6437
+ context.layersWithOutsidePointerEventsDisabled.add(node);
6438
+ }
6439
+ context.layers.add(node);
6440
+ dispatchUpdate();
6441
+ return () => {
6442
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
6443
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
6444
+ }
6445
+ };
6446
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
6447
+ React.useEffect(() => {
6448
+ return () => {
6449
+ if (!node) return;
6450
+ context.layers.delete(node);
6451
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
6452
+ dispatchUpdate();
6453
+ };
6454
+ }, [node, context]);
6455
+ React.useEffect(() => {
6456
+ const handleUpdate = () => force({});
6457
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
6458
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
6459
+ }, []);
6460
+ return /* @__PURE__ */ jsx(
6461
+ Primitive.div,
6462
+ {
6463
+ ...layerProps,
6464
+ ref: composedRefs,
6465
+ style: {
6466
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
6467
+ ...props.style
6468
+ },
6469
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
6470
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
6471
+ onPointerDownCapture: composeEventHandlers(
6472
+ props.onPointerDownCapture,
6473
+ pointerDownOutside.onPointerDownCapture
6474
+ )
6475
+ }
6476
+ );
6477
+ }
6478
+ );
6479
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
6480
+ var BRANCH_NAME = "DismissableLayerBranch";
6481
+ var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
6482
+ const context = React.useContext(DismissableLayerContext);
6483
+ const ref = React.useRef(null);
6484
+ const composedRefs = useComposedRefs(forwardedRef, ref);
6485
+ React.useEffect(() => {
6486
+ const node = ref.current;
6487
+ if (node) {
6488
+ context.branches.add(node);
6489
+ return () => {
6490
+ context.branches.delete(node);
6491
+ };
6492
+ }
6493
+ }, [context.branches]);
6494
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
6495
+ });
6496
+ DismissableLayerBranch.displayName = BRANCH_NAME;
6497
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
6498
+ const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
6499
+ const isPointerInsideReactTreeRef = React.useRef(false);
6500
+ const handleClickRef = React.useRef(() => {
6501
+ });
6502
+ React.useEffect(() => {
6503
+ const handlePointerDown = (event) => {
6504
+ if (event.target && !isPointerInsideReactTreeRef.current) {
6505
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
6506
+ handleAndDispatchCustomEvent(
6507
+ POINTER_DOWN_OUTSIDE,
6508
+ handlePointerDownOutside,
6509
+ eventDetail,
6510
+ { discrete: true }
6511
+ );
6512
+ };
6513
+ const eventDetail = { originalEvent: event };
6514
+ if (event.pointerType === "touch") {
6515
+ ownerDocument.removeEventListener("click", handleClickRef.current);
6516
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
6517
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
6518
+ } else {
6519
+ handleAndDispatchPointerDownOutsideEvent2();
6520
+ }
6521
+ } else {
6522
+ ownerDocument.removeEventListener("click", handleClickRef.current);
6523
+ }
6524
+ isPointerInsideReactTreeRef.current = false;
6525
+ };
6526
+ const timerId = window.setTimeout(() => {
6527
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
6528
+ }, 0);
6529
+ return () => {
6530
+ window.clearTimeout(timerId);
6531
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
6532
+ ownerDocument.removeEventListener("click", handleClickRef.current);
6533
+ };
6534
+ }, [ownerDocument, handlePointerDownOutside]);
6535
+ return {
6536
+ // ensures we check React component tree (not just DOM tree)
6537
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
6538
+ };
6539
+ }
6540
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
6541
+ const handleFocusOutside = useCallbackRef(onFocusOutside);
6542
+ const isFocusInsideReactTreeRef = React.useRef(false);
6543
+ React.useEffect(() => {
6544
+ const handleFocus = (event) => {
6545
+ if (event.target && !isFocusInsideReactTreeRef.current) {
6546
+ const eventDetail = { originalEvent: event };
6547
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
6548
+ discrete: false
6549
+ });
6550
+ }
6551
+ };
6552
+ ownerDocument.addEventListener("focusin", handleFocus);
6553
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
6554
+ }, [ownerDocument, handleFocusOutside]);
6555
+ return {
6556
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
6557
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
6558
+ };
6559
+ }
6560
+ function dispatchUpdate() {
6561
+ const event = new CustomEvent(CONTEXT_UPDATE);
6562
+ document.dispatchEvent(event);
6563
+ }
6564
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
6565
+ const target = detail.originalEvent.target;
6566
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
6567
+ if (handler) target.addEventListener(name, handler, { once: true });
6568
+ if (discrete) {
6569
+ dispatchDiscreteCustomEvent(target, event);
6570
+ } else {
6571
+ target.dispatchEvent(event);
6572
+ }
6573
+ }
6574
+ var useLayoutEffect2 = Boolean(globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
6575
+ };
6576
+ var useReactId = React["useId".toString()] || (() => void 0);
6577
+ var count = 0;
6578
+ function useId(deterministicId) {
6579
+ const [id, setId] = React.useState(useReactId());
6580
+ useLayoutEffect2(() => {
6581
+ setId((reactId) => reactId ?? String(count++));
6582
+ }, [deterministicId]);
6583
+ return id ? `radix-${id}` : "";
6584
+ }
6585
+ const sides = ["top", "right", "bottom", "left"];
6586
+ const min = Math.min;
6587
+ const max = Math.max;
6588
+ const round = Math.round;
6589
+ const floor = Math.floor;
6590
+ const createCoords = (v) => ({
6591
+ x: v,
6592
+ y: v
6593
+ });
6594
+ const oppositeSideMap = {
6595
+ left: "right",
6596
+ right: "left",
6597
+ bottom: "top",
6598
+ top: "bottom"
6599
+ };
6600
+ function clamp(start, value, end) {
6601
+ return max(start, min(value, end));
6602
+ }
6603
+ function evaluate(value, param) {
6604
+ return typeof value === "function" ? value(param) : value;
6605
+ }
6606
+ function getSide(placement) {
6607
+ return placement.split("-")[0];
6608
+ }
6609
+ function getAlignment(placement) {
6610
+ return placement.split("-")[1];
6611
+ }
6612
+ function getOppositeAxis(axis) {
6613
+ return axis === "x" ? "y" : "x";
6614
+ }
6615
+ function getAxisLength(axis) {
6616
+ return axis === "y" ? "height" : "width";
6617
+ }
6618
+ function getSideAxis(placement) {
6619
+ const firstChar = placement[0];
6620
+ return firstChar === "t" || firstChar === "b" ? "y" : "x";
6621
+ }
6622
+ function getAlignmentAxis(placement) {
6623
+ return getOppositeAxis(getSideAxis(placement));
6624
+ }
6625
+ function getAlignmentSides(placement, rects, rtl) {
6626
+ if (rtl === void 0) {
6627
+ rtl = false;
6628
+ }
6629
+ const alignment = getAlignment(placement);
6630
+ const alignmentAxis = getAlignmentAxis(placement);
6631
+ const length = getAxisLength(alignmentAxis);
6632
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
6633
+ if (rects.reference[length] > rects.floating[length]) {
6634
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
6635
+ }
6636
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
6637
+ }
6638
+ function getExpandedPlacements(placement) {
6639
+ const oppositePlacement = getOppositePlacement(placement);
6640
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
6641
+ }
6642
+ function getOppositeAlignmentPlacement(placement) {
6643
+ return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
6644
+ }
6645
+ const lrPlacement = ["left", "right"];
6646
+ const rlPlacement = ["right", "left"];
6647
+ const tbPlacement = ["top", "bottom"];
6648
+ const btPlacement = ["bottom", "top"];
6649
+ function getSideList(side, isStart, rtl) {
6650
+ switch (side) {
6651
+ case "top":
6652
+ case "bottom":
6653
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
6654
+ return isStart ? lrPlacement : rlPlacement;
6655
+ case "left":
6656
+ case "right":
6657
+ return isStart ? tbPlacement : btPlacement;
6658
+ default:
6659
+ return [];
6660
+ }
6661
+ }
6662
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
6663
+ const alignment = getAlignment(placement);
6664
+ let list = getSideList(getSide(placement), direction === "start", rtl);
6665
+ if (alignment) {
6666
+ list = list.map((side) => side + "-" + alignment);
6667
+ if (flipAlignment) {
6668
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
6669
+ }
6670
+ }
6671
+ return list;
6672
+ }
6673
+ function getOppositePlacement(placement) {
6674
+ const side = getSide(placement);
6675
+ return oppositeSideMap[side] + placement.slice(side.length);
6676
+ }
6677
+ function expandPaddingObject(padding) {
6678
+ return {
6679
+ top: 0,
6680
+ right: 0,
6681
+ bottom: 0,
6682
+ left: 0,
6683
+ ...padding
6684
+ };
6685
+ }
6686
+ function getPaddingObject(padding) {
6687
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
6688
+ top: padding,
6689
+ right: padding,
6690
+ bottom: padding,
6691
+ left: padding
6692
+ };
6693
+ }
6694
+ function rectToClientRect(rect) {
6695
+ const {
6696
+ x,
6697
+ y,
6698
+ width,
6699
+ height
6700
+ } = rect;
6701
+ return {
6702
+ width,
6703
+ height,
6704
+ top: y,
6705
+ left: x,
6706
+ right: x + width,
6707
+ bottom: y + height,
6708
+ x,
6709
+ y
6710
+ };
6711
+ }
6712
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
6713
+ let {
6714
+ reference,
6715
+ floating
6716
+ } = _ref;
6717
+ const sideAxis = getSideAxis(placement);
6718
+ const alignmentAxis = getAlignmentAxis(placement);
6719
+ const alignLength = getAxisLength(alignmentAxis);
6720
+ const side = getSide(placement);
6721
+ const isVertical = sideAxis === "y";
6722
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
6723
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
6724
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
6725
+ let coords;
6726
+ switch (side) {
6727
+ case "top":
6728
+ coords = {
6729
+ x: commonX,
6730
+ y: reference.y - floating.height
6731
+ };
6732
+ break;
6733
+ case "bottom":
6734
+ coords = {
6735
+ x: commonX,
6736
+ y: reference.y + reference.height
6737
+ };
6738
+ break;
6739
+ case "right":
6740
+ coords = {
6741
+ x: reference.x + reference.width,
6742
+ y: commonY
6743
+ };
6744
+ break;
6745
+ case "left":
6746
+ coords = {
6747
+ x: reference.x - floating.width,
6748
+ y: commonY
6749
+ };
6750
+ break;
6751
+ default:
6752
+ coords = {
6753
+ x: reference.x,
6754
+ y: reference.y
6755
+ };
6756
+ }
6757
+ switch (getAlignment(placement)) {
6758
+ case "start":
6759
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
6760
+ break;
6761
+ case "end":
6762
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
6763
+ break;
6764
+ }
6765
+ return coords;
6766
+ }
6767
+ async function detectOverflow(state, options) {
6768
+ var _await$platform$isEle;
6769
+ if (options === void 0) {
6770
+ options = {};
6771
+ }
6772
+ const {
6773
+ x,
6774
+ y,
6775
+ platform: platform2,
6776
+ rects,
6777
+ elements,
6778
+ strategy
6779
+ } = state;
6780
+ const {
6781
+ boundary = "clippingAncestors",
6782
+ rootBoundary = "viewport",
6783
+ elementContext = "floating",
6784
+ altBoundary = false,
6785
+ padding = 0
6786
+ } = evaluate(options, state);
6787
+ const paddingObject = getPaddingObject(padding);
6788
+ const altContext = elementContext === "floating" ? "reference" : "floating";
6789
+ const element = elements[altBoundary ? altContext : elementContext];
6790
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
6791
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
6792
+ boundary,
6793
+ rootBoundary,
6794
+ strategy
6795
+ }));
6796
+ const rect = elementContext === "floating" ? {
6797
+ x,
6798
+ y,
6799
+ width: rects.floating.width,
6800
+ height: rects.floating.height
6801
+ } : rects.reference;
6802
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
6803
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
6804
+ x: 1,
6805
+ y: 1
6806
+ } : {
6807
+ x: 1,
6808
+ y: 1
6809
+ };
6810
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
6811
+ elements,
6812
+ rect,
6813
+ offsetParent,
6814
+ strategy
6815
+ }) : rect);
6816
+ return {
6817
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
6818
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
6819
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
6820
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
6821
+ };
6822
+ }
6823
+ const MAX_RESET_COUNT = 50;
6824
+ const computePosition$1 = async (reference, floating, config) => {
6825
+ const {
6826
+ placement = "bottom",
6827
+ strategy = "absolute",
6828
+ middleware = [],
6829
+ platform: platform2
6830
+ } = config;
6831
+ const platformWithDetectOverflow = platform2.detectOverflow ? platform2 : {
6832
+ ...platform2,
6833
+ detectOverflow
6834
+ };
6835
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
6836
+ let rects = await platform2.getElementRects({
6837
+ reference,
6838
+ floating,
6839
+ strategy
6840
+ });
6841
+ let {
6842
+ x,
6843
+ y
6844
+ } = computeCoordsFromPlacement(rects, placement, rtl);
6845
+ let statefulPlacement = placement;
6846
+ let resetCount = 0;
6847
+ const middlewareData = {};
6848
+ for (let i = 0; i < middleware.length; i++) {
6849
+ const currentMiddleware = middleware[i];
6850
+ if (!currentMiddleware) {
6851
+ continue;
6852
+ }
6853
+ const {
6854
+ name,
6855
+ fn
6856
+ } = currentMiddleware;
6857
+ const {
6858
+ x: nextX,
6859
+ y: nextY,
6860
+ data,
6861
+ reset
6862
+ } = await fn({
6863
+ x,
6864
+ y,
6865
+ initialPlacement: placement,
6866
+ placement: statefulPlacement,
6867
+ strategy,
6868
+ middlewareData,
6869
+ rects,
6870
+ platform: platformWithDetectOverflow,
6871
+ elements: {
6872
+ reference,
6873
+ floating
6874
+ }
6875
+ });
6876
+ x = nextX != null ? nextX : x;
6877
+ y = nextY != null ? nextY : y;
6878
+ middlewareData[name] = {
6879
+ ...middlewareData[name],
6880
+ ...data
6881
+ };
6882
+ if (reset && resetCount < MAX_RESET_COUNT) {
6883
+ resetCount++;
6884
+ if (typeof reset === "object") {
6885
+ if (reset.placement) {
6886
+ statefulPlacement = reset.placement;
6887
+ }
6888
+ if (reset.rects) {
6889
+ rects = reset.rects === true ? await platform2.getElementRects({
6890
+ reference,
6891
+ floating,
6892
+ strategy
6893
+ }) : reset.rects;
6894
+ }
6895
+ ({
6896
+ x,
6897
+ y
6898
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
6899
+ }
6900
+ i = -1;
6901
+ }
6902
+ }
6903
+ return {
6904
+ x,
6905
+ y,
6906
+ placement: statefulPlacement,
6907
+ strategy,
6908
+ middlewareData
6909
+ };
6910
+ };
6911
+ const arrow$3 = (options) => ({
6912
+ name: "arrow",
6913
+ options,
6914
+ async fn(state) {
6915
+ const {
6916
+ x,
6917
+ y,
6918
+ placement,
6919
+ rects,
6920
+ platform: platform2,
6921
+ elements,
6922
+ middlewareData
6923
+ } = state;
6924
+ const {
6925
+ element,
6926
+ padding = 0
6927
+ } = evaluate(options, state) || {};
6928
+ if (element == null) {
6929
+ return {};
6930
+ }
6931
+ const paddingObject = getPaddingObject(padding);
6932
+ const coords = {
6933
+ x,
6934
+ y
6935
+ };
6936
+ const axis = getAlignmentAxis(placement);
6937
+ const length = getAxisLength(axis);
6938
+ const arrowDimensions = await platform2.getDimensions(element);
6939
+ const isYAxis = axis === "y";
6940
+ const minProp = isYAxis ? "top" : "left";
6941
+ const maxProp = isYAxis ? "bottom" : "right";
6942
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
6943
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
6944
+ const startDiff = coords[axis] - rects.reference[axis];
6945
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
6946
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
6947
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
6948
+ clientSize = elements.floating[clientProp] || rects.floating[length];
6949
+ }
6950
+ const centerToReference = endDiff / 2 - startDiff / 2;
6951
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
6952
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
6953
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
6954
+ const min$1 = minPadding;
6955
+ const max2 = clientSize - arrowDimensions[length] - maxPadding;
6956
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
6957
+ const offset2 = clamp(min$1, center, max2);
6958
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
6959
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
6960
+ return {
6961
+ [axis]: coords[axis] + alignmentOffset,
6962
+ data: {
6963
+ [axis]: offset2,
6964
+ centerOffset: center - offset2 - alignmentOffset,
6965
+ ...shouldAddOffset && {
6966
+ alignmentOffset
6967
+ }
6968
+ },
6969
+ reset: shouldAddOffset
6970
+ };
6971
+ }
6972
+ });
6973
+ const flip$2 = function(options) {
6974
+ if (options === void 0) {
6975
+ options = {};
6976
+ }
6977
+ return {
6978
+ name: "flip",
6979
+ options,
6980
+ async fn(state) {
6981
+ var _middlewareData$arrow, _middlewareData$flip;
6982
+ const {
6983
+ placement,
6984
+ middlewareData,
6985
+ rects,
6986
+ initialPlacement,
6987
+ platform: platform2,
6988
+ elements
6989
+ } = state;
6990
+ const {
6991
+ mainAxis: checkMainAxis = true,
6992
+ crossAxis: checkCrossAxis = true,
6993
+ fallbackPlacements: specifiedFallbackPlacements,
6994
+ fallbackStrategy = "bestFit",
6995
+ fallbackAxisSideDirection = "none",
6996
+ flipAlignment = true,
6997
+ ...detectOverflowOptions
6998
+ } = evaluate(options, state);
6999
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
7000
+ return {};
7001
+ }
7002
+ const side = getSide(placement);
7003
+ const initialSideAxis = getSideAxis(initialPlacement);
7004
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
7005
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
7006
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
7007
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
7008
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
7009
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
7010
+ }
7011
+ const placements = [initialPlacement, ...fallbackPlacements];
7012
+ const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
7013
+ const overflows = [];
7014
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
7015
+ if (checkMainAxis) {
7016
+ overflows.push(overflow[side]);
7017
+ }
7018
+ if (checkCrossAxis) {
7019
+ const sides2 = getAlignmentSides(placement, rects, rtl);
7020
+ overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
7021
+ }
7022
+ overflowsData = [...overflowsData, {
7023
+ placement,
7024
+ overflows
7025
+ }];
7026
+ if (!overflows.every((side2) => side2 <= 0)) {
7027
+ var _middlewareData$flip2, _overflowsData$filter;
7028
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
7029
+ const nextPlacement = placements[nextIndex];
7030
+ if (nextPlacement) {
7031
+ const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
7032
+ if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
7033
+ // overflows the main axis.
7034
+ overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
7035
+ return {
7036
+ data: {
7037
+ index: nextIndex,
7038
+ overflows: overflowsData
7039
+ },
7040
+ reset: {
7041
+ placement: nextPlacement
7042
+ }
7043
+ };
7044
+ }
7045
+ }
7046
+ 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;
7047
+ if (!resetPlacement) {
7048
+ switch (fallbackStrategy) {
7049
+ case "bestFit": {
7050
+ var _overflowsData$filter2;
7051
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
7052
+ if (hasFallbackAxisSideDirection) {
7053
+ const currentSideAxis = getSideAxis(d.placement);
7054
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
7055
+ // reading directions favoring greater width.
7056
+ currentSideAxis === "y";
7057
+ }
7058
+ return true;
7059
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
7060
+ if (placement2) {
7061
+ resetPlacement = placement2;
7062
+ }
7063
+ break;
7064
+ }
7065
+ case "initialPlacement":
7066
+ resetPlacement = initialPlacement;
7067
+ break;
7068
+ }
7069
+ }
7070
+ if (placement !== resetPlacement) {
7071
+ return {
7072
+ reset: {
7073
+ placement: resetPlacement
7074
+ }
7075
+ };
7076
+ }
7077
+ }
7078
+ return {};
7079
+ }
7080
+ };
7081
+ };
7082
+ function getSideOffsets(overflow, rect) {
7083
+ return {
7084
+ top: overflow.top - rect.height,
7085
+ right: overflow.right - rect.width,
7086
+ bottom: overflow.bottom - rect.height,
7087
+ left: overflow.left - rect.width
7088
+ };
7089
+ }
7090
+ function isAnySideFullyClipped(overflow) {
7091
+ return sides.some((side) => overflow[side] >= 0);
7092
+ }
7093
+ const hide$2 = function(options) {
7094
+ if (options === void 0) {
7095
+ options = {};
7096
+ }
7097
+ return {
7098
+ name: "hide",
7099
+ options,
7100
+ async fn(state) {
7101
+ const {
7102
+ rects,
7103
+ platform: platform2
7104
+ } = state;
7105
+ const {
7106
+ strategy = "referenceHidden",
7107
+ ...detectOverflowOptions
7108
+ } = evaluate(options, state);
7109
+ switch (strategy) {
7110
+ case "referenceHidden": {
7111
+ const overflow = await platform2.detectOverflow(state, {
7112
+ ...detectOverflowOptions,
7113
+ elementContext: "reference"
7114
+ });
7115
+ const offsets = getSideOffsets(overflow, rects.reference);
7116
+ return {
7117
+ data: {
7118
+ referenceHiddenOffsets: offsets,
7119
+ referenceHidden: isAnySideFullyClipped(offsets)
7120
+ }
7121
+ };
7122
+ }
7123
+ case "escaped": {
7124
+ const overflow = await platform2.detectOverflow(state, {
7125
+ ...detectOverflowOptions,
7126
+ altBoundary: true
7127
+ });
7128
+ const offsets = getSideOffsets(overflow, rects.floating);
7129
+ return {
7130
+ data: {
7131
+ escapedOffsets: offsets,
7132
+ escaped: isAnySideFullyClipped(offsets)
7133
+ }
7134
+ };
7135
+ }
7136
+ default: {
7137
+ return {};
7138
+ }
7139
+ }
7140
+ }
7141
+ };
7142
+ };
7143
+ const originSides = /* @__PURE__ */ new Set(["left", "top"]);
7144
+ async function convertValueToCoords(state, options) {
7145
+ const {
7146
+ placement,
7147
+ platform: platform2,
7148
+ elements
7149
+ } = state;
7150
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
7151
+ const side = getSide(placement);
7152
+ const alignment = getAlignment(placement);
7153
+ const isVertical = getSideAxis(placement) === "y";
7154
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
7155
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
7156
+ const rawValue = evaluate(options, state);
7157
+ let {
7158
+ mainAxis,
7159
+ crossAxis,
7160
+ alignmentAxis
7161
+ } = typeof rawValue === "number" ? {
7162
+ mainAxis: rawValue,
7163
+ crossAxis: 0,
7164
+ alignmentAxis: null
7165
+ } : {
7166
+ mainAxis: rawValue.mainAxis || 0,
7167
+ crossAxis: rawValue.crossAxis || 0,
7168
+ alignmentAxis: rawValue.alignmentAxis
7169
+ };
7170
+ if (alignment && typeof alignmentAxis === "number") {
7171
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
7172
+ }
7173
+ return isVertical ? {
7174
+ x: crossAxis * crossAxisMulti,
7175
+ y: mainAxis * mainAxisMulti
7176
+ } : {
7177
+ x: mainAxis * mainAxisMulti,
7178
+ y: crossAxis * crossAxisMulti
7179
+ };
7180
+ }
7181
+ const offset$2 = function(options) {
7182
+ if (options === void 0) {
7183
+ options = 0;
7184
+ }
7185
+ return {
7186
+ name: "offset",
7187
+ options,
7188
+ async fn(state) {
7189
+ var _middlewareData$offse, _middlewareData$arrow;
7190
+ const {
7191
+ x,
7192
+ y,
7193
+ placement,
7194
+ middlewareData
7195
+ } = state;
7196
+ const diffCoords = await convertValueToCoords(state, options);
7197
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
7198
+ return {};
7199
+ }
7200
+ return {
7201
+ x: x + diffCoords.x,
7202
+ y: y + diffCoords.y,
7203
+ data: {
7204
+ ...diffCoords,
7205
+ placement
7206
+ }
7207
+ };
7208
+ }
7209
+ };
7210
+ };
7211
+ const shift$2 = function(options) {
7212
+ if (options === void 0) {
7213
+ options = {};
7214
+ }
7215
+ return {
7216
+ name: "shift",
7217
+ options,
7218
+ async fn(state) {
7219
+ const {
7220
+ x,
7221
+ y,
7222
+ placement,
7223
+ platform: platform2
7224
+ } = state;
7225
+ const {
7226
+ mainAxis: checkMainAxis = true,
7227
+ crossAxis: checkCrossAxis = false,
7228
+ limiter = {
7229
+ fn: (_ref) => {
7230
+ let {
7231
+ x: x2,
7232
+ y: y2
7233
+ } = _ref;
7234
+ return {
7235
+ x: x2,
7236
+ y: y2
7237
+ };
7238
+ }
7239
+ },
7240
+ ...detectOverflowOptions
7241
+ } = evaluate(options, state);
7242
+ const coords = {
7243
+ x,
7244
+ y
7245
+ };
7246
+ const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
7247
+ const crossAxis = getSideAxis(getSide(placement));
7248
+ const mainAxis = getOppositeAxis(crossAxis);
7249
+ let mainAxisCoord = coords[mainAxis];
7250
+ let crossAxisCoord = coords[crossAxis];
7251
+ if (checkMainAxis) {
7252
+ const minSide = mainAxis === "y" ? "top" : "left";
7253
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
7254
+ const min2 = mainAxisCoord + overflow[minSide];
7255
+ const max2 = mainAxisCoord - overflow[maxSide];
7256
+ mainAxisCoord = clamp(min2, mainAxisCoord, max2);
7257
+ }
7258
+ if (checkCrossAxis) {
7259
+ const minSide = crossAxis === "y" ? "top" : "left";
7260
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
7261
+ const min2 = crossAxisCoord + overflow[minSide];
7262
+ const max2 = crossAxisCoord - overflow[maxSide];
7263
+ crossAxisCoord = clamp(min2, crossAxisCoord, max2);
7264
+ }
7265
+ const limitedCoords = limiter.fn({
7266
+ ...state,
7267
+ [mainAxis]: mainAxisCoord,
7268
+ [crossAxis]: crossAxisCoord
7269
+ });
7270
+ return {
7271
+ ...limitedCoords,
7272
+ data: {
7273
+ x: limitedCoords.x - x,
7274
+ y: limitedCoords.y - y,
7275
+ enabled: {
7276
+ [mainAxis]: checkMainAxis,
7277
+ [crossAxis]: checkCrossAxis
7278
+ }
7279
+ }
7280
+ };
7281
+ }
7282
+ };
7283
+ };
7284
+ const limitShift$2 = function(options) {
7285
+ if (options === void 0) {
7286
+ options = {};
7287
+ }
7288
+ return {
7289
+ options,
7290
+ fn(state) {
7291
+ const {
7292
+ x,
7293
+ y,
7294
+ placement,
7295
+ rects,
7296
+ middlewareData
7297
+ } = state;
7298
+ const {
7299
+ offset: offset2 = 0,
7300
+ mainAxis: checkMainAxis = true,
7301
+ crossAxis: checkCrossAxis = true
7302
+ } = evaluate(options, state);
7303
+ const coords = {
7304
+ x,
7305
+ y
7306
+ };
7307
+ const crossAxis = getSideAxis(placement);
7308
+ const mainAxis = getOppositeAxis(crossAxis);
7309
+ let mainAxisCoord = coords[mainAxis];
7310
+ let crossAxisCoord = coords[crossAxis];
7311
+ const rawOffset = evaluate(offset2, state);
7312
+ const computedOffset = typeof rawOffset === "number" ? {
7313
+ mainAxis: rawOffset,
7314
+ crossAxis: 0
7315
+ } : {
7316
+ mainAxis: 0,
7317
+ crossAxis: 0,
7318
+ ...rawOffset
7319
+ };
7320
+ if (checkMainAxis) {
7321
+ const len = mainAxis === "y" ? "height" : "width";
7322
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
7323
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
7324
+ if (mainAxisCoord < limitMin) {
7325
+ mainAxisCoord = limitMin;
7326
+ } else if (mainAxisCoord > limitMax) {
7327
+ mainAxisCoord = limitMax;
7328
+ }
7329
+ }
7330
+ if (checkCrossAxis) {
7331
+ var _middlewareData$offse, _middlewareData$offse2;
7332
+ const len = mainAxis === "y" ? "width" : "height";
7333
+ const isOriginSide = originSides.has(getSide(placement));
7334
+ 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);
7335
+ 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);
7336
+ if (crossAxisCoord < limitMin) {
7337
+ crossAxisCoord = limitMin;
7338
+ } else if (crossAxisCoord > limitMax) {
7339
+ crossAxisCoord = limitMax;
7340
+ }
7341
+ }
7342
+ return {
7343
+ [mainAxis]: mainAxisCoord,
7344
+ [crossAxis]: crossAxisCoord
7345
+ };
7346
+ }
7347
+ };
7348
+ };
7349
+ const size$2 = function(options) {
7350
+ if (options === void 0) {
7351
+ options = {};
7352
+ }
7353
+ return {
7354
+ name: "size",
7355
+ options,
7356
+ async fn(state) {
7357
+ var _state$middlewareData, _state$middlewareData2;
7358
+ const {
7359
+ placement,
7360
+ rects,
7361
+ platform: platform2,
7362
+ elements
7363
+ } = state;
7364
+ const {
7365
+ apply = () => {
7366
+ },
7367
+ ...detectOverflowOptions
7368
+ } = evaluate(options, state);
7369
+ const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
7370
+ const side = getSide(placement);
7371
+ const alignment = getAlignment(placement);
7372
+ const isYAxis = getSideAxis(placement) === "y";
7373
+ const {
7374
+ width,
7375
+ height
7376
+ } = rects.floating;
7377
+ let heightSide;
7378
+ let widthSide;
7379
+ if (side === "top" || side === "bottom") {
7380
+ heightSide = side;
7381
+ widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
7382
+ } else {
7383
+ widthSide = side;
7384
+ heightSide = alignment === "end" ? "top" : "bottom";
7385
+ }
7386
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
7387
+ const maximumClippingWidth = width - overflow.left - overflow.right;
7388
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
7389
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
7390
+ const noShift = !state.middlewareData.shift;
7391
+ let availableHeight = overflowAvailableHeight;
7392
+ let availableWidth = overflowAvailableWidth;
7393
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
7394
+ availableWidth = maximumClippingWidth;
7395
+ }
7396
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
7397
+ availableHeight = maximumClippingHeight;
7398
+ }
7399
+ if (noShift && !alignment) {
7400
+ const xMin = max(overflow.left, 0);
7401
+ const xMax = max(overflow.right, 0);
7402
+ const yMin = max(overflow.top, 0);
7403
+ const yMax = max(overflow.bottom, 0);
7404
+ if (isYAxis) {
7405
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
7406
+ } else {
7407
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
7408
+ }
7409
+ }
7410
+ await apply({
7411
+ ...state,
7412
+ availableWidth,
7413
+ availableHeight
7414
+ });
7415
+ const nextDimensions = await platform2.getDimensions(elements.floating);
7416
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
7417
+ return {
7418
+ reset: {
7419
+ rects: true
7420
+ }
7421
+ };
7422
+ }
7423
+ return {};
7424
+ }
7425
+ };
7426
+ };
7427
+ function hasWindow() {
7428
+ return typeof window !== "undefined";
7429
+ }
7430
+ function getNodeName(node) {
7431
+ if (isNode(node)) {
7432
+ return (node.nodeName || "").toLowerCase();
7433
+ }
7434
+ return "#document";
7435
+ }
7436
+ function getWindow(node) {
7437
+ var _node$ownerDocument;
7438
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
7439
+ }
7440
+ function getDocumentElement(node) {
7441
+ var _ref;
7442
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
7443
+ }
7444
+ function isNode(value) {
7445
+ if (!hasWindow()) {
7446
+ return false;
7447
+ }
7448
+ return value instanceof Node || value instanceof getWindow(value).Node;
7449
+ }
7450
+ function isElement(value) {
7451
+ if (!hasWindow()) {
7452
+ return false;
7453
+ }
7454
+ return value instanceof Element || value instanceof getWindow(value).Element;
7455
+ }
7456
+ function isHTMLElement(value) {
7457
+ if (!hasWindow()) {
7458
+ return false;
7459
+ }
7460
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
7461
+ }
7462
+ function isShadowRoot(value) {
7463
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
7464
+ return false;
7465
+ }
7466
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
7467
+ }
7468
+ function isOverflowElement(element) {
7469
+ const {
7470
+ overflow,
7471
+ overflowX,
7472
+ overflowY,
7473
+ display
7474
+ } = getComputedStyle$1(element);
7475
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
7476
+ }
7477
+ function isTableElement(element) {
7478
+ return /^(table|td|th)$/.test(getNodeName(element));
7479
+ }
7480
+ function isTopLayer(element) {
7481
+ try {
7482
+ if (element.matches(":popover-open")) {
7483
+ return true;
7484
+ }
7485
+ } catch (_e) {
7486
+ }
7487
+ try {
7488
+ return element.matches(":modal");
7489
+ } catch (_e) {
7490
+ return false;
7491
+ }
7492
+ }
7493
+ const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
7494
+ const containRe = /paint|layout|strict|content/;
7495
+ const isNotNone = (value) => !!value && value !== "none";
7496
+ let isWebKitValue;
7497
+ function isContainingBlock(elementOrCss) {
7498
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
7499
+ return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
7500
+ }
7501
+ function getContainingBlock(element) {
7502
+ let currentNode = getParentNode(element);
7503
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
7504
+ if (isContainingBlock(currentNode)) {
7505
+ return currentNode;
7506
+ } else if (isTopLayer(currentNode)) {
7507
+ return null;
7508
+ }
7509
+ currentNode = getParentNode(currentNode);
7510
+ }
7511
+ return null;
7512
+ }
7513
+ function isWebKit() {
7514
+ if (isWebKitValue == null) {
7515
+ isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
7516
+ }
7517
+ return isWebKitValue;
7518
+ }
7519
+ function isLastTraversableNode(node) {
7520
+ return /^(html|body|#document)$/.test(getNodeName(node));
7521
+ }
7522
+ function getComputedStyle$1(element) {
7523
+ return getWindow(element).getComputedStyle(element);
7524
+ }
7525
+ function getNodeScroll(element) {
7526
+ if (isElement(element)) {
7527
+ return {
7528
+ scrollLeft: element.scrollLeft,
7529
+ scrollTop: element.scrollTop
7530
+ };
7531
+ }
7532
+ return {
7533
+ scrollLeft: element.scrollX,
7534
+ scrollTop: element.scrollY
7535
+ };
7536
+ }
7537
+ function getParentNode(node) {
7538
+ if (getNodeName(node) === "html") {
7539
+ return node;
7540
+ }
7541
+ const result = (
7542
+ // Step into the shadow DOM of the parent of a slotted node.
7543
+ node.assignedSlot || // DOM Element detected.
7544
+ node.parentNode || // ShadowRoot detected.
7545
+ isShadowRoot(node) && node.host || // Fallback.
7546
+ getDocumentElement(node)
7547
+ );
7548
+ return isShadowRoot(result) ? result.host : result;
7549
+ }
7550
+ function getNearestOverflowAncestor(node) {
7551
+ const parentNode = getParentNode(node);
7552
+ if (isLastTraversableNode(parentNode)) {
7553
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
7554
+ }
7555
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
7556
+ return parentNode;
7557
+ }
7558
+ return getNearestOverflowAncestor(parentNode);
7559
+ }
7560
+ function getOverflowAncestors(node, list, traverseIframes) {
7561
+ var _node$ownerDocument2;
7562
+ if (list === void 0) {
7563
+ list = [];
7564
+ }
7565
+ if (traverseIframes === void 0) {
7566
+ traverseIframes = true;
7567
+ }
7568
+ const scrollableAncestor = getNearestOverflowAncestor(node);
7569
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
7570
+ const win = getWindow(scrollableAncestor);
7571
+ if (isBody) {
7572
+ const frameElement = getFrameElement(win);
7573
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
7574
+ } else {
7575
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
7576
+ }
7577
+ }
7578
+ function getFrameElement(win) {
7579
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
7580
+ }
7581
+ function getCssDimensions(element) {
7582
+ const css = getComputedStyle$1(element);
7583
+ let width = parseFloat(css.width) || 0;
7584
+ let height = parseFloat(css.height) || 0;
7585
+ const hasOffset = isHTMLElement(element);
7586
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
7587
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
7588
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7589
+ if (shouldFallback) {
7590
+ width = offsetWidth;
7591
+ height = offsetHeight;
7592
+ }
7593
+ return {
7594
+ width,
7595
+ height,
7596
+ $: shouldFallback
7597
+ };
7598
+ }
7599
+ function unwrapElement(element) {
7600
+ return !isElement(element) ? element.contextElement : element;
7601
+ }
7602
+ function getScale(element) {
7603
+ const domElement = unwrapElement(element);
7604
+ if (!isHTMLElement(domElement)) {
7605
+ return createCoords(1);
7606
+ }
7607
+ const rect = domElement.getBoundingClientRect();
7608
+ const {
7609
+ width,
7610
+ height,
7611
+ $
7612
+ } = getCssDimensions(domElement);
7613
+ let x = ($ ? round(rect.width) : rect.width) / width;
7614
+ let y = ($ ? round(rect.height) : rect.height) / height;
7615
+ if (!x || !Number.isFinite(x)) {
7616
+ x = 1;
7617
+ }
7618
+ if (!y || !Number.isFinite(y)) {
7619
+ y = 1;
7620
+ }
7621
+ return {
7622
+ x,
7623
+ y
7624
+ };
7625
+ }
7626
+ const noOffsets = /* @__PURE__ */ createCoords(0);
7627
+ function getVisualOffsets(element) {
7628
+ const win = getWindow(element);
7629
+ if (!isWebKit() || !win.visualViewport) {
7630
+ return noOffsets;
7631
+ }
7632
+ return {
7633
+ x: win.visualViewport.offsetLeft,
7634
+ y: win.visualViewport.offsetTop
7635
+ };
7636
+ }
7637
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
7638
+ if (isFixed === void 0) {
7639
+ isFixed = false;
7640
+ }
7641
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
7642
+ return false;
7643
+ }
7644
+ return isFixed;
7645
+ }
7646
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
7647
+ if (includeScale === void 0) {
7648
+ includeScale = false;
7649
+ }
7650
+ if (isFixedStrategy === void 0) {
7651
+ isFixedStrategy = false;
7652
+ }
7653
+ const clientRect = element.getBoundingClientRect();
7654
+ const domElement = unwrapElement(element);
7655
+ let scale = createCoords(1);
7656
+ if (includeScale) {
7657
+ if (offsetParent) {
7658
+ if (isElement(offsetParent)) {
7659
+ scale = getScale(offsetParent);
7660
+ }
7661
+ } else {
7662
+ scale = getScale(element);
7663
+ }
7664
+ }
7665
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
7666
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
7667
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
7668
+ let width = clientRect.width / scale.x;
7669
+ let height = clientRect.height / scale.y;
7670
+ if (domElement) {
7671
+ const win = getWindow(domElement);
7672
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
7673
+ let currentWin = win;
7674
+ let currentIFrame = getFrameElement(currentWin);
7675
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
7676
+ const iframeScale = getScale(currentIFrame);
7677
+ const iframeRect = currentIFrame.getBoundingClientRect();
7678
+ const css = getComputedStyle$1(currentIFrame);
7679
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
7680
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
7681
+ x *= iframeScale.x;
7682
+ y *= iframeScale.y;
7683
+ width *= iframeScale.x;
7684
+ height *= iframeScale.y;
7685
+ x += left;
7686
+ y += top;
7687
+ currentWin = getWindow(currentIFrame);
7688
+ currentIFrame = getFrameElement(currentWin);
7689
+ }
7690
+ }
7691
+ return rectToClientRect({
7692
+ width,
7693
+ height,
7694
+ x,
7695
+ y
7696
+ });
7697
+ }
7698
+ function getWindowScrollBarX(element, rect) {
7699
+ const leftScroll = getNodeScroll(element).scrollLeft;
7700
+ if (!rect) {
7701
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
7702
+ }
7703
+ return rect.left + leftScroll;
7704
+ }
7705
+ function getHTMLOffset(documentElement, scroll) {
7706
+ const htmlRect = documentElement.getBoundingClientRect();
7707
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
7708
+ const y = htmlRect.top + scroll.scrollTop;
7709
+ return {
7710
+ x,
7711
+ y
7712
+ };
7713
+ }
7714
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
7715
+ let {
7716
+ elements,
7717
+ rect,
7718
+ offsetParent,
7719
+ strategy
7720
+ } = _ref;
7721
+ const isFixed = strategy === "fixed";
7722
+ const documentElement = getDocumentElement(offsetParent);
7723
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
7724
+ if (offsetParent === documentElement || topLayer && isFixed) {
7725
+ return rect;
7726
+ }
7727
+ let scroll = {
7728
+ scrollLeft: 0,
7729
+ scrollTop: 0
7730
+ };
7731
+ let scale = createCoords(1);
7732
+ const offsets = createCoords(0);
7733
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
7734
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
7735
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
7736
+ scroll = getNodeScroll(offsetParent);
7737
+ }
7738
+ if (isOffsetParentAnElement) {
7739
+ const offsetRect = getBoundingClientRect(offsetParent);
7740
+ scale = getScale(offsetParent);
7741
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
7742
+ offsets.y = offsetRect.y + offsetParent.clientTop;
7743
+ }
7744
+ }
7745
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
7746
+ return {
7747
+ width: rect.width * scale.x,
7748
+ height: rect.height * scale.y,
7749
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
7750
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
7751
+ };
7752
+ }
7753
+ function getClientRects(element) {
7754
+ return Array.from(element.getClientRects());
7755
+ }
7756
+ function getDocumentRect(element) {
7757
+ const html = getDocumentElement(element);
7758
+ const scroll = getNodeScroll(element);
7759
+ const body = element.ownerDocument.body;
7760
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
7761
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
7762
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
7763
+ const y = -scroll.scrollTop;
7764
+ if (getComputedStyle$1(body).direction === "rtl") {
7765
+ x += max(html.clientWidth, body.clientWidth) - width;
7766
+ }
7767
+ return {
7768
+ width,
7769
+ height,
7770
+ x,
7771
+ y
7772
+ };
7773
+ }
7774
+ const SCROLLBAR_MAX = 25;
7775
+ function getViewportRect(element, strategy) {
7776
+ const win = getWindow(element);
7777
+ const html = getDocumentElement(element);
7778
+ const visualViewport = win.visualViewport;
7779
+ let width = html.clientWidth;
7780
+ let height = html.clientHeight;
7781
+ let x = 0;
7782
+ let y = 0;
7783
+ if (visualViewport) {
7784
+ width = visualViewport.width;
7785
+ height = visualViewport.height;
7786
+ const visualViewportBased = isWebKit();
7787
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
7788
+ x = visualViewport.offsetLeft;
7789
+ y = visualViewport.offsetTop;
7790
+ }
7791
+ }
7792
+ const windowScrollbarX = getWindowScrollBarX(html);
7793
+ if (windowScrollbarX <= 0) {
7794
+ const doc = html.ownerDocument;
7795
+ const body = doc.body;
7796
+ const bodyStyles = getComputedStyle(body);
7797
+ const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
7798
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
7799
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
7800
+ width -= clippingStableScrollbarWidth;
7801
+ }
7802
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
7803
+ width += windowScrollbarX;
7804
+ }
7805
+ return {
7806
+ width,
7807
+ height,
7808
+ x,
7809
+ y
7810
+ };
7811
+ }
7812
+ function getInnerBoundingClientRect(element, strategy) {
7813
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
7814
+ const top = clientRect.top + element.clientTop;
7815
+ const left = clientRect.left + element.clientLeft;
7816
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
7817
+ const width = element.clientWidth * scale.x;
7818
+ const height = element.clientHeight * scale.y;
7819
+ const x = left * scale.x;
7820
+ const y = top * scale.y;
7821
+ return {
7822
+ width,
7823
+ height,
7824
+ x,
7825
+ y
7826
+ };
7827
+ }
7828
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
7829
+ let rect;
7830
+ if (clippingAncestor === "viewport") {
7831
+ rect = getViewportRect(element, strategy);
7832
+ } else if (clippingAncestor === "document") {
7833
+ rect = getDocumentRect(getDocumentElement(element));
7834
+ } else if (isElement(clippingAncestor)) {
7835
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
7836
+ } else {
7837
+ const visualOffsets = getVisualOffsets(element);
7838
+ rect = {
7839
+ x: clippingAncestor.x - visualOffsets.x,
7840
+ y: clippingAncestor.y - visualOffsets.y,
7841
+ width: clippingAncestor.width,
7842
+ height: clippingAncestor.height
7843
+ };
7844
+ }
7845
+ return rectToClientRect(rect);
7846
+ }
7847
+ function hasFixedPositionAncestor(element, stopNode) {
7848
+ const parentNode = getParentNode(element);
7849
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
7850
+ return false;
7851
+ }
7852
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
7853
+ }
7854
+ function getClippingElementAncestors(element, cache) {
7855
+ const cachedResult = cache.get(element);
7856
+ if (cachedResult) {
7857
+ return cachedResult;
7858
+ }
7859
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
7860
+ let currentContainingBlockComputedStyle = null;
7861
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
7862
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
7863
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
7864
+ const computedStyle = getComputedStyle$1(currentNode);
7865
+ const currentNodeIsContaining = isContainingBlock(currentNode);
7866
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
7867
+ currentContainingBlockComputedStyle = null;
7868
+ }
7869
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
7870
+ if (shouldDropCurrentNode) {
7871
+ result = result.filter((ancestor) => ancestor !== currentNode);
7872
+ } else {
7873
+ currentContainingBlockComputedStyle = computedStyle;
7874
+ }
7875
+ currentNode = getParentNode(currentNode);
7876
+ }
7877
+ cache.set(element, result);
7878
+ return result;
7879
+ }
7880
+ function getClippingRect(_ref) {
7881
+ let {
7882
+ element,
7883
+ boundary,
7884
+ rootBoundary,
7885
+ strategy
7886
+ } = _ref;
7887
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
7888
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
7889
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
7890
+ let top = firstRect.top;
7891
+ let right = firstRect.right;
7892
+ let bottom = firstRect.bottom;
7893
+ let left = firstRect.left;
7894
+ for (let i = 1; i < clippingAncestors.length; i++) {
7895
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
7896
+ top = max(rect.top, top);
7897
+ right = min(rect.right, right);
7898
+ bottom = min(rect.bottom, bottom);
7899
+ left = max(rect.left, left);
7900
+ }
7901
+ return {
7902
+ width: right - left,
7903
+ height: bottom - top,
7904
+ x: left,
7905
+ y: top
7906
+ };
7907
+ }
7908
+ function getDimensions(element) {
7909
+ const {
7910
+ width,
7911
+ height
7912
+ } = getCssDimensions(element);
7913
+ return {
7914
+ width,
7915
+ height
7916
+ };
7917
+ }
7918
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
7919
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
7920
+ const documentElement = getDocumentElement(offsetParent);
7921
+ const isFixed = strategy === "fixed";
7922
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
7923
+ let scroll = {
7924
+ scrollLeft: 0,
7925
+ scrollTop: 0
7926
+ };
7927
+ const offsets = createCoords(0);
7928
+ function setLeftRTLScrollbarOffset() {
7929
+ offsets.x = getWindowScrollBarX(documentElement);
7930
+ }
7931
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
7932
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
7933
+ scroll = getNodeScroll(offsetParent);
7934
+ }
7935
+ if (isOffsetParentAnElement) {
7936
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
7937
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
7938
+ offsets.y = offsetRect.y + offsetParent.clientTop;
7939
+ } else if (documentElement) {
7940
+ setLeftRTLScrollbarOffset();
7941
+ }
7942
+ }
7943
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
7944
+ setLeftRTLScrollbarOffset();
7945
+ }
7946
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
7947
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
7948
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
7949
+ return {
7950
+ x,
7951
+ y,
7952
+ width: rect.width,
7953
+ height: rect.height
7954
+ };
7955
+ }
7956
+ function isStaticPositioned(element) {
7957
+ return getComputedStyle$1(element).position === "static";
7958
+ }
7959
+ function getTrueOffsetParent(element, polyfill) {
7960
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
7961
+ return null;
7962
+ }
7963
+ if (polyfill) {
7964
+ return polyfill(element);
7965
+ }
7966
+ let rawOffsetParent = element.offsetParent;
7967
+ if (getDocumentElement(element) === rawOffsetParent) {
7968
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
7969
+ }
7970
+ return rawOffsetParent;
7971
+ }
7972
+ function getOffsetParent(element, polyfill) {
7973
+ const win = getWindow(element);
7974
+ if (isTopLayer(element)) {
7975
+ return win;
7976
+ }
7977
+ if (!isHTMLElement(element)) {
7978
+ let svgOffsetParent = getParentNode(element);
7979
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
7980
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
7981
+ return svgOffsetParent;
7982
+ }
7983
+ svgOffsetParent = getParentNode(svgOffsetParent);
7984
+ }
7985
+ return win;
7986
+ }
7987
+ let offsetParent = getTrueOffsetParent(element, polyfill);
7988
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
7989
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
7990
+ }
7991
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
7992
+ return win;
7993
+ }
7994
+ return offsetParent || getContainingBlock(element) || win;
7995
+ }
7996
+ const getElementRects = async function(data) {
7997
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
7998
+ const getDimensionsFn = this.getDimensions;
7999
+ const floatingDimensions = await getDimensionsFn(data.floating);
8000
+ return {
8001
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
8002
+ floating: {
8003
+ x: 0,
8004
+ y: 0,
8005
+ width: floatingDimensions.width,
8006
+ height: floatingDimensions.height
8007
+ }
8008
+ };
8009
+ };
8010
+ function isRTL(element) {
8011
+ return getComputedStyle$1(element).direction === "rtl";
8012
+ }
8013
+ const platform = {
8014
+ convertOffsetParentRelativeRectToViewportRelativeRect,
8015
+ getDocumentElement,
8016
+ getClippingRect,
8017
+ getOffsetParent,
8018
+ getElementRects,
8019
+ getClientRects,
8020
+ getDimensions,
8021
+ getScale,
8022
+ isElement,
8023
+ isRTL
8024
+ };
8025
+ function rectsAreEqual(a, b) {
8026
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
8027
+ }
8028
+ function observeMove(element, onMove) {
8029
+ let io = null;
8030
+ let timeoutId;
8031
+ const root = getDocumentElement(element);
8032
+ function cleanup() {
8033
+ var _io;
8034
+ clearTimeout(timeoutId);
8035
+ (_io = io) == null || _io.disconnect();
8036
+ io = null;
8037
+ }
8038
+ function refresh(skip, threshold) {
8039
+ if (skip === void 0) {
8040
+ skip = false;
8041
+ }
8042
+ if (threshold === void 0) {
8043
+ threshold = 1;
8044
+ }
8045
+ cleanup();
8046
+ const elementRectForRootMargin = element.getBoundingClientRect();
8047
+ const {
8048
+ left,
8049
+ top,
8050
+ width,
8051
+ height
8052
+ } = elementRectForRootMargin;
8053
+ if (!skip) {
8054
+ onMove();
8055
+ }
8056
+ if (!width || !height) {
8057
+ return;
8058
+ }
8059
+ const insetTop = floor(top);
8060
+ const insetRight = floor(root.clientWidth - (left + width));
8061
+ const insetBottom = floor(root.clientHeight - (top + height));
8062
+ const insetLeft = floor(left);
8063
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
8064
+ const options = {
8065
+ rootMargin,
8066
+ threshold: max(0, min(1, threshold)) || 1
8067
+ };
8068
+ let isFirstUpdate = true;
8069
+ function handleObserve(entries) {
8070
+ const ratio = entries[0].intersectionRatio;
8071
+ if (ratio !== threshold) {
8072
+ if (!isFirstUpdate) {
8073
+ return refresh();
8074
+ }
8075
+ if (!ratio) {
8076
+ timeoutId = setTimeout(() => {
8077
+ refresh(false, 1e-7);
8078
+ }, 1e3);
8079
+ } else {
8080
+ refresh(false, ratio);
8081
+ }
8082
+ }
8083
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
8084
+ refresh();
8085
+ }
8086
+ isFirstUpdate = false;
8087
+ }
8088
+ try {
8089
+ io = new IntersectionObserver(handleObserve, {
8090
+ ...options,
8091
+ // Handle <iframe>s
8092
+ root: root.ownerDocument
8093
+ });
8094
+ } catch (_e) {
8095
+ io = new IntersectionObserver(handleObserve, options);
8096
+ }
8097
+ io.observe(element);
8098
+ }
8099
+ refresh(true);
8100
+ return cleanup;
8101
+ }
8102
+ function autoUpdate(reference, floating, update, options) {
8103
+ if (options === void 0) {
8104
+ options = {};
8105
+ }
8106
+ const {
8107
+ ancestorScroll = true,
8108
+ ancestorResize = true,
8109
+ elementResize = typeof ResizeObserver === "function",
8110
+ layoutShift = typeof IntersectionObserver === "function",
8111
+ animationFrame = false
8112
+ } = options;
8113
+ const referenceEl = unwrapElement(reference);
8114
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
8115
+ ancestors.forEach((ancestor) => {
8116
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
8117
+ passive: true
8118
+ });
8119
+ ancestorResize && ancestor.addEventListener("resize", update);
8120
+ });
8121
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
8122
+ let reobserveFrame = -1;
8123
+ let resizeObserver = null;
8124
+ if (elementResize) {
8125
+ resizeObserver = new ResizeObserver((_ref) => {
8126
+ let [firstEntry] = _ref;
8127
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
8128
+ resizeObserver.unobserve(floating);
8129
+ cancelAnimationFrame(reobserveFrame);
8130
+ reobserveFrame = requestAnimationFrame(() => {
8131
+ var _resizeObserver;
8132
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
8133
+ });
8134
+ }
8135
+ update();
8136
+ });
8137
+ if (referenceEl && !animationFrame) {
8138
+ resizeObserver.observe(referenceEl);
8139
+ }
8140
+ if (floating) {
8141
+ resizeObserver.observe(floating);
8142
+ }
8143
+ }
8144
+ let frameId;
8145
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
8146
+ if (animationFrame) {
8147
+ frameLoop();
8148
+ }
8149
+ function frameLoop() {
8150
+ const nextRefRect = getBoundingClientRect(reference);
8151
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
8152
+ update();
8153
+ }
8154
+ prevRefRect = nextRefRect;
8155
+ frameId = requestAnimationFrame(frameLoop);
8156
+ }
8157
+ update();
8158
+ return () => {
8159
+ var _resizeObserver2;
8160
+ ancestors.forEach((ancestor) => {
8161
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
8162
+ ancestorResize && ancestor.removeEventListener("resize", update);
8163
+ });
8164
+ cleanupIo == null || cleanupIo();
8165
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
8166
+ resizeObserver = null;
8167
+ if (animationFrame) {
8168
+ cancelAnimationFrame(frameId);
8169
+ }
8170
+ };
8171
+ }
8172
+ const offset$1 = offset$2;
8173
+ const shift$1 = shift$2;
8174
+ const flip$1 = flip$2;
8175
+ const size$1 = size$2;
8176
+ const hide$1 = hide$2;
8177
+ const arrow$2 = arrow$3;
8178
+ const limitShift$1 = limitShift$2;
8179
+ const computePosition = (reference, floating, options) => {
8180
+ const cache = /* @__PURE__ */ new Map();
8181
+ const mergedOptions = {
8182
+ platform,
8183
+ ...options
8184
+ };
8185
+ const platformWithCache = {
8186
+ ...mergedOptions.platform,
8187
+ _c: cache
8188
+ };
8189
+ return computePosition$1(reference, floating, {
8190
+ ...mergedOptions,
8191
+ platform: platformWithCache
8192
+ });
8193
+ };
8194
+ var isClient = typeof document !== "undefined";
8195
+ var noop = function noop2() {
8196
+ };
8197
+ var index$1 = isClient ? useLayoutEffect : noop;
8198
+ function deepEqual(a, b) {
8199
+ if (a === b) {
8200
+ return true;
8201
+ }
8202
+ if (typeof a !== typeof b) {
8203
+ return false;
8204
+ }
8205
+ if (typeof a === "function" && a.toString() === b.toString()) {
8206
+ return true;
8207
+ }
8208
+ let length;
8209
+ let i;
8210
+ let keys;
8211
+ if (a && b && typeof a === "object") {
8212
+ if (Array.isArray(a)) {
8213
+ length = a.length;
8214
+ if (length !== b.length) return false;
8215
+ for (i = length; i-- !== 0; ) {
8216
+ if (!deepEqual(a[i], b[i])) {
8217
+ return false;
8218
+ }
8219
+ }
8220
+ return true;
8221
+ }
8222
+ keys = Object.keys(a);
8223
+ length = keys.length;
8224
+ if (length !== Object.keys(b).length) {
8225
+ return false;
8226
+ }
8227
+ for (i = length; i-- !== 0; ) {
8228
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
8229
+ return false;
8230
+ }
8231
+ }
8232
+ for (i = length; i-- !== 0; ) {
8233
+ const key = keys[i];
8234
+ if (key === "_owner" && a.$$typeof) {
8235
+ continue;
8236
+ }
8237
+ if (!deepEqual(a[key], b[key])) {
8238
+ return false;
8239
+ }
8240
+ }
8241
+ return true;
8242
+ }
8243
+ return a !== a && b !== b;
8244
+ }
8245
+ function getDPR(element) {
8246
+ if (typeof window === "undefined") {
8247
+ return 1;
8248
+ }
8249
+ const win = element.ownerDocument.defaultView || window;
8250
+ return win.devicePixelRatio || 1;
8251
+ }
8252
+ function roundByDPR(element, value) {
8253
+ const dpr = getDPR(element);
8254
+ return Math.round(value * dpr) / dpr;
8255
+ }
8256
+ function useLatestRef(value) {
8257
+ const ref = React.useRef(value);
8258
+ index$1(() => {
8259
+ ref.current = value;
8260
+ });
8261
+ return ref;
8262
+ }
8263
+ function useFloating(options) {
8264
+ if (options === void 0) {
8265
+ options = {};
8266
+ }
8267
+ const {
8268
+ placement = "bottom",
8269
+ strategy = "absolute",
8270
+ middleware = [],
8271
+ platform: platform2,
8272
+ elements: {
8273
+ reference: externalReference,
8274
+ floating: externalFloating
8275
+ } = {},
8276
+ transform = true,
8277
+ whileElementsMounted,
8278
+ open
8279
+ } = options;
8280
+ const [data, setData] = React.useState({
8281
+ x: 0,
8282
+ y: 0,
8283
+ strategy,
8284
+ placement,
8285
+ middlewareData: {},
8286
+ isPositioned: false
8287
+ });
8288
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
8289
+ if (!deepEqual(latestMiddleware, middleware)) {
8290
+ setLatestMiddleware(middleware);
8291
+ }
8292
+ const [_reference, _setReference] = React.useState(null);
8293
+ const [_floating, _setFloating] = React.useState(null);
8294
+ const setReference = React.useCallback((node) => {
8295
+ if (node !== referenceRef.current) {
8296
+ referenceRef.current = node;
8297
+ _setReference(node);
8298
+ }
8299
+ }, []);
8300
+ const setFloating = React.useCallback((node) => {
8301
+ if (node !== floatingRef.current) {
8302
+ floatingRef.current = node;
8303
+ _setFloating(node);
8304
+ }
8305
+ }, []);
8306
+ const referenceEl = externalReference || _reference;
8307
+ const floatingEl = externalFloating || _floating;
8308
+ const referenceRef = React.useRef(null);
8309
+ const floatingRef = React.useRef(null);
8310
+ const dataRef = React.useRef(data);
8311
+ const hasWhileElementsMounted = whileElementsMounted != null;
8312
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
8313
+ const platformRef = useLatestRef(platform2);
8314
+ const openRef = useLatestRef(open);
8315
+ const update = React.useCallback(() => {
8316
+ if (!referenceRef.current || !floatingRef.current) {
8317
+ return;
8318
+ }
8319
+ const config = {
8320
+ placement,
8321
+ strategy,
8322
+ middleware: latestMiddleware
8323
+ };
8324
+ if (platformRef.current) {
8325
+ config.platform = platformRef.current;
8326
+ }
8327
+ computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
8328
+ const fullData = {
8329
+ ...data2,
8330
+ // The floating element's position may be recomputed while it's closed
8331
+ // but still mounted (such as when transitioning out). To ensure
8332
+ // `isPositioned` will be `false` initially on the next open, avoid
8333
+ // setting it to `true` when `open === false` (must be specified).
8334
+ isPositioned: openRef.current !== false
8335
+ };
8336
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
8337
+ dataRef.current = fullData;
8338
+ ReactDOM.flushSync(() => {
8339
+ setData(fullData);
8340
+ });
8341
+ }
8342
+ });
8343
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
8344
+ index$1(() => {
8345
+ if (open === false && dataRef.current.isPositioned) {
8346
+ dataRef.current.isPositioned = false;
8347
+ setData((data2) => ({
8348
+ ...data2,
8349
+ isPositioned: false
8350
+ }));
8351
+ }
8352
+ }, [open]);
8353
+ const isMountedRef = React.useRef(false);
8354
+ index$1(() => {
8355
+ isMountedRef.current = true;
8356
+ return () => {
8357
+ isMountedRef.current = false;
8358
+ };
8359
+ }, []);
8360
+ index$1(() => {
8361
+ if (referenceEl) referenceRef.current = referenceEl;
8362
+ if (floatingEl) floatingRef.current = floatingEl;
8363
+ if (referenceEl && floatingEl) {
8364
+ if (whileElementsMountedRef.current) {
8365
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
8366
+ }
8367
+ update();
8368
+ }
8369
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
8370
+ const refs = React.useMemo(() => ({
8371
+ reference: referenceRef,
8372
+ floating: floatingRef,
8373
+ setReference,
8374
+ setFloating
8375
+ }), [setReference, setFloating]);
8376
+ const elements = React.useMemo(() => ({
8377
+ reference: referenceEl,
8378
+ floating: floatingEl
8379
+ }), [referenceEl, floatingEl]);
8380
+ const floatingStyles = React.useMemo(() => {
8381
+ const initialStyles = {
8382
+ position: strategy,
8383
+ left: 0,
8384
+ top: 0
8385
+ };
8386
+ if (!elements.floating) {
8387
+ return initialStyles;
8388
+ }
8389
+ const x = roundByDPR(elements.floating, data.x);
8390
+ const y = roundByDPR(elements.floating, data.y);
8391
+ if (transform) {
8392
+ return {
8393
+ ...initialStyles,
8394
+ transform: "translate(" + x + "px, " + y + "px)",
8395
+ ...getDPR(elements.floating) >= 1.5 && {
8396
+ willChange: "transform"
8397
+ }
8398
+ };
8399
+ }
8400
+ return {
8401
+ position: strategy,
8402
+ left: x,
8403
+ top: y
8404
+ };
8405
+ }, [strategy, transform, elements.floating, data.x, data.y]);
8406
+ return React.useMemo(() => ({
8407
+ ...data,
8408
+ update,
8409
+ refs,
8410
+ elements,
8411
+ floatingStyles
8412
+ }), [data, update, refs, elements, floatingStyles]);
8413
+ }
8414
+ const arrow$1 = (options) => {
8415
+ function isRef(value) {
8416
+ return {}.hasOwnProperty.call(value, "current");
8417
+ }
8418
+ return {
8419
+ name: "arrow",
8420
+ options,
8421
+ fn(state) {
8422
+ const {
8423
+ element,
8424
+ padding
8425
+ } = typeof options === "function" ? options(state) : options;
8426
+ if (element && isRef(element)) {
8427
+ if (element.current != null) {
8428
+ return arrow$2({
8429
+ element: element.current,
8430
+ padding
8431
+ }).fn(state);
8432
+ }
8433
+ return {};
8434
+ }
8435
+ if (element) {
8436
+ return arrow$2({
8437
+ element,
8438
+ padding
8439
+ }).fn(state);
8440
+ }
8441
+ return {};
8442
+ }
8443
+ };
8444
+ };
8445
+ const offset = (options, deps) => {
8446
+ const result = offset$1(options);
8447
+ return {
8448
+ name: result.name,
8449
+ fn: result.fn,
8450
+ options: [options, deps]
8451
+ };
8452
+ };
8453
+ const shift = (options, deps) => {
8454
+ const result = shift$1(options);
8455
+ return {
8456
+ name: result.name,
8457
+ fn: result.fn,
8458
+ options: [options, deps]
8459
+ };
8460
+ };
8461
+ const limitShift = (options, deps) => {
8462
+ const result = limitShift$1(options);
8463
+ return {
8464
+ fn: result.fn,
8465
+ options: [options, deps]
8466
+ };
8467
+ };
8468
+ const flip = (options, deps) => {
8469
+ const result = flip$1(options);
8470
+ return {
8471
+ name: result.name,
8472
+ fn: result.fn,
8473
+ options: [options, deps]
8474
+ };
8475
+ };
8476
+ const size = (options, deps) => {
8477
+ const result = size$1(options);
8478
+ return {
8479
+ name: result.name,
8480
+ fn: result.fn,
8481
+ options: [options, deps]
8482
+ };
8483
+ };
8484
+ const hide = (options, deps) => {
8485
+ const result = hide$1(options);
8486
+ return {
8487
+ name: result.name,
8488
+ fn: result.fn,
8489
+ options: [options, deps]
8490
+ };
8491
+ };
8492
+ const arrow = (options, deps) => {
8493
+ const result = arrow$1(options);
8494
+ return {
8495
+ name: result.name,
8496
+ fn: result.fn,
8497
+ options: [options, deps]
8498
+ };
8499
+ };
8500
+ var NAME$1 = "Arrow";
8501
+ var Arrow$1 = React.forwardRef((props, forwardedRef) => {
8502
+ const { children, width = 10, height = 5, ...arrowProps } = props;
8503
+ return /* @__PURE__ */ jsx(
8504
+ Primitive.svg,
8505
+ {
8506
+ ...arrowProps,
8507
+ ref: forwardedRef,
8508
+ width,
8509
+ height,
8510
+ viewBox: "0 0 30 10",
8511
+ preserveAspectRatio: "none",
8512
+ children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
8513
+ }
8514
+ );
8515
+ });
8516
+ Arrow$1.displayName = NAME$1;
8517
+ var Root$1 = Arrow$1;
8518
+ function useSize(element) {
8519
+ const [size2, setSize] = React.useState(void 0);
8520
+ useLayoutEffect2(() => {
8521
+ if (element) {
8522
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
8523
+ const resizeObserver = new ResizeObserver((entries) => {
8524
+ if (!Array.isArray(entries)) {
8525
+ return;
8526
+ }
8527
+ if (!entries.length) {
8528
+ return;
8529
+ }
8530
+ const entry = entries[0];
8531
+ let width;
8532
+ let height;
8533
+ if ("borderBoxSize" in entry) {
8534
+ const borderSizeEntry = entry["borderBoxSize"];
8535
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
8536
+ width = borderSize["inlineSize"];
8537
+ height = borderSize["blockSize"];
8538
+ } else {
8539
+ width = element.offsetWidth;
8540
+ height = element.offsetHeight;
8541
+ }
8542
+ setSize({ width, height });
8543
+ });
8544
+ resizeObserver.observe(element, { box: "border-box" });
8545
+ return () => resizeObserver.unobserve(element);
8546
+ } else {
8547
+ setSize(void 0);
8548
+ }
8549
+ }, [element]);
8550
+ return size2;
8551
+ }
8552
+ var POPPER_NAME = "Popper";
8553
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
8554
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
8555
+ var Popper = (props) => {
8556
+ const { __scopePopper, children } = props;
8557
+ const [anchor, setAnchor] = React.useState(null);
8558
+ return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
8559
+ };
8560
+ Popper.displayName = POPPER_NAME;
8561
+ var ANCHOR_NAME = "PopperAnchor";
8562
+ var PopperAnchor = React.forwardRef(
8563
+ (props, forwardedRef) => {
8564
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
8565
+ const context = usePopperContext(ANCHOR_NAME, __scopePopper);
8566
+ const ref = React.useRef(null);
8567
+ const composedRefs = useComposedRefs(forwardedRef, ref);
8568
+ React.useEffect(() => {
8569
+ context.onAnchorChange((virtualRef == null ? void 0 : virtualRef.current) || ref.current);
8570
+ });
8571
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
8572
+ }
8573
+ );
8574
+ PopperAnchor.displayName = ANCHOR_NAME;
8575
+ var CONTENT_NAME$1 = "PopperContent";
8576
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$1);
8577
+ var PopperContent = React.forwardRef(
8578
+ (props, forwardedRef) => {
8579
+ var _a, _b, _c, _d, _e, _f;
8580
+ const {
8581
+ __scopePopper,
8582
+ side = "bottom",
8583
+ sideOffset = 0,
8584
+ align = "center",
8585
+ alignOffset = 0,
8586
+ arrowPadding = 0,
8587
+ avoidCollisions = true,
8588
+ collisionBoundary = [],
8589
+ collisionPadding: collisionPaddingProp = 0,
8590
+ sticky = "partial",
8591
+ hideWhenDetached = false,
8592
+ updatePositionStrategy = "optimized",
8593
+ onPlaced,
8594
+ ...contentProps
8595
+ } = props;
8596
+ const context = usePopperContext(CONTENT_NAME$1, __scopePopper);
8597
+ const [content, setContent] = React.useState(null);
8598
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
8599
+ const [arrow$12, setArrow] = React.useState(null);
8600
+ const arrowSize = useSize(arrow$12);
8601
+ const arrowWidth = (arrowSize == null ? void 0 : arrowSize.width) ?? 0;
8602
+ const arrowHeight = (arrowSize == null ? void 0 : arrowSize.height) ?? 0;
8603
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
8604
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
8605
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
8606
+ const hasExplicitBoundaries = boundary.length > 0;
8607
+ const detectOverflowOptions = {
8608
+ padding: collisionPadding,
8609
+ boundary: boundary.filter(isNotNull),
8610
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
8611
+ altBoundary: hasExplicitBoundaries
8612
+ };
8613
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
8614
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
8615
+ strategy: "fixed",
8616
+ placement: desiredPlacement,
8617
+ whileElementsMounted: (...args) => {
8618
+ const cleanup = autoUpdate(...args, {
8619
+ animationFrame: updatePositionStrategy === "always"
8620
+ });
8621
+ return cleanup;
8622
+ },
8623
+ elements: {
8624
+ reference: context.anchor
8625
+ },
8626
+ middleware: [
8627
+ offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
8628
+ avoidCollisions && shift({
8629
+ mainAxis: true,
8630
+ crossAxis: false,
8631
+ limiter: sticky === "partial" ? limitShift() : void 0,
8632
+ ...detectOverflowOptions
8633
+ }),
8634
+ avoidCollisions && flip({ ...detectOverflowOptions }),
8635
+ size({
8636
+ ...detectOverflowOptions,
8637
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
8638
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
8639
+ const contentStyle = elements.floating.style;
8640
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
8641
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
8642
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
8643
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
8644
+ }
8645
+ }),
8646
+ arrow$12 && arrow({ element: arrow$12, padding: arrowPadding }),
8647
+ transformOrigin({ arrowWidth, arrowHeight }),
8648
+ hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
8649
+ ]
8650
+ });
8651
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
8652
+ const handlePlaced = useCallbackRef(onPlaced);
8653
+ useLayoutEffect2(() => {
8654
+ if (isPositioned) {
8655
+ handlePlaced == null ? void 0 : handlePlaced();
8656
+ }
8657
+ }, [isPositioned, handlePlaced]);
8658
+ const arrowX = (_a = middlewareData.arrow) == null ? void 0 : _a.x;
8659
+ const arrowY = (_b = middlewareData.arrow) == null ? void 0 : _b.y;
8660
+ const cannotCenterArrow = ((_c = middlewareData.arrow) == null ? void 0 : _c.centerOffset) !== 0;
8661
+ const [contentZIndex, setContentZIndex] = React.useState();
8662
+ useLayoutEffect2(() => {
8663
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
8664
+ }, [content]);
8665
+ return /* @__PURE__ */ jsx(
8666
+ "div",
8667
+ {
8668
+ ref: refs.setFloating,
8669
+ "data-radix-popper-content-wrapper": "",
8670
+ style: {
8671
+ ...floatingStyles,
8672
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
8673
+ // keep off the page when measuring
8674
+ minWidth: "max-content",
8675
+ zIndex: contentZIndex,
8676
+ ["--radix-popper-transform-origin"]: [
8677
+ (_d = middlewareData.transformOrigin) == null ? void 0 : _d.x,
8678
+ (_e = middlewareData.transformOrigin) == null ? void 0 : _e.y
8679
+ ].join(" "),
8680
+ // hide the content if using the hide middleware and should be hidden
8681
+ // set visibility to hidden and disable pointer events so the UI behaves
8682
+ // as if the PopperContent isn't there at all
8683
+ ...((_f = middlewareData.hide) == null ? void 0 : _f.referenceHidden) && {
8684
+ visibility: "hidden",
8685
+ pointerEvents: "none"
8686
+ }
8687
+ },
8688
+ dir: props.dir,
8689
+ children: /* @__PURE__ */ jsx(
8690
+ PopperContentProvider,
8691
+ {
8692
+ scope: __scopePopper,
8693
+ placedSide,
8694
+ onArrowChange: setArrow,
8695
+ arrowX,
8696
+ arrowY,
8697
+ shouldHideArrow: cannotCenterArrow,
8698
+ children: /* @__PURE__ */ jsx(
8699
+ Primitive.div,
8700
+ {
8701
+ "data-side": placedSide,
8702
+ "data-align": placedAlign,
8703
+ ...contentProps,
8704
+ ref: composedRefs,
8705
+ style: {
8706
+ ...contentProps.style,
8707
+ // if the PopperContent hasn't been placed yet (not all measurements done)
8708
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
8709
+ animation: !isPositioned ? "none" : void 0
8710
+ }
8711
+ }
8712
+ )
8713
+ }
8714
+ )
8715
+ }
8716
+ );
8717
+ }
8718
+ );
8719
+ PopperContent.displayName = CONTENT_NAME$1;
8720
+ var ARROW_NAME$1 = "PopperArrow";
8721
+ var OPPOSITE_SIDE = {
8722
+ top: "bottom",
8723
+ right: "left",
8724
+ bottom: "top",
8725
+ left: "right"
8726
+ };
8727
+ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
8728
+ const { __scopePopper, ...arrowProps } = props;
8729
+ const contentContext = useContentContext(ARROW_NAME$1, __scopePopper);
8730
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
8731
+ return (
8732
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
8733
+ // doesn't report size as we'd expect on SVG elements.
8734
+ // it reports their bounding box which is effectively the largest path inside the SVG.
8735
+ /* @__PURE__ */ jsx(
8736
+ "span",
8737
+ {
8738
+ ref: contentContext.onArrowChange,
8739
+ style: {
8740
+ position: "absolute",
8741
+ left: contentContext.arrowX,
8742
+ top: contentContext.arrowY,
8743
+ [baseSide]: 0,
8744
+ transformOrigin: {
8745
+ top: "",
8746
+ right: "0 0",
8747
+ bottom: "center 0",
8748
+ left: "100% 0"
8749
+ }[contentContext.placedSide],
8750
+ transform: {
8751
+ top: "translateY(100%)",
8752
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
8753
+ bottom: `rotate(180deg)`,
8754
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
8755
+ }[contentContext.placedSide],
8756
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
8757
+ },
8758
+ children: /* @__PURE__ */ jsx(
8759
+ Root$1,
8760
+ {
8761
+ ...arrowProps,
8762
+ ref: forwardedRef,
8763
+ style: {
8764
+ ...arrowProps.style,
8765
+ // ensures the element can be measured correctly (mostly for if SVG)
8766
+ display: "block"
8767
+ }
8768
+ }
8769
+ )
8770
+ }
8771
+ )
8772
+ );
8773
+ });
8774
+ PopperArrow.displayName = ARROW_NAME$1;
8775
+ function isNotNull(value) {
8776
+ return value !== null;
8777
+ }
8778
+ var transformOrigin = (options) => ({
8779
+ name: "transformOrigin",
8780
+ options,
8781
+ fn(data) {
8782
+ var _a, _b, _c;
8783
+ const { placement, rects, middlewareData } = data;
8784
+ const cannotCenterArrow = ((_a = middlewareData.arrow) == null ? void 0 : _a.centerOffset) !== 0;
8785
+ const isArrowHidden = cannotCenterArrow;
8786
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
8787
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
8788
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
8789
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
8790
+ const arrowXCenter = (((_b = middlewareData.arrow) == null ? void 0 : _b.x) ?? 0) + arrowWidth / 2;
8791
+ const arrowYCenter = (((_c = middlewareData.arrow) == null ? void 0 : _c.y) ?? 0) + arrowHeight / 2;
8792
+ let x = "";
8793
+ let y = "";
8794
+ if (placedSide === "bottom") {
8795
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
8796
+ y = `${-arrowHeight}px`;
8797
+ } else if (placedSide === "top") {
8798
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
8799
+ y = `${rects.floating.height + arrowHeight}px`;
8800
+ } else if (placedSide === "right") {
8801
+ x = `${-arrowHeight}px`;
8802
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
8803
+ } else if (placedSide === "left") {
8804
+ x = `${rects.floating.width + arrowHeight}px`;
8805
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
8806
+ }
8807
+ return { data: { x, y } };
8808
+ }
8809
+ });
8810
+ function getSideAndAlignFromPlacement(placement) {
8811
+ const [side, align = "center"] = placement.split("-");
8812
+ return [side, align];
8813
+ }
8814
+ var Root2 = Popper;
8815
+ var Anchor = PopperAnchor;
8816
+ var Content = PopperContent;
8817
+ var Arrow = PopperArrow;
8818
+ var PORTAL_NAME$1 = "Portal";
8819
+ var Portal$1 = React.forwardRef((props, forwardedRef) => {
8820
+ var _a;
8821
+ const { container: containerProp, ...portalProps } = props;
8822
+ const [mounted, setMounted] = React.useState(false);
8823
+ useLayoutEffect2(() => setMounted(true), []);
8824
+ const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
8825
+ return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
8826
+ });
8827
+ Portal$1.displayName = PORTAL_NAME$1;
8828
+ function useStateMachine(initialState, machine) {
8829
+ return React.useReducer((state, event) => {
8830
+ const nextState = machine[state][event];
8831
+ return nextState ?? state;
8832
+ }, initialState);
8833
+ }
8834
+ var Presence = (props) => {
8835
+ const { present, children } = props;
8836
+ const presence = usePresence(present);
8837
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
8838
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
8839
+ const forceMount = typeof children === "function";
8840
+ return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
8841
+ };
8842
+ Presence.displayName = "Presence";
8843
+ function usePresence(present) {
8844
+ const [node, setNode] = React.useState();
8845
+ const stylesRef = React.useRef({});
8846
+ const prevPresentRef = React.useRef(present);
8847
+ const prevAnimationNameRef = React.useRef("none");
8848
+ const initialState = present ? "mounted" : "unmounted";
8849
+ const [state, send] = useStateMachine(initialState, {
8850
+ mounted: {
8851
+ UNMOUNT: "unmounted",
8852
+ ANIMATION_OUT: "unmountSuspended"
8853
+ },
8854
+ unmountSuspended: {
8855
+ MOUNT: "mounted",
8856
+ ANIMATION_END: "unmounted"
8857
+ },
8858
+ unmounted: {
8859
+ MOUNT: "mounted"
8860
+ }
8861
+ });
8862
+ React.useEffect(() => {
8863
+ const currentAnimationName = getAnimationName(stylesRef.current);
8864
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
8865
+ }, [state]);
8866
+ useLayoutEffect2(() => {
8867
+ const styles = stylesRef.current;
8868
+ const wasPresent = prevPresentRef.current;
8869
+ const hasPresentChanged = wasPresent !== present;
8870
+ if (hasPresentChanged) {
8871
+ const prevAnimationName = prevAnimationNameRef.current;
8872
+ const currentAnimationName = getAnimationName(styles);
8873
+ if (present) {
8874
+ send("MOUNT");
8875
+ } else if (currentAnimationName === "none" || (styles == null ? void 0 : styles.display) === "none") {
8876
+ send("UNMOUNT");
8877
+ } else {
8878
+ const isAnimating = prevAnimationName !== currentAnimationName;
8879
+ if (wasPresent && isAnimating) {
8880
+ send("ANIMATION_OUT");
8881
+ } else {
8882
+ send("UNMOUNT");
8883
+ }
8884
+ }
8885
+ prevPresentRef.current = present;
8886
+ }
8887
+ }, [present, send]);
8888
+ useLayoutEffect2(() => {
8889
+ if (node) {
8890
+ let timeoutId;
8891
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
8892
+ const handleAnimationEnd = (event) => {
8893
+ const currentAnimationName = getAnimationName(stylesRef.current);
8894
+ const isCurrentAnimation = currentAnimationName.includes(event.animationName);
8895
+ if (event.target === node && isCurrentAnimation) {
8896
+ send("ANIMATION_END");
8897
+ if (!prevPresentRef.current) {
8898
+ const currentFillMode = node.style.animationFillMode;
8899
+ node.style.animationFillMode = "forwards";
8900
+ timeoutId = ownerWindow.setTimeout(() => {
8901
+ if (node.style.animationFillMode === "forwards") {
8902
+ node.style.animationFillMode = currentFillMode;
8903
+ }
8904
+ });
8905
+ }
8906
+ }
8907
+ };
8908
+ const handleAnimationStart = (event) => {
8909
+ if (event.target === node) {
8910
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
8911
+ }
8912
+ };
8913
+ node.addEventListener("animationstart", handleAnimationStart);
8914
+ node.addEventListener("animationcancel", handleAnimationEnd);
8915
+ node.addEventListener("animationend", handleAnimationEnd);
8916
+ return () => {
8917
+ ownerWindow.clearTimeout(timeoutId);
8918
+ node.removeEventListener("animationstart", handleAnimationStart);
8919
+ node.removeEventListener("animationcancel", handleAnimationEnd);
8920
+ node.removeEventListener("animationend", handleAnimationEnd);
8921
+ };
8922
+ } else {
8923
+ send("ANIMATION_END");
8924
+ }
8925
+ }, [node, send]);
8926
+ return {
8927
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
8928
+ ref: React.useCallback((node2) => {
8929
+ if (node2) stylesRef.current = getComputedStyle(node2);
8930
+ setNode(node2);
8931
+ }, [])
8932
+ };
8933
+ }
8934
+ function getAnimationName(styles) {
8935
+ return (styles == null ? void 0 : styles.animationName) || "none";
8936
+ }
8937
+ function getElementRef(element) {
8938
+ var _a, _b;
8939
+ let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
8940
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
8941
+ if (mayWarn) {
8942
+ return element.ref;
8943
+ }
8944
+ getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
8945
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
8946
+ if (mayWarn) {
8947
+ return element.props.ref;
8948
+ }
8949
+ return element.props.ref || element.ref;
8950
+ }
8951
+ function useControllableState({
8952
+ prop,
8953
+ defaultProp,
8954
+ onChange = () => {
8955
+ }
8956
+ }) {
8957
+ const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });
8958
+ const isControlled = prop !== void 0;
8959
+ const value = isControlled ? prop : uncontrolledProp;
8960
+ const handleChange = useCallbackRef(onChange);
8961
+ const setValue = React.useCallback(
8962
+ (nextValue) => {
8963
+ if (isControlled) {
8964
+ const setter = nextValue;
8965
+ const value2 = typeof nextValue === "function" ? setter(prop) : nextValue;
8966
+ if (value2 !== prop) handleChange(value2);
8967
+ } else {
8968
+ setUncontrolledProp(nextValue);
8969
+ }
8970
+ },
8971
+ [isControlled, prop, setUncontrolledProp, handleChange]
8972
+ );
8973
+ return [value, setValue];
8974
+ }
8975
+ function useUncontrolledState({
8976
+ defaultProp,
8977
+ onChange
8978
+ }) {
8979
+ const uncontrolledState = React.useState(defaultProp);
8980
+ const [value] = uncontrolledState;
8981
+ const prevValueRef = React.useRef(value);
8982
+ const handleChange = useCallbackRef(onChange);
8983
+ React.useEffect(() => {
8984
+ if (prevValueRef.current !== value) {
8985
+ handleChange(value);
8986
+ prevValueRef.current = value;
8987
+ }
8988
+ }, [value, prevValueRef, handleChange]);
8989
+ return uncontrolledState;
8990
+ }
8991
+ var NAME = "VisuallyHidden";
8992
+ var VisuallyHidden = React.forwardRef(
8993
+ (props, forwardedRef) => {
8994
+ return /* @__PURE__ */ jsx(
8995
+ Primitive.span,
8996
+ {
8997
+ ...props,
8998
+ ref: forwardedRef,
8999
+ style: {
9000
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
9001
+ position: "absolute",
9002
+ border: 0,
9003
+ width: 1,
9004
+ height: 1,
9005
+ padding: 0,
9006
+ margin: -1,
9007
+ overflow: "hidden",
9008
+ clip: "rect(0, 0, 0, 0)",
9009
+ whiteSpace: "nowrap",
9010
+ wordWrap: "normal",
9011
+ ...props.style
9012
+ }
9013
+ }
9014
+ );
9015
+ }
9016
+ );
9017
+ VisuallyHidden.displayName = NAME;
9018
+ var Root = VisuallyHidden;
9019
+ var [createTooltipContext] = createContextScope("Tooltip", [
9020
+ createPopperScope
9021
+ ]);
9022
+ var usePopperScope = createPopperScope();
9023
+ var PROVIDER_NAME = "TooltipProvider";
9024
+ var DEFAULT_DELAY_DURATION = 700;
9025
+ var TOOLTIP_OPEN = "tooltip.open";
9026
+ var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
9027
+ var TooltipProvider = (props) => {
9028
+ const {
9029
+ __scopeTooltip,
9030
+ delayDuration = DEFAULT_DELAY_DURATION,
9031
+ skipDelayDuration = 300,
9032
+ disableHoverableContent = false,
9033
+ children
9034
+ } = props;
9035
+ const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
9036
+ const isPointerInTransitRef = React.useRef(false);
9037
+ const skipDelayTimerRef = React.useRef(0);
9038
+ React.useEffect(() => {
9039
+ const skipDelayTimer = skipDelayTimerRef.current;
9040
+ return () => window.clearTimeout(skipDelayTimer);
9041
+ }, []);
9042
+ return /* @__PURE__ */ jsx(
9043
+ TooltipProviderContextProvider,
9044
+ {
9045
+ scope: __scopeTooltip,
9046
+ isOpenDelayed,
9047
+ delayDuration,
9048
+ onOpen: React.useCallback(() => {
9049
+ window.clearTimeout(skipDelayTimerRef.current);
9050
+ setIsOpenDelayed(false);
9051
+ }, []),
9052
+ onClose: React.useCallback(() => {
9053
+ window.clearTimeout(skipDelayTimerRef.current);
9054
+ skipDelayTimerRef.current = window.setTimeout(
9055
+ () => setIsOpenDelayed(true),
9056
+ skipDelayDuration
9057
+ );
9058
+ }, [skipDelayDuration]),
9059
+ isPointerInTransitRef,
9060
+ onPointerInTransitChange: React.useCallback((inTransit) => {
9061
+ isPointerInTransitRef.current = inTransit;
9062
+ }, []),
9063
+ disableHoverableContent,
9064
+ children
9065
+ }
9066
+ );
9067
+ };
9068
+ TooltipProvider.displayName = PROVIDER_NAME;
9069
+ var TOOLTIP_NAME = "Tooltip";
9070
+ var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
9071
+ var Tooltip$1 = (props) => {
9072
+ const {
9073
+ __scopeTooltip,
9074
+ children,
9075
+ open: openProp,
9076
+ defaultOpen = false,
9077
+ onOpenChange,
9078
+ disableHoverableContent: disableHoverableContentProp,
9079
+ delayDuration: delayDurationProp
9080
+ } = props;
9081
+ const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);
9082
+ const popperScope = usePopperScope(__scopeTooltip);
9083
+ const [trigger, setTrigger] = React.useState(null);
9084
+ const contentId = useId();
9085
+ const openTimerRef = React.useRef(0);
9086
+ const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
9087
+ const delayDuration = delayDurationProp ?? providerContext.delayDuration;
9088
+ const wasOpenDelayedRef = React.useRef(false);
9089
+ const [open = false, setOpen] = useControllableState({
9090
+ prop: openProp,
9091
+ defaultProp: defaultOpen,
9092
+ onChange: (open2) => {
9093
+ if (open2) {
9094
+ providerContext.onOpen();
9095
+ document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
9096
+ } else {
9097
+ providerContext.onClose();
9098
+ }
9099
+ onOpenChange == null ? void 0 : onOpenChange(open2);
9100
+ }
9101
+ });
9102
+ const stateAttribute = React.useMemo(() => {
9103
+ return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
9104
+ }, [open]);
9105
+ const handleOpen = React.useCallback(() => {
9106
+ window.clearTimeout(openTimerRef.current);
9107
+ openTimerRef.current = 0;
9108
+ wasOpenDelayedRef.current = false;
9109
+ setOpen(true);
9110
+ }, [setOpen]);
9111
+ const handleClose = React.useCallback(() => {
9112
+ window.clearTimeout(openTimerRef.current);
9113
+ openTimerRef.current = 0;
9114
+ setOpen(false);
9115
+ }, [setOpen]);
9116
+ const handleDelayedOpen = React.useCallback(() => {
9117
+ window.clearTimeout(openTimerRef.current);
9118
+ openTimerRef.current = window.setTimeout(() => {
9119
+ wasOpenDelayedRef.current = true;
9120
+ setOpen(true);
9121
+ openTimerRef.current = 0;
9122
+ }, delayDuration);
9123
+ }, [delayDuration, setOpen]);
9124
+ React.useEffect(() => {
9125
+ return () => {
9126
+ if (openTimerRef.current) {
9127
+ window.clearTimeout(openTimerRef.current);
9128
+ openTimerRef.current = 0;
9129
+ }
9130
+ };
9131
+ }, []);
9132
+ return /* @__PURE__ */ jsx(Root2, { ...popperScope, children: /* @__PURE__ */ jsx(
9133
+ TooltipContextProvider,
9134
+ {
9135
+ scope: __scopeTooltip,
9136
+ contentId,
9137
+ open,
9138
+ stateAttribute,
9139
+ trigger,
9140
+ onTriggerChange: setTrigger,
9141
+ onTriggerEnter: React.useCallback(() => {
9142
+ if (providerContext.isOpenDelayed) handleDelayedOpen();
9143
+ else handleOpen();
9144
+ }, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen]),
9145
+ onTriggerLeave: React.useCallback(() => {
9146
+ if (disableHoverableContent) {
9147
+ handleClose();
9148
+ } else {
9149
+ window.clearTimeout(openTimerRef.current);
9150
+ openTimerRef.current = 0;
9151
+ }
9152
+ }, [handleClose, disableHoverableContent]),
9153
+ onOpen: handleOpen,
9154
+ onClose: handleClose,
9155
+ disableHoverableContent,
9156
+ children
9157
+ }
9158
+ ) });
9159
+ };
9160
+ Tooltip$1.displayName = TOOLTIP_NAME;
9161
+ var TRIGGER_NAME = "TooltipTrigger";
9162
+ var TooltipTrigger = React.forwardRef(
9163
+ (props, forwardedRef) => {
9164
+ const { __scopeTooltip, ...triggerProps } = props;
9165
+ const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
9166
+ const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
9167
+ const popperScope = usePopperScope(__scopeTooltip);
9168
+ const ref = React.useRef(null);
9169
+ const composedRefs = useComposedRefs(forwardedRef, ref, context.onTriggerChange);
9170
+ const isPointerDownRef = React.useRef(false);
9171
+ const hasPointerMoveOpenedRef = React.useRef(false);
9172
+ const handlePointerUp = React.useCallback(() => isPointerDownRef.current = false, []);
9173
+ React.useEffect(() => {
9174
+ return () => document.removeEventListener("pointerup", handlePointerUp);
9175
+ }, [handlePointerUp]);
9176
+ return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
9177
+ Primitive.button,
9178
+ {
9179
+ "aria-describedby": context.open ? context.contentId : void 0,
9180
+ "data-state": context.stateAttribute,
9181
+ ...triggerProps,
9182
+ ref: composedRefs,
9183
+ onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
9184
+ if (event.pointerType === "touch") return;
9185
+ if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
9186
+ context.onTriggerEnter();
9187
+ hasPointerMoveOpenedRef.current = true;
9188
+ }
9189
+ }),
9190
+ onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
9191
+ context.onTriggerLeave();
9192
+ hasPointerMoveOpenedRef.current = false;
9193
+ }),
9194
+ onPointerDown: composeEventHandlers(props.onPointerDown, () => {
9195
+ isPointerDownRef.current = true;
9196
+ document.addEventListener("pointerup", handlePointerUp, { once: true });
9197
+ }),
9198
+ onFocus: composeEventHandlers(props.onFocus, () => {
9199
+ if (!isPointerDownRef.current) context.onOpen();
9200
+ }),
9201
+ onBlur: composeEventHandlers(props.onBlur, context.onClose),
9202
+ onClick: composeEventHandlers(props.onClick, context.onClose)
9203
+ }
9204
+ ) });
9205
+ }
9206
+ );
9207
+ TooltipTrigger.displayName = TRIGGER_NAME;
9208
+ var PORTAL_NAME = "TooltipPortal";
9209
+ var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
9210
+ forceMount: void 0
9211
+ });
9212
+ var TooltipPortal = (props) => {
9213
+ const { __scopeTooltip, forceMount, children, container } = props;
9214
+ const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
9215
+ return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeTooltip, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
9216
+ };
9217
+ TooltipPortal.displayName = PORTAL_NAME;
9218
+ var CONTENT_NAME = "TooltipContent";
9219
+ var TooltipContent$1 = React.forwardRef(
9220
+ (props, forwardedRef) => {
9221
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
9222
+ const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
9223
+ const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
9224
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.disableHoverableContent ? /* @__PURE__ */ jsx(TooltipContentImpl, { side, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(TooltipContentHoverable, { side, ...contentProps, ref: forwardedRef }) });
9225
+ }
9226
+ );
9227
+ var TooltipContentHoverable = React.forwardRef((props, forwardedRef) => {
9228
+ const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
9229
+ const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
9230
+ const ref = React.useRef(null);
9231
+ const composedRefs = useComposedRefs(forwardedRef, ref);
9232
+ const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
9233
+ const { trigger, onClose } = context;
9234
+ const content = ref.current;
9235
+ const { onPointerInTransitChange } = providerContext;
9236
+ const handleRemoveGraceArea = React.useCallback(() => {
9237
+ setPointerGraceArea(null);
9238
+ onPointerInTransitChange(false);
9239
+ }, [onPointerInTransitChange]);
9240
+ const handleCreateGraceArea = React.useCallback(
9241
+ (event, hoverTarget) => {
9242
+ const currentTarget = event.currentTarget;
9243
+ const exitPoint = { x: event.clientX, y: event.clientY };
9244
+ const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
9245
+ const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
9246
+ const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
9247
+ const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
9248
+ setPointerGraceArea(graceArea);
9249
+ onPointerInTransitChange(true);
9250
+ },
9251
+ [onPointerInTransitChange]
9252
+ );
9253
+ React.useEffect(() => {
9254
+ return () => handleRemoveGraceArea();
9255
+ }, [handleRemoveGraceArea]);
9256
+ React.useEffect(() => {
9257
+ if (trigger && content) {
9258
+ const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
9259
+ const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
9260
+ trigger.addEventListener("pointerleave", handleTriggerLeave);
9261
+ content.addEventListener("pointerleave", handleContentLeave);
9262
+ return () => {
9263
+ trigger.removeEventListener("pointerleave", handleTriggerLeave);
9264
+ content.removeEventListener("pointerleave", handleContentLeave);
9265
+ };
9266
+ }
9267
+ }, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
9268
+ React.useEffect(() => {
9269
+ if (pointerGraceArea) {
9270
+ const handleTrackPointerGrace = (event) => {
9271
+ const target = event.target;
9272
+ const pointerPosition = { x: event.clientX, y: event.clientY };
9273
+ const hasEnteredTarget = (trigger == null ? void 0 : trigger.contains(target)) || (content == null ? void 0 : content.contains(target));
9274
+ const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
9275
+ if (hasEnteredTarget) {
9276
+ handleRemoveGraceArea();
9277
+ } else if (isPointerOutsideGraceArea) {
9278
+ handleRemoveGraceArea();
9279
+ onClose();
9280
+ }
9281
+ };
9282
+ document.addEventListener("pointermove", handleTrackPointerGrace);
9283
+ return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
9284
+ }
9285
+ }, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);
9286
+ return /* @__PURE__ */ jsx(TooltipContentImpl, { ...props, ref: composedRefs });
9287
+ });
9288
+ var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
9289
+ var TooltipContentImpl = React.forwardRef(
9290
+ (props, forwardedRef) => {
9291
+ const {
9292
+ __scopeTooltip,
9293
+ children,
9294
+ "aria-label": ariaLabel,
9295
+ onEscapeKeyDown,
9296
+ onPointerDownOutside,
9297
+ ...contentProps
9298
+ } = props;
9299
+ const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
9300
+ const popperScope = usePopperScope(__scopeTooltip);
9301
+ const { onClose } = context;
9302
+ React.useEffect(() => {
9303
+ document.addEventListener(TOOLTIP_OPEN, onClose);
9304
+ return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
9305
+ }, [onClose]);
9306
+ React.useEffect(() => {
9307
+ if (context.trigger) {
9308
+ const handleScroll = (event) => {
9309
+ const target = event.target;
9310
+ if (target == null ? void 0 : target.contains(context.trigger)) onClose();
9311
+ };
9312
+ window.addEventListener("scroll", handleScroll, { capture: true });
9313
+ return () => window.removeEventListener("scroll", handleScroll, { capture: true });
9314
+ }
9315
+ }, [context.trigger, onClose]);
9316
+ return /* @__PURE__ */ jsx(
9317
+ DismissableLayer,
9318
+ {
9319
+ asChild: true,
9320
+ disableOutsidePointerEvents: false,
9321
+ onEscapeKeyDown,
9322
+ onPointerDownOutside,
9323
+ onFocusOutside: (event) => event.preventDefault(),
9324
+ onDismiss: onClose,
9325
+ children: /* @__PURE__ */ jsxs(
9326
+ Content,
9327
+ {
9328
+ "data-state": context.stateAttribute,
9329
+ ...popperScope,
9330
+ ...contentProps,
9331
+ ref: forwardedRef,
9332
+ style: {
9333
+ ...contentProps.style,
9334
+ // re-namespace exposed content custom properties
9335
+ ...{
9336
+ "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
9337
+ "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
9338
+ "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
9339
+ "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
9340
+ "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
9341
+ }
9342
+ },
9343
+ children: [
9344
+ /* @__PURE__ */ jsx(Slottable, { children }),
9345
+ /* @__PURE__ */ jsx(VisuallyHiddenContentContextProvider, { scope: __scopeTooltip, isInside: true, children: /* @__PURE__ */ jsx(Root, { id: context.contentId, role: "tooltip", children: ariaLabel || children }) })
9346
+ ]
9347
+ }
9348
+ )
9349
+ }
9350
+ );
9351
+ }
9352
+ );
9353
+ TooltipContent$1.displayName = CONTENT_NAME;
9354
+ var ARROW_NAME = "TooltipArrow";
9355
+ var TooltipArrow = React.forwardRef(
9356
+ (props, forwardedRef) => {
9357
+ const { __scopeTooltip, ...arrowProps } = props;
9358
+ const popperScope = usePopperScope(__scopeTooltip);
9359
+ const visuallyHiddenContentContext = useVisuallyHiddenContentContext(
9360
+ ARROW_NAME,
9361
+ __scopeTooltip
9362
+ );
9363
+ return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
9364
+ }
9365
+ );
9366
+ TooltipArrow.displayName = ARROW_NAME;
9367
+ function getExitSideFromRect(point, rect) {
9368
+ const top = Math.abs(rect.top - point.y);
9369
+ const bottom = Math.abs(rect.bottom - point.y);
9370
+ const right = Math.abs(rect.right - point.x);
9371
+ const left = Math.abs(rect.left - point.x);
9372
+ switch (Math.min(top, bottom, right, left)) {
9373
+ case left:
9374
+ return "left";
9375
+ case right:
9376
+ return "right";
9377
+ case top:
9378
+ return "top";
9379
+ case bottom:
9380
+ return "bottom";
9381
+ default:
9382
+ throw new Error("unreachable");
9383
+ }
9384
+ }
9385
+ function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
9386
+ const paddedExitPoints = [];
9387
+ switch (exitSide) {
9388
+ case "top":
9389
+ paddedExitPoints.push(
9390
+ { x: exitPoint.x - padding, y: exitPoint.y + padding },
9391
+ { x: exitPoint.x + padding, y: exitPoint.y + padding }
9392
+ );
9393
+ break;
9394
+ case "bottom":
9395
+ paddedExitPoints.push(
9396
+ { x: exitPoint.x - padding, y: exitPoint.y - padding },
9397
+ { x: exitPoint.x + padding, y: exitPoint.y - padding }
9398
+ );
9399
+ break;
9400
+ case "left":
9401
+ paddedExitPoints.push(
9402
+ { x: exitPoint.x + padding, y: exitPoint.y - padding },
9403
+ { x: exitPoint.x + padding, y: exitPoint.y + padding }
9404
+ );
9405
+ break;
9406
+ case "right":
9407
+ paddedExitPoints.push(
9408
+ { x: exitPoint.x - padding, y: exitPoint.y - padding },
9409
+ { x: exitPoint.x - padding, y: exitPoint.y + padding }
9410
+ );
9411
+ break;
9412
+ }
9413
+ return paddedExitPoints;
9414
+ }
9415
+ function getPointsFromRect(rect) {
9416
+ const { top, right, bottom, left } = rect;
9417
+ return [
9418
+ { x: left, y: top },
9419
+ { x: right, y: top },
9420
+ { x: right, y: bottom },
9421
+ { x: left, y: bottom }
9422
+ ];
9423
+ }
9424
+ function isPointInPolygon(point, polygon) {
9425
+ const { x, y } = point;
9426
+ let inside = false;
9427
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
9428
+ const xi = polygon[i].x;
9429
+ const yi = polygon[i].y;
9430
+ const xj = polygon[j].x;
9431
+ const yj = polygon[j].y;
9432
+ const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
9433
+ if (intersect) inside = !inside;
9434
+ }
9435
+ return inside;
9436
+ }
9437
+ function getHull(points) {
9438
+ const newPoints = points.slice();
9439
+ newPoints.sort((a, b) => {
9440
+ if (a.x < b.x) return -1;
9441
+ else if (a.x > b.x) return 1;
9442
+ else if (a.y < b.y) return -1;
9443
+ else if (a.y > b.y) return 1;
9444
+ else return 0;
9445
+ });
9446
+ return getHullPresorted(newPoints);
9447
+ }
9448
+ function getHullPresorted(points) {
9449
+ if (points.length <= 1) return points.slice();
9450
+ const upperHull = [];
9451
+ for (let i = 0; i < points.length; i++) {
9452
+ const p = points[i];
9453
+ while (upperHull.length >= 2) {
9454
+ const q = upperHull[upperHull.length - 1];
9455
+ const r = upperHull[upperHull.length - 2];
9456
+ if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
9457
+ else break;
9458
+ }
9459
+ upperHull.push(p);
9460
+ }
9461
+ upperHull.pop();
9462
+ const lowerHull = [];
9463
+ for (let i = points.length - 1; i >= 0; i--) {
9464
+ const p = points[i];
9465
+ while (lowerHull.length >= 2) {
9466
+ const q = lowerHull[lowerHull.length - 1];
9467
+ const r = lowerHull[lowerHull.length - 2];
9468
+ if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
9469
+ else break;
9470
+ }
9471
+ lowerHull.push(p);
9472
+ }
9473
+ lowerHull.pop();
9474
+ if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) {
9475
+ return upperHull;
9476
+ } else {
9477
+ return upperHull.concat(lowerHull);
9478
+ }
9479
+ }
9480
+ var Provider = TooltipProvider;
9481
+ var Root3 = Tooltip$1;
9482
+ var Trigger = TooltipTrigger;
9483
+ var Portal = TooltipPortal;
9484
+ var Content2 = TooltipContent$1;
9485
+ var Arrow2 = TooltipArrow;
9486
+ const TooltipContent = forwardRef(({ className, sideOffset, children, ...props }, ref) => /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(
9487
+ Content2,
9488
+ {
9489
+ ref,
9490
+ sideOffset,
9491
+ className: cn(
9492
+ "z-50 max-w-64 rounded-lg bg-[var(--bg-default-dark)] p-2 text-sm leading-normal text-[var(--text-default-white)]",
9493
+ className
9494
+ ),
9495
+ ...props,
9496
+ children: [
9497
+ children,
9498
+ /* @__PURE__ */ jsx(
9499
+ Arrow2,
9500
+ {
9501
+ width: 8,
9502
+ height: 4,
9503
+ style: { fill: "var(--bg-default-dark)" }
9504
+ }
9505
+ )
9506
+ ]
9507
+ }
9508
+ ) }));
9509
+ TooltipContent.displayName = "TooltipContent";
9510
+ function Tooltip({
9511
+ children,
9512
+ content,
9513
+ side = "top",
9514
+ align = "center",
9515
+ delayDuration = 300,
9516
+ sideOffset = 6,
9517
+ className
9518
+ }) {
9519
+ return /* @__PURE__ */ jsx(Provider, { delayDuration, children: /* @__PURE__ */ jsxs(Root3, { children: [
9520
+ /* @__PURE__ */ jsx(Trigger, { asChild: true, children }),
9521
+ /* @__PURE__ */ jsx(
9522
+ TooltipContent,
9523
+ {
9524
+ side,
9525
+ align,
9526
+ sideOffset,
9527
+ className,
9528
+ children: content
9529
+ }
9530
+ )
9531
+ ] }) });
9532
+ }
6105
9533
  const index = {
6106
9534
  Button,
6107
9535
  Badge,
@@ -6137,6 +9565,9 @@ const index = {
6137
9565
  TimeInput,
6138
9566
  Avatar,
6139
9567
  AvatarStack,
9568
+ Breadcrumb,
9569
+ Tooltip,
9570
+ Popover,
6140
9571
  cn,
6141
9572
  useIsMobile
6142
9573
  };
@@ -6146,6 +9577,7 @@ export {
6146
9577
  AvatarStack,
6147
9578
  Badge,
6148
9579
  BottomSheet,
9580
+ Breadcrumb,
6149
9581
  Button,
6150
9582
  Card,
6151
9583
  Checkbox,
@@ -6157,6 +9589,7 @@ export {
6157
9589
  Modal,
6158
9590
  Notification,
6159
9591
  OptionList,
9592
+ Popover,
6160
9593
  Radio,
6161
9594
  SearchInput,
6162
9595
  StatusTag,
@@ -6175,6 +9608,7 @@ export {
6175
9608
  ToastStack,
6176
9609
  Toaster,
6177
9610
  Toggle,
9611
+ Tooltip,
6178
9612
  cn,
6179
9613
  index as default,
6180
9614
  useIsMobile