@swisspost/design-system-components 10.0.0-next.47 → 10.0.0-next.49

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 (317) hide show
  1. package/dist/cjs/{event-from-AKK8RQrn.js → event-from-C6kpQwhw.js} +2 -2
  2. package/dist/cjs/index-CpDyH7Ww.js +4 -4
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{package-wsZ6ig4j.js → package-CR0YynRY.js} +1 -1
  5. package/dist/cjs/post-accordion_2.cjs.entry.js +6 -6
  6. package/dist/cjs/post-avatar.cjs.entry.js +107 -80
  7. package/dist/cjs/post-back-to-top.cjs.entry.js +2 -2
  8. package/dist/cjs/post-banner.cjs.entry.js +3 -3
  9. package/dist/cjs/post-breadcrumb-item_2.cjs.entry.js +3 -3
  10. package/dist/cjs/post-breadcrumbs.cjs.entry.js +4 -4
  11. package/dist/cjs/post-card-control.cjs.entry.js +4 -4
  12. package/dist/cjs/post-closebutton_15.cjs.entry.js +133 -74
  13. package/dist/cjs/post-collapsible_2.cjs.entry.js +4 -4
  14. package/dist/cjs/post-components.cjs.js +1 -1
  15. package/dist/cjs/post-footer.cjs.entry.js +3 -3
  16. package/dist/cjs/post-linkarea.cjs.entry.js +19 -8
  17. package/dist/cjs/post-popover.cjs.entry.js +3 -3
  18. package/dist/cjs/post-rating.cjs.entry.js +3 -3
  19. package/dist/cjs/post-tab-header.cjs.entry.js +3 -3
  20. package/dist/cjs/post-tab-panel.cjs.entry.js +2 -2
  21. package/dist/cjs/post-tabs.cjs.entry.js +2 -2
  22. package/dist/cjs/post-tooltip-trigger.cjs.entry.js +2 -2
  23. package/dist/cjs/post-tooltip.cjs.entry.js +3 -3
  24. package/dist/collection/animations/pop-in.js +14 -0
  25. package/dist/collection/components/post-accordion/post-accordion.css +1 -1
  26. package/dist/collection/components/post-accordion-item/post-accordion-item.css +1 -1
  27. package/dist/collection/components/post-accordion-item/post-accordion-item.js +5 -5
  28. package/dist/collection/components/post-avatar/avatar-utils.js +16 -0
  29. package/dist/collection/components/post-avatar/post-avatar.css +1 -1
  30. package/dist/collection/components/post-avatar/post-avatar.js +119 -82
  31. package/dist/collection/components/post-back-to-top/post-back-to-top.js +1 -1
  32. package/dist/collection/components/post-banner/post-banner.js +2 -2
  33. package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.js +1 -1
  34. package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.css +1 -1
  35. package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.js +2 -2
  36. package/dist/collection/components/post-card-control/post-card-control.css +1 -1
  37. package/dist/collection/components/post-card-control/post-card-control.js +2 -2
  38. package/dist/collection/components/post-closebutton/post-closebutton.js +1 -19
  39. package/dist/collection/components/post-collapsible/post-collapsible.js +1 -1
  40. package/dist/collection/components/post-collapsible-trigger/post-collapsible-trigger.js +1 -1
  41. package/dist/collection/components/post-footer/post-footer.css +1 -1
  42. package/dist/collection/components/post-footer/post-footer.js +1 -1
  43. package/dist/collection/components/post-header/post-header.css +1 -1
  44. package/dist/collection/components/post-header/post-header.js +11 -2
  45. package/dist/collection/components/post-icon/post-icon.js +39 -33
  46. package/dist/collection/components/post-language-option/post-language-option.css +1 -1
  47. package/dist/collection/components/post-language-option/post-language-option.js +1 -2
  48. package/dist/collection/components/post-language-switch/post-language-switch.js +1 -2
  49. package/dist/collection/components/post-linkarea/post-linkarea.css +1 -1
  50. package/dist/collection/components/post-linkarea/post-linkarea.js +24 -6
  51. package/dist/collection/components/post-list/post-list.css +1 -1
  52. package/dist/collection/components/post-list/post-list.js +1 -1
  53. package/dist/collection/components/post-list-item/post-list-item.js +1 -1
  54. package/dist/collection/components/post-logo/post-logo.js +1 -1
  55. package/dist/collection/components/post-mainnavigation/post-mainnavigation.css +1 -1
  56. package/dist/collection/components/post-mainnavigation/post-mainnavigation.js +1 -1
  57. package/dist/collection/components/post-megadropdown/post-megadropdown.css +1 -1
  58. package/dist/collection/components/post-megadropdown/post-megadropdown.js +12 -2
  59. package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.js +1 -1
  60. package/dist/collection/components/post-menu/post-menu.css +1 -1
  61. package/dist/collection/components/post-menu/post-menu.js +41 -5
  62. package/dist/collection/components/post-menu-item/post-menu-item.js +1 -1
  63. package/dist/collection/components/post-menu-trigger/post-menu-trigger.js +1 -1
  64. package/dist/collection/components/post-popover/post-popover.css +1 -1
  65. package/dist/collection/components/post-popover/post-popover.js +1 -1
  66. package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -1
  67. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +18 -7
  68. package/dist/collection/components/post-rating/post-rating.css +1 -1
  69. package/dist/collection/components/post-rating/post-rating.js +1 -1
  70. package/dist/collection/components/post-tab-header/post-tab-header.css +1 -1
  71. package/dist/collection/components/post-tab-header/post-tab-header.js +1 -1
  72. package/dist/collection/components/post-tab-panel/post-tab-panel.js +1 -1
  73. package/dist/collection/components/post-tabs/post-tabs.js +3 -3
  74. package/dist/collection/components/post-togglebutton/post-togglebutton.js +1 -1
  75. package/dist/collection/components/post-tooltip/post-tooltip.js +2 -2
  76. package/dist/collection/components/post-tooltip-trigger/post-tooltip-trigger.js +1 -1
  77. package/dist/collection/utils/event-from.js +2 -2
  78. package/dist/component-names.json +39 -0
  79. package/dist/{esm/event-from-8U5GFtQP.js → components/event-from.js} +2 -2
  80. package/dist/components/get-root.js +15 -0
  81. package/dist/components/index.d.ts +73 -0
  82. package/dist/components/index.js +36 -2315
  83. package/dist/components/package.js +3 -0
  84. package/dist/components/post-accordion-item.js +1 -1
  85. package/dist/components/post-accordion-item2.js +113 -0
  86. package/dist/components/post-accordion.js +1 -1
  87. package/dist/components/post-accordion2.js +138 -0
  88. package/dist/components/post-avatar.js +117 -88
  89. package/dist/components/post-back-to-top.js +7 -8
  90. package/dist/components/post-banner.js +10 -11
  91. package/dist/components/post-breadcrumb-item.js +1 -1
  92. package/dist/components/post-breadcrumb-item2.js +79 -0
  93. package/dist/components/post-breadcrumbs.js +16 -17
  94. package/dist/components/post-card-control.js +11 -12
  95. package/dist/components/post-closebutton.js +5 -7
  96. package/dist/components/post-collapsible-trigger.js +1 -1
  97. package/dist/components/post-collapsible-trigger2.js +135 -0
  98. package/dist/components/post-collapsible.js +1 -1
  99. package/dist/components/post-collapsible2.js +110 -0
  100. package/dist/components/post-footer.js +12 -13
  101. package/dist/components/post-header.js +18 -10
  102. package/dist/components/post-icon.js +1 -1
  103. package/dist/components/post-icon2.js +159 -0
  104. package/dist/components/post-language-option.js +10 -12
  105. package/dist/components/post-language-switch.js +13 -15
  106. package/dist/components/post-linkarea.js +24 -12
  107. package/dist/components/post-list-item.js +4 -5
  108. package/dist/components/post-list.js +6 -7
  109. package/dist/components/post-logo.js +6 -7
  110. package/dist/components/post-mainnavigation.js +6 -7
  111. package/dist/components/post-megadropdown-trigger.js +7 -8
  112. package/dist/components/post-megadropdown.js +20 -11
  113. package/dist/components/post-menu-item.js +1 -1
  114. package/dist/components/post-menu-item2.js +30 -0
  115. package/dist/components/post-menu-trigger.js +1 -1
  116. package/dist/components/post-menu-trigger2.js +110 -0
  117. package/dist/components/post-menu.js +1 -1
  118. package/dist/components/post-menu2.js +237 -0
  119. package/dist/components/post-popover.js +8 -9
  120. package/dist/components/post-popovercontainer.js +1 -1
  121. package/dist/components/post-popovercontainer2.js +3043 -0
  122. package/dist/components/post-rating.js +10 -11
  123. package/dist/components/post-tab-header.js +8 -9
  124. package/dist/components/post-tab-panel.js +7 -8
  125. package/dist/components/post-tabs.js +7 -8
  126. package/dist/components/post-togglebutton.js +4 -5
  127. package/dist/components/post-tooltip-trigger.js +7 -8
  128. package/dist/components/post-tooltip.js +8 -9
  129. package/dist/components/react/index.d.ts +33 -0
  130. package/dist/components/react/index.js +2315 -0
  131. package/dist/components/{p-Cxrx7SXz.js → react/p-Amg0f2Yo.js} +40 -34
  132. package/dist/components/{p-C0H2ohSv.js → react/p-B6vPT8S3.js} +3 -3
  133. package/dist/components/{p-336Lbkey.js → react/p-BDs0pvkX.js} +2 -2
  134. package/dist/components/react/p-BLchVpF6.js +14 -0
  135. package/dist/components/{p-BM8mtEfS.js → react/p-BMdFdJWl.js} +2 -2
  136. package/dist/components/{p-DP5pj8mq.js → react/p-BS0ZqwA-.js} +31 -6
  137. package/dist/components/react/p-C35MCWIp.js +35 -0
  138. package/dist/components/react/p-CJ80BZ06.js +178 -0
  139. package/dist/{esm/index-BWC0gtGU.js → components/react/p-CV7fm1rW.js} +1 -1
  140. package/dist/components/react/p-C_2k3G1c.js +264 -0
  141. package/dist/components/{p-DVGX_JCp.js → react/p-D1oOccKr.js} +3 -3
  142. package/dist/components/{p-pHxypsHK.js → react/p-D50E7y6E.js} +24 -9
  143. package/dist/components/react/p-DO48NanC.js +3 -0
  144. package/dist/components/{p-i0-mizzM.js → react/p-DOo9tmN-.js} +2 -2
  145. package/dist/components/{p-DEi5TIMq.js → react/p-Do9awHW7.js} +3 -3
  146. package/dist/components/react/p-SbIC4aZX.js +11 -0
  147. package/dist/components/{p-8U5GFtQP.js → react/p-kraHE1r3.js} +2 -2
  148. package/dist/components/react/p-r4txK0AC.js +3 -0
  149. package/dist/components/{p-BSvy4uym.js → react/p-xelWyg_P.js} +8 -8
  150. package/dist/components/react/post-accordion-item.d.ts +11 -0
  151. package/dist/components/react/post-accordion-item.js +6 -0
  152. package/dist/components/react/post-accordion.d.ts +11 -0
  153. package/dist/components/react/post-accordion.js +6 -0
  154. package/dist/components/react/post-avatar.d.ts +11 -0
  155. package/dist/components/react/post-avatar.js +218 -0
  156. package/dist/components/react/post-back-to-top.d.ts +11 -0
  157. package/dist/components/react/post-back-to-top.js +145 -0
  158. package/dist/components/react/post-banner.d.ts +11 -0
  159. package/dist/components/react/post-banner.js +99 -0
  160. package/dist/components/react/post-breadcrumb-item.d.ts +11 -0
  161. package/dist/components/react/post-breadcrumb-item.js +6 -0
  162. package/dist/components/react/post-breadcrumbs.d.ts +11 -0
  163. package/dist/components/react/post-breadcrumbs.js +187 -0
  164. package/dist/components/react/post-card-control.d.ts +11 -0
  165. package/dist/components/react/post-card-control.js +327 -0
  166. package/dist/components/react/post-closebutton.d.ts +11 -0
  167. package/dist/components/react/post-closebutton.js +50 -0
  168. package/dist/components/react/post-collapsible-trigger.d.ts +11 -0
  169. package/dist/components/react/post-collapsible-trigger.js +6 -0
  170. package/dist/components/react/post-collapsible.d.ts +11 -0
  171. package/dist/components/react/post-collapsible.js +6 -0
  172. package/dist/components/react/post-footer.d.ts +11 -0
  173. package/dist/components/react/post-footer.js +117 -0
  174. package/dist/components/react/post-header.d.ts +11 -0
  175. package/dist/components/react/post-header.js +342 -0
  176. package/dist/components/react/post-icon.d.ts +11 -0
  177. package/dist/components/react/post-icon.js +6 -0
  178. package/dist/components/react/post-language-option.d.ts +11 -0
  179. package/dist/components/react/post-language-option.js +100 -0
  180. package/dist/components/react/post-language-switch.d.ts +11 -0
  181. package/dist/components/react/post-language-switch.js +158 -0
  182. package/dist/components/react/post-linkarea.d.ts +11 -0
  183. package/dist/components/react/post-linkarea.js +59 -0
  184. package/dist/components/react/post-list-item.d.ts +11 -0
  185. package/dist/components/react/post-list-item.js +39 -0
  186. package/dist/components/react/post-list.d.ts +11 -0
  187. package/dist/components/react/post-list.js +62 -0
  188. package/dist/components/react/post-logo.d.ts +11 -0
  189. package/dist/components/react/post-logo.js +59 -0
  190. package/dist/components/react/post-mainnavigation.d.ts +11 -0
  191. package/dist/components/react/post-mainnavigation.js +181 -0
  192. package/dist/components/react/post-megadropdown-trigger.d.ts +11 -0
  193. package/dist/components/react/post-megadropdown-trigger.js +137 -0
  194. package/dist/components/react/post-megadropdown.d.ts +11 -0
  195. package/dist/components/react/post-megadropdown.js +207 -0
  196. package/dist/components/react/post-menu-item.d.ts +11 -0
  197. package/dist/components/react/post-menu-item.js +6 -0
  198. package/dist/components/react/post-menu-trigger.d.ts +11 -0
  199. package/dist/components/react/post-menu-trigger.js +6 -0
  200. package/dist/components/react/post-menu.d.ts +11 -0
  201. package/dist/components/react/post-menu.js +6 -0
  202. package/dist/components/react/post-popover.d.ts +11 -0
  203. package/dist/components/react/post-popover.js +189 -0
  204. package/dist/components/react/post-popovercontainer.d.ts +11 -0
  205. package/dist/components/react/post-popovercontainer.js +6 -0
  206. package/dist/components/react/post-rating.d.ts +11 -0
  207. package/dist/components/react/post-rating.js +153 -0
  208. package/dist/components/react/post-tab-header.d.ts +11 -0
  209. package/dist/components/react/post-tab-header.js +53 -0
  210. package/dist/components/react/post-tab-panel.d.ts +11 -0
  211. package/dist/components/react/post-tab-panel.js +55 -0
  212. package/dist/components/react/post-tabs.d.ts +11 -0
  213. package/dist/components/react/post-tabs.js +197 -0
  214. package/dist/components/react/post-togglebutton.d.ts +11 -0
  215. package/dist/components/react/post-togglebutton.js +57 -0
  216. package/dist/components/react/post-tooltip-trigger.d.ts +11 -0
  217. package/dist/components/react/post-tooltip-trigger.js +5223 -0
  218. package/dist/components/react/post-tooltip.d.ts +11 -0
  219. package/dist/components/react/post-tooltip.js +115 -0
  220. package/dist/components/switch-variants.js +3 -0
  221. package/dist/docs.json +71 -35
  222. package/dist/esm/event-from-kraHE1r3.js +105 -0
  223. package/dist/esm/index-C8a0ddDa.js +4 -4
  224. package/dist/esm/index-VmK3ABCB.js +88 -0
  225. package/dist/esm/loader.js +1 -1
  226. package/dist/esm/package-DO48NanC.js +3 -0
  227. package/dist/esm/post-accordion_2.entry.js +7 -7
  228. package/dist/esm/post-avatar.entry.js +108 -81
  229. package/dist/esm/post-back-to-top.entry.js +3 -3
  230. package/dist/esm/post-banner.entry.js +4 -4
  231. package/dist/esm/post-breadcrumb-item_2.entry.js +4 -4
  232. package/dist/esm/post-breadcrumbs.entry.js +5 -5
  233. package/dist/esm/post-card-control.entry.js +5 -5
  234. package/dist/esm/post-closebutton_15.entry.js +135 -76
  235. package/dist/esm/post-collapsible_2.entry.js +5 -5
  236. package/dist/esm/post-components.js +1 -1
  237. package/dist/esm/post-footer.entry.js +4 -4
  238. package/dist/esm/post-linkarea.entry.js +19 -8
  239. package/dist/esm/post-popover.entry.js +4 -4
  240. package/dist/esm/post-rating.entry.js +4 -4
  241. package/dist/esm/post-tab-header.entry.js +4 -4
  242. package/dist/esm/post-tab-panel.entry.js +3 -3
  243. package/dist/esm/post-tabs.entry.js +2 -2
  244. package/dist/esm/post-tooltip-trigger.entry.js +3 -3
  245. package/dist/esm/post-tooltip.entry.js +4 -4
  246. package/dist/loader/cdn.js +1 -0
  247. package/dist/loader/index.cjs.js +1 -0
  248. package/{loader → dist/loader}/index.d.ts +1 -1
  249. package/dist/loader/index.es2017.js +1 -0
  250. package/{loader → dist/loader}/index.js +1 -1
  251. package/dist/post-components/p-01bc39c2.entry.js +1 -0
  252. package/dist/post-components/p-0dc1e940.entry.js +1 -0
  253. package/dist/post-components/p-16da91bc.entry.js +1 -0
  254. package/dist/post-components/p-26a04741.entry.js +1 -0
  255. package/dist/post-components/p-2f2f9b22.entry.js +1 -0
  256. package/dist/post-components/{p-45007aac.entry.js → p-33008981.entry.js} +1 -1
  257. package/dist/post-components/p-36358cd4.entry.js +1 -0
  258. package/dist/post-components/p-71c48d48.entry.js +1 -0
  259. package/dist/post-components/{p-e9802b56.entry.js → p-84395e1d.entry.js} +1 -1
  260. package/dist/post-components/p-848c10ac.entry.js +1 -0
  261. package/dist/post-components/{p-ab8017bb.entry.js → p-8d2e5814.entry.js} +1 -1
  262. package/dist/post-components/{p-a2fa5ce4.entry.js → p-9dbe6595.entry.js} +1 -1
  263. package/dist/post-components/p-DO48NanC.js +1 -0
  264. package/dist/post-components/{p-BWC0gtGU.js → p-VmK3ABCB.js} +1 -1
  265. package/dist/post-components/p-a982458f.entry.js +1 -0
  266. package/dist/post-components/{p-f67b616a.entry.js → p-b0aaa058.entry.js} +1 -1
  267. package/dist/post-components/{p-bbe02ba3.entry.js → p-bdeef760.entry.js} +1 -1
  268. package/dist/post-components/{p-2f698af4.entry.js → p-d221395c.entry.js} +1 -1
  269. package/dist/post-components/{p-57703aee.entry.js → p-e49aa78e.entry.js} +1 -1
  270. package/dist/post-components/p-eb405167.entry.js +1 -0
  271. package/dist/post-components/p-kraHE1r3.js +1 -0
  272. package/dist/post-components/post-components.esm.js +1 -1
  273. package/dist/types/animations/pop-in.d.ts +1 -0
  274. package/dist/types/components/post-accordion-item/post-accordion-item.d.ts +3 -3
  275. package/dist/types/components/post-avatar/avatar-utils.d.ts +3 -0
  276. package/dist/types/components/post-avatar/post-avatar.d.ts +17 -13
  277. package/dist/types/components/post-closebutton/post-closebutton.d.ts +0 -6
  278. package/dist/types/components/post-header/post-header.d.ts +2 -0
  279. package/dist/types/components/post-icon/post-icon.d.ts +11 -0
  280. package/dist/types/components/post-linkarea/post-linkarea.d.ts +6 -0
  281. package/dist/types/components/post-megadropdown/post-megadropdown.d.ts +2 -1
  282. package/dist/types/components/post-menu/post-menu.d.ts +7 -0
  283. package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +6 -2
  284. package/dist/types/components/post-tabs/post-tabs.d.ts +2 -2
  285. package/dist/types/components.d.ts +19 -22
  286. package/dist/types/utils/component-on-ready.d.ts +2 -2
  287. package/hydrate/index.js +308 -201
  288. package/hydrate/index.mjs +308 -201
  289. package/package.json +24 -12
  290. package/dist/components/p-Z01QMrov.js +0 -3
  291. package/dist/esm/package-Z01QMrov.js +0 -3
  292. package/dist/post-components/p-031f7489.entry.js +0 -1
  293. package/dist/post-components/p-1e6a068a.entry.js +0 -1
  294. package/dist/post-components/p-2ca196d6.entry.js +0 -1
  295. package/dist/post-components/p-3adbdda7.entry.js +0 -1
  296. package/dist/post-components/p-7b8ab026.entry.js +0 -1
  297. package/dist/post-components/p-8U5GFtQP.js +0 -1
  298. package/dist/post-components/p-9428231b.entry.js +0 -1
  299. package/dist/post-components/p-Z01QMrov.js +0 -1
  300. package/dist/post-components/p-ac73ab00.entry.js +0 -1
  301. package/dist/post-components/p-c1cf39cb.entry.js +0 -1
  302. package/dist/post-components/p-d0d92071.entry.js +0 -1
  303. package/dist/post-components/p-e96239c4.entry.js +0 -1
  304. package/dist/prebuild.js +0 -26
  305. package/dist/types/home/runner/work/design-system/design-system/packages/components/.stencil/prebuild.d.ts +0 -1
  306. package/loader/cdn.js +0 -1
  307. package/loader/index.cjs.js +0 -1
  308. package/loader/index.es2017.js +0 -1
  309. /package/dist/components/{p-CJ80BZ06.js → breakpoints.js} +0 -0
  310. /package/dist/components/{p-SbIC4aZX.js → fade.js} +0 -0
  311. /package/dist/components/{p-C35MCWIp.js → get-focusable-children.js} +0 -0
  312. /package/dist/components/{p-r4txK0AC.js → heading-levels.js} +0 -0
  313. /package/dist/components/{p-BLchVpF6.js → index.browser.js} +0 -0
  314. /package/dist/components/{p-CV7fm1rW.js → index2.js} +0 -0
  315. /package/dist/components/{p-C_2k3G1c.js → long-press-event.js} +0 -0
  316. /package/dist/components/{p-CBFgkSgY.js → react/p-CBFgkSgY.js} +0 -0
  317. /package/dist/components/{p-DjIHLduJ.js → react/p-DjIHLduJ.js} +0 -0
