@tedi-design-system/react 18.0.0-rc.1 → 18.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/_virtual/index.cjs10.js +1 -1
  2. package/_virtual/index.cjs11.js +1 -1
  3. package/_virtual/index.cjs12.js +1 -1
  4. package/_virtual/index.cjs13.js +1 -1
  5. package/_virtual/index.cjs5.js +1 -1
  6. package/_virtual/index.cjs6.js +1 -1
  7. package/_virtual/index.cjs7.js +1 -1
  8. package/_virtual/index.cjs8.js +1 -1
  9. package/_virtual/index.cjs9.js +1 -1
  10. package/_virtual/index.es10.js +1 -1
  11. package/_virtual/index.es11.js +1 -1
  12. package/_virtual/index.es12.js +1 -1
  13. package/_virtual/index.es13.js +2 -4
  14. package/_virtual/index.es14.js +2 -2
  15. package/_virtual/index.es5.js +4 -2
  16. package/_virtual/index.es6.js +1 -1
  17. package/_virtual/index.es7.js +1 -1
  18. package/_virtual/index.es8.js +1 -1
  19. package/_virtual/index.es9.js +1 -1
  20. package/bundle-stats.html +1 -1
  21. package/external/@floating-ui/core/dist/floating-ui.core.cjs.js +1 -1
  22. package/external/@floating-ui/core/dist/floating-ui.core.es.js +275 -271
  23. package/external/@floating-ui/dom/dist/floating-ui.dom.cjs.js +1 -1
  24. package/external/@floating-ui/dom/dist/floating-ui.dom.es.js +189 -188
  25. package/external/@floating-ui/react/dist/floating-ui.react.cjs.js +1 -1
  26. package/external/@floating-ui/react/dist/floating-ui.react.es.js +1419 -1538
  27. package/external/@floating-ui/react/dist/floating-ui.react.utils.cjs.js +1 -1
  28. package/external/@floating-ui/react/dist/floating-ui.react.utils.es.js +348 -81
  29. package/external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js +1 -1
  30. package/external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js +113 -93
  31. package/external/@floating-ui/utils/dist/floating-ui.utils.cjs.js +1 -1
  32. package/external/@floating-ui/utils/dist/floating-ui.utils.dom.cjs.js +1 -1
  33. package/external/@floating-ui/utils/dist/floating-ui.utils.dom.es.js +97 -97
  34. package/external/@floating-ui/utils/dist/floating-ui.utils.es.js +66 -68
  35. package/external/@mui/system/colorManipulator.cjs.js +1 -1
  36. package/external/@mui/system/colorManipulator.es.js +2 -2
  37. package/external/@mui/system/createStyled.cjs.js +1 -1
  38. package/external/@mui/system/createStyled.es.js +6 -6
  39. package/external/@mui/system/useThemeWithoutDefault.cjs.js +1 -1
  40. package/external/@mui/system/useThemeWithoutDefault.es.js +1 -1
  41. package/external/lodash-es/_baseUnset.cjs.js +1 -1
  42. package/external/lodash-es/_baseUnset.es.js +12 -19
  43. package/external/react-is/index.cjs.js +1 -1
  44. package/external/react-is/index.es.js +1 -1
  45. package/external/tabbable/dist/index.esm.cjs.js +1 -1
  46. package/external/tabbable/dist/index.esm.es.js +72 -63
  47. package/external/toposort/index.cjs.js +1 -1
  48. package/external/toposort/index.es.js +1 -1
  49. package/index.css +1 -1
  50. package/package.json +4 -4
  51. package/src/community/components/form/pickers/calendar/calendar.d.ts +6 -0
  52. package/src/community/components/form/pickers/datepicker/datepicker.d.ts +6 -0
  53. package/src/community/components/form/pickers/datetimepicker/datetimepicker.d.ts +6 -0
  54. package/src/community/components/form/pickers/timepicker/timepicker.d.ts +6 -0
  55. package/src/community/components/modal/modal-closer.d.ts +6 -0
  56. package/src/community/components/modal/modal-provider.d.ts +6 -0
  57. package/src/community/components/modal/modal-trigger.d.ts +6 -0
  58. package/src/community/components/modal/modal.d.ts +6 -0
  59. package/src/tedi/components/buttons/button-group/button-group.cjs.js +1 -1
  60. package/src/tedi/components/buttons/button-group/button-group.es.js +4 -4
  61. package/src/tedi/components/buttons/collapse/collapse.cjs.js +1 -1
  62. package/src/tedi/components/buttons/collapse/collapse.d.ts +23 -0
  63. package/src/tedi/components/buttons/collapse/collapse.es.js +62 -59
  64. package/src/tedi/components/buttons/collapse/collapse.module.scss.cjs.js +1 -1
  65. package/src/tedi/components/buttons/collapse/collapse.module.scss.es.js +2 -1
  66. package/src/tedi/components/content/calendar/calendar-grid.cjs.js +1 -1
  67. package/src/tedi/components/content/calendar/calendar-grid.es.js +7 -6
  68. package/src/tedi/components/content/calendar/calendar.cjs.js +1 -1
  69. package/src/tedi/components/content/calendar/calendar.d.ts +9 -1
  70. package/src/tedi/components/content/calendar/calendar.es.js +72 -71
  71. package/src/tedi/components/content/calendar/calendar.module.scss.cjs.js +1 -1
  72. package/src/tedi/components/content/calendar/calendar.module.scss.es.js +3 -2
  73. package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js +1 -1
  74. package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js +99 -79
  75. package/src/tedi/components/content/table/index.d.ts +6 -0
  76. package/src/tedi/components/content/table/table-columns-menu/table-columns-menu.cjs.js +1 -0
  77. package/src/tedi/components/content/table/table-columns-menu/table-columns-menu.d.ts +15 -0
  78. package/src/tedi/components/content/table/table-columns-menu/table-columns-menu.es.js +37 -0
  79. package/src/tedi/components/content/table/table-context.cjs.js +1 -0
  80. package/src/tedi/components/content/table/table-context.d.ts +3 -0
  81. package/src/tedi/components/content/table/table-context.es.js +11 -0
  82. package/src/tedi/components/content/table/table-header-button/table-header-button.cjs.js +1 -0
  83. package/src/tedi/components/content/table/table-header-button/table-header-button.d.ts +51 -0
  84. package/src/tedi/components/content/table/table-header-button/table-header-button.es.js +42 -0
  85. package/src/tedi/components/content/table/table-header-button/table-header-button.module.scss.cjs.js +1 -0
  86. package/src/tedi/components/content/table/table-header-button/table-header-button.module.scss.es.js +7 -0
  87. package/src/tedi/components/content/table/table-toolbar/table-toolbar.cjs.js +1 -0
  88. package/src/tedi/components/content/table/table-toolbar/table-toolbar.d.ts +21 -0
  89. package/src/tedi/components/content/table/table-toolbar/table-toolbar.es.js +9 -0
  90. package/src/tedi/components/content/table/table.cjs.js +1 -0
  91. package/src/tedi/components/content/table/table.d.ts +519 -0
  92. package/src/tedi/components/content/table/table.es.js +856 -0
  93. package/src/tedi/components/content/table/table.module.scss.cjs.js +1 -0
  94. package/src/tedi/components/content/table/table.module.scss.es.js +54 -0
  95. package/src/tedi/components/content/table/use-table-persistence.cjs.js +1 -0
  96. package/src/tedi/components/content/table/use-table-persistence.d.ts +13 -0
  97. package/src/tedi/components/content/table/use-table-persistence.es.js +53 -0
  98. package/src/tedi/components/filter/filter/filter-group-context.cjs.js +1 -0
  99. package/src/tedi/components/filter/filter/filter-group-context.d.ts +8 -0
  100. package/src/tedi/components/filter/filter/filter-group-context.es.js +5 -0
  101. package/src/tedi/components/filter/filter/filter-group.cjs.js +1 -0
  102. package/src/tedi/components/filter/filter/filter-group.d.ts +94 -0
  103. package/src/tedi/components/filter/filter/filter-group.es.js +64 -0
  104. package/src/tedi/components/filter/filter/filter.cjs.js +1 -0
  105. package/src/tedi/components/filter/filter/filter.d.ts +98 -0
  106. package/src/tedi/components/filter/filter/filter.es.js +236 -0
  107. package/src/tedi/components/filter/filter/filter.module.scss.cjs.js +1 -0
  108. package/src/tedi/components/filter/filter/filter.module.scss.es.js +21 -0
  109. package/src/tedi/components/filter/filter/index.d.ts +3 -0
  110. package/src/tedi/components/form/date-field/date-field-helpers.cjs.js +1 -0
  111. package/src/tedi/components/form/date-field/date-field-helpers.d.ts +66 -0
  112. package/src/tedi/components/form/date-field/date-field-helpers.es.js +28 -0
  113. package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
  114. package/src/tedi/components/form/date-field/date-field.d.ts +22 -0
  115. package/src/tedi/components/form/date-field/date-field.es.js +248 -212
  116. package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -0
  117. package/src/tedi/components/form/date-time-field/date-time-field.d.ts +207 -0
  118. package/src/tedi/components/form/date-time-field/date-time-field.es.js +376 -0
  119. package/src/tedi/components/form/date-time-field/date-time-field.module.scss.cjs.js +1 -0
  120. package/src/tedi/components/form/date-time-field/date-time-field.module.scss.es.js +30 -0
  121. package/src/tedi/components/form/search/search.cjs.js +1 -1
  122. package/src/tedi/components/form/search/search.es.js +22 -20
  123. package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
  124. package/src/tedi/components/form/time-field/time-field.d.ts +9 -0
  125. package/src/tedi/components/form/time-field/time-field.es.js +80 -78
  126. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.cjs.js +1 -0
  127. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.d.ts +52 -0
  128. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.es.js +68 -0
  129. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.module.scss.cjs.js +1 -0
  130. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.module.scss.es.js +9 -0
  131. package/src/tedi/components/layout/mobile-nav/index.d.ts +2 -0
  132. package/src/tedi/components/layout/mobile-nav/mobile-nav.cjs.js +1 -0
  133. package/src/tedi/components/layout/mobile-nav/mobile-nav.d.ts +20 -0
  134. package/src/tedi/components/layout/{sidenav/components/sidenav-mobile/sidenav-mobile.es.js → mobile-nav/mobile-nav.es.js} +21 -20
  135. package/src/tedi/components/layout/sidenav/index.d.ts +2 -2
  136. package/src/tedi/components/layout/sidenav/sidenav.cjs.js +1 -1
  137. package/src/tedi/components/layout/sidenav/sidenav.d.ts +2 -11
  138. package/src/tedi/components/layout/sidenav/sidenav.es.js +27 -27
  139. package/src/tedi/components/layout/top-nav/components/top-nav-group/top-nav-group.cjs.js +1 -0
  140. package/src/tedi/components/layout/top-nav/components/top-nav-group/top-nav-group.d.ts +34 -0
  141. package/src/tedi/components/layout/top-nav/components/top-nav-group/top-nav-group.es.js +33 -0
  142. package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.cjs.js +1 -0
  143. package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.d.ts +66 -0
  144. package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.es.js +101 -0
  145. package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.cjs.js +1 -0
  146. package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.d.ts +11 -0
  147. package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.es.js +9 -0
  148. package/src/tedi/components/layout/top-nav/components/top-nav-subitem/top-nav-subitem.cjs.js +1 -0
  149. package/src/tedi/components/layout/top-nav/components/top-nav-subitem/top-nav-subitem.d.ts +28 -0
  150. package/src/tedi/components/layout/top-nav/components/top-nav-subitem/top-nav-subitem.es.js +30 -0
  151. package/src/tedi/components/layout/top-nav/index.d.ts +5 -0
  152. package/src/tedi/components/layout/top-nav/top-nav-context.cjs.js +1 -0
  153. package/src/tedi/components/layout/top-nav/top-nav-context.d.ts +11 -0
  154. package/src/tedi/components/layout/top-nav/top-nav-context.es.js +6 -0
  155. package/src/tedi/components/layout/top-nav/top-nav.cjs.js +1 -0
  156. package/src/tedi/components/layout/top-nav/top-nav.d.ts +91 -0
  157. package/src/tedi/components/layout/top-nav/top-nav.es.js +171 -0
  158. package/src/tedi/components/layout/top-nav/top-nav.module.scss.cjs.js +1 -0
  159. package/src/tedi/components/layout/top-nav/top-nav.module.scss.es.js +28 -0
  160. package/src/tedi/components/navigation/pagination/index.d.ts +1 -0
  161. package/src/tedi/components/navigation/pagination/pagination-mobile-modal/pagination-mobile-modal.cjs.js +1 -0
  162. package/src/tedi/components/navigation/pagination/pagination-mobile-modal/pagination-mobile-modal.d.ts +36 -0
  163. package/src/tedi/components/navigation/pagination/pagination-mobile-modal/pagination-mobile-modal.es.js +65 -0
  164. package/src/tedi/components/navigation/pagination/pagination-mobile-modal/pagination-mobile-modal.module.scss.cjs.js +1 -0
  165. package/src/tedi/components/navigation/pagination/pagination-mobile-modal/pagination-mobile-modal.module.scss.es.js +13 -0
  166. package/src/tedi/components/navigation/pagination/pagination.cjs.js +1 -1
  167. package/src/tedi/components/navigation/pagination/pagination.d.ts +115 -13
  168. package/src/tedi/components/navigation/pagination/pagination.es.js +244 -96
  169. package/src/tedi/components/navigation/pagination/pagination.module.scss.cjs.js +1 -1
  170. package/src/tedi/components/navigation/pagination/pagination.module.scss.es.js +18 -1
  171. package/src/tedi/components/notifications/alert/alert.cjs.js +1 -1
  172. package/src/tedi/components/notifications/alert/alert.d.ts +14 -1
  173. package/src/tedi/components/notifications/alert/alert.es.js +45 -42
  174. package/src/tedi/components/notifications/alert/alert.module.scss.cjs.js +1 -1
  175. package/src/tedi/components/notifications/alert/alert.module.scss.es.js +2 -1
  176. package/src/tedi/components/overlays/dropdown/dropdown.es.js +0 -3
  177. package/src/tedi/components/overlays/modal/index.d.ts +8 -0
  178. package/src/tedi/components/overlays/modal/modal-body/modal-body.cjs.js +1 -0
  179. package/src/tedi/components/overlays/modal/modal-body/modal-body.d.ts +22 -0
  180. package/src/tedi/components/overlays/modal/modal-body/modal-body.es.js +21 -0
  181. package/src/tedi/components/overlays/modal/modal-closer/modal-closer.cjs.js +1 -0
  182. package/src/tedi/components/overlays/modal/modal-closer/modal-closer.d.ts +15 -0
  183. package/src/tedi/components/overlays/modal/modal-closer/modal-closer.es.js +16 -0
  184. package/src/tedi/components/overlays/modal/modal-content/modal-content.cjs.js +1 -0
  185. package/src/tedi/components/overlays/modal/modal-content/modal-content.d.ts +108 -0
  186. package/src/tedi/components/overlays/modal/modal-content/modal-content.es.js +81 -0
  187. package/src/tedi/components/overlays/modal/modal-context.cjs.js +1 -0
  188. package/src/tedi/components/overlays/modal/modal-context.d.ts +59 -0
  189. package/src/tedi/components/overlays/modal/modal-context.es.js +15 -0
  190. package/src/tedi/components/overlays/modal/modal-footer/modal-footer.cjs.js +1 -0
  191. package/src/tedi/components/overlays/modal/modal-footer/modal-footer.d.ts +22 -0
  192. package/src/tedi/components/overlays/modal/modal-footer/modal-footer.es.js +25 -0
  193. package/src/tedi/components/overlays/modal/modal-header/modal-header.cjs.js +1 -0
  194. package/src/tedi/components/overlays/modal/modal-header/modal-header.d.ts +58 -0
  195. package/src/tedi/components/overlays/modal/modal-header/modal-header.es.js +25 -0
  196. package/src/tedi/components/overlays/modal/modal-trigger/modal-trigger.cjs.js +1 -0
  197. package/src/tedi/components/overlays/modal/modal-trigger/modal-trigger.d.ts +13 -0
  198. package/src/tedi/components/overlays/modal/modal-trigger/modal-trigger.es.js +14 -0
  199. package/src/tedi/components/overlays/modal/modal.cjs.js +1 -0
  200. package/src/tedi/components/overlays/modal/modal.d.ts +68 -0
  201. package/src/tedi/components/overlays/modal/modal.es.js +76 -0
  202. package/src/tedi/components/overlays/modal/modal.module.scss.cjs.js +1 -0
  203. package/src/tedi/components/overlays/modal/modal.module.scss.es.js +37 -0
  204. package/src/tedi/components/overlays/overlay/overlay-content.cjs.js +1 -1
  205. package/src/tedi/components/overlays/overlay/overlay-content.es.js +35 -32
  206. package/src/tedi/components/overlays/tooltip/tooltip.cjs.js +1 -1
  207. package/src/tedi/components/overlays/tooltip/tooltip.es.js +14 -6
  208. package/src/tedi/helpers/hooks/use-breakpoint.cjs.js +1 -1
  209. package/src/tedi/helpers/hooks/use-breakpoint.d.ts +7 -0
  210. package/src/tedi/helpers/hooks/use-breakpoint.es.js +22 -14
  211. package/src/tedi/helpers/hooks/use-sidenav-state.d.ts +1 -1
  212. package/src/tedi/index.d.ts +6 -0
  213. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  214. package/src/tedi/providers/label-provider/labels-map.d.ts +174 -6
  215. package/src/tedi/providers/label-provider/labels-map.es.js +234 -57
  216. package/tedi.cjs.js +1 -1
  217. package/tedi.es.js +257 -202
  218. package/src/tedi/components/layout/sidenav/components/sidenav-mobile/sidenav-mobile.cjs.js +0 -1
  219. package/src/tedi/components/layout/sidenav/components/sidenav-mobile/sidenav-mobile.d.ts +0 -14
  220. package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.cjs.js +0 -1
  221. package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.d.ts +0 -31
  222. package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.es.js +0 -48
  223. package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.module.scss.cjs.js +0 -1
  224. package/src/tedi/components/layout/sidenav/components/sidenav-toggle/sidenav-toggle.module.scss.es.js +0 -8
