@odx/foundation 1.0.0-beta.13 → 1.0.0-beta.130

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 (276) hide show
  1. package/README.md +7 -8
  2. package/dist/_virtual_class-decorator-runtime.js +13 -0
  3. package/dist/components/accordion/accordion.d.ts +14 -2
  4. package/dist/components/accordion-item/accordion-item.d.ts +25 -0
  5. package/dist/components/{accordion → accordion-panel}/accordion-panel.d.ts +0 -1
  6. package/dist/components/action-button/action-button.d.ts +26 -0
  7. package/dist/components/anchor-navigation/anchor-navigation.d.ts +3 -4
  8. package/dist/components/anchor-navigation/anchor-observer.d.ts +9 -7
  9. package/dist/components/anchor-navigation/index.d.ts +0 -1
  10. package/dist/components/area-header/area-header.d.ts +11 -5
  11. package/dist/components/auto-grid/auto-grid.d.ts +16 -0
  12. package/dist/components/avatar/avatar.d.ts +32 -7
  13. package/dist/components/badge/badge.d.ts +18 -6
  14. package/dist/components/breadcrumbs/breadcrumbs-item.d.ts +1 -4
  15. package/dist/components/breadcrumbs/breadcrumbs.d.ts +2 -5
  16. package/dist/components/breadcrumbs/index.d.ts +1 -2
  17. package/dist/components/button/button.d.ts +29 -24
  18. package/dist/components/button-group/button-group.d.ts +7 -1
  19. package/dist/components/card/card.d.ts +3 -2
  20. package/dist/components/checkbox/checkbox.d.ts +3 -4
  21. package/dist/components/checkbox-group/checkbox-group.d.ts +8 -4
  22. package/dist/components/chip/chip.d.ts +16 -4
  23. package/dist/components/combobox/autocomplete.d.ts +24 -0
  24. package/dist/components/content-box/content-box.d.ts +0 -1
  25. package/dist/components/dropdown/dropdown.d.ts +9 -13
  26. package/dist/components/empty-state/empty-state.d.ts +37 -0
  27. package/dist/components/form-field/form-field.d.ts +0 -1
  28. package/dist/components/format/base-format.d.ts +0 -1
  29. package/dist/components/format/format-bytes.d.ts +1 -2
  30. package/dist/components/format/format-date.d.ts +0 -1
  31. package/dist/components/format/format-number.d.ts +1 -2
  32. package/dist/components/format/index.d.ts +0 -1
  33. package/dist/components/format/relative-time.d.ts +2 -3
  34. package/dist/components/gradient-overlay/gradient-overlay.d.ts +21 -0
  35. package/dist/components/header/header-actions.d.ts +0 -1
  36. package/dist/components/header/header.d.ts +0 -1
  37. package/dist/components/header/index.d.ts +1 -2
  38. package/dist/components/highlight/highlight.d.ts +27 -8
  39. package/dist/components/icon-button/icon-button.d.ts +12 -17
  40. package/dist/components/image/image.d.ts +4 -5
  41. package/dist/components/inline-message/inline-message.d.ts +19 -6
  42. package/dist/components/input/input.d.ts +17 -10
  43. package/dist/components/kpi/kpi.d.ts +39 -0
  44. package/dist/components/line-clamp/line-clamp.d.ts +2 -3
  45. package/dist/components/link/link.d.ts +3 -4
  46. package/dist/components/list/list.d.ts +3 -1
  47. package/dist/components/{list → list-item}/list-item.d.ts +7 -6
  48. package/dist/components/loader.d.ts +1 -0
  49. package/dist/components/loading-overlay/loading-overlay.d.ts +2 -4
  50. package/dist/components/loading-spinner/loading-spinner.d.ts +1 -3
  51. package/dist/components/logo/logo.d.ts +11 -4
  52. package/dist/components/main-menu/index.d.ts +1 -3
  53. package/dist/components/main-menu/main-menu-button.d.ts +0 -1
  54. package/dist/components/main-menu/main-menu-subtitle.d.ts +0 -1
  55. package/dist/components/main-menu/main-menu-title.d.ts +0 -1
  56. package/dist/components/main-menu/main-menu.d.ts +4 -5
  57. package/dist/components/main.d.ts +63 -56
  58. package/dist/components/menu/index.d.ts +1 -2
  59. package/dist/components/menu/menu-label.d.ts +0 -1
  60. package/dist/components/menu/menu.d.ts +3 -4
  61. package/dist/components/menu-item/menu-item.d.ts +5 -4
  62. package/dist/components/modal/modal.d.ts +8 -7
  63. package/dist/components/navigation-item/navigation-item.d.ts +15 -8
  64. package/dist/components/navigation-item-group/navigation-item-group.d.ts +20 -0
  65. package/dist/components/option/option.d.ts +1 -2
  66. package/dist/components/page/page.d.ts +16 -7
  67. package/dist/components/page-layout/page-layout.d.ts +0 -1
  68. package/dist/components/pagination/pagination.d.ts +0 -1
  69. package/dist/components/popover/popover-host.d.ts +34 -0
  70. package/dist/components/popover/popover-observer.d.ts +10 -0
  71. package/dist/{cdk → components}/popover/popover.d.ts +1 -1
  72. package/dist/components/progress-bar/base-progress.d.ts +13 -0
  73. package/dist/components/progress-bar/progress-bar.d.ts +2 -14
  74. package/dist/components/progress-ring/progress-ring.d.ts +33 -0
  75. package/dist/components/radio-button/radio-button.d.ts +1 -2
  76. package/dist/components/radio-group/radio-group.d.ts +8 -4
  77. package/dist/components/rail-navigation/rail-navigation.d.ts +6 -4
  78. package/dist/components/search-bar/index.d.ts +0 -2
  79. package/dist/components/search-bar/search-bar.d.ts +9 -4
  80. package/dist/components/search-bar/search-bar.events.d.ts +0 -1
  81. package/dist/components/select/select.d.ts +14 -6
  82. package/dist/components/separator/separator.d.ts +9 -5
  83. package/dist/components/skeleton/skeleton.d.ts +21 -7
  84. package/dist/components/slider/index.d.ts +2 -3
  85. package/dist/components/slider/slider-handle.d.ts +7 -7
  86. package/dist/components/slider/slider-marks.d.ts +1 -2
  87. package/dist/components/slider/slider.d.ts +2 -4
  88. package/dist/components/slider/slider.models.d.ts +3 -3
  89. package/dist/components/spacer/spacer.d.ts +0 -1
  90. package/dist/components/spinbox/spinbox.d.ts +15 -13
  91. package/dist/components/status/status.d.ts +26 -0
  92. package/dist/components/switch/switch.d.ts +1 -2
  93. package/dist/components/table/index.d.ts +3 -4
  94. package/dist/components/table/table-body.d.ts +0 -3
  95. package/dist/components/table/table-cell.d.ts +0 -3
  96. package/dist/components/table/table-checkbox-cell.d.ts +0 -1
  97. package/dist/components/table/table-header-cell.d.ts +0 -1
  98. package/dist/components/table/table-header.d.ts +2 -3
  99. package/dist/components/table/table-row.d.ts +0 -1
  100. package/dist/components/table/table.d.ts +0 -1
  101. package/dist/components/table/table.models.d.ts +0 -1
  102. package/dist/components/text/text.d.ts +27 -5
  103. package/dist/components/title/title.d.ts +18 -6
  104. package/dist/components/toast/toast.d.ts +18 -4
  105. package/dist/components/toggle-button/toggle-button.d.ts +2 -6
  106. package/dist/components/toggle-button-group/toggle-button-group.d.ts +11 -0
  107. package/dist/components/toggle-content/toggle-content.d.ts +2 -3
  108. package/dist/components/tooltip/tooltip.d.ts +36 -4
  109. package/dist/components/translate/translate.d.ts +0 -1
  110. package/dist/components/visually-hidden/visually-hidden.d.ts +0 -3
  111. package/dist/components.js +3195 -3756
  112. package/dist/i18n/{lib/config.d.ts → config.d.ts} +0 -1
  113. package/dist/i18n/{lib/format.d.ts → format.d.ts} +0 -1
  114. package/dist/i18n/{lib/is-localized.d.ts → is-localized.d.ts} +2 -3
  115. package/dist/i18n/{lib/localization.d.ts → localization.d.ts} +0 -2
  116. package/dist/i18n/main.d.ts +6 -7
  117. package/dist/i18n/{lib/models.d.ts → models.d.ts} +0 -1
  118. package/dist/i18n/{lib/translate.d.ts → translate.d.ts} +1 -3
  119. package/dist/i18n.js +15 -28
  120. package/dist/lib/control/checkbox-form-control.d.ts +13 -0
  121. package/dist/lib/control/checkbox-group-form-control.d.ts +22 -0
  122. package/dist/lib/control/form-control.d.ts +28 -0
  123. package/dist/lib/control/listbox-form-control.d.ts +25 -0
  124. package/dist/lib/control/number-form-control.d.ts +12 -0
  125. package/dist/lib/control/option-control.d.ts +23 -0
  126. package/dist/lib/control/radio-group-form-control.d.ts +15 -0
  127. package/dist/lib/controllers/active-descendants-controller.d.ts +28 -0
  128. package/dist/{cdk/drag-drop → lib/controllers}/drag.controller.d.ts +2 -2
  129. package/dist/lib/controllers/expandable-controller.d.ts +1 -3
  130. package/dist/lib/custom-element.d.ts +10 -6
  131. package/dist/lib/interactive/interactive-element.d.ts +29 -0
  132. package/dist/{cdk → lib}/interactive/interactive-link.d.ts +9 -4
  133. package/dist/lib/main.d.ts +27 -24
  134. package/dist/lib/mixins/can-be-disabled.d.ts +1 -10
  135. package/dist/lib/mixins/can-be-expanded.d.ts +5 -8
  136. package/dist/lib/mixins/is-draggable.d.ts +15 -0
  137. package/dist/{cdk/drag-drop/drag-events.d.ts → lib/models/drag-event.d.ts} +0 -1
  138. package/dist/lib/models/layout.d.ts +30 -0
  139. package/dist/lib/models/placement.d.ts +16 -0
  140. package/dist/lib/models/shape.d.ts +6 -0
  141. package/dist/lib/models/size.d.ts +10 -0
  142. package/dist/lib/models/variant.d.ts +23 -0
  143. package/dist/lib/utils/compute-popover-placement.d.ts +12 -0
  144. package/dist/lib/utils/dom.d.ts +26 -16
  145. package/dist/lib/utils/get-unique-id.d.ts +6 -24
  146. package/dist/lib/utils/lit.d.ts +2 -5
  147. package/dist/lib/utils/shared-resize-observer.d.ts +0 -8
  148. package/dist/lib/utils/{a11y.d.ts → types.d.ts} +2 -6
  149. package/dist/loader.js +6 -11
  150. package/dist/main.js +1112 -732
  151. package/dist/styles.css +1 -1
  152. package/dist/vendor.js +1986 -0
  153. package/package.json +49 -27
  154. package/dist/cdk/control/checkbox-form-control.d.ts +0 -15
  155. package/dist/cdk/control/checkbox-group-form-control.d.ts +0 -21
  156. package/dist/cdk/control/listbox-form-control.d.ts +0 -22
  157. package/dist/cdk/control/option-control.d.ts +0 -24
  158. package/dist/cdk/control/radio-group-form-control.d.ts +0 -22
  159. package/dist/cdk/drag-drop/is-draggable.d.ts +0 -18
  160. package/dist/cdk/interactive/interactive-element.d.ts +0 -28
  161. package/dist/cdk/main.d.ts +0 -14
  162. package/dist/cdk/popover/popover-host.d.ts +0 -25
  163. package/dist/cdk/popover/popover.models.d.ts +0 -34
  164. package/dist/cdk/popover/popover.utils.d.ts +0 -5
  165. package/dist/cdk.js +0 -948
  166. package/dist/components/accordion/accordion-header.d.ts +0 -18
  167. package/dist/components/accordion/index.d.ts +0 -4
  168. package/dist/components/action-group/action-group.d.ts +0 -24
  169. package/dist/components/action-group/index.d.ts +0 -2
  170. package/dist/components/area-header/area-header.models.d.ts +0 -12
  171. package/dist/components/area-header/index.d.ts +0 -3
  172. package/dist/components/avatar/avatar.models.d.ts +0 -13
  173. package/dist/components/avatar/index.d.ts +0 -3
  174. package/dist/components/avatar-group/avatar-group.d.ts +0 -15
  175. package/dist/components/avatar-group/index.d.ts +0 -2
  176. package/dist/components/badge/badge.models.d.ts +0 -14
  177. package/dist/components/badge/index.d.ts +0 -3
  178. package/dist/components/button/button.models.d.ts +0 -26
  179. package/dist/components/button/index.d.ts +0 -3
  180. package/dist/components/button-group/index.d.ts +0 -2
  181. package/dist/components/card/index.d.ts +0 -2
  182. package/dist/components/checkbox/index.d.ts +0 -2
  183. package/dist/components/checkbox-group/checkbox-group.models.d.ts +0 -6
  184. package/dist/components/checkbox-group/index.d.ts +0 -3
  185. package/dist/components/chip/chip.models.d.ts +0 -10
  186. package/dist/components/chip/index.d.ts +0 -3
  187. package/dist/components/circular-progress-bar/circular-progress-bar.d.ts +0 -42
  188. package/dist/components/circular-progress-bar/circular-progress-bar.models.d.ts +0 -7
  189. package/dist/components/circular-progress-bar/index.d.ts +0 -3
  190. package/dist/components/combobox/combobox.d.ts +0 -20
  191. package/dist/components/combobox/index.d.ts +0 -2
  192. package/dist/components/content-box/content-box.models.d.ts +0 -2
  193. package/dist/components/content-box/index.d.ts +0 -2
  194. package/dist/components/dropdown/dropdown.models.d.ts +0 -6
  195. package/dist/components/dropdown/index.d.ts +0 -3
  196. package/dist/components/form-field/index.d.ts +0 -2
  197. package/dist/components/headline/headline.d.ts +0 -13
  198. package/dist/components/headline/headline.models.d.ts +0 -8
  199. package/dist/components/headline/index.d.ts +0 -3
  200. package/dist/components/highlight/index.d.ts +0 -2
  201. package/dist/components/icon-button/index.d.ts +0 -2
  202. package/dist/components/image/index.d.ts +0 -2
  203. package/dist/components/inline-message/index.d.ts +0 -3
  204. package/dist/components/inline-message/inline-message.models.d.ts +0 -12
  205. package/dist/components/input/index.d.ts +0 -3
  206. package/dist/components/input/input.models.d.ts +0 -7
  207. package/dist/components/line-clamp/index.d.ts +0 -2
  208. package/dist/components/link/base-link.d.ts +0 -15
  209. package/dist/components/link/index.d.ts +0 -3
  210. package/dist/components/list/index.d.ts +0 -3
  211. package/dist/components/loading-overlay/index.d.ts +0 -2
  212. package/dist/components/loading-spinner/index.d.ts +0 -2
  213. package/dist/components/logo/index.d.ts +0 -3
  214. package/dist/components/logo/logo.models.d.ts +0 -9
  215. package/dist/components/main-menu/main-menu-link.d.ts +0 -9
  216. package/dist/components/menu-item/index.d.ts +0 -2
  217. package/dist/components/modal/index.d.ts +0 -3
  218. package/dist/components/modal/modal.models.d.ts +0 -5
  219. package/dist/components/navigation-item/index.d.ts +0 -3
  220. package/dist/components/navigation-item/navigation-item.models.d.ts +0 -6
  221. package/dist/components/option/index.d.ts +0 -2
  222. package/dist/components/page/index.d.ts +0 -3
  223. package/dist/components/page/page.models.d.ts +0 -10
  224. package/dist/components/page-layout/index.d.ts +0 -2
  225. package/dist/components/pagination/index.d.ts +0 -2
  226. package/dist/components/progress-bar/index.d.ts +0 -3
  227. package/dist/components/progress-bar/progress-bar.models.d.ts +0 -7
  228. package/dist/components/radio-button/index.d.ts +0 -2
  229. package/dist/components/radio-group/index.d.ts +0 -3
  230. package/dist/components/radio-group/radio-group.models.d.ts +0 -6
  231. package/dist/components/rail-navigation/index.d.ts +0 -2
  232. package/dist/components/search-bar/search-bar.models.d.ts +0 -6
  233. package/dist/components/select/index.d.ts +0 -2
  234. package/dist/components/separator/index.d.ts +0 -3
  235. package/dist/components/separator/separator.models.d.ts +0 -6
  236. package/dist/components/skeleton/index.d.ts +0 -3
  237. package/dist/components/skeleton/skeleton.models.d.ts +0 -13
  238. package/dist/components/spacer/index.d.ts +0 -2
  239. package/dist/components/spacer/spacer.models.d.ts +0 -7
  240. package/dist/components/spinbox/index.d.ts +0 -2
  241. package/dist/components/stack/index.d.ts +0 -3
  242. package/dist/components/stack/stack.d.ts +0 -18
  243. package/dist/components/stack/stack.models.d.ts +0 -25
  244. package/dist/components/switch/index.d.ts +0 -2
  245. package/dist/components/text/index.d.ts +0 -3
  246. package/dist/components/text/text.models.d.ts +0 -14
  247. package/dist/components/title/index.d.ts +0 -3
  248. package/dist/components/title/title.models.d.ts +0 -10
  249. package/dist/components/toast/index.d.ts +0 -3
  250. package/dist/components/toast/toast.models.d.ts +0 -5
  251. package/dist/components/toggle-button/index.d.ts +0 -2
  252. package/dist/components/toggle-content/index.d.ts +0 -2
  253. package/dist/components/tooltip/index.d.ts +0 -3
  254. package/dist/components/tooltip/tooltip.models.d.ts +0 -8
  255. package/dist/components/translate/index.d.ts +0 -2
  256. package/dist/components/visually-hidden/index.d.ts +0 -2
  257. package/dist/lib/controllers/active-desendants-controller.d.ts +0 -25
  258. package/dist/lib/controllers/focus-trap.controller.d.ts +0 -14
  259. package/dist/lib/mixins/can-be-highlighted.d.ts +0 -8
  260. package/dist/lib/mixins/can-be-readonly.d.ts +0 -7
  261. package/dist/lib/mixins/can-be-required.d.ts +0 -7
  262. package/dist/lib/mixins/can-be-selected.d.ts +0 -9
  263. package/dist/lib/mixins/can-be-validated.d.ts +0 -12
  264. package/dist/lib/mixins/form-control.d.ts +0 -17
  265. package/dist/lib/mixins/number-control.d.ts +0 -12
  266. package/dist/lib/mixins/with-loading-state.d.ts +0 -8
  267. package/dist/lib/utils/date.d.ts +0 -2
  268. package/dist/lib/utils/dedupe-mixin.d.ts +0 -3
  269. package/dist/lib/utils/empty-slot-fallback-fix.d.ts +0 -8
  270. package/dist/lib/utils/keyboard-events.d.ts +0 -43
  271. package/dist/lib/utils/query-assigned-element.d.ts +0 -16
  272. package/dist/lib/utils/search-text-content.d.ts +0 -8
  273. package/dist/lib/utils/shared-intersection-observer.d.ts +0 -18
  274. package/dist/lib/utils/transformers.d.ts +0 -5
  275. package/dist/loader/main.d.ts +0 -2
  276. package/dist/vendor-dJxQG085.js +0 -138