@@ -0,0 +1,3043 @@
1
+ import { proxyCustomElement, HTMLElement as HTMLElement$1, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { I as IS_BROWSER } from './breakpoints.js';
3
+ import { d as checkEmptyOrOneOf, e as checkEmptyOrType } from './index2.js';
4
+ import { v as version } from './package.js';
5
+
6
+ const PLACEMENT_TYPES = [
7
+ 'top',
8
+ 'right',
9
+ 'bottom',
10
+ 'left',
11
+ 'top-start',
12
+ 'top-end',
13
+ 'right-start',
14
+ 'right-end',
15
+ 'bottom-start',
16
+ 'bottom-end',
17
+ 'left-start',
18
+ 'left-end',
19
+ ];
20
+
21
+ /**
22
+ * Custom positioning reference element.
23
+ * @see https://floating-ui.com/docs/virtual-elements
24
+ */
25
+
26
+ const min = Math.min;
27
+ const max = Math.max;
28
+ const round = Math.round;
29
+ const floor = Math.floor;
30
+ const createCoords = v => ({
31
+ x: v,
32
+ y: v
33
+ });
34
+ const oppositeSideMap = {
35
+ left: 'right',
36
+ right: 'left',
37
+ bottom: 'top',
38
+ top: 'bottom'
39
+ };
40
+ const oppositeAlignmentMap = {
41
+ start: 'end',
42
+ end: 'start'
43
+ };
44
+ function clamp(start, value, end) {
45
+ return max(start, min(value, end));
46
+ }
47
+ function evaluate(value, param) {
48
+ return typeof value === 'function' ? value(param) : value;
49
+ }
50
+ function getSide(placement) {
51
+ return placement.split('-')[0];
52
+ }
53
+ function getAlignment(placement) {
54
+ return placement.split('-')[1];
55
+ }
56
+ function getOppositeAxis(axis) {
57
+ return axis === 'x' ? 'y' : 'x';
58
+ }
59
+ function getAxisLength(axis) {
60
+ return axis === 'y' ? 'height' : 'width';
61
+ }
62
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
63
+ function getSideAxis(placement) {
64
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
65
+ }
66
+ function getAlignmentAxis(placement) {
67
+ return getOppositeAxis(getSideAxis(placement));
68
+ }
69
+ function getAlignmentSides(placement, rects, rtl) {
70
+ if (rtl === void 0) {
71
+ rtl = false;
72
+ }
73
+ const alignment = getAlignment(placement);
74
+ const alignmentAxis = getAlignmentAxis(placement);
75
+ const length = getAxisLength(alignmentAxis);
76
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
77
+ if (rects.reference[length] > rects.floating[length]) {
78
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
79
+ }
80
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
81
+ }
82
+ function getExpandedPlacements(placement) {
83
+ const oppositePlacement = getOppositePlacement(placement);
84
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
85
+ }
86
+ function getOppositeAlignmentPlacement(placement) {
87
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
88
+ }
89
+ const lrPlacement = ['left', 'right'];
90
+ const rlPlacement = ['right', 'left'];
91
+ const tbPlacement = ['top', 'bottom'];
92
+ const btPlacement = ['bottom', 'top'];
93
+ function getSideList(side, isStart, rtl) {
94
+ switch (side) {
95
+ case 'top':
96
+ case 'bottom':
97
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
98
+ return isStart ? lrPlacement : rlPlacement;
99
+ case 'left':
100
+ case 'right':
101
+ return isStart ? tbPlacement : btPlacement;
102
+ default:
103
+ return [];
104
+ }
105
+ }
106
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
107
+ const alignment = getAlignment(placement);
108
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
109
+ if (alignment) {
110
+ list = list.map(side => side + "-" + alignment);
111
+ if (flipAlignment) {
112
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
113
+ }
114
+ }
115
+ return list;
116
+ }
117
+ function getOppositePlacement(placement) {
118
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
119
+ }
120
+ function expandPaddingObject(padding) {
121
+ return {
122
+ top: 0,
123
+ right: 0,
124
+ bottom: 0,
125
+ left: 0,
126
+ ...padding
127
+ };
128
+ }
129
+ function getPaddingObject(padding) {
130
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
131
+ top: padding,
132
+ right: padding,
133
+ bottom: padding,
134
+ left: padding
135
+ };
136
+ }
137
+ function rectToClientRect(rect) {
138
+ const {
139
+ x,
140
+ y,
141
+ width,
142
+ height
143
+ } = rect;
144
+ return {
145
+ width,
146
+ height,
147
+ top: y,
148
+ left: x,
149
+ right: x + width,
150
+ bottom: y + height,
151
+ x,
152
+ y
153
+ };
154
+ }
155
+
156
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
157
+ let {
158
+ reference,
159
+ floating
160
+ } = _ref;
161
+ const sideAxis = getSideAxis(placement);
162
+ const alignmentAxis = getAlignmentAxis(placement);
163
+ const alignLength = getAxisLength(alignmentAxis);
164
+ const side = getSide(placement);
165
+ const isVertical = sideAxis === 'y';
166
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
167
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
168
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
169
+ let coords;
170
+ switch (side) {
171
+ case 'top':
172
+ coords = {
173
+ x: commonX,
174
+ y: reference.y - floating.height
175
+ };
176
+ break;
177
+ case 'bottom':
178
+ coords = {
179
+ x: commonX,
180
+ y: reference.y + reference.height
181
+ };
182
+ break;
183
+ case 'right':
184
+ coords = {
185
+ x: reference.x + reference.width,
186
+ y: commonY
187
+ };
188
+ break;
189
+ case 'left':
190
+ coords = {
191
+ x: reference.x - floating.width,
192
+ y: commonY
193
+ };
194
+ break;
195
+ default:
196
+ coords = {
197
+ x: reference.x,
198
+ y: reference.y
199
+ };
200
+ }
201
+ switch (getAlignment(placement)) {
202
+ case 'start':
203
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
204
+ break;
205
+ case 'end':
206
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
207
+ break;
208
+ }
209
+ return coords;
210
+ }
211
+
212
+ /**
213
+ * Computes the `x` and `y` coordinates that will place the floating element
214
+ * next to a given reference element.
215
+ *
216
+ * This export does not have any `platform` interface logic. You will need to
217
+ * write one for the platform you are using Floating UI with.
218
+ */
219
+ const computePosition$1 = async (reference, floating, config) => {
220
+ const {
221
+ placement = 'bottom',
222
+ strategy = 'absolute',
223
+ middleware = [],
224
+ platform
225
+ } = config;
226
+ const validMiddleware = middleware.filter(Boolean);
227
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
228
+ let rects = await platform.getElementRects({
229
+ reference,
230
+ floating,
231
+ strategy
232
+ });
233
+ let {
234
+ x,
235
+ y
236
+ } = computeCoordsFromPlacement(rects, placement, rtl);
237
+ let statefulPlacement = placement;
238
+ let middlewareData = {};
239
+ let resetCount = 0;
240
+ for (let i = 0; i < validMiddleware.length; i++) {
241
+ const {
242
+ name,
243
+ fn
244
+ } = validMiddleware[i];
245
+ const {
246
+ x: nextX,
247
+ y: nextY,
248
+ data,
249
+ reset
250
+ } = await fn({
251
+ x,
252
+ y,
253
+ initialPlacement: placement,
254
+ placement: statefulPlacement,
255
+ strategy,
256
+ middlewareData,
257
+ rects,
258
+ platform,
259
+ elements: {
260
+ reference,
261
+ floating
262
+ }
263
+ });
264
+ x = nextX != null ? nextX : x;
265
+ y = nextY != null ? nextY : y;
266
+ middlewareData = {
267
+ ...middlewareData,
268
+ [name]: {
269
+ ...middlewareData[name],
270
+ ...data
271
+ }
272
+ };
273
+ if (reset && resetCount <= 50) {
274
+ resetCount++;
275
+ if (typeof reset === 'object') {
276
+ if (reset.placement) {
277
+ statefulPlacement = reset.placement;
278
+ }
279
+ if (reset.rects) {
280
+ rects = reset.rects === true ? await platform.getElementRects({
281
+ reference,
282
+ floating,
283
+ strategy
284
+ }) : reset.rects;
285
+ }
286
+ ({
287
+ x,
288
+ y
289
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
290
+ }
291
+ i = -1;
292
+ }
293
+ }
294
+ return {
295
+ x,
296
+ y,
297
+ placement: statefulPlacement,
298
+ strategy,
299
+ middlewareData
300
+ };
301
+ };
302
+
303
+ /**
304
+ * Resolves with an object of overflow side offsets that determine how much the
305
+ * element is overflowing a given clipping boundary on each side.
306
+ * - positive = overflowing the boundary by that number of pixels
307
+ * - negative = how many pixels left before it will overflow
308
+ * - 0 = lies flush with the boundary
309
+ * @see https://floating-ui.com/docs/detectOverflow
310
+ */
311
+ async function detectOverflow(state, options) {
312
+ var _await$platform$isEle;
313
+ if (options === void 0) {
314
+ options = {};
315
+ }
316
+ const {
317
+ x,
318
+ y,
319
+ platform,
320
+ rects,
321
+ elements,
322
+ strategy
323
+ } = state;
324
+ const {
325
+ boundary = 'clippingAncestors',
326
+ rootBoundary = 'viewport',
327
+ elementContext = 'floating',
328
+ altBoundary = false,
329
+ padding = 0
330
+ } = evaluate(options, state);
331
+ const paddingObject = getPaddingObject(padding);
332
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
333
+ const element = elements[altBoundary ? altContext : elementContext];
334
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
335
+ 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))),
336
+ boundary,
337
+ rootBoundary,
338
+ strategy
339
+ }));
340
+ const rect = elementContext === 'floating' ? {
341
+ x,
342
+ y,
343
+ width: rects.floating.width,
344
+ height: rects.floating.height
345
+ } : rects.reference;
346
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
347
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
348
+ x: 1,
349
+ y: 1
350
+ } : {
351
+ x: 1,
352
+ y: 1
353
+ };
354
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
355
+ elements,
356
+ rect,
357
+ offsetParent,
358
+ strategy
359
+ }) : rect);
360
+ return {
361
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
362
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
363
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
364
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
365
+ };
366
+ }
367
+
368
+ /**
369
+ * Provides data to position an inner element of the floating element so that it
370
+ * appears centered to the reference element.
371
+ * @see https://floating-ui.com/docs/arrow
372
+ */
373
+ const arrow$1 = options => ({
374
+ name: 'arrow',
375
+ options,
376
+ async fn(state) {
377
+ const {
378
+ x,
379
+ y,
380
+ placement,
381
+ rects,
382
+ platform,
383
+ elements,
384
+ middlewareData
385
+ } = state;
386
+ // Since `element` is required, we don't Partial<> the type.
387
+ const {
388
+ element,
389
+ padding = 0
390
+ } = evaluate(options, state) || {};
391
+ if (element == null) {
392
+ return {};
393
+ }
394
+ const paddingObject = getPaddingObject(padding);
395
+ const coords = {
396
+ x,
397
+ y
398
+ };
399
+ const axis = getAlignmentAxis(placement);
400
+ const length = getAxisLength(axis);
401
+ const arrowDimensions = await platform.getDimensions(element);
402
+ const isYAxis = axis === 'y';
403
+ const minProp = isYAxis ? 'top' : 'left';
404
+ const maxProp = isYAxis ? 'bottom' : 'right';
405
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
406
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
407
+ const startDiff = coords[axis] - rects.reference[axis];
408
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
409
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
410
+
411
+ // DOM platform can return `window` as the `offsetParent`.
412
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
413
+ clientSize = elements.floating[clientProp] || rects.floating[length];
414
+ }
415
+ const centerToReference = endDiff / 2 - startDiff / 2;
416
+
417
+ // If the padding is large enough that it causes the arrow to no longer be
418
+ // centered, modify the padding so that it is centered.
419
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
420
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
421
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
422
+
423
+ // Make sure the arrow doesn't overflow the floating element if the center
424
+ // point is outside the floating element's bounds.
425
+ const min$1 = minPadding;
426
+ const max = clientSize - arrowDimensions[length] - maxPadding;
427
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
428
+ const offset = clamp(min$1, center, max);
429
+
430
+ // If the reference is small enough that the arrow's padding causes it to
431
+ // to point to nothing for an aligned placement, adjust the offset of the
432
+ // floating element itself. To ensure `shift()` continues to take action,
433
+ // a single reset is performed when this is true.
434
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
435
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
436
+ return {
437
+ [axis]: coords[axis] + alignmentOffset,
438
+ data: {
439
+ [axis]: offset,
440
+ centerOffset: center - offset - alignmentOffset,
441
+ ...(shouldAddOffset && {
442
+ alignmentOffset
443
+ })
444
+ },
445
+ reset: shouldAddOffset
446
+ };
447
+ }
448
+ });
449
+
450
+ /**
451
+ * Optimizes the visibility of the floating element by flipping the `placement`
452
+ * in order to keep it in view when the preferred placement(s) will overflow the
453
+ * clipping boundary. Alternative to `autoPlacement`.
454
+ * @see https://floating-ui.com/docs/flip
455
+ */
456
+ const flip$1 = function (options) {
457
+ if (options === void 0) {
458
+ options = {};
459
+ }
460
+ return {
461
+ name: 'flip',
462
+ options,
463
+ async fn(state) {
464
+ var _middlewareData$arrow, _middlewareData$flip;
465
+ const {
466
+ placement,
467
+ middlewareData,
468
+ rects,
469
+ initialPlacement,
470
+ platform,
471
+ elements
472
+ } = state;
473
+ const {
474
+ mainAxis: checkMainAxis = true,
475
+ crossAxis: checkCrossAxis = true,
476
+ fallbackPlacements: specifiedFallbackPlacements,
477
+ fallbackStrategy = 'bestFit',
478
+ fallbackAxisSideDirection = 'none',
479
+ flipAlignment = true,
480
+ ...detectOverflowOptions
481
+ } = evaluate(options, state);
482
+
483
+ // If a reset by the arrow was caused due to an alignment offset being
484
+ // added, we should skip any logic now since `flip()` has already done its
485
+ // work.
486
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
487
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
488
+ return {};
489
+ }
490
+ const side = getSide(placement);
491
+ const initialSideAxis = getSideAxis(initialPlacement);
492
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
493
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
494
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
495
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
496
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
497
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
498
+ }
499
+ const placements = [initialPlacement, ...fallbackPlacements];
500
+ const overflow = await detectOverflow(state, detectOverflowOptions);
501
+ const overflows = [];
502
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
503
+ if (checkMainAxis) {
504
+ overflows.push(overflow[side]);
505
+ }
506
+ if (checkCrossAxis) {
507
+ const sides = getAlignmentSides(placement, rects, rtl);
508
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
509
+ }
510
+ overflowsData = [...overflowsData, {
511
+ placement,
512
+ overflows
513
+ }];
514
+
515
+ // One or more sides is overflowing.
516
+ if (!overflows.every(side => side <= 0)) {
517
+ var _middlewareData$flip2, _overflowsData$filter;
518
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
519
+ const nextPlacement = placements[nextIndex];
520
+ if (nextPlacement) {
521
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
522
+ if (!ignoreCrossAxisOverflow ||
523
+ // We leave the current main axis only if every placement on that axis
524
+ // overflows the main axis.
525
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
526
+ // Try next placement and re-run the lifecycle.
527
+ return {
528
+ data: {
529
+ index: nextIndex,
530
+ overflows: overflowsData
531
+ },
532
+ reset: {
533
+ placement: nextPlacement
534
+ }
535
+ };
536
+ }
537
+ }
538
+
539
+ // First, find the candidates that fit on the mainAxis side of overflow,
540
+ // then find the placement that fits the best on the main crossAxis side.
541
+ 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;
542
+
543
+ // Otherwise fallback.
544
+ if (!resetPlacement) {
545
+ switch (fallbackStrategy) {
546
+ case 'bestFit':
547
+ {
548
+ var _overflowsData$filter2;
549
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
550
+ if (hasFallbackAxisSideDirection) {
551
+ const currentSideAxis = getSideAxis(d.placement);
552
+ return currentSideAxis === initialSideAxis ||
553
+ // Create a bias to the `y` side axis due to horizontal
554
+ // reading directions favoring greater width.
555
+ currentSideAxis === 'y';
556
+ }
557
+ return true;
558
+ }).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];
559
+ if (placement) {
560
+ resetPlacement = placement;
561
+ }
562
+ break;
563
+ }
564
+ case 'initialPlacement':
565
+ resetPlacement = initialPlacement;
566
+ break;
567
+ }
568
+ }
569
+ if (placement !== resetPlacement) {
570
+ return {
571
+ reset: {
572
+ placement: resetPlacement
573
+ }
574
+ };
575
+ }
576
+ }
577
+ return {};
578
+ }
579
+ };
580
+ };
581
+
582
+ function getBoundingRect(rects) {
583
+ const minX = min(...rects.map(rect => rect.left));
584
+ const minY = min(...rects.map(rect => rect.top));
585
+ const maxX = max(...rects.map(rect => rect.right));
586
+ const maxY = max(...rects.map(rect => rect.bottom));
587
+ return {
588
+ x: minX,
589
+ y: minY,
590
+ width: maxX - minX,
591
+ height: maxY - minY
592
+ };
593
+ }
594
+ function getRectsByLine(rects) {
595
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
596
+ const groups = [];
597
+ let prevRect = null;
598
+ for (let i = 0; i < sortedRects.length; i++) {
599
+ const rect = sortedRects[i];
600
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
601
+ groups.push([rect]);
602
+ } else {
603
+ groups[groups.length - 1].push(rect);
604
+ }
605
+ prevRect = rect;
606
+ }
607
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
608
+ }
609
+ /**
610
+ * Provides improved positioning for inline reference elements that can span
611
+ * over multiple lines, such as hyperlinks or range selections.
612
+ * @see https://floating-ui.com/docs/inline
613
+ */
614
+ const inline$1 = function (options) {
615
+ if (options === void 0) {
616
+ options = {};
617
+ }
618
+ return {
619
+ name: 'inline',
620
+ options,
621
+ async fn(state) {
622
+ const {
623
+ placement,
624
+ elements,
625
+ rects,
626
+ platform,
627
+ strategy
628
+ } = state;
629
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
630
+ // ClientRect's bounds, despite the event listener being triggered. A
631
+ // padding of 2 seems to handle this issue.
632
+ const {
633
+ padding = 2,
634
+ x,
635
+ y
636
+ } = evaluate(options, state);
637
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
638
+ const clientRects = getRectsByLine(nativeClientRects);
639
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
640
+ const paddingObject = getPaddingObject(padding);
641
+ function getBoundingClientRect() {
642
+ // There are two rects and they are disjoined.
643
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
644
+ // Find the first rect in which the point is fully inside.
645
+ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
646
+ }
647
+
648
+ // There are 2 or more connected rects.
649
+ if (clientRects.length >= 2) {
650
+ if (getSideAxis(placement) === 'y') {
651
+ const firstRect = clientRects[0];
652
+ const lastRect = clientRects[clientRects.length - 1];
653
+ const isTop = getSide(placement) === 'top';
654
+ const top = firstRect.top;
655
+ const bottom = lastRect.bottom;
656
+ const left = isTop ? firstRect.left : lastRect.left;
657
+ const right = isTop ? firstRect.right : lastRect.right;
658
+ const width = right - left;
659
+ const height = bottom - top;
660
+ return {
661
+ top,
662
+ bottom,
663
+ left,
664
+ right,
665
+ width,
666
+ height,
667
+ x: left,
668
+ y: top
669
+ };
670
+ }
671
+ const isLeftSide = getSide(placement) === 'left';
672
+ const maxRight = max(...clientRects.map(rect => rect.right));
673
+ const minLeft = min(...clientRects.map(rect => rect.left));
674
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
675
+ const top = measureRects[0].top;
676
+ const bottom = measureRects[measureRects.length - 1].bottom;
677
+ const left = minLeft;
678
+ const right = maxRight;
679
+ const width = right - left;
680
+ const height = bottom - top;
681
+ return {
682
+ top,
683
+ bottom,
684
+ left,
685
+ right,
686
+ width,
687
+ height,
688
+ x: left,
689
+ y: top
690
+ };
691
+ }
692
+ return fallback;
693
+ }
694
+ const resetRects = await platform.getElementRects({
695
+ reference: {
696
+ getBoundingClientRect
697
+ },
698
+ floating: elements.floating,
699
+ strategy
700
+ });
701
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
702
+ return {
703
+ reset: {
704
+ rects: resetRects
705
+ }
706
+ };
707
+ }
708
+ return {};
709
+ }
710
+ };
711
+ };
712
+
713
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
714
+
715
+ // For type backwards-compatibility, the `OffsetOptions` type was also
716
+ // Derivable.
717
+
718
+ async function convertValueToCoords(state, options) {
719
+ const {
720
+ placement,
721
+ platform,
722
+ elements
723
+ } = state;
724
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
725
+ const side = getSide(placement);
726
+ const alignment = getAlignment(placement);
727
+ const isVertical = getSideAxis(placement) === 'y';
728
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
729
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
730
+ const rawValue = evaluate(options, state);
731
+
732
+ // eslint-disable-next-line prefer-const
733
+ let {
734
+ mainAxis,
735
+ crossAxis,
736
+ alignmentAxis
737
+ } = typeof rawValue === 'number' ? {
738
+ mainAxis: rawValue,
739
+ crossAxis: 0,
740
+ alignmentAxis: null
741
+ } : {
742
+ mainAxis: rawValue.mainAxis || 0,
743
+ crossAxis: rawValue.crossAxis || 0,
744
+ alignmentAxis: rawValue.alignmentAxis
745
+ };
746
+ if (alignment && typeof alignmentAxis === 'number') {
747
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
748
+ }
749
+ return isVertical ? {
750
+ x: crossAxis * crossAxisMulti,
751
+ y: mainAxis * mainAxisMulti
752
+ } : {
753
+ x: mainAxis * mainAxisMulti,
754
+ y: crossAxis * crossAxisMulti
755
+ };
756
+ }
757
+
758
+ /**
759
+ * Modifies the placement by translating the floating element along the
760
+ * specified axes.
761
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
762
+ * object may be passed.
763
+ * @see https://floating-ui.com/docs/offset
764
+ */
765
+ const offset$1 = function (options) {
766
+ if (options === void 0) {
767
+ options = 0;
768
+ }
769
+ return {
770
+ name: 'offset',
771
+ options,
772
+ async fn(state) {
773
+ var _middlewareData$offse, _middlewareData$arrow;
774
+ const {
775
+ x,
776
+ y,
777
+ placement,
778
+ middlewareData
779
+ } = state;
780
+ const diffCoords = await convertValueToCoords(state, options);
781
+
782
+ // If the placement is the same and the arrow caused an alignment offset
783
+ // then we don't need to change the positioning coordinates.
784
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
785
+ return {};
786
+ }
787
+ return {
788
+ x: x + diffCoords.x,
789
+ y: y + diffCoords.y,
790
+ data: {
791
+ ...diffCoords,
792
+ placement
793
+ }
794
+ };
795
+ }
796
+ };
797
+ };
798
+
799
+ /**
800
+ * Optimizes the visibility of the floating element by shifting it in order to
801
+ * keep it in view when it will overflow the clipping boundary.
802
+ * @see https://floating-ui.com/docs/shift
803
+ */
804
+ const shift$1 = function (options) {
805
+ if (options === void 0) {
806
+ options = {};
807
+ }
808
+ return {
809
+ name: 'shift',
810
+ options,
811
+ async fn(state) {
812
+ const {
813
+ x,
814
+ y,
815
+ placement
816
+ } = state;
817
+ const {
818
+ mainAxis: checkMainAxis = true,
819
+ crossAxis: checkCrossAxis = false,
820
+ limiter = {
821
+ fn: _ref => {
822
+ let {
823
+ x,
824
+ y
825
+ } = _ref;
826
+ return {
827
+ x,
828
+ y
829
+ };
830
+ }
831
+ },
832
+ ...detectOverflowOptions
833
+ } = evaluate(options, state);
834
+ const coords = {
835
+ x,
836
+ y
837
+ };
838
+ const overflow = await detectOverflow(state, detectOverflowOptions);
839
+ const crossAxis = getSideAxis(getSide(placement));
840
+ const mainAxis = getOppositeAxis(crossAxis);
841
+ let mainAxisCoord = coords[mainAxis];
842
+ let crossAxisCoord = coords[crossAxis];
843
+ if (checkMainAxis) {
844
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
845
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
846
+ const min = mainAxisCoord + overflow[minSide];
847
+ const max = mainAxisCoord - overflow[maxSide];
848
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
849
+ }
850
+ if (checkCrossAxis) {
851
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
852
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
853
+ const min = crossAxisCoord + overflow[minSide];
854
+ const max = crossAxisCoord - overflow[maxSide];
855
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
856
+ }
857
+ const limitedCoords = limiter.fn({
858
+ ...state,
859
+ [mainAxis]: mainAxisCoord,
860
+ [crossAxis]: crossAxisCoord
861
+ });
862
+ return {
863
+ ...limitedCoords,
864
+ data: {
865
+ x: limitedCoords.x - x,
866
+ y: limitedCoords.y - y,
867
+ enabled: {
868
+ [mainAxis]: checkMainAxis,
869
+ [crossAxis]: checkCrossAxis
870
+ }
871
+ }
872
+ };
873
+ }
874
+ };
875
+ };
876
+ /**
877
+ * Built-in `limiter` that will stop `shift()` at a certain point.
878
+ */
879
+ const limitShift$1 = function (options) {
880
+ if (options === void 0) {
881
+ options = {};
882
+ }
883
+ return {
884
+ options,
885
+ fn(state) {
886
+ const {
887
+ x,
888
+ y,
889
+ placement,
890
+ rects,
891
+ middlewareData
892
+ } = state;
893
+ const {
894
+ offset = 0,
895
+ mainAxis: checkMainAxis = true,
896
+ crossAxis: checkCrossAxis = true
897
+ } = evaluate(options, state);
898
+ const coords = {
899
+ x,
900
+ y
901
+ };
902
+ const crossAxis = getSideAxis(placement);
903
+ const mainAxis = getOppositeAxis(crossAxis);
904
+ let mainAxisCoord = coords[mainAxis];
905
+ let crossAxisCoord = coords[crossAxis];
906
+ const rawOffset = evaluate(offset, state);
907
+ const computedOffset = typeof rawOffset === 'number' ? {
908
+ mainAxis: rawOffset,
909
+ crossAxis: 0
910
+ } : {
911
+ mainAxis: 0,
912
+ crossAxis: 0,
913
+ ...rawOffset
914
+ };
915
+ if (checkMainAxis) {
916
+ const len = mainAxis === 'y' ? 'height' : 'width';
917
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
918
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
919
+ if (mainAxisCoord < limitMin) {
920
+ mainAxisCoord = limitMin;
921
+ } else if (mainAxisCoord > limitMax) {
922
+ mainAxisCoord = limitMax;
923
+ }
924
+ }
925
+ if (checkCrossAxis) {
926
+ var _middlewareData$offse, _middlewareData$offse2;
927
+ const len = mainAxis === 'y' ? 'width' : 'height';
928
+ const isOriginSide = originSides.has(getSide(placement));
929
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
930
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
931
+ if (crossAxisCoord < limitMin) {
932
+ crossAxisCoord = limitMin;
933
+ } else if (crossAxisCoord > limitMax) {
934
+ crossAxisCoord = limitMax;
935
+ }
936
+ }
937
+ return {
938
+ [mainAxis]: mainAxisCoord,
939
+ [crossAxis]: crossAxisCoord
940
+ };
941
+ }
942
+ };
943
+ };
944
+
945
+ /**
946
+ * Provides data that allows you to change the size of the floating element —
947
+ * for instance, prevent it from overflowing the clipping boundary or match the
948
+ * width of the reference element.
949
+ * @see https://floating-ui.com/docs/size
950
+ */
951
+ const size$1 = function (options) {
952
+ if (options === void 0) {
953
+ options = {};
954
+ }
955
+ return {
956
+ name: 'size',
957
+ options,
958
+ async fn(state) {
959
+ var _state$middlewareData, _state$middlewareData2;
960
+ const {
961
+ placement,
962
+ rects,
963
+ platform,
964
+ elements
965
+ } = state;
966
+ const {
967
+ apply = () => {},
968
+ ...detectOverflowOptions
969
+ } = evaluate(options, state);
970
+ const overflow = await detectOverflow(state, detectOverflowOptions);
971
+ const side = getSide(placement);
972
+ const alignment = getAlignment(placement);
973
+ const isYAxis = getSideAxis(placement) === 'y';
974
+ const {
975
+ width,
976
+ height
977
+ } = rects.floating;
978
+ let heightSide;
979
+ let widthSide;
980
+ if (side === 'top' || side === 'bottom') {
981
+ heightSide = side;
982
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
983
+ } else {
984
+ widthSide = side;
985
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
986
+ }
987
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
988
+ const maximumClippingWidth = width - overflow.left - overflow.right;
989
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
990
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
991
+ const noShift = !state.middlewareData.shift;
992
+ let availableHeight = overflowAvailableHeight;
993
+ let availableWidth = overflowAvailableWidth;
994
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
995
+ availableWidth = maximumClippingWidth;
996
+ }
997
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
998
+ availableHeight = maximumClippingHeight;
999
+ }
1000
+ if (noShift && !alignment) {
1001
+ const xMin = max(overflow.left, 0);
1002
+ const xMax = max(overflow.right, 0);
1003
+ const yMin = max(overflow.top, 0);
1004
+ const yMax = max(overflow.bottom, 0);
1005
+ if (isYAxis) {
1006
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1007
+ } else {
1008
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1009
+ }
1010
+ }
1011
+ await apply({
1012
+ ...state,
1013
+ availableWidth,
1014
+ availableHeight
1015
+ });
1016
+ const nextDimensions = await platform.getDimensions(elements.floating);
1017
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1018
+ return {
1019
+ reset: {
1020
+ rects: true
1021
+ }
1022
+ };
1023
+ }
1024
+ return {};
1025
+ }
1026
+ };
1027
+ };
1028
+
1029
+ function hasWindow() {
1030
+ return typeof window !== 'undefined';
1031
+ }
1032
+ function getNodeName(node) {
1033
+ if (isNode(node)) {
1034
+ return (node.nodeName || '').toLowerCase();
1035
+ }
1036
+ // Mocked nodes in testing environments may not be instances of Node. By
1037
+ // returning `#document` an infinite loop won't occur.
1038
+ // https://github.com/floating-ui/floating-ui/issues/2317
1039
+ return '#document';
1040
+ }
1041
+ function getWindow(node) {
1042
+ var _node$ownerDocument;
1043
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1044
+ }
1045
+ function getDocumentElement(node) {
1046
+ var _ref;
1047
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1048
+ }
1049
+ function isNode(value) {
1050
+ if (!hasWindow()) {
1051
+ return false;
1052
+ }
1053
+ return value instanceof Node || value instanceof getWindow(value).Node;
1054
+ }
1055
+ function isElement(value) {
1056
+ if (!hasWindow()) {
1057
+ return false;
1058
+ }
1059
+ return value instanceof Element || value instanceof getWindow(value).Element;
1060
+ }
1061
+ function isHTMLElement(value) {
1062
+ if (!hasWindow()) {
1063
+ return false;
1064
+ }
1065
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1066
+ }
1067
+ function isShadowRoot(value) {
1068
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1069
+ return false;
1070
+ }
1071
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1072
+ }
1073
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
1074
+ function isOverflowElement(element) {
1075
+ const {
1076
+ overflow,
1077
+ overflowX,
1078
+ overflowY,
1079
+ display
1080
+ } = getComputedStyle$1(element);
1081
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
1082
+ }
1083
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
1084
+ function isTableElement(element) {
1085
+ return tableElements.has(getNodeName(element));
1086
+ }
1087
+ const topLayerSelectors = [':popover-open', ':modal'];
1088
+ function isTopLayer(element) {
1089
+ return topLayerSelectors.some(selector => {
1090
+ try {
1091
+ return element.matches(selector);
1092
+ } catch (_e) {
1093
+ return false;
1094
+ }
1095
+ });
1096
+ }
1097
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
1098
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
1099
+ const containValues = ['paint', 'layout', 'strict', 'content'];
1100
+ function isContainingBlock(elementOrCss) {
1101
+ const webkit = isWebKit();
1102
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
1103
+
1104
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1105
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
1106
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
1107
+ }
1108
+ function getContainingBlock(element) {
1109
+ let currentNode = getParentNode(element);
1110
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1111
+ if (isContainingBlock(currentNode)) {
1112
+ return currentNode;
1113
+ } else if (isTopLayer(currentNode)) {
1114
+ return null;
1115
+ }
1116
+ currentNode = getParentNode(currentNode);
1117
+ }
1118
+ return null;
1119
+ }
1120
+ function isWebKit() {
1121
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1122
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1123
+ }
1124
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
1125
+ function isLastTraversableNode(node) {
1126
+ return lastTraversableNodeNames.has(getNodeName(node));
1127
+ }
1128
+ function getComputedStyle$1(element) {
1129
+ return getWindow(element).getComputedStyle(element);
1130
+ }
1131
+ function getNodeScroll(element) {
1132
+ if (isElement(element)) {
1133
+ return {
1134
+ scrollLeft: element.scrollLeft,
1135
+ scrollTop: element.scrollTop
1136
+ };
1137
+ }
1138
+ return {
1139
+ scrollLeft: element.scrollX,
1140
+ scrollTop: element.scrollY
1141
+ };
1142
+ }
1143
+ function getParentNode(node) {
1144
+ if (getNodeName(node) === 'html') {
1145
+ return node;
1146
+ }
1147
+ const result =
1148
+ // Step into the shadow DOM of the parent of a slotted node.
1149
+ node.assignedSlot ||
1150
+ // DOM Element detected.
1151
+ node.parentNode ||
1152
+ // ShadowRoot detected.
1153
+ isShadowRoot(node) && node.host ||
1154
+ // Fallback.
1155
+ getDocumentElement(node);
1156
+ return isShadowRoot(result) ? result.host : result;
1157
+ }
1158
+ function getNearestOverflowAncestor(node) {
1159
+ const parentNode = getParentNode(node);
1160
+ if (isLastTraversableNode(parentNode)) {
1161
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1162
+ }
1163
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1164
+ return parentNode;
1165
+ }
1166
+ return getNearestOverflowAncestor(parentNode);
1167
+ }
1168
+ function getOverflowAncestors(node, list, traverseIframes) {
1169
+ var _node$ownerDocument2;
1170
+ if (list === void 0) {
1171
+ list = [];
1172
+ }
1173
+ if (traverseIframes === void 0) {
1174
+ traverseIframes = true;
1175
+ }
1176
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1177
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1178
+ const win = getWindow(scrollableAncestor);
1179
+ if (isBody) {
1180
+ const frameElement = getFrameElement(win);
1181
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1182
+ }
1183
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1184
+ }
1185
+ function getFrameElement(win) {
1186
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1187
+ }
1188
+
1189
+ function getCssDimensions(element) {
1190
+ const css = getComputedStyle$1(element);
1191
+ // In testing environments, the `width` and `height` properties are empty
1192
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1193
+ let width = parseFloat(css.width) || 0;
1194
+ let height = parseFloat(css.height) || 0;
1195
+ const hasOffset = isHTMLElement(element);
1196
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1197
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1198
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1199
+ if (shouldFallback) {
1200
+ width = offsetWidth;
1201
+ height = offsetHeight;
1202
+ }
1203
+ return {
1204
+ width,
1205
+ height,
1206
+ $: shouldFallback
1207
+ };
1208
+ }
1209
+
1210
+ function unwrapElement(element) {
1211
+ return !isElement(element) ? element.contextElement : element;
1212
+ }
1213
+
1214
+ function getScale(element) {
1215
+ const domElement = unwrapElement(element);
1216
+ if (!isHTMLElement(domElement)) {
1217
+ return createCoords(1);
1218
+ }
1219
+ const rect = domElement.getBoundingClientRect();
1220
+ const {
1221
+ width,
1222
+ height,
1223
+ $
1224
+ } = getCssDimensions(domElement);
1225
+ let x = ($ ? round(rect.width) : rect.width) / width;
1226
+ let y = ($ ? round(rect.height) : rect.height) / height;
1227
+
1228
+ // 0, NaN, or Infinity should always fallback to 1.
1229
+
1230
+ if (!x || !Number.isFinite(x)) {
1231
+ x = 1;
1232
+ }
1233
+ if (!y || !Number.isFinite(y)) {
1234
+ y = 1;
1235
+ }
1236
+ return {
1237
+ x,
1238
+ y
1239
+ };
1240
+ }
1241
+
1242
+ const noOffsets = /*#__PURE__*/createCoords(0);
1243
+ function getVisualOffsets(element) {
1244
+ const win = getWindow(element);
1245
+ if (!isWebKit() || !win.visualViewport) {
1246
+ return noOffsets;
1247
+ }
1248
+ return {
1249
+ x: win.visualViewport.offsetLeft,
1250
+ y: win.visualViewport.offsetTop
1251
+ };
1252
+ }
1253
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1254
+ if (isFixed === void 0) {
1255
+ isFixed = false;
1256
+ }
1257
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1258
+ return false;
1259
+ }
1260
+ return isFixed;
1261
+ }
1262
+
1263
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1264
+ if (includeScale === void 0) {
1265
+ includeScale = false;
1266
+ }
1267
+ if (isFixedStrategy === void 0) {
1268
+ isFixedStrategy = false;
1269
+ }
1270
+ const clientRect = element.getBoundingClientRect();
1271
+ const domElement = unwrapElement(element);
1272
+ let scale = createCoords(1);
1273
+ if (includeScale) {
1274
+ if (offsetParent) {
1275
+ if (isElement(offsetParent)) {
1276
+ scale = getScale(offsetParent);
1277
+ }
1278
+ } else {
1279
+ scale = getScale(element);
1280
+ }
1281
+ }
1282
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1283
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1284
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1285
+ let width = clientRect.width / scale.x;
1286
+ let height = clientRect.height / scale.y;
1287
+ if (domElement) {
1288
+ const win = getWindow(domElement);
1289
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1290
+ let currentWin = win;
1291
+ let currentIFrame = getFrameElement(currentWin);
1292
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1293
+ const iframeScale = getScale(currentIFrame);
1294
+ const iframeRect = currentIFrame.getBoundingClientRect();
1295
+ const css = getComputedStyle$1(currentIFrame);
1296
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1297
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1298
+ x *= iframeScale.x;
1299
+ y *= iframeScale.y;
1300
+ width *= iframeScale.x;
1301
+ height *= iframeScale.y;
1302
+ x += left;
1303
+ y += top;
1304
+ currentWin = getWindow(currentIFrame);
1305
+ currentIFrame = getFrameElement(currentWin);
1306
+ }
1307
+ }
1308
+ return rectToClientRect({
1309
+ width,
1310
+ height,
1311
+ x,
1312
+ y
1313
+ });
1314
+ }
1315
+
1316
+ // If <html> has a CSS width greater than the viewport, then this will be
1317
+ // incorrect for RTL.
1318
+ function getWindowScrollBarX(element, rect) {
1319
+ const leftScroll = getNodeScroll(element).scrollLeft;
1320
+ if (!rect) {
1321
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1322
+ }
1323
+ return rect.left + leftScroll;
1324
+ }
1325
+
1326
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1327
+ if (ignoreScrollbarX === void 0) {
1328
+ ignoreScrollbarX = false;
1329
+ }
1330
+ const htmlRect = documentElement.getBoundingClientRect();
1331
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
1332
+ // RTL <body> scrollbar.
1333
+ getWindowScrollBarX(documentElement, htmlRect));
1334
+ const y = htmlRect.top + scroll.scrollTop;
1335
+ return {
1336
+ x,
1337
+ y
1338
+ };
1339
+ }
1340
+
1341
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1342
+ let {
1343
+ elements,
1344
+ rect,
1345
+ offsetParent,
1346
+ strategy
1347
+ } = _ref;
1348
+ const isFixed = strategy === 'fixed';
1349
+ const documentElement = getDocumentElement(offsetParent);
1350
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1351
+ if (offsetParent === documentElement || topLayer && isFixed) {
1352
+ return rect;
1353
+ }
1354
+ let scroll = {
1355
+ scrollLeft: 0,
1356
+ scrollTop: 0
1357
+ };
1358
+ let scale = createCoords(1);
1359
+ const offsets = createCoords(0);
1360
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1361
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1362
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1363
+ scroll = getNodeScroll(offsetParent);
1364
+ }
1365
+ if (isHTMLElement(offsetParent)) {
1366
+ const offsetRect = getBoundingClientRect(offsetParent);
1367
+ scale = getScale(offsetParent);
1368
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1369
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1370
+ }
1371
+ }
1372
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1373
+ return {
1374
+ width: rect.width * scale.x,
1375
+ height: rect.height * scale.y,
1376
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1377
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1378
+ };
1379
+ }
1380
+
1381
+ function getClientRects(element) {
1382
+ return Array.from(element.getClientRects());
1383
+ }
1384
+
1385
+ // Gets the entire size of the scrollable document area, even extending outside
1386
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1387
+ function getDocumentRect(element) {
1388
+ const html = getDocumentElement(element);
1389
+ const scroll = getNodeScroll(element);
1390
+ const body = element.ownerDocument.body;
1391
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1392
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1393
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1394
+ const y = -scroll.scrollTop;
1395
+ if (getComputedStyle$1(body).direction === 'rtl') {
1396
+ x += max(html.clientWidth, body.clientWidth) - width;
1397
+ }
1398
+ return {
1399
+ width,
1400
+ height,
1401
+ x,
1402
+ y
1403
+ };
1404
+ }
1405
+
1406
+ function getViewportRect(element, strategy) {
1407
+ const win = getWindow(element);
1408
+ const html = getDocumentElement(element);
1409
+ const visualViewport = win.visualViewport;
1410
+ let width = html.clientWidth;
1411
+ let height = html.clientHeight;
1412
+ let x = 0;
1413
+ let y = 0;
1414
+ if (visualViewport) {
1415
+ width = visualViewport.width;
1416
+ height = visualViewport.height;
1417
+ const visualViewportBased = isWebKit();
1418
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1419
+ x = visualViewport.offsetLeft;
1420
+ y = visualViewport.offsetTop;
1421
+ }
1422
+ }
1423
+ return {
1424
+ width,
1425
+ height,
1426
+ x,
1427
+ y
1428
+ };
1429
+ }
1430
+
1431
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1432
+ // Returns the inner client rect, subtracting scrollbars if present.
1433
+ function getInnerBoundingClientRect(element, strategy) {
1434
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1435
+ const top = clientRect.top + element.clientTop;
1436
+ const left = clientRect.left + element.clientLeft;
1437
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1438
+ const width = element.clientWidth * scale.x;
1439
+ const height = element.clientHeight * scale.y;
1440
+ const x = left * scale.x;
1441
+ const y = top * scale.y;
1442
+ return {
1443
+ width,
1444
+ height,
1445
+ x,
1446
+ y
1447
+ };
1448
+ }
1449
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1450
+ let rect;
1451
+ if (clippingAncestor === 'viewport') {
1452
+ rect = getViewportRect(element, strategy);
1453
+ } else if (clippingAncestor === 'document') {
1454
+ rect = getDocumentRect(getDocumentElement(element));
1455
+ } else if (isElement(clippingAncestor)) {
1456
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1457
+ } else {
1458
+ const visualOffsets = getVisualOffsets(element);
1459
+ rect = {
1460
+ x: clippingAncestor.x - visualOffsets.x,
1461
+ y: clippingAncestor.y - visualOffsets.y,
1462
+ width: clippingAncestor.width,
1463
+ height: clippingAncestor.height
1464
+ };
1465
+ }
1466
+ return rectToClientRect(rect);
1467
+ }
1468
+ function hasFixedPositionAncestor(element, stopNode) {
1469
+ const parentNode = getParentNode(element);
1470
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1471
+ return false;
1472
+ }
1473
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1474
+ }
1475
+
1476
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1477
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1478
+ // of the given element up the tree.
1479
+ function getClippingElementAncestors(element, cache) {
1480
+ const cachedResult = cache.get(element);
1481
+ if (cachedResult) {
1482
+ return cachedResult;
1483
+ }
1484
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1485
+ let currentContainingBlockComputedStyle = null;
1486
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1487
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1488
+
1489
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1490
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1491
+ const computedStyle = getComputedStyle$1(currentNode);
1492
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1493
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1494
+ currentContainingBlockComputedStyle = null;
1495
+ }
1496
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1497
+ if (shouldDropCurrentNode) {
1498
+ // Drop non-containing blocks.
1499
+ result = result.filter(ancestor => ancestor !== currentNode);
1500
+ } else {
1501
+ // Record last containing block for next iteration.
1502
+ currentContainingBlockComputedStyle = computedStyle;
1503
+ }
1504
+ currentNode = getParentNode(currentNode);
1505
+ }
1506
+ cache.set(element, result);
1507
+ return result;
1508
+ }
1509
+
1510
+ // Gets the maximum area that the element is visible in due to any number of
1511
+ // clipping ancestors.
1512
+ function getClippingRect(_ref) {
1513
+ let {
1514
+ element,
1515
+ boundary,
1516
+ rootBoundary,
1517
+ strategy
1518
+ } = _ref;
1519
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1520
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1521
+ const firstClippingAncestor = clippingAncestors[0];
1522
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1523
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1524
+ accRect.top = max(rect.top, accRect.top);
1525
+ accRect.right = min(rect.right, accRect.right);
1526
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1527
+ accRect.left = max(rect.left, accRect.left);
1528
+ return accRect;
1529
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1530
+ return {
1531
+ width: clippingRect.right - clippingRect.left,
1532
+ height: clippingRect.bottom - clippingRect.top,
1533
+ x: clippingRect.left,
1534
+ y: clippingRect.top
1535
+ };
1536
+ }
1537
+
1538
+ function getDimensions(element) {
1539
+ const {
1540
+ width,
1541
+ height
1542
+ } = getCssDimensions(element);
1543
+ return {
1544
+ width,
1545
+ height
1546
+ };
1547
+ }
1548
+
1549
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1550
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1551
+ const documentElement = getDocumentElement(offsetParent);
1552
+ const isFixed = strategy === 'fixed';
1553
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1554
+ let scroll = {
1555
+ scrollLeft: 0,
1556
+ scrollTop: 0
1557
+ };
1558
+ const offsets = createCoords(0);
1559
+
1560
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1561
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1562
+ function setLeftRTLScrollbarOffset() {
1563
+ offsets.x = getWindowScrollBarX(documentElement);
1564
+ }
1565
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1566
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1567
+ scroll = getNodeScroll(offsetParent);
1568
+ }
1569
+ if (isOffsetParentAnElement) {
1570
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1571
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1572
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1573
+ } else if (documentElement) {
1574
+ setLeftRTLScrollbarOffset();
1575
+ }
1576
+ }
1577
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1578
+ setLeftRTLScrollbarOffset();
1579
+ }
1580
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1581
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1582
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1583
+ return {
1584
+ x,
1585
+ y,
1586
+ width: rect.width,
1587
+ height: rect.height
1588
+ };
1589
+ }
1590
+
1591
+ function isStaticPositioned(element) {
1592
+ return getComputedStyle$1(element).position === 'static';
1593
+ }
1594
+
1595
+ function getTrueOffsetParent(element, polyfill) {
1596
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1597
+ return null;
1598
+ }
1599
+ if (polyfill) {
1600
+ return polyfill(element);
1601
+ }
1602
+ let rawOffsetParent = element.offsetParent;
1603
+
1604
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1605
+ // while Chrome and Safari return the <body> element. The <body> element must
1606
+ // be used to perform the correct calculations even if the <html> element is
1607
+ // non-static.
1608
+ if (getDocumentElement(element) === rawOffsetParent) {
1609
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1610
+ }
1611
+ return rawOffsetParent;
1612
+ }
1613
+
1614
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1615
+ // such as table ancestors and cross browser bugs.
1616
+ function getOffsetParent(element, polyfill) {
1617
+ const win = getWindow(element);
1618
+ if (isTopLayer(element)) {
1619
+ return win;
1620
+ }
1621
+ if (!isHTMLElement(element)) {
1622
+ let svgOffsetParent = getParentNode(element);
1623
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1624
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1625
+ return svgOffsetParent;
1626
+ }
1627
+ svgOffsetParent = getParentNode(svgOffsetParent);
1628
+ }
1629
+ return win;
1630
+ }
1631
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1632
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1633
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1634
+ }
1635
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1636
+ return win;
1637
+ }
1638
+ return offsetParent || getContainingBlock(element) || win;
1639
+ }
1640
+
1641
+ const getElementRects = async function (data) {
1642
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1643
+ const getDimensionsFn = this.getDimensions;
1644
+ const floatingDimensions = await getDimensionsFn(data.floating);
1645
+ return {
1646
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1647
+ floating: {
1648
+ x: 0,
1649
+ y: 0,
1650
+ width: floatingDimensions.width,
1651
+ height: floatingDimensions.height
1652
+ }
1653
+ };
1654
+ };
1655
+
1656
+ function isRTL(element) {
1657
+ return getComputedStyle$1(element).direction === 'rtl';
1658
+ }
1659
+
1660
+ const platform = {
1661
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1662
+ getDocumentElement,
1663
+ getClippingRect,
1664
+ getOffsetParent,
1665
+ getElementRects,
1666
+ getClientRects,
1667
+ getDimensions,
1668
+ getScale,
1669
+ isElement,
1670
+ isRTL
1671
+ };
1672
+
1673
+ function rectsAreEqual(a, b) {
1674
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1675
+ }
1676
+
1677
+ // https://samthor.au/2021/observing-dom/
1678
+ function observeMove(element, onMove) {
1679
+ let io = null;
1680
+ let timeoutId;
1681
+ const root = getDocumentElement(element);
1682
+ function cleanup() {
1683
+ var _io;
1684
+ clearTimeout(timeoutId);
1685
+ (_io = io) == null || _io.disconnect();
1686
+ io = null;
1687
+ }
1688
+ function refresh(skip, threshold) {
1689
+ if (skip === void 0) {
1690
+ skip = false;
1691
+ }
1692
+ if (threshold === void 0) {
1693
+ threshold = 1;
1694
+ }
1695
+ cleanup();
1696
+ const elementRectForRootMargin = element.getBoundingClientRect();
1697
+ const {
1698
+ left,
1699
+ top,
1700
+ width,
1701
+ height
1702
+ } = elementRectForRootMargin;
1703
+ if (!skip) {
1704
+ onMove();
1705
+ }
1706
+ if (!width || !height) {
1707
+ return;
1708
+ }
1709
+ const insetTop = floor(top);
1710
+ const insetRight = floor(root.clientWidth - (left + width));
1711
+ const insetBottom = floor(root.clientHeight - (top + height));
1712
+ const insetLeft = floor(left);
1713
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1714
+ const options = {
1715
+ rootMargin,
1716
+ threshold: max(0, min(1, threshold)) || 1
1717
+ };
1718
+ let isFirstUpdate = true;
1719
+ function handleObserve(entries) {
1720
+ const ratio = entries[0].intersectionRatio;
1721
+ if (ratio !== threshold) {
1722
+ if (!isFirstUpdate) {
1723
+ return refresh();
1724
+ }
1725
+ if (!ratio) {
1726
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1727
+ // to prevent an infinite loop of updates.
1728
+ timeoutId = setTimeout(() => {
1729
+ refresh(false, 1e-7);
1730
+ }, 1000);
1731
+ } else {
1732
+ refresh(false, ratio);
1733
+ }
1734
+ }
1735
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1736
+ // It's possible that even though the ratio is reported as 1, the
1737
+ // element is not actually fully within the IntersectionObserver's root
1738
+ // area anymore. This can happen under performance constraints. This may
1739
+ // be a bug in the browser's IntersectionObserver implementation. To
1740
+ // work around this, we compare the element's bounding rect now with
1741
+ // what it was at the time we created the IntersectionObserver. If they
1742
+ // are not equal then the element moved, so we refresh.
1743
+ refresh();
1744
+ }
1745
+ isFirstUpdate = false;
1746
+ }
1747
+
1748
+ // Older browsers don't support a `document` as the root and will throw an
1749
+ // error.
1750
+ try {
1751
+ io = new IntersectionObserver(handleObserve, {
1752
+ ...options,
1753
+ // Handle <iframe>s
1754
+ root: root.ownerDocument
1755
+ });
1756
+ } catch (_e) {
1757
+ io = new IntersectionObserver(handleObserve, options);
1758
+ }
1759
+ io.observe(element);
1760
+ }
1761
+ refresh(true);
1762
+ return cleanup;
1763
+ }
1764
+
1765
+ /**
1766
+ * Automatically updates the position of the floating element when necessary.
1767
+ * Should only be called when the floating element is mounted on the DOM or
1768
+ * visible on the screen.
1769
+ * @returns cleanup function that should be invoked when the floating element is
1770
+ * removed from the DOM or hidden from the screen.
1771
+ * @see https://floating-ui.com/docs/autoUpdate
1772
+ */
1773
+ function autoUpdate(reference, floating, update, options) {
1774
+ if (options === void 0) {
1775
+ options = {};
1776
+ }
1777
+ const {
1778
+ ancestorScroll = true,
1779
+ ancestorResize = true,
1780
+ elementResize = typeof ResizeObserver === 'function',
1781
+ layoutShift = typeof IntersectionObserver === 'function',
1782
+ animationFrame = false
1783
+ } = options;
1784
+ const referenceEl = unwrapElement(reference);
1785
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1786
+ ancestors.forEach(ancestor => {
1787
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1788
+ passive: true
1789
+ });
1790
+ ancestorResize && ancestor.addEventListener('resize', update);
1791
+ });
1792
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1793
+ let reobserveFrame = -1;
1794
+ let resizeObserver = null;
1795
+ if (elementResize) {
1796
+ resizeObserver = new ResizeObserver(_ref => {
1797
+ let [firstEntry] = _ref;
1798
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1799
+ // Prevent update loops when using the `size` middleware.
1800
+ // https://github.com/floating-ui/floating-ui/issues/1740
1801
+ resizeObserver.unobserve(floating);
1802
+ cancelAnimationFrame(reobserveFrame);
1803
+ reobserveFrame = requestAnimationFrame(() => {
1804
+ var _resizeObserver;
1805
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1806
+ });
1807
+ }
1808
+ update();
1809
+ });
1810
+ if (referenceEl && !animationFrame) {
1811
+ resizeObserver.observe(referenceEl);
1812
+ }
1813
+ resizeObserver.observe(floating);
1814
+ }
1815
+ let frameId;
1816
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1817
+ if (animationFrame) {
1818
+ frameLoop();
1819
+ }
1820
+ function frameLoop() {
1821
+ const nextRefRect = getBoundingClientRect(reference);
1822
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1823
+ update();
1824
+ }
1825
+ prevRefRect = nextRefRect;
1826
+ frameId = requestAnimationFrame(frameLoop);
1827
+ }
1828
+ update();
1829
+ return () => {
1830
+ var _resizeObserver2;
1831
+ ancestors.forEach(ancestor => {
1832
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1833
+ ancestorResize && ancestor.removeEventListener('resize', update);
1834
+ });
1835
+ cleanupIo == null || cleanupIo();
1836
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1837
+ resizeObserver = null;
1838
+ if (animationFrame) {
1839
+ cancelAnimationFrame(frameId);
1840
+ }
1841
+ };
1842
+ }
1843
+
1844
+ /**
1845
+ * Modifies the placement by translating the floating element along the
1846
+ * specified axes.
1847
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1848
+ * object may be passed.
1849
+ * @see https://floating-ui.com/docs/offset
1850
+ */
1851
+ const offset = offset$1;
1852
+
1853
+ /**
1854
+ * Optimizes the visibility of the floating element by shifting it in order to
1855
+ * keep it in view when it will overflow the clipping boundary.
1856
+ * @see https://floating-ui.com/docs/shift
1857
+ */
1858
+ const shift = shift$1;
1859
+
1860
+ /**
1861
+ * Optimizes the visibility of the floating element by flipping the `placement`
1862
+ * in order to keep it in view when the preferred placement(s) will overflow the
1863
+ * clipping boundary. Alternative to `autoPlacement`.
1864
+ * @see https://floating-ui.com/docs/flip
1865
+ */
1866
+ const flip = flip$1;
1867
+
1868
+ /**
1869
+ * Provides data that allows you to change the size of the floating element —
1870
+ * for instance, prevent it from overflowing the clipping boundary or match the
1871
+ * width of the reference element.
1872
+ * @see https://floating-ui.com/docs/size
1873
+ */
1874
+ const size = size$1;
1875
+
1876
+ /**
1877
+ * Provides data to position an inner element of the floating element so that it
1878
+ * appears centered to the reference element.
1879
+ * @see https://floating-ui.com/docs/arrow
1880
+ */
1881
+ const arrow = arrow$1;
1882
+
1883
+ /**
1884
+ * Provides improved positioning for inline reference elements that can span
1885
+ * over multiple lines, such as hyperlinks or range selections.
1886
+ * @see https://floating-ui.com/docs/inline
1887
+ */
1888
+ const inline = inline$1;
1889
+
1890
+ /**
1891
+ * Built-in `limiter` that will stop `shift()` at a certain point.
1892
+ */
1893
+ const limitShift = limitShift$1;
1894
+
1895
+ /**
1896
+ * Computes the `x` and `y` coordinates that will place the floating element
1897
+ * next to a given reference element.
1898
+ */
1899
+ const computePosition = (reference, floating, options) => {
1900
+ // This caches the expensive `getClippingElementAncestors` function so that
1901
+ // multiple lifecycle resets re-use the same result. It only lives for a
1902
+ // single call. If other functions become expensive, we can add them as well.
1903
+ const cache = new Map();
1904
+ const mergedOptions = {
1905
+ platform,
1906
+ ...options
1907
+ };
1908
+ const platformWithCache = {
1909
+ ...mergedOptions.platform,
1910
+ _c: cache
1911
+ };
1912
+ return computePosition$1(reference, floating, {
1913
+ ...mergedOptions,
1914
+ platform: platformWithCache
1915
+ });
1916
+ };
1917
+
1918
+ // src/events.ts
1919
+ var ToggleEvent = class extends Event {
1920
+ oldState;
1921
+ newState;
1922
+ constructor(type, { oldState = "", newState = "", ...init } = {}) {
1923
+ super(type, init);
1924
+ this.oldState = String(oldState || "");
1925
+ this.newState = String(newState || "");
1926
+ }
1927
+ };
1928
+ var popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();
1929
+ function queuePopoverToggleEventTask(element, oldState, newState) {
1930
+ popoverToggleTaskQueue.set(
1931
+ element,
1932
+ setTimeout(() => {
1933
+ if (!popoverToggleTaskQueue.has(element)) return;
1934
+ element.dispatchEvent(
1935
+ new ToggleEvent("toggle", {
1936
+ cancelable: false,
1937
+ oldState,
1938
+ newState
1939
+ })
1940
+ );
1941
+ }, 0)
1942
+ );
1943
+ }
1944
+
1945
+ // src/popover-helpers.ts
1946
+ var ShadowRoot$1 = globalThis.ShadowRoot || function() {
1947
+ };
1948
+ var HTMLDialogElement = globalThis.HTMLDialogElement || function() {
1949
+ };
1950
+ var topLayerElements = /* @__PURE__ */ new WeakMap();
1951
+ var autoPopoverList = /* @__PURE__ */ new WeakMap();
1952
+ var hintPopoverList = /* @__PURE__ */ new WeakMap();
1953
+ var visibilityState = /* @__PURE__ */ new WeakMap();
1954
+ function getPopoverVisibilityState(popover) {
1955
+ return visibilityState.get(popover) || "hidden";
1956
+ }
1957
+ var popoverInvoker = /* @__PURE__ */ new WeakMap();
1958
+ function lastSetElement(set) {
1959
+ return [...set].pop();
1960
+ }
1961
+ function popoverTargetAttributeActivationBehavior(element) {
1962
+ const popover = element.popoverTargetElement;
1963
+ if (!(popover instanceof HTMLElement)) {
1964
+ return;
1965
+ }
1966
+ const visibility = getPopoverVisibilityState(popover);
1967
+ if (element.popoverTargetAction === "show" && visibility === "showing") {
1968
+ return;
1969
+ }
1970
+ if (element.popoverTargetAction === "hide" && visibility === "hidden") return;
1971
+ if (visibility === "showing") {
1972
+ hidePopover(popover, true, true);
1973
+ } else if (checkPopoverValidity(popover, false)) {
1974
+ popoverInvoker.set(popover, element);
1975
+ showPopover(popover);
1976
+ }
1977
+ }
1978
+ function checkPopoverValidity(element, expectedToBeShowing) {
1979
+ if (element.popover !== "auto" && element.popover !== "manual" && element.popover !== "hint") {
1980
+ return false;
1981
+ }
1982
+ if (!element.isConnected) return false;
1983
+ if (expectedToBeShowing && getPopoverVisibilityState(element) !== "showing") {
1984
+ return false;
1985
+ }
1986
+ if (!expectedToBeShowing && getPopoverVisibilityState(element) !== "hidden") {
1987
+ return false;
1988
+ }
1989
+ if (element instanceof HTMLDialogElement && element.hasAttribute("open")) {
1990
+ return false;
1991
+ }
1992
+ if (document.fullscreenElement === element) return false;
1993
+ return true;
1994
+ }
1995
+ function getStackPosition(popover) {
1996
+ if (!popover) return 0;
1997
+ const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();
1998
+ const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();
1999
+ if (hintPopovers.has(popover)) {
2000
+ return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;
2001
+ }
2002
+ if (autoPopovers.has(popover)) {
2003
+ return [...autoPopovers].indexOf(popover) + 1;
2004
+ }
2005
+ return 0;
2006
+ }
2007
+ function topMostClickedPopover(target) {
2008
+ const clickedPopover = nearestInclusiveOpenPopover(target);
2009
+ const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);
2010
+ if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {
2011
+ return clickedPopover;
2012
+ }
2013
+ return invokerPopover;
2014
+ }
2015
+ function topmostAutoOrHintPopover(document2) {
2016
+ let topmostPopover;
2017
+ const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();
2018
+ const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();
2019
+ const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;
2020
+ if (usedStack) {
2021
+ topmostPopover = lastSetElement(usedStack);
2022
+ if (!topmostPopover.isConnected) {
2023
+ usedStack.delete(topmostPopover);
2024
+ return topmostAutoOrHintPopover(document2);
2025
+ }
2026
+ return topmostPopover;
2027
+ }
2028
+ return null;
2029
+ }
2030
+ function topMostPopoverInList(list) {
2031
+ for (const popover of list || []) {
2032
+ if (!popover.isConnected) {
2033
+ list.delete(popover);
2034
+ } else {
2035
+ return popover;
2036
+ }
2037
+ }
2038
+ return null;
2039
+ }
2040
+ function getRootNode(node) {
2041
+ if (typeof node.getRootNode === "function") {
2042
+ return node.getRootNode();
2043
+ }
2044
+ if (node.parentNode) return getRootNode(node.parentNode);
2045
+ return node;
2046
+ }
2047
+ function nearestInclusiveOpenPopover(node) {
2048
+ while (node) {
2049
+ if (node instanceof HTMLElement && node.popover === "auto" && visibilityState.get(node) === "showing") {
2050
+ return node;
2051
+ }
2052
+ node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);
2053
+ if (node instanceof ShadowRoot$1) node = node.host;
2054
+ if (node instanceof Document) return;
2055
+ }
2056
+ }
2057
+ function nearestInclusiveTargetPopoverForInvoker(node) {
2058
+ while (node) {
2059
+ const nodePopover = node.popoverTargetElement;
2060
+ if (nodePopover instanceof HTMLElement) return nodePopover;
2061
+ node = node.parentElement || getRootNode(node);
2062
+ if (node instanceof ShadowRoot$1) node = node.host;
2063
+ if (node instanceof Document) return;
2064
+ }
2065
+ }
2066
+ function topMostPopoverAncestor(newPopover, list) {
2067
+ const popoverPositions = /* @__PURE__ */ new Map();
2068
+ let i = 0;
2069
+ for (const popover of list || []) {
2070
+ popoverPositions.set(popover, i);
2071
+ i += 1;
2072
+ }
2073
+ popoverPositions.set(newPopover, i);
2074
+ i += 1;
2075
+ let topMostPopoverAncestor2 = null;
2076
+ function checkAncestor(candidate) {
2077
+ if (!candidate) return;
2078
+ let okNesting = false;
2079
+ let candidateAncestor = null;
2080
+ let candidatePosition = null;
2081
+ while (!okNesting) {
2082
+ candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;
2083
+ if (candidateAncestor === null) return;
2084
+ if (!popoverPositions.has(candidateAncestor)) return;
2085
+ if (newPopover.popover === "hint" || candidateAncestor.popover === "auto") {
2086
+ okNesting = true;
2087
+ }
2088
+ if (!okNesting) {
2089
+ candidate = candidateAncestor.parentElement;
2090
+ }
2091
+ }
2092
+ candidatePosition = popoverPositions.get(candidateAncestor);
2093
+ if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {
2094
+ topMostPopoverAncestor2 = candidateAncestor;
2095
+ }
2096
+ }
2097
+ checkAncestor(newPopover.parentElement || getRootNode(newPopover));
2098
+ return topMostPopoverAncestor2;
2099
+ }
2100
+ function isFocusable(focusTarget) {
2101
+ if (focusTarget.hidden || focusTarget instanceof ShadowRoot$1) return false;
2102
+ if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {
2103
+ if (focusTarget.disabled) return false;
2104
+ }
2105
+ if (focusTarget instanceof HTMLInputElement && focusTarget.type === "hidden") {
2106
+ return false;
2107
+ }
2108
+ if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === "") {
2109
+ return false;
2110
+ }
2111
+ return typeof focusTarget.tabIndex === "number" && focusTarget.tabIndex !== -1;
2112
+ }
2113
+ function focusDelegate(focusTarget) {
2114
+ if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {
2115
+ return null;
2116
+ }
2117
+ let whereToLook = focusTarget;
2118
+ if (whereToLook.shadowRoot) {
2119
+ whereToLook = whereToLook.shadowRoot;
2120
+ }
2121
+ let autoFocusDelegate = whereToLook.querySelector("[autofocus]");
2122
+ if (autoFocusDelegate) {
2123
+ return autoFocusDelegate;
2124
+ } else {
2125
+ const slots = whereToLook.querySelectorAll("slot");
2126
+ for (const slot of slots) {
2127
+ const assignedElements = slot.assignedElements({ flatten: true });
2128
+ for (const el of assignedElements) {
2129
+ if (el.hasAttribute("autofocus")) {
2130
+ return el;
2131
+ } else {
2132
+ autoFocusDelegate = el.querySelector("[autofocus]");
2133
+ if (autoFocusDelegate) {
2134
+ return autoFocusDelegate;
2135
+ }
2136
+ }
2137
+ }
2138
+ }
2139
+ }
2140
+ const walker = focusTarget.ownerDocument.createTreeWalker(
2141
+ whereToLook,
2142
+ NodeFilter.SHOW_ELEMENT
2143
+ );
2144
+ let descendant = walker.currentNode;
2145
+ while (descendant) {
2146
+ if (isFocusable(descendant)) {
2147
+ return descendant;
2148
+ }
2149
+ descendant = walker.nextNode();
2150
+ }
2151
+ }
2152
+ function popoverFocusingSteps(subject) {
2153
+ focusDelegate(subject)?.focus();
2154
+ }
2155
+ var previouslyFocusedElements = /* @__PURE__ */ new WeakMap();
2156
+ function showPopover(element) {
2157
+ if (!checkPopoverValidity(element, false)) {
2158
+ return;
2159
+ }
2160
+ const document2 = element.ownerDocument;
2161
+ if (!element.dispatchEvent(
2162
+ new ToggleEvent("beforetoggle", {
2163
+ cancelable: true,
2164
+ oldState: "closed",
2165
+ newState: "open"
2166
+ })
2167
+ )) {
2168
+ return;
2169
+ }
2170
+ if (!checkPopoverValidity(element, false)) {
2171
+ return;
2172
+ }
2173
+ let shouldRestoreFocus = false;
2174
+ const originalType = element.popover;
2175
+ let stackToAppendTo = null;
2176
+ const autoAncestor = topMostPopoverAncestor(
2177
+ element,
2178
+ autoPopoverList.get(document2) || /* @__PURE__ */ new Set()
2179
+ );
2180
+ const hintAncestor = topMostPopoverAncestor(
2181
+ element,
2182
+ hintPopoverList.get(document2) || /* @__PURE__ */ new Set()
2183
+ );
2184
+ if (originalType === "auto") {
2185
+ closeAllOpenPopoversInList(
2186
+ hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),
2187
+ shouldRestoreFocus,
2188
+ true
2189
+ );
2190
+ const ancestor = autoAncestor || document2;
2191
+ hideAllPopoversUntil(ancestor, shouldRestoreFocus, true);
2192
+ stackToAppendTo = "auto";
2193
+ }
2194
+ if (originalType === "hint") {
2195
+ if (hintAncestor) {
2196
+ hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);
2197
+ stackToAppendTo = "hint";
2198
+ } else {
2199
+ closeAllOpenPopoversInList(
2200
+ hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),
2201
+ shouldRestoreFocus,
2202
+ true
2203
+ );
2204
+ if (autoAncestor) {
2205
+ hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);
2206
+ stackToAppendTo = "auto";
2207
+ } else {
2208
+ stackToAppendTo = "hint";
2209
+ }
2210
+ }
2211
+ }
2212
+ if (originalType === "auto" || originalType === "hint") {
2213
+ if (originalType !== element.popover || !checkPopoverValidity(element, false)) {
2214
+ return;
2215
+ }
2216
+ if (!topmostAutoOrHintPopover(document2)) {
2217
+ shouldRestoreFocus = true;
2218
+ }
2219
+ if (stackToAppendTo === "auto") {
2220
+ if (!autoPopoverList.has(document2)) {
2221
+ autoPopoverList.set(document2, /* @__PURE__ */ new Set());
2222
+ }
2223
+ autoPopoverList.get(document2).add(element);
2224
+ } else if (stackToAppendTo === "hint") {
2225
+ if (!hintPopoverList.has(document2)) {
2226
+ hintPopoverList.set(document2, /* @__PURE__ */ new Set());
2227
+ }
2228
+ hintPopoverList.get(document2).add(element);
2229
+ }
2230
+ }
2231
+ previouslyFocusedElements.delete(element);
2232
+ const originallyFocusedElement = document2.activeElement;
2233
+ element.classList.add(":popover-open");
2234
+ visibilityState.set(element, "showing");
2235
+ if (!topLayerElements.has(document2)) {
2236
+ topLayerElements.set(document2, /* @__PURE__ */ new Set());
2237
+ }
2238
+ topLayerElements.get(document2).add(element);
2239
+ setInvokerAriaExpanded(popoverInvoker.get(element), true);
2240
+ popoverFocusingSteps(element);
2241
+ if (shouldRestoreFocus && originallyFocusedElement && element.popover === "auto") {
2242
+ previouslyFocusedElements.set(element, originallyFocusedElement);
2243
+ }
2244
+ queuePopoverToggleEventTask(element, "closed", "open");
2245
+ }
2246
+ function hidePopover(element, focusPreviousElement = false, fireEvents = false) {
2247
+ if (!checkPopoverValidity(element, true)) {
2248
+ return;
2249
+ }
2250
+ const document2 = element.ownerDocument;
2251
+ if (["auto", "hint"].includes(element.popover)) {
2252
+ hideAllPopoversUntil(element, focusPreviousElement, fireEvents);
2253
+ if (!checkPopoverValidity(element, true)) {
2254
+ return;
2255
+ }
2256
+ }
2257
+ const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();
2258
+ const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;
2259
+ setInvokerAriaExpanded(popoverInvoker.get(element), false);
2260
+ popoverInvoker.delete(element);
2261
+ if (fireEvents) {
2262
+ element.dispatchEvent(
2263
+ new ToggleEvent("beforetoggle", {
2264
+ oldState: "open",
2265
+ newState: "closed"
2266
+ })
2267
+ );
2268
+ if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) {
2269
+ hideAllPopoversUntil(element, focusPreviousElement, fireEvents);
2270
+ }
2271
+ if (!checkPopoverValidity(element, true)) {
2272
+ return;
2273
+ }
2274
+ }
2275
+ topLayerElements.get(document2)?.delete(element);
2276
+ autoList.delete(element);
2277
+ hintPopoverList.get(document2)?.delete(element);
2278
+ element.classList.remove(":popover-open");
2279
+ visibilityState.set(element, "hidden");
2280
+ if (fireEvents) {
2281
+ queuePopoverToggleEventTask(element, "open", "closed");
2282
+ }
2283
+ const previouslyFocusedElement = previouslyFocusedElements.get(element);
2284
+ if (previouslyFocusedElement) {
2285
+ previouslyFocusedElements.delete(element);
2286
+ if (focusPreviousElement) {
2287
+ previouslyFocusedElement.focus();
2288
+ }
2289
+ }
2290
+ }
2291
+ function closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {
2292
+ let popover = topmostAutoOrHintPopover(document2);
2293
+ while (popover) {
2294
+ hidePopover(popover, focusPreviousElement, fireEvents);
2295
+ popover = topmostAutoOrHintPopover(document2);
2296
+ }
2297
+ }
2298
+ function closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {
2299
+ let popover = topMostPopoverInList(list);
2300
+ while (popover) {
2301
+ hidePopover(popover, focusPreviousElement, fireEvents);
2302
+ popover = topMostPopoverInList(list);
2303
+ }
2304
+ }
2305
+ function hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {
2306
+ let repeatingHide = false;
2307
+ let hasRunOnce = false;
2308
+ while (repeatingHide || !hasRunOnce) {
2309
+ hasRunOnce = true;
2310
+ let lastToHide = null;
2311
+ let foundEndpoint = false;
2312
+ for (const popover of set) {
2313
+ if (popover === endpoint) {
2314
+ foundEndpoint = true;
2315
+ } else if (foundEndpoint) {
2316
+ lastToHide = popover;
2317
+ break;
2318
+ }
2319
+ }
2320
+ if (!lastToHide) return;
2321
+ while (getPopoverVisibilityState(lastToHide) === "showing" && set.size) {
2322
+ hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);
2323
+ }
2324
+ if (set.has(endpoint) && lastSetElement(set) !== endpoint) {
2325
+ repeatingHide = true;
2326
+ }
2327
+ if (repeatingHide) {
2328
+ fireEvents = false;
2329
+ }
2330
+ }
2331
+ }
2332
+ function hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {
2333
+ const document2 = endpoint.ownerDocument || endpoint;
2334
+ if (endpoint instanceof Document) {
2335
+ return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);
2336
+ }
2337
+ if (hintPopoverList.get(document2)?.has(endpoint)) {
2338
+ hidePopoverStackUntil(
2339
+ endpoint,
2340
+ hintPopoverList.get(document2),
2341
+ focusPreviousElement,
2342
+ fireEvents
2343
+ );
2344
+ return;
2345
+ }
2346
+ closeAllOpenPopoversInList(
2347
+ hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),
2348
+ focusPreviousElement,
2349
+ fireEvents
2350
+ );
2351
+ if (!autoPopoverList.get(document2)?.has(endpoint)) {
2352
+ return;
2353
+ }
2354
+ hidePopoverStackUntil(
2355
+ endpoint,
2356
+ autoPopoverList.get(document2),
2357
+ focusPreviousElement,
2358
+ fireEvents
2359
+ );
2360
+ }
2361
+ var popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();
2362
+ function lightDismissOpenPopovers(event) {
2363
+ if (!event.isTrusted) return;
2364
+ const target = event.composedPath()[0];
2365
+ if (!target) return;
2366
+ const document2 = target.ownerDocument;
2367
+ const topMostPopover = topmostAutoOrHintPopover(document2);
2368
+ if (!topMostPopover) return;
2369
+ const ancestor = topMostClickedPopover(target);
2370
+ if (ancestor && event.type === "pointerdown") {
2371
+ popoverPointerDownTargets.set(document2, ancestor);
2372
+ } else if (event.type === "pointerup") {
2373
+ const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;
2374
+ popoverPointerDownTargets.delete(document2);
2375
+ if (sameTarget) {
2376
+ hideAllPopoversUntil(ancestor || document2, false, true);
2377
+ }
2378
+ }
2379
+ }
2380
+ var initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();
2381
+ function setInvokerAriaExpanded(el, force = false) {
2382
+ if (!el) return;
2383
+ if (!initialAriaExpandedValue.has(el)) {
2384
+ initialAriaExpandedValue.set(el, el.getAttribute("aria-expanded"));
2385
+ }
2386
+ const popover = el.popoverTargetElement;
2387
+ if (popover instanceof HTMLElement && popover.popover === "auto") {
2388
+ el.setAttribute("aria-expanded", String(force));
2389
+ } else {
2390
+ const initialValue = initialAriaExpandedValue.get(el);
2391
+ if (!initialValue) {
2392
+ el.removeAttribute("aria-expanded");
2393
+ } else {
2394
+ el.setAttribute("aria-expanded", initialValue);
2395
+ }
2396
+ }
2397
+ }
2398
+
2399
+ // src/popover.ts
2400
+ var ShadowRoot2 = globalThis.ShadowRoot || function() {
2401
+ };
2402
+ function isSupported() {
2403
+ return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype === "object" && "popover" in HTMLElement.prototype;
2404
+ }
2405
+ function patchSelectorFn(object, name, mapper) {
2406
+ const original = object[name];
2407
+ Object.defineProperty(object, name, {
2408
+ value(selector) {
2409
+ return original.call(this, mapper(selector));
2410
+ }
2411
+ });
2412
+ }
2413
+ var nonEscapedPopoverSelector = /(^|[^\\]):popover-open\b/g;
2414
+ function hasLayerSupport() {
2415
+ return typeof globalThis.CSSLayerBlockRule === "function";
2416
+ }
2417
+ function getStyles() {
2418
+ const useLayer = hasLayerSupport();
2419
+ return `
2420
+ ${useLayer ? "@layer popover-polyfill {" : ""}
2421
+ :where([popover]) {
2422
+ position: fixed;
2423
+ z-index: 2147483647;
2424
+ inset: 0;
2425
+ padding: 0.25em;
2426
+ width: fit-content;
2427
+ height: fit-content;
2428
+ border-width: initial;
2429
+ border-color: initial;
2430
+ border-image: initial;
2431
+ border-style: solid;
2432
+ background-color: canvas;
2433
+ color: canvastext;
2434
+ overflow: auto;
2435
+ margin: auto;
2436
+ }
2437
+
2438
+ :where([popover]:not(.\\:popover-open)) {
2439
+ display: none;
2440
+ }
2441
+
2442
+ :where(dialog[popover].\\:popover-open) {
2443
+ display: block;
2444
+ }
2445
+
2446
+ :where(dialog[popover][open]) {
2447
+ display: revert;
2448
+ }
2449
+
2450
+ :where([anchor].\\:popover-open) {
2451
+ inset: auto;
2452
+ }
2453
+
2454
+ :where([anchor]:popover-open) {
2455
+ inset: auto;
2456
+ }
2457
+
2458
+ @supports not (background-color: canvas) {
2459
+ :where([popover]) {
2460
+ background-color: white;
2461
+ color: black;
2462
+ }
2463
+ }
2464
+
2465
+ @supports (width: -moz-fit-content) {
2466
+ :where([popover]) {
2467
+ width: -moz-fit-content;
2468
+ height: -moz-fit-content;
2469
+ }
2470
+ }
2471
+
2472
+ @supports not (inset: 0) {
2473
+ :where([popover]) {
2474
+ top: 0;
2475
+ left: 0;
2476
+ right: 0;
2477
+ bottom: 0;
2478
+ }
2479
+ }
2480
+ ${useLayer ? "}" : ""}
2481
+ `;
2482
+ }
2483
+ var popoverStyleSheet = null;
2484
+ function injectStyles(root) {
2485
+ const styles = getStyles();
2486
+ if (popoverStyleSheet === null) {
2487
+ try {
2488
+ popoverStyleSheet = new CSSStyleSheet();
2489
+ popoverStyleSheet.replaceSync(styles);
2490
+ } catch {
2491
+ popoverStyleSheet = false;
2492
+ }
2493
+ }
2494
+ if (popoverStyleSheet === false) {
2495
+ const sheet = document.createElement("style");
2496
+ sheet.textContent = styles;
2497
+ if (root instanceof Document) {
2498
+ root.head.prepend(sheet);
2499
+ } else {
2500
+ root.prepend(sheet);
2501
+ }
2502
+ } else {
2503
+ root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];
2504
+ }
2505
+ }
2506
+ function apply() {
2507
+ if (typeof window === "undefined") return;
2508
+ window.ToggleEvent = window.ToggleEvent || ToggleEvent;
2509
+ function rewriteSelector(selector) {
2510
+ if (selector?.includes(":popover-open")) {
2511
+ selector = selector.replace(
2512
+ nonEscapedPopoverSelector,
2513
+ "$1.\\:popover-open"
2514
+ );
2515
+ }
2516
+ return selector;
2517
+ }
2518
+ patchSelectorFn(Document.prototype, "querySelector", rewriteSelector);
2519
+ patchSelectorFn(Document.prototype, "querySelectorAll", rewriteSelector);
2520
+ patchSelectorFn(Element.prototype, "querySelector", rewriteSelector);
2521
+ patchSelectorFn(Element.prototype, "querySelectorAll", rewriteSelector);
2522
+ patchSelectorFn(Element.prototype, "matches", rewriteSelector);
2523
+ patchSelectorFn(Element.prototype, "closest", rewriteSelector);
2524
+ patchSelectorFn(
2525
+ DocumentFragment.prototype,
2526
+ "querySelectorAll",
2527
+ rewriteSelector
2528
+ );
2529
+ Object.defineProperties(HTMLElement.prototype, {
2530
+ popover: {
2531
+ enumerable: true,
2532
+ configurable: true,
2533
+ get() {
2534
+ if (!this.hasAttribute("popover")) return null;
2535
+ const value = (this.getAttribute("popover") || "").toLowerCase();
2536
+ if (value === "" || value == "auto") return "auto";
2537
+ if (value == "hint") return "hint";
2538
+ return "manual";
2539
+ },
2540
+ set(value) {
2541
+ if (value === null) {
2542
+ this.removeAttribute("popover");
2543
+ } else {
2544
+ this.setAttribute("popover", value);
2545
+ }
2546
+ }
2547
+ },
2548
+ showPopover: {
2549
+ enumerable: true,
2550
+ configurable: true,
2551
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2552
+ value(options = {}) {
2553
+ showPopover(this);
2554
+ }
2555
+ },
2556
+ hidePopover: {
2557
+ enumerable: true,
2558
+ configurable: true,
2559
+ value() {
2560
+ hidePopover(this, true, true);
2561
+ }
2562
+ },
2563
+ togglePopover: {
2564
+ enumerable: true,
2565
+ configurable: true,
2566
+ value(options = {}) {
2567
+ if (typeof options === "boolean") {
2568
+ options = { force: options };
2569
+ }
2570
+ if (visibilityState.get(this) === "showing" && options.force === void 0 || options.force === false) {
2571
+ hidePopover(this, true, true);
2572
+ } else if (options.force === void 0 || options.force === true) {
2573
+ showPopover(this);
2574
+ }
2575
+ return visibilityState.get(this) === "showing";
2576
+ }
2577
+ }
2578
+ });
2579
+ const originalAttachShadow = Element.prototype.attachShadow;
2580
+ if (originalAttachShadow) {
2581
+ Object.defineProperties(Element.prototype, {
2582
+ attachShadow: {
2583
+ enumerable: true,
2584
+ configurable: true,
2585
+ writable: true,
2586
+ value(options) {
2587
+ const shadowRoot = originalAttachShadow.call(this, options);
2588
+ injectStyles(shadowRoot);
2589
+ return shadowRoot;
2590
+ }
2591
+ }
2592
+ });
2593
+ }
2594
+ const originalAttachInternals = HTMLElement.prototype.attachInternals;
2595
+ if (originalAttachInternals) {
2596
+ Object.defineProperties(HTMLElement.prototype, {
2597
+ attachInternals: {
2598
+ enumerable: true,
2599
+ configurable: true,
2600
+ writable: true,
2601
+ value() {
2602
+ const internals = originalAttachInternals.call(this);
2603
+ if (internals.shadowRoot) {
2604
+ injectStyles(internals.shadowRoot);
2605
+ }
2606
+ return internals;
2607
+ }
2608
+ }
2609
+ });
2610
+ }
2611
+ const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();
2612
+ function applyPopoverInvokerElementMixin(ElementClass) {
2613
+ Object.defineProperties(ElementClass.prototype, {
2614
+ popoverTargetElement: {
2615
+ enumerable: true,
2616
+ configurable: true,
2617
+ set(targetElement) {
2618
+ if (targetElement === null) {
2619
+ this.removeAttribute("popovertarget");
2620
+ popoverTargetAssociatedElements.delete(this);
2621
+ } else if (!(targetElement instanceof Element)) {
2622
+ throw new TypeError(
2623
+ `popoverTargetElement must be an element or null`
2624
+ );
2625
+ } else {
2626
+ this.setAttribute("popovertarget", "");
2627
+ popoverTargetAssociatedElements.set(this, targetElement);
2628
+ }
2629
+ },
2630
+ get() {
2631
+ if (this.localName !== "button" && this.localName !== "input") {
2632
+ return null;
2633
+ }
2634
+ if (this.localName === "input" && this.type !== "reset" && this.type !== "image" && this.type !== "button") {
2635
+ return null;
2636
+ }
2637
+ if (this.disabled) {
2638
+ return null;
2639
+ }
2640
+ if (this.form && this.type === "submit") {
2641
+ return null;
2642
+ }
2643
+ const targetElement = popoverTargetAssociatedElements.get(this);
2644
+ if (targetElement && targetElement.isConnected) {
2645
+ return targetElement;
2646
+ } else if (targetElement && !targetElement.isConnected) {
2647
+ popoverTargetAssociatedElements.delete(this);
2648
+ return null;
2649
+ }
2650
+ const root = getRootNode(this);
2651
+ const idref = this.getAttribute("popovertarget");
2652
+ if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {
2653
+ return root.getElementById(idref) || null;
2654
+ }
2655
+ return null;
2656
+ }
2657
+ },
2658
+ popoverTargetAction: {
2659
+ enumerable: true,
2660
+ configurable: true,
2661
+ get() {
2662
+ const value = (this.getAttribute("popovertargetaction") || "").toLowerCase();
2663
+ if (value === "show" || value === "hide") return value;
2664
+ return "toggle";
2665
+ },
2666
+ set(value) {
2667
+ this.setAttribute("popovertargetaction", value);
2668
+ }
2669
+ }
2670
+ });
2671
+ }
2672
+ applyPopoverInvokerElementMixin(HTMLButtonElement);
2673
+ applyPopoverInvokerElementMixin(HTMLInputElement);
2674
+ const handleInvokerActivation = (event) => {
2675
+ const composedPath = event.composedPath();
2676
+ const target = composedPath[0];
2677
+ if (!(target instanceof Element) || target?.shadowRoot) {
2678
+ return;
2679
+ }
2680
+ const root = getRootNode(target);
2681
+ if (!(root instanceof ShadowRoot2 || root instanceof Document)) {
2682
+ return;
2683
+ }
2684
+ const invoker = composedPath.find(
2685
+ (el) => el.matches?.("[popovertargetaction],[popovertarget]")
2686
+ );
2687
+ if (invoker) {
2688
+ popoverTargetAttributeActivationBehavior(invoker);
2689
+ event.preventDefault();
2690
+ return;
2691
+ }
2692
+ };
2693
+ const onKeydown = (event) => {
2694
+ const key = event.key;
2695
+ const target = event.target;
2696
+ if (!event.defaultPrevented && target && (key === "Escape" || key === "Esc")) {
2697
+ hideAllPopoversUntil(target.ownerDocument, true, true);
2698
+ }
2699
+ };
2700
+ const addEventListeners = (root) => {
2701
+ root.addEventListener("click", handleInvokerActivation);
2702
+ root.addEventListener("keydown", onKeydown);
2703
+ root.addEventListener("pointerdown", lightDismissOpenPopovers);
2704
+ root.addEventListener("pointerup", lightDismissOpenPopovers);
2705
+ };
2706
+ addEventListeners(document);
2707
+ injectStyles(document);
2708
+ }
2709
+
2710
+ const duration = 250;
2711
+ const easing = 'ease-out';
2712
+ function popIn(el) {
2713
+ if (!el)
2714
+ return;
2715
+ return el.animate([
2716
+ { transform: 'scale(0.9)', opacity: 0 },
2717
+ { transform: 'scale(1)', opacity: 1 },
2718
+ ], {
2719
+ duration,
2720
+ easing,
2721
+ fill: 'forwards',
2722
+ });
2723
+ }
2724
+
2725
+ const postPopovercontainerCss = "@layer polyfill{@supports not selector(:popover-open){[popover]:not(.\\:popover-open){display:none}}}:where(post-popovercontainer){background-color:rgba(0,0,0,0);border:rgba(0,0,0,0);position:fixed;margin:0;padding:0;overflow:visible}:where(post-popovercontainer)>div{box-shadow:var(--post-device-elevation-300);width:max-content;max-width:100%;color:var(--post-current-fg);background-color:var(--post-current-bg);border-radius:4px}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:where(post-popovercontainer)>div{border:2px solid rgba(0,0,0,0)}}:where(post-popovercontainer)[tooltip]{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}:where(post-popovercontainer)[safe-space]::after{content:\"\";position:fixed;inset:0;z-index:-1;pointer-events:auto}:where(post-popovercontainer)[safe-space=triangle]::after{clip-path:polygon(var(--post-safe-space-cursor-x, 0) var(--post-safe-space-cursor-y, 0), var(--post-safe-space-popover-x-start, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-start, 0)), var(--post-safe-space-popover-x-end, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-end, 0)))}:where(post-popovercontainer)[safe-space=trapezoid]::after{clip-path:polygon(var(--post-safe-space-trigger-x-start, var(--post-safe-space-trigger-x, 0)) var(--post-safe-space-trigger-y, var(--post-safe-space-trigger-y-start, 0)), var(--post-safe-space-trigger-x-end, var(--post-safe-space-trigger-x, 0)) var(--post-safe-space-trigger-y, var(--post-safe-space-trigger-y-end, 0)), var(--post-safe-space-popover-x-end, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-end, 0)), var(--post-safe-space-popover-x-start, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-start, 0)))}:where(post-popovercontainer):not(:has(.arrow))>div{box-shadow:var(--post-device-elevation-300)}:where(post-popovercontainer):has(.arrow)>div{filter:drop-shadow(1px 2px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(2px 4px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(4px 8px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer):has(.arrow.top)>div{filter:drop-shadow(0px -2px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(0px -4px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(0px -8px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer):has(.arrow.left)>div{filter:drop-shadow(-2px 0px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(-4px 0px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(-8px 0px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer):has(.arrow.right)>div{filter:drop-shadow(2px 0px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(4px 0px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(8px 0px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer) .arrow{position:absolute;width:.5825rem;height:.5825rem;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1}:where(post-popovercontainer) .arrow.top{border-block-start:2px solid rgba(0,0,0,0);border-inline-start:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.right{border-block-start:2px solid rgba(0,0,0,0);border-inline-end:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.left{border-block-end:2px solid rgba(0,0,0,0);border-inline-start:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.bottom{border-block-end:2px solid rgba(0,0,0,0);border-inline-end:2px solid rgba(0,0,0,0)}";
2726
+
2727
+ const PostPopovercontainer = /*@__PURE__*/ proxyCustomElement(class PostPopovercontainer extends HTMLElement$1 {
2728
+ constructor() {
2729
+ super();
2730
+ this.__registerHost();
2731
+ this.postToggle = createEvent(this, "postToggle", 7);
2732
+ this.firstOpen = true;
2733
+ /**
2734
+ * Defines the placement of the popovercontainer according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.
2735
+ * Popovercontainers are automatically flipped to the opposite side if there is not enough available space and are shifted
2736
+ * towards the viewport if they would overlap edge boundaries.
2737
+ */
2738
+ this.placement = 'top';
2739
+ /**
2740
+ * Gap between the edge of the page and the popovercontainer
2741
+ */
2742
+ this.edgeGap = 8;
2743
+ /**
2744
+ * Animation style
2745
+ */
2746
+ this.animation = null;
2747
+ /**
2748
+ * Whether or not to display a little pointer arrow
2749
+ */
2750
+ this.arrow = false;
2751
+ /**
2752
+ * Whether or not the popovercontainer should close when user clicks outside of it
2753
+ */
2754
+ this.manualClose = false;
2755
+ }
2756
+ validatePlacement() {
2757
+ checkEmptyOrOneOf(this, 'placement', PLACEMENT_TYPES);
2758
+ }
2759
+ validateEdgeGap() {
2760
+ checkEmptyOrType(this, 'edgeGap', 'number');
2761
+ }
2762
+ validateSafeSpace() {
2763
+ checkEmptyOrOneOf(this, 'safeSpace', ['triangle', 'trapezoid']);
2764
+ }
2765
+ /**
2766
+ * Updates cursor position for safe space feature when popover is open.
2767
+ * Sets CSS custom properties for dynamic styling of safe area.
2768
+ * @param event MouseEvent with cursor position
2769
+ */
2770
+ mouseTrackingHandler(event) {
2771
+ this.host.style.setProperty('--post-safe-space-cursor-x', `${event.clientX}px`);
2772
+ this.host.style.setProperty('--post-safe-space-cursor-y', `${event.clientY}px`);
2773
+ }
2774
+ connectedCallback() {
2775
+ if (IS_BROWSER && !isSupported()) {
2776
+ apply();
2777
+ }
2778
+ }
2779
+ componentDidLoad() {
2780
+ this.host.addEventListener('beforetoggle', this.handleToggle.bind(this));
2781
+ }
2782
+ disconnectedCallback() {
2783
+ if (typeof this.clearAutoUpdate === 'function') {
2784
+ this.clearAutoUpdate();
2785
+ }
2786
+ }
2787
+ /**
2788
+ * Programmatically display the popovercontainer
2789
+ * @param target An element with [data-popover-target="id"] where the popovercontainer should be shown
2790
+ */
2791
+ async show(target) {
2792
+ if (this.toggleTimeoutId)
2793
+ return;
2794
+ this.eventTarget = target;
2795
+ this.calculatePosition();
2796
+ this.host.showPopover();
2797
+ }
2798
+ /**
2799
+ * Programmatically hide the popovercontainer
2800
+ */
2801
+ async hide() {
2802
+ if (!this.toggleTimeoutId) {
2803
+ this.eventTarget = null;
2804
+ this.host.hidePopover();
2805
+ }
2806
+ }
2807
+ /**
2808
+ * Toggle popovercontainer display
2809
+ * @param target An element with [data-popover-target="id"] where the popovercontainer should be shown
2810
+ * @param force Pass true to always show or false to always hide
2811
+ */
2812
+ async toggle(target, force) {
2813
+ // Prevent instant double toggle
2814
+ if (!this.toggleTimeoutId) {
2815
+ this.eventTarget = target;
2816
+ this.calculatePosition();
2817
+ this.host.togglePopover(force);
2818
+ this.toggleTimeoutId = null;
2819
+ }
2820
+ return this.host.matches(':where(:popover-open, .popover-open)');
2821
+ }
2822
+ /**
2823
+ * Start or stop auto updates based on popovercontainer events.
2824
+ * Popovercontainers can be closed or opened with other methods than class members,
2825
+ * therefore listening to the toggle event is safer for cleaning up.
2826
+ * @param e ToggleEvent
2827
+ */
2828
+ handleToggle(e) {
2829
+ this.toggleTimeoutId = window.setTimeout(() => (this.toggleTimeoutId = null), 10);
2830
+ const isOpen = e.newState === 'open';
2831
+ if (isOpen) {
2832
+ const content = this.host.querySelector('.popover-content');
2833
+ this.startAutoupdates();
2834
+ if (content && this.animation === 'pop-in') {
2835
+ popIn(content);
2836
+ }
2837
+ if (this.safeSpace)
2838
+ window.addEventListener('mousemove', this.mouseTrackingHandler.bind(this));
2839
+ // Emit event with `first` flag only true on the first open
2840
+ if (this.firstOpen) {
2841
+ this.postToggle.emit({ isOpen, first: this.firstOpen });
2842
+ this.firstOpen = false;
2843
+ return;
2844
+ }
2845
+ }
2846
+ else {
2847
+ if (typeof this.clearAutoUpdate === 'function')
2848
+ this.clearAutoUpdate();
2849
+ if (this.safeSpace)
2850
+ window.removeEventListener('mousemove', this.mouseTrackingHandler.bind(this));
2851
+ }
2852
+ this.postToggle.emit({ isOpen: isOpen, first: false });
2853
+ }
2854
+ /**
2855
+ * Start listening for DOM updates, scroll events etc. that have
2856
+ * an influence on popovercontainer positioning
2857
+ */
2858
+ startAutoupdates() {
2859
+ this.clearAutoUpdate = autoUpdate(this.eventTarget, this.host, this.calculatePosition.bind(this));
2860
+ }
2861
+ /**
2862
+ * Retrieves the dynamic height of the header
2863
+ */
2864
+ getHeaderHeight() {
2865
+ const header = document.querySelector('post-header');
2866
+ return header ? parseFloat(getComputedStyle(header).height) : 0;
2867
+ }
2868
+ async calculatePosition() {
2869
+ const { x, y, middlewareData, placement } = await this.computeMainPosition();
2870
+ const currentPlacement = placement.split('-')[0];
2871
+ // Position popover
2872
+ this.host.style.left = `${x}px`;
2873
+ this.host.style.top = `${y}px`;
2874
+ // Position arrow if enabled
2875
+ if (this.arrow && middlewareData.arrow) {
2876
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
2877
+ const staticSide = PostPopovercontainer.STATIC_SIDES[currentPlacement];
2878
+ if (staticSide) {
2879
+ Object.assign(this.arrowRef.style, {
2880
+ left: arrowX ? `${arrowX}px` : '',
2881
+ top: arrowY ? `${arrowY}px` : '',
2882
+ [staticSide]: '-5px',
2883
+ });
2884
+ }
2885
+ }
2886
+ // Handle safe space if enabled
2887
+ if (this.safeSpace && this.eventTarget) {
2888
+ await this.updateSafeSpaceBoundaries(currentPlacement);
2889
+ }
2890
+ }
2891
+ async computeMainPosition() {
2892
+ const gap = this.edgeGap;
2893
+ const middleware = [
2894
+ flip({
2895
+ padding: this.getHeaderHeight(),
2896
+ }),
2897
+ inline(),
2898
+ shift({
2899
+ padding: gap,
2900
+ limiter: limitShift({
2901
+ offset: 32,
2902
+ }),
2903
+ }),
2904
+ size({
2905
+ apply({ availableWidth, elements }) {
2906
+ Object.assign(elements.floating.style, {
2907
+ maxWidth: `${availableWidth - gap * 2}px`,
2908
+ });
2909
+ },
2910
+ }),
2911
+ offset(this.arrow ? gap + 4 : gap),
2912
+ ];
2913
+ if (this.arrow) {
2914
+ middleware.push(arrow({ element: this.arrowRef, padding: gap }));
2915
+ }
2916
+ return computePosition(this.eventTarget, this.host, {
2917
+ placement: this.placement || 'top',
2918
+ strategy: 'fixed',
2919
+ middleware,
2920
+ });
2921
+ }
2922
+ async updateSafeSpaceBoundaries(currentPlacement) {
2923
+ const targetRect = this.eventTarget.getBoundingClientRect();
2924
+ const popoverRect = this.host.getBoundingClientRect();
2925
+ const isVertical = currentPlacement === 'top' || currentPlacement === 'bottom';
2926
+ // Helper function to get positioning data based on placement
2927
+ const getPositioningData = (placement, popoverRect, targetRect) => {
2928
+ if (placement === 'top' || placement === 'bottom') {
2929
+ return {
2930
+ popover: {
2931
+ y: placement === 'top' ? popoverRect.bottom : popoverRect.top,
2932
+ xStart: popoverRect.left,
2933
+ xEnd: popoverRect.right,
2934
+ },
2935
+ trigger: {
2936
+ y: placement === 'top' ? targetRect.top : targetRect.bottom,
2937
+ xStart: targetRect.left,
2938
+ xEnd: targetRect.right,
2939
+ },
2940
+ };
2941
+ }
2942
+ else {
2943
+ // left or right
2944
+ return {
2945
+ popover: {
2946
+ x: placement === 'left' ? popoverRect.right : popoverRect.left,
2947
+ yStart: popoverRect.top,
2948
+ yEnd: popoverRect.bottom,
2949
+ },
2950
+ trigger: {
2951
+ x: placement === 'left' ? targetRect.left : targetRect.right,
2952
+ yStart: targetRect.top,
2953
+ yEnd: targetRect.bottom,
2954
+ },
2955
+ };
2956
+ }
2957
+ };
2958
+ const posData = getPositioningData(currentPlacement, popoverRect, targetRect);
2959
+ // Clear previous values
2960
+ PostPopovercontainer.PROPERTIES_TO_CLEAR.forEach(prop => {
2961
+ this.host.style.removeProperty(prop);
2962
+ });
2963
+ if (isVertical) {
2964
+ // For top/bottom placement
2965
+ this.host.style.setProperty('--post-safe-space-popover-y', `${posData.popover.y}px`);
2966
+ this.host.style.setProperty('--post-safe-space-popover-x-start', `${posData.popover.xStart}px`);
2967
+ this.host.style.setProperty('--post-safe-space-popover-x-end', `${posData.popover.xEnd}px`);
2968
+ this.host.style.setProperty('--post-safe-space-trigger-y', `${posData.trigger.y}px`);
2969
+ this.host.style.setProperty('--post-safe-space-trigger-x-start', `${posData.trigger.xStart}px`);
2970
+ this.host.style.setProperty('--post-safe-space-trigger-x-end', `${posData.trigger.xEnd}px`);
2971
+ }
2972
+ else {
2973
+ // For left/right placement
2974
+ this.host.style.setProperty('--post-safe-space-popover-x', `${posData.popover.x}px`);
2975
+ this.host.style.setProperty('--post-safe-space-popover-y-start', `${posData.popover.yStart}px`);
2976
+ this.host.style.setProperty('--post-safe-space-popover-y-end', `${posData.popover.yEnd}px`);
2977
+ this.host.style.setProperty('--post-safe-space-trigger-x', `${posData.trigger.x}px`);
2978
+ this.host.style.setProperty('--post-safe-space-trigger-y-start', `${posData.trigger.yStart}px`);
2979
+ this.host.style.setProperty('--post-safe-space-trigger-y-end', `${posData.trigger.yEnd}px`);
2980
+ }
2981
+ }
2982
+ render() {
2983
+ return (h(Host, { key: '1594b782ac56ae23eba2df3f452ad40015ace67d', "data-version": version, popover: this.manualClose ? 'manual' : 'auto' }, h("div", { key: '565cbf870aca9abbc665525a627922d1cfdb9195', class: "popover-content" }, this.arrow && (h("span", { key: 'add7d6f7b176e7365b5a0c25fa81dd2a9520e7f3', class: "arrow", ref: el => {
2984
+ this.arrowRef = el;
2985
+ } })), h("slot", { key: '308138890a4148c5c94b675e2a6b911fef1c31b5' }))));
2986
+ }
2987
+ get host() { return this; }
2988
+ static get watchers() { return {
2989
+ "placement": ["validatePlacement"],
2990
+ "edgeGap": ["validateEdgeGap"],
2991
+ "safeSpace": ["validateSafeSpace"]
2992
+ }; }
2993
+ static get style() { return postPopovercontainerCss; }
2994
+ }, [4, "post-popovercontainer", {
2995
+ "placement": [1],
2996
+ "edgeGap": [2, "edge-gap"],
2997
+ "animation": [1],
2998
+ "arrow": [4],
2999
+ "manualClose": [4, "manual-close"],
3000
+ "safeSpace": [513, "safe-space"],
3001
+ "show": [64],
3002
+ "hide": [64],
3003
+ "toggle": [64]
3004
+ }, undefined, {
3005
+ "placement": ["validatePlacement"],
3006
+ "edgeGap": ["validateEdgeGap"],
3007
+ "safeSpace": ["validateSafeSpace"]
3008
+ }]);
3009
+ PostPopovercontainer.STATIC_SIDES = {
3010
+ top: 'bottom',
3011
+ right: 'left',
3012
+ bottom: 'top',
3013
+ left: 'right',
3014
+ };
3015
+ PostPopovercontainer.PROPERTIES_TO_CLEAR = [
3016
+ '--post-safe-space-popover-x',
3017
+ '--post-safe-space-popover-y',
3018
+ '--post-safe-space-popover-x-start',
3019
+ '--post-safe-space-popover-x-end',
3020
+ '--post-safe-space-popover-y-start',
3021
+ '--post-safe-space-popover-y-end',
3022
+ '--post-safe-space-trigger-x',
3023
+ '--post-safe-space-trigger-y',
3024
+ '--post-safe-space-trigger-x-start',
3025
+ '--post-safe-space-trigger-x-end',
3026
+ '--post-safe-space-trigger-y-start',
3027
+ '--post-safe-space-trigger-y-end',
3028
+ ];
3029
+ function defineCustomElement() {
3030
+ if (typeof customElements === "undefined") {
3031
+ return;
3032
+ }
3033
+ const components = ["post-popovercontainer"];
3034
+ components.forEach(tagName => { switch (tagName) {
3035
+ case "post-popovercontainer":
3036
+ if (!customElements.get(tagName)) {
3037
+ customElements.define(tagName, PostPopovercontainer);
3038
+ }
3039
+ break;
3040
+ } });
3041
+ }
3042
+
3043
+ export { PostPopovercontainer as P, PLACEMENT_TYPES as a, defineCustomElement as d };