@@ -1,627 +1,449 @@
1
- import * as u from "react";
2
- import { useLayoutEffect as en, useEffect as tn, useRef as nn } from "react";
3
- import { isMouseLikePointerType as Ae, getDocument as re, isTypeableCombobox as ct, activeElement as ae, contains as ee, isVirtualClick as Wt, isVirtualPointerEvent as lt, stopEvent as ie, getTarget as pe, isSafari as at, isMac as Ht, isTypeableElement as Bt, isReactEvent as rn, isRootElement as on, isEventTargetWithin as Je, getPlatform as sn } from "./floating-ui.react.utils.es.js";
4
- import { floor as bt } from "../../utils/dist/floating-ui.utils.es.js";
5
- import { isElement as oe, getOverflowAncestors as et, isHTMLElement as ge, getWindow as cn, isWebKit as un, isLastTraversableNode as ht, getParentNode as ln, getComputedStyle as qt, getNodeName as jt } from "../../utils/dist/floating-ui.utils.dom.es.js";
6
- import { tabbable as Ge, isTabbable as an } from "../../../tabbable/dist/index.esm.es.js";
7
- import * as fn from "react-dom";
8
- import { useFloating as dn } from "../../react-dom/dist/floating-ui.react-dom.es.js";
9
- import { arrow as fr, flip as dr, offset as mr, shift as pr, size as gr } from "../../react-dom/dist/floating-ui.react-dom.es.js";
10
- function $n(t) {
11
- return u.useMemo(() => t.every((e) => e == null) ? null : (e) => {
12
- t.forEach((n) => {
13
- typeof n == "function" ? n(e) : n != null && (n.current = e);
1
+ import * as c from "react";
2
+ import { useModernLayoutEffect as ee, isMouseLikePointerType as Ae, getFloatingFocusElement as Qe, useEffectEvent as ce, getDocument as ge, isTypeableCombobox as mt, useLatestRef as Re, getNodeAncestors as wt, activeElement as we, contains as ae, getNodeChildren as Se, isVirtualClick as Gt, isVirtualPointerEvent as jt, isOutsideEvent as De, getNextTabbable as Ut, getPreviousTabbable as zt, isIndexOutOfListBounds as xt, getMinListIndex as tt, getMaxListIndex as It, getDeepestNode as fn, stopEvent as he, enableFocusInside as Tt, getTarget as xe, isTypeableElement as Qt, matchesFocusVisible as dn, isReactEvent as mn, isRootElement as pn, isEventTargetWithin as nt, getPlatform as gn, getTabbableOptions as pt, isSafari as Zt, createGridCellMap as vn, isListIndexDisabled as rt, getGridNavigatedIndex as bn, getGridCellIndexOfCorner as Rn, getGridCellIndices as hn, findNonDisabledListIndex as qe, disableFocusInside as En, isMac as yn } from "./floating-ui.react.utils.es.js";
3
+ import { jsx as ve, jsxs as gt, Fragment as wn } from "react/jsx-runtime";
4
+ import { isElement as fe, getOverflowAncestors as ot, isHTMLElement as ye, getWindow as xn, isWebKit as In, isLastTraversableNode as st, getParentNode as Tn, getComputedStyle as Jt, getNodeName as en, isNode as Cn, isShadowRoot as tn } from "../../utils/dist/floating-ui.utils.dom.es.js";
5
+ import { tabbable as nn, isTabbable as rn, focusable as Mn } from "../../../tabbable/dist/index.esm.es.js";
6
+ import * as Pn from "react-dom";
7
+ import { useFloating as kn } from "../../react-dom/dist/floating-ui.react-dom.es.js";
8
+ import { arrow as Tr, flip as Cr, offset as Mr, shift as Pr, size as kr } from "../../react-dom/dist/floating-ui.react-dom.es.js";
9
+ function cr(e) {
10
+ const t = c.useRef(void 0), r = c.useCallback((n) => {
11
+ const o = e.map((i) => {
12
+ if (i != null) {
13
+ if (typeof i == "function") {
14
+ const s = i, a = s(n);
15
+ return typeof a == "function" ? a : () => {
16
+ s(null);
17
+ };
18
+ }
19
+ return i.current = n, () => {
20
+ i.current = null;
21
+ };
22
+ }
14
23
  });
15
- }, t);
16
- }
17
- const Xt = {
18
- ...u
19
- }, mn = Xt.useInsertionEffect, pn = mn || ((t) => t());
20
- function ue(t) {
21
- const e = u.useRef(() => {
22
- if (process.env.NODE_ENV !== "production")
23
- throw new Error("Cannot call an event handler while rendering.");
24
- });
25
- return pn(() => {
26
- e.current = t;
27
- }), u.useCallback(function() {
28
- for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++)
29
- r[o] = arguments[o];
30
- return e.current == null ? void 0 : e.current(...r);
31
- }, []);
32
- }
33
- const ft = "ArrowUp", _e = "ArrowDown", ye = "ArrowLeft", xe = "ArrowRight";
34
- function qe(t, e, n) {
35
- return Math.floor(t / e) !== n;
36
- }
37
- function Se(t, e) {
38
- return e < 0 || e >= t.current.length;
39
- }
40
- function tt(t, e) {
41
- return se(t, {
42
- disabledIndices: e
43
- });
44
- }
45
- function Et(t, e) {
46
- return se(t, {
47
- decrement: !0,
48
- startingIndex: t.current.length,
49
- disabledIndices: e
50
- });
51
- }
52
- function se(t, e) {
53
- let {
54
- startingIndex: n = -1,
55
- decrement: r = !1,
56
- disabledIndices: o,
57
- amount: s = 1
58
- } = e === void 0 ? {} : e;
59
- const i = t.current;
60
- let c = n;
61
- do
62
- c += r ? -s : s;
63
- while (c >= 0 && c <= i.length - 1 && Ue(i, c, o));
64
- return c;
65
- }
66
- function gn(t, e) {
67
- let {
68
- event: n,
69
- orientation: r,
70
- loop: o,
71
- rtl: s,
72
- cols: i,
73
- disabledIndices: c,
74
- minIndex: v,
75
- maxIndex: f,
76
- prevIndex: m,
77
- stopEvent: b = !1
78
- } = e, p = m;
79
- if (n.key === ft) {
80
- if (b && ie(n), m === -1)
81
- p = f;
82
- else if (p = se(t, {
83
- startingIndex: p,
84
- amount: i,
85
- decrement: !0,
86
- disabledIndices: c
87
- }), o && (m - i < v || p < 0)) {
88
- const l = m % i, g = f % i, a = f - (g - l);
89
- g === l ? p = f : p = g > l ? a : a - i;
90
- }
91
- Se(t, p) && (p = m);
92
- }
93
- if (n.key === _e && (b && ie(n), m === -1 ? p = v : (p = se(t, {
94
- startingIndex: m,
95
- amount: i,
96
- disabledIndices: c
97
- }), o && m + i > f && (p = se(t, {
98
- startingIndex: m % i - i,
99
- amount: i,
100
- disabledIndices: c
101
- }))), Se(t, p) && (p = m)), r === "both") {
102
- const l = bt(m / i);
103
- n.key === (s ? ye : xe) && (b && ie(n), m % i !== i - 1 ? (p = se(t, {
104
- startingIndex: m,
105
- disabledIndices: c
106
- }), o && qe(p, i, l) && (p = se(t, {
107
- startingIndex: m - m % i - 1,
108
- disabledIndices: c
109
- }))) : o && (p = se(t, {
110
- startingIndex: m - m % i - 1,
111
- disabledIndices: c
112
- })), qe(p, i, l) && (p = m)), n.key === (s ? xe : ye) && (b && ie(n), m % i !== 0 ? (p = se(t, {
113
- startingIndex: m,
114
- decrement: !0,
115
- disabledIndices: c
116
- }), o && qe(p, i, l) && (p = se(t, {
117
- startingIndex: m + (i - m % i),
118
- decrement: !0,
119
- disabledIndices: c
120
- }))) : o && (p = se(t, {
121
- startingIndex: m + (i - m % i),
122
- decrement: !0,
123
- disabledIndices: c
124
- })), qe(p, i, l) && (p = m));
125
- const g = bt(f / i) === l;
126
- Se(t, p) && (o && g ? p = n.key === (s ? xe : ye) ? f : se(t, {
127
- startingIndex: m - m % i - 1,
128
- disabledIndices: c
129
- }) : p = m);
130
- }
131
- return p;
132
- }
133
- function vn(t, e, n) {
134
- const r = [];
135
- let o = 0;
136
- return t.forEach((s, i) => {
137
- let {
138
- width: c,
139
- height: v
140
- } = s;
141
- if (c > e && process.env.NODE_ENV !== "production")
142
- throw new Error("[Floating UI]: Invalid grid - item width at index " + i + " is greater than grid columns");
143
- let f = !1;
144
- for (n && (o = 0); !f; ) {
145
- const m = [];
146
- for (let b = 0; b < c; b++)
147
- for (let p = 0; p < v; p++)
148
- m.push(o + b + p * e);
149
- o % e + c <= e && m.every((b) => r[b] == null) ? (m.forEach((b) => {
150
- r[b] = i;
151
- }), f = !0) : o++;
152
- }
153
- }), [...r];
154
- }
155
- function bn(t, e, n, r, o) {
156
- if (t === -1) return -1;
157
- const s = n.indexOf(t), i = e[t];
158
- switch (o) {
159
- case "tl":
160
- return s;
161
- case "tr":
162
- return i ? s + i.width - 1 : s;
163
- case "bl":
164
- return i ? s + (i.height - 1) * r : s;
165
- case "br":
166
- return n.lastIndexOf(t);
167
- }
168
- }
169
- function hn(t, e) {
170
- return e.flatMap((n, r) => t.includes(n) ? [r] : []);
171
- }
172
- function Ue(t, e, n) {
173
- if (n)
174
- return n.includes(e);
175
- const r = t[e];
176
- return r == null || r.hasAttribute("disabled") || r.getAttribute("aria-disabled") === "true";
177
- }
178
- var G = typeof document < "u" ? en : tn;
179
- function Pe() {
180
- return Pe = Object.assign ? Object.assign.bind() : function(t) {
181
- for (var e = 1; e < arguments.length; e++) {
182
- var n = arguments[e];
183
- for (var r in n)
184
- Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
185
- }
186
- return t;
187
- }, Pe.apply(this, arguments);
24
+ return () => {
25
+ o.forEach((i) => i == null ? void 0 : i());
26
+ };
27
+ }, e);
28
+ return c.useMemo(() => e.every((n) => n == null) ? null : (n) => {
29
+ t.current && (t.current(), t.current = void 0), n != null && (t.current = r(n));
30
+ }, e);
188
31
  }
189
- let Rt = !1, En = 0;
190
- const yt = () => (
32
+ const On = "data-floating-ui-focusable", Ct = "active", Mt = "selected", _e = "ArrowLeft", Ke = "ArrowRight", on = "ArrowUp", Je = "ArrowDown", Ln = {
33
+ ...c
34
+ };
35
+ let Pt = !1, Fn = 0;
36
+ const kt = () => (
191
37
  // Ensure the id is unique with multiple independent versions of Floating UI
192
38
  // on <React 18
193
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + En++
39
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + Fn++
194
40
  );
195
- function Rn() {
196
- const [t, e] = u.useState(() => Rt ? yt() : void 0);
197
- return G(() => {
198
- t == null && e(yt());
199
- }, []), u.useEffect(() => {
200
- Rt = !0;
201
- }, []), t;
41
+ function Sn() {
42
+ const [e, t] = c.useState(() => Pt ? kt() : void 0);
43
+ return ee(() => {
44
+ e == null && t(kt());
45
+ }, []), c.useEffect(() => {
46
+ Pt = !0;
47
+ }, []), e;
202
48
  }
203
- const yn = Xt.useId, Ve = yn || Rn;
49
+ const Dn = Ln.useId, We = Dn || Sn;
204
50
  let Ne;
205
51
  process.env.NODE_ENV !== "production" && (Ne = /* @__PURE__ */ new Set());
206
- function $e() {
207
- for (var t, e = arguments.length, n = new Array(e), r = 0; r < e; r++)
208
- n[r] = arguments[r];
209
- const o = "Floating UI: " + n.join(" ");
210
- if (!((t = Ne) != null && t.has(o))) {
211
- var s;
212
- (s = Ne) == null || s.add(o), console.warn(o);
52
+ function ze() {
53
+ for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++)
54
+ r[n] = arguments[n];
55
+ const o = "Floating UI: " + r.join(" ");
56
+ if (!((e = Ne) != null && e.has(o))) {
57
+ var i;
58
+ (i = Ne) == null || i.add(o), console.warn(o);
213
59
  }
214
60
  }
215
- function xn() {
216
- for (var t, e = arguments.length, n = new Array(e), r = 0; r < e; r++)
217
- n[r] = arguments[r];
218
- const o = "Floating UI: " + n.join(" ");
219
- if (!((t = Ne) != null && t.has(o))) {
220
- var s;
221
- (s = Ne) == null || s.add(o), console.error(o);
61
+ function An() {
62
+ for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++)
63
+ r[n] = arguments[n];
64
+ const o = "Floating UI: " + r.join(" ");
65
+ if (!((e = Ne) != null && e.has(o))) {
66
+ var i;
67
+ (i = Ne) == null || i.add(o), console.error(o);
222
68
  }
223
69
  }
224
- const zn = /* @__PURE__ */ u.forwardRef(function(e, n) {
70
+ const lr = /* @__PURE__ */ c.forwardRef(function(t, r) {
225
71
  const {
226
72
  context: {
227
- placement: r,
73
+ placement: n,
228
74
  elements: {
229
75
  floating: o
230
76
  },
231
77
  middlewareData: {
232
- arrow: s,
233
- shift: i
78
+ arrow: i,
79
+ shift: s
234
80
  }
235
81
  },
236
- width: c = 14,
237
- height: v = 7,
238
- tipRadius: f = 0,
239
- strokeWidth: m = 0,
240
- staticOffset: b,
241
- stroke: p,
242
- d: l,
82
+ width: a = 14,
83
+ height: g = 7,
84
+ tipRadius: m = 0,
85
+ strokeWidth: R = 0,
86
+ staticOffset: x,
87
+ stroke: E,
88
+ d: f,
243
89
  style: {
244
- transform: g,
245
- ...a
90
+ transform: v,
91
+ ...l
246
92
  } = {},
247
- ...k
248
- } = e;
249
- process.env.NODE_ENV !== "production" && (n || $e("The `ref` prop is required for `FloatingArrow`."));
250
- const A = Ve(), [N, h] = u.useState(!1);
251
- if (G(() => {
93
+ ...w
94
+ } = t;
95
+ process.env.NODE_ENV !== "production" && (r || ze("The `ref` prop is required for `FloatingArrow`."));
96
+ const k = We(), [b, h] = c.useState(!1);
97
+ if (ee(() => {
252
98
  if (!o) return;
253
- qt(o).direction === "rtl" && h(!0);
99
+ Jt(o).direction === "rtl" && h(!0);
254
100
  }, [o]), !o)
255
101
  return null;
256
- const [F, Y] = r.split("-"), V = F === "top" || F === "bottom";
257
- let X = b;
258
- (V && i != null && i.x || !V && i != null && i.y) && (X = null);
259
- const q = m * 2, U = q / 2, $ = c / 2 * (f / -8 + 1), B = v / 2 * f / 4, R = !!l, I = X && Y === "end" ? "bottom" : "top";
260
- let E = X && Y === "end" ? "right" : "left";
261
- X && N && (E = Y === "end" ? "left" : "right");
262
- const w = (s == null ? void 0 : s.x) != null ? X || s.x : "", y = (s == null ? void 0 : s.y) != null ? X || s.y : "", x = l || "M0,0" + (" H" + c) + (" L" + (c - $) + "," + (v - B)) + (" Q" + c / 2 + "," + v + " " + $ + "," + (v - B)) + " Z", T = {
263
- top: R ? "rotate(180deg)" : "",
264
- left: R ? "rotate(90deg)" : "rotate(-90deg)",
265
- bottom: R ? "" : "rotate(180deg)",
266
- right: R ? "rotate(-90deg)" : "rotate(90deg)"
267
- }[F];
268
- return /* @__PURE__ */ u.createElement("svg", Pe({}, k, {
102
+ const [T, $] = n.split("-"), H = T === "top" || T === "bottom";
103
+ let B = x;
104
+ (H && s != null && s.x || !H && s != null && s.y) && (B = null);
105
+ const _ = R * 2, oe = _ / 2, j = a / 2 * (m / -8 + 1), q = g / 2 * m / 4, X = !!f, F = B && $ === "end" ? "bottom" : "top";
106
+ let u = B && $ === "end" ? "right" : "left";
107
+ B && b && (u = $ === "end" ? "left" : "right");
108
+ const p = (i == null ? void 0 : i.x) != null ? B || i.x : "", K = (i == null ? void 0 : i.y) != null ? B || i.y : "", y = f || "M0,0" + (" H" + a) + (" L" + (a - j) + "," + (g - q)) + (" Q" + a / 2 + "," + g + " " + j + "," + (g - q)) + " Z", d = {
109
+ top: X ? "rotate(180deg)" : "",
110
+ left: X ? "rotate(90deg)" : "rotate(-90deg)",
111
+ bottom: X ? "" : "rotate(180deg)",
112
+ right: X ? "rotate(-90deg)" : "rotate(90deg)"
113
+ }[T];
114
+ return /* @__PURE__ */ gt("svg", {
115
+ ...w,
269
116
  "aria-hidden": !0,
270
- ref: n,
271
- width: R ? c : c + q,
272
- height: c,
273
- viewBox: "0 0 " + c + " " + (v > c ? v : c),
117
+ ref: r,
118
+ width: X ? a : a + _,
119
+ height: a,
120
+ viewBox: "0 0 " + a + " " + (g > a ? g : a),
274
121
  style: {
275
122
  position: "absolute",
276
123
  pointerEvents: "none",
277
- [E]: w,
278
- [I]: y,
279
- [F]: V || R ? "100%" : "calc(100% - " + q / 2 + "px)",
280
- transform: [T, g].filter((d) => !!d).join(" "),
281
- ...a
282
- }
283
- }), q > 0 && /* @__PURE__ */ u.createElement("path", {
284
- clipPath: "url(#" + A + ")",
285
- fill: "none",
286
- stroke: p,
287
- strokeWidth: q + (l ? 0 : 1),
288
- d: x
289
- }), /* @__PURE__ */ u.createElement("path", {
290
- stroke: q && !l ? k.fill : "none",
291
- d: x
292
- }), /* @__PURE__ */ u.createElement("clipPath", {
293
- id: A
294
- }, /* @__PURE__ */ u.createElement("rect", {
295
- x: -U,
296
- y: U * (R ? -1 : 1),
297
- width: c + q,
298
- height: c
299
- })));
124
+ [u]: p,
125
+ [F]: K,
126
+ [T]: H || X ? "100%" : "calc(100% - " + _ / 2 + "px)",
127
+ transform: [d, v].filter((I) => !!I).join(" "),
128
+ ...l
129
+ },
130
+ children: [_ > 0 && /* @__PURE__ */ ve("path", {
131
+ clipPath: "url(#" + k + ")",
132
+ fill: "none",
133
+ stroke: E,
134
+ strokeWidth: _ + (f ? 0 : 1),
135
+ d: y
136
+ }), /* @__PURE__ */ ve("path", {
137
+ stroke: _ && !f ? w.fill : "none",
138
+ d: y
139
+ }), /* @__PURE__ */ ve("clipPath", {
140
+ id: k,
141
+ children: /* @__PURE__ */ ve("rect", {
142
+ x: -oe,
143
+ y: oe * (X ? -1 : 1),
144
+ width: a + _,
145
+ height: a
146
+ })
147
+ })]
148
+ });
300
149
  });
301
- function wn() {
302
- const t = /* @__PURE__ */ new Map();
150
+ function Nn() {
151
+ const e = /* @__PURE__ */ new Map();
303
152
  return {
304
- emit(e, n) {
305
- var r;
306
- (r = t.get(e)) == null || r.forEach((o) => o(n));
153
+ emit(t, r) {
154
+ var n;
155
+ (n = e.get(t)) == null || n.forEach((o) => o(r));
307
156
  },
308
- on(e, n) {
309
- t.set(e, [...t.get(e) || [], n]);
157
+ on(t, r) {
158
+ e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(r);
310
159
  },
311
- off(e, n) {
312
- var r;
313
- t.set(e, ((r = t.get(e)) == null ? void 0 : r.filter((o) => o !== n)) || []);
160
+ off(t, r) {
161
+ var n;
162
+ (n = e.get(t)) == null || n.delete(r);
314
163
  }
315
164
  };
316
165
  }
317
- const In = /* @__PURE__ */ u.createContext(null), Tn = /* @__PURE__ */ u.createContext(null), We = () => {
318
- var t;
319
- return ((t = u.useContext(In)) == null ? void 0 : t.id) || null;
320
- }, ke = () => u.useContext(Tn);
321
- function Gn(t) {
322
- const e = Ve(), n = ke(), o = We();
323
- return G(() => {
324
- const s = {
325
- id: e,
166
+ const _n = /* @__PURE__ */ c.createContext(null), Kn = /* @__PURE__ */ c.createContext(null), Ve = () => {
167
+ var e;
168
+ return ((e = c.useContext(_n)) == null ? void 0 : e.id) || null;
169
+ }, Oe = () => c.useContext(Kn);
170
+ function ar(e) {
171
+ const t = We(), r = Oe(), o = Ve();
172
+ return ee(() => {
173
+ if (!t) return;
174
+ const i = {
175
+ id: t,
326
176
  parentId: o
327
177
  };
328
- return n == null || n.addNode(s), () => {
329
- n == null || n.removeNode(s);
178
+ return r == null || r.addNode(i), () => {
179
+ r == null || r.removeNode(i);
330
180
  };
331
- }, [n, e, o]), e;
181
+ }, [r, t, o]), t;
182
+ }
183
+ function Pe(e) {
184
+ return "data-floating-ui-" + e;
332
185
  }
333
- function Oe(t) {
334
- return "data-floating-ui-" + t;
186
+ function me(e) {
187
+ e.current !== -1 && (clearTimeout(e.current), e.current = -1);
335
188
  }
336
- function fe(t) {
337
- const e = nn(t);
338
- return G(() => {
339
- e.current = t;
340
- }), e;
189
+ const Ot = /* @__PURE__ */ Pe("safe-polygon");
190
+ function it(e, t, r) {
191
+ if (r && !Ae(r))
192
+ return 0;
193
+ if (typeof e == "number")
194
+ return e;
195
+ if (typeof e == "function") {
196
+ const n = e();
197
+ return typeof n == "number" ? n : n == null ? void 0 : n[t];
198
+ }
199
+ return e == null ? void 0 : e[t];
341
200
  }
342
- const xt = /* @__PURE__ */ Oe("safe-polygon");
343
- function nt(t, e, n) {
344
- return n && !Ae(n) ? 0 : typeof t == "number" ? t : t == null ? void 0 : t[e];
201
+ function ut(e) {
202
+ return typeof e == "function" ? e() : e;
345
203
  }
346
- function Qn(t, e) {
347
- e === void 0 && (e = {});
204
+ function fr(e, t) {
205
+ t === void 0 && (t = {});
348
206
  const {
349
- open: n,
350
- onOpenChange: r,
207
+ open: r,
208
+ onOpenChange: n,
351
209
  dataRef: o,
352
- events: s,
353
- elements: i
354
- } = t, {
355
- enabled: c = !0,
356
- delay: v = 0,
357
- handleClose: f = null,
358
- mouseOnly: m = !1,
359
- restMs: b = 0,
360
- move: p = !0
361
- } = e, l = ke(), g = We(), a = fe(f), k = fe(v), A = fe(n), N = u.useRef(), h = u.useRef(-1), F = u.useRef(), Y = u.useRef(-1), V = u.useRef(!0), X = u.useRef(!1), q = u.useRef(() => {
362
- }), U = u.useRef(!1), $ = u.useCallback(() => {
363
- var x;
364
- const T = (x = o.current.openEvent) == null ? void 0 : x.type;
365
- return (T == null ? void 0 : T.includes("mouse")) && T !== "mousedown";
366
- }, [o]);
367
- u.useEffect(() => {
368
- if (!c) return;
369
- function x(T) {
210
+ events: i,
211
+ elements: s
212
+ } = e, {
213
+ enabled: a = !0,
214
+ delay: g = 0,
215
+ handleClose: m = null,
216
+ mouseOnly: R = !1,
217
+ restMs: x = 0,
218
+ move: E = !0
219
+ } = t, f = Oe(), v = Ve(), l = Re(m), w = Re(g), k = Re(r), b = Re(x), h = c.useRef(), T = c.useRef(-1), $ = c.useRef(), H = c.useRef(-1), B = c.useRef(!0), _ = c.useRef(!1), oe = c.useRef(() => {
220
+ }), j = c.useRef(!1), q = ce(() => {
221
+ var y;
222
+ const d = (y = o.current.openEvent) == null ? void 0 : y.type;
223
+ return (d == null ? void 0 : d.includes("mouse")) && d !== "mousedown";
224
+ });
225
+ c.useEffect(() => {
226
+ if (!a) return;
227
+ function y(d) {
370
228
  let {
371
- open: d
372
- } = T;
373
- d || (clearTimeout(h.current), clearTimeout(Y.current), V.current = !0, U.current = !1);
229
+ open: I
230
+ } = d;
231
+ I || (me(T), me(H), B.current = !0, j.current = !1);
374
232
  }
375
- return s.on("openchange", x), () => {
376
- s.off("openchange", x);
233
+ return i.on("openchange", y), () => {
234
+ i.off("openchange", y);
377
235
  };
378
- }, [c, s]), u.useEffect(() => {
379
- if (!c || !a.current || !n) return;
380
- function x(d) {
381
- $() && r(!1, d, "hover");
236
+ }, [a, i]), c.useEffect(() => {
237
+ if (!a || !l.current || !r) return;
238
+ function y(I) {
239
+ q() && n(!1, I, "hover");
382
240
  }
383
- const T = re(i.floating).documentElement;
384
- return T.addEventListener("mouseleave", x), () => {
385
- T.removeEventListener("mouseleave", x);
241
+ const d = ge(s.floating).documentElement;
242
+ return d.addEventListener("mouseleave", y), () => {
243
+ d.removeEventListener("mouseleave", y);
386
244
  };
387
- }, [i.floating, n, r, c, a, $]);
388
- const B = u.useCallback(function(x, T, d) {
389
- T === void 0 && (T = !0), d === void 0 && (d = "hover");
390
- const C = nt(k.current, "close", N.current);
391
- C && !F.current ? (clearTimeout(h.current), h.current = window.setTimeout(() => r(!1, x, d), C)) : T && (clearTimeout(h.current), r(!1, x, d));
392
- }, [k, r]), R = ue(() => {
393
- q.current(), F.current = void 0;
394
- }), I = ue(() => {
395
- if (X.current) {
396
- const x = re(i.floating).body;
397
- x.style.pointerEvents = "", x.removeAttribute(xt), X.current = !1;
245
+ }, [s.floating, r, n, a, l, q]);
246
+ const X = c.useCallback(function(y, d, I) {
247
+ d === void 0 && (d = !0), I === void 0 && (I = "hover");
248
+ const O = it(w.current, "close", h.current);
249
+ O && !$.current ? (me(T), T.current = window.setTimeout(() => n(!1, y, I), O)) : d && (me(T), n(!1, y, I));
250
+ }, [w, n]), F = ce(() => {
251
+ oe.current(), $.current = void 0;
252
+ }), u = ce(() => {
253
+ if (_.current) {
254
+ const y = ge(s.floating).body;
255
+ y.style.pointerEvents = "", y.removeAttribute(Ot), _.current = !1;
398
256
  }
399
- }), E = ue(() => o.current.openEvent ? ["click", "mousedown"].includes(o.current.openEvent.type) : !1);
400
- u.useEffect(() => {
401
- if (!c) return;
402
- function x(O) {
403
- if (clearTimeout(h.current), V.current = !1, m && !Ae(N.current) || b > 0 && !nt(k.current, "open"))
257
+ }), p = ce(() => o.current.openEvent ? ["click", "mousedown"].includes(o.current.openEvent.type) : !1);
258
+ c.useEffect(() => {
259
+ if (!a) return;
260
+ function y(S) {
261
+ if (me(T), B.current = !1, R && !Ae(h.current) || ut(b.current) > 0 && !it(w.current, "open"))
404
262
  return;
405
- const H = nt(k.current, "open", N.current);
406
- H ? h.current = window.setTimeout(() => {
407
- A.current || r(!0, O, "hover");
408
- }, H) : n || r(!0, O, "hover");
263
+ const M = it(w.current, "open", h.current);
264
+ M ? T.current = window.setTimeout(() => {
265
+ k.current || n(!0, S, "hover");
266
+ }, M) : r || n(!0, S, "hover");
409
267
  }
410
- function T(O) {
411
- if (E()) return;
412
- q.current();
413
- const H = re(i.floating);
414
- if (clearTimeout(Y.current), U.current = !1, a.current && o.current.floatingContext) {
415
- n || clearTimeout(h.current), F.current = a.current({
268
+ function d(S) {
269
+ if (p()) {
270
+ u();
271
+ return;
272
+ }
273
+ oe.current();
274
+ const M = ge(s.floating);
275
+ if (me(H), j.current = !1, l.current && o.current.floatingContext) {
276
+ r || me(T), $.current = l.current({
416
277
  ...o.current.floatingContext,
417
- tree: l,
418
- x: O.clientX,
419
- y: O.clientY,
278
+ tree: f,
279
+ x: S.clientX,
280
+ y: S.clientY,
420
281
  onClose() {
421
- I(), R(), E() || B(O, !0, "safe-polygon");
282
+ u(), F(), p() || X(S, !0, "safe-polygon");
422
283
  }
423
284
  });
424
- const L = F.current;
425
- H.addEventListener("mousemove", L), q.current = () => {
426
- H.removeEventListener("mousemove", L);
285
+ const N = $.current;
286
+ M.addEventListener("mousemove", N), oe.current = () => {
287
+ M.removeEventListener("mousemove", N);
427
288
  };
428
289
  return;
429
290
  }
430
- (N.current === "touch" ? !ee(i.floating, O.relatedTarget) : !0) && B(O);
291
+ (h.current === "touch" ? !ae(s.floating, S.relatedTarget) : !0) && X(S);
431
292
  }
432
- function d(O) {
433
- E() || o.current.floatingContext && (a.current == null || a.current({
293
+ function I(S) {
294
+ p() || o.current.floatingContext && (l.current == null || l.current({
434
295
  ...o.current.floatingContext,
435
- tree: l,
436
- x: O.clientX,
437
- y: O.clientY,
296
+ tree: f,
297
+ x: S.clientX,
298
+ y: S.clientY,
438
299
  onClose() {
439
- I(), R(), E() || B(O);
300
+ u(), F(), p() || X(S);
440
301
  }
441
- })(O));
302
+ })(S));
303
+ }
304
+ function O() {
305
+ me(T);
306
+ }
307
+ function G(S) {
308
+ p() || X(S, !1);
442
309
  }
443
- if (oe(i.domReference)) {
444
- var C;
445
- const O = i.domReference;
446
- return n && O.addEventListener("mouseleave", d), (C = i.floating) == null || C.addEventListener("mouseleave", d), p && O.addEventListener("mousemove", x, {
310
+ if (fe(s.domReference)) {
311
+ const S = s.domReference, M = s.floating;
312
+ return r && S.addEventListener("mouseleave", I), E && S.addEventListener("mousemove", y, {
447
313
  once: !0
448
- }), O.addEventListener("mouseenter", x), O.addEventListener("mouseleave", T), () => {
449
- var H;
450
- n && O.removeEventListener("mouseleave", d), (H = i.floating) == null || H.removeEventListener("mouseleave", d), p && O.removeEventListener("mousemove", x), O.removeEventListener("mouseenter", x), O.removeEventListener("mouseleave", T);
314
+ }), S.addEventListener("mouseenter", y), S.addEventListener("mouseleave", d), M && (M.addEventListener("mouseleave", I), M.addEventListener("mouseenter", O), M.addEventListener("mouseleave", G)), () => {
315
+ r && S.removeEventListener("mouseleave", I), E && S.removeEventListener("mousemove", y), S.removeEventListener("mouseenter", y), S.removeEventListener("mouseleave", d), M && (M.removeEventListener("mouseleave", I), M.removeEventListener("mouseenter", O), M.removeEventListener("mouseleave", G));
451
316
  };
452
317
  }
453
- }, [i, c, t, m, b, p, B, R, I, r, n, A, l, k, a, o, E]), G(() => {
454
- var x;
455
- if (c && n && (x = a.current) != null && x.__options.blockPointerEvents && $()) {
456
- X.current = !0;
457
- const d = i.floating;
458
- if (oe(i.domReference) && d) {
459
- var T;
460
- const C = re(i.floating).body;
461
- C.setAttribute(xt, "");
462
- const O = i.domReference, H = l == null || (T = l.nodesRef.current.find((ne) => ne.id === g)) == null || (T = T.context) == null ? void 0 : T.elements.floating;
463
- return H && (H.style.pointerEvents = ""), C.style.pointerEvents = "none", O.style.pointerEvents = "auto", d.style.pointerEvents = "auto", () => {
464
- C.style.pointerEvents = "", O.style.pointerEvents = "", d.style.pointerEvents = "";
318
+ }, [s, a, e, R, E, X, F, u, n, r, k, f, w, l, o, p, b]), ee(() => {
319
+ var y;
320
+ if (a && r && (y = l.current) != null && (y = y.__options) != null && y.blockPointerEvents && q()) {
321
+ _.current = !0;
322
+ const I = s.floating;
323
+ if (fe(s.domReference) && I) {
324
+ var d;
325
+ const O = ge(s.floating).body;
326
+ O.setAttribute(Ot, "");
327
+ const G = s.domReference, S = f == null || (d = f.nodesRef.current.find((M) => M.id === v)) == null || (d = d.context) == null ? void 0 : d.elements.floating;
328
+ return S && (S.style.pointerEvents = ""), O.style.pointerEvents = "none", G.style.pointerEvents = "auto", I.style.pointerEvents = "auto", () => {
329
+ O.style.pointerEvents = "", G.style.pointerEvents = "", I.style.pointerEvents = "";
465
330
  };
466
331
  }
467
332
  }
468
- }, [c, n, g, i, l, a, $]), G(() => {
469
- n || (N.current = void 0, U.current = !1, R(), I());
470
- }, [n, R, I]), u.useEffect(() => () => {
471
- R(), clearTimeout(h.current), clearTimeout(Y.current), I();
472
- }, [c, i.domReference, R, I]);
473
- const w = u.useMemo(() => {
474
- function x(T) {
475
- N.current = T.pointerType;
333
+ }, [a, r, v, s, f, l, q]), ee(() => {
334
+ r || (h.current = void 0, j.current = !1, F(), u());
335
+ }, [r, F, u]), c.useEffect(() => () => {
336
+ F(), me(T), me(H), u();
337
+ }, [a, s.domReference, F, u]);
338
+ const K = c.useMemo(() => {
339
+ function y(d) {
340
+ h.current = d.pointerType;
476
341
  }
477
342
  return {
478
- onPointerDown: x,
479
- onPointerEnter: x,
480
- onMouseMove(T) {
343
+ onPointerDown: y,
344
+ onPointerEnter: y,
345
+ onMouseMove(d) {
481
346
  const {
482
- nativeEvent: d
483
- } = T;
484
- function C() {
485
- !V.current && !A.current && r(!0, d, "hover");
347
+ nativeEvent: I
348
+ } = d;
349
+ function O() {
350
+ !B.current && !k.current && n(!0, I, "hover");
486
351
  }
487
- m && !Ae(N.current) || n || b === 0 || U.current && T.movementX ** 2 + T.movementY ** 2 < 2 || (clearTimeout(Y.current), N.current === "touch" ? C() : (U.current = !0, Y.current = window.setTimeout(C, b)));
352
+ R && !Ae(h.current) || r || ut(b.current) === 0 || j.current && d.movementX ** 2 + d.movementY ** 2 < 2 || (me(H), h.current === "touch" ? O() : (j.current = !0, H.current = window.setTimeout(O, ut(b.current))));
488
353
  }
489
354
  };
490
- }, [m, r, n, A, b]), y = u.useMemo(() => ({
491
- onMouseEnter() {
492
- clearTimeout(h.current);
493
- },
494
- onMouseLeave(x) {
495
- E() || B(x.nativeEvent, !1);
496
- }
497
- }), [B, E]);
498
- return u.useMemo(() => c ? {
499
- reference: w,
500
- floating: y
501
- } : {}, [c, w, y]);
355
+ }, [R, n, r, k, b]);
356
+ return c.useMemo(() => a ? {
357
+ reference: K
358
+ } : {}, [a, K]);
502
359
  }
503
- let wt = 0;
504
- function Re(t, e) {
505
- e === void 0 && (e = {});
360
+ let Lt = 0;
361
+ function Me(e, t) {
362
+ t === void 0 && (t = {});
506
363
  const {
507
- preventScroll: n = !1,
508
- cancelPrevious: r = !0,
364
+ preventScroll: r = !1,
365
+ cancelPrevious: n = !0,
509
366
  sync: o = !1
510
- } = e;
511
- r && cancelAnimationFrame(wt);
512
- const s = () => t == null ? void 0 : t.focus({
513
- preventScroll: n
367
+ } = t;
368
+ n && cancelAnimationFrame(Lt);
369
+ const i = () => e == null ? void 0 : e.focus({
370
+ preventScroll: r
514
371
  });
515
- o ? s() : wt = requestAnimationFrame(s);
372
+ o ? i() : Lt = requestAnimationFrame(i);
516
373
  }
517
- function Cn(t, e) {
518
- var n;
519
- let r = [], o = (n = t.find((s) => s.id === e)) == null ? void 0 : n.parentId;
520
- for (; o; ) {
521
- const s = t.find((i) => i.id === o);
522
- o = s == null ? void 0 : s.parentId, s && (r = r.concat(s));
374
+ function ct(e, t) {
375
+ if (!e || !t)
376
+ return !1;
377
+ const r = t.getRootNode == null ? void 0 : t.getRootNode();
378
+ if (e.contains(t))
379
+ return !0;
380
+ if (r && tn(r)) {
381
+ let n = t;
382
+ for (; n; ) {
383
+ if (e === n)
384
+ return !0;
385
+ n = n.parentNode || n.host;
386
+ }
523
387
  }
524
- return r;
388
+ return !1;
525
389
  }
526
- function Ce(t, e) {
527
- let n = t.filter((o) => {
528
- var s;
529
- return o.parentId === e && ((s = o.context) == null ? void 0 : s.open);
530
- }), r = n;
531
- for (; r.length; )
532
- r = t.filter((o) => {
533
- var s;
534
- return (s = r) == null ? void 0 : s.some((i) => {
535
- var c;
536
- return o.parentId === i.id && ((c = o.context) == null ? void 0 : c.open);
537
- });
538
- }), n = n.concat(r);
539
- return n;
390
+ function Wn(e) {
391
+ return "composedPath" in e ? e.composedPath()[0] : e.target;
540
392
  }
541
- function On(t, e) {
542
- let n, r = -1;
543
- function o(s, i) {
544
- i > r && (n = s, r = i), Ce(t, s).forEach((v) => {
545
- o(v.id, i + 1);
546
- });
547
- }
548
- return o(e, 0), t.find((s) => s.id === n);
393
+ function Vn(e) {
394
+ return (e == null ? void 0 : e.ownerDocument) || document;
549
395
  }
550
- let Me = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakSet(), Xe = {}, rt = 0;
551
- const Mn = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype, Yt = (t) => t && (t.host || Yt(t.parentNode)), Pn = (t, e) => e.map((n) => {
552
- if (t.contains(n))
553
- return n;
554
- const r = Yt(n);
555
- return t.contains(r) ? r : null;
556
- }).filter((n) => n != null);
557
- function kn(t, e, n, r) {
558
- const o = "data-floating-ui-inert", s = r ? "inert" : n ? "aria-hidden" : null, i = Pn(e, t), c = /* @__PURE__ */ new Set(), v = new Set(i), f = [];
559
- Xe[o] || (Xe[o] = /* @__PURE__ */ new WeakMap());
560
- const m = Xe[o];
561
- i.forEach(b), p(e), c.clear();
562
- function b(l) {
563
- !l || c.has(l) || (c.add(l), l.parentNode && b(l.parentNode));
396
+ const ke = {
397
+ inert: /* @__PURE__ */ new WeakMap(),
398
+ "aria-hidden": /* @__PURE__ */ new WeakMap(),
399
+ none: /* @__PURE__ */ new WeakMap()
400
+ };
401
+ function Ft(e) {
402
+ return e === "inert" ? ke.inert : e === "aria-hidden" ? ke["aria-hidden"] : ke.none;
403
+ }
404
+ let Xe = /* @__PURE__ */ new WeakSet(), Ge = {}, lt = 0;
405
+ const Hn = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype;
406
+ function sn(e) {
407
+ return e ? tn(e) ? e.host : sn(e.parentNode) : null;
408
+ }
409
+ const Bn = (e, t) => t.map((r) => {
410
+ if (e.contains(r))
411
+ return r;
412
+ const n = sn(r);
413
+ return e.contains(n) ? n : null;
414
+ }).filter((r) => r != null);
415
+ function $n(e, t, r, n) {
416
+ const o = "data-floating-ui-inert", i = n ? "inert" : r ? "aria-hidden" : null, s = Bn(t, e), a = /* @__PURE__ */ new Set(), g = new Set(s), m = [];
417
+ Ge[o] || (Ge[o] = /* @__PURE__ */ new WeakMap());
418
+ const R = Ge[o];
419
+ s.forEach(x), E(t), a.clear();
420
+ function x(f) {
421
+ !f || a.has(f) || (a.add(f), f.parentNode && x(f.parentNode));
564
422
  }
565
- function p(l) {
566
- !l || v.has(l) || [].forEach.call(l.children, (g) => {
567
- if (jt(g) !== "script")
568
- if (c.has(g))
569
- p(g);
423
+ function E(f) {
424
+ !f || g.has(f) || [].forEach.call(f.children, (v) => {
425
+ if (en(v) !== "script")
426
+ if (a.has(v))
427
+ E(v);
570
428
  else {
571
- const a = s ? g.getAttribute(s) : null, k = a !== null && a !== "false", A = (Me.get(g) || 0) + 1, N = (m.get(g) || 0) + 1;
572
- Me.set(g, A), m.set(g, N), f.push(g), A === 1 && k && je.add(g), N === 1 && g.setAttribute(o, ""), !k && s && g.setAttribute(s, "true");
429
+ const l = i ? v.getAttribute(i) : null, w = l !== null && l !== "false", k = Ft(i), b = (k.get(v) || 0) + 1, h = (R.get(v) || 0) + 1;
430
+ k.set(v, b), R.set(v, h), m.push(v), b === 1 && w && Xe.add(v), h === 1 && v.setAttribute(o, ""), !w && i && v.setAttribute(i, i === "inert" ? "" : "true");
573
431
  }
574
432
  });
575
433
  }
576
- return rt++, () => {
577
- f.forEach((l) => {
578
- const g = (Me.get(l) || 0) - 1, a = (m.get(l) || 0) - 1;
579
- Me.set(l, g), m.set(l, a), g || (!je.has(l) && s && l.removeAttribute(s), je.delete(l)), a || l.removeAttribute(o);
580
- }), rt--, rt || (Me = /* @__PURE__ */ new WeakMap(), Me = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakSet(), Xe = {});
434
+ return lt++, () => {
435
+ m.forEach((f) => {
436
+ const v = Ft(i), w = (v.get(f) || 0) - 1, k = (R.get(f) || 0) - 1;
437
+ v.set(f, w), R.set(f, k), w || (!Xe.has(f) && i && f.removeAttribute(i), Xe.delete(f)), k || f.removeAttribute(o);
438
+ }), lt--, lt || (ke.inert = /* @__PURE__ */ new WeakMap(), ke["aria-hidden"] = /* @__PURE__ */ new WeakMap(), ke.none = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakSet(), Ge = {});
581
439
  };
582
440
  }
583
- function It(t, e, n) {
584
- e === void 0 && (e = !1), n === void 0 && (n = !1);
585
- const r = re(t[0]).body;
586
- return kn(t.concat(Array.from(r.querySelectorAll("[aria-live]"))), r, e, n);
587
- }
588
- const Ke = () => ({
589
- getShadowRoot: !0,
590
- displayCheck: (
591
- // JSDOM does not support the `tabbable` library. To solve this we can
592
- // check if `ResizeObserver` is a real function (not polyfilled), which
593
- // determines if the current environment is JSDOM-like.
594
- typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
595
- )
596
- });
597
- function Ut(t, e) {
598
- const n = Ge(t, Ke());
599
- e === "prev" && n.reverse();
600
- const r = n.indexOf(ae(re(t)));
601
- return n.slice(r + 1)[0];
602
- }
603
- function $t() {
604
- return Ut(document.body, "next");
605
- }
606
- function zt() {
607
- return Ut(document.body, "prev");
608
- }
609
- function De(t, e) {
610
- const n = e || t.currentTarget, r = t.relatedTarget;
611
- return !r || !ee(n, r);
612
- }
613
- function Fn(t) {
614
- Ge(t, Ke()).forEach((n) => {
615
- n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
616
- });
617
- }
618
- function Tt(t) {
619
- t.querySelectorAll("[data-tabindex]").forEach((n) => {
620
- const r = n.dataset.tabindex;
621
- delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
622
- });
441
+ function St(e, t, r) {
442
+ t === void 0 && (t = !1), r === void 0 && (r = !1);
443
+ const n = Vn(e[0]).body;
444
+ return $n(e.concat(Array.from(n.querySelectorAll('[aria-live],[role="status"],output'))), n, t, r);
623
445
  }
624
- const Qe = {
446
+ const vt = {
625
447
  border: 0,
626
448
  clip: "rect(0 0 0 0)",
627
449
  height: "1px",
@@ -633,399 +455,440 @@ const Qe = {
633
455
  width: "1px",
634
456
  top: 0,
635
457
  left: 0
636
- };
637
- let Ln;
638
- function Ct(t) {
639
- t.key === "Tab" && (t.target, clearTimeout(Ln));
640
- }
641
- const ze = /* @__PURE__ */ u.forwardRef(function(e, n) {
642
- const [r, o] = u.useState();
643
- G(() => (at() && o("button"), document.addEventListener("keydown", Ct), () => {
644
- document.removeEventListener("keydown", Ct);
645
- }), []);
646
- const s = {
647
- ref: n,
458
+ }, Ze = /* @__PURE__ */ c.forwardRef(function(t, r) {
459
+ const [n, o] = c.useState();
460
+ ee(() => {
461
+ Zt() && o("button");
462
+ }, []);
463
+ const i = {
464
+ ref: r,
648
465
  tabIndex: 0,
649
466
  // Role is only for VoiceOver
650
- role: r,
651
- "aria-hidden": r ? void 0 : !0,
652
- [Oe("focus-guard")]: "",
653
- style: Qe
467
+ role: n,
468
+ "aria-hidden": n ? void 0 : !0,
469
+ [Pe("focus-guard")]: "",
470
+ style: vt
654
471
  };
655
- return /* @__PURE__ */ u.createElement("span", Pe({}, e, s));
656
- }), Gt = /* @__PURE__ */ u.createContext(null), Ot = /* @__PURE__ */ Oe("portal");
657
- function Sn(t) {
658
- t === void 0 && (t = {});
472
+ return /* @__PURE__ */ ve("span", {
473
+ ...t,
474
+ ...i
475
+ });
476
+ }), Yn = {
477
+ clipPath: "inset(50%)",
478
+ position: "fixed",
479
+ top: 0,
480
+ left: 0
481
+ }, un = /* @__PURE__ */ c.createContext(null), Dt = /* @__PURE__ */ Pe("portal");
482
+ function qn(e) {
483
+ e === void 0 && (e = {});
659
484
  const {
660
- id: e,
661
- root: n
662
- } = t, r = Ve(), o = Qt(), [s, i] = u.useState(null), c = u.useRef(null);
663
- return G(() => () => {
664
- s == null || s.remove(), queueMicrotask(() => {
665
- c.current = null;
485
+ id: t,
486
+ root: r
487
+ } = e, n = We(), o = cn(), [i, s] = c.useState(null), a = c.useRef(null);
488
+ return ee(() => () => {
489
+ i == null || i.remove(), queueMicrotask(() => {
490
+ a.current = null;
666
491
  });
667
- }, [s]), G(() => {
668
- if (!r || c.current) return;
669
- const v = e ? document.getElementById(e) : null;
670
- if (!v) return;
671
- const f = document.createElement("div");
672
- f.id = r, f.setAttribute(Ot, ""), v.appendChild(f), c.current = f, i(f);
673
- }, [e, r]), G(() => {
674
- if (n === null || !r || c.current) return;
675
- let v = n || (o == null ? void 0 : o.portalNode);
676
- v && !oe(v) && (v = v.current), v = v || document.body;
677
- let f = null;
678
- e && (f = document.createElement("div"), f.id = e, v.appendChild(f));
492
+ }, [i]), ee(() => {
493
+ if (!n || a.current) return;
494
+ const g = t ? document.getElementById(t) : null;
495
+ if (!g) return;
679
496
  const m = document.createElement("div");
680
- m.id = r, m.setAttribute(Ot, ""), v = f || v, v.appendChild(m), c.current = m, i(m);
681
- }, [e, n, r, o]), s;
497
+ m.id = n, m.setAttribute(Dt, ""), g.appendChild(m), a.current = m, s(m);
498
+ }, [t, n]), ee(() => {
499
+ if (r === null || !n || a.current) return;
500
+ let g = r || (o == null ? void 0 : o.portalNode);
501
+ g && !Cn(g) && (g = g.current), g = g || document.body;
502
+ let m = null;
503
+ t && (m = document.createElement("div"), m.id = t, g.appendChild(m));
504
+ const R = document.createElement("div");
505
+ R.id = n, R.setAttribute(Dt, ""), g = m || g, g.appendChild(R), a.current = R, s(R);
506
+ }, [t, r, n, o]), i;
682
507
  }
683
- function Zn(t) {
508
+ function dr(e) {
684
509
  const {
685
- children: e,
686
- id: n,
687
- root: r,
510
+ children: t,
511
+ id: r,
512
+ root: n,
688
513
  preserveTabOrder: o = !0
689
- } = t, s = Sn({
690
- id: n,
691
- root: r
692
- }), [i, c] = u.useState(null), v = u.useRef(null), f = u.useRef(null), m = u.useRef(null), b = u.useRef(null), p = i == null ? void 0 : i.modal, l = i == null ? void 0 : i.open, g = (
514
+ } = e, i = qn({
515
+ id: r,
516
+ root: n
517
+ }), [s, a] = c.useState(null), g = c.useRef(null), m = c.useRef(null), R = c.useRef(null), x = c.useRef(null), E = s == null ? void 0 : s.modal, f = s == null ? void 0 : s.open, v = (
693
518
  // The FocusManager and therefore floating element are currently open/
694
519
  // rendered.
695
- !!i && // Guards are only for non-modal focus management.
696
- !i.modal && // Don't render if unmount is transitioning.
697
- i.open && o && !!(r || s)
520
+ !!s && // Guards are only for non-modal focus management.
521
+ !s.modal && // Don't render if unmount is transitioning.
522
+ s.open && o && !!(n || i)
698
523
  );
699
- return u.useEffect(() => {
700
- if (!s || !o || p)
524
+ return c.useEffect(() => {
525
+ if (!i || !o || E)
701
526
  return;
702
- function a(k) {
703
- s && De(k) && (k.type === "focusin" ? Tt : Fn)(s);
527
+ function l(w) {
528
+ i && De(w) && (w.type === "focusin" ? Tt : En)(i);
704
529
  }
705
- return s.addEventListener("focusin", a, !0), s.addEventListener("focusout", a, !0), () => {
706
- s.removeEventListener("focusin", a, !0), s.removeEventListener("focusout", a, !0);
530
+ return i.addEventListener("focusin", l, !0), i.addEventListener("focusout", l, !0), () => {
531
+ i.removeEventListener("focusin", l, !0), i.removeEventListener("focusout", l, !0);
707
532
  };
708
- }, [s, o, p]), u.useEffect(() => {
709
- s && (l || Tt(s));
710
- }, [l, s]), /* @__PURE__ */ u.createElement(Gt.Provider, {
711
- value: u.useMemo(() => ({
533
+ }, [i, o, E]), c.useEffect(() => {
534
+ i && (f || Tt(i));
535
+ }, [f, i]), /* @__PURE__ */ gt(un.Provider, {
536
+ value: c.useMemo(() => ({
712
537
  preserveTabOrder: o,
713
- beforeOutsideRef: v,
714
- afterOutsideRef: f,
715
- beforeInsideRef: m,
716
- afterInsideRef: b,
717
- portalNode: s,
718
- setFocusManagerState: c
719
- }), [o, s])
720
- }, g && s && /* @__PURE__ */ u.createElement(ze, {
721
- "data-type": "outside",
722
- ref: v,
723
- onFocus: (a) => {
724
- if (De(a, s)) {
725
- var k;
726
- (k = m.current) == null || k.focus();
727
- } else {
728
- const A = zt() || (i == null ? void 0 : i.refs.domReference.current);
729
- A == null || A.focus();
538
+ beforeOutsideRef: g,
539
+ afterOutsideRef: m,
540
+ beforeInsideRef: R,
541
+ afterInsideRef: x,
542
+ portalNode: i,
543
+ setFocusManagerState: a
544
+ }), [o, i]),
545
+ children: [v && i && /* @__PURE__ */ ve(Ze, {
546
+ "data-type": "outside",
547
+ ref: g,
548
+ onFocus: (l) => {
549
+ if (De(l, i)) {
550
+ var w;
551
+ (w = R.current) == null || w.focus();
552
+ } else {
553
+ const k = s ? s.domReference : null, b = zt(k);
554
+ b == null || b.focus();
555
+ }
730
556
  }
731
- }
732
- }), g && s && /* @__PURE__ */ u.createElement("span", {
733
- "aria-owns": s.id,
734
- style: Qe
735
- }), s && /* @__PURE__ */ fn.createPortal(e, s), g && s && /* @__PURE__ */ u.createElement(ze, {
736
- "data-type": "outside",
737
- ref: f,
738
- onFocus: (a) => {
739
- if (De(a, s)) {
740
- var k;
741
- (k = b.current) == null || k.focus();
742
- } else {
743
- const A = $t() || (i == null ? void 0 : i.refs.domReference.current);
744
- A == null || A.focus(), i != null && i.closeOnFocusOut && (i == null || i.onOpenChange(!1, a.nativeEvent, "focus-out"));
557
+ }), v && i && /* @__PURE__ */ ve("span", {
558
+ "aria-owns": i.id,
559
+ style: Yn
560
+ }), i && /* @__PURE__ */ Pn.createPortal(t, i), v && i && /* @__PURE__ */ ve(Ze, {
561
+ "data-type": "outside",
562
+ ref: m,
563
+ onFocus: (l) => {
564
+ if (De(l, i)) {
565
+ var w;
566
+ (w = x.current) == null || w.focus();
567
+ } else {
568
+ const k = s ? s.domReference : null, b = Ut(k);
569
+ b == null || b.focus(), s != null && s.closeOnFocusOut && (s == null || s.onOpenChange(!1, l.nativeEvent, "focus-out"));
570
+ }
745
571
  }
746
- }
747
- }));
572
+ })]
573
+ });
748
574
  }
749
- const Qt = () => u.useContext(Gt), ut = "data-floating-ui-focusable";
750
- function Zt(t) {
751
- return t ? t.hasAttribute(ut) ? t : t.querySelector("[" + ut + "]") || t : null;
575
+ const cn = () => c.useContext(un);
576
+ function At(e) {
577
+ return c.useMemo(() => (t) => {
578
+ e.forEach((r) => {
579
+ r && (r.current = t);
580
+ });
581
+ }, e);
752
582
  }
753
- const Mt = 20;
583
+ const Nt = 20;
754
584
  let Te = [];
755
- function ot(t) {
756
- Te = Te.filter((n) => n.isConnected);
757
- let e = t;
758
- if (!(!e || jt(e) === "body")) {
759
- if (!an(e, Ke())) {
760
- const n = Ge(e, Ke())[0];
761
- n && (e = n);
762
- }
763
- Te.push(e), Te.length > Mt && (Te = Te.slice(-Mt));
764
- }
585
+ function bt() {
586
+ Te = Te.filter((e) => {
587
+ var t;
588
+ return (t = e.deref()) == null ? void 0 : t.isConnected;
589
+ });
765
590
  }
766
- function Pt() {
767
- return Te.slice().reverse().find((t) => t.isConnected);
591
+ function Xn(e) {
592
+ bt(), e && en(e) !== "body" && (Te.push(new WeakRef(e)), Te.length > Nt && (Te = Te.slice(-Nt)));
768
593
  }
769
- const Dn = /* @__PURE__ */ u.forwardRef(function(e, n) {
770
- return /* @__PURE__ */ u.createElement("button", Pe({}, e, {
594
+ function _t() {
595
+ bt();
596
+ const e = Te[Te.length - 1];
597
+ return e == null ? void 0 : e.deref();
598
+ }
599
+ function Gn(e) {
600
+ const t = pt();
601
+ return rn(e, t) ? e : nn(e, t)[0] || e;
602
+ }
603
+ function Kt(e, t) {
604
+ var r;
605
+ if (!t.current.includes("floating") && !((r = e.getAttribute("role")) != null && r.includes("dialog")))
606
+ return;
607
+ const n = pt(), i = Mn(e, n).filter((a) => {
608
+ const g = a.getAttribute("data-tabindex") || "";
609
+ return rn(a, n) || a.hasAttribute("data-tabindex") && !g.startsWith("-");
610
+ }), s = e.getAttribute("tabindex");
611
+ t.current.includes("floating") || i.length === 0 ? s !== "0" && e.setAttribute("tabindex", "0") : (s !== "-1" || e.hasAttribute("data-tabindex") && e.getAttribute("data-tabindex") !== "-1") && (e.setAttribute("tabindex", "-1"), e.setAttribute("data-tabindex", "-1"));
612
+ }
613
+ const jn = /* @__PURE__ */ c.forwardRef(function(t, r) {
614
+ return /* @__PURE__ */ ve("button", {
615
+ ...t,
771
616
  type: "button",
772
- ref: n,
617
+ ref: r,
773
618
  tabIndex: -1,
774
- style: Qe
775
- }));
619
+ style: vt
620
+ });
776
621
  });
777
- function Jn(t) {
622
+ function mr(e) {
778
623
  const {
779
- context: e,
780
- children: n,
781
- disabled: r = !1,
624
+ context: t,
625
+ children: r,
626
+ disabled: n = !1,
782
627
  order: o = ["content"],
783
- guards: s = !0,
784
- initialFocus: i = 0,
785
- returnFocus: c = !0,
786
- restoreFocus: v = !1,
787
- modal: f = !0,
788
- visuallyHiddenDismiss: m = !1,
789
- closeOnFocusOut: b = !0
790
- } = t, {
791
- open: p,
792
- refs: l,
793
- nodeId: g,
794
- onOpenChange: a,
795
- events: k,
796
- dataRef: A,
797
- floatingId: N,
628
+ guards: i = !0,
629
+ initialFocus: s = 0,
630
+ returnFocus: a = !0,
631
+ restoreFocus: g = !1,
632
+ modal: m = !0,
633
+ visuallyHiddenDismiss: R = !1,
634
+ closeOnFocusOut: x = !0,
635
+ outsideElementsInert: E = !1,
636
+ getInsideElements: f = () => []
637
+ } = e, {
638
+ open: v,
639
+ onOpenChange: l,
640
+ events: w,
641
+ dataRef: k,
798
642
  elements: {
799
- domReference: h,
800
- floating: F
643
+ domReference: b,
644
+ floating: h
801
645
  }
802
- } = e, Y = typeof i == "number" && i < 0, V = ct(h) && Y, X = Mn() ? s : !0, q = fe(o), U = fe(i), $ = fe(c), B = ke(), R = Qt(), I = u.useRef(null), E = u.useRef(null), w = u.useRef(!1), y = u.useRef(!1), x = u.useRef(-1), T = R != null, d = Zt(F), C = ue(function(L) {
803
- return L === void 0 && (L = d), L ? Ge(L, Ke()) : [];
804
- }), O = ue((L) => {
805
- const K = C(L);
806
- return q.current.map((M) => h && M === "reference" ? h : d && M === "floating" ? d : K).filter(Boolean).flat();
646
+ } = t, T = ce(() => {
647
+ var L;
648
+ return (L = k.current.floatingContext) == null ? void 0 : L.nodeId;
649
+ }), $ = ce(f), H = typeof s == "number" && s < 0, B = mt(b) && H, _ = Hn(), oe = _ ? i : !0, j = !oe || _ && E, q = Re(o), X = Re(s), F = Re(a), u = Oe(), p = cn(), K = c.useRef(null), y = c.useRef(null), d = c.useRef(!1), I = c.useRef(!1), O = c.useRef(-1), G = c.useRef(-1), S = p != null, M = Qe(h), U = ce(function(L) {
650
+ return L === void 0 && (L = M), L ? nn(L, pt()) : [];
651
+ }), N = ce((L) => {
652
+ const W = U(L);
653
+ return q.current.map((D) => b && D === "reference" ? b : M && D === "floating" ? M : W).filter(Boolean).flat();
807
654
  });
808
- u.useEffect(() => {
809
- if (r || !f) return;
810
- function L(M) {
811
- if (M.key === "Tab") {
812
- ee(d, ae(re(d))) && C().length === 0 && !V && ie(M);
813
- const D = O(), P = pe(M);
814
- q.current[0] === "reference" && P === h && (ie(M), M.shiftKey ? Re(D[D.length - 1]) : Re(D[1])), q.current[1] === "floating" && P === d && M.shiftKey && (ie(M), Re(D[0]));
655
+ c.useEffect(() => {
656
+ if (n || !m) return;
657
+ function L(D) {
658
+ if (D.key === "Tab") {
659
+ ae(M, we(ge(M))) && U().length === 0 && !B && he(D);
660
+ const z = N(), te = xe(D);
661
+ q.current[0] === "reference" && te === b && (he(D), D.shiftKey ? Me(z[z.length - 1]) : Me(z[1])), q.current[1] === "floating" && te === M && D.shiftKey && (he(D), Me(z[0]));
815
662
  }
816
663
  }
817
- const K = re(d);
818
- return K.addEventListener("keydown", L), () => {
819
- K.removeEventListener("keydown", L);
664
+ const W = ge(M);
665
+ return W.addEventListener("keydown", L), () => {
666
+ W.removeEventListener("keydown", L);
820
667
  };
821
- }, [r, h, d, f, q, V, C, O]), u.useEffect(() => {
822
- if (r || !F) return;
823
- function L(K) {
824
- const M = pe(K), P = C().indexOf(M);
825
- P !== -1 && (x.current = P);
668
+ }, [n, b, M, m, q, B, U, N]), c.useEffect(() => {
669
+ if (n || !h) return;
670
+ function L(W) {
671
+ const D = xe(W), te = U().indexOf(D);
672
+ te !== -1 && (O.current = te);
826
673
  }
827
- return F.addEventListener("focusin", L), () => {
828
- F.removeEventListener("focusin", L);
674
+ return h.addEventListener("focusin", L), () => {
675
+ h.removeEventListener("focusin", L);
829
676
  };
830
- }, [r, F, C]), u.useEffect(() => {
831
- if (r || !b) return;
677
+ }, [n, h, U]), c.useEffect(() => {
678
+ if (n || !x) return;
832
679
  function L() {
833
- y.current = !0, setTimeout(() => {
834
- y.current = !1;
680
+ I.current = !0, setTimeout(() => {
681
+ I.current = !1;
835
682
  });
836
683
  }
837
- function K(M) {
838
- const D = M.relatedTarget;
684
+ function W(te) {
685
+ const V = te.relatedTarget, de = te.currentTarget, ue = xe(te);
839
686
  queueMicrotask(() => {
840
- const P = !(ee(h, D) || ee(F, D) || ee(D, F) || ee(R == null ? void 0 : R.portalNode, D) || D != null && D.hasAttribute(Oe("focus-guard")) || B && (Ce(B.nodesRef.current, g).find((W) => {
841
- var j, J;
842
- return ee((j = W.context) == null ? void 0 : j.elements.floating, D) || ee((J = W.context) == null ? void 0 : J.elements.domReference, D);
843
- }) || Cn(B.nodesRef.current, g).find((W) => {
844
- var j, J;
845
- return ((j = W.context) == null ? void 0 : j.elements.floating) === D || ((J = W.context) == null ? void 0 : J.elements.domReference) === D;
687
+ const le = T(), Ee = !(ae(b, V) || ae(h, V) || ae(V, h) || ae(p == null ? void 0 : p.portalNode, V) || V != null && V.hasAttribute(Pe("focus-guard")) || u && (Se(u.nodesRef.current, le).find((P) => {
688
+ var A, C;
689
+ return ae((A = P.context) == null ? void 0 : A.elements.floating, V) || ae((C = P.context) == null ? void 0 : C.elements.domReference, V);
690
+ }) || wt(u.nodesRef.current, le).find((P) => {
691
+ var A, C, Y;
692
+ return [(A = P.context) == null ? void 0 : A.elements.floating, Qe((C = P.context) == null ? void 0 : C.elements.floating)].includes(V) || ((Y = P.context) == null ? void 0 : Y.elements.domReference) === V;
846
693
  })));
847
- if (v && P && ae(re(d)) === re(d).body) {
848
- ge(d) && d.focus();
849
- const W = x.current, j = C(), J = j[W] || j[j.length - 1] || d;
850
- ge(J) && J.focus();
694
+ if (de === b && M && Kt(M, q), g && de !== b && !(ue != null && ue.isConnected) && we(ge(M)) === ge(M).body) {
695
+ ye(M) && M.focus();
696
+ const P = O.current, A = U(), C = A[P] || A[A.length - 1] || M;
697
+ ye(C) && C.focus();
851
698
  }
852
- (V || !f) && D && P && !y.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
853
- D !== Pt() && (w.current = !0, a(!1, M, "focus-out"));
699
+ if (k.current.insideReactTree) {
700
+ k.current.insideReactTree = !1;
701
+ return;
702
+ }
703
+ (B || !m) && V && Ee && !I.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
704
+ V !== _t() && (d.current = !0, l(!1, te, "focus-out"));
854
705
  });
855
706
  }
856
- if (F && ge(h))
857
- return h.addEventListener("focusout", K), h.addEventListener("pointerdown", L), F.addEventListener("focusout", K), () => {
858
- h.removeEventListener("focusout", K), h.removeEventListener("pointerdown", L), F.removeEventListener("focusout", K);
859
- };
860
- }, [r, h, F, d, f, g, B, R, a, b, v, C, V]), u.useEffect(() => {
861
- var L;
862
- if (r) return;
863
- const K = Array.from((R == null || (L = R.portalNode) == null ? void 0 : L.querySelectorAll("[" + Oe("portal") + "]")) || []);
864
- if (F) {
865
- const M = [F, ...K, I.current, E.current, q.current.includes("reference") || V ? h : null].filter((P) => P != null), D = f || V ? It(M, X, !X) : It(M);
866
- return () => {
867
- D();
868
- };
707
+ const D = !!(!u && p);
708
+ function z() {
709
+ me(G), k.current.insideReactTree = !0, G.current = window.setTimeout(() => {
710
+ k.current.insideReactTree = !1;
711
+ });
869
712
  }
870
- }, [r, h, F, f, q, R, V, X]), G(() => {
871
- if (r || !ge(d)) return;
872
- const L = re(d), K = ae(L);
713
+ if (h && ye(b))
714
+ return b.addEventListener("focusout", W), b.addEventListener("pointerdown", L), h.addEventListener("focusout", W), D && h.addEventListener("focusout", z, !0), () => {
715
+ b.removeEventListener("focusout", W), b.removeEventListener("pointerdown", L), h.removeEventListener("focusout", W), D && h.removeEventListener("focusout", z, !0);
716
+ };
717
+ }, [n, b, h, M, m, u, p, l, x, g, U, B, T, q, k]);
718
+ const ne = c.useRef(null), se = c.useRef(null), Z = At([ne, p == null ? void 0 : p.beforeInsideRef]), J = At([se, p == null ? void 0 : p.afterInsideRef]);
719
+ c.useEffect(() => {
720
+ var L, W;
721
+ if (n || !h) return;
722
+ const D = Array.from((p == null || (L = p.portalNode) == null ? void 0 : L.querySelectorAll("[" + Pe("portal") + "]")) || []), te = (W = (u ? wt(u.nodesRef.current, T()) : []).find((ue) => {
723
+ var le;
724
+ return mt(((le = ue.context) == null ? void 0 : le.elements.domReference) || null);
725
+ })) == null || (W = W.context) == null ? void 0 : W.elements.domReference, V = [h, te, ...D, ...$(), K.current, y.current, ne.current, se.current, p == null ? void 0 : p.beforeOutsideRef.current, p == null ? void 0 : p.afterOutsideRef.current, q.current.includes("reference") || B ? b : null].filter((ue) => ue != null), de = m || B ? St(V, !j, j) : St(V);
726
+ return () => {
727
+ de();
728
+ };
729
+ }, [n, b, h, m, q, p, B, oe, j, u, T, $]), ee(() => {
730
+ if (n || !ye(M)) return;
731
+ const L = ge(M), W = we(L);
873
732
  queueMicrotask(() => {
874
- const M = O(d), D = U.current, P = (typeof D == "number" ? M[D] : D.current) || d, W = ee(d, K);
875
- !Y && !W && p && Re(P, {
876
- preventScroll: P === d
733
+ const D = N(M), z = X.current, te = (typeof z == "number" ? D[z] : z.current) || M, V = ae(M, W);
734
+ !H && !V && v && Me(te, {
735
+ preventScroll: te === M
877
736
  });
878
737
  });
879
- }, [r, p, d, Y, O, U]), G(() => {
880
- if (r || !d) return;
881
- let L = !1;
882
- const K = re(d), M = ae(K);
883
- let P = A.current.openEvent;
884
- ot(M);
885
- function W(te) {
738
+ }, [n, v, M, H, N, X]), ee(() => {
739
+ if (n || !M) return;
740
+ const L = ge(M), W = we(L);
741
+ Xn(W);
742
+ function D(V) {
886
743
  let {
887
- open: we,
888
- reason: ve,
889
- event: ce,
890
- nested: be
891
- } = te;
892
- we && (P = ce), ve === "escape-key" && l.domReference.current && ot(l.domReference.current), ve === "hover" && ce.type === "mouseleave" && (w.current = !0), ve === "outside-press" && (be ? (w.current = !1, L = !0) : w.current = !(Wt(ce) || lt(ce)));
744
+ reason: de,
745
+ event: ue,
746
+ nested: le
747
+ } = V;
748
+ if (["hover", "safe-polygon"].includes(de) && ue.type === "mouseleave" && (d.current = !0), de === "outside-press")
749
+ if (le)
750
+ d.current = !1;
751
+ else if (Gt(ue) || jt(ue))
752
+ d.current = !1;
753
+ else {
754
+ let Ee = !1;
755
+ document.createElement("div").focus({
756
+ get preventScroll() {
757
+ return Ee = !0, !1;
758
+ }
759
+ }), Ee ? d.current = !1 : d.current = !0;
760
+ }
893
761
  }
894
- k.on("openchange", W);
895
- const j = K.createElement("span");
896
- j.setAttribute("tabindex", "-1"), j.setAttribute("aria-hidden", "true"), Object.assign(j.style, Qe), T && h && h.insertAdjacentElement("afterend", j);
897
- function J() {
898
- return typeof $.current == "boolean" ? Pt() || j : $.current.current || j;
762
+ w.on("openchange", D);
763
+ const z = L.createElement("span");
764
+ z.setAttribute("tabindex", "-1"), z.setAttribute("aria-hidden", "true"), Object.assign(z.style, vt), S && b && b.insertAdjacentElement("afterend", z);
765
+ function te() {
766
+ if (typeof F.current == "boolean") {
767
+ const V = b || _t();
768
+ return V && V.isConnected ? V : z;
769
+ }
770
+ return F.current.current || z;
899
771
  }
900
772
  return () => {
901
- k.off("openchange", W);
902
- const te = ae(K), we = ee(F, te) || B && Ce(B.nodesRef.current, g).some((be) => {
903
- var Fe;
904
- return ee((Fe = be.context) == null ? void 0 : Fe.elements.floating, te);
905
- });
906
- (we || P && ["click", "mousedown"].includes(P.type)) && l.domReference.current && ot(l.domReference.current);
907
- const ce = J();
773
+ w.off("openchange", D);
774
+ const V = we(L), de = ae(h, V) || u && Se(u.nodesRef.current, T(), !1).some((le) => {
775
+ var Ee;
776
+ return ae((Ee = le.context) == null ? void 0 : Ee.elements.floating, V);
777
+ }), ue = te();
908
778
  queueMicrotask(() => {
779
+ const le = Gn(ue);
909
780
  // eslint-disable-next-line react-hooks/exhaustive-deps
910
- $.current && !w.current && ge(ce) && // If the focus moved somewhere else after mount, avoid returning focus
781
+ F.current && !d.current && ye(le) && // If the focus moved somewhere else after mount, avoid returning focus
911
782
  // since it likely entered a different element which should be
912
783
  // respected: https://github.com/floating-ui/floating-ui/issues/2607
913
- (!(ce !== te && te !== K.body) || we) && ce.focus({
914
- preventScroll: L
915
- }), j.remove();
784
+ (!(le !== V && V !== L.body) || de) && le.focus({
785
+ preventScroll: !0
786
+ }), z.remove();
916
787
  });
917
788
  };
918
- }, [r, F, d, $, A, l, k, B, g, T, h]), u.useEffect(() => {
919
- queueMicrotask(() => {
920
- w.current = !1;
921
- });
922
- }, [r]), G(() => {
923
- if (!r && R)
924
- return R.setFocusManagerState({
925
- modal: f,
926
- closeOnFocusOut: b,
927
- open: p,
928
- onOpenChange: a,
929
- refs: l
789
+ }, [n, h, M, F, k, w, u, S, b, T]), c.useEffect(() => (queueMicrotask(() => {
790
+ d.current = !1;
791
+ }), () => {
792
+ queueMicrotask(bt);
793
+ }), [n]), ee(() => {
794
+ if (!n && p)
795
+ return p.setFocusManagerState({
796
+ modal: m,
797
+ closeOnFocusOut: x,
798
+ open: v,
799
+ onOpenChange: l,
800
+ domReference: b
930
801
  }), () => {
931
- R.setFocusManagerState(null);
802
+ p.setFocusManagerState(null);
932
803
  };
933
- }, [r, R, f, p, a, l, b]), G(() => {
934
- if (r || !d || typeof MutationObserver != "function" || Y) return;
935
- const L = () => {
936
- const M = d.getAttribute("tabindex"), D = C(), P = ae(re(F)), W = D.indexOf(P);
937
- W !== -1 && (x.current = W), q.current.includes("floating") || P !== l.domReference.current && D.length === 0 ? M !== "0" && d.setAttribute("tabindex", "0") : M !== "-1" && d.setAttribute("tabindex", "-1");
938
- };
939
- L();
940
- const K = new MutationObserver(L);
941
- return K.observe(d, {
942
- childList: !0,
943
- subtree: !0,
944
- attributes: !0
945
- }), () => {
946
- K.disconnect();
947
- };
948
- }, [r, F, d, l, q, C, Y]);
949
- function H(L) {
950
- return r || !m || !f ? null : /* @__PURE__ */ u.createElement(Dn, {
951
- ref: L === "start" ? I : E,
952
- onClick: (K) => a(!1, K.nativeEvent)
953
- }, typeof m == "string" ? m : "Dismiss");
804
+ }, [n, p, m, v, l, x, b]), ee(() => {
805
+ n || M && Kt(M, q);
806
+ }, [n, M, q]);
807
+ function ie(L) {
808
+ return n || !R || !m ? null : /* @__PURE__ */ ve(jn, {
809
+ ref: L === "start" ? K : y,
810
+ onClick: (W) => l(!1, W.nativeEvent),
811
+ children: typeof R == "string" ? R : "Dismiss"
812
+ });
954
813
  }
955
- const ne = !r && X && (f ? !V : !0) && (T || f);
956
- return /* @__PURE__ */ u.createElement(u.Fragment, null, ne && /* @__PURE__ */ u.createElement(ze, {
957
- "data-type": "inside",
958
- ref: R == null ? void 0 : R.beforeInsideRef,
959
- onFocus: (L) => {
960
- if (f) {
961
- const M = O();
962
- Re(o[0] === "reference" ? M[0] : M[M.length - 1]);
963
- } else if (R != null && R.preserveTabOrder && R.portalNode)
964
- if (w.current = !1, De(L, R.portalNode)) {
965
- const M = $t() || h;
966
- M == null || M.focus();
967
- } else {
968
- var K;
969
- (K = R.beforeOutsideRef.current) == null || K.focus();
970
- }
971
- }
972
- }), !V && H("start"), n, H("end"), ne && /* @__PURE__ */ u.createElement(ze, {
973
- "data-type": "inside",
974
- ref: R == null ? void 0 : R.afterInsideRef,
975
- onFocus: (L) => {
976
- if (f)
977
- Re(O()[0]);
978
- else if (R != null && R.preserveTabOrder && R.portalNode)
979
- if (b && (w.current = !0), De(L, R.portalNode)) {
980
- const M = zt() || h;
981
- M == null || M.focus();
982
- } else {
983
- var K;
984
- (K = R.afterOutsideRef.current) == null || K.focus();
985
- }
986
- }
987
- }));
814
+ const pe = !n && oe && (m ? !B : !0) && (S || m);
815
+ return /* @__PURE__ */ gt(wn, {
816
+ children: [pe && /* @__PURE__ */ ve(Ze, {
817
+ "data-type": "inside",
818
+ ref: Z,
819
+ onFocus: (L) => {
820
+ if (m) {
821
+ const D = N();
822
+ Me(o[0] === "reference" ? D[0] : D[D.length - 1]);
823
+ } else if (p != null && p.preserveTabOrder && p.portalNode)
824
+ if (d.current = !1, De(L, p.portalNode)) {
825
+ const D = Ut(b);
826
+ D == null || D.focus();
827
+ } else {
828
+ var W;
829
+ (W = p.beforeOutsideRef.current) == null || W.focus();
830
+ }
831
+ }
832
+ }), !B && ie("start"), r, ie("end"), pe && /* @__PURE__ */ ve(Ze, {
833
+ "data-type": "inside",
834
+ ref: J,
835
+ onFocus: (L) => {
836
+ if (m)
837
+ Me(N()[0]);
838
+ else if (p != null && p.preserveTabOrder && p.portalNode)
839
+ if (x && (d.current = !0), De(L, p.portalNode)) {
840
+ const D = zt(b);
841
+ D == null || D.focus();
842
+ } else {
843
+ var W;
844
+ (W = p.afterOutsideRef.current) == null || W.focus();
845
+ }
846
+ }
847
+ })]
848
+ });
988
849
  }
989
- let Ye = 0;
990
- function An() {
991
- const t = /iP(hone|ad|od)|iOS/.test(sn()), e = document.body.style, r = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft ? "paddingLeft" : "paddingRight", o = window.innerWidth - document.documentElement.clientWidth, s = e.left ? parseFloat(e.left) : window.scrollX, i = e.top ? parseFloat(e.top) : window.scrollY;
992
- if (e.overflow = "hidden", o && (e[r] = o + "px"), t) {
993
- var c, v;
994
- const f = ((c = window.visualViewport) == null ? void 0 : c.offsetLeft) || 0, m = ((v = window.visualViewport) == null ? void 0 : v.offsetTop) || 0;
995
- Object.assign(e, {
850
+ let je = 0;
851
+ const Wt = "--floating-ui-scrollbar-width";
852
+ function Un() {
853
+ const e = gn(), t = /iP(hone|ad|od)|iOS/.test(e) || // iPads can claim to be MacIntel
854
+ e === "MacIntel" && navigator.maxTouchPoints > 1, r = document.body.style, o = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft ? "paddingLeft" : "paddingRight", i = window.innerWidth - document.documentElement.clientWidth, s = r.left ? parseFloat(r.left) : window.scrollX, a = r.top ? parseFloat(r.top) : window.scrollY;
855
+ if (r.overflow = "hidden", r.setProperty(Wt, i + "px"), i && (r[o] = i + "px"), t) {
856
+ var g, m;
857
+ const R = ((g = window.visualViewport) == null ? void 0 : g.offsetLeft) || 0, x = ((m = window.visualViewport) == null ? void 0 : m.offsetTop) || 0;
858
+ Object.assign(r, {
996
859
  position: "fixed",
997
- top: -(i - Math.floor(m)) + "px",
998
- left: -(s - Math.floor(f)) + "px",
860
+ top: -(a - Math.floor(x)) + "px",
861
+ left: -(s - Math.floor(R)) + "px",
999
862
  right: "0"
1000
863
  });
1001
864
  }
1002
865
  return () => {
1003
- Object.assign(e, {
866
+ Object.assign(r, {
1004
867
  overflow: "",
1005
- [r]: ""
1006
- }), t && (Object.assign(e, {
868
+ [o]: ""
869
+ }), r.removeProperty(Wt), t && (Object.assign(r, {
1007
870
  position: "",
1008
871
  top: "",
1009
872
  left: "",
1010
873
  right: ""
1011
- }), window.scrollTo(s, i));
874
+ }), window.scrollTo(s, a));
1012
875
  };
1013
876
  }
1014
- let kt = () => {
877
+ let Vt = () => {
1015
878
  };
1016
- const er = /* @__PURE__ */ u.forwardRef(function(e, n) {
879
+ const pr = /* @__PURE__ */ c.forwardRef(function(t, r) {
1017
880
  const {
1018
- lockScroll: r = !1,
881
+ lockScroll: n = !1,
1019
882
  ...o
1020
- } = e;
1021
- return G(() => {
1022
- if (r)
1023
- return Ye++, Ye === 1 && (kt = An()), () => {
1024
- Ye--, Ye === 0 && kt();
883
+ } = t;
884
+ return ee(() => {
885
+ if (n)
886
+ return je++, je === 1 && (Vt = Un()), () => {
887
+ je--, je === 0 && Vt();
1025
888
  };
1026
- }, [r]), /* @__PURE__ */ u.createElement("div", Pe({
1027
- ref: n
1028
- }, o, {
889
+ }, [n]), /* @__PURE__ */ ve("div", {
890
+ ref: r,
891
+ ...o,
1029
892
  style: {
1030
893
  position: "fixed",
1031
894
  overflow: "auto",
@@ -1035,964 +898,982 @@ const er = /* @__PURE__ */ u.forwardRef(function(e, n) {
1035
898
  left: 0,
1036
899
  ...o.style
1037
900
  }
1038
- }));
901
+ });
1039
902
  });
1040
- function Ft(t) {
1041
- return ge(t.target) && t.target.tagName === "BUTTON";
903
+ function Ht(e) {
904
+ return ye(e.target) && e.target.tagName === "BUTTON";
1042
905
  }
1043
- function Lt(t) {
1044
- return Bt(t);
906
+ function zn(e) {
907
+ return ye(e.target) && e.target.tagName === "A";
1045
908
  }
1046
- function tr(t, e) {
1047
- e === void 0 && (e = {});
909
+ function Bt(e) {
910
+ return Qt(e);
911
+ }
912
+ function gr(e, t) {
913
+ t === void 0 && (t = {});
1048
914
  const {
1049
- open: n,
1050
- onOpenChange: r,
915
+ open: r,
916
+ onOpenChange: n,
1051
917
  dataRef: o,
1052
918
  elements: {
1053
- domReference: s
919
+ domReference: i
1054
920
  }
1055
- } = t, {
1056
- enabled: i = !0,
1057
- event: c = "click",
1058
- toggle: v = !0,
1059
- ignoreMouse: f = !1,
1060
- keyboardHandlers: m = !0,
1061
- stickIfOpen: b = !0
1062
- } = e, p = u.useRef(), l = u.useRef(!1), g = u.useMemo(() => ({
1063
- onPointerDown(a) {
1064
- p.current = a.pointerType;
921
+ } = e, {
922
+ enabled: s = !0,
923
+ event: a = "click",
924
+ toggle: g = !0,
925
+ ignoreMouse: m = !1,
926
+ keyboardHandlers: R = !0,
927
+ stickIfOpen: x = !0
928
+ } = t, E = c.useRef(), f = c.useRef(!1), v = c.useMemo(() => ({
929
+ onPointerDown(l) {
930
+ E.current = l.pointerType;
1065
931
  },
1066
- onMouseDown(a) {
1067
- const k = p.current;
1068
- a.button === 0 && c !== "click" && (Ae(k, !0) && f || (n && v && (!(o.current.openEvent && b) || o.current.openEvent.type === "mousedown") ? r(!1, a.nativeEvent, "click") : (a.preventDefault(), r(!0, a.nativeEvent, "click"))));
932
+ onMouseDown(l) {
933
+ const w = E.current;
934
+ l.button === 0 && a !== "click" && (Ae(w, !0) && m || (r && g && (!(o.current.openEvent && x) || o.current.openEvent.type === "mousedown") ? n(!1, l.nativeEvent, "click") : (l.preventDefault(), n(!0, l.nativeEvent, "click"))));
1069
935
  },
1070
- onClick(a) {
1071
- const k = p.current;
1072
- if (c === "mousedown" && p.current) {
1073
- p.current = void 0;
936
+ onClick(l) {
937
+ const w = E.current;
938
+ if (a === "mousedown" && E.current) {
939
+ E.current = void 0;
1074
940
  return;
1075
941
  }
1076
- Ae(k, !0) && f || (n && v && (!(o.current.openEvent && b) || o.current.openEvent.type === "click") ? r(!1, a.nativeEvent, "click") : r(!0, a.nativeEvent, "click"));
942
+ Ae(w, !0) && m || (r && g && (!(o.current.openEvent && x) || o.current.openEvent.type === "click") ? n(!1, l.nativeEvent, "click") : n(!0, l.nativeEvent, "click"));
1077
943
  },
1078
- onKeyDown(a) {
1079
- p.current = void 0, !(a.defaultPrevented || !m || Ft(a)) && (a.key === " " && !Lt(s) && (a.preventDefault(), l.current = !0), a.key === "Enter" && r(!(n && v), a.nativeEvent, "click"));
944
+ onKeyDown(l) {
945
+ E.current = void 0, !(l.defaultPrevented || !R || Ht(l)) && (l.key === " " && !Bt(i) && (l.preventDefault(), f.current = !0), !zn(l) && l.key === "Enter" && n(!(r && g), l.nativeEvent, "click"));
1080
946
  },
1081
- onKeyUp(a) {
1082
- a.defaultPrevented || !m || Ft(a) || Lt(s) || a.key === " " && l.current && (l.current = !1, r(!(n && v), a.nativeEvent, "click"));
947
+ onKeyUp(l) {
948
+ l.defaultPrevented || !R || Ht(l) || Bt(i) || l.key === " " && f.current && (f.current = !1, n(!(r && g), l.nativeEvent, "click"));
1083
949
  }
1084
- }), [o, s, c, f, m, r, n, b, v]);
1085
- return u.useMemo(() => i ? {
1086
- reference: g
1087
- } : {}, [i, g]);
950
+ }), [o, i, a, m, R, n, r, x, g]);
951
+ return c.useMemo(() => s ? {
952
+ reference: v
953
+ } : {}, [s, v]);
1088
954
  }
1089
- const Nn = {
955
+ const Qn = {
1090
956
  pointerdown: "onPointerDown",
1091
957
  mousedown: "onMouseDown",
1092
958
  click: "onClick"
1093
- }, Kn = {
959
+ }, Zn = {
1094
960
  pointerdown: "onPointerDownCapture",
1095
961
  mousedown: "onMouseDownCapture",
1096
962
  click: "onClickCapture"
1097
- }, St = (t) => {
1098
- var e, n;
963
+ }, $t = (e) => {
964
+ var t, r;
1099
965
  return {
1100
- escapeKey: typeof t == "boolean" ? t : (e = t == null ? void 0 : t.escapeKey) != null ? e : !1,
1101
- outsidePress: typeof t == "boolean" ? t : (n = t == null ? void 0 : t.outsidePress) != null ? n : !0
966
+ escapeKey: typeof e == "boolean" ? e : (t = e == null ? void 0 : e.escapeKey) != null ? t : !1,
967
+ outsidePress: typeof e == "boolean" ? e : (r = e == null ? void 0 : e.outsidePress) != null ? r : !0
1102
968
  };
1103
969
  };
1104
- function nr(t, e) {
1105
- e === void 0 && (e = {});
970
+ function vr(e, t) {
971
+ t === void 0 && (t = {});
1106
972
  const {
1107
- open: n,
1108
- onOpenChange: r,
973
+ open: r,
974
+ onOpenChange: n,
1109
975
  elements: o,
1110
- dataRef: s
1111
- } = t, {
1112
- enabled: i = !0,
1113
- escapeKey: c = !0,
1114
- outsidePress: v = !0,
1115
- outsidePressEvent: f = "pointerdown",
1116
- referencePress: m = !1,
1117
- referencePressEvent: b = "pointerdown",
1118
- ancestorScroll: p = !1,
1119
- bubbles: l,
1120
- capture: g
1121
- } = e, a = ke(), k = ue(typeof v == "function" ? v : () => !1), A = typeof v == "function" ? k : v, N = u.useRef(!1), h = u.useRef(!1), {
1122
- escapeKey: F,
1123
- outsidePress: Y
1124
- } = St(l), {
1125
- escapeKey: V,
1126
- outsidePress: X
1127
- } = St(g), q = u.useRef(!1), U = ue((w) => {
1128
- var y;
1129
- if (!n || !i || !c || w.key !== "Escape" || q.current)
976
+ dataRef: i
977
+ } = e, {
978
+ enabled: s = !0,
979
+ escapeKey: a = !0,
980
+ outsidePress: g = !0,
981
+ outsidePressEvent: m = "pointerdown",
982
+ referencePress: R = !1,
983
+ referencePressEvent: x = "pointerdown",
984
+ ancestorScroll: E = !1,
985
+ bubbles: f,
986
+ capture: v
987
+ } = t, l = Oe(), w = ce(typeof g == "function" ? g : () => !1), k = typeof g == "function" ? w : g, b = c.useRef(!1), {
988
+ escapeKey: h,
989
+ outsidePress: T
990
+ } = $t(f), {
991
+ escapeKey: $,
992
+ outsidePress: H
993
+ } = $t(v), B = c.useRef(!1), _ = ce((u) => {
994
+ var p;
995
+ if (!r || !s || !a || u.key !== "Escape" || B.current)
1130
996
  return;
1131
- const x = (y = s.current.floatingContext) == null ? void 0 : y.nodeId, T = a ? Ce(a.nodesRef.current, x) : [];
1132
- if (!F && (w.stopPropagation(), T.length > 0)) {
997
+ const K = (p = i.current.floatingContext) == null ? void 0 : p.nodeId, y = l ? Se(l.nodesRef.current, K) : [];
998
+ if (!h && (u.stopPropagation(), y.length > 0)) {
1133
999
  let d = !0;
1134
- if (T.forEach((C) => {
1000
+ if (y.forEach((I) => {
1135
1001
  var O;
1136
- if ((O = C.context) != null && O.open && !C.context.dataRef.current.__escapeKeyBubbles) {
1002
+ if ((O = I.context) != null && O.open && !I.context.dataRef.current.__escapeKeyBubbles) {
1137
1003
  d = !1;
1138
1004
  return;
1139
1005
  }
1140
1006
  }), !d)
1141
1007
  return;
1142
1008
  }
1143
- r(!1, rn(w) ? w.nativeEvent : w, "escape-key");
1144
- }), $ = ue((w) => {
1145
- var y;
1146
- const x = () => {
1147
- var T;
1148
- U(w), (T = pe(w)) == null || T.removeEventListener("keydown", x);
1009
+ n(!1, mn(u) ? u.nativeEvent : u, "escape-key");
1010
+ }), oe = ce((u) => {
1011
+ var p;
1012
+ const K = () => {
1013
+ var y;
1014
+ _(u), (y = xe(u)) == null || y.removeEventListener("keydown", K);
1149
1015
  };
1150
- (y = pe(w)) == null || y.addEventListener("keydown", x);
1151
- }), B = ue((w) => {
1152
- var y;
1153
- const x = N.current;
1154
- N.current = !1;
1155
- const T = h.current;
1156
- if (h.current = !1, f === "click" && T || x || typeof A == "function" && !A(w))
1016
+ (p = xe(u)) == null || p.addEventListener("keydown", K);
1017
+ }), j = ce((u) => {
1018
+ var p;
1019
+ const K = i.current.insideReactTree;
1020
+ i.current.insideReactTree = !1;
1021
+ const y = b.current;
1022
+ if (b.current = !1, m === "click" && y || K || typeof k == "function" && !k(u))
1157
1023
  return;
1158
- const d = pe(w), C = "[" + Oe("inert") + "]", O = re(o.floating).querySelectorAll(C);
1159
- let H = oe(d) ? d : null;
1160
- for (; H && !ht(H); ) {
1161
- const M = ln(H);
1162
- if (ht(M) || !oe(M))
1024
+ const d = xe(u), I = "[" + Pe("inert") + "]", O = ge(o.floating).querySelectorAll(I);
1025
+ let G = fe(d) ? d : null;
1026
+ for (; G && !st(G); ) {
1027
+ const N = Tn(G);
1028
+ if (st(N) || !fe(N))
1163
1029
  break;
1164
- H = M;
1030
+ G = N;
1165
1031
  }
1166
- if (O.length && oe(d) && !on(d) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
1167
- !ee(d, o.floating) && // If the target root element contains none of the markers, then the
1032
+ if (O.length && fe(d) && !pn(d) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
1033
+ !ae(d, o.floating) && // If the target root element contains none of the markers, then the
1168
1034
  // element was injected after the floating element rendered.
1169
- Array.from(O).every((M) => !ee(H, M)))
1035
+ Array.from(O).every((N) => !ae(G, N)))
1170
1036
  return;
1171
- if (ge(d) && E) {
1172
- const M = d.clientWidth > 0 && d.scrollWidth > d.clientWidth, D = d.clientHeight > 0 && d.scrollHeight > d.clientHeight;
1173
- let P = D && w.offsetX > d.clientWidth;
1174
- if (D && qt(d).direction === "rtl" && (P = w.offsetX <= d.offsetWidth - d.clientWidth), P || M && w.offsetY > d.clientHeight)
1037
+ if (ye(d) && F) {
1038
+ const N = st(d), ne = Jt(d), se = /auto|scroll/, Z = N || se.test(ne.overflowX), J = N || se.test(ne.overflowY), ie = Z && d.clientWidth > 0 && d.scrollWidth > d.clientWidth, pe = J && d.clientHeight > 0 && d.scrollHeight > d.clientHeight, L = ne.direction === "rtl", W = pe && (L ? u.offsetX <= d.offsetWidth - d.clientWidth : u.offsetX > d.clientWidth), D = ie && u.offsetY > d.clientHeight;
1039
+ if (W || D)
1175
1040
  return;
1176
1041
  }
1177
- const ne = (y = s.current.floatingContext) == null ? void 0 : y.nodeId, L = a && Ce(a.nodesRef.current, ne).some((M) => {
1178
- var D;
1179
- return Je(w, (D = M.context) == null ? void 0 : D.elements.floating);
1042
+ const S = (p = i.current.floatingContext) == null ? void 0 : p.nodeId, M = l && Se(l.nodesRef.current, S).some((N) => {
1043
+ var ne;
1044
+ return nt(u, (ne = N.context) == null ? void 0 : ne.elements.floating);
1180
1045
  });
1181
- if (Je(w, o.floating) || Je(w, o.domReference) || L)
1046
+ if (nt(u, o.floating) || nt(u, o.domReference) || M)
1182
1047
  return;
1183
- const K = a ? Ce(a.nodesRef.current, ne) : [];
1184
- if (K.length > 0) {
1185
- let M = !0;
1186
- if (K.forEach((D) => {
1187
- var P;
1188
- if ((P = D.context) != null && P.open && !D.context.dataRef.current.__outsidePressBubbles) {
1189
- M = !1;
1048
+ const U = l ? Se(l.nodesRef.current, S) : [];
1049
+ if (U.length > 0) {
1050
+ let N = !0;
1051
+ if (U.forEach((ne) => {
1052
+ var se;
1053
+ if ((se = ne.context) != null && se.open && !ne.context.dataRef.current.__outsidePressBubbles) {
1054
+ N = !1;
1190
1055
  return;
1191
1056
  }
1192
- }), !M)
1057
+ }), !N)
1193
1058
  return;
1194
1059
  }
1195
- r(!1, w, "outside-press");
1196
- }), R = ue((w) => {
1197
- var y;
1198
- const x = () => {
1199
- var T;
1200
- B(w), (T = pe(w)) == null || T.removeEventListener(f, x);
1060
+ n(!1, u, "outside-press");
1061
+ }), q = ce((u) => {
1062
+ var p;
1063
+ const K = () => {
1064
+ var y;
1065
+ j(u), (y = xe(u)) == null || y.removeEventListener(m, K);
1201
1066
  };
1202
- (y = pe(w)) == null || y.addEventListener(f, x);
1067
+ (p = xe(u)) == null || p.addEventListener(m, K);
1203
1068
  });
1204
- u.useEffect(() => {
1205
- if (!n || !i)
1069
+ c.useEffect(() => {
1070
+ if (!r || !s)
1206
1071
  return;
1207
- s.current.__escapeKeyBubbles = F, s.current.__outsidePressBubbles = Y;
1208
- let w = -1;
1209
- function y(O) {
1210
- r(!1, O, "ancestor-scroll");
1072
+ i.current.__escapeKeyBubbles = h, i.current.__outsidePressBubbles = T;
1073
+ let u = -1;
1074
+ function p(O) {
1075
+ n(!1, O, "ancestor-scroll");
1211
1076
  }
1212
- function x() {
1213
- window.clearTimeout(w), q.current = !0;
1077
+ function K() {
1078
+ window.clearTimeout(u), B.current = !0;
1214
1079
  }
1215
- function T() {
1216
- w = window.setTimeout(
1080
+ function y() {
1081
+ u = window.setTimeout(
1217
1082
  () => {
1218
- q.current = !1;
1083
+ B.current = !1;
1219
1084
  },
1220
1085
  // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
1221
1086
  // Only apply to WebKit for the test to remain 0ms.
1222
- un() ? 5 : 0
1087
+ In() ? 5 : 0
1223
1088
  );
1224
1089
  }
1225
- const d = re(o.floating);
1226
- c && (d.addEventListener("keydown", V ? $ : U, V), d.addEventListener("compositionstart", x), d.addEventListener("compositionend", T)), A && d.addEventListener(f, X ? R : B, X);
1227
- let C = [];
1228
- return p && (oe(o.domReference) && (C = et(o.domReference)), oe(o.floating) && (C = C.concat(et(o.floating))), !oe(o.reference) && o.reference && o.reference.contextElement && (C = C.concat(et(o.reference.contextElement)))), C = C.filter((O) => {
1229
- var H;
1230
- return O !== ((H = d.defaultView) == null ? void 0 : H.visualViewport);
1231
- }), C.forEach((O) => {
1232
- O.addEventListener("scroll", y, {
1090
+ const d = ge(o.floating);
1091
+ a && (d.addEventListener("keydown", $ ? oe : _, $), d.addEventListener("compositionstart", K), d.addEventListener("compositionend", y)), k && d.addEventListener(m, H ? q : j, H);
1092
+ let I = [];
1093
+ return E && (fe(o.domReference) && (I = ot(o.domReference)), fe(o.floating) && (I = I.concat(ot(o.floating))), !fe(o.reference) && o.reference && o.reference.contextElement && (I = I.concat(ot(o.reference.contextElement)))), I = I.filter((O) => {
1094
+ var G;
1095
+ return O !== ((G = d.defaultView) == null ? void 0 : G.visualViewport);
1096
+ }), I.forEach((O) => {
1097
+ O.addEventListener("scroll", p, {
1233
1098
  passive: !0
1234
1099
  });
1235
1100
  }), () => {
1236
- c && (d.removeEventListener("keydown", V ? $ : U, V), d.removeEventListener("compositionstart", x), d.removeEventListener("compositionend", T)), A && d.removeEventListener(f, X ? R : B, X), C.forEach((O) => {
1237
- O.removeEventListener("scroll", y);
1238
- }), window.clearTimeout(w);
1101
+ a && (d.removeEventListener("keydown", $ ? oe : _, $), d.removeEventListener("compositionstart", K), d.removeEventListener("compositionend", y)), k && d.removeEventListener(m, H ? q : j, H), I.forEach((O) => {
1102
+ O.removeEventListener("scroll", p);
1103
+ }), window.clearTimeout(u);
1239
1104
  };
1240
- }, [s, o, c, A, f, n, r, p, i, F, Y, U, V, $, B, X, R]), u.useEffect(() => {
1241
- N.current = !1;
1242
- }, [A, f]);
1243
- const I = u.useMemo(() => ({
1244
- onKeyDown: U,
1245
- [Nn[b]]: (w) => {
1246
- m && r(!1, w.nativeEvent, "reference-press");
1105
+ }, [i, o, a, k, m, r, n, E, s, h, T, _, $, oe, j, H, q]), c.useEffect(() => {
1106
+ i.current.insideReactTree = !1;
1107
+ }, [i, k, m]);
1108
+ const X = c.useMemo(() => ({
1109
+ onKeyDown: _,
1110
+ ...R && {
1111
+ [Qn[x]]: (u) => {
1112
+ n(!1, u.nativeEvent, "reference-press");
1113
+ },
1114
+ ...x !== "click" && {
1115
+ onClick(u) {
1116
+ n(!1, u.nativeEvent, "reference-press");
1117
+ }
1118
+ }
1247
1119
  }
1248
- }), [U, r, m, b]), E = u.useMemo(() => ({
1249
- onKeyDown: U,
1250
- onMouseDown() {
1251
- h.current = !0;
1252
- },
1253
- onMouseUp() {
1254
- h.current = !0;
1255
- },
1256
- [Kn[f]]: () => {
1257
- N.current = !0;
1120
+ }), [_, n, R, x]), F = c.useMemo(() => {
1121
+ function u(p) {
1122
+ p.button === 0 && (b.current = !0);
1258
1123
  }
1259
- }), [U, f]);
1260
- return u.useMemo(() => i ? {
1261
- reference: I,
1262
- floating: E
1263
- } : {}, [i, I, E]);
1124
+ return {
1125
+ onKeyDown: _,
1126
+ onMouseDown: u,
1127
+ onMouseUp: u,
1128
+ [Zn[m]]: () => {
1129
+ i.current.insideReactTree = !0;
1130
+ }
1131
+ };
1132
+ }, [_, m, i]);
1133
+ return c.useMemo(() => s ? {
1134
+ reference: X,
1135
+ floating: F
1136
+ } : {}, [s, X, F]);
1264
1137
  }
1265
- function _n(t) {
1138
+ function Jn(e) {
1266
1139
  const {
1267
- open: e = !1,
1268
- onOpenChange: n,
1269
- elements: r
1270
- } = t, o = Ve(), s = u.useRef({}), [i] = u.useState(() => wn()), c = We() != null;
1140
+ open: t = !1,
1141
+ onOpenChange: r,
1142
+ elements: n
1143
+ } = e, o = We(), i = c.useRef({}), [s] = c.useState(() => Nn()), a = Ve() != null;
1271
1144
  if (process.env.NODE_ENV !== "production") {
1272
- const l = r.reference;
1273
- l && !oe(l) && xn("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
1145
+ const f = n.reference;
1146
+ f && !fe(f) && An("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
1274
1147
  }
1275
- const [v, f] = u.useState(r.reference), m = ue((l, g, a) => {
1276
- s.current.openEvent = l ? g : void 0, i.emit("openchange", {
1277
- open: l,
1278
- event: g,
1279
- reason: a,
1280
- nested: c
1281
- }), n == null || n(l, g, a);
1282
- }), b = u.useMemo(() => ({
1283
- setPositionReference: f
1284
- }), []), p = u.useMemo(() => ({
1285
- reference: v || r.reference || null,
1286
- floating: r.floating || null,
1287
- domReference: r.reference
1288
- }), [v, r.reference, r.floating]);
1289
- return u.useMemo(() => ({
1290
- dataRef: s,
1291
- open: e,
1292
- onOpenChange: m,
1293
- elements: p,
1294
- events: i,
1148
+ const [g, m] = c.useState(n.reference), R = ce((f, v, l) => {
1149
+ i.current.openEvent = f ? v : void 0, s.emit("openchange", {
1150
+ open: f,
1151
+ event: v,
1152
+ reason: l,
1153
+ nested: a
1154
+ }), r == null || r(f, v, l);
1155
+ }), x = c.useMemo(() => ({
1156
+ setPositionReference: m
1157
+ }), []), E = c.useMemo(() => ({
1158
+ reference: g || n.reference || null,
1159
+ floating: n.floating || null,
1160
+ domReference: n.reference
1161
+ }), [g, n.reference, n.floating]);
1162
+ return c.useMemo(() => ({
1163
+ dataRef: i,
1164
+ open: t,
1165
+ onOpenChange: R,
1166
+ elements: E,
1167
+ events: s,
1295
1168
  floatingId: o,
1296
- refs: b
1297
- }), [e, m, p, i, o, b]);
1169
+ refs: x
1170
+ }), [t, R, E, s, o, x]);
1298
1171
  }
1299
- function rr(t) {
1300
- t === void 0 && (t = {});
1172
+ function br(e) {
1173
+ e === void 0 && (e = {});
1301
1174
  const {
1302
- nodeId: e
1303
- } = t, n = _n({
1304
- ...t,
1175
+ nodeId: t
1176
+ } = e, r = Jn({
1177
+ ...e,
1305
1178
  elements: {
1306
1179
  reference: null,
1307
1180
  floating: null,
1308
- ...t.elements
1181
+ ...e.elements
1309
1182
  }
1310
- }), r = t.rootContext || n, o = r.elements, [s, i] = u.useState(null), [c, v] = u.useState(null), m = (o == null ? void 0 : o.domReference) || s, b = u.useRef(null), p = ke();
1311
- G(() => {
1312
- m && (b.current = m);
1313
- }, [m]);
1314
- const l = dn({
1315
- ...t,
1183
+ }), n = e.rootContext || r, o = n.elements, [i, s] = c.useState(null), [a, g] = c.useState(null), R = (o == null ? void 0 : o.domReference) || i, x = c.useRef(null), E = Oe();
1184
+ ee(() => {
1185
+ R && (x.current = R);
1186
+ }, [R]);
1187
+ const f = kn({
1188
+ ...e,
1316
1189
  elements: {
1317
1190
  ...o,
1318
- ...c && {
1319
- reference: c
1191
+ ...a && {
1192
+ reference: a
1320
1193
  }
1321
1194
  }
1322
- }), g = u.useCallback((h) => {
1323
- const F = oe(h) ? {
1195
+ }), v = c.useCallback((h) => {
1196
+ const T = fe(h) ? {
1324
1197
  getBoundingClientRect: () => h.getBoundingClientRect(),
1198
+ getClientRects: () => h.getClientRects(),
1325
1199
  contextElement: h
1326
1200
  } : h;
1327
- v(F), l.refs.setReference(F);
1328
- }, [l.refs]), a = u.useCallback((h) => {
1329
- (oe(h) || h === null) && (b.current = h, i(h)), (oe(l.refs.reference.current) || l.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
1201
+ g(T), f.refs.setReference(T);
1202
+ }, [f.refs]), l = c.useCallback((h) => {
1203
+ (fe(h) || h === null) && (x.current = h, s(h)), (fe(f.refs.reference.current) || f.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
1330
1204
  // `null` to support `positionReference` + an unstable `reference`
1331
1205
  // callback ref.
1332
- h !== null && !oe(h)) && l.refs.setReference(h);
1333
- }, [l.refs]), k = u.useMemo(() => ({
1334
- ...l.refs,
1335
- setReference: a,
1336
- setPositionReference: g,
1337
- domReference: b
1338
- }), [l.refs, a, g]), A = u.useMemo(() => ({
1339
- ...l.elements,
1340
- domReference: m
1341
- }), [l.elements, m]), N = u.useMemo(() => ({
1342
- ...l,
1343
- ...r,
1344
- refs: k,
1345
- elements: A,
1346
- nodeId: e
1347
- }), [l, k, A, e, r]);
1348
- return G(() => {
1349
- r.dataRef.current.floatingContext = N;
1350
- const h = p == null ? void 0 : p.nodesRef.current.find((F) => F.id === e);
1351
- h && (h.context = N);
1352
- }), u.useMemo(() => ({
1353
- ...l,
1354
- context: N,
1355
- refs: k,
1356
- elements: A
1357
- }), [l, k, A, N]);
1206
+ h !== null && !fe(h)) && f.refs.setReference(h);
1207
+ }, [f.refs]), w = c.useMemo(() => ({
1208
+ ...f.refs,
1209
+ setReference: l,
1210
+ setPositionReference: v,
1211
+ domReference: x
1212
+ }), [f.refs, l, v]), k = c.useMemo(() => ({
1213
+ ...f.elements,
1214
+ domReference: R
1215
+ }), [f.elements, R]), b = c.useMemo(() => ({
1216
+ ...f,
1217
+ ...n,
1218
+ refs: w,
1219
+ elements: k,
1220
+ nodeId: t
1221
+ }), [f, w, k, t, n]);
1222
+ return ee(() => {
1223
+ n.dataRef.current.floatingContext = b;
1224
+ const h = E == null ? void 0 : E.nodesRef.current.find((T) => T.id === t);
1225
+ h && (h.context = b);
1226
+ }), c.useMemo(() => ({
1227
+ ...f,
1228
+ context: b,
1229
+ refs: w,
1230
+ elements: k
1231
+ }), [f, w, k, b]);
1358
1232
  }
1359
- function or(t, e) {
1360
- e === void 0 && (e = {});
1233
+ function at() {
1234
+ return yn() && Zt();
1235
+ }
1236
+ function Rr(e, t) {
1237
+ t === void 0 && (t = {});
1361
1238
  const {
1362
- open: n,
1363
- onOpenChange: r,
1239
+ open: r,
1240
+ onOpenChange: n,
1364
1241
  events: o,
1365
- dataRef: s,
1366
- elements: i
1367
- } = t, {
1368
- enabled: c = !0,
1369
- visibleOnly: v = !0
1370
- } = e, f = u.useRef(!1), m = u.useRef(), b = u.useRef(!0);
1371
- u.useEffect(() => {
1372
- if (!c) return;
1373
- const l = cn(i.domReference);
1374
- function g() {
1375
- !n && ge(i.domReference) && i.domReference === ae(re(i.domReference)) && (f.current = !0);
1242
+ dataRef: i,
1243
+ elements: s
1244
+ } = e, {
1245
+ enabled: a = !0,
1246
+ visibleOnly: g = !0
1247
+ } = t, m = c.useRef(!1), R = c.useRef(-1), x = c.useRef(!0);
1248
+ c.useEffect(() => {
1249
+ if (!a) return;
1250
+ const f = xn(s.domReference);
1251
+ function v() {
1252
+ !r && ye(s.domReference) && s.domReference === we(ge(s.domReference)) && (m.current = !0);
1376
1253
  }
1377
- function a() {
1378
- b.current = !0;
1254
+ function l() {
1255
+ x.current = !0;
1379
1256
  }
1380
- return l.addEventListener("blur", g), l.addEventListener("keydown", a, !0), () => {
1381
- l.removeEventListener("blur", g), l.removeEventListener("keydown", a, !0);
1257
+ function w() {
1258
+ x.current = !1;
1259
+ }
1260
+ return f.addEventListener("blur", v), at() && (f.addEventListener("keydown", l, !0), f.addEventListener("pointerdown", w, !0)), () => {
1261
+ f.removeEventListener("blur", v), at() && (f.removeEventListener("keydown", l, !0), f.removeEventListener("pointerdown", w, !0));
1382
1262
  };
1383
- }, [i.domReference, n, c]), u.useEffect(() => {
1384
- if (!c) return;
1385
- function l(g) {
1263
+ }, [s.domReference, r, a]), c.useEffect(() => {
1264
+ if (!a) return;
1265
+ function f(v) {
1386
1266
  let {
1387
- reason: a
1388
- } = g;
1389
- (a === "reference-press" || a === "escape-key") && (f.current = !0);
1267
+ reason: l
1268
+ } = v;
1269
+ (l === "reference-press" || l === "escape-key") && (m.current = !0);
1390
1270
  }
1391
- return o.on("openchange", l), () => {
1392
- o.off("openchange", l);
1271
+ return o.on("openchange", f), () => {
1272
+ o.off("openchange", f);
1393
1273
  };
1394
- }, [o, c]), u.useEffect(() => () => {
1395
- clearTimeout(m.current);
1274
+ }, [o, a]), c.useEffect(() => () => {
1275
+ me(R);
1396
1276
  }, []);
1397
- const p = u.useMemo(() => ({
1398
- onPointerDown(l) {
1399
- lt(l.nativeEvent) || (b.current = !1);
1400
- },
1277
+ const E = c.useMemo(() => ({
1401
1278
  onMouseLeave() {
1402
- f.current = !1;
1279
+ m.current = !1;
1403
1280
  },
1404
- onFocus(l) {
1405
- if (f.current) return;
1406
- const g = pe(l.nativeEvent);
1407
- if (v && oe(g))
1408
- try {
1409
- if (at() && Ht()) throw Error();
1410
- if (!g.matches(":focus-visible")) return;
1411
- } catch {
1412
- if (!b.current && !Bt(g))
1281
+ onFocus(f) {
1282
+ if (m.current) return;
1283
+ const v = xe(f.nativeEvent);
1284
+ if (g && fe(v)) {
1285
+ if (at() && !f.relatedTarget) {
1286
+ if (!x.current && !Qt(v))
1413
1287
  return;
1414
- }
1415
- r(!0, l.nativeEvent, "focus");
1288
+ } else if (!dn(v))
1289
+ return;
1290
+ }
1291
+ n(!0, f.nativeEvent, "focus");
1416
1292
  },
1417
- onBlur(l) {
1418
- f.current = !1;
1419
- const g = l.relatedTarget, a = l.nativeEvent, k = oe(g) && g.hasAttribute(Oe("focus-guard")) && g.getAttribute("data-type") === "outside";
1420
- m.current = window.setTimeout(() => {
1421
- var A;
1422
- const N = ae(i.domReference ? i.domReference.ownerDocument : document);
1423
- !g && N === i.domReference || ee((A = s.current.floatingContext) == null ? void 0 : A.refs.floating.current, N) || ee(i.domReference, N) || k || r(!1, a, "focus");
1293
+ onBlur(f) {
1294
+ m.current = !1;
1295
+ const v = f.relatedTarget, l = f.nativeEvent, w = fe(v) && v.hasAttribute(Pe("focus-guard")) && v.getAttribute("data-type") === "outside";
1296
+ R.current = window.setTimeout(() => {
1297
+ var k;
1298
+ const b = we(s.domReference ? s.domReference.ownerDocument : document);
1299
+ !v && b === s.domReference || ae((k = i.current.floatingContext) == null ? void 0 : k.refs.floating.current, b) || ae(s.domReference, b) || w || n(!1, l, "focus");
1424
1300
  });
1425
1301
  }
1426
- }), [s, i.domReference, r, v]);
1427
- return u.useMemo(() => c ? {
1428
- reference: p
1429
- } : {}, [c, p]);
1302
+ }), [i, s.domReference, n, g]);
1303
+ return c.useMemo(() => a ? {
1304
+ reference: E
1305
+ } : {}, [a, E]);
1430
1306
  }
1431
- const Dt = "active", At = "selected";
1432
- function st(t, e, n) {
1433
- const r = /* @__PURE__ */ new Map(), o = n === "item";
1434
- let s = t;
1435
- if (o && t) {
1307
+ function ft(e, t, r) {
1308
+ const n = /* @__PURE__ */ new Map(), o = r === "item";
1309
+ let i = e;
1310
+ if (o && e) {
1436
1311
  const {
1437
- [Dt]: i,
1438
- [At]: c,
1439
- ...v
1440
- } = t;
1441
- s = v;
1312
+ [Ct]: s,
1313
+ [Mt]: a,
1314
+ ...g
1315
+ } = e;
1316
+ i = g;
1442
1317
  }
1443
1318
  return {
1444
- ...n === "floating" && {
1319
+ ...r === "floating" && {
1445
1320
  tabIndex: -1,
1446
- [ut]: ""
1321
+ [On]: ""
1447
1322
  },
1448
- ...s,
1449
- ...e.map((i) => {
1450
- const c = i ? i[n] : null;
1451
- return typeof c == "function" ? t ? c(t) : null : c;
1452
- }).concat(t).reduce((i, c) => (c && Object.entries(c).forEach((v) => {
1453
- let [f, m] = v;
1454
- if (!(o && [Dt, At].includes(f)))
1455
- if (f.indexOf("on") === 0) {
1456
- if (r.has(f) || r.set(f, []), typeof m == "function") {
1457
- var b;
1458
- (b = r.get(f)) == null || b.push(m), i[f] = function() {
1459
- for (var p, l = arguments.length, g = new Array(l), a = 0; a < l; a++)
1460
- g[a] = arguments[a];
1461
- return (p = r.get(f)) == null ? void 0 : p.map((k) => k(...g)).find((k) => k !== void 0);
1323
+ ...i,
1324
+ ...t.map((s) => {
1325
+ const a = s ? s[r] : null;
1326
+ return typeof a == "function" ? e ? a(e) : null : a;
1327
+ }).concat(e).reduce((s, a) => (a && Object.entries(a).forEach((g) => {
1328
+ let [m, R] = g;
1329
+ if (!(o && [Ct, Mt].includes(m)))
1330
+ if (m.indexOf("on") === 0) {
1331
+ if (n.has(m) || n.set(m, []), typeof R == "function") {
1332
+ var x;
1333
+ (x = n.get(m)) == null || x.push(R), s[m] = function() {
1334
+ for (var E, f = arguments.length, v = new Array(f), l = 0; l < f; l++)
1335
+ v[l] = arguments[l];
1336
+ return (E = n.get(m)) == null ? void 0 : E.map((w) => w(...v)).find((w) => w !== void 0);
1462
1337
  };
1463
1338
  }
1464
1339
  } else
1465
- i[f] = m;
1466
- }), i), {})
1340
+ s[m] = R;
1341
+ }), s), {})
1467
1342
  };
1468
1343
  }
1469
- function sr(t) {
1470
- t === void 0 && (t = []);
1471
- const e = t.map((c) => c == null ? void 0 : c.reference), n = t.map((c) => c == null ? void 0 : c.floating), r = t.map((c) => c == null ? void 0 : c.item), o = u.useCallback(
1472
- (c) => st(c, t, "reference"),
1344
+ function hr(e) {
1345
+ e === void 0 && (e = []);
1346
+ const t = e.map((a) => a == null ? void 0 : a.reference), r = e.map((a) => a == null ? void 0 : a.floating), n = e.map((a) => a == null ? void 0 : a.item), o = c.useCallback(
1347
+ (a) => ft(a, e, "reference"),
1473
1348
  // eslint-disable-next-line react-hooks/exhaustive-deps
1474
- e
1475
- ), s = u.useCallback(
1476
- (c) => st(c, t, "floating"),
1477
- // eslint-disable-next-line react-hooks/exhaustive-deps
1478
- n
1479
- ), i = u.useCallback(
1480
- (c) => st(c, t, "item"),
1349
+ t
1350
+ ), i = c.useCallback(
1351
+ (a) => ft(a, e, "floating"),
1481
1352
  // eslint-disable-next-line react-hooks/exhaustive-deps
1482
1353
  r
1354
+ ), s = c.useCallback(
1355
+ (a) => ft(a, e, "item"),
1356
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1357
+ n
1483
1358
  );
1484
- return u.useMemo(() => ({
1359
+ return c.useMemo(() => ({
1485
1360
  getReferenceProps: o,
1486
- getFloatingProps: s,
1487
- getItemProps: i
1488
- }), [o, s, i]);
1361
+ getFloatingProps: i,
1362
+ getItemProps: s
1363
+ }), [o, i, s]);
1489
1364
  }
1490
- let Nt = !1;
1491
- function Ze(t, e, n) {
1492
- switch (t) {
1365
+ const er = "Escape";
1366
+ function et(e, t, r) {
1367
+ switch (e) {
1493
1368
  case "vertical":
1494
- return e;
1369
+ return t;
1495
1370
  case "horizontal":
1496
- return n;
1371
+ return r;
1497
1372
  default:
1498
- return e || n;
1373
+ return t || r;
1499
1374
  }
1500
1375
  }
1501
- function Kt(t, e) {
1502
- return Ze(e, t === ft || t === _e, t === ye || t === xe);
1376
+ function Ue(e, t) {
1377
+ return et(t, e === on || e === Je, e === _e || e === Ke);
1503
1378
  }
1504
- function it(t, e, n) {
1505
- return Ze(e, t === _e, n ? t === ye : t === xe) || t === "Enter" || t === " " || t === "";
1379
+ function dt(e, t, r) {
1380
+ return et(t, e === Je, r ? e === _e : e === Ke) || e === "Enter" || e === " " || e === "";
1506
1381
  }
1507
- function Vn(t, e, n) {
1508
- return Ze(e, n ? t === ye : t === xe, t === _e);
1382
+ function Yt(e, t, r) {
1383
+ return et(t, r ? e === _e : e === Ke, e === Je);
1509
1384
  }
1510
- function _t(t, e, n) {
1511
- return Ze(e, n ? t === xe : t === ye, t === ft);
1385
+ function qt(e, t, r, n) {
1386
+ const o = r ? e === Ke : e === _e, i = e === on;
1387
+ return t === "both" || t === "horizontal" && n && n > 1 ? e === er : et(t, o, i);
1512
1388
  }
1513
- function ir(t, e) {
1389
+ function Er(e, t) {
1514
1390
  const {
1515
- open: n,
1516
- onOpenChange: r,
1517
- elements: o
1518
- } = t, {
1391
+ open: r,
1392
+ onOpenChange: n,
1393
+ elements: o,
1394
+ floatingId: i
1395
+ } = e, {
1519
1396
  listRef: s,
1520
- activeIndex: i,
1521
- onNavigate: c = () => {
1397
+ activeIndex: a,
1398
+ onNavigate: g = () => {
1522
1399
  },
1523
- enabled: v = !0,
1524
- selectedIndex: f = null,
1525
- allowEscape: m = !1,
1526
- loop: b = !1,
1527
- nested: p = !1,
1528
- rtl: l = !1,
1529
- virtual: g = !1,
1530
- focusItemOnOpen: a = "auto",
1400
+ enabled: m = !0,
1401
+ selectedIndex: R = null,
1402
+ allowEscape: x = !1,
1403
+ loop: E = !1,
1404
+ nested: f = !1,
1405
+ rtl: v = !1,
1406
+ virtual: l = !1,
1407
+ focusItemOnOpen: w = "auto",
1531
1408
  focusItemOnHover: k = !0,
1532
- openOnArrowKeyDown: A = !0,
1533
- disabledIndices: N = void 0,
1534
- orientation: h = "vertical",
1535
- cols: F = 1,
1536
- scrollItemIntoView: Y = !0,
1537
- virtualItemRef: V,
1538
- itemSizes: X,
1539
- dense: q = !1
1540
- } = e;
1541
- process.env.NODE_ENV !== "production" && (m && (b || $e("`useListNavigation` looping must be enabled to allow escaping."), g || $e("`useListNavigation` must be virtual to allow escaping.")), h === "vertical" && F > 1 && $e("In grid list navigation mode (`cols` > 1), the `orientation` should", 'be either "horizontal" or "both".'));
1542
- const U = Zt(o.floating), $ = fe(U), B = We(), R = ke(), I = ue(c), E = ct(o.domReference), w = u.useRef(a), y = u.useRef(f ?? -1), x = u.useRef(null), T = u.useRef(!0), d = u.useRef(I), C = u.useRef(!!o.floating), O = u.useRef(n), H = u.useRef(!1), ne = u.useRef(!1), L = fe(N), K = fe(n), M = fe(Y), D = fe(f), [P, W] = u.useState(), [j, J] = u.useState(), te = ue(function(_, Q, S) {
1543
- S === void 0 && (S = !1);
1544
- function z(Z) {
1545
- g ? (W(Z.id), R == null || R.events.emit("virtualfocus", Z), V && (V.current = Z)) : Re(Z, {
1546
- preventScroll: !0,
1547
- // Mac Safari does not move the virtual cursor unless the focus call
1548
- // is sync. However, for the very first focus call, we need to wait
1549
- // for the position to be ready in order to prevent unwanted
1550
- // scrolling. This means the virtual cursor will not move to the first
1551
- // item when first opening the floating element, but will on
1552
- // subsequent calls. `preventScroll` is supported in modern Safari,
1553
- // so we can use that instead.
1554
- // iOS Safari must be async or the first item will not be focused.
1555
- sync: Ht() && at() ? Nt || H.current : !1
1556
- });
1409
+ openOnArrowKeyDown: b = !0,
1410
+ disabledIndices: h = void 0,
1411
+ orientation: T = "vertical",
1412
+ parentOrientation: $,
1413
+ cols: H = 1,
1414
+ scrollItemIntoView: B = !0,
1415
+ virtualItemRef: _,
1416
+ itemSizes: oe,
1417
+ dense: j = !1
1418
+ } = t;
1419
+ process.env.NODE_ENV !== "production" && (x && (E || ze("`useListNavigation` looping must be enabled to allow escaping."), l || ze("`useListNavigation` must be virtual to allow escaping.")), T === "vertical" && H > 1 && ze("In grid list navigation mode (`cols` > 1), the `orientation` should", 'be either "horizontal" or "both".'));
1420
+ const q = Qe(o.floating), X = Re(q), F = Ve(), u = Oe();
1421
+ ee(() => {
1422
+ e.dataRef.current.orientation = T;
1423
+ }, [e, T]);
1424
+ const p = ce(() => {
1425
+ g(d.current === -1 ? null : d.current);
1426
+ }), K = mt(o.domReference), y = c.useRef(w), d = c.useRef(R ?? -1), I = c.useRef(null), O = c.useRef(!0), G = c.useRef(p), S = c.useRef(!!o.floating), M = c.useRef(r), U = c.useRef(!1), N = c.useRef(!1), ne = Re(h), se = Re(r), Z = Re(B), J = Re(R), [ie, pe] = c.useState(), [L, W] = c.useState(), D = ce(() => {
1427
+ function P(Q) {
1428
+ if (l) {
1429
+ var re;
1430
+ (re = Q.id) != null && re.endsWith("-fui-option") && (Q.id = i + "-" + Math.random().toString(16).slice(2, 10)), pe(Q.id), u == null || u.events.emit("virtualfocus", Q), _ && (_.current = Q);
1431
+ } else
1432
+ Me(Q, {
1433
+ sync: U.current,
1434
+ preventScroll: !0
1435
+ });
1557
1436
  }
1558
- const le = _.current[Q.current];
1559
- le && z(le), requestAnimationFrame(() => {
1560
- const Z = _.current[Q.current] || le;
1561
- if (!Z) return;
1562
- le || z(Z);
1563
- const de = M.current;
1564
- de && ve && (S || !T.current) && (Z.scrollIntoView == null || Z.scrollIntoView(typeof de == "boolean" ? {
1437
+ const A = s.current[d.current], C = N.current;
1438
+ A && P(A), (U.current ? (Q) => Q() : requestAnimationFrame)(() => {
1439
+ const Q = s.current[d.current] || A;
1440
+ if (!Q) return;
1441
+ A || P(Q);
1442
+ const re = Z.current;
1443
+ re && te && (C || !O.current) && (Q.scrollIntoView == null || Q.scrollIntoView(typeof re == "boolean" ? {
1565
1444
  block: "nearest",
1566
1445
  inline: "nearest"
1567
- } : de));
1446
+ } : re));
1568
1447
  });
1569
1448
  });
1570
- G(() => {
1571
- document.createElement("div").focus({
1572
- get preventScroll() {
1573
- return Nt = !0, !1;
1574
- }
1575
- });
1576
- }, []), G(() => {
1577
- v && (n && o.floating ? w.current && f != null && (ne.current = !0, y.current = f, I(f)) : C.current && (y.current = -1, d.current(null)));
1578
- }, [v, n, o.floating, f, I]), G(() => {
1579
- if (v && n && o.floating)
1580
- if (i == null) {
1581
- if (H.current = !1, D.current != null)
1449
+ ee(() => {
1450
+ m && (r && o.floating ? y.current && R != null && (N.current = !0, d.current = R, p()) : S.current && (d.current = -1, G.current()));
1451
+ }, [m, r, o.floating, R, p]), ee(() => {
1452
+ if (m && r && o.floating)
1453
+ if (a == null) {
1454
+ if (U.current = !1, J.current != null)
1582
1455
  return;
1583
- if (C.current && (y.current = -1, te(s, y)), (!O.current || !C.current) && w.current && (x.current != null || w.current === !0 && x.current == null)) {
1584
- let _ = 0;
1585
- const Q = () => {
1586
- s.current[0] == null ? (_ < 2 && (_ ? requestAnimationFrame : queueMicrotask)(Q), _++) : (y.current = x.current == null || it(x.current, h, l) || p ? tt(s, L.current) : Et(s, L.current), x.current = null, I(y.current));
1456
+ if (S.current && (d.current = -1, D()), (!M.current || !S.current) && y.current && (I.current != null || y.current === !0 && I.current == null)) {
1457
+ let P = 0;
1458
+ const A = () => {
1459
+ s.current[0] == null ? (P < 2 && (P ? requestAnimationFrame : queueMicrotask)(A), P++) : (d.current = I.current == null || dt(I.current, T, v) || f ? tt(s, ne.current) : It(s, ne.current), I.current = null, p());
1587
1460
  };
1588
- Q();
1461
+ A();
1589
1462
  }
1590
- } else Se(s, i) || (y.current = i, te(s, y, ne.current), ne.current = !1);
1591
- }, [v, n, o.floating, i, D, p, s, h, l, I, te, L]), G(() => {
1592
- var _;
1593
- if (!v || o.floating || !R || g || !C.current)
1463
+ } else xt(s, a) || (d.current = a, D(), N.current = !1);
1464
+ }, [m, r, o.floating, a, J, f, s, T, v, p, D, ne]), ee(() => {
1465
+ var P;
1466
+ if (!m || o.floating || !u || l || !S.current)
1594
1467
  return;
1595
- const Q = R.nodesRef.current, S = (_ = Q.find((Z) => Z.id === B)) == null || (_ = _.context) == null ? void 0 : _.elements.floating, z = ae(re(o.floating)), le = Q.some((Z) => Z.context && ee(Z.context.elements.floating, z));
1596
- S && !le && T.current && S.focus({
1468
+ const A = u.nodesRef.current, C = (P = A.find((re) => re.id === F)) == null || (P = P.context) == null ? void 0 : P.elements.floating, Y = we(ge(o.floating)), Q = A.some((re) => re.context && ae(re.context.elements.floating, Y));
1469
+ C && !Q && O.current && C.focus({
1597
1470
  preventScroll: !0
1598
1471
  });
1599
- }, [v, o.floating, R, B, g]), G(() => {
1600
- if (!v || !R || !g || B) return;
1601
- function _(Q) {
1602
- J(Q.id), V && (V.current = Q);
1472
+ }, [m, o.floating, u, F, l]), ee(() => {
1473
+ if (!m || !u || !l || F) return;
1474
+ function P(A) {
1475
+ W(A.id), _ && (_.current = A);
1603
1476
  }
1604
- return R.events.on("virtualfocus", _), () => {
1605
- R.events.off("virtualfocus", _);
1477
+ return u.events.on("virtualfocus", P), () => {
1478
+ u.events.off("virtualfocus", P);
1606
1479
  };
1607
- }, [v, R, g, B, V]), G(() => {
1608
- d.current = I, C.current = !!o.floating;
1609
- }), G(() => {
1610
- n || (x.current = null);
1611
- }, [n]), G(() => {
1612
- O.current = n;
1613
- }, [n]);
1614
- const we = i != null, ve = u.useMemo(() => {
1615
- function _(S) {
1616
- if (!n) return;
1617
- const z = s.current.indexOf(S);
1618
- z !== -1 && I(z);
1480
+ }, [m, u, l, F, _]), ee(() => {
1481
+ G.current = p, M.current = r, S.current = !!o.floating;
1482
+ }), ee(() => {
1483
+ r || (I.current = null, y.current = w);
1484
+ }, [r, w]);
1485
+ const z = a != null, te = c.useMemo(() => {
1486
+ function P(C) {
1487
+ if (!se.current) return;
1488
+ const Y = s.current.indexOf(C);
1489
+ Y !== -1 && d.current !== Y && (d.current = Y, p());
1619
1490
  }
1620
1491
  return {
1621
- onFocus(S) {
1492
+ onFocus(C) {
1622
1493
  let {
1623
- currentTarget: z
1624
- } = S;
1625
- _(z);
1494
+ currentTarget: Y
1495
+ } = C;
1496
+ U.current = !0, P(Y);
1626
1497
  },
1627
- onClick: (S) => {
1498
+ onClick: (C) => {
1628
1499
  let {
1629
- currentTarget: z
1630
- } = S;
1631
- return z.focus({
1500
+ currentTarget: Y
1501
+ } = C;
1502
+ return Y.focus({
1632
1503
  preventScroll: !0
1633
1504
  });
1634
1505
  },
1635
1506
  // Safari
1636
- ...k && {
1637
- onMouseMove(S) {
1638
- let {
1639
- currentTarget: z
1640
- } = S;
1641
- _(z);
1642
- },
1643
- onPointerLeave(S) {
1644
- let {
1645
- pointerType: z
1646
- } = S;
1647
- !T.current || z === "touch" || (y.current = -1, te(s, y), I(null), g || Re($.current, {
1507
+ onMouseMove(C) {
1508
+ let {
1509
+ currentTarget: Y
1510
+ } = C;
1511
+ U.current = !0, N.current = !1, k && P(Y);
1512
+ },
1513
+ onPointerLeave(C) {
1514
+ let {
1515
+ pointerType: Y
1516
+ } = C;
1517
+ if (!(!O.current || Y === "touch") && (U.current = !0, !!k && (d.current = -1, p(), !l))) {
1518
+ var Q;
1519
+ (Q = X.current) == null || Q.focus({
1648
1520
  preventScroll: !0
1649
- }));
1521
+ });
1650
1522
  }
1651
1523
  }
1652
1524
  };
1653
- }, [n, $, te, k, s, I, g]), ce = ue((_) => {
1654
- if (T.current = !1, H.current = !0, _.which === 229 || !K.current && _.currentTarget === $.current)
1525
+ }, [se, X, k, s, p, l]), V = c.useCallback(() => {
1526
+ var P;
1527
+ return $ ?? (u == null || (P = u.nodesRef.current.find((A) => A.id === F)) == null || (P = P.context) == null || (P = P.dataRef) == null ? void 0 : P.current.orientation);
1528
+ }, [F, u, $]), de = ce((P) => {
1529
+ if (O.current = !1, U.current = !0, P.which === 229 || !se.current && P.currentTarget === X.current)
1655
1530
  return;
1656
- if (p && _t(_.key, h, l)) {
1657
- ie(_), r(!1, _.nativeEvent, "list-navigation"), ge(o.domReference) && (g ? R == null || R.events.emit("virtualfocus", o.domReference) : o.domReference.focus());
1531
+ if (f && qt(P.key, T, v, H)) {
1532
+ Ue(P.key, V()) || he(P), n(!1, P.nativeEvent, "list-navigation"), ye(o.domReference) && (l ? u == null || u.events.emit("virtualfocus", o.domReference) : o.domReference.focus());
1658
1533
  return;
1659
1534
  }
1660
- const Q = y.current, S = tt(s, N), z = Et(s, N);
1661
- if (E || (_.key === "Home" && (ie(_), y.current = S, I(y.current)), _.key === "End" && (ie(_), y.current = z, I(y.current))), F > 1) {
1662
- const le = X || Array.from({
1535
+ const A = d.current, C = tt(s, h), Y = It(s, h);
1536
+ if (K || (P.key === "Home" && (he(P), d.current = C, p()), P.key === "End" && (he(P), d.current = Y, p())), H > 1) {
1537
+ const Q = oe || Array.from({
1663
1538
  length: s.current.length
1664
1539
  }, () => ({
1665
1540
  width: 1,
1666
1541
  height: 1
1667
- })), Z = vn(le, F, q), de = Z.findIndex((me) => me != null && !Ue(s.current, me, N)), Le = Z.reduce((me, he, He) => he != null && !Ue(s.current, he, N) ? He : me, -1), Ie = Z[gn({
1668
- current: Z.map((me) => me != null ? s.current[me] : null)
1542
+ })), re = vn(Q, H, j), Le = re.findIndex((be) => be != null && !rt(s, be, h)), He = re.reduce((be, Ce, Be) => Ce != null && !rt(s, Ce, h) ? Be : be, -1), Fe = re[bn({
1543
+ current: re.map((be) => be != null ? s.current[be] : null)
1669
1544
  }, {
1670
- event: _,
1671
- orientation: h,
1672
- loop: b,
1673
- rtl: l,
1674
- cols: F,
1545
+ event: P,
1546
+ orientation: T,
1547
+ loop: E,
1548
+ rtl: v,
1549
+ cols: H,
1675
1550
  // treat undefined (empty grid spaces) as disabled indices so we
1676
1551
  // don't end up in them
1677
- disabledIndices: hn([...N || s.current.map((me, he) => Ue(s.current, he) ? he : void 0), void 0], Z),
1678
- minIndex: de,
1679
- maxIndex: Le,
1680
- prevIndex: bn(
1681
- y.current > z ? S : y.current,
1682
- le,
1683
- Z,
1684
- F,
1552
+ disabledIndices: hn([...(typeof h != "function" ? h : null) || s.current.map((be, Ce) => rt(s, Ce, h) ? Ce : void 0), void 0], re),
1553
+ minIndex: Le,
1554
+ maxIndex: He,
1555
+ prevIndex: Rn(
1556
+ d.current > Y ? C : d.current,
1557
+ Q,
1558
+ re,
1559
+ H,
1685
1560
  // use a corner matching the edge closest to the direction
1686
1561
  // we're moving in so we don't end up in the same item. Prefer
1687
1562
  // top/left over bottom/right.
1688
- _.key === _e ? "bl" : _.key === (l ? ye : xe) ? "tr" : "tl"
1563
+ P.key === Je ? "bl" : P.key === (v ? _e : Ke) ? "tr" : "tl"
1689
1564
  ),
1690
1565
  stopEvent: !0
1691
1566
  })];
1692
- if (Ie != null && (y.current = Ie, I(y.current)), h === "both")
1567
+ if (Fe != null && (d.current = Fe, p()), T === "both")
1693
1568
  return;
1694
1569
  }
1695
- if (Kt(_.key, h)) {
1696
- if (ie(_), n && !g && ae(_.currentTarget.ownerDocument) === _.currentTarget) {
1697
- y.current = it(_.key, h, l) ? S : z, I(y.current);
1570
+ if (Ue(P.key, T)) {
1571
+ if (he(P), r && !l && we(P.currentTarget.ownerDocument) === P.currentTarget) {
1572
+ d.current = dt(P.key, T, v) ? C : Y, p();
1698
1573
  return;
1699
1574
  }
1700
- it(_.key, h, l) ? b ? y.current = Q >= z ? m && Q !== s.current.length ? -1 : S : se(s, {
1701
- startingIndex: Q,
1702
- disabledIndices: N
1703
- }) : y.current = Math.min(z, se(s, {
1704
- startingIndex: Q,
1705
- disabledIndices: N
1706
- })) : b ? y.current = Q <= S ? m && Q !== -1 ? s.current.length : z : se(s, {
1707
- startingIndex: Q,
1575
+ dt(P.key, T, v) ? E ? d.current = A >= Y ? x && A !== s.current.length ? -1 : C : qe(s, {
1576
+ startingIndex: A,
1577
+ disabledIndices: h
1578
+ }) : d.current = Math.min(Y, qe(s, {
1579
+ startingIndex: A,
1580
+ disabledIndices: h
1581
+ })) : E ? d.current = A <= C ? x && A !== -1 ? s.current.length : Y : qe(s, {
1582
+ startingIndex: A,
1708
1583
  decrement: !0,
1709
- disabledIndices: N
1710
- }) : y.current = Math.max(S, se(s, {
1711
- startingIndex: Q,
1584
+ disabledIndices: h
1585
+ }) : d.current = Math.max(C, qe(s, {
1586
+ startingIndex: A,
1712
1587
  decrement: !0,
1713
- disabledIndices: N
1714
- })), Se(s, y.current) ? I(null) : I(y.current);
1588
+ disabledIndices: h
1589
+ })), xt(s, d.current) && (d.current = -1), p();
1715
1590
  }
1716
- }), be = u.useMemo(() => g && n && we && {
1717
- "aria-activedescendant": j || P
1718
- }, [g, n, we, j, P]), Fe = u.useMemo(() => ({
1719
- "aria-orientation": h === "both" ? void 0 : h,
1720
- ...!ct(o.domReference) && be,
1721
- onKeyDown: ce,
1591
+ }), ue = c.useMemo(() => l && r && z && {
1592
+ "aria-activedescendant": L || ie
1593
+ }, [l, r, z, L, ie]), le = c.useMemo(() => ({
1594
+ "aria-orientation": T === "both" ? void 0 : T,
1595
+ ...K ? {} : ue,
1596
+ onKeyDown: de,
1722
1597
  onPointerMove() {
1723
- T.current = !0;
1598
+ O.current = !0;
1724
1599
  }
1725
- }), [be, ce, o.domReference, h]), dt = u.useMemo(() => {
1726
- function _(S) {
1727
- a === "auto" && Wt(S.nativeEvent) && (w.current = !0);
1600
+ }), [ue, de, T, K]), Ee = c.useMemo(() => {
1601
+ function P(C) {
1602
+ w === "auto" && Gt(C.nativeEvent) && (y.current = !0);
1728
1603
  }
1729
- function Q(S) {
1730
- w.current = a, a === "auto" && lt(S.nativeEvent) && (w.current = !0);
1604
+ function A(C) {
1605
+ y.current = w, w === "auto" && jt(C.nativeEvent) && (y.current = !0);
1731
1606
  }
1732
1607
  return {
1733
- ...be,
1734
- onKeyDown(S) {
1735
- T.current = !1;
1736
- const z = S.key.startsWith("Arrow"), le = ["Home", "End"].includes(S.key), Z = z || le, de = Vn(S.key, h, l), Le = _t(S.key, h, l), Ie = Kt(S.key, h), me = (p ? de : Ie) || S.key === "Enter" || S.key.trim() === "";
1737
- if (g && n) {
1738
- const pt = R == null ? void 0 : R.nodesRef.current.find((Be) => Be.parentId == null), Ee = R && pt ? On(R.nodesRef.current, pt.id) : null;
1739
- if (Z && Ee && V) {
1740
- const Be = new KeyboardEvent("keydown", {
1741
- key: S.key,
1608
+ ...ue,
1609
+ onKeyDown(C) {
1610
+ O.current = !1;
1611
+ const Y = C.key.startsWith("Arrow"), Q = ["Home", "End"].includes(C.key), re = Y || Q, Le = Yt(C.key, T, v), He = qt(C.key, T, v, H), Fe = Yt(C.key, V(), v), be = Ue(C.key, T), Ce = (f ? Fe : be) || C.key === "Enter" || C.key.trim() === "";
1612
+ if (l && r) {
1613
+ const $e = u == null ? void 0 : u.nodesRef.current.find((Ye) => Ye.parentId == null), Ie = u && $e ? fn(u.nodesRef.current, $e.id) : null;
1614
+ if (re && Ie && _) {
1615
+ const Ye = new KeyboardEvent("keydown", {
1616
+ key: C.key,
1742
1617
  bubbles: !0
1743
1618
  });
1744
- if (de || Le) {
1745
- var he, He;
1746
- const Jt = ((he = Ee.context) == null ? void 0 : he.elements.domReference) === S.currentTarget, gt = Le && !Jt ? (He = Ee.context) == null ? void 0 : He.elements.domReference : de ? s.current.find((vt) => (vt == null ? void 0 : vt.id) === P) : null;
1747
- gt && (ie(S), gt.dispatchEvent(Be), J(void 0));
1619
+ if (Le || He) {
1620
+ var Be, Rt;
1621
+ const an = ((Be = Ie.context) == null ? void 0 : Be.elements.domReference) === C.currentTarget, Et = He && !an ? (Rt = Ie.context) == null ? void 0 : Rt.elements.domReference : Le ? s.current.find((yt) => (yt == null ? void 0 : yt.id) === ie) : null;
1622
+ Et && (he(C), Et.dispatchEvent(Ye), W(void 0));
1748
1623
  }
1749
- if ((Ie || le) && Ee.context && Ee.context.open && Ee.parentId && S.currentTarget !== Ee.context.elements.domReference) {
1750
- var mt;
1751
- ie(S), (mt = Ee.context.elements.domReference) == null || mt.dispatchEvent(Be);
1624
+ if ((be || Q) && Ie.context && Ie.context.open && Ie.parentId && C.currentTarget !== Ie.context.elements.domReference) {
1625
+ var ht;
1626
+ he(C), (ht = Ie.context.elements.domReference) == null || ht.dispatchEvent(Ye);
1752
1627
  return;
1753
1628
  }
1754
1629
  }
1755
- return ce(S);
1630
+ return de(C);
1756
1631
  }
1757
- if (!(!n && !A && z)) {
1758
- if (me && (x.current = p && Ie ? null : S.key), p) {
1759
- de && (ie(S), n ? (y.current = tt(s, L.current), I(y.current)) : r(!0, S.nativeEvent, "list-navigation"));
1632
+ if (!(!r && !b && Y)) {
1633
+ if (Ce) {
1634
+ const $e = Ue(C.key, V());
1635
+ I.current = f && $e ? null : C.key;
1636
+ }
1637
+ if (f) {
1638
+ Fe && (he(C), r ? (d.current = tt(s, ne.current), p()) : n(!0, C.nativeEvent, "list-navigation"));
1760
1639
  return;
1761
1640
  }
1762
- Ie && (f != null && (y.current = f), ie(S), !n && A ? r(!0, S.nativeEvent, "list-navigation") : ce(S), n && I(y.current));
1641
+ be && (R != null && (d.current = R), he(C), !r && b ? n(!0, C.nativeEvent, "list-navigation") : de(C), r && p());
1763
1642
  }
1764
1643
  },
1765
1644
  onFocus() {
1766
- n && !g && I(null);
1645
+ r && !l && (d.current = -1, p());
1767
1646
  },
1768
- onPointerDown: Q,
1769
- onMouseDown: _,
1770
- onClick: _
1647
+ onPointerDown: A,
1648
+ onPointerEnter: A,
1649
+ onMouseDown: P,
1650
+ onClick: P
1771
1651
  };
1772
- }, [P, be, ce, L, a, s, p, I, r, n, A, h, l, f, R, g, V]);
1773
- return u.useMemo(() => v ? {
1774
- reference: dt,
1775
- floating: Fe,
1776
- item: ve
1777
- } : {}, [v, dt, Fe, ve]);
1652
+ }, [ie, ue, H, de, ne, w, s, f, p, n, r, b, T, V, v, R, u, l, _]);
1653
+ return c.useMemo(() => m ? {
1654
+ reference: Ee,
1655
+ floating: le,
1656
+ item: te
1657
+ } : {}, [m, Ee, le, te]);
1778
1658
  }
1779
- const Wn = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
1780
- function cr(t, e) {
1781
- var n;
1782
- e === void 0 && (e = {});
1659
+ const tr = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
1660
+ function yr(e, t) {
1661
+ var r, n;
1662
+ t === void 0 && (t = {});
1783
1663
  const {
1784
- open: r,
1785
- floatingId: o
1786
- } = t, {
1787
- enabled: s = !0,
1788
- role: i = "dialog"
1789
- } = e, c = (n = Wn.get(i)) != null ? n : i, v = Ve(), m = We() != null, b = u.useMemo(() => c === "tooltip" || i === "label" ? {
1790
- ["aria-" + (i === "label" ? "labelledby" : "describedby")]: r ? o : void 0
1664
+ open: o,
1665
+ elements: i,
1666
+ floatingId: s
1667
+ } = e, {
1668
+ enabled: a = !0,
1669
+ role: g = "dialog"
1670
+ } = t, m = We(), R = ((r = i.domReference) == null ? void 0 : r.id) || m, x = c.useMemo(() => {
1671
+ var b;
1672
+ return ((b = Qe(i.floating)) == null ? void 0 : b.id) || s;
1673
+ }, [i.floating, s]), E = (n = tr.get(g)) != null ? n : g, v = Ve() != null, l = c.useMemo(() => E === "tooltip" || g === "label" ? {
1674
+ ["aria-" + (g === "label" ? "labelledby" : "describedby")]: o ? x : void 0
1791
1675
  } : {
1792
- "aria-expanded": r ? "true" : "false",
1793
- "aria-haspopup": c === "alertdialog" ? "dialog" : c,
1794
- "aria-controls": r ? o : void 0,
1795
- ...c === "listbox" && {
1676
+ "aria-expanded": o ? "true" : "false",
1677
+ "aria-haspopup": E === "alertdialog" ? "dialog" : E,
1678
+ "aria-controls": o ? x : void 0,
1679
+ ...E === "listbox" && {
1796
1680
  role: "combobox"
1797
1681
  },
1798
- ...c === "menu" && {
1799
- id: v
1682
+ ...E === "menu" && {
1683
+ id: R
1800
1684
  },
1801
- ...c === "menu" && m && {
1685
+ ...E === "menu" && v && {
1802
1686
  role: "menuitem"
1803
1687
  },
1804
- ...i === "select" && {
1688
+ ...g === "select" && {
1805
1689
  "aria-autocomplete": "none"
1806
1690
  },
1807
- ...i === "combobox" && {
1691
+ ...g === "combobox" && {
1808
1692
  "aria-autocomplete": "list"
1809
1693
  }
1810
- }, [c, o, m, r, v, i]), p = u.useMemo(() => {
1811
- const g = {
1812
- id: o,
1813
- ...c && {
1814
- role: c
1694
+ }, [E, x, v, o, R, g]), w = c.useMemo(() => {
1695
+ const b = {
1696
+ id: x,
1697
+ ...E && {
1698
+ role: E
1815
1699
  }
1816
1700
  };
1817
- return c === "tooltip" || i === "label" ? g : {
1818
- ...g,
1819
- ...c === "menu" && {
1820
- "aria-labelledby": v
1701
+ return E === "tooltip" || g === "label" ? b : {
1702
+ ...b,
1703
+ ...E === "menu" && {
1704
+ "aria-labelledby": R
1821
1705
  }
1822
1706
  };
1823
- }, [c, o, v, i]), l = u.useCallback((g) => {
1707
+ }, [E, x, R, g]), k = c.useCallback((b) => {
1824
1708
  let {
1825
- active: a,
1826
- selected: k
1827
- } = g;
1828
- const A = {
1709
+ active: h,
1710
+ selected: T
1711
+ } = b;
1712
+ const $ = {
1829
1713
  role: "option",
1830
- ...a && {
1831
- id: o + "-option"
1714
+ ...h && {
1715
+ id: x + "-fui-option"
1832
1716
  }
1833
1717
  };
1834
- switch (i) {
1718
+ switch (g) {
1835
1719
  case "select":
1836
- return {
1837
- ...A,
1838
- "aria-selected": a && k
1839
- };
1840
1720
  case "combobox":
1841
1721
  return {
1842
- ...A,
1843
- ...a && {
1844
- "aria-selected": !0
1845
- }
1722
+ ...$,
1723
+ "aria-selected": T
1846
1724
  };
1847
1725
  }
1848
1726
  return {};
1849
- }, [o, i]);
1850
- return u.useMemo(() => s ? {
1851
- reference: b,
1852
- floating: p,
1853
- item: l
1854
- } : {}, [s, b, p, l]);
1727
+ }, [x, g]);
1728
+ return c.useMemo(() => a ? {
1729
+ reference: l,
1730
+ floating: w,
1731
+ item: k
1732
+ } : {}, [a, l, w, k]);
1855
1733
  }
1856
- function Vt(t, e) {
1857
- const [n, r] = t;
1734
+ function ln(e, t, r) {
1735
+ return r === void 0 && (r = !0), e.filter((o) => {
1736
+ var i;
1737
+ return o.parentId === t && (!r || ((i = o.context) == null ? void 0 : i.open));
1738
+ }).flatMap((o) => [o, ...ln(e, o.id, r)]);
1739
+ }
1740
+ function Xt(e, t) {
1741
+ const [r, n] = e;
1858
1742
  let o = !1;
1859
- const s = e.length;
1860
- for (let i = 0, c = s - 1; i < s; c = i++) {
1861
- const [v, f] = e[i] || [0, 0], [m, b] = e[c] || [0, 0];
1862
- f >= r != b >= r && n <= (m - v) * (r - f) / (b - f) + v && (o = !o);
1743
+ const i = t.length;
1744
+ for (let s = 0, a = i - 1; s < i; a = s++) {
1745
+ const [g, m] = t[s] || [0, 0], [R, x] = t[a] || [0, 0];
1746
+ m >= n != x >= n && r <= (R - g) * (n - m) / (x - m) + g && (o = !o);
1863
1747
  }
1864
1748
  return o;
1865
1749
  }
1866
- function Hn(t, e) {
1867
- return t[0] >= e.x && t[0] <= e.x + e.width && t[1] >= e.y && t[1] <= e.y + e.height;
1750
+ function nr(e, t) {
1751
+ return e[0] >= t.x && e[0] <= t.x + t.width && e[1] >= t.y && e[1] <= t.y + t.height;
1868
1752
  }
1869
- function ur(t) {
1870
- t === void 0 && (t = {});
1753
+ function wr(e) {
1754
+ e === void 0 && (e = {});
1871
1755
  const {
1872
- buffer: e = 0.5,
1873
- blockPointerEvents: n = !1,
1874
- requireIntent: r = !0
1875
- } = t;
1876
- let o, s = !1, i = null, c = null, v = performance.now();
1877
- function f(b, p) {
1878
- const l = performance.now(), g = l - v;
1879
- if (i === null || c === null || g === 0)
1880
- return i = b, c = p, v = l, null;
1881
- const a = b - i, k = p - c, N = Math.sqrt(a * a + k * k) / g;
1882
- return i = b, c = p, v = l, N;
1756
+ buffer: t = 0.5,
1757
+ blockPointerEvents: r = !1,
1758
+ requireIntent: n = !0
1759
+ } = e, o = {
1760
+ current: -1
1761
+ };
1762
+ let i = !1, s = null, a = null, g = typeof performance < "u" ? performance.now() : 0;
1763
+ function m(x, E) {
1764
+ const f = performance.now(), v = f - g;
1765
+ if (s === null || a === null || v === 0)
1766
+ return s = x, a = E, g = f, null;
1767
+ const l = x - s, w = E - a, b = Math.sqrt(l * l + w * w) / v;
1768
+ return s = x, a = E, g = f, b;
1883
1769
  }
1884
- const m = (b) => {
1770
+ const R = (x) => {
1885
1771
  let {
1886
- x: p,
1887
- y: l,
1888
- placement: g,
1889
- elements: a,
1890
- onClose: k,
1891
- nodeId: A,
1892
- tree: N
1893
- } = b;
1894
- return function(F) {
1895
- function Y() {
1896
- clearTimeout(o), k();
1772
+ x: E,
1773
+ y: f,
1774
+ placement: v,
1775
+ elements: l,
1776
+ onClose: w,
1777
+ nodeId: k,
1778
+ tree: b
1779
+ } = x;
1780
+ return function(T) {
1781
+ function $() {
1782
+ me(o), w();
1897
1783
  }
1898
- if (clearTimeout(o), !a.domReference || !a.floating || g == null || p == null || l == null)
1784
+ if (me(o), !l.domReference || !l.floating || v == null || E == null || f == null)
1899
1785
  return;
1900
1786
  const {
1901
- clientX: V,
1902
- clientY: X
1903
- } = F, q = [V, X], U = pe(F), $ = F.type === "mouseleave", B = ee(a.floating, U), R = ee(a.domReference, U), I = a.domReference.getBoundingClientRect(), E = a.floating.getBoundingClientRect(), w = g.split("-")[0], y = p > E.right - E.width / 2, x = l > E.bottom - E.height / 2, T = Hn(q, I), d = E.width > I.width, C = E.height > I.height, O = (d ? I : E).left, H = (d ? I : E).right, ne = (C ? I : E).top, L = (C ? I : E).bottom;
1904
- if (B && (s = !0, !$))
1787
+ clientX: H,
1788
+ clientY: B
1789
+ } = T, _ = [H, B], oe = Wn(T), j = T.type === "mouseleave", q = ct(l.floating, oe), X = ct(l.domReference, oe), F = l.domReference.getBoundingClientRect(), u = l.floating.getBoundingClientRect(), p = v.split("-")[0], K = E > u.right - u.width / 2, y = f > u.bottom - u.height / 2, d = nr(_, F), I = u.width > F.width, O = u.height > F.height, G = (I ? F : u).left, S = (I ? F : u).right, M = (O ? F : u).top, U = (O ? F : u).bottom;
1790
+ if (q && (i = !0, !j))
1905
1791
  return;
1906
- if (R && (s = !1), R && !$) {
1907
- s = !0;
1792
+ if (X && (i = !1), X && !j) {
1793
+ i = !0;
1908
1794
  return;
1909
1795
  }
1910
- if ($ && oe(F.relatedTarget) && ee(a.floating, F.relatedTarget) || N && Ce(N.nodesRef.current, A).some((D) => {
1911
- let {
1912
- context: P
1913
- } = D;
1914
- return P == null ? void 0 : P.open;
1915
- }))
1796
+ if (j && fe(T.relatedTarget) && ct(l.floating, T.relatedTarget) || b && ln(b.nodesRef.current, k).length)
1916
1797
  return;
1917
- if (w === "top" && l >= I.bottom - 1 || w === "bottom" && l <= I.top + 1 || w === "left" && p >= I.right - 1 || w === "right" && p <= I.left + 1)
1918
- return Y();
1919
- let K = [];
1920
- switch (w) {
1798
+ if (p === "top" && f >= F.bottom - 1 || p === "bottom" && f <= F.top + 1 || p === "left" && E >= F.right - 1 || p === "right" && E <= F.left + 1)
1799
+ return $();
1800
+ let N = [];
1801
+ switch (p) {
1921
1802
  case "top":
1922
- K = [[O, I.top + 1], [O, E.bottom - 1], [H, E.bottom - 1], [H, I.top + 1]];
1803
+ N = [[G, F.top + 1], [G, u.bottom - 1], [S, u.bottom - 1], [S, F.top + 1]];
1923
1804
  break;
1924
1805
  case "bottom":
1925
- K = [[O, E.top + 1], [O, I.bottom - 1], [H, I.bottom - 1], [H, E.top + 1]];
1806
+ N = [[G, u.top + 1], [G, F.bottom - 1], [S, F.bottom - 1], [S, u.top + 1]];
1926
1807
  break;
1927
1808
  case "left":
1928
- K = [[E.right - 1, L], [E.right - 1, ne], [I.left + 1, ne], [I.left + 1, L]];
1809
+ N = [[u.right - 1, U], [u.right - 1, M], [F.left + 1, M], [F.left + 1, U]];
1929
1810
  break;
1930
1811
  case "right":
1931
- K = [[I.right - 1, L], [I.right - 1, ne], [E.left + 1, ne], [E.left + 1, L]];
1812
+ N = [[F.right - 1, U], [F.right - 1, M], [u.left + 1, M], [u.left + 1, U]];
1932
1813
  break;
1933
1814
  }
1934
- function M(D) {
1935
- let [P, W] = D;
1936
- switch (w) {
1815
+ function ne(se) {
1816
+ let [Z, J] = se;
1817
+ switch (p) {
1937
1818
  case "top": {
1938
- const j = [d ? P + e / 2 : y ? P + e * 4 : P - e * 4, W + e + 1], J = [d ? P - e / 2 : y ? P + e * 4 : P - e * 4, W + e + 1], te = [[E.left, y || d ? E.bottom - e : E.top], [E.right, y ? d ? E.bottom - e : E.top : E.bottom - e]];
1939
- return [j, J, ...te];
1819
+ const ie = [I ? Z + t / 2 : K ? Z + t * 4 : Z - t * 4, J + t + 1], pe = [I ? Z - t / 2 : K ? Z + t * 4 : Z - t * 4, J + t + 1], L = [[u.left, K || I ? u.bottom - t : u.top], [u.right, K ? I ? u.bottom - t : u.top : u.bottom - t]];
1820
+ return [ie, pe, ...L];
1940
1821
  }
1941
1822
  case "bottom": {
1942
- const j = [d ? P + e / 2 : y ? P + e * 4 : P - e * 4, W - e], J = [d ? P - e / 2 : y ? P + e * 4 : P - e * 4, W - e], te = [[E.left, y || d ? E.top + e : E.bottom], [E.right, y ? d ? E.top + e : E.bottom : E.top + e]];
1943
- return [j, J, ...te];
1823
+ const ie = [I ? Z + t / 2 : K ? Z + t * 4 : Z - t * 4, J - t], pe = [I ? Z - t / 2 : K ? Z + t * 4 : Z - t * 4, J - t], L = [[u.left, K || I ? u.top + t : u.bottom], [u.right, K ? I ? u.top + t : u.bottom : u.top + t]];
1824
+ return [ie, pe, ...L];
1944
1825
  }
1945
1826
  case "left": {
1946
- const j = [P + e + 1, C ? W + e / 2 : x ? W + e * 4 : W - e * 4], J = [P + e + 1, C ? W - e / 2 : x ? W + e * 4 : W - e * 4];
1947
- return [...[[x || C ? E.right - e : E.left, E.top], [x ? C ? E.right - e : E.left : E.right - e, E.bottom]], j, J];
1827
+ const ie = [Z + t + 1, O ? J + t / 2 : y ? J + t * 4 : J - t * 4], pe = [Z + t + 1, O ? J - t / 2 : y ? J + t * 4 : J - t * 4];
1828
+ return [...[[y || O ? u.right - t : u.left, u.top], [y ? O ? u.right - t : u.left : u.right - t, u.bottom]], ie, pe];
1948
1829
  }
1949
1830
  case "right": {
1950
- const j = [P - e, C ? W + e / 2 : x ? W + e * 4 : W - e * 4], J = [P - e, C ? W - e / 2 : x ? W + e * 4 : W - e * 4], te = [[x || C ? E.left + e : E.right, E.top], [x ? C ? E.left + e : E.right : E.left + e, E.bottom]];
1951
- return [j, J, ...te];
1831
+ const ie = [Z - t, O ? J + t / 2 : y ? J + t * 4 : J - t * 4], pe = [Z - t, O ? J - t / 2 : y ? J + t * 4 : J - t * 4], L = [[y || O ? u.left + t : u.right, u.top], [y ? O ? u.left + t : u.right : u.left + t, u.bottom]];
1832
+ return [ie, pe, ...L];
1952
1833
  }
1953
1834
  }
1954
1835
  }
1955
- if (!Vt([V, X], K)) {
1956
- if (s && !T)
1957
- return Y();
1958
- if (!$ && r) {
1959
- const D = f(F.clientX, F.clientY);
1960
- if (D !== null && D < 0.1)
1961
- return Y();
1836
+ if (!Xt([H, B], N)) {
1837
+ if (i && !d)
1838
+ return $();
1839
+ if (!j && n) {
1840
+ const se = m(T.clientX, T.clientY);
1841
+ if (se !== null && se < 0.1)
1842
+ return $();
1962
1843
  }
1963
- Vt([V, X], M([p, l])) ? !s && r && (o = window.setTimeout(Y, 40)) : Y();
1844
+ Xt([H, B], ne([E, f])) ? !i && n && (o.current = window.setTimeout($, 40)) : $();
1964
1845
  }
1965
1846
  };
1966
1847
  };
1967
- return m.__options = {
1968
- blockPointerEvents: n
1969
- }, m;
1848
+ return R.__options = {
1849
+ blockPointerEvents: r
1850
+ }, R;
1970
1851
  }
1971
1852
  export {
1972
- zn as FloatingArrow,
1973
- Jn as FloatingFocusManager,
1974
- er as FloatingOverlay,
1975
- Zn as FloatingPortal,
1976
- fr as arrow,
1977
- dr as flip,
1978
- et as getOverflowAncestors,
1979
- mr as offset,
1980
- ur as safePolygon,
1981
- pr as shift,
1982
- gr as size,
1983
- tr as useClick,
1984
- nr as useDismiss,
1985
- rr as useFloating,
1986
- Gn as useFloatingNodeId,
1987
- We as useFloatingParentNodeId,
1988
- Sn as useFloatingPortalNode,
1989
- _n as useFloatingRootContext,
1990
- ke as useFloatingTree,
1991
- or as useFocus,
1992
- Qn as useHover,
1993
- Ve as useId,
1994
- sr as useInteractions,
1995
- ir as useListNavigation,
1996
- $n as useMergeRefs,
1997
- cr as useRole
1853
+ lr as FloatingArrow,
1854
+ mr as FloatingFocusManager,
1855
+ pr as FloatingOverlay,
1856
+ dr as FloatingPortal,
1857
+ Tr as arrow,
1858
+ Cr as flip,
1859
+ ot as getOverflowAncestors,
1860
+ Mr as offset,
1861
+ wr as safePolygon,
1862
+ Pr as shift,
1863
+ kr as size,
1864
+ gr as useClick,
1865
+ vr as useDismiss,
1866
+ br as useFloating,
1867
+ ar as useFloatingNodeId,
1868
+ Ve as useFloatingParentNodeId,
1869
+ qn as useFloatingPortalNode,
1870
+ Jn as useFloatingRootContext,
1871
+ Oe as useFloatingTree,
1872
+ Rr as useFocus,
1873
+ fr as useHover,
1874
+ We as useId,
1875
+ hr as useInteractions,
1876
+ Er as useListNavigation,
1877
+ cr as useMergeRefs,
1878
+ yr as useRole
1998
1879
  };