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