package/dist/vendor.js ADDED
@@ -0,0 +1,1986 @@
1
+ import { effect } from '@preact/signals-core';
2
+ import 'lit/html.js';
3
+ import { directive } from 'lit/directive.js';
4
+ import { AsyncDirective } from 'lit/async-directive.js';
5
+
6
+ function round$1(value, precision = 0) {
7
+ if (!Number.isInteger(precision)) {
8
+ throw new Error('Precision must be an integer.');
9
+ }
10
+ const multiplier = Math.pow(10, precision);
11
+ return Math.round(value * multiplier) / multiplier;
12
+ }
13
+
14
+ function minBy(items, getValue) {
15
+ if (items.length === 0) {
16
+ return undefined;
17
+ }
18
+ let minElement = items[0];
19
+ let min = getValue(minElement);
20
+ for (let i = 1; i < items.length; i++) {
21
+ const element = items[i];
22
+ const value = getValue(element);
23
+ if (value < min) {
24
+ min = value;
25
+ minElement = element;
26
+ }
27
+ }
28
+ return minElement;
29
+ }
30
+
31
+ function uniqBy(arr, mapper) {
32
+ const map = new Map();
33
+ for (let i = 0; i < arr.length; i++) {
34
+ const item = arr[i];
35
+ const key = mapper(item);
36
+ if (!map.has(key)) {
37
+ map.set(key, item);
38
+ }
39
+ }
40
+ return Array.from(map.values());
41
+ }
42
+
43
+ function o(r,e,t){return typeof r===e?()=>r:typeof r=="function"?r:t}class FocusGroupController{constructor(e,{hostDelegatesFocus:t,direction:n,elementEnterAction:s,elements:i,focusInIndex:h,isFocusableElement:c,listenerScope:l}={elements:()=>[]}){this._currentIndex=-1;this.prevIndex=-1;this._direction=()=>"both";this.directionLength=5;this.hostDelegatesFocus=false;this.elementEnterAction=e=>{};this._focused=false;this._focusInIndex=e=>0;this.isFocusableElement=e=>true;this._listenerScope=()=>this.host;this.offset=0;this.recentlyConnected=false;this.handleFocusin=e=>{if(!this.isEventWithinListenerScope(e))return;const t=e.composedPath();let n=-1;t.find(s=>(n=this.elements.indexOf(s),n!==-1)),this.prevIndex=this.currentIndex,this.currentIndex=n>-1?n:this.currentIndex,this.isRelatedTargetOrContainAnElement(e)&&this.hostContainsFocus();};this.handleClick=()=>{var n;const e=this.elements;if(!e.length)return;let t=e[this.currentIndex];this.currentIndex<0||((!t||!this.isFocusableElement(t))&&(this.setCurrentIndexCircularly(1),t=e[this.currentIndex]),t&&this.isFocusableElement(t)&&((n=e[this.prevIndex])==null||n.setAttribute("tabindex","-1"),t.setAttribute("tabindex","0")));};this.handleFocusout=e=>{this.isRelatedTargetOrContainAnElement(e)&&this.hostNoLongerContainsFocus();};this.handleKeydown=e=>{if(!this.acceptsEventKey(e.key)||e.defaultPrevented)return;let t=0;switch(this.prevIndex=this.currentIndex,e.key){case "ArrowRight":t+=1;break;case "ArrowDown":t+=this.direction==="grid"?this.directionLength:1;break;case "ArrowLeft":t-=1;break;case "ArrowUp":t-=this.direction==="grid"?this.directionLength:1;break;case "End":this.currentIndex=0,t-=1;break;case "Home":this.currentIndex=this.elements.length-1,t+=1;break}e.preventDefault(),this.direction==="grid"&&this.currentIndex+t<0?this.currentIndex=0:this.direction==="grid"&&this.currentIndex+t>this.elements.length-1?this.currentIndex=this.elements.length-1:this.setCurrentIndexCircularly(t),this.elementEnterAction(this.elements[this.currentIndex]),this.focus();};this.mutationObserver=new MutationObserver(()=>{this.handleItemMutation();}),this.hostDelegatesFocus=t||false,this.host=e,this.host.addController(this),this._elements=i,this.isFocusableElement=c||this.isFocusableElement,this._direction=o(n,"string",this._direction),this.elementEnterAction=s||this.elementEnterAction,this._focusInIndex=o(h,"number",this._focusInIndex),this._listenerScope=o(l,"object",this._listenerScope);}get currentIndex(){return this._currentIndex===-1&&(this._currentIndex=this.focusInIndex),this._currentIndex-this.offset}set currentIndex(e){this._currentIndex=e+this.offset;}get direction(){return this._direction()}get elements(){return this.cachedElements||(this.cachedElements=this._elements()),this.cachedElements}set focused(e){e!==this.focused&&(this._focused=e);}get focused(){return this._focused}get focusInElement(){return this.elements[this.focusInIndex]}get focusInIndex(){return this._focusInIndex(this.elements)}isEventWithinListenerScope(e){return this._listenerScope()===this.host?true:e.composedPath().includes(this._listenerScope())}handleItemMutation(){if(this._currentIndex==-1||this.elements.length<=this._elements().length)return;const e=this.elements[this.currentIndex];if(this.clearElementCache(),this.elements.includes(e))return;const t=this.currentIndex!==this.elements.length,n=t?1:-1;t&&this.setCurrentIndexCircularly(-1),this.setCurrentIndexCircularly(n),this.focus();}update({elements:e}={elements:()=>[]}){this.unmanage(),this._elements=e,this.clearElementCache(),this.manage();}reset(){var n;const e=this.elements;if(!e.length)return;this.setCurrentIndexCircularly(this.focusInIndex-this.currentIndex);let t=e[this.currentIndex];this.currentIndex<0||((!t||!this.isFocusableElement(t))&&(this.setCurrentIndexCircularly(1),t=e[this.currentIndex]),t&&this.isFocusableElement(t)&&((n=e[this.prevIndex])==null||n.setAttribute("tabindex","-1"),t.setAttribute("tabindex","0")));}focusOnItem(e,t){var i;const n=this.elements||[],s=!e||!this.isFocusableElement(e)?-1:n.indexOf(e);s>-1&&(this.currentIndex=s,(i=n[this.prevIndex])==null||i.setAttribute("tabindex","-1")),this.focus(t);}focus(e){var s;const t=this.elements;if(!t.length)return;let n=t[this.currentIndex];(!n||!this.isFocusableElement(n))&&(this.setCurrentIndexCircularly(1),n=t[this.currentIndex]),n&&this.isFocusableElement(n)&&((!this.hostDelegatesFocus||t[this.prevIndex]!==n)&&((s=t[this.prevIndex])==null||s.setAttribute("tabindex","-1")),n.tabIndex=0,n.focus(e),this.hostDelegatesFocus&&!this.focused&&this.hostContainsFocus());}clearElementCache(e=0){this.mutationObserver.disconnect(),delete this.cachedElements,this.offset=e,requestAnimationFrame(()=>{this.elements.forEach(t=>{this.mutationObserver.observe(t,{attributes:true});});});}setCurrentIndexCircularly(e){const{length:t}=this.elements;let n=t;this.prevIndex=this.currentIndex;let s=(t+this.currentIndex+e)%t;for(;n&&this.elements[s]&&!this.isFocusableElement(this.elements[s]);)s=(t+s+e)%t,n-=1;this.currentIndex=s;}hostContainsFocus(){this.host.addEventListener("focusout",this.handleFocusout),this.host.addEventListener("keydown",this.handleKeydown),this.focused=true;}hostNoLongerContainsFocus(){this.host.addEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout),this.host.removeEventListener("keydown",this.handleKeydown),this.focused=false;}isRelatedTargetOrContainAnElement(e){const t=e.relatedTarget,n=this.elements.includes(t),s=this.elements.some(i=>i.contains(t));return !(n||s)}acceptsEventKey(e){if(e==="End"||e==="Home")return true;switch(this.direction){case "horizontal":return e==="ArrowLeft"||e==="ArrowRight";case "vertical":return e==="ArrowUp"||e==="ArrowDown";case "both":case "grid":return e.startsWith("Arrow")}}manage(){this.addEventListeners();}unmanage(){this.removeEventListeners();}addEventListeners(){this.host.addEventListener("focusin",this.handleFocusin),this.host.addEventListener("click",this.handleClick);}removeEventListeners(){this.host.removeEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout),this.host.removeEventListener("keydown",this.handleKeydown),this.host.removeEventListener("click",this.handleClick);}hostConnected(){this.recentlyConnected=true,this.addEventListeners();}hostDisconnected(){this.mutationObserver.disconnect(),this.removeEventListeners();}hostUpdated(){this.recentlyConnected&&(this.recentlyConnected=false,this.elements.forEach(e=>{this.mutationObserver.observe(e,{attributes:true});}));}}
44
+
45
+ class RovingTabindexController extends FocusGroupController{constructor(){super(...arguments);this.managed=true;this.manageIndexesAnimationFrame=0;}set focused(e){e!==this.focused&&(super.focused=e,this.manageTabindexes());}get focused(){return super.focused}clearElementCache(e=0){cancelAnimationFrame(this.manageIndexesAnimationFrame),super.clearElementCache(e),this.managed&&(this.manageIndexesAnimationFrame=requestAnimationFrame(()=>this.manageTabindexes()));}manageTabindexes(){this.focused&&!this.hostDelegatesFocus?this.updateTabindexes(()=>({tabIndex:-1})):this.updateTabindexes(e=>({removeTabIndex:e.contains(this.focusInElement)&&e!==this.focusInElement,tabIndex:e===this.focusInElement?0:-1}));}updateTabindexes(e){this.elements.forEach(a=>{const{tabIndex:n,removeTabIndex:s}=e(a);if(!s){this.focused?a!==this.elements[this.currentIndex]&&(a.tabIndex=n):a.tabIndex=n;return}const t=a;t.requestUpdate&&t.requestUpdate();});}manage(){this.managed=true,this.manageTabindexes(),super.manage();}unmanage(){this.managed=false,this.updateTabindexes(()=>({tabIndex:0})),super.unmanage();}hostUpdated(){super.hostUpdated(),this.host.hasUpdated||this.manageTabindexes();}}
46
+
47
+ function isPlainObject(value) {
48
+ if (!value || typeof value !== 'object') {
49
+ return false;
50
+ }
51
+ const proto = Object.getPrototypeOf(value);
52
+ const hasObjectPrototype = proto === null ||
53
+ proto === Object.prototype ||
54
+ Object.getPrototypeOf(proto) === null;
55
+ if (!hasObjectPrototype) {
56
+ return false;
57
+ }
58
+ return Object.prototype.toString.call(value) === '[object Object]';
59
+ }
60
+
61
+ function flattenObject(object, { delimiter = '.' } = {}) {
62
+ return flattenObjectImpl(object, '', delimiter);
63
+ }
64
+ function flattenObjectImpl(object, prefix = '', delimiter = '.') {
65
+ const result = {};
66
+ const keys = Object.keys(object);
67
+ for (let i = 0; i < keys.length; i++) {
68
+ const key = keys[i];
69
+ const value = object[key];
70
+ const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key;
71
+ if (isPlainObject(value) && Object.keys(value).length > 0) {
72
+ Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
73
+ continue;
74
+ }
75
+ if (Array.isArray(value)) {
76
+ Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
77
+ continue;
78
+ }
79
+ result[prefixedKey] = value;
80
+ }
81
+ return result;
82
+ }
83
+
84
+ function pick(obj, keys) {
85
+ const result = {};
86
+ for (let i = 0; i < keys.length; i++) {
87
+ const key = keys[i];
88
+ if (Object.hasOwn(obj, key)) {
89
+ result[key] = obj[key];
90
+ }
91
+ }
92
+ return result;
93
+ }
94
+
95
+ /**
96
+ * Custom positioning reference element.
97
+ * @see https://floating-ui.com/docs/virtual-elements
98
+ */
99
+
100
+ const sides = ['top', 'right', 'bottom', 'left'];
101
+ const min = Math.min;
102
+ const max = Math.max;
103
+ const round = Math.round;
104
+ const floor = Math.floor;
105
+ const createCoords = v => ({
106
+ x: v,
107
+ y: v
108
+ });
109
+ const oppositeSideMap = {
110
+ left: 'right',
111
+ right: 'left',
112
+ bottom: 'top',
113
+ top: 'bottom'
114
+ };
115
+ const oppositeAlignmentMap = {
116
+ start: 'end',
117
+ end: 'start'
118
+ };
119
+ function clamp(start, value, end) {
120
+ return max(start, min(value, end));
121
+ }
122
+ function evaluate(value, param) {
123
+ return typeof value === 'function' ? value(param) : value;
124
+ }
125
+ function getSide(placement) {
126
+ return placement.split('-')[0];
127
+ }
128
+ function getAlignment(placement) {
129
+ return placement.split('-')[1];
130
+ }
131
+ function getOppositeAxis(axis) {
132
+ return axis === 'x' ? 'y' : 'x';
133
+ }
134
+ function getAxisLength(axis) {
135
+ return axis === 'y' ? 'height' : 'width';
136
+ }
137
+ function getSideAxis(placement) {
138
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
139
+ }
140
+ function getAlignmentAxis(placement) {
141
+ return getOppositeAxis(getSideAxis(placement));
142
+ }
143
+ function getAlignmentSides(placement, rects, rtl) {
144
+ if (rtl === void 0) {
145
+ rtl = false;
146
+ }
147
+ const alignment = getAlignment(placement);
148
+ const alignmentAxis = getAlignmentAxis(placement);
149
+ const length = getAxisLength(alignmentAxis);
150
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
151
+ if (rects.reference[length] > rects.floating[length]) {
152
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
153
+ }
154
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
155
+ }
156
+ function getExpandedPlacements(placement) {
157
+ const oppositePlacement = getOppositePlacement(placement);
158
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
159
+ }
160
+ function getOppositeAlignmentPlacement(placement) {
161
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
162
+ }
163
+ function getSideList(side, isStart, rtl) {
164
+ const lr = ['left', 'right'];
165
+ const rl = ['right', 'left'];
166
+ const tb = ['top', 'bottom'];
167
+ const bt = ['bottom', 'top'];
168
+ switch (side) {
169
+ case 'top':
170
+ case 'bottom':
171
+ if (rtl) return isStart ? rl : lr;
172
+ return isStart ? lr : rl;
173
+ case 'left':
174
+ case 'right':
175
+ return isStart ? tb : bt;
176
+ default:
177
+ return [];
178
+ }
179
+ }
180
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
181
+ const alignment = getAlignment(placement);
182
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
183
+ if (alignment) {
184
+ list = list.map(side => side + "-" + alignment);
185
+ if (flipAlignment) {
186
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
187
+ }
188
+ }
189
+ return list;
190
+ }
191
+ function getOppositePlacement(placement) {
192
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
193
+ }
194
+ function expandPaddingObject(padding) {
195
+ return {
196
+ top: 0,
197
+ right: 0,
198
+ bottom: 0,
199
+ left: 0,
200
+ ...padding
201
+ };
202
+ }
203
+ function getPaddingObject(padding) {
204
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
205
+ top: padding,
206
+ right: padding,
207
+ bottom: padding,
208
+ left: padding
209
+ };
210
+ }
211
+ function rectToClientRect(rect) {
212
+ const {
213
+ x,
214
+ y,
215
+ width,
216
+ height
217
+ } = rect;
218
+ return {
219
+ width,
220
+ height,
221
+ top: y,
222
+ left: x,
223
+ right: x + width,
224
+ bottom: y + height,
225
+ x,
226
+ y
227
+ };
228
+ }
229
+
230
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
231
+ let {
232
+ reference,
233
+ floating
234
+ } = _ref;
235
+ const sideAxis = getSideAxis(placement);
236
+ const alignmentAxis = getAlignmentAxis(placement);
237
+ const alignLength = getAxisLength(alignmentAxis);
238
+ const side = getSide(placement);
239
+ const isVertical = sideAxis === 'y';
240
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
241
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
242
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
243
+ let coords;
244
+ switch (side) {
245
+ case 'top':
246
+ coords = {
247
+ x: commonX,
248
+ y: reference.y - floating.height
249
+ };
250
+ break;
251
+ case 'bottom':
252
+ coords = {
253
+ x: commonX,
254
+ y: reference.y + reference.height
255
+ };
256
+ break;
257
+ case 'right':
258
+ coords = {
259
+ x: reference.x + reference.width,
260
+ y: commonY
261
+ };
262
+ break;
263
+ case 'left':
264
+ coords = {
265
+ x: reference.x - floating.width,
266
+ y: commonY
267
+ };
268
+ break;
269
+ default:
270
+ coords = {
271
+ x: reference.x,
272
+ y: reference.y
273
+ };
274
+ }
275
+ switch (getAlignment(placement)) {
276
+ case 'start':
277
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
278
+ break;
279
+ case 'end':
280
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
281
+ break;
282
+ }
283
+ return coords;
284
+ }
285
+
286
+ /**
287
+ * Computes the `x` and `y` coordinates that will place the floating element
288
+ * next to a given reference element.
289
+ *
290
+ * This export does not have any `platform` interface logic. You will need to
291
+ * write one for the platform you are using Floating UI with.
292
+ */
293
+ const computePosition$1 = async (reference, floating, config) => {
294
+ const {
295
+ placement = 'bottom',
296
+ strategy = 'absolute',
297
+ middleware = [],
298
+ platform
299
+ } = config;
300
+ const validMiddleware = middleware.filter(Boolean);
301
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
302
+ let rects = await platform.getElementRects({
303
+ reference,
304
+ floating,
305
+ strategy
306
+ });
307
+ let {
308
+ x,
309
+ y
310
+ } = computeCoordsFromPlacement(rects, placement, rtl);
311
+ let statefulPlacement = placement;
312
+ let middlewareData = {};
313
+ let resetCount = 0;
314
+ for (let i = 0; i < validMiddleware.length; i++) {
315
+ const {
316
+ name,
317
+ fn
318
+ } = validMiddleware[i];
319
+ const {
320
+ x: nextX,
321
+ y: nextY,
322
+ data,
323
+ reset
324
+ } = await fn({
325
+ x,
326
+ y,
327
+ initialPlacement: placement,
328
+ placement: statefulPlacement,
329
+ strategy,
330
+ middlewareData,
331
+ rects,
332
+ platform,
333
+ elements: {
334
+ reference,
335
+ floating
336
+ }
337
+ });
338
+ x = nextX != null ? nextX : x;
339
+ y = nextY != null ? nextY : y;
340
+ middlewareData = {
341
+ ...middlewareData,
342
+ [name]: {
343
+ ...middlewareData[name],
344
+ ...data
345
+ }
346
+ };
347
+ if (reset && resetCount <= 50) {
348
+ resetCount++;
349
+ if (typeof reset === 'object') {
350
+ if (reset.placement) {
351
+ statefulPlacement = reset.placement;
352
+ }
353
+ if (reset.rects) {
354
+ rects = reset.rects === true ? await platform.getElementRects({
355
+ reference,
356
+ floating,
357
+ strategy
358
+ }) : reset.rects;
359
+ }
360
+ ({
361
+ x,
362
+ y
363
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
364
+ }
365
+ i = -1;
366
+ }
367
+ }
368
+ return {
369
+ x,
370
+ y,
371
+ placement: statefulPlacement,
372
+ strategy,
373
+ middlewareData
374
+ };
375
+ };
376
+
377
+ /**
378
+ * Resolves with an object of overflow side offsets that determine how much the
379
+ * element is overflowing a given clipping boundary on each side.
380
+ * - positive = overflowing the boundary by that number of pixels
381
+ * - negative = how many pixels left before it will overflow
382
+ * - 0 = lies flush with the boundary
383
+ * @see https://floating-ui.com/docs/detectOverflow
384
+ */
385
+ async function detectOverflow(state, options) {
386
+ var _await$platform$isEle;
387
+ if (options === void 0) {
388
+ options = {};
389
+ }
390
+ const {
391
+ x,
392
+ y,
393
+ platform,
394
+ rects,
395
+ elements,
396
+ strategy
397
+ } = state;
398
+ const {
399
+ boundary = 'clippingAncestors',
400
+ rootBoundary = 'viewport',
401
+ elementContext = 'floating',
402
+ altBoundary = false,
403
+ padding = 0
404
+ } = evaluate(options, state);
405
+ const paddingObject = getPaddingObject(padding);
406
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
407
+ const element = elements[altBoundary ? altContext : elementContext];
408
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
409
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
410
+ boundary,
411
+ rootBoundary,
412
+ strategy
413
+ }));
414
+ const rect = elementContext === 'floating' ? {
415
+ x,
416
+ y,
417
+ width: rects.floating.width,
418
+ height: rects.floating.height
419
+ } : rects.reference;
420
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
421
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
422
+ x: 1,
423
+ y: 1
424
+ } : {
425
+ x: 1,
426
+ y: 1
427
+ };
428
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
429
+ elements,
430
+ rect,
431
+ offsetParent,
432
+ strategy
433
+ }) : rect);
434
+ return {
435
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
436
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
437
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
438
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
439
+ };
440
+ }
441
+
442
+ /**
443
+ * Provides data to position an inner element of the floating element so that it
444
+ * appears centered to the reference element.
445
+ * @see https://floating-ui.com/docs/arrow
446
+ */
447
+ const arrow$1 = options => ({
448
+ name: 'arrow',
449
+ options,
450
+ async fn(state) {
451
+ const {
452
+ x,
453
+ y,
454
+ placement,
455
+ rects,
456
+ platform,
457
+ elements,
458
+ middlewareData
459
+ } = state;
460
+ // Since `element` is required, we don't Partial<> the type.
461
+ const {
462
+ element,
463
+ padding = 0
464
+ } = evaluate(options, state) || {};
465
+ if (element == null) {
466
+ return {};
467
+ }
468
+ const paddingObject = getPaddingObject(padding);
469
+ const coords = {
470
+ x,
471
+ y
472
+ };
473
+ const axis = getAlignmentAxis(placement);
474
+ const length = getAxisLength(axis);
475
+ const arrowDimensions = await platform.getDimensions(element);
476
+ const isYAxis = axis === 'y';
477
+ const minProp = isYAxis ? 'top' : 'left';
478
+ const maxProp = isYAxis ? 'bottom' : 'right';
479
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
480
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
481
+ const startDiff = coords[axis] - rects.reference[axis];
482
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
483
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
484
+
485
+ // DOM platform can return `window` as the `offsetParent`.
486
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
487
+ clientSize = elements.floating[clientProp] || rects.floating[length];
488
+ }
489
+ const centerToReference = endDiff / 2 - startDiff / 2;
490
+
491
+ // If the padding is large enough that it causes the arrow to no longer be
492
+ // centered, modify the padding so that it is centered.
493
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
494
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
495
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
496
+
497
+ // Make sure the arrow doesn't overflow the floating element if the center
498
+ // point is outside the floating element's bounds.
499
+ const min$1 = minPadding;
500
+ const max = clientSize - arrowDimensions[length] - maxPadding;
501
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
502
+ const offset = clamp(min$1, center, max);
503
+
504
+ // If the reference is small enough that the arrow's padding causes it to
505
+ // to point to nothing for an aligned placement, adjust the offset of the
506
+ // floating element itself. To ensure `shift()` continues to take action,
507
+ // a single reset is performed when this is true.
508
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
509
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
510
+ return {
511
+ [axis]: coords[axis] + alignmentOffset,
512
+ data: {
513
+ [axis]: offset,
514
+ centerOffset: center - offset - alignmentOffset,
515
+ ...(shouldAddOffset && {
516
+ alignmentOffset
517
+ })
518
+ },
519
+ reset: shouldAddOffset
520
+ };
521
+ }
522
+ });
523
+
524
+ /**
525
+ * Optimizes the visibility of the floating element by flipping the `placement`
526
+ * in order to keep it in view when the preferred placement(s) will overflow the
527
+ * clipping boundary. Alternative to `autoPlacement`.
528
+ * @see https://floating-ui.com/docs/flip
529
+ */
530
+ const flip$1 = function (options) {
531
+ if (options === void 0) {
532
+ options = {};
533
+ }
534
+ return {
535
+ name: 'flip',
536
+ options,
537
+ async fn(state) {
538
+ var _middlewareData$arrow, _middlewareData$flip;
539
+ const {
540
+ placement,
541
+ middlewareData,
542
+ rects,
543
+ initialPlacement,
544
+ platform,
545
+ elements
546
+ } = state;
547
+ const {
548
+ mainAxis: checkMainAxis = true,
549
+ crossAxis: checkCrossAxis = true,
550
+ fallbackPlacements: specifiedFallbackPlacements,
551
+ fallbackStrategy = 'bestFit',
552
+ fallbackAxisSideDirection = 'none',
553
+ flipAlignment = true,
554
+ ...detectOverflowOptions
555
+ } = evaluate(options, state);
556
+
557
+ // If a reset by the arrow was caused due to an alignment offset being
558
+ // added, we should skip any logic now since `flip()` has already done its
559
+ // work.
560
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
561
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
562
+ return {};
563
+ }
564
+ const side = getSide(placement);
565
+ const initialSideAxis = getSideAxis(initialPlacement);
566
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
567
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
568
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
569
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
570
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
571
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
572
+ }
573
+ const placements = [initialPlacement, ...fallbackPlacements];
574
+ const overflow = await detectOverflow(state, detectOverflowOptions);
575
+ const overflows = [];
576
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
577
+ if (checkMainAxis) {
578
+ overflows.push(overflow[side]);
579
+ }
580
+ if (checkCrossAxis) {
581
+ const sides = getAlignmentSides(placement, rects, rtl);
582
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
583
+ }
584
+ overflowsData = [...overflowsData, {
585
+ placement,
586
+ overflows
587
+ }];
588
+
589
+ // One or more sides is overflowing.
590
+ if (!overflows.every(side => side <= 0)) {
591
+ var _middlewareData$flip2, _overflowsData$filter;
592
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
593
+ const nextPlacement = placements[nextIndex];
594
+ if (nextPlacement) {
595
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
596
+ if (!ignoreCrossAxisOverflow ||
597
+ // We leave the current main axis only if every placement on that axis
598
+ // overflows the main axis.
599
+ overflowsData.every(d => d.overflows[0] > 0 && getSideAxis(d.placement) === initialSideAxis)) {
600
+ // Try next placement and re-run the lifecycle.
601
+ return {
602
+ data: {
603
+ index: nextIndex,
604
+ overflows: overflowsData
605
+ },
606
+ reset: {
607
+ placement: nextPlacement
608
+ }
609
+ };
610
+ }
611
+ }
612
+
613
+ // First, find the candidates that fit on the mainAxis side of overflow,
614
+ // then find the placement that fits the best on the main crossAxis side.
615
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
616
+
617
+ // Otherwise fallback.
618
+ if (!resetPlacement) {
619
+ switch (fallbackStrategy) {
620
+ case 'bestFit':
621
+ {
622
+ var _overflowsData$filter2;
623
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
624
+ if (hasFallbackAxisSideDirection) {
625
+ const currentSideAxis = getSideAxis(d.placement);
626
+ return currentSideAxis === initialSideAxis ||
627
+ // Create a bias to the `y` side axis due to horizontal
628
+ // reading directions favoring greater width.
629
+ currentSideAxis === 'y';
630
+ }
631
+ return true;
632
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
633
+ if (placement) {
634
+ resetPlacement = placement;
635
+ }
636
+ break;
637
+ }
638
+ case 'initialPlacement':
639
+ resetPlacement = initialPlacement;
640
+ break;
641
+ }
642
+ }
643
+ if (placement !== resetPlacement) {
644
+ return {
645
+ reset: {
646
+ placement: resetPlacement
647
+ }
648
+ };
649
+ }
650
+ }
651
+ return {};
652
+ }
653
+ };
654
+ };
655
+
656
+ function getSideOffsets(overflow, rect) {
657
+ return {
658
+ top: overflow.top - rect.height,
659
+ right: overflow.right - rect.width,
660
+ bottom: overflow.bottom - rect.height,
661
+ left: overflow.left - rect.width
662
+ };
663
+ }
664
+ function isAnySideFullyClipped(overflow) {
665
+ return sides.some(side => overflow[side] >= 0);
666
+ }
667
+ /**
668
+ * Provides data to hide the floating element in applicable situations, such as
669
+ * when it is not in the same clipping context as the reference element.
670
+ * @see https://floating-ui.com/docs/hide
671
+ */
672
+ const hide$1 = function (options) {
673
+ if (options === void 0) {
674
+ options = {};
675
+ }
676
+ return {
677
+ name: 'hide',
678
+ options,
679
+ async fn(state) {
680
+ const {
681
+ rects
682
+ } = state;
683
+ const {
684
+ strategy = 'referenceHidden',
685
+ ...detectOverflowOptions
686
+ } = evaluate(options, state);
687
+ switch (strategy) {
688
+ case 'referenceHidden':
689
+ {
690
+ const overflow = await detectOverflow(state, {
691
+ ...detectOverflowOptions,
692
+ elementContext: 'reference'
693
+ });
694
+ const offsets = getSideOffsets(overflow, rects.reference);
695
+ return {
696
+ data: {
697
+ referenceHiddenOffsets: offsets,
698
+ referenceHidden: isAnySideFullyClipped(offsets)
699
+ }
700
+ };
701
+ }
702
+ case 'escaped':
703
+ {
704
+ const overflow = await detectOverflow(state, {
705
+ ...detectOverflowOptions,
706
+ altBoundary: true
707
+ });
708
+ const offsets = getSideOffsets(overflow, rects.floating);
709
+ return {
710
+ data: {
711
+ escapedOffsets: offsets,
712
+ escaped: isAnySideFullyClipped(offsets)
713
+ }
714
+ };
715
+ }
716
+ default:
717
+ {
718
+ return {};
719
+ }
720
+ }
721
+ }
722
+ };
723
+ };
724
+
725
+ // For type backwards-compatibility, the `OffsetOptions` type was also
726
+ // Derivable.
727
+
728
+ async function convertValueToCoords(state, options) {
729
+ const {
730
+ placement,
731
+ platform,
732
+ elements
733
+ } = state;
734
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
735
+ const side = getSide(placement);
736
+ const alignment = getAlignment(placement);
737
+ const isVertical = getSideAxis(placement) === 'y';
738
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
739
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
740
+ const rawValue = evaluate(options, state);
741
+
742
+ // eslint-disable-next-line prefer-const
743
+ let {
744
+ mainAxis,
745
+ crossAxis,
746
+ alignmentAxis
747
+ } = typeof rawValue === 'number' ? {
748
+ mainAxis: rawValue,
749
+ crossAxis: 0,
750
+ alignmentAxis: null
751
+ } : {
752
+ mainAxis: rawValue.mainAxis || 0,
753
+ crossAxis: rawValue.crossAxis || 0,
754
+ alignmentAxis: rawValue.alignmentAxis
755
+ };
756
+ if (alignment && typeof alignmentAxis === 'number') {
757
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
758
+ }
759
+ return isVertical ? {
760
+ x: crossAxis * crossAxisMulti,
761
+ y: mainAxis * mainAxisMulti
762
+ } : {
763
+ x: mainAxis * mainAxisMulti,
764
+ y: crossAxis * crossAxisMulti
765
+ };
766
+ }
767
+
768
+ /**
769
+ * Modifies the placement by translating the floating element along the
770
+ * specified axes.
771
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
772
+ * object may be passed.
773
+ * @see https://floating-ui.com/docs/offset
774
+ */
775
+ const offset$1 = function (options) {
776
+ if (options === void 0) {
777
+ options = 0;
778
+ }
779
+ return {
780
+ name: 'offset',
781
+ options,
782
+ async fn(state) {
783
+ var _middlewareData$offse, _middlewareData$arrow;
784
+ const {
785
+ x,
786
+ y,
787
+ placement,
788
+ middlewareData
789
+ } = state;
790
+ const diffCoords = await convertValueToCoords(state, options);
791
+
792
+ // If the placement is the same and the arrow caused an alignment offset
793
+ // then we don't need to change the positioning coordinates.
794
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
795
+ return {};
796
+ }
797
+ return {
798
+ x: x + diffCoords.x,
799
+ y: y + diffCoords.y,
800
+ data: {
801
+ ...diffCoords,
802
+ placement
803
+ }
804
+ };
805
+ }
806
+ };
807
+ };
808
+
809
+ /**
810
+ * Optimizes the visibility of the floating element by shifting it in order to
811
+ * keep it in view when it will overflow the clipping boundary.
812
+ * @see https://floating-ui.com/docs/shift
813
+ */
814
+ const shift$1 = function (options) {
815
+ if (options === void 0) {
816
+ options = {};
817
+ }
818
+ return {
819
+ name: 'shift',
820
+ options,
821
+ async fn(state) {
822
+ const {
823
+ x,
824
+ y,
825
+ placement
826
+ } = state;
827
+ const {
828
+ mainAxis: checkMainAxis = true,
829
+ crossAxis: checkCrossAxis = false,
830
+ limiter = {
831
+ fn: _ref => {
832
+ let {
833
+ x,
834
+ y
835
+ } = _ref;
836
+ return {
837
+ x,
838
+ y
839
+ };
840
+ }
841
+ },
842
+ ...detectOverflowOptions
843
+ } = evaluate(options, state);
844
+ const coords = {
845
+ x,
846
+ y
847
+ };
848
+ const overflow = await detectOverflow(state, detectOverflowOptions);
849
+ const crossAxis = getSideAxis(getSide(placement));
850
+ const mainAxis = getOppositeAxis(crossAxis);
851
+ let mainAxisCoord = coords[mainAxis];
852
+ let crossAxisCoord = coords[crossAxis];
853
+ if (checkMainAxis) {
854
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
855
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
856
+ const min = mainAxisCoord + overflow[minSide];
857
+ const max = mainAxisCoord - overflow[maxSide];
858
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
859
+ }
860
+ if (checkCrossAxis) {
861
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
862
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
863
+ const min = crossAxisCoord + overflow[minSide];
864
+ const max = crossAxisCoord - overflow[maxSide];
865
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
866
+ }
867
+ const limitedCoords = limiter.fn({
868
+ ...state,
869
+ [mainAxis]: mainAxisCoord,
870
+ [crossAxis]: crossAxisCoord
871
+ });
872
+ return {
873
+ ...limitedCoords,
874
+ data: {
875
+ x: limitedCoords.x - x,
876
+ y: limitedCoords.y - y,
877
+ enabled: {
878
+ [mainAxis]: checkMainAxis,
879
+ [crossAxis]: checkCrossAxis
880
+ }
881
+ }
882
+ };
883
+ }
884
+ };
885
+ };
886
+
887
+ /**
888
+ * Provides data that allows you to change the size of the floating element —
889
+ * for instance, prevent it from overflowing the clipping boundary or match the
890
+ * width of the reference element.
891
+ * @see https://floating-ui.com/docs/size
892
+ */
893
+ const size$1 = function (options) {
894
+ if (options === void 0) {
895
+ options = {};
896
+ }
897
+ return {
898
+ name: 'size',
899
+ options,
900
+ async fn(state) {
901
+ var _state$middlewareData, _state$middlewareData2;
902
+ const {
903
+ placement,
904
+ rects,
905
+ platform,
906
+ elements
907
+ } = state;
908
+ const {
909
+ apply = () => {},
910
+ ...detectOverflowOptions
911
+ } = evaluate(options, state);
912
+ const overflow = await detectOverflow(state, detectOverflowOptions);
913
+ const side = getSide(placement);
914
+ const alignment = getAlignment(placement);
915
+ const isYAxis = getSideAxis(placement) === 'y';
916
+ const {
917
+ width,
918
+ height
919
+ } = rects.floating;
920
+ let heightSide;
921
+ let widthSide;
922
+ if (side === 'top' || side === 'bottom') {
923
+ heightSide = side;
924
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
925
+ } else {
926
+ widthSide = side;
927
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
928
+ }
929
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
930
+ const maximumClippingWidth = width - overflow.left - overflow.right;
931
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
932
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
933
+ const noShift = !state.middlewareData.shift;
934
+ let availableHeight = overflowAvailableHeight;
935
+ let availableWidth = overflowAvailableWidth;
936
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
937
+ availableWidth = maximumClippingWidth;
938
+ }
939
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
940
+ availableHeight = maximumClippingHeight;
941
+ }
942
+ if (noShift && !alignment) {
943
+ const xMin = max(overflow.left, 0);
944
+ const xMax = max(overflow.right, 0);
945
+ const yMin = max(overflow.top, 0);
946
+ const yMax = max(overflow.bottom, 0);
947
+ if (isYAxis) {
948
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
949
+ } else {
950
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
951
+ }
952
+ }
953
+ await apply({
954
+ ...state,
955
+ availableWidth,
956
+ availableHeight
957
+ });
958
+ const nextDimensions = await platform.getDimensions(elements.floating);
959
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
960
+ return {
961
+ reset: {
962
+ rects: true
963
+ }
964
+ };
965
+ }
966
+ return {};
967
+ }
968
+ };
969
+ };
970
+
971
+ function hasWindow() {
972
+ return typeof window !== 'undefined';
973
+ }
974
+ function getNodeName(node) {
975
+ if (isNode(node)) {
976
+ return (node.nodeName || '').toLowerCase();
977
+ }
978
+ // Mocked nodes in testing environments may not be instances of Node. By
979
+ // returning `#document` an infinite loop won't occur.
980
+ // https://github.com/floating-ui/floating-ui/issues/2317
981
+ return '#document';
982
+ }
983
+ function getWindow(node) {
984
+ var _node$ownerDocument;
985
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
986
+ }
987
+ function getDocumentElement(node) {
988
+ var _ref;
989
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
990
+ }
991
+ function isNode(value) {
992
+ if (!hasWindow()) {
993
+ return false;
994
+ }
995
+ return value instanceof Node || value instanceof getWindow(value).Node;
996
+ }
997
+ function isElement(value) {
998
+ if (!hasWindow()) {
999
+ return false;
1000
+ }
1001
+ return value instanceof Element || value instanceof getWindow(value).Element;
1002
+ }
1003
+ function isHTMLElement(value) {
1004
+ if (!hasWindow()) {
1005
+ return false;
1006
+ }
1007
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1008
+ }
1009
+ function isShadowRoot(value) {
1010
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1011
+ return false;
1012
+ }
1013
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1014
+ }
1015
+ function isOverflowElement(element) {
1016
+ const {
1017
+ overflow,
1018
+ overflowX,
1019
+ overflowY,
1020
+ display
1021
+ } = getComputedStyle(element);
1022
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1023
+ }
1024
+ function isTableElement(element) {
1025
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1026
+ }
1027
+ function isTopLayer(element) {
1028
+ return [':popover-open', ':modal'].some(selector => {
1029
+ try {
1030
+ return element.matches(selector);
1031
+ } catch (e) {
1032
+ return false;
1033
+ }
1034
+ });
1035
+ }
1036
+ function isContainingBlock(elementOrCss) {
1037
+ const webkit = isWebKit();
1038
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1039
+
1040
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1041
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
1042
+ return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
1043
+ }
1044
+ function getContainingBlock(element) {
1045
+ let currentNode = getParentNode(element);
1046
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1047
+ if (isContainingBlock(currentNode)) {
1048
+ return currentNode;
1049
+ } else if (isTopLayer(currentNode)) {
1050
+ return null;
1051
+ }
1052
+ currentNode = getParentNode(currentNode);
1053
+ }
1054
+ return null;
1055
+ }
1056
+ function isWebKit() {
1057
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1058
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1059
+ }
1060
+ function isLastTraversableNode(node) {
1061
+ return ['html', 'body', '#document'].includes(getNodeName(node));
1062
+ }
1063
+ function getComputedStyle(element) {
1064
+ return getWindow(element).getComputedStyle(element);
1065
+ }
1066
+ function getNodeScroll(element) {
1067
+ if (isElement(element)) {
1068
+ return {
1069
+ scrollLeft: element.scrollLeft,
1070
+ scrollTop: element.scrollTop
1071
+ };
1072
+ }
1073
+ return {
1074
+ scrollLeft: element.scrollX,
1075
+ scrollTop: element.scrollY
1076
+ };
1077
+ }
1078
+ function getParentNode(node) {
1079
+ if (getNodeName(node) === 'html') {
1080
+ return node;
1081
+ }
1082
+ const result =
1083
+ // Step into the shadow DOM of the parent of a slotted node.
1084
+ node.assignedSlot ||
1085
+ // DOM Element detected.
1086
+ node.parentNode ||
1087
+ // ShadowRoot detected.
1088
+ isShadowRoot(node) && node.host ||
1089
+ // Fallback.
1090
+ getDocumentElement(node);
1091
+ return isShadowRoot(result) ? result.host : result;
1092
+ }
1093
+ function getNearestOverflowAncestor(node) {
1094
+ const parentNode = getParentNode(node);
1095
+ if (isLastTraversableNode(parentNode)) {
1096
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1097
+ }
1098
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1099
+ return parentNode;
1100
+ }
1101
+ return getNearestOverflowAncestor(parentNode);
1102
+ }
1103
+ function getOverflowAncestors(node, list, traverseIframes) {
1104
+ var _node$ownerDocument2;
1105
+ if (list === void 0) {
1106
+ list = [];
1107
+ }
1108
+ if (traverseIframes === void 0) {
1109
+ traverseIframes = true;
1110
+ }
1111
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1112
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1113
+ const win = getWindow(scrollableAncestor);
1114
+ if (isBody) {
1115
+ const frameElement = getFrameElement(win);
1116
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1117
+ }
1118
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1119
+ }
1120
+ function getFrameElement(win) {
1121
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1122
+ }
1123
+
1124
+ function getCssDimensions(element) {
1125
+ const css = getComputedStyle(element);
1126
+ // In testing environments, the `width` and `height` properties are empty
1127
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1128
+ let width = parseFloat(css.width) || 0;
1129
+ let height = parseFloat(css.height) || 0;
1130
+ const hasOffset = isHTMLElement(element);
1131
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1132
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1133
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1134
+ if (shouldFallback) {
1135
+ width = offsetWidth;
1136
+ height = offsetHeight;
1137
+ }
1138
+ return {
1139
+ width,
1140
+ height,
1141
+ $: shouldFallback
1142
+ };
1143
+ }
1144
+
1145
+ function unwrapElement(element) {
1146
+ return !isElement(element) ? element.contextElement : element;
1147
+ }
1148
+
1149
+ function getScale(element) {
1150
+ const domElement = unwrapElement(element);
1151
+ if (!isHTMLElement(domElement)) {
1152
+ return createCoords(1);
1153
+ }
1154
+ const rect = domElement.getBoundingClientRect();
1155
+ const {
1156
+ width,
1157
+ height,
1158
+ $
1159
+ } = getCssDimensions(domElement);
1160
+ let x = ($ ? round(rect.width) : rect.width) / width;
1161
+ let y = ($ ? round(rect.height) : rect.height) / height;
1162
+
1163
+ // 0, NaN, or Infinity should always fallback to 1.
1164
+
1165
+ if (!x || !Number.isFinite(x)) {
1166
+ x = 1;
1167
+ }
1168
+ if (!y || !Number.isFinite(y)) {
1169
+ y = 1;
1170
+ }
1171
+ return {
1172
+ x,
1173
+ y
1174
+ };
1175
+ }
1176
+
1177
+ const noOffsets = /*#__PURE__*/createCoords(0);
1178
+ function getVisualOffsets(element) {
1179
+ const win = getWindow(element);
1180
+ if (!isWebKit() || !win.visualViewport) {
1181
+ return noOffsets;
1182
+ }
1183
+ return {
1184
+ x: win.visualViewport.offsetLeft,
1185
+ y: win.visualViewport.offsetTop
1186
+ };
1187
+ }
1188
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1189
+ if (isFixed === void 0) {
1190
+ isFixed = false;
1191
+ }
1192
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1193
+ return false;
1194
+ }
1195
+ return isFixed;
1196
+ }
1197
+
1198
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1199
+ if (includeScale === void 0) {
1200
+ includeScale = false;
1201
+ }
1202
+ if (isFixedStrategy === void 0) {
1203
+ isFixedStrategy = false;
1204
+ }
1205
+ const clientRect = element.getBoundingClientRect();
1206
+ const domElement = unwrapElement(element);
1207
+ let scale = createCoords(1);
1208
+ if (includeScale) {
1209
+ if (offsetParent) {
1210
+ if (isElement(offsetParent)) {
1211
+ scale = getScale(offsetParent);
1212
+ }
1213
+ } else {
1214
+ scale = getScale(element);
1215
+ }
1216
+ }
1217
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1218
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1219
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1220
+ let width = clientRect.width / scale.x;
1221
+ let height = clientRect.height / scale.y;
1222
+ if (domElement) {
1223
+ const win = getWindow(domElement);
1224
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1225
+ let currentWin = win;
1226
+ let currentIFrame = getFrameElement(currentWin);
1227
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1228
+ const iframeScale = getScale(currentIFrame);
1229
+ const iframeRect = currentIFrame.getBoundingClientRect();
1230
+ const css = getComputedStyle(currentIFrame);
1231
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1232
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1233
+ x *= iframeScale.x;
1234
+ y *= iframeScale.y;
1235
+ width *= iframeScale.x;
1236
+ height *= iframeScale.y;
1237
+ x += left;
1238
+ y += top;
1239
+ currentWin = getWindow(currentIFrame);
1240
+ currentIFrame = getFrameElement(currentWin);
1241
+ }
1242
+ }
1243
+ return rectToClientRect({
1244
+ width,
1245
+ height,
1246
+ x,
1247
+ y
1248
+ });
1249
+ }
1250
+
1251
+ // If <html> has a CSS width greater than the viewport, then this will be
1252
+ // incorrect for RTL.
1253
+ function getWindowScrollBarX(element, rect) {
1254
+ const leftScroll = getNodeScroll(element).scrollLeft;
1255
+ if (!rect) {
1256
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1257
+ }
1258
+ return rect.left + leftScroll;
1259
+ }
1260
+
1261
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1262
+ if (ignoreScrollbarX === void 0) {
1263
+ ignoreScrollbarX = false;
1264
+ }
1265
+ const htmlRect = documentElement.getBoundingClientRect();
1266
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
1267
+ // RTL <body> scrollbar.
1268
+ getWindowScrollBarX(documentElement, htmlRect));
1269
+ const y = htmlRect.top + scroll.scrollTop;
1270
+ return {
1271
+ x,
1272
+ y
1273
+ };
1274
+ }
1275
+
1276
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1277
+ let {
1278
+ elements,
1279
+ rect,
1280
+ offsetParent,
1281
+ strategy
1282
+ } = _ref;
1283
+ const isFixed = strategy === 'fixed';
1284
+ const documentElement = getDocumentElement(offsetParent);
1285
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1286
+ if (offsetParent === documentElement || topLayer && isFixed) {
1287
+ return rect;
1288
+ }
1289
+ let scroll = {
1290
+ scrollLeft: 0,
1291
+ scrollTop: 0
1292
+ };
1293
+ let scale = createCoords(1);
1294
+ const offsets = createCoords(0);
1295
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1296
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1297
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1298
+ scroll = getNodeScroll(offsetParent);
1299
+ }
1300
+ if (isHTMLElement(offsetParent)) {
1301
+ const offsetRect = getBoundingClientRect(offsetParent);
1302
+ scale = getScale(offsetParent);
1303
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1304
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1305
+ }
1306
+ }
1307
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1308
+ return {
1309
+ width: rect.width * scale.x,
1310
+ height: rect.height * scale.y,
1311
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1312
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1313
+ };
1314
+ }
1315
+
1316
+ function getClientRects(element) {
1317
+ return Array.from(element.getClientRects());
1318
+ }
1319
+
1320
+ // Gets the entire size of the scrollable document area, even extending outside
1321
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1322
+ function getDocumentRect(element) {
1323
+ const html = getDocumentElement(element);
1324
+ const scroll = getNodeScroll(element);
1325
+ const body = element.ownerDocument.body;
1326
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1327
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1328
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1329
+ const y = -scroll.scrollTop;
1330
+ if (getComputedStyle(body).direction === 'rtl') {
1331
+ x += max(html.clientWidth, body.clientWidth) - width;
1332
+ }
1333
+ return {
1334
+ width,
1335
+ height,
1336
+ x,
1337
+ y
1338
+ };
1339
+ }
1340
+
1341
+ function getViewportRect(element, strategy) {
1342
+ const win = getWindow(element);
1343
+ const html = getDocumentElement(element);
1344
+ const visualViewport = win.visualViewport;
1345
+ let width = html.clientWidth;
1346
+ let height = html.clientHeight;
1347
+ let x = 0;
1348
+ let y = 0;
1349
+ if (visualViewport) {
1350
+ width = visualViewport.width;
1351
+ height = visualViewport.height;
1352
+ const visualViewportBased = isWebKit();
1353
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1354
+ x = visualViewport.offsetLeft;
1355
+ y = visualViewport.offsetTop;
1356
+ }
1357
+ }
1358
+ return {
1359
+ width,
1360
+ height,
1361
+ x,
1362
+ y
1363
+ };
1364
+ }
1365
+
1366
+ // Returns the inner client rect, subtracting scrollbars if present.
1367
+ function getInnerBoundingClientRect(element, strategy) {
1368
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1369
+ const top = clientRect.top + element.clientTop;
1370
+ const left = clientRect.left + element.clientLeft;
1371
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1372
+ const width = element.clientWidth * scale.x;
1373
+ const height = element.clientHeight * scale.y;
1374
+ const x = left * scale.x;
1375
+ const y = top * scale.y;
1376
+ return {
1377
+ width,
1378
+ height,
1379
+ x,
1380
+ y
1381
+ };
1382
+ }
1383
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1384
+ let rect;
1385
+ if (clippingAncestor === 'viewport') {
1386
+ rect = getViewportRect(element, strategy);
1387
+ } else if (clippingAncestor === 'document') {
1388
+ rect = getDocumentRect(getDocumentElement(element));
1389
+ } else if (isElement(clippingAncestor)) {
1390
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1391
+ } else {
1392
+ const visualOffsets = getVisualOffsets(element);
1393
+ rect = {
1394
+ x: clippingAncestor.x - visualOffsets.x,
1395
+ y: clippingAncestor.y - visualOffsets.y,
1396
+ width: clippingAncestor.width,
1397
+ height: clippingAncestor.height
1398
+ };
1399
+ }
1400
+ return rectToClientRect(rect);
1401
+ }
1402
+ function hasFixedPositionAncestor(element, stopNode) {
1403
+ const parentNode = getParentNode(element);
1404
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1405
+ return false;
1406
+ }
1407
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1408
+ }
1409
+
1410
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1411
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1412
+ // of the given element up the tree.
1413
+ function getClippingElementAncestors(element, cache) {
1414
+ const cachedResult = cache.get(element);
1415
+ if (cachedResult) {
1416
+ return cachedResult;
1417
+ }
1418
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1419
+ let currentContainingBlockComputedStyle = null;
1420
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1421
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1422
+
1423
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1424
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1425
+ const computedStyle = getComputedStyle(currentNode);
1426
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1427
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1428
+ currentContainingBlockComputedStyle = null;
1429
+ }
1430
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1431
+ if (shouldDropCurrentNode) {
1432
+ // Drop non-containing blocks.
1433
+ result = result.filter(ancestor => ancestor !== currentNode);
1434
+ } else {
1435
+ // Record last containing block for next iteration.
1436
+ currentContainingBlockComputedStyle = computedStyle;
1437
+ }
1438
+ currentNode = getParentNode(currentNode);
1439
+ }
1440
+ cache.set(element, result);
1441
+ return result;
1442
+ }
1443
+
1444
+ // Gets the maximum area that the element is visible in due to any number of
1445
+ // clipping ancestors.
1446
+ function getClippingRect(_ref) {
1447
+ let {
1448
+ element,
1449
+ boundary,
1450
+ rootBoundary,
1451
+ strategy
1452
+ } = _ref;
1453
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1454
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1455
+ const firstClippingAncestor = clippingAncestors[0];
1456
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1457
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1458
+ accRect.top = max(rect.top, accRect.top);
1459
+ accRect.right = min(rect.right, accRect.right);
1460
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1461
+ accRect.left = max(rect.left, accRect.left);
1462
+ return accRect;
1463
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1464
+ return {
1465
+ width: clippingRect.right - clippingRect.left,
1466
+ height: clippingRect.bottom - clippingRect.top,
1467
+ x: clippingRect.left,
1468
+ y: clippingRect.top
1469
+ };
1470
+ }
1471
+
1472
+ function getDimensions(element) {
1473
+ const {
1474
+ width,
1475
+ height
1476
+ } = getCssDimensions(element);
1477
+ return {
1478
+ width,
1479
+ height
1480
+ };
1481
+ }
1482
+
1483
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1484
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1485
+ const documentElement = getDocumentElement(offsetParent);
1486
+ const isFixed = strategy === 'fixed';
1487
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1488
+ let scroll = {
1489
+ scrollLeft: 0,
1490
+ scrollTop: 0
1491
+ };
1492
+ const offsets = createCoords(0);
1493
+
1494
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1495
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1496
+ function setLeftRTLScrollbarOffset() {
1497
+ offsets.x = getWindowScrollBarX(documentElement);
1498
+ }
1499
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1500
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1501
+ scroll = getNodeScroll(offsetParent);
1502
+ }
1503
+ if (isOffsetParentAnElement) {
1504
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1505
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1506
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1507
+ } else if (documentElement) {
1508
+ setLeftRTLScrollbarOffset();
1509
+ }
1510
+ }
1511
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1512
+ setLeftRTLScrollbarOffset();
1513
+ }
1514
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1515
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1516
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1517
+ return {
1518
+ x,
1519
+ y,
1520
+ width: rect.width,
1521
+ height: rect.height
1522
+ };
1523
+ }
1524
+
1525
+ function isStaticPositioned(element) {
1526
+ return getComputedStyle(element).position === 'static';
1527
+ }
1528
+
1529
+ function getTrueOffsetParent(element, polyfill) {
1530
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1531
+ return null;
1532
+ }
1533
+ if (polyfill) {
1534
+ return polyfill(element);
1535
+ }
1536
+ let rawOffsetParent = element.offsetParent;
1537
+
1538
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1539
+ // while Chrome and Safari return the <body> element. The <body> element must
1540
+ // be used to perform the correct calculations even if the <html> element is
1541
+ // non-static.
1542
+ if (getDocumentElement(element) === rawOffsetParent) {
1543
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1544
+ }
1545
+ return rawOffsetParent;
1546
+ }
1547
+
1548
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1549
+ // such as table ancestors and cross browser bugs.
1550
+ function getOffsetParent(element, polyfill) {
1551
+ const win = getWindow(element);
1552
+ if (isTopLayer(element)) {
1553
+ return win;
1554
+ }
1555
+ if (!isHTMLElement(element)) {
1556
+ let svgOffsetParent = getParentNode(element);
1557
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1558
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1559
+ return svgOffsetParent;
1560
+ }
1561
+ svgOffsetParent = getParentNode(svgOffsetParent);
1562
+ }
1563
+ return win;
1564
+ }
1565
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1566
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1567
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1568
+ }
1569
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1570
+ return win;
1571
+ }
1572
+ return offsetParent || getContainingBlock(element) || win;
1573
+ }
1574
+
1575
+ const getElementRects = async function (data) {
1576
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1577
+ const getDimensionsFn = this.getDimensions;
1578
+ const floatingDimensions = await getDimensionsFn(data.floating);
1579
+ return {
1580
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1581
+ floating: {
1582
+ x: 0,
1583
+ y: 0,
1584
+ width: floatingDimensions.width,
1585
+ height: floatingDimensions.height
1586
+ }
1587
+ };
1588
+ };
1589
+
1590
+ function isRTL(element) {
1591
+ return getComputedStyle(element).direction === 'rtl';
1592
+ }
1593
+
1594
+ const platform = {
1595
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1596
+ getDocumentElement,
1597
+ getClippingRect,
1598
+ getOffsetParent,
1599
+ getElementRects,
1600
+ getClientRects,
1601
+ getDimensions,
1602
+ getScale,
1603
+ isElement,
1604
+ isRTL
1605
+ };
1606
+
1607
+ function rectsAreEqual(a, b) {
1608
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1609
+ }
1610
+
1611
+ // https://samthor.au/2021/observing-dom/
1612
+ function observeMove(element, onMove) {
1613
+ let io = null;
1614
+ let timeoutId;
1615
+ const root = getDocumentElement(element);
1616
+ function cleanup() {
1617
+ var _io;
1618
+ clearTimeout(timeoutId);
1619
+ (_io = io) == null || _io.disconnect();
1620
+ io = null;
1621
+ }
1622
+ function refresh(skip, threshold) {
1623
+ if (skip === void 0) {
1624
+ skip = false;
1625
+ }
1626
+ if (threshold === void 0) {
1627
+ threshold = 1;
1628
+ }
1629
+ cleanup();
1630
+ const elementRectForRootMargin = element.getBoundingClientRect();
1631
+ const {
1632
+ left,
1633
+ top,
1634
+ width,
1635
+ height
1636
+ } = elementRectForRootMargin;
1637
+ if (!skip) {
1638
+ onMove();
1639
+ }
1640
+ if (!width || !height) {
1641
+ return;
1642
+ }
1643
+ const insetTop = floor(top);
1644
+ const insetRight = floor(root.clientWidth - (left + width));
1645
+ const insetBottom = floor(root.clientHeight - (top + height));
1646
+ const insetLeft = floor(left);
1647
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1648
+ const options = {
1649
+ rootMargin,
1650
+ threshold: max(0, min(1, threshold)) || 1
1651
+ };
1652
+ let isFirstUpdate = true;
1653
+ function handleObserve(entries) {
1654
+ const ratio = entries[0].intersectionRatio;
1655
+ if (ratio !== threshold) {
1656
+ if (!isFirstUpdate) {
1657
+ return refresh();
1658
+ }
1659
+ if (!ratio) {
1660
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1661
+ // to prevent an infinite loop of updates.
1662
+ timeoutId = setTimeout(() => {
1663
+ refresh(false, 1e-7);
1664
+ }, 1000);
1665
+ } else {
1666
+ refresh(false, ratio);
1667
+ }
1668
+ }
1669
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1670
+ // It's possible that even though the ratio is reported as 1, the
1671
+ // element is not actually fully within the IntersectionObserver's root
1672
+ // area anymore. This can happen under performance constraints. This may
1673
+ // be a bug in the browser's IntersectionObserver implementation. To
1674
+ // work around this, we compare the element's bounding rect now with
1675
+ // what it was at the time we created the IntersectionObserver. If they
1676
+ // are not equal then the element moved, so we refresh.
1677
+ refresh();
1678
+ }
1679
+ isFirstUpdate = false;
1680
+ }
1681
+
1682
+ // Older browsers don't support a `document` as the root and will throw an
1683
+ // error.
1684
+ try {
1685
+ io = new IntersectionObserver(handleObserve, {
1686
+ ...options,
1687
+ // Handle <iframe>s
1688
+ root: root.ownerDocument
1689
+ });
1690
+ } catch (_e) {
1691
+ io = new IntersectionObserver(handleObserve, options);
1692
+ }
1693
+ io.observe(element);
1694
+ }
1695
+ refresh(true);
1696
+ return cleanup;
1697
+ }
1698
+
1699
+ /**
1700
+ * Automatically updates the position of the floating element when necessary.
1701
+ * Should only be called when the floating element is mounted on the DOM or
1702
+ * visible on the screen.
1703
+ * @returns cleanup function that should be invoked when the floating element is
1704
+ * removed from the DOM or hidden from the screen.
1705
+ * @see https://floating-ui.com/docs/autoUpdate
1706
+ */
1707
+ function autoUpdate(reference, floating, update, options) {
1708
+ if (options === void 0) {
1709
+ options = {};
1710
+ }
1711
+ const {
1712
+ ancestorScroll = true,
1713
+ ancestorResize = true,
1714
+ elementResize = typeof ResizeObserver === 'function',
1715
+ layoutShift = typeof IntersectionObserver === 'function',
1716
+ animationFrame = false
1717
+ } = options;
1718
+ const referenceEl = unwrapElement(reference);
1719
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1720
+ ancestors.forEach(ancestor => {
1721
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1722
+ passive: true
1723
+ });
1724
+ ancestorResize && ancestor.addEventListener('resize', update);
1725
+ });
1726
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1727
+ let reobserveFrame = -1;
1728
+ let resizeObserver = null;
1729
+ if (elementResize) {
1730
+ resizeObserver = new ResizeObserver(_ref => {
1731
+ let [firstEntry] = _ref;
1732
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1733
+ // Prevent update loops when using the `size` middleware.
1734
+ // https://github.com/floating-ui/floating-ui/issues/1740
1735
+ resizeObserver.unobserve(floating);
1736
+ cancelAnimationFrame(reobserveFrame);
1737
+ reobserveFrame = requestAnimationFrame(() => {
1738
+ var _resizeObserver;
1739
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1740
+ });
1741
+ }
1742
+ update();
1743
+ });
1744
+ if (referenceEl && !animationFrame) {
1745
+ resizeObserver.observe(referenceEl);
1746
+ }
1747
+ resizeObserver.observe(floating);
1748
+ }
1749
+ let frameId;
1750
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1751
+ if (animationFrame) {
1752
+ frameLoop();
1753
+ }
1754
+ function frameLoop() {
1755
+ const nextRefRect = getBoundingClientRect(reference);
1756
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1757
+ update();
1758
+ }
1759
+ prevRefRect = nextRefRect;
1760
+ frameId = requestAnimationFrame(frameLoop);
1761
+ }
1762
+ update();
1763
+ return () => {
1764
+ var _resizeObserver2;
1765
+ ancestors.forEach(ancestor => {
1766
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1767
+ ancestorResize && ancestor.removeEventListener('resize', update);
1768
+ });
1769
+ cleanupIo == null || cleanupIo();
1770
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1771
+ resizeObserver = null;
1772
+ if (animationFrame) {
1773
+ cancelAnimationFrame(frameId);
1774
+ }
1775
+ };
1776
+ }
1777
+
1778
+ /**
1779
+ * Modifies the placement by translating the floating element along the
1780
+ * specified axes.
1781
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1782
+ * object may be passed.
1783
+ * @see https://floating-ui.com/docs/offset
1784
+ */
1785
+ const offset = offset$1;
1786
+
1787
+ /**
1788
+ * Optimizes the visibility of the floating element by shifting it in order to
1789
+ * keep it in view when it will overflow the clipping boundary.
1790
+ * @see https://floating-ui.com/docs/shift
1791
+ */
1792
+ const shift = shift$1;
1793
+
1794
+ /**
1795
+ * Optimizes the visibility of the floating element by flipping the `placement`
1796
+ * in order to keep it in view when the preferred placement(s) will overflow the
1797
+ * clipping boundary. Alternative to `autoPlacement`.
1798
+ * @see https://floating-ui.com/docs/flip
1799
+ */
1800
+ const flip = flip$1;
1801
+
1802
+ /**
1803
+ * Provides data that allows you to change the size of the floating element —
1804
+ * for instance, prevent it from overflowing the clipping boundary or match the
1805
+ * width of the reference element.
1806
+ * @see https://floating-ui.com/docs/size
1807
+ */
1808
+ const size = size$1;
1809
+
1810
+ /**
1811
+ * Provides data to hide the floating element in applicable situations, such as
1812
+ * when it is not in the same clipping context as the reference element.
1813
+ * @see https://floating-ui.com/docs/hide
1814
+ */
1815
+ const hide = hide$1;
1816
+
1817
+ /**
1818
+ * Provides data to position an inner element of the floating element so that it
1819
+ * appears centered to the reference element.
1820
+ * @see https://floating-ui.com/docs/arrow
1821
+ */
1822
+ const arrow = arrow$1;
1823
+
1824
+ /**
1825
+ * Computes the `x` and `y` coordinates that will place the floating element
1826
+ * next to a given reference element.
1827
+ */
1828
+ const computePosition = (reference, floating, options) => {
1829
+ // This caches the expensive `getClippingElementAncestors` function so that
1830
+ // multiple lifecycle resets re-use the same result. It only lives for a
1831
+ // single call. If other functions become expensive, we can add them as well.
1832
+ const cache = new Map();
1833
+ const mergedOptions = {
1834
+ platform,
1835
+ ...options
1836
+ };
1837
+ const platformWithCache = {
1838
+ ...mergedOptions.platform,
1839
+ _c: cache
1840
+ };
1841
+ return computePosition$1(reference, floating, {
1842
+ ...mergedOptions,
1843
+ platform: platformWithCache
1844
+ });
1845
+ };
1846
+
1847
+ function debounce(func, debounceMs, { signal, edges } = {}) {
1848
+ let pendingThis = undefined;
1849
+ let pendingArgs = null;
1850
+ const leading = edges != null && edges.includes('leading');
1851
+ const trailing = edges == null || edges.includes('trailing');
1852
+ const invoke = () => {
1853
+ if (pendingArgs !== null) {
1854
+ func.apply(pendingThis, pendingArgs);
1855
+ pendingThis = undefined;
1856
+ pendingArgs = null;
1857
+ }
1858
+ };
1859
+ const onTimerEnd = () => {
1860
+ if (trailing) {
1861
+ invoke();
1862
+ }
1863
+ cancel();
1864
+ };
1865
+ let timeoutId = null;
1866
+ const schedule = () => {
1867
+ if (timeoutId != null) {
1868
+ clearTimeout(timeoutId);
1869
+ }
1870
+ timeoutId = setTimeout(() => {
1871
+ timeoutId = null;
1872
+ onTimerEnd();
1873
+ }, debounceMs);
1874
+ };
1875
+ const cancelTimer = () => {
1876
+ if (timeoutId !== null) {
1877
+ clearTimeout(timeoutId);
1878
+ timeoutId = null;
1879
+ }
1880
+ };
1881
+ const cancel = () => {
1882
+ cancelTimer();
1883
+ pendingThis = undefined;
1884
+ pendingArgs = null;
1885
+ };
1886
+ const flush = () => {
1887
+ cancelTimer();
1888
+ invoke();
1889
+ };
1890
+ const debounced = function (...args) {
1891
+ if (signal?.aborted) {
1892
+ return;
1893
+ }
1894
+ pendingThis = this;
1895
+ pendingArgs = args;
1896
+ const isFirstCall = timeoutId == null;
1897
+ schedule();
1898
+ if (leading && isFirstCall) {
1899
+ invoke();
1900
+ }
1901
+ };
1902
+ debounced.schedule = schedule;
1903
+ debounced.cancel = cancel;
1904
+ debounced.flush = flush;
1905
+ signal?.addEventListener('abort', cancel, { once: true });
1906
+ return debounced;
1907
+ }
1908
+
1909
+ function throttle(func, throttleMs, { signal, edges = ['leading', 'trailing'] } = {}) {
1910
+ let pendingAt = null;
1911
+ const debounced = debounce(func, throttleMs, { signal, edges });
1912
+ const throttled = function (...args) {
1913
+ if (pendingAt == null) {
1914
+ pendingAt = Date.now();
1915
+ }
1916
+ else {
1917
+ if (Date.now() - pendingAt >= throttleMs) {
1918
+ pendingAt = Date.now();
1919
+ debounced.cancel();
1920
+ }
1921
+ }
1922
+ debounced(...args);
1923
+ };
1924
+ throttled.cancel = debounced.cancel;
1925
+ throttled.flush = debounced.flush;
1926
+ return throttled;
1927
+ }
1928
+
1929
+ /**
1930
+ * @license
1931
+ * Copyright 2023 Google LLC
1932
+ * SPDX-License-Identifier: BSD-3-Clause
1933
+ */function e$2(e){return class extends e{performUpdate(){var e;if(false===this.isUpdatePending)return;null===(e=this._$Oo)||void 0===e||e.call(this);let s=true;this._$Oo=effect((()=>{s?(s=false,super.performUpdate()):this.requestUpdate();}));}connectedCallback(){super.connectedCallback(),this.requestUpdate();}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Oo)||void 0===t||t.call(this);}}}
1934
+
1935
+ /**
1936
+ * @license
1937
+ * Copyright 2023 Google LLC
1938
+ * SPDX-License-Identifier: BSD-3-Clause
1939
+ */directive(class extends AsyncDirective{render(i){var t;if(i!==this._$Oi){null===(t=this._$Oo)||void 0===t||t.call(this),this._$Oi=i;let s=true;this._$Oo=i.subscribe((i=>{ false===s&&this.setValue(i);})),s=false;}return i.peek()}disconnected(){var i;null===(i=this._$Oo)||void 0===i||i.call(this);}reconnected(){var i;this._$Oo=null===(i=this._$Oi)||void 0===i?void 0:i.subscribe((i=>{this.setValue(i);}));}});
1940
+
1941
+ /**
1942
+ * @license
1943
+ * Copyright 2021 Google LLC
1944
+ * SPDX-License-Identifier: BSD-3-Clause
1945
+ */
1946
+ let s$2 = class s extends Event{constructor(s,t,e,o){super("context-request",{bubbles:true,composed:true}),this.context=s,this.contextTarget=t,this.callback=e,this.subscribe=o??false;}};
1947
+
1948
+ /**
1949
+ * @license
1950
+ * Copyright 2021 Google LLC
1951
+ * SPDX-License-Identifier: BSD-3-Clause
1952
+ */
1953
+ function n(n){return n}
1954
+
1955
+ /**
1956
+ * @license
1957
+ * Copyright 2021 Google LLC
1958
+ * SPDX-License-Identifier: BSD-3-Clause
1959
+ */let s$1 = class s{constructor(t,s,i,h){if(this.subscribe=false,this.provided=false,this.value=void 0,this.t=(t,s)=>{this.unsubscribe&&(this.unsubscribe!==s&&(this.provided=false,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=t,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=true,this.callback&&this.callback(t,s)),this.unsubscribe=s;},this.host=t,void 0!==s.context){const t=s;this.context=t.context,this.callback=t.callback,this.subscribe=t.subscribe??false;}else this.context=s,this.callback=i,this.subscribe=h??false;this.host.addController(this);}hostConnected(){this.dispatchRequest();}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0);}dispatchRequest(){this.host.dispatchEvent(new s$2(this.context,this.host,this.t,this.subscribe));}};
1960
+
1961
+ /**
1962
+ * @license
1963
+ * Copyright 2021 Google LLC
1964
+ * SPDX-License-Identifier: BSD-3-Clause
1965
+ */
1966
+ class s{get value(){return this.o}set value(s){this.setValue(s);}setValue(s,t=false){const i=t||!Object.is(s,this.o);this.o=s,i&&this.updateObservers();}constructor(s){this.subscriptions=new Map,this.updateObservers=()=>{for(const[s,{disposer:t}]of this.subscriptions)s(this.o,t);},void 0!==s&&(this.value=s);}addCallback(s,t,i){if(!i)return void s(this.value);this.subscriptions.has(s)||this.subscriptions.set(s,{disposer:()=>{this.subscriptions.delete(s);},consumerHost:t});const{disposer:h}=this.subscriptions.get(s);s(this.value,h);}clearCallbacks(){this.subscriptions.clear();}}
1967
+
1968
+ /**
1969
+ * @license
1970
+ * Copyright 2021 Google LLC
1971
+ * SPDX-License-Identifier: BSD-3-Clause
1972
+ */let e$1 = class e extends Event{constructor(t,s){super("context-provider",{bubbles:true,composed:true}),this.context=t,this.contextTarget=s;}};class i extends s{constructor(s,e,i){super(void 0!==e.context?e.initialValue:i),this.onContextRequest=t=>{if(t.context!==this.context)return;const s=t.contextTarget??t.composedPath()[0];s!==this.host&&(t.stopPropagation(),this.addCallback(t.callback,s,t.subscribe));},this.onProviderRequest=s=>{if(s.context!==this.context)return;if((s.contextTarget??s.composedPath()[0])===this.host)return;const e=new Set;for(const[s,{consumerHost:i}]of this.subscriptions)e.has(s)||(e.add(s),i.dispatchEvent(new s$2(this.context,i,s,true)));s.stopPropagation();},this.host=s,void 0!==e.context?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this);}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest);}hostConnected(){this.host.dispatchEvent(new e$1(this.context,this.host));}}
1973
+
1974
+ /**
1975
+ * @license
1976
+ * Copyright 2017 Google LLC
1977
+ * SPDX-License-Identifier: BSD-3-Clause
1978
+ */function e({context:e}){return (n,i$1)=>{const r=new WeakMap;if("object"==typeof i$1)return {get(){return n.get.call(this)},set(t){return r.get(this).setValue(t),n.set.call(this,t)},init(n){return r.set(this,new i(this,{context:e,initialValue:n})),n}};{n.constructor.addInitializer((n=>{r.set(n,new i(n,{context:e}));}));const o=Object.getOwnPropertyDescriptor(n,i$1);let s;if(void 0===o){const t=new WeakMap;s={get(){return t.get(this)},set(e){r.get(this).setValue(e),t.set(this,e);},configurable:true,enumerable:true};}else {const t=o.set;s={...o,set(e){r.get(this).setValue(e),t?.call(this,e);}};}return void Object.defineProperty(n,i$1,s)}}}
1979
+
1980
+ /**
1981
+ * @license
1982
+ * Copyright 2022 Google LLC
1983
+ * SPDX-License-Identifier: BSD-3-Clause
1984
+ */function c({context:c,subscribe:e}){return (o,n)=>{"object"==typeof n?n.addInitializer((function(){new s$1(this,{context:c,callback:t=>{o.set.call(this,t);},subscribe:e});})):o.constructor.addInitializer((o=>{new s$1(o,{context:c,callback:t=>{o[n]=t;},subscribe:e});}));}}
1985
+
1986
+ export { RovingTabindexController as R, size as a, arrow as b, computePosition as c, autoUpdate as d, e$2 as e, flip as f, debounce as g, hide as h, c as i, e as j, flattenObject as k, minBy as m, n, offset as o, pick as p, round$1 as r, shift as s, throttle as t, uniqBy as u };