@andespindola/ui-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/README.md +45 -0
  2. package/dist/cjs/floating-ui.dom-BPemvNRD.js +1542 -0
  3. package/dist/cjs/index-Cb1tfi_9.js +1728 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +12 -0
  6. package/dist/cjs/ui-accordion-item.cjs.entry.js +27 -0
  7. package/dist/cjs/ui-accordion.cjs.entry.js +17 -0
  8. package/dist/cjs/ui-avatar.cjs.entry.js +19 -0
  9. package/dist/cjs/ui-badge.cjs.entry.js +19 -0
  10. package/dist/cjs/ui-button.cjs.entry.js +31 -0
  11. package/dist/cjs/ui-card.cjs.entry.js +17 -0
  12. package/dist/cjs/ui-checkbox.cjs.entry.js +34 -0
  13. package/dist/cjs/ui-dialog.cjs.entry.js +57 -0
  14. package/dist/cjs/ui-drawer.cjs.entry.js +59 -0
  15. package/dist/cjs/ui-dropdown-item.cjs.entry.js +27 -0
  16. package/dist/cjs/ui-dropdown-menu.cjs.entry.js +97 -0
  17. package/dist/cjs/ui-field.cjs.entry.js +19 -0
  18. package/dist/cjs/ui-input.cjs.entry.js +35 -0
  19. package/dist/cjs/ui-label.cjs.entry.js +17 -0
  20. package/dist/cjs/ui-loading-overlay.cjs.entry.js +24 -0
  21. package/dist/cjs/ui-popover.cjs.entry.js +94 -0
  22. package/dist/cjs/ui-progress.cjs.entry.js +33 -0
  23. package/dist/cjs/ui-radio-group.cjs.entry.js +49 -0
  24. package/dist/cjs/ui-reveal.cjs.entry.js +41 -0
  25. package/dist/cjs/ui-scroll-progress.cjs.entry.js +37 -0
  26. package/dist/cjs/ui-section.cjs.entry.js +23 -0
  27. package/dist/cjs/ui-select.cjs.entry.js +28 -0
  28. package/dist/cjs/ui-separator.cjs.entry.js +19 -0
  29. package/dist/cjs/ui-skeleton.cjs.entry.js +17 -0
  30. package/dist/cjs/ui-slider.cjs.entry.js +37 -0
  31. package/dist/cjs/ui-spinner.cjs.entry.js +19 -0
  32. package/dist/cjs/ui-switch.cjs.entry.js +34 -0
  33. package/dist/cjs/ui-tabs.cjs.entry.js +31 -0
  34. package/dist/cjs/ui-textarea.cjs.entry.js +35 -0
  35. package/dist/cjs/ui-theme-toggle.cjs.entry.js +65 -0
  36. package/dist/cjs/ui-toast.cjs.entry.js +67 -0
  37. package/dist/cjs/ui-toaster.cjs.entry.js +29 -0
  38. package/dist/cjs/ui-tooltip.cjs.entry.js +64 -0
  39. package/dist/cjs/uikit.cjs.js +24 -0
  40. package/dist/collection/collection-manifest.json +45 -0
  41. package/dist/collection/components/ui-accordion/ui-accordion.css +4 -0
  42. package/dist/collection/components/ui-accordion/ui-accordion.js +18 -0
  43. package/dist/collection/components/ui-accordion-item/ui-accordion-item.css +42 -0
  44. package/dist/collection/components/ui-accordion-item/ui-accordion-item.js +91 -0
  45. package/dist/collection/components/ui-avatar/ui-avatar.css +30 -0
  46. package/dist/collection/components/ui-avatar/ui-avatar.js +84 -0
  47. package/dist/collection/components/ui-badge/ui-badge.css +46 -0
  48. package/dist/collection/components/ui-badge/ui-badge.js +52 -0
  49. package/dist/collection/components/ui-button/ui-button.css +130 -0
  50. package/dist/collection/components/ui-button/ui-button.js +150 -0
  51. package/dist/collection/components/ui-card/ui-card.css +24 -0
  52. package/dist/collection/components/ui-card/ui-card.js +18 -0
  53. package/dist/collection/components/ui-checkbox/ui-checkbox.css +46 -0
  54. package/dist/collection/components/ui-checkbox/ui-checkbox.js +136 -0
  55. package/dist/collection/components/ui-dialog/ui-dialog.css +48 -0
  56. package/dist/collection/components/ui-dialog/ui-dialog.js +140 -0
  57. package/dist/collection/components/ui-drawer/ui-drawer.css +88 -0
  58. package/dist/collection/components/ui-drawer/ui-drawer.js +162 -0
  59. package/dist/collection/components/ui-dropdown-item/ui-dropdown-item.css +36 -0
  60. package/dist/collection/components/ui-dropdown-item/ui-dropdown-item.js +71 -0
  61. package/dist/collection/components/ui-dropdown-menu/ui-dropdown-menu.css +39 -0
  62. package/dist/collection/components/ui-dropdown-menu/ui-dropdown-menu.js +216 -0
  63. package/dist/collection/components/ui-field/ui-field.css +34 -0
  64. package/dist/collection/components/ui-field/ui-field.js +122 -0
  65. package/dist/collection/components/ui-input/ui-input.css +40 -0
  66. package/dist/collection/components/ui-input/ui-input.js +191 -0
  67. package/dist/collection/components/ui-label/ui-label.css +10 -0
  68. package/dist/collection/components/ui-label/ui-label.js +18 -0
  69. package/dist/collection/components/ui-loading-overlay/ui-loading-overlay.css +24 -0
  70. package/dist/collection/components/ui-loading-overlay/ui-loading-overlay.js +102 -0
  71. package/dist/collection/components/ui-popover/ui-popover.css +36 -0
  72. package/dist/collection/components/ui-popover/ui-popover.js +204 -0
  73. package/dist/collection/components/ui-progress/ui-progress.css +32 -0
  74. package/dist/collection/components/ui-progress/ui-progress.js +100 -0
  75. package/dist/collection/components/ui-radio-group/ui-radio-group.css +67 -0
  76. package/dist/collection/components/ui-radio-group/ui-radio-group.js +155 -0
  77. package/dist/collection/components/ui-reveal/ui-reveal.css +17 -0
  78. package/dist/collection/components/ui-reveal/ui-reveal.js +73 -0
  79. package/dist/collection/components/ui-scroll-progress/ui-scroll-progress.css +20 -0
  80. package/dist/collection/components/ui-scroll-progress/ui-scroll-progress.js +45 -0
  81. package/dist/collection/components/ui-section/ui-section.css +32 -0
  82. package/dist/collection/components/ui-section/ui-section.js +90 -0
  83. package/dist/collection/components/ui-select/ui-select.css +49 -0
  84. package/dist/collection/components/ui-select/ui-select.js +153 -0
  85. package/dist/collection/components/ui-separator/ui-separator.css +15 -0
  86. package/dist/collection/components/ui-separator/ui-separator.js +52 -0
  87. package/dist/collection/components/ui-skeleton/ui-skeleton.css +27 -0
  88. package/dist/collection/components/ui-skeleton/ui-skeleton.js +18 -0
  89. package/dist/collection/components/ui-slider/ui-slider.css +80 -0
  90. package/dist/collection/components/ui-slider/ui-slider.js +175 -0
  91. package/dist/collection/components/ui-spinner/ui-spinner.css +39 -0
  92. package/dist/collection/components/ui-spinner/ui-spinner.js +52 -0
  93. package/dist/collection/components/ui-switch/ui-switch.css +47 -0
  94. package/dist/collection/components/ui-switch/ui-switch.js +98 -0
  95. package/dist/collection/components/ui-tabs/ui-tabs.css +38 -0
  96. package/dist/collection/components/ui-tabs/ui-tabs.js +99 -0
  97. package/dist/collection/components/ui-textarea/ui-textarea.css +42 -0
  98. package/dist/collection/components/ui-textarea/ui-textarea.js +191 -0
  99. package/dist/collection/components/ui-theme-toggle/ui-theme-toggle.css +28 -0
  100. package/dist/collection/components/ui-theme-toggle/ui-theme-toggle.js +90 -0
  101. package/dist/collection/components/ui-toast/ui-toast.css +81 -0
  102. package/dist/collection/components/ui-toast/ui-toast.js +234 -0
  103. package/dist/collection/components/ui-toaster/ui-toaster.css +15 -0
  104. package/dist/collection/components/ui-toaster/ui-toaster.js +67 -0
  105. package/dist/collection/components/ui-tooltip/ui-tooltip.css +37 -0
  106. package/dist/collection/components/ui-tooltip/ui-tooltip.js +143 -0
  107. package/dist/collection/index.js +1 -0
  108. package/dist/components/index.d.ts +35 -0
  109. package/dist/components/index.js +1 -0
  110. package/dist/components/p-Bz9HyboB.js +1 -0
  111. package/dist/components/p-C8ePpPG3.js +1 -0
  112. package/dist/components/p-CyBRmmbs.js +1 -0
  113. package/dist/components/ui-accordion-item.d.ts +11 -0
  114. package/dist/components/ui-accordion-item.js +1 -0
  115. package/dist/components/ui-accordion.d.ts +11 -0
  116. package/dist/components/ui-accordion.js +1 -0
  117. package/dist/components/ui-avatar.d.ts +11 -0
  118. package/dist/components/ui-avatar.js +1 -0
  119. package/dist/components/ui-badge.d.ts +11 -0
  120. package/dist/components/ui-badge.js +1 -0
  121. package/dist/components/ui-button.d.ts +11 -0
  122. package/dist/components/ui-button.js +1 -0
  123. package/dist/components/ui-card.d.ts +11 -0
  124. package/dist/components/ui-card.js +1 -0
  125. package/dist/components/ui-checkbox.d.ts +11 -0
  126. package/dist/components/ui-checkbox.js +1 -0
  127. package/dist/components/ui-dialog.d.ts +11 -0
  128. package/dist/components/ui-dialog.js +1 -0
  129. package/dist/components/ui-drawer.d.ts +11 -0
  130. package/dist/components/ui-drawer.js +1 -0
  131. package/dist/components/ui-dropdown-item.d.ts +11 -0
  132. package/dist/components/ui-dropdown-item.js +1 -0
  133. package/dist/components/ui-dropdown-menu.d.ts +11 -0
  134. package/dist/components/ui-dropdown-menu.js +1 -0
  135. package/dist/components/ui-field.d.ts +11 -0
  136. package/dist/components/ui-field.js +1 -0
  137. package/dist/components/ui-input.d.ts +11 -0
  138. package/dist/components/ui-input.js +1 -0
  139. package/dist/components/ui-label.d.ts +11 -0
  140. package/dist/components/ui-label.js +1 -0
  141. package/dist/components/ui-loading-overlay.d.ts +11 -0
  142. package/dist/components/ui-loading-overlay.js +1 -0
  143. package/dist/components/ui-popover.d.ts +11 -0
  144. package/dist/components/ui-popover.js +1 -0
  145. package/dist/components/ui-progress.d.ts +11 -0
  146. package/dist/components/ui-progress.js +1 -0
  147. package/dist/components/ui-radio-group.d.ts +11 -0
  148. package/dist/components/ui-radio-group.js +1 -0
  149. package/dist/components/ui-reveal.d.ts +11 -0
  150. package/dist/components/ui-reveal.js +1 -0
  151. package/dist/components/ui-scroll-progress.d.ts +11 -0
  152. package/dist/components/ui-scroll-progress.js +1 -0
  153. package/dist/components/ui-section.d.ts +11 -0
  154. package/dist/components/ui-section.js +1 -0
  155. package/dist/components/ui-select.d.ts +11 -0
  156. package/dist/components/ui-select.js +1 -0
  157. package/dist/components/ui-separator.d.ts +11 -0
  158. package/dist/components/ui-separator.js +1 -0
  159. package/dist/components/ui-skeleton.d.ts +11 -0
  160. package/dist/components/ui-skeleton.js +1 -0
  161. package/dist/components/ui-slider.d.ts +11 -0
  162. package/dist/components/ui-slider.js +1 -0
  163. package/dist/components/ui-spinner.d.ts +11 -0
  164. package/dist/components/ui-spinner.js +1 -0
  165. package/dist/components/ui-switch.d.ts +11 -0
  166. package/dist/components/ui-switch.js +1 -0
  167. package/dist/components/ui-tabs.d.ts +11 -0
  168. package/dist/components/ui-tabs.js +1 -0
  169. package/dist/components/ui-textarea.d.ts +11 -0
  170. package/dist/components/ui-textarea.js +1 -0
  171. package/dist/components/ui-theme-toggle.d.ts +11 -0
  172. package/dist/components/ui-theme-toggle.js +1 -0
  173. package/dist/components/ui-toast.d.ts +11 -0
  174. package/dist/components/ui-toast.js +1 -0
  175. package/dist/components/ui-toaster.d.ts +11 -0
  176. package/dist/components/ui-toaster.js +1 -0
  177. package/dist/components/ui-tooltip.d.ts +11 -0
  178. package/dist/components/ui-tooltip.js +1 -0
  179. package/dist/esm/floating-ui.dom-CyBRmmbs.js +1536 -0
  180. package/dist/esm/index-DYwlrXg_.js +1718 -0
  181. package/dist/esm/index.js +1 -0
  182. package/dist/esm/loader.js +10 -0
  183. package/dist/esm/ui-accordion-item.entry.js +25 -0
  184. package/dist/esm/ui-accordion.entry.js +15 -0
  185. package/dist/esm/ui-avatar.entry.js +17 -0
  186. package/dist/esm/ui-badge.entry.js +17 -0
  187. package/dist/esm/ui-button.entry.js +29 -0
  188. package/dist/esm/ui-card.entry.js +15 -0
  189. package/dist/esm/ui-checkbox.entry.js +32 -0
  190. package/dist/esm/ui-dialog.entry.js +55 -0
  191. package/dist/esm/ui-drawer.entry.js +57 -0
  192. package/dist/esm/ui-dropdown-item.entry.js +25 -0
  193. package/dist/esm/ui-dropdown-menu.entry.js +95 -0
  194. package/dist/esm/ui-field.entry.js +17 -0
  195. package/dist/esm/ui-input.entry.js +33 -0
  196. package/dist/esm/ui-label.entry.js +15 -0
  197. package/dist/esm/ui-loading-overlay.entry.js +22 -0
  198. package/dist/esm/ui-popover.entry.js +92 -0
  199. package/dist/esm/ui-progress.entry.js +31 -0
  200. package/dist/esm/ui-radio-group.entry.js +47 -0
  201. package/dist/esm/ui-reveal.entry.js +39 -0
  202. package/dist/esm/ui-scroll-progress.entry.js +35 -0
  203. package/dist/esm/ui-section.entry.js +21 -0
  204. package/dist/esm/ui-select.entry.js +26 -0
  205. package/dist/esm/ui-separator.entry.js +17 -0
  206. package/dist/esm/ui-skeleton.entry.js +15 -0
  207. package/dist/esm/ui-slider.entry.js +35 -0
  208. package/dist/esm/ui-spinner.entry.js +17 -0
  209. package/dist/esm/ui-switch.entry.js +32 -0
  210. package/dist/esm/ui-tabs.entry.js +29 -0
  211. package/dist/esm/ui-textarea.entry.js +33 -0
  212. package/dist/esm/ui-theme-toggle.entry.js +63 -0
  213. package/dist/esm/ui-toast.entry.js +65 -0
  214. package/dist/esm/ui-toaster.entry.js +27 -0
  215. package/dist/esm/ui-tooltip.entry.js +62 -0
  216. package/dist/esm/uikit.js +20 -0
  217. package/dist/index.cjs.js +1 -0
  218. package/dist/index.js +1 -0
  219. package/dist/types/components/ui-accordion/ui-accordion.d.ts +3 -0
  220. package/dist/types/components/ui-accordion-item/ui-accordion-item.d.ts +11 -0
  221. package/dist/types/components/ui-avatar/ui-avatar.d.ts +9 -0
  222. package/dist/types/components/ui-badge/ui-badge.d.ts +6 -0
  223. package/dist/types/components/ui-button/ui-button.d.ts +15 -0
  224. package/dist/types/components/ui-card/ui-card.d.ts +3 -0
  225. package/dist/types/components/ui-checkbox/ui-checkbox.d.ts +16 -0
  226. package/dist/types/components/ui-dialog/ui-dialog.d.ts +18 -0
  227. package/dist/types/components/ui-drawer/ui-drawer.d.ts +20 -0
  228. package/dist/types/components/ui-dropdown-item/ui-dropdown-item.d.ts +10 -0
  229. package/dist/types/components/ui-dropdown-menu/ui-dropdown-menu.d.ts +28 -0
  230. package/dist/types/components/ui-field/ui-field.d.ts +13 -0
  231. package/dist/types/components/ui-input/ui-input.d.ts +22 -0
  232. package/dist/types/components/ui-label/ui-label.d.ts +3 -0
  233. package/dist/types/components/ui-loading-overlay/ui-loading-overlay.d.ts +15 -0
  234. package/dist/types/components/ui-popover/ui-popover.d.ts +27 -0
  235. package/dist/types/components/ui-progress/ui-progress.d.ts +11 -0
  236. package/dist/types/components/ui-radio-group/ui-radio-group.d.ts +20 -0
  237. package/dist/types/components/ui-reveal/ui-reveal.d.ts +11 -0
  238. package/dist/types/components/ui-scroll-progress/ui-scroll-progress.d.ts +8 -0
  239. package/dist/types/components/ui-section/ui-section.d.ts +9 -0
  240. package/dist/types/components/ui-select/ui-select.d.ts +21 -0
  241. package/dist/types/components/ui-separator/ui-separator.d.ts +6 -0
  242. package/dist/types/components/ui-skeleton/ui-skeleton.d.ts +3 -0
  243. package/dist/types/components/ui-slider/ui-slider.d.ts +20 -0
  244. package/dist/types/components/ui-spinner/ui-spinner.d.ts +6 -0
  245. package/dist/types/components/ui-switch/ui-switch.d.ts +12 -0
  246. package/dist/types/components/ui-tabs/ui-tabs.d.ts +15 -0
  247. package/dist/types/components/ui-textarea/ui-textarea.d.ts +22 -0
  248. package/dist/types/components/ui-theme-toggle/ui-theme-toggle.d.ts +13 -0
  249. package/dist/types/components/ui-toast/ui-toast.d.ts +28 -0
  250. package/dist/types/components/ui-toaster/ui-toaster.d.ts +19 -0
  251. package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +21 -0
  252. package/dist/types/components.d.ts +1727 -0
  253. package/dist/types/index.d.ts +1 -0
  254. package/dist/types/stencil-public-runtime.d.ts +1861 -0
  255. package/dist/uikit/index.esm.js +0 -0
  256. package/dist/uikit/p-06d6d907.entry.js +1 -0
  257. package/dist/uikit/p-0fb4949b.entry.js +1 -0
  258. package/dist/uikit/p-162302d1.entry.js +1 -0
  259. package/dist/uikit/p-19b81437.entry.js +1 -0
  260. package/dist/uikit/p-24edfe3e.entry.js +1 -0
  261. package/dist/uikit/p-3d30bc7a.entry.js +1 -0
  262. package/dist/uikit/p-4382718f.entry.js +1 -0
  263. package/dist/uikit/p-4a1abc1c.entry.js +1 -0
  264. package/dist/uikit/p-57058c30.entry.js +1 -0
  265. package/dist/uikit/p-5df32809.entry.js +1 -0
  266. package/dist/uikit/p-5ea42ee5.entry.js +1 -0
  267. package/dist/uikit/p-629c1728.entry.js +1 -0
  268. package/dist/uikit/p-76f0f79f.entry.js +1 -0
  269. package/dist/uikit/p-83159bfc.entry.js +1 -0
  270. package/dist/uikit/p-8bcd423c.entry.js +1 -0
  271. package/dist/uikit/p-8cebbe65.entry.js +1 -0
  272. package/dist/uikit/p-90d49509.entry.js +1 -0
  273. package/dist/uikit/p-94fb298e.entry.js +1 -0
  274. package/dist/uikit/p-9aa557d1.entry.js +1 -0
  275. package/dist/uikit/p-9c57cf57.entry.js +1 -0
  276. package/dist/uikit/p-9d784b04.entry.js +1 -0
  277. package/dist/uikit/p-9e7b81ef.entry.js +1 -0
  278. package/dist/uikit/p-9f7c6ca8.entry.js +1 -0
  279. package/dist/uikit/p-CyBRmmbs.js +1 -0
  280. package/dist/uikit/p-DYwlrXg_.js +2 -0
  281. package/dist/uikit/p-a7be1c69.entry.js +1 -0
  282. package/dist/uikit/p-b30aa6a6.entry.js +1 -0
  283. package/dist/uikit/p-b61e3df4.entry.js +1 -0
  284. package/dist/uikit/p-c72ed105.entry.js +1 -0
  285. package/dist/uikit/p-cb2adfb7.entry.js +1 -0
  286. package/dist/uikit/p-cf10ca3b.entry.js +1 -0
  287. package/dist/uikit/p-e410c789.entry.js +1 -0
  288. package/dist/uikit/p-f7402442.entry.js +1 -0
  289. package/dist/uikit/p-fd05c146.entry.js +1 -0
  290. package/dist/uikit/p-fd1648bf.entry.js +1 -0
  291. package/dist/uikit/uikit.css +6 -0
  292. package/dist/uikit/uikit.esm.js +1 -0
  293. package/loader/cdn.js +1 -0
  294. package/loader/index.cjs.js +1 -0
  295. package/loader/index.d.ts +24 -0
  296. package/loader/index.es2017.js +1 -0
  297. package/loader/index.js +2 -0
  298. package/package.json +48 -0
@@ -0,0 +1,1542 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Custom positioning reference element.
5
+ * @see https://floating-ui.com/docs/virtual-elements
6
+ */
7
+
8
+ const min = Math.min;
9
+ const max = Math.max;
10
+ const round = Math.round;
11
+ const floor = Math.floor;
12
+ const createCoords = v => ({
13
+ x: v,
14
+ y: v
15
+ });
16
+ const oppositeSideMap = {
17
+ left: 'right',
18
+ right: 'left',
19
+ bottom: 'top',
20
+ top: 'bottom'
21
+ };
22
+ function clamp(start, value, end) {
23
+ return max(start, min(value, end));
24
+ }
25
+ function evaluate(value, param) {
26
+ return typeof value === 'function' ? value(param) : value;
27
+ }
28
+ function getSide(placement) {
29
+ return placement.split('-')[0];
30
+ }
31
+ function getAlignment(placement) {
32
+ return placement.split('-')[1];
33
+ }
34
+ function getOppositeAxis(axis) {
35
+ return axis === 'x' ? 'y' : 'x';
36
+ }
37
+ function getAxisLength(axis) {
38
+ return axis === 'y' ? 'height' : 'width';
39
+ }
40
+ function getSideAxis(placement) {
41
+ const firstChar = placement[0];
42
+ return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
43
+ }
44
+ function getAlignmentAxis(placement) {
45
+ return getOppositeAxis(getSideAxis(placement));
46
+ }
47
+ function getAlignmentSides(placement, rects, rtl) {
48
+ if (rtl === void 0) {
49
+ rtl = false;
50
+ }
51
+ const alignment = getAlignment(placement);
52
+ const alignmentAxis = getAlignmentAxis(placement);
53
+ const length = getAxisLength(alignmentAxis);
54
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
55
+ if (rects.reference[length] > rects.floating[length]) {
56
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
57
+ }
58
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
59
+ }
60
+ function getExpandedPlacements(placement) {
61
+ const oppositePlacement = getOppositePlacement(placement);
62
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
63
+ }
64
+ function getOppositeAlignmentPlacement(placement) {
65
+ return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
66
+ }
67
+ const lrPlacement = ['left', 'right'];
68
+ const rlPlacement = ['right', 'left'];
69
+ const tbPlacement = ['top', 'bottom'];
70
+ const btPlacement = ['bottom', 'top'];
71
+ function getSideList(side, isStart, rtl) {
72
+ switch (side) {
73
+ case 'top':
74
+ case 'bottom':
75
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
76
+ return isStart ? lrPlacement : rlPlacement;
77
+ case 'left':
78
+ case 'right':
79
+ return isStart ? tbPlacement : btPlacement;
80
+ default:
81
+ return [];
82
+ }
83
+ }
84
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
85
+ const alignment = getAlignment(placement);
86
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
87
+ if (alignment) {
88
+ list = list.map(side => side + "-" + alignment);
89
+ if (flipAlignment) {
90
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
91
+ }
92
+ }
93
+ return list;
94
+ }
95
+ function getOppositePlacement(placement) {
96
+ const side = getSide(placement);
97
+ return oppositeSideMap[side] + placement.slice(side.length);
98
+ }
99
+ function expandPaddingObject(padding) {
100
+ return {
101
+ top: 0,
102
+ right: 0,
103
+ bottom: 0,
104
+ left: 0,
105
+ ...padding
106
+ };
107
+ }
108
+ function getPaddingObject(padding) {
109
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
110
+ top: padding,
111
+ right: padding,
112
+ bottom: padding,
113
+ left: padding
114
+ };
115
+ }
116
+ function rectToClientRect(rect) {
117
+ const {
118
+ x,
119
+ y,
120
+ width,
121
+ height
122
+ } = rect;
123
+ return {
124
+ width,
125
+ height,
126
+ top: y,
127
+ left: x,
128
+ right: x + width,
129
+ bottom: y + height,
130
+ x,
131
+ y
132
+ };
133
+ }
134
+
135
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
136
+ let {
137
+ reference,
138
+ floating
139
+ } = _ref;
140
+ const sideAxis = getSideAxis(placement);
141
+ const alignmentAxis = getAlignmentAxis(placement);
142
+ const alignLength = getAxisLength(alignmentAxis);
143
+ const side = getSide(placement);
144
+ const isVertical = sideAxis === 'y';
145
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
146
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
147
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
148
+ let coords;
149
+ switch (side) {
150
+ case 'top':
151
+ coords = {
152
+ x: commonX,
153
+ y: reference.y - floating.height
154
+ };
155
+ break;
156
+ case 'bottom':
157
+ coords = {
158
+ x: commonX,
159
+ y: reference.y + reference.height
160
+ };
161
+ break;
162
+ case 'right':
163
+ coords = {
164
+ x: reference.x + reference.width,
165
+ y: commonY
166
+ };
167
+ break;
168
+ case 'left':
169
+ coords = {
170
+ x: reference.x - floating.width,
171
+ y: commonY
172
+ };
173
+ break;
174
+ default:
175
+ coords = {
176
+ x: reference.x,
177
+ y: reference.y
178
+ };
179
+ }
180
+ switch (getAlignment(placement)) {
181
+ case 'start':
182
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
183
+ break;
184
+ case 'end':
185
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
186
+ break;
187
+ }
188
+ return coords;
189
+ }
190
+
191
+ /**
192
+ * Resolves with an object of overflow side offsets that determine how much the
193
+ * element is overflowing a given clipping boundary on each side.
194
+ * - positive = overflowing the boundary by that number of pixels
195
+ * - negative = how many pixels left before it will overflow
196
+ * - 0 = lies flush with the boundary
197
+ * @see https://floating-ui.com/docs/detectOverflow
198
+ */
199
+ async function detectOverflow(state, options) {
200
+ var _await$platform$isEle;
201
+ if (options === void 0) {
202
+ options = {};
203
+ }
204
+ const {
205
+ x,
206
+ y,
207
+ platform,
208
+ rects,
209
+ elements,
210
+ strategy
211
+ } = state;
212
+ const {
213
+ boundary = 'clippingAncestors',
214
+ rootBoundary = 'viewport',
215
+ elementContext = 'floating',
216
+ altBoundary = false,
217
+ padding = 0
218
+ } = evaluate(options, state);
219
+ const paddingObject = getPaddingObject(padding);
220
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
221
+ const element = elements[altBoundary ? altContext : elementContext];
222
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
223
+ 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))),
224
+ boundary,
225
+ rootBoundary,
226
+ strategy
227
+ }));
228
+ const rect = elementContext === 'floating' ? {
229
+ x,
230
+ y,
231
+ width: rects.floating.width,
232
+ height: rects.floating.height
233
+ } : rects.reference;
234
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
235
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
236
+ x: 1,
237
+ y: 1
238
+ } : {
239
+ x: 1,
240
+ y: 1
241
+ };
242
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
243
+ elements,
244
+ rect,
245
+ offsetParent,
246
+ strategy
247
+ }) : rect);
248
+ return {
249
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
250
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
251
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
252
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
253
+ };
254
+ }
255
+
256
+ // Maximum number of resets that can occur before bailing to avoid infinite reset loops.
257
+ const MAX_RESET_COUNT = 50;
258
+
259
+ /**
260
+ * Computes the `x` and `y` coordinates that will place the floating element
261
+ * next to a given reference element.
262
+ *
263
+ * This export does not have any `platform` interface logic. You will need to
264
+ * write one for the platform you are using Floating UI with.
265
+ */
266
+ const computePosition$1 = async (reference, floating, config) => {
267
+ const {
268
+ placement = 'bottom',
269
+ strategy = 'absolute',
270
+ middleware = [],
271
+ platform
272
+ } = config;
273
+ const platformWithDetectOverflow = platform.detectOverflow ? platform : {
274
+ ...platform,
275
+ detectOverflow
276
+ };
277
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
278
+ let rects = await platform.getElementRects({
279
+ reference,
280
+ floating,
281
+ strategy
282
+ });
283
+ let {
284
+ x,
285
+ y
286
+ } = computeCoordsFromPlacement(rects, placement, rtl);
287
+ let statefulPlacement = placement;
288
+ let resetCount = 0;
289
+ const middlewareData = {};
290
+ for (let i = 0; i < middleware.length; i++) {
291
+ const currentMiddleware = middleware[i];
292
+ if (!currentMiddleware) {
293
+ continue;
294
+ }
295
+ const {
296
+ name,
297
+ fn
298
+ } = currentMiddleware;
299
+ const {
300
+ x: nextX,
301
+ y: nextY,
302
+ data,
303
+ reset
304
+ } = await fn({
305
+ x,
306
+ y,
307
+ initialPlacement: placement,
308
+ placement: statefulPlacement,
309
+ strategy,
310
+ middlewareData,
311
+ rects,
312
+ platform: platformWithDetectOverflow,
313
+ elements: {
314
+ reference,
315
+ floating
316
+ }
317
+ });
318
+ x = nextX != null ? nextX : x;
319
+ y = nextY != null ? nextY : y;
320
+ middlewareData[name] = {
321
+ ...middlewareData[name],
322
+ ...data
323
+ };
324
+ if (reset && resetCount < MAX_RESET_COUNT) {
325
+ resetCount++;
326
+ if (typeof reset === 'object') {
327
+ if (reset.placement) {
328
+ statefulPlacement = reset.placement;
329
+ }
330
+ if (reset.rects) {
331
+ rects = reset.rects === true ? await platform.getElementRects({
332
+ reference,
333
+ floating,
334
+ strategy
335
+ }) : reset.rects;
336
+ }
337
+ ({
338
+ x,
339
+ y
340
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
341
+ }
342
+ i = -1;
343
+ }
344
+ }
345
+ return {
346
+ x,
347
+ y,
348
+ placement: statefulPlacement,
349
+ strategy,
350
+ middlewareData
351
+ };
352
+ };
353
+
354
+ /**
355
+ * Optimizes the visibility of the floating element by flipping the `placement`
356
+ * in order to keep it in view when the preferred placement(s) will overflow the
357
+ * clipping boundary. Alternative to `autoPlacement`.
358
+ * @see https://floating-ui.com/docs/flip
359
+ */
360
+ const flip$1 = function (options) {
361
+ if (options === void 0) {
362
+ options = {};
363
+ }
364
+ return {
365
+ name: 'flip',
366
+ options,
367
+ async fn(state) {
368
+ var _middlewareData$arrow, _middlewareData$flip;
369
+ const {
370
+ placement,
371
+ middlewareData,
372
+ rects,
373
+ initialPlacement,
374
+ platform,
375
+ elements
376
+ } = state;
377
+ const {
378
+ mainAxis: checkMainAxis = true,
379
+ crossAxis: checkCrossAxis = true,
380
+ fallbackPlacements: specifiedFallbackPlacements,
381
+ fallbackStrategy = 'bestFit',
382
+ fallbackAxisSideDirection = 'none',
383
+ flipAlignment = true,
384
+ ...detectOverflowOptions
385
+ } = evaluate(options, state);
386
+
387
+ // If a reset by the arrow was caused due to an alignment offset being
388
+ // added, we should skip any logic now since `flip()` has already done its
389
+ // work.
390
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
391
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
392
+ return {};
393
+ }
394
+ const side = getSide(placement);
395
+ const initialSideAxis = getSideAxis(initialPlacement);
396
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
397
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
398
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
399
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
400
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
401
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
402
+ }
403
+ const placements = [initialPlacement, ...fallbackPlacements];
404
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
405
+ const overflows = [];
406
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
407
+ if (checkMainAxis) {
408
+ overflows.push(overflow[side]);
409
+ }
410
+ if (checkCrossAxis) {
411
+ const sides = getAlignmentSides(placement, rects, rtl);
412
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
413
+ }
414
+ overflowsData = [...overflowsData, {
415
+ placement,
416
+ overflows
417
+ }];
418
+
419
+ // One or more sides is overflowing.
420
+ if (!overflows.every(side => side <= 0)) {
421
+ var _middlewareData$flip2, _overflowsData$filter;
422
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
423
+ const nextPlacement = placements[nextIndex];
424
+ if (nextPlacement) {
425
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
426
+ if (!ignoreCrossAxisOverflow ||
427
+ // We leave the current main axis only if every placement on that axis
428
+ // overflows the main axis.
429
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
430
+ // Try next placement and re-run the lifecycle.
431
+ return {
432
+ data: {
433
+ index: nextIndex,
434
+ overflows: overflowsData
435
+ },
436
+ reset: {
437
+ placement: nextPlacement
438
+ }
439
+ };
440
+ }
441
+ }
442
+
443
+ // First, find the candidates that fit on the mainAxis side of overflow,
444
+ // then find the placement that fits the best on the main crossAxis side.
445
+ 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;
446
+
447
+ // Otherwise fallback.
448
+ if (!resetPlacement) {
449
+ switch (fallbackStrategy) {
450
+ case 'bestFit':
451
+ {
452
+ var _overflowsData$filter2;
453
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
454
+ if (hasFallbackAxisSideDirection) {
455
+ const currentSideAxis = getSideAxis(d.placement);
456
+ return currentSideAxis === initialSideAxis ||
457
+ // Create a bias to the `y` side axis due to horizontal
458
+ // reading directions favoring greater width.
459
+ currentSideAxis === 'y';
460
+ }
461
+ return true;
462
+ }).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];
463
+ if (placement) {
464
+ resetPlacement = placement;
465
+ }
466
+ break;
467
+ }
468
+ case 'initialPlacement':
469
+ resetPlacement = initialPlacement;
470
+ break;
471
+ }
472
+ }
473
+ if (placement !== resetPlacement) {
474
+ return {
475
+ reset: {
476
+ placement: resetPlacement
477
+ }
478
+ };
479
+ }
480
+ }
481
+ return {};
482
+ }
483
+ };
484
+ };
485
+
486
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
487
+
488
+ // For type backwards-compatibility, the `OffsetOptions` type was also
489
+ // Derivable.
490
+
491
+ async function convertValueToCoords(state, options) {
492
+ const {
493
+ placement,
494
+ platform,
495
+ elements
496
+ } = state;
497
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
498
+ const side = getSide(placement);
499
+ const alignment = getAlignment(placement);
500
+ const isVertical = getSideAxis(placement) === 'y';
501
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
502
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
503
+ const rawValue = evaluate(options, state);
504
+
505
+ // eslint-disable-next-line prefer-const
506
+ let {
507
+ mainAxis,
508
+ crossAxis,
509
+ alignmentAxis
510
+ } = typeof rawValue === 'number' ? {
511
+ mainAxis: rawValue,
512
+ crossAxis: 0,
513
+ alignmentAxis: null
514
+ } : {
515
+ mainAxis: rawValue.mainAxis || 0,
516
+ crossAxis: rawValue.crossAxis || 0,
517
+ alignmentAxis: rawValue.alignmentAxis
518
+ };
519
+ if (alignment && typeof alignmentAxis === 'number') {
520
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
521
+ }
522
+ return isVertical ? {
523
+ x: crossAxis * crossAxisMulti,
524
+ y: mainAxis * mainAxisMulti
525
+ } : {
526
+ x: mainAxis * mainAxisMulti,
527
+ y: crossAxis * crossAxisMulti
528
+ };
529
+ }
530
+
531
+ /**
532
+ * Modifies the placement by translating the floating element along the
533
+ * specified axes.
534
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
535
+ * object may be passed.
536
+ * @see https://floating-ui.com/docs/offset
537
+ */
538
+ const offset$1 = function (options) {
539
+ if (options === void 0) {
540
+ options = 0;
541
+ }
542
+ return {
543
+ name: 'offset',
544
+ options,
545
+ async fn(state) {
546
+ var _middlewareData$offse, _middlewareData$arrow;
547
+ const {
548
+ x,
549
+ y,
550
+ placement,
551
+ middlewareData
552
+ } = state;
553
+ const diffCoords = await convertValueToCoords(state, options);
554
+
555
+ // If the placement is the same and the arrow caused an alignment offset
556
+ // then we don't need to change the positioning coordinates.
557
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
558
+ return {};
559
+ }
560
+ return {
561
+ x: x + diffCoords.x,
562
+ y: y + diffCoords.y,
563
+ data: {
564
+ ...diffCoords,
565
+ placement
566
+ }
567
+ };
568
+ }
569
+ };
570
+ };
571
+
572
+ /**
573
+ * Optimizes the visibility of the floating element by shifting it in order to
574
+ * keep it in view when it will overflow the clipping boundary.
575
+ * @see https://floating-ui.com/docs/shift
576
+ */
577
+ const shift$1 = function (options) {
578
+ if (options === void 0) {
579
+ options = {};
580
+ }
581
+ return {
582
+ name: 'shift',
583
+ options,
584
+ async fn(state) {
585
+ const {
586
+ x,
587
+ y,
588
+ placement,
589
+ platform
590
+ } = state;
591
+ const {
592
+ mainAxis: checkMainAxis = true,
593
+ crossAxis: checkCrossAxis = false,
594
+ limiter = {
595
+ fn: _ref => {
596
+ let {
597
+ x,
598
+ y
599
+ } = _ref;
600
+ return {
601
+ x,
602
+ y
603
+ };
604
+ }
605
+ },
606
+ ...detectOverflowOptions
607
+ } = evaluate(options, state);
608
+ const coords = {
609
+ x,
610
+ y
611
+ };
612
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
613
+ const crossAxis = getSideAxis(getSide(placement));
614
+ const mainAxis = getOppositeAxis(crossAxis);
615
+ let mainAxisCoord = coords[mainAxis];
616
+ let crossAxisCoord = coords[crossAxis];
617
+ if (checkMainAxis) {
618
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
619
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
620
+ const min = mainAxisCoord + overflow[minSide];
621
+ const max = mainAxisCoord - overflow[maxSide];
622
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
623
+ }
624
+ if (checkCrossAxis) {
625
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
626
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
627
+ const min = crossAxisCoord + overflow[minSide];
628
+ const max = crossAxisCoord - overflow[maxSide];
629
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
630
+ }
631
+ const limitedCoords = limiter.fn({
632
+ ...state,
633
+ [mainAxis]: mainAxisCoord,
634
+ [crossAxis]: crossAxisCoord
635
+ });
636
+ return {
637
+ ...limitedCoords,
638
+ data: {
639
+ x: limitedCoords.x - x,
640
+ y: limitedCoords.y - y,
641
+ enabled: {
642
+ [mainAxis]: checkMainAxis,
643
+ [crossAxis]: checkCrossAxis
644
+ }
645
+ }
646
+ };
647
+ }
648
+ };
649
+ };
650
+
651
+ function hasWindow() {
652
+ return typeof window !== 'undefined';
653
+ }
654
+ function getNodeName(node) {
655
+ if (isNode(node)) {
656
+ return (node.nodeName || '').toLowerCase();
657
+ }
658
+ // Mocked nodes in testing environments may not be instances of Node. By
659
+ // returning `#document` an infinite loop won't occur.
660
+ // https://github.com/floating-ui/floating-ui/issues/2317
661
+ return '#document';
662
+ }
663
+ function getWindow(node) {
664
+ var _node$ownerDocument;
665
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
666
+ }
667
+ function getDocumentElement(node) {
668
+ var _ref;
669
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
670
+ }
671
+ function isNode(value) {
672
+ if (!hasWindow()) {
673
+ return false;
674
+ }
675
+ return value instanceof Node || value instanceof getWindow(value).Node;
676
+ }
677
+ function isElement(value) {
678
+ if (!hasWindow()) {
679
+ return false;
680
+ }
681
+ return value instanceof Element || value instanceof getWindow(value).Element;
682
+ }
683
+ function isHTMLElement(value) {
684
+ if (!hasWindow()) {
685
+ return false;
686
+ }
687
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
688
+ }
689
+ function isShadowRoot(value) {
690
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
691
+ return false;
692
+ }
693
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
694
+ }
695
+ function isOverflowElement(element) {
696
+ const {
697
+ overflow,
698
+ overflowX,
699
+ overflowY,
700
+ display
701
+ } = getComputedStyle$1(element);
702
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
703
+ }
704
+ function isTableElement(element) {
705
+ return /^(table|td|th)$/.test(getNodeName(element));
706
+ }
707
+ function isTopLayer(element) {
708
+ try {
709
+ if (element.matches(':popover-open')) {
710
+ return true;
711
+ }
712
+ } catch (_e) {
713
+ // no-op
714
+ }
715
+ try {
716
+ return element.matches(':modal');
717
+ } catch (_e) {
718
+ return false;
719
+ }
720
+ }
721
+ const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
722
+ const containRe = /paint|layout|strict|content/;
723
+ const isNotNone = value => !!value && value !== 'none';
724
+ let isWebKitValue;
725
+ function isContainingBlock(elementOrCss) {
726
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
727
+
728
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
729
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
730
+ return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
731
+ }
732
+ function getContainingBlock(element) {
733
+ let currentNode = getParentNode(element);
734
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
735
+ if (isContainingBlock(currentNode)) {
736
+ return currentNode;
737
+ } else if (isTopLayer(currentNode)) {
738
+ return null;
739
+ }
740
+ currentNode = getParentNode(currentNode);
741
+ }
742
+ return null;
743
+ }
744
+ function isWebKit() {
745
+ if (isWebKitValue == null) {
746
+ isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
747
+ }
748
+ return isWebKitValue;
749
+ }
750
+ function isLastTraversableNode(node) {
751
+ return /^(html|body|#document)$/.test(getNodeName(node));
752
+ }
753
+ function getComputedStyle$1(element) {
754
+ return getWindow(element).getComputedStyle(element);
755
+ }
756
+ function getNodeScroll(element) {
757
+ if (isElement(element)) {
758
+ return {
759
+ scrollLeft: element.scrollLeft,
760
+ scrollTop: element.scrollTop
761
+ };
762
+ }
763
+ return {
764
+ scrollLeft: element.scrollX,
765
+ scrollTop: element.scrollY
766
+ };
767
+ }
768
+ function getParentNode(node) {
769
+ if (getNodeName(node) === 'html') {
770
+ return node;
771
+ }
772
+ const result =
773
+ // Step into the shadow DOM of the parent of a slotted node.
774
+ node.assignedSlot ||
775
+ // DOM Element detected.
776
+ node.parentNode ||
777
+ // ShadowRoot detected.
778
+ isShadowRoot(node) && node.host ||
779
+ // Fallback.
780
+ getDocumentElement(node);
781
+ return isShadowRoot(result) ? result.host : result;
782
+ }
783
+ function getNearestOverflowAncestor(node) {
784
+ const parentNode = getParentNode(node);
785
+ if (isLastTraversableNode(parentNode)) {
786
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
787
+ }
788
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
789
+ return parentNode;
790
+ }
791
+ return getNearestOverflowAncestor(parentNode);
792
+ }
793
+ function getOverflowAncestors(node, list, traverseIframes) {
794
+ var _node$ownerDocument2;
795
+ if (list === void 0) {
796
+ list = [];
797
+ }
798
+ if (traverseIframes === void 0) {
799
+ traverseIframes = true;
800
+ }
801
+ const scrollableAncestor = getNearestOverflowAncestor(node);
802
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
803
+ const win = getWindow(scrollableAncestor);
804
+ if (isBody) {
805
+ const frameElement = getFrameElement(win);
806
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
807
+ } else {
808
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
809
+ }
810
+ }
811
+ function getFrameElement(win) {
812
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
813
+ }
814
+
815
+ function getCssDimensions(element) {
816
+ const css = getComputedStyle$1(element);
817
+ // In testing environments, the `width` and `height` properties are empty
818
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
819
+ let width = parseFloat(css.width) || 0;
820
+ let height = parseFloat(css.height) || 0;
821
+ const hasOffset = isHTMLElement(element);
822
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
823
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
824
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
825
+ if (shouldFallback) {
826
+ width = offsetWidth;
827
+ height = offsetHeight;
828
+ }
829
+ return {
830
+ width,
831
+ height,
832
+ $: shouldFallback
833
+ };
834
+ }
835
+
836
+ function unwrapElement(element) {
837
+ return !isElement(element) ? element.contextElement : element;
838
+ }
839
+
840
+ function getScale(element) {
841
+ const domElement = unwrapElement(element);
842
+ if (!isHTMLElement(domElement)) {
843
+ return createCoords(1);
844
+ }
845
+ const rect = domElement.getBoundingClientRect();
846
+ const {
847
+ width,
848
+ height,
849
+ $
850
+ } = getCssDimensions(domElement);
851
+ let x = ($ ? round(rect.width) : rect.width) / width;
852
+ let y = ($ ? round(rect.height) : rect.height) / height;
853
+
854
+ // 0, NaN, or Infinity should always fallback to 1.
855
+
856
+ if (!x || !Number.isFinite(x)) {
857
+ x = 1;
858
+ }
859
+ if (!y || !Number.isFinite(y)) {
860
+ y = 1;
861
+ }
862
+ return {
863
+ x,
864
+ y
865
+ };
866
+ }
867
+
868
+ const noOffsets = /*#__PURE__*/createCoords(0);
869
+ function getVisualOffsets(element) {
870
+ const win = getWindow(element);
871
+ if (!isWebKit() || !win.visualViewport) {
872
+ return noOffsets;
873
+ }
874
+ return {
875
+ x: win.visualViewport.offsetLeft,
876
+ y: win.visualViewport.offsetTop
877
+ };
878
+ }
879
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
880
+ if (isFixed === void 0) {
881
+ isFixed = false;
882
+ }
883
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
884
+ return false;
885
+ }
886
+ return isFixed;
887
+ }
888
+
889
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
890
+ if (includeScale === void 0) {
891
+ includeScale = false;
892
+ }
893
+ if (isFixedStrategy === void 0) {
894
+ isFixedStrategy = false;
895
+ }
896
+ const clientRect = element.getBoundingClientRect();
897
+ const domElement = unwrapElement(element);
898
+ let scale = createCoords(1);
899
+ if (includeScale) {
900
+ if (offsetParent) {
901
+ if (isElement(offsetParent)) {
902
+ scale = getScale(offsetParent);
903
+ }
904
+ } else {
905
+ scale = getScale(element);
906
+ }
907
+ }
908
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
909
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
910
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
911
+ let width = clientRect.width / scale.x;
912
+ let height = clientRect.height / scale.y;
913
+ if (domElement) {
914
+ const win = getWindow(domElement);
915
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
916
+ let currentWin = win;
917
+ let currentIFrame = getFrameElement(currentWin);
918
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
919
+ const iframeScale = getScale(currentIFrame);
920
+ const iframeRect = currentIFrame.getBoundingClientRect();
921
+ const css = getComputedStyle$1(currentIFrame);
922
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
923
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
924
+ x *= iframeScale.x;
925
+ y *= iframeScale.y;
926
+ width *= iframeScale.x;
927
+ height *= iframeScale.y;
928
+ x += left;
929
+ y += top;
930
+ currentWin = getWindow(currentIFrame);
931
+ currentIFrame = getFrameElement(currentWin);
932
+ }
933
+ }
934
+ return rectToClientRect({
935
+ width,
936
+ height,
937
+ x,
938
+ y
939
+ });
940
+ }
941
+
942
+ // If <html> has a CSS width greater than the viewport, then this will be
943
+ // incorrect for RTL.
944
+ function getWindowScrollBarX(element, rect) {
945
+ const leftScroll = getNodeScroll(element).scrollLeft;
946
+ if (!rect) {
947
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
948
+ }
949
+ return rect.left + leftScroll;
950
+ }
951
+
952
+ function getHTMLOffset(documentElement, scroll) {
953
+ const htmlRect = documentElement.getBoundingClientRect();
954
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
955
+ const y = htmlRect.top + scroll.scrollTop;
956
+ return {
957
+ x,
958
+ y
959
+ };
960
+ }
961
+
962
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
963
+ let {
964
+ elements,
965
+ rect,
966
+ offsetParent,
967
+ strategy
968
+ } = _ref;
969
+ const isFixed = strategy === 'fixed';
970
+ const documentElement = getDocumentElement(offsetParent);
971
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
972
+ if (offsetParent === documentElement || topLayer && isFixed) {
973
+ return rect;
974
+ }
975
+ let scroll = {
976
+ scrollLeft: 0,
977
+ scrollTop: 0
978
+ };
979
+ let scale = createCoords(1);
980
+ const offsets = createCoords(0);
981
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
982
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
983
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
984
+ scroll = getNodeScroll(offsetParent);
985
+ }
986
+ if (isOffsetParentAnElement) {
987
+ const offsetRect = getBoundingClientRect(offsetParent);
988
+ scale = getScale(offsetParent);
989
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
990
+ offsets.y = offsetRect.y + offsetParent.clientTop;
991
+ }
992
+ }
993
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
994
+ return {
995
+ width: rect.width * scale.x,
996
+ height: rect.height * scale.y,
997
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
998
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
999
+ };
1000
+ }
1001
+
1002
+ function getClientRects(element) {
1003
+ return Array.from(element.getClientRects());
1004
+ }
1005
+
1006
+ // Gets the entire size of the scrollable document area, even extending outside
1007
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1008
+ function getDocumentRect(element) {
1009
+ const html = getDocumentElement(element);
1010
+ const scroll = getNodeScroll(element);
1011
+ const body = element.ownerDocument.body;
1012
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1013
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1014
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1015
+ const y = -scroll.scrollTop;
1016
+ if (getComputedStyle$1(body).direction === 'rtl') {
1017
+ x += max(html.clientWidth, body.clientWidth) - width;
1018
+ }
1019
+ return {
1020
+ width,
1021
+ height,
1022
+ x,
1023
+ y
1024
+ };
1025
+ }
1026
+
1027
+ // Safety check: ensure the scrollbar space is reasonable in case this
1028
+ // calculation is affected by unusual styles.
1029
+ // Most scrollbars leave 15-18px of space.
1030
+ const SCROLLBAR_MAX = 25;
1031
+ function getViewportRect(element, strategy) {
1032
+ const win = getWindow(element);
1033
+ const html = getDocumentElement(element);
1034
+ const visualViewport = win.visualViewport;
1035
+ let width = html.clientWidth;
1036
+ let height = html.clientHeight;
1037
+ let x = 0;
1038
+ let y = 0;
1039
+ if (visualViewport) {
1040
+ width = visualViewport.width;
1041
+ height = visualViewport.height;
1042
+ const visualViewportBased = isWebKit();
1043
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1044
+ x = visualViewport.offsetLeft;
1045
+ y = visualViewport.offsetTop;
1046
+ }
1047
+ }
1048
+ const windowScrollbarX = getWindowScrollBarX(html);
1049
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1050
+ // visual width of the <html> but this is not considered in the size
1051
+ // of `html.clientWidth`.
1052
+ if (windowScrollbarX <= 0) {
1053
+ const doc = html.ownerDocument;
1054
+ const body = doc.body;
1055
+ const bodyStyles = getComputedStyle(body);
1056
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1057
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1058
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1059
+ width -= clippingStableScrollbarWidth;
1060
+ }
1061
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1062
+ // If the <body> scrollbar is on the left, the width needs to be extended
1063
+ // by the scrollbar amount so there isn't extra space on the right.
1064
+ width += windowScrollbarX;
1065
+ }
1066
+ return {
1067
+ width,
1068
+ height,
1069
+ x,
1070
+ y
1071
+ };
1072
+ }
1073
+
1074
+ // Returns the inner client rect, subtracting scrollbars if present.
1075
+ function getInnerBoundingClientRect(element, strategy) {
1076
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1077
+ const top = clientRect.top + element.clientTop;
1078
+ const left = clientRect.left + element.clientLeft;
1079
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1080
+ const width = element.clientWidth * scale.x;
1081
+ const height = element.clientHeight * scale.y;
1082
+ const x = left * scale.x;
1083
+ const y = top * scale.y;
1084
+ return {
1085
+ width,
1086
+ height,
1087
+ x,
1088
+ y
1089
+ };
1090
+ }
1091
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1092
+ let rect;
1093
+ if (clippingAncestor === 'viewport') {
1094
+ rect = getViewportRect(element, strategy);
1095
+ } else if (clippingAncestor === 'document') {
1096
+ rect = getDocumentRect(getDocumentElement(element));
1097
+ } else if (isElement(clippingAncestor)) {
1098
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1099
+ } else {
1100
+ const visualOffsets = getVisualOffsets(element);
1101
+ rect = {
1102
+ x: clippingAncestor.x - visualOffsets.x,
1103
+ y: clippingAncestor.y - visualOffsets.y,
1104
+ width: clippingAncestor.width,
1105
+ height: clippingAncestor.height
1106
+ };
1107
+ }
1108
+ return rectToClientRect(rect);
1109
+ }
1110
+ function hasFixedPositionAncestor(element, stopNode) {
1111
+ const parentNode = getParentNode(element);
1112
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1113
+ return false;
1114
+ }
1115
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1116
+ }
1117
+
1118
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1119
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1120
+ // of the given element up the tree.
1121
+ function getClippingElementAncestors(element, cache) {
1122
+ const cachedResult = cache.get(element);
1123
+ if (cachedResult) {
1124
+ return cachedResult;
1125
+ }
1126
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1127
+ let currentContainingBlockComputedStyle = null;
1128
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1129
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1130
+
1131
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1132
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1133
+ const computedStyle = getComputedStyle$1(currentNode);
1134
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1135
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1136
+ currentContainingBlockComputedStyle = null;
1137
+ }
1138
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1139
+ if (shouldDropCurrentNode) {
1140
+ // Drop non-containing blocks.
1141
+ result = result.filter(ancestor => ancestor !== currentNode);
1142
+ } else {
1143
+ // Record last containing block for next iteration.
1144
+ currentContainingBlockComputedStyle = computedStyle;
1145
+ }
1146
+ currentNode = getParentNode(currentNode);
1147
+ }
1148
+ cache.set(element, result);
1149
+ return result;
1150
+ }
1151
+
1152
+ // Gets the maximum area that the element is visible in due to any number of
1153
+ // clipping ancestors.
1154
+ function getClippingRect(_ref) {
1155
+ let {
1156
+ element,
1157
+ boundary,
1158
+ rootBoundary,
1159
+ strategy
1160
+ } = _ref;
1161
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1162
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1163
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
1164
+ let top = firstRect.top;
1165
+ let right = firstRect.right;
1166
+ let bottom = firstRect.bottom;
1167
+ let left = firstRect.left;
1168
+ for (let i = 1; i < clippingAncestors.length; i++) {
1169
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
1170
+ top = max(rect.top, top);
1171
+ right = min(rect.right, right);
1172
+ bottom = min(rect.bottom, bottom);
1173
+ left = max(rect.left, left);
1174
+ }
1175
+ return {
1176
+ width: right - left,
1177
+ height: bottom - top,
1178
+ x: left,
1179
+ y: top
1180
+ };
1181
+ }
1182
+
1183
+ function getDimensions(element) {
1184
+ const {
1185
+ width,
1186
+ height
1187
+ } = getCssDimensions(element);
1188
+ return {
1189
+ width,
1190
+ height
1191
+ };
1192
+ }
1193
+
1194
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1195
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1196
+ const documentElement = getDocumentElement(offsetParent);
1197
+ const isFixed = strategy === 'fixed';
1198
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1199
+ let scroll = {
1200
+ scrollLeft: 0,
1201
+ scrollTop: 0
1202
+ };
1203
+ const offsets = createCoords(0);
1204
+
1205
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1206
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1207
+ function setLeftRTLScrollbarOffset() {
1208
+ offsets.x = getWindowScrollBarX(documentElement);
1209
+ }
1210
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1211
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1212
+ scroll = getNodeScroll(offsetParent);
1213
+ }
1214
+ if (isOffsetParentAnElement) {
1215
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1216
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1217
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1218
+ } else if (documentElement) {
1219
+ setLeftRTLScrollbarOffset();
1220
+ }
1221
+ }
1222
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1223
+ setLeftRTLScrollbarOffset();
1224
+ }
1225
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1226
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1227
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1228
+ return {
1229
+ x,
1230
+ y,
1231
+ width: rect.width,
1232
+ height: rect.height
1233
+ };
1234
+ }
1235
+
1236
+ function isStaticPositioned(element) {
1237
+ return getComputedStyle$1(element).position === 'static';
1238
+ }
1239
+
1240
+ function getTrueOffsetParent(element, polyfill) {
1241
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1242
+ return null;
1243
+ }
1244
+ if (polyfill) {
1245
+ return polyfill(element);
1246
+ }
1247
+ let rawOffsetParent = element.offsetParent;
1248
+
1249
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1250
+ // while Chrome and Safari return the <body> element. The <body> element must
1251
+ // be used to perform the correct calculations even if the <html> element is
1252
+ // non-static.
1253
+ if (getDocumentElement(element) === rawOffsetParent) {
1254
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1255
+ }
1256
+ return rawOffsetParent;
1257
+ }
1258
+
1259
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1260
+ // such as table ancestors and cross browser bugs.
1261
+ function getOffsetParent(element, polyfill) {
1262
+ const win = getWindow(element);
1263
+ if (isTopLayer(element)) {
1264
+ return win;
1265
+ }
1266
+ if (!isHTMLElement(element)) {
1267
+ let svgOffsetParent = getParentNode(element);
1268
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1269
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1270
+ return svgOffsetParent;
1271
+ }
1272
+ svgOffsetParent = getParentNode(svgOffsetParent);
1273
+ }
1274
+ return win;
1275
+ }
1276
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1277
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1278
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1279
+ }
1280
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1281
+ return win;
1282
+ }
1283
+ return offsetParent || getContainingBlock(element) || win;
1284
+ }
1285
+
1286
+ const getElementRects = async function (data) {
1287
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1288
+ const getDimensionsFn = this.getDimensions;
1289
+ const floatingDimensions = await getDimensionsFn(data.floating);
1290
+ return {
1291
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1292
+ floating: {
1293
+ x: 0,
1294
+ y: 0,
1295
+ width: floatingDimensions.width,
1296
+ height: floatingDimensions.height
1297
+ }
1298
+ };
1299
+ };
1300
+
1301
+ function isRTL(element) {
1302
+ return getComputedStyle$1(element).direction === 'rtl';
1303
+ }
1304
+
1305
+ const platform = {
1306
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1307
+ getDocumentElement,
1308
+ getClippingRect,
1309
+ getOffsetParent,
1310
+ getElementRects,
1311
+ getClientRects,
1312
+ getDimensions,
1313
+ getScale,
1314
+ isElement,
1315
+ isRTL
1316
+ };
1317
+
1318
+ function rectsAreEqual(a, b) {
1319
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1320
+ }
1321
+
1322
+ // https://samthor.au/2021/observing-dom/
1323
+ function observeMove(element, onMove) {
1324
+ let io = null;
1325
+ let timeoutId;
1326
+ const root = getDocumentElement(element);
1327
+ function cleanup() {
1328
+ var _io;
1329
+ clearTimeout(timeoutId);
1330
+ (_io = io) == null || _io.disconnect();
1331
+ io = null;
1332
+ }
1333
+ function refresh(skip, threshold) {
1334
+ if (skip === void 0) {
1335
+ skip = false;
1336
+ }
1337
+ if (threshold === void 0) {
1338
+ threshold = 1;
1339
+ }
1340
+ cleanup();
1341
+ const elementRectForRootMargin = element.getBoundingClientRect();
1342
+ const {
1343
+ left,
1344
+ top,
1345
+ width,
1346
+ height
1347
+ } = elementRectForRootMargin;
1348
+ if (!skip) {
1349
+ onMove();
1350
+ }
1351
+ if (!width || !height) {
1352
+ return;
1353
+ }
1354
+ const insetTop = floor(top);
1355
+ const insetRight = floor(root.clientWidth - (left + width));
1356
+ const insetBottom = floor(root.clientHeight - (top + height));
1357
+ const insetLeft = floor(left);
1358
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1359
+ const options = {
1360
+ rootMargin,
1361
+ threshold: max(0, min(1, threshold)) || 1
1362
+ };
1363
+ let isFirstUpdate = true;
1364
+ function handleObserve(entries) {
1365
+ const ratio = entries[0].intersectionRatio;
1366
+ if (ratio !== threshold) {
1367
+ if (!isFirstUpdate) {
1368
+ return refresh();
1369
+ }
1370
+ if (!ratio) {
1371
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1372
+ // to prevent an infinite loop of updates.
1373
+ timeoutId = setTimeout(() => {
1374
+ refresh(false, 1e-7);
1375
+ }, 1000);
1376
+ } else {
1377
+ refresh(false, ratio);
1378
+ }
1379
+ }
1380
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1381
+ // It's possible that even though the ratio is reported as 1, the
1382
+ // element is not actually fully within the IntersectionObserver's root
1383
+ // area anymore. This can happen under performance constraints. This may
1384
+ // be a bug in the browser's IntersectionObserver implementation. To
1385
+ // work around this, we compare the element's bounding rect now with
1386
+ // what it was at the time we created the IntersectionObserver. If they
1387
+ // are not equal then the element moved, so we refresh.
1388
+ refresh();
1389
+ }
1390
+ isFirstUpdate = false;
1391
+ }
1392
+
1393
+ // Older browsers don't support a `document` as the root and will throw an
1394
+ // error.
1395
+ try {
1396
+ io = new IntersectionObserver(handleObserve, {
1397
+ ...options,
1398
+ // Handle <iframe>s
1399
+ root: root.ownerDocument
1400
+ });
1401
+ } catch (_e) {
1402
+ io = new IntersectionObserver(handleObserve, options);
1403
+ }
1404
+ io.observe(element);
1405
+ }
1406
+ refresh(true);
1407
+ return cleanup;
1408
+ }
1409
+
1410
+ /**
1411
+ * Automatically updates the position of the floating element when necessary.
1412
+ * Should only be called when the floating element is mounted on the DOM or
1413
+ * visible on the screen.
1414
+ * @returns cleanup function that should be invoked when the floating element is
1415
+ * removed from the DOM or hidden from the screen.
1416
+ * @see https://floating-ui.com/docs/autoUpdate
1417
+ */
1418
+ function autoUpdate(reference, floating, update, options) {
1419
+ if (options === void 0) {
1420
+ options = {};
1421
+ }
1422
+ const {
1423
+ ancestorScroll = true,
1424
+ ancestorResize = true,
1425
+ elementResize = typeof ResizeObserver === 'function',
1426
+ layoutShift = typeof IntersectionObserver === 'function',
1427
+ animationFrame = false
1428
+ } = options;
1429
+ const referenceEl = unwrapElement(reference);
1430
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
1431
+ ancestors.forEach(ancestor => {
1432
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1433
+ passive: true
1434
+ });
1435
+ ancestorResize && ancestor.addEventListener('resize', update);
1436
+ });
1437
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1438
+ let reobserveFrame = -1;
1439
+ let resizeObserver = null;
1440
+ if (elementResize) {
1441
+ resizeObserver = new ResizeObserver(_ref => {
1442
+ let [firstEntry] = _ref;
1443
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
1444
+ // Prevent update loops when using the `size` middleware.
1445
+ // https://github.com/floating-ui/floating-ui/issues/1740
1446
+ resizeObserver.unobserve(floating);
1447
+ cancelAnimationFrame(reobserveFrame);
1448
+ reobserveFrame = requestAnimationFrame(() => {
1449
+ var _resizeObserver;
1450
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1451
+ });
1452
+ }
1453
+ update();
1454
+ });
1455
+ if (referenceEl && !animationFrame) {
1456
+ resizeObserver.observe(referenceEl);
1457
+ }
1458
+ if (floating) {
1459
+ resizeObserver.observe(floating);
1460
+ }
1461
+ }
1462
+ let frameId;
1463
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1464
+ if (animationFrame) {
1465
+ frameLoop();
1466
+ }
1467
+ function frameLoop() {
1468
+ const nextRefRect = getBoundingClientRect(reference);
1469
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1470
+ update();
1471
+ }
1472
+ prevRefRect = nextRefRect;
1473
+ frameId = requestAnimationFrame(frameLoop);
1474
+ }
1475
+ update();
1476
+ return () => {
1477
+ var _resizeObserver2;
1478
+ ancestors.forEach(ancestor => {
1479
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1480
+ ancestorResize && ancestor.removeEventListener('resize', update);
1481
+ });
1482
+ cleanupIo == null || cleanupIo();
1483
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1484
+ resizeObserver = null;
1485
+ if (animationFrame) {
1486
+ cancelAnimationFrame(frameId);
1487
+ }
1488
+ };
1489
+ }
1490
+
1491
+ /**
1492
+ * Modifies the placement by translating the floating element along the
1493
+ * specified axes.
1494
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1495
+ * object may be passed.
1496
+ * @see https://floating-ui.com/docs/offset
1497
+ */
1498
+ const offset = offset$1;
1499
+
1500
+ /**
1501
+ * Optimizes the visibility of the floating element by shifting it in order to
1502
+ * keep it in view when it will overflow the clipping boundary.
1503
+ * @see https://floating-ui.com/docs/shift
1504
+ */
1505
+ const shift = shift$1;
1506
+
1507
+ /**
1508
+ * Optimizes the visibility of the floating element by flipping the `placement`
1509
+ * in order to keep it in view when the preferred placement(s) will overflow the
1510
+ * clipping boundary. Alternative to `autoPlacement`.
1511
+ * @see https://floating-ui.com/docs/flip
1512
+ */
1513
+ const flip = flip$1;
1514
+
1515
+ /**
1516
+ * Computes the `x` and `y` coordinates that will place the floating element
1517
+ * next to a given reference element.
1518
+ */
1519
+ const computePosition = (reference, floating, options) => {
1520
+ // This caches the expensive `getClippingElementAncestors` function so that
1521
+ // multiple lifecycle resets re-use the same result. It only lives for a
1522
+ // single call. If other functions become expensive, we can add them as well.
1523
+ const cache = new Map();
1524
+ const mergedOptions = {
1525
+ platform,
1526
+ ...options
1527
+ };
1528
+ const platformWithCache = {
1529
+ ...mergedOptions.platform,
1530
+ _c: cache
1531
+ };
1532
+ return computePosition$1(reference, floating, {
1533
+ ...mergedOptions,
1534
+ platform: platformWithCache
1535
+ });
1536
+ };
1537
+
1538
+ exports.autoUpdate = autoUpdate;
1539
+ exports.computePosition = computePosition;
1540
+ exports.flip = flip;
1541
+ exports.offset = offset;
1542
+ exports.shift = shift;