@swisspost/design-system-components 9.0.1 → 10.0.0-next.38

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 (568) hide show
  1. package/dist/.config/bindings.angular.js +4 -0
  2. package/dist/cjs/breakpoints-cdf1b747.js +59 -0
  3. package/dist/cjs/check-non-empty-bd99d236.js +15 -0
  4. package/dist/cjs/check-one-of-75d270b5.js +13 -0
  5. package/dist/cjs/check-type-cdbf6d29.js +21 -0
  6. package/dist/cjs/check-url-220a286c.js +19 -0
  7. package/dist/cjs/event-guard-efabc84f.js +47 -0
  8. package/dist/cjs/fade-72d5ef55.js +14 -0
  9. package/dist/cjs/get-root-8102fecd.js +17 -0
  10. package/dist/cjs/index-23e36ff7.js +37 -0
  11. package/dist/cjs/{index-e1f32cce.js → index-b60129c4.js} +35 -15
  12. package/dist/cjs/index.browser-4af21c17.js +16 -0
  13. package/dist/cjs/index.cjs.js +57 -28
  14. package/dist/cjs/loader.cjs.js +2 -2
  15. package/dist/cjs/long-press-event-6e62d113.js +266 -0
  16. package/dist/cjs/{package-93f142ae.js → package-3e61e6f3.js} +1 -1
  17. package/dist/cjs/{post-accordion-60af96cf.js → post-accordion-e54524be.js} +11 -12
  18. package/dist/cjs/post-accordion-item-86f11a16.js +64 -0
  19. package/dist/cjs/post-accordion-item.cjs.entry.js +10 -6
  20. package/dist/cjs/post-accordion.cjs.entry.js +6 -4
  21. package/dist/cjs/post-avatar-22bfd12e.js +145 -0
  22. package/dist/cjs/post-avatar.cjs.entry.js +14 -0
  23. package/dist/cjs/post-back-to-top-f682ea05.js +96 -0
  24. package/dist/cjs/post-back-to-top.cjs.entry.js +16 -0
  25. package/dist/cjs/post-banner-5c749a94.js +92 -0
  26. package/dist/cjs/post-banner.cjs.entry.js +20 -0
  27. package/dist/cjs/post-breadcrumb-item_2.cjs.entry.js +18 -0
  28. package/dist/cjs/post-breadcrumbs-76f55ae5.js +120 -0
  29. package/dist/cjs/post-breadcrumbs.cjs.entry.js +13 -0
  30. package/dist/cjs/post-card-control-161a7102.js +269 -0
  31. package/dist/cjs/post-card-control.cjs.entry.js +6 -5
  32. package/dist/cjs/post-closebutton_15.cjs.entry.js +36 -0
  33. package/dist/cjs/{post-collapsible-trigger-3de8fe4e.js → post-collapsible-trigger-6cdf4481.js} +62 -76
  34. package/dist/cjs/post-collapsible_2.cjs.entry.js +11 -7
  35. package/dist/cjs/post-components.cjs.js +2 -2
  36. package/dist/cjs/post-footer-15d78645.js +38 -0
  37. package/dist/cjs/post-footer.cjs.entry.js +12 -0
  38. package/dist/cjs/post-linkarea-095d1928.js +30 -0
  39. package/dist/cjs/post-linkarea.cjs.entry.js +11 -0
  40. package/dist/cjs/post-menu-item-387e079b.js +68 -0
  41. package/dist/cjs/post-popover-388c8091.js +135 -0
  42. package/dist/cjs/post-popover.cjs.entry.js +4 -3
  43. package/dist/cjs/{post-rating-21f9c46d.js → post-rating-246e4d89.js} +4 -4
  44. package/dist/cjs/post-rating.cjs.entry.js +3 -3
  45. package/dist/cjs/post-tab-header-0e9d0e06.js +34 -0
  46. package/dist/cjs/post-tab-header.cjs.entry.js +6 -4
  47. package/dist/cjs/{post-tab-panel-dd58f425.js → post-tab-panel-f952714f.js} +5 -4
  48. package/dist/cjs/post-tab-panel.cjs.entry.js +4 -3
  49. package/dist/cjs/{post-tabs-83191b9a.js → post-tabs-97c30d81.js} +14 -16
  50. package/dist/cjs/post-tabs.cjs.entry.js +5 -4
  51. package/dist/cjs/post-tag-58003cf0.js +47 -0
  52. package/dist/cjs/post-tag.cjs.entry.js +3 -3
  53. package/dist/cjs/post-togglebutton-87c984d8.js +4494 -0
  54. package/dist/cjs/{post-tooltip-782f020b.js → post-tooltip-28e7711a.js} +10 -6
  55. package/dist/cjs/{post-tooltip-trigger-b2aeb636.js → post-tooltip-trigger-cbc53d14.js} +17 -280
  56. package/dist/cjs/post-tooltip-trigger.cjs.entry.js +5 -4
  57. package/dist/cjs/post-tooltip.cjs.entry.js +5 -4
  58. package/dist/cjs/slide-cd1f09b3.js +28 -0
  59. package/dist/collection/animations/collapse.js +8 -6
  60. package/dist/collection/animations/fade.js +6 -2
  61. package/dist/collection/animations/slide.js +23 -0
  62. package/dist/collection/collection-manifest.json +22 -3
  63. package/dist/collection/components/post-accordion/post-accordion.css +1 -1
  64. package/dist/collection/components/post-accordion/post-accordion.js +8 -10
  65. package/dist/collection/components/post-accordion-item/post-accordion-item.css +1 -1
  66. package/dist/collection/components/post-accordion-item/post-accordion-item.js +30 -16
  67. package/dist/collection/components/post-avatar/post-avatar.css +1 -0
  68. package/dist/collection/components/post-avatar/post-avatar.js +233 -0
  69. package/dist/collection/components/post-back-to-top/post-back-to-top.css +1 -0
  70. package/dist/collection/components/post-back-to-top/post-back-to-top.js +127 -0
  71. package/dist/collection/components/post-banner/banner-types.js +1 -0
  72. package/dist/collection/components/post-banner/post-banner.css +1 -0
  73. package/dist/collection/components/{post-alert/post-alert.js → post-banner/post-banner.js} +44 -72
  74. package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.css +1 -0
  75. package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.js +96 -0
  76. package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.css +1 -0
  77. package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.js +160 -0
  78. package/dist/collection/components/post-card-control/post-card-control.css +1 -31
  79. package/dist/collection/components/post-card-control/post-card-control.js +20 -24
  80. package/dist/collection/components/post-closebutton/post-closebutton.css +1 -0
  81. package/dist/collection/components/post-closebutton/post-closebutton.js +23 -0
  82. package/dist/collection/components/post-collapsible/post-collapsible.css +1 -1
  83. package/dist/collection/components/post-collapsible/post-collapsible.js +6 -3
  84. package/dist/collection/components/post-collapsible-trigger/post-collapsible-trigger.js +43 -45
  85. package/dist/collection/components/post-footer/post-footer.css +1 -0
  86. package/dist/collection/components/post-footer/post-footer.js +75 -0
  87. package/dist/collection/components/post-header/post-header.css +1 -0
  88. package/dist/collection/components/post-header/post-header.js +320 -0
  89. package/dist/collection/components/post-icon/post-icon.js +58 -55
  90. package/dist/collection/components/post-language-option/post-language-option.css +1 -0
  91. package/dist/collection/components/post-language-option/post-language-option.js +237 -0
  92. package/dist/collection/components/post-language-switch/post-language-switch.css +1 -0
  93. package/dist/collection/components/post-language-switch/post-language-switch.js +186 -0
  94. package/dist/collection/components/post-language-switch/switch-variants.js +1 -0
  95. package/dist/collection/components/post-linkarea/post-linkarea.css +1 -0
  96. package/dist/collection/components/post-linkarea/post-linkarea.js +30 -0
  97. package/dist/collection/components/post-list/post-list.css +1 -0
  98. package/dist/collection/components/post-list/post-list.js +88 -0
  99. package/dist/collection/components/post-list-item/post-list-item.css +1 -0
  100. package/dist/collection/components/post-list-item/post-list-item.js +26 -0
  101. package/dist/collection/components/post-logo/post-logo.css +1 -1
  102. package/dist/collection/components/post-logo/post-logo.js +2 -2
  103. package/dist/collection/components/post-mainnavigation/post-mainnavigation.css +1 -0
  104. package/dist/collection/components/post-mainnavigation/post-mainnavigation.js +184 -0
  105. package/dist/collection/components/post-megadropdown/post-megadropdown.css +1 -0
  106. package/dist/collection/components/post-megadropdown/post-megadropdown.js +275 -0
  107. package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.css +1 -0
  108. package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.js +133 -0
  109. package/dist/collection/components/post-menu/post-menu.css +1 -0
  110. package/dist/collection/components/post-menu/post-menu.js +294 -0
  111. package/dist/collection/components/post-menu-item/post-menu-item.js +8 -0
  112. package/dist/collection/components/post-menu-trigger/post-menu-trigger.css +1 -0
  113. package/dist/collection/components/post-menu-trigger/post-menu-trigger.js +120 -0
  114. package/dist/collection/components/post-popover/post-popover.css +1 -31
  115. package/dist/collection/components/post-popover/post-popover.js +16 -13
  116. package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -31
  117. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +39 -6
  118. package/dist/collection/components/post-rating/post-rating.css +1 -31
  119. package/dist/collection/components/post-rating/post-rating.js +1 -1
  120. package/dist/collection/components/post-tab-header/post-tab-header.css +1 -31
  121. package/dist/collection/components/post-tab-header/post-tab-header.js +6 -5
  122. package/dist/collection/components/post-tab-panel/post-tab-panel.js +4 -3
  123. package/dist/collection/components/post-tabs/post-tabs.css +1 -1
  124. package/dist/collection/components/post-tabs/post-tabs.js +7 -15
  125. package/dist/collection/components/post-tag/post-tag.css +1 -31
  126. package/dist/collection/components/post-tag/post-tag.js +2 -2
  127. package/dist/collection/components/post-togglebutton/post-togglebutton.css +1 -0
  128. package/dist/collection/components/post-togglebutton/post-togglebutton.js +74 -0
  129. package/dist/collection/components/post-tooltip/post-tooltip.css +1 -1
  130. package/dist/collection/components/post-tooltip/post-tooltip.js +6 -3
  131. package/dist/collection/components/post-tooltip-trigger/post-tooltip-trigger.js +14 -14
  132. package/dist/collection/index.js +21 -2
  133. package/dist/collection/utils/attribute-observer.js +6 -5
  134. package/dist/collection/utils/breakpoints.js +52 -0
  135. package/dist/collection/utils/component-on-ready.js +4 -4
  136. package/dist/collection/utils/debounce.js +2 -1
  137. package/dist/collection/utils/environment.js +2 -0
  138. package/dist/collection/utils/event-guard.js +43 -0
  139. package/dist/collection/utils/get-focusable-children.js +33 -0
  140. package/dist/collection/utils/get-root.js +6 -1
  141. package/dist/collection/utils/index.js +5 -0
  142. package/dist/collection/utils/is-motion-reduced.js +2 -1
  143. package/dist/collection/utils/property-checkers/check-non-empty.js +6 -2
  144. package/dist/collection/utils/property-checkers/check-one-of.js +8 -3
  145. package/dist/collection/utils/property-checkers/check-pattern.js +8 -3
  146. package/dist/collection/utils/property-checkers/check-type.js +11 -6
  147. package/dist/collection/utils/property-checkers/check-url.js +11 -6
  148. package/dist/collection/utils/property-checkers/empty-or.js +5 -2
  149. package/dist/collection/utils/sass-export.js +8 -5
  150. package/dist/components/breakpoints.js +56 -0
  151. package/dist/components/check-non-empty.js +6 -2
  152. package/dist/components/check-one-of.js +8 -3
  153. package/dist/components/check-type.js +11 -6
  154. package/dist/components/event-guard.js +45 -0
  155. package/dist/components/fade.js +6 -2
  156. package/dist/components/get-focusable-children.js +35 -0
  157. package/dist/components/get-root.js +15 -0
  158. package/dist/components/index.browser.js +14 -0
  159. package/dist/components/index.js +21 -2
  160. package/dist/components/index2.js +25 -12
  161. package/dist/components/long-press-event.js +264 -0
  162. package/dist/components/package.js +1 -1
  163. package/dist/components/post-accordion-item2.js +37 -18
  164. package/dist/components/post-accordion2.js +8 -9
  165. package/dist/components/post-avatar.d.ts +11 -0
  166. package/dist/components/post-avatar.js +6 -0
  167. package/dist/components/post-avatar2.js +170 -0
  168. package/dist/components/post-back-to-top.d.ts +11 -0
  169. package/dist/components/post-back-to-top.js +6 -0
  170. package/dist/components/post-back-to-top2.js +121 -0
  171. package/dist/components/post-banner.d.ts +11 -0
  172. package/dist/components/post-banner.js +6 -0
  173. package/dist/components/post-banner2.js +127 -0
  174. package/dist/components/post-breadcrumb-item.d.ts +11 -0
  175. package/dist/components/post-breadcrumb-item.js +6 -0
  176. package/dist/components/post-breadcrumb-item2.js +82 -0
  177. package/dist/components/post-breadcrumbs.d.ts +11 -0
  178. package/dist/components/post-breadcrumbs.js +6 -0
  179. package/dist/components/post-breadcrumbs2.js +177 -0
  180. package/dist/components/post-card-control2.js +16 -19
  181. package/dist/components/post-closebutton.d.ts +11 -0
  182. package/dist/components/post-closebutton.js +6 -0
  183. package/dist/components/post-closebutton2.js +39 -0
  184. package/dist/components/post-collapsible-trigger2.js +47 -64
  185. package/dist/components/post-collapsible2.js +17 -12
  186. package/dist/components/post-footer.d.ts +11 -0
  187. package/dist/components/post-footer.js +6 -0
  188. package/dist/components/post-footer2.js +78 -0
  189. package/dist/components/post-header.d.ts +11 -0
  190. package/dist/components/post-header.js +6 -0
  191. package/dist/components/post-header2.js +399 -0
  192. package/dist/components/post-icon2.js +59 -55
  193. package/dist/components/post-language-option.d.ts +11 -0
  194. package/dist/components/post-language-option.js +6 -0
  195. package/dist/components/post-language-option2.js +103 -0
  196. package/dist/components/post-language-switch.d.ts +11 -0
  197. package/dist/components/post-language-switch.js +6 -0
  198. package/dist/components/post-language-switch2.js +145 -0
  199. package/dist/components/post-linkarea.d.ts +11 -0
  200. package/dist/components/post-linkarea.js +6 -0
  201. package/dist/components/post-linkarea2.js +43 -0
  202. package/dist/components/post-list-item.d.ts +11 -0
  203. package/dist/components/post-list-item.js +6 -0
  204. package/dist/components/post-list-item2.js +36 -0
  205. package/dist/components/{post-alert.d.ts → post-list.d.ts} +4 -4
  206. package/dist/components/post-list.js +6 -0
  207. package/dist/components/post-list2.js +54 -0
  208. package/dist/components/post-logo2.js +4 -3
  209. package/dist/components/post-mainnavigation.d.ts +11 -0
  210. package/dist/components/post-mainnavigation.js +6 -0
  211. package/dist/components/post-mainnavigation2.js +183 -0
  212. package/dist/components/post-megadropdown-trigger.d.ts +11 -0
  213. package/dist/components/post-megadropdown-trigger.js +6 -0
  214. package/dist/components/post-megadropdown-trigger2.js +121 -0
  215. package/dist/components/post-megadropdown.d.ts +11 -0
  216. package/dist/components/post-megadropdown.js +6 -0
  217. package/dist/components/post-megadropdown2.js +190 -0
  218. package/dist/components/post-menu-item.d.ts +11 -0
  219. package/dist/components/post-menu-item.js +6 -0
  220. package/dist/components/post-menu-item2.js +27 -0
  221. package/dist/components/post-menu-trigger.d.ts +11 -0
  222. package/dist/components/post-menu-trigger.js +6 -0
  223. package/dist/components/post-menu-trigger2.js +109 -0
  224. package/dist/components/post-menu.d.ts +11 -0
  225. package/dist/components/post-menu.js +6 -0
  226. package/dist/components/post-menu2.js +192 -0
  227. package/dist/components/post-popover2.js +20 -16
  228. package/dist/components/post-popovercontainer2.js +788 -73
  229. package/dist/components/post-rating2.js +2 -2
  230. package/dist/components/post-tab-header2.js +8 -6
  231. package/dist/components/post-tab-panel2.js +4 -3
  232. package/dist/components/post-tabs2.js +11 -13
  233. package/dist/components/post-tag2.js +2 -2
  234. package/dist/components/post-togglebutton.d.ts +11 -0
  235. package/dist/components/post-togglebutton.js +6 -0
  236. package/dist/components/post-togglebutton2.js +62 -0
  237. package/dist/components/post-tooltip-trigger2.js +14 -277
  238. package/dist/components/post-tooltip2.js +7 -3
  239. package/dist/components/slide.js +25 -0
  240. package/dist/docs.json +1977 -287
  241. package/dist/esm/breakpoints-7812702e.js +56 -0
  242. package/dist/esm/check-non-empty-258a56b3.js +13 -0
  243. package/dist/esm/check-one-of-0bee20f5.js +11 -0
  244. package/dist/esm/check-type-37d5d307.js +19 -0
  245. package/dist/esm/check-url-17962bc8.js +17 -0
  246. package/dist/esm/event-guard-538ee077.js +45 -0
  247. package/dist/esm/fade-1f3cacf4.js +11 -0
  248. package/dist/esm/get-root-1b1af46f.js +15 -0
  249. package/dist/esm/index-8f8fe5b0.js +32 -0
  250. package/dist/esm/{index-e1b64755.js → index-f4d19816.js} +35 -15
  251. package/dist/esm/index.browser-ff103197.js +14 -0
  252. package/dist/esm/index.js +33 -23
  253. package/dist/esm/loader.js +3 -3
  254. package/dist/esm/long-press-event-04d24397.js +264 -0
  255. package/dist/esm/package-33ac2576.js +3 -0
  256. package/dist/esm/{post-accordion-bcfe7e61.js → post-accordion-03796d13.js} +11 -12
  257. package/dist/esm/post-accordion-item-d29c49e5.js +62 -0
  258. package/dist/esm/post-accordion-item.entry.js +10 -6
  259. package/dist/esm/post-accordion.entry.js +6 -4
  260. package/dist/esm/post-avatar-639dc17a.js +143 -0
  261. package/dist/esm/post-avatar.entry.js +6 -0
  262. package/dist/esm/post-back-to-top-8099279e.js +94 -0
  263. package/dist/esm/post-back-to-top.entry.js +8 -0
  264. package/dist/esm/post-banner-54834fbf.js +90 -0
  265. package/dist/esm/post-banner.entry.js +12 -0
  266. package/dist/esm/post-breadcrumb-item_2.entry.js +9 -0
  267. package/dist/esm/post-breadcrumbs-caf56014.js +118 -0
  268. package/dist/esm/post-breadcrumbs.entry.js +5 -0
  269. package/dist/esm/post-card-control-b063586b.js +267 -0
  270. package/dist/esm/post-card-control.entry.js +6 -5
  271. package/dist/esm/post-closebutton_15.entry.js +14 -0
  272. package/dist/esm/{post-collapsible-trigger-3168178e.js → post-collapsible-trigger-727bcde1.js} +62 -76
  273. package/dist/esm/post-collapsible_2.entry.js +11 -7
  274. package/dist/esm/post-components.js +3 -3
  275. package/dist/esm/post-footer-16f1a8de.js +36 -0
  276. package/dist/esm/post-footer.entry.js +4 -0
  277. package/dist/esm/post-linkarea-4e4228fb.js +28 -0
  278. package/dist/esm/post-linkarea.entry.js +3 -0
  279. package/dist/esm/post-menu-item-e9dd8173.js +65 -0
  280. package/dist/esm/post-popover-46ede6b5.js +133 -0
  281. package/dist/esm/post-popover.entry.js +4 -3
  282. package/dist/esm/{post-rating-0fd5de37.js → post-rating-8d0d970b.js} +4 -4
  283. package/dist/esm/post-rating.entry.js +3 -3
  284. package/dist/esm/post-tab-header-8224c7c2.js +32 -0
  285. package/dist/esm/post-tab-header.entry.js +6 -4
  286. package/dist/esm/{post-tab-panel-6b1219e0.js → post-tab-panel-dfdeccd3.js} +5 -4
  287. package/dist/esm/post-tab-panel.entry.js +4 -3
  288. package/dist/esm/{post-tabs-b8ff3c5d.js → post-tabs-fabd0569.js} +14 -16
  289. package/dist/esm/post-tabs.entry.js +5 -4
  290. package/dist/esm/post-tag-13994238.js +45 -0
  291. package/dist/esm/post-tag.entry.js +3 -3
  292. package/dist/esm/post-togglebutton-87967c5b.js +4478 -0
  293. package/dist/esm/{post-tooltip-aa745743.js → post-tooltip-eecaa4c7.js} +10 -6
  294. package/dist/esm/{post-tooltip-trigger-ce0b4106.js → post-tooltip-trigger-642cbb22.js} +17 -280
  295. package/dist/esm/post-tooltip-trigger.entry.js +5 -4
  296. package/dist/esm/post-tooltip.entry.js +5 -4
  297. package/dist/esm/slide-cd2850ee.js +25 -0
  298. package/dist/post-components/index.esm.js +1 -1
  299. package/dist/post-components/p-0539071d.js +1 -0
  300. package/dist/post-components/p-0889c759.js +1 -0
  301. package/dist/post-components/p-0dcd25ab.js +1 -0
  302. package/dist/post-components/p-181c73d5.js +1 -0
  303. package/dist/post-components/p-19317b15.js +8 -0
  304. package/dist/post-components/p-1ef9415b.js +1 -0
  305. package/dist/post-components/p-24d0695f.entry.js +1 -0
  306. package/dist/post-components/p-2e50a07d.entry.js +1 -0
  307. package/dist/post-components/p-30eb4d87.js +1 -0
  308. package/dist/post-components/p-46008c18.entry.js +1 -0
  309. package/dist/post-components/p-47ab2c2b.entry.js +1 -0
  310. package/dist/post-components/p-4c049de0.entry.js +1 -0
  311. package/dist/post-components/p-4c4acc32.entry.js +1 -0
  312. package/dist/post-components/p-5d473fcd.js +1 -0
  313. package/dist/post-components/p-5d539b30.js +1 -0
  314. package/dist/post-components/p-64e3de38.js +1 -0
  315. package/dist/post-components/p-6783e509.entry.js +1 -0
  316. package/dist/post-components/p-692ba59d.js +1 -0
  317. package/dist/post-components/p-6933fb57.entry.js +1 -0
  318. package/dist/post-components/p-6b31a76a.js +1 -0
  319. package/dist/post-components/p-72197a6b.js +1 -0
  320. package/dist/post-components/p-722ffaae.js +1 -0
  321. package/dist/post-components/p-7709c14a.js +1 -0
  322. package/dist/post-components/p-77910344.entry.js +1 -0
  323. package/dist/post-components/p-80e5100e.entry.js +1 -0
  324. package/dist/post-components/p-84fbf49c.js +1 -0
  325. package/dist/post-components/p-85fdc2d3.js +1 -0
  326. package/dist/post-components/p-8c09291c.js +1 -0
  327. package/dist/post-components/p-8db32dab.js +8 -0
  328. package/dist/post-components/p-93da1a5f.js +1 -0
  329. package/dist/post-components/p-9b052461.js +1 -0
  330. package/dist/post-components/p-9b8ee310.entry.js +1 -0
  331. package/dist/post-components/{p-3eab790d.js → p-9e461613.js} +2 -2
  332. package/dist/post-components/p-9efb84d3.entry.js +1 -0
  333. package/dist/post-components/p-9fbf2f82.entry.js +1 -0
  334. package/dist/post-components/p-a07f85ee.js +1 -0
  335. package/dist/post-components/p-a25019de.js +1 -0
  336. package/dist/post-components/p-a710ee00.js +1 -0
  337. package/dist/post-components/p-b94e5b4d.entry.js +1 -0
  338. package/dist/post-components/p-c2348d3d.js +1 -0
  339. package/dist/post-components/p-c65f32b0.js +1 -0
  340. package/dist/post-components/p-c6b03446.entry.js +1 -0
  341. package/dist/post-components/p-d0dfd5f9.js +1 -0
  342. package/dist/post-components/p-d45df336.js +1 -0
  343. package/dist/post-components/p-d4890d50.entry.js +1 -0
  344. package/dist/post-components/p-d5210531.entry.js +1 -0
  345. package/dist/post-components/p-dd39c542.entry.js +1 -0
  346. package/dist/post-components/p-df6c8a4c.js +1 -0
  347. package/dist/post-components/p-e068a41e.js +1 -0
  348. package/dist/post-components/p-e585c6fe.js +1 -0
  349. package/dist/post-components/p-f2c4a48d.js +1 -0
  350. package/dist/post-components/p-f31b9b5d.entry.js +1 -0
  351. package/dist/post-components/p-f58252d5.entry.js +1 -0
  352. package/dist/post-components/p-fda767f0.js +1 -0
  353. package/dist/post-components/post-components.esm.js +1 -1
  354. package/dist/types/animations/collapse.d.ts +2 -2
  355. package/dist/types/animations/fade.d.ts +2 -2
  356. package/dist/types/animations/slide.d.ts +2 -0
  357. package/dist/types/components/post-accordion/post-accordion.d.ts +1 -1
  358. package/dist/types/components/post-accordion-item/post-accordion-item.d.ts +8 -2
  359. package/dist/types/components/post-avatar/post-avatar.d.ts +51 -0
  360. package/dist/types/components/post-back-to-top/post-back-to-top.d.ts +21 -0
  361. package/dist/types/components/post-banner/banner-types.d.ts +2 -0
  362. package/dist/types/components/post-banner/post-banner.d.ts +49 -0
  363. package/dist/types/components/post-breadcrumb-item/post-breadcrumb-item.d.ts +20 -0
  364. package/dist/types/components/post-breadcrumbs/post-breadcrumbs.d.ts +30 -0
  365. package/dist/types/components/post-card-control/post-card-control.d.ts +9 -9
  366. package/dist/types/components/post-closebutton/post-closebutton.d.ts +7 -0
  367. package/dist/types/components/post-collapsible-trigger/post-collapsible-trigger.d.ts +9 -14
  368. package/dist/types/components/post-footer/post-footer.d.ts +23 -0
  369. package/dist/types/components/post-header/post-header.d.ts +52 -0
  370. package/dist/types/components/post-icon/post-icon.d.ts +10 -6
  371. package/dist/types/components/post-language-option/post-language-option.d.ts +49 -0
  372. package/dist/types/components/post-language-switch/post-language-switch.d.ts +39 -0
  373. package/dist/types/components/post-language-switch/switch-variants.d.ts +2 -0
  374. package/dist/types/components/post-linkarea/post-linkarea.d.ts +5 -0
  375. package/dist/types/components/post-list/post-list.d.ts +24 -0
  376. package/dist/types/components/post-list-item/post-list-item.d.ts +8 -0
  377. package/dist/types/components/post-mainnavigation/post-mainnavigation.d.ts +46 -0
  378. package/dist/types/components/post-megadropdown/post-megadropdown.d.ts +59 -0
  379. package/dist/types/components/post-megadropdown-trigger/post-megadropdown-trigger.d.ts +33 -0
  380. package/dist/types/components/post-menu/post-menu.d.ts +49 -0
  381. package/dist/types/components/post-menu-item/post-menu-item.d.ts +3 -0
  382. package/dist/types/components/post-menu-trigger/post-menu-trigger.d.ts +28 -0
  383. package/dist/types/components/post-popover/post-popover.d.ts +6 -4
  384. package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +9 -1
  385. package/dist/types/components/post-tab-header/post-tab-header.d.ts +1 -1
  386. package/dist/types/components/post-tabs/post-tabs.d.ts +1 -1
  387. package/dist/types/components/post-tag/post-tag.d.ts +2 -2
  388. package/dist/types/components/post-togglebutton/post-togglebutton.d.ts +15 -0
  389. package/dist/types/components/post-tooltip/post-tooltip.d.ts +1 -0
  390. package/dist/types/components/post-tooltip-trigger/post-tooltip-trigger.d.ts +0 -1
  391. package/dist/types/components.d.ts +603 -50
  392. package/dist/types/home/runner/work/design-system/design-system/packages/components/.stencil/.config/bindings.angular.d.ts +2 -0
  393. package/dist/types/index.d.ts +22 -3
  394. package/dist/types/popover-fn.d.ts +11 -0
  395. package/dist/types/utils/attribute-observer.d.ts +1 -1
  396. package/dist/types/utils/breakpoints.d.ts +12 -0
  397. package/dist/types/utils/component-on-ready.d.ts +1 -1
  398. package/dist/types/utils/environment.d.ts +2 -0
  399. package/dist/types/utils/event-guard.d.ts +4 -0
  400. package/dist/types/utils/get-focusable-children.d.ts +1 -0
  401. package/dist/types/utils/get-root.d.ts +5 -1
  402. package/dist/types/utils/index.d.ts +5 -0
  403. package/dist/types/utils/property-checkers/check-non-empty.d.ts +3 -1
  404. package/dist/types/utils/property-checkers/check-one-of.d.ts +3 -1
  405. package/dist/types/utils/property-checkers/check-pattern.d.ts +3 -1
  406. package/dist/types/utils/property-checkers/check-type.d.ts +3 -1
  407. package/dist/types/utils/property-checkers/check-url.d.ts +3 -1
  408. package/dist/types/utils/property-checkers/index.d.ts +12 -4
  409. package/dist/types/utils/sass-export.d.ts +5 -1
  410. package/loaders/breakpoints.js +56 -0
  411. package/loaders/check-non-empty.js +6 -2
  412. package/loaders/check-one-of.js +8 -3
  413. package/loaders/check-type.js +11 -6
  414. package/loaders/event-guard.js +45 -0
  415. package/loaders/fade.js +6 -2
  416. package/loaders/get-focusable-children.js +35 -0
  417. package/loaders/get-root.js +15 -0
  418. package/loaders/index.browser.js +14 -0
  419. package/loaders/index.d.ts +40 -2
  420. package/loaders/index.js +22 -2
  421. package/loaders/index2.js +25 -12
  422. package/loaders/long-press-event.js +264 -0
  423. package/loaders/package.js +1 -1
  424. package/loaders/post-accordion-item.js +1 -82
  425. package/loaders/post-accordion-item2.js +103 -0
  426. package/loaders/post-accordion.js +8 -9
  427. package/loaders/post-avatar.d.ts +11 -0
  428. package/loaders/post-avatar.js +173 -0
  429. package/loaders/post-back-to-top.d.ts +11 -0
  430. package/loaders/post-back-to-top.js +124 -0
  431. package/loaders/post-banner.d.ts +11 -0
  432. package/loaders/post-banner.js +130 -0
  433. package/loaders/post-breadcrumb-item.d.ts +11 -0
  434. package/loaders/post-breadcrumb-item.js +6 -0
  435. package/loaders/post-breadcrumb-item2.js +82 -0
  436. package/loaders/post-breadcrumbs.d.ts +11 -0
  437. package/loaders/post-breadcrumbs.js +180 -0
  438. package/loaders/post-card-control.js +16 -19
  439. package/loaders/post-closebutton.d.ts +11 -0
  440. package/loaders/post-closebutton.js +42 -0
  441. package/loaders/post-collapsible-trigger2.js +47 -64
  442. package/loaders/post-collapsible2.js +16 -11
  443. package/loaders/post-footer.d.ts +11 -0
  444. package/loaders/post-footer.js +81 -0
  445. package/loaders/post-header.d.ts +11 -0
  446. package/loaders/post-header.js +402 -0
  447. package/loaders/post-icon2.js +59 -55
  448. package/loaders/post-language-option.d.ts +11 -0
  449. package/loaders/post-language-option.js +106 -0
  450. package/loaders/post-language-switch.d.ts +11 -0
  451. package/loaders/post-language-switch.js +148 -0
  452. package/loaders/post-linkarea.d.ts +11 -0
  453. package/loaders/post-linkarea.js +46 -0
  454. package/loaders/post-list-item.d.ts +11 -0
  455. package/loaders/post-list-item.js +39 -0
  456. package/loaders/{post-alert.d.ts → post-list.d.ts} +4 -4
  457. package/loaders/post-list.js +57 -0
  458. package/loaders/post-logo.js +5 -4
  459. package/loaders/post-mainnavigation.d.ts +11 -0
  460. package/loaders/post-mainnavigation.js +186 -0
  461. package/loaders/post-megadropdown-trigger.d.ts +11 -0
  462. package/loaders/post-megadropdown-trigger.js +124 -0
  463. package/loaders/post-megadropdown.d.ts +11 -0
  464. package/loaders/post-megadropdown.js +193 -0
  465. package/loaders/post-menu-item.d.ts +11 -0
  466. package/loaders/post-menu-item.js +6 -0
  467. package/loaders/post-menu-item2.js +27 -0
  468. package/loaders/post-menu-trigger.d.ts +11 -0
  469. package/loaders/post-menu-trigger.js +6 -0
  470. package/loaders/post-menu-trigger2.js +109 -0
  471. package/loaders/post-menu.d.ts +11 -0
  472. package/loaders/post-menu.js +6 -0
  473. package/loaders/post-menu2.js +192 -0
  474. package/loaders/post-popover.js +20 -16
  475. package/loaders/post-popovercontainer2.js +788 -73
  476. package/loaders/post-rating.js +2 -2
  477. package/loaders/post-tab-header.js +8 -6
  478. package/loaders/post-tab-panel.js +4 -3
  479. package/loaders/post-tabs.js +11 -13
  480. package/loaders/post-tag.js +2 -2
  481. package/loaders/post-togglebutton.d.ts +11 -0
  482. package/loaders/post-togglebutton.js +65 -0
  483. package/loaders/post-tooltip-trigger.js +14 -277
  484. package/loaders/post-tooltip.js +7 -3
  485. package/loaders/slide.js +25 -0
  486. package/package.json +45 -33
  487. package/dist/cjs/check-non-empty-eeaa8f77.js +0 -11
  488. package/dist/cjs/check-one-of-f4f5d0c0.js +0 -8
  489. package/dist/cjs/check-type-64af82a9.js +0 -16
  490. package/dist/cjs/fade-35a3633a.js +0 -10
  491. package/dist/cjs/index-824d2b71.js +0 -39
  492. package/dist/cjs/post-accordion-item-744c881d.js +0 -52
  493. package/dist/cjs/post-alert-2a768f58.js +0 -99
  494. package/dist/cjs/post-alert.cjs.entry.js +0 -17
  495. package/dist/cjs/post-card-control-197c8e44.js +0 -272
  496. package/dist/cjs/post-icon-df629079.js +0 -139
  497. package/dist/cjs/post-icon.cjs.entry.js +0 -16
  498. package/dist/cjs/post-logo-7caeb918.js +0 -39
  499. package/dist/cjs/post-logo.cjs.entry.js +0 -15
  500. package/dist/cjs/post-popover-090c3d01.js +0 -131
  501. package/dist/cjs/post-popovercontainer-872681bf.js +0 -2281
  502. package/dist/cjs/post-popovercontainer.cjs.entry.js +0 -11
  503. package/dist/cjs/post-tab-header-422d0f03.js +0 -32
  504. package/dist/cjs/post-tag-c72183f2.js +0 -47
  505. package/dist/collection/components/post-alert/alert-types.js +0 -1
  506. package/dist/collection/components/post-alert/post-alert.css +0 -35
  507. package/dist/components/post-alert.js +0 -6
  508. package/dist/components/post-alert2.js +0 -136
  509. package/dist/esm/check-non-empty-58bd6b17.js +0 -9
  510. package/dist/esm/check-one-of-6b3ef8eb.js +0 -6
  511. package/dist/esm/check-type-8828dbe4.js +0 -14
  512. package/dist/esm/fade-7fd71785.js +0 -7
  513. package/dist/esm/index-69587a51.js +0 -34
  514. package/dist/esm/package-45827c3b.js +0 -3
  515. package/dist/esm/post-accordion-item-8869c90b.js +0 -50
  516. package/dist/esm/post-alert-21fd0068.js +0 -97
  517. package/dist/esm/post-alert.entry.js +0 -9
  518. package/dist/esm/post-card-control-60c132dc.js +0 -270
  519. package/dist/esm/post-icon-2e2e18ad.js +0 -137
  520. package/dist/esm/post-icon.entry.js +0 -8
  521. package/dist/esm/post-logo-f364eb72.js +0 -37
  522. package/dist/esm/post-logo.entry.js +0 -7
  523. package/dist/esm/post-popover-697201cd.js +0 -129
  524. package/dist/esm/post-popovercontainer-2b5f37fb.js +0 -2279
  525. package/dist/esm/post-popovercontainer.entry.js +0 -3
  526. package/dist/esm/post-tab-header-c8898fa2.js +0 -30
  527. package/dist/esm/post-tag-83470f28.js +0 -45
  528. package/dist/post-components/p-08dc45bb.entry.js +0 -1
  529. package/dist/post-components/p-1a48d1b0.js +0 -1
  530. package/dist/post-components/p-2737eaf5.js +0 -1
  531. package/dist/post-components/p-2b61a526.entry.js +0 -1
  532. package/dist/post-components/p-3f5bf5d9.entry.js +0 -1
  533. package/dist/post-components/p-40e5bb56.entry.js +0 -1
  534. package/dist/post-components/p-4a3f67ab.js +0 -1
  535. package/dist/post-components/p-56ca6bb5.js +0 -1
  536. package/dist/post-components/p-58cbb854.entry.js +0 -1
  537. package/dist/post-components/p-5c557e64.js +0 -1
  538. package/dist/post-components/p-5ce2abc9.entry.js +0 -1
  539. package/dist/post-components/p-5f08d625.js +0 -15
  540. package/dist/post-components/p-611b3c41.js +0 -1
  541. package/dist/post-components/p-7069ac74.entry.js +0 -1
  542. package/dist/post-components/p-755b2746.js +0 -1
  543. package/dist/post-components/p-788e64fb.js +0 -1
  544. package/dist/post-components/p-799cf60e.js +0 -1
  545. package/dist/post-components/p-7bbcc8ee.js +0 -1
  546. package/dist/post-components/p-7cdf9571.entry.js +0 -1
  547. package/dist/post-components/p-7e4181ce.entry.js +0 -1
  548. package/dist/post-components/p-9409f729.js +0 -1
  549. package/dist/post-components/p-a07846ea.js +0 -1
  550. package/dist/post-components/p-a4560368.js +0 -1
  551. package/dist/post-components/p-a503cb2c.entry.js +0 -1
  552. package/dist/post-components/p-b095519d.js +0 -1
  553. package/dist/post-components/p-b46e2451.js +0 -1
  554. package/dist/post-components/p-b7207224.js +0 -1
  555. package/dist/post-components/p-bafc0491.js +0 -1
  556. package/dist/post-components/p-c078fd94.entry.js +0 -1
  557. package/dist/post-components/p-c0aebe5e.entry.js +0 -1
  558. package/dist/post-components/p-c7e4acde.js +0 -1
  559. package/dist/post-components/p-ca71a3ff.entry.js +0 -1
  560. package/dist/post-components/p-d582cc10.js +0 -1
  561. package/dist/post-components/p-e49f57c0.entry.js +0 -1
  562. package/dist/post-components/p-eb712f9b.entry.js +0 -1
  563. package/dist/post-components/p-eebd060d.js +0 -1
  564. package/dist/post-components/p-f7cead60.entry.js +0 -1
  565. package/dist/post-components/p-ffd75503.js +0 -1
  566. package/dist/types/components/post-alert/alert-types.d.ts +0 -2
  567. package/dist/types/components/post-alert/post-alert.d.ts +0 -54
  568. package/loaders/post-alert.js +0 -139
@@ -0,0 +1,4494 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-b60129c4.js');
4
+ const _package = require('./package-3e61e6f3.js');
5
+ const slide = require('./slide-cd1f09b3.js');
6
+ const eventGuard = require('./event-guard-efabc84f.js');
7
+ const breakpoints = require('./breakpoints-cdf1b747.js');
8
+ const index$1 = require('./index-23e36ff7.js');
9
+ const checkNonEmpty = require('./check-non-empty-bd99d236.js');
10
+ const checkType = require('./check-type-cdbf6d29.js');
11
+ const index_browser = require('./index.browser-4af21c17.js');
12
+ const getRoot = require('./get-root-8102fecd.js');
13
+
14
+ const focusableSelector = `:where(${[
15
+ 'button',
16
+ 'input:not([type="hidden"])',
17
+ '[tabindex]',
18
+ 'select',
19
+ 'textarea',
20
+ '[contenteditable]',
21
+ 'a[href]',
22
+ 'iframe',
23
+ 'audio[controls]',
24
+ 'video[controls]',
25
+ 'area[href]',
26
+ 'details > summary:first-of-type',
27
+ ].join(',')})`;
28
+ const focusDisablingSelector = `:where(${[
29
+ '[inert]',
30
+ '[inert] *',
31
+ ':disabled',
32
+ 'dialog:not([open]) *',
33
+ '[popover]:not(:popover-open) *',
34
+ 'details:not([open]) > *:not(details > summary:first-of-type)',
35
+ 'details:not([open]) > *:not(details > summary:first-of-type) *',
36
+ '[tabindex^="-"]',
37
+ '[hidden]:not([hidden="false"])',
38
+ ].join(',')})`;
39
+ function getFocusableChildren(element) {
40
+ const focusableChildren = element.querySelectorAll(`${focusableSelector}:not(${focusDisablingSelector})`);
41
+ const visibleFocusableChildren = Array.from(focusableChildren).filter(child => {
42
+ const style = window.getComputedStyle(child.parentElement);
43
+ return style.display !== 'none' && style.visibility !== 'hidden';
44
+ });
45
+ return visibleFocusableChildren;
46
+ }
47
+
48
+ const postClosebuttonCss = ".btn-icon-close{padding:0;border:unset;min-height:unset;min-width:unset;width:var(--post-device-sizing-notification-1);height:var(--post-device-sizing-notification-1);border-radius:var(--post-device-border-radius-round);background-color:var(--post-scheme-color-interactive-button-tertiary-enabled-bg);color:var(--post-scheme-color-interactive-button-tertiary-enabled-fg)}.btn-icon-close>post-icon{min-width:var(--post-device-sizing-interactive-icon-size4);width:var(--post-device-sizing-interactive-icon-size4);height:var(--post-device-sizing-interactive-icon-size4)}.btn-icon-close:not(:disabled):hover,.btn-icon-close.pretend-hover{cursor:pointer;background-color:var(--post-scheme-color-interactive-button-tertiary-hover-bg);color:var(--post-scheme-color-interactive-button-tertiary-hover-fg)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.btn-icon-close:not(:disabled):hover,.btn-icon-close.pretend-hover{color:HighlightText !important}}.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}";
49
+ const PostClosebuttonStyle0 = postClosebuttonCss;
50
+
51
+ const PostClosebutton = class {
52
+ constructor(hostRef) {
53
+ index.registerInstance(this, hostRef);
54
+ }
55
+ render() {
56
+ return (index.h(index.Host, { key: 'cfa55f799fdf9ad0f3ac1eb296e063b5001de997', "data-version": _package.version }, index.h("button", { key: '7c8a084f6d7278329ddfb5fc4b2b8f992a185666', class: "btn btn-icon-close", type: "button" }, index.h("post-icon", { key: 'fc74ccb4f0c4c091a02a41cdef918d6c3b065c8c', "aria-hidden": "true", name: "closex" }), index.h("span", { key: '98478b013714df6d82c6c2f533ac8ecd2abae778', class: "visually-hidden" }, index.h("slot", { key: '109e2bca4436986dd037d8c29088cc79395bc200' })))));
57
+ }
58
+ get host() { return index.getElement(this); }
59
+ };
60
+ PostClosebutton.style = PostClosebuttonStyle0;
61
+
62
+ /* eslint-disable no-undefined,no-param-reassign,no-shadow */
63
+
64
+ /**
65
+ * Throttle execution of a function. Especially useful for rate limiting
66
+ * execution of handlers on events like resize and scroll.
67
+ *
68
+ * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
69
+ * are most useful.
70
+ * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
71
+ * as-is, to `callback` when the throttled-function is executed.
72
+ * @param {object} [options] - An object to configure options.
73
+ * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
74
+ * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
75
+ * one final time after the last throttled-function call. (After the throttled-function has not been called for
76
+ * `delay` milliseconds, the internal counter is reset).
77
+ * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
78
+ * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
79
+ * callback will never executed if both noLeading = true and noTrailing = true.
80
+ * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
81
+ * false (at end), schedule `callback` to execute after `delay` ms.
82
+ *
83
+ * @returns {Function} A new, throttled, function.
84
+ */
85
+ function throttle (delay, callback, options) {
86
+ var _ref = options || {},
87
+ _ref$noTrailing = _ref.noTrailing,
88
+ noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing,
89
+ _ref$noLeading = _ref.noLeading,
90
+ noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading,
91
+ _ref$debounceMode = _ref.debounceMode,
92
+ debounceMode = _ref$debounceMode === void 0 ? undefined : _ref$debounceMode;
93
+ /*
94
+ * After wrapper has stopped being called, this timeout ensures that
95
+ * `callback` is executed at the proper times in `throttle` and `end`
96
+ * debounce modes.
97
+ */
98
+ var timeoutID;
99
+ var cancelled = false;
100
+
101
+ // Keep track of the last time `callback` was executed.
102
+ var lastExec = 0;
103
+
104
+ // Function to clear existing timeout
105
+ function clearExistingTimeout() {
106
+ if (timeoutID) {
107
+ clearTimeout(timeoutID);
108
+ }
109
+ }
110
+
111
+ // Function to cancel next exec
112
+ function cancel(options) {
113
+ var _ref2 = options || {},
114
+ _ref2$upcomingOnly = _ref2.upcomingOnly,
115
+ upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;
116
+ clearExistingTimeout();
117
+ cancelled = !upcomingOnly;
118
+ }
119
+
120
+ /*
121
+ * The `wrapper` function encapsulates all of the throttling / debouncing
122
+ * functionality and when executed will limit the rate at which `callback`
123
+ * is executed.
124
+ */
125
+ function wrapper() {
126
+ for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {
127
+ arguments_[_key] = arguments[_key];
128
+ }
129
+ var self = this;
130
+ var elapsed = Date.now() - lastExec;
131
+ if (cancelled) {
132
+ return;
133
+ }
134
+
135
+ // Execute `callback` and update the `lastExec` timestamp.
136
+ function exec() {
137
+ lastExec = Date.now();
138
+ callback.apply(self, arguments_);
139
+ }
140
+
141
+ /*
142
+ * If `debounceMode` is true (at begin) this is used to clear the flag
143
+ * to allow future `callback` executions.
144
+ */
145
+ function clear() {
146
+ timeoutID = undefined;
147
+ }
148
+ if (!noLeading && debounceMode && !timeoutID) {
149
+ /*
150
+ * Since `wrapper` is being called for the first time and
151
+ * `debounceMode` is true (at begin), execute `callback`
152
+ * and noLeading != true.
153
+ */
154
+ exec();
155
+ }
156
+ clearExistingTimeout();
157
+ if (debounceMode === undefined && elapsed > delay) {
158
+ if (noLeading) {
159
+ /*
160
+ * In throttle mode with noLeading, if `delay` time has
161
+ * been exceeded, update `lastExec` and schedule `callback`
162
+ * to execute after `delay` ms.
163
+ */
164
+ lastExec = Date.now();
165
+ if (!noTrailing) {
166
+ timeoutID = setTimeout(debounceMode ? clear : exec, delay);
167
+ }
168
+ } else {
169
+ /*
170
+ * In throttle mode without noLeading, if `delay` time has been exceeded, execute
171
+ * `callback`.
172
+ */
173
+ exec();
174
+ }
175
+ } else if (noTrailing !== true) {
176
+ /*
177
+ * In trailing throttle mode, since `delay` time has not been
178
+ * exceeded, schedule `callback` to execute `delay` ms after most
179
+ * recent execution.
180
+ *
181
+ * If `debounceMode` is true (at begin), schedule `clear` to execute
182
+ * after `delay` ms.
183
+ *
184
+ * If `debounceMode` is false (at end), schedule `callback` to
185
+ * execute after `delay` ms.
186
+ */
187
+ timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
188
+ }
189
+ }
190
+ wrapper.cancel = cancel;
191
+
192
+ // Return the wrapper function.
193
+ return wrapper;
194
+ }
195
+
196
+ const postHeaderCss = "*,::before,::after{box-sizing:border-box}:host{z-index:1020;position:relative;--post-global-header-top:calc( (var(--post-global-header-height) - var(--post-global-header-reduced-height)) * -1 );--post-local-header-top:calc( -1 * (var(--post-local-header-height) - var(--post-main-navigation-height)) + var(--post-global-header-reduced-height) );--post-logo-height:calc(var(--post-global-header-height) - var(--post-header-scroll-top, 0px));--post-global-controls-top:calc(min((var(--post-header-scroll-top) / 4), 20px) * -1)}:host:has(.global-sub>*:not(.logo):focus-within),:host:has(.local-sub:focus-within){--post-global-header-top:0;--post-local-header-top:var(--post-global-header-height);--post-logo-height:var(--post-global-header-height);--post-global-controls-top:0}:host(:not(:has([slot=title]))) .local-header{padding-block-start:0}:host(:not(:has([slot=title]))) .local-sub{display:none}.d-flex{display:flex}.space-between{justify-content:space-between}.global-header{background-color:#fc0;display:flex;justify-content:space-between;position:sticky;padding-inline:4px;height:var(--post-global-header-height)}@media screen and (max-width: 1023.98px){.global-header{z-index:3;inset-block-start:0}}@media screen and (min-width: 1024px){.global-header{z-index:5;padding-inline-end:12px;inset-block-start:var(--post-global-header-top);transition:inset-block-start .2s ease-in-out}}.global-sub{display:flex;align-items:center;gap:24px}@media screen and (min-width: 1024px){.global-sub:not(:has(.logo)){position:relative;transition:inset-block-start .2s ease-in-out;inset-block-start:var(--post-global-controls-top)}}.align-end{align-items:flex-end}.logo{flex:1 0 auto;height:var(--post-global-header-height);width:var(--post-global-header-height);min-height:var(--post-global-header-reduced-height);align-self:flex-end}@media screen and (min-width: 1024px){.logo{transition:height .2 ease-in-out;height:var(--post-logo-height)}}::slotted(ul){margin-block:0 !important;list-style:none;display:flex;padding-inline-start:0;gap:1rem;flex-shrink:0 !important}.local-header{display:flex;position:sticky;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px;min-height:var(--post-local-header-min-height);background:#fff;transition:box-shadow .2s ease-in-out}.local-header::after{content:\"\";position:absolute;width:100%;height:1px;background-color:#e1e0dc;inset-block-end:-1px;z-index:1}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.local-header::after{background-color:Highlight}}@media screen and (min-width: 1024px){.local-header{z-index:3;inset-block-start:var(--post-local-header-top);padding-block-start:18px;box-shadow:var(--post-device-elevation-300);transition:box-shadow .2s ease-in-out,inset-block-start .2s ease-in-out}}@media screen and (max-width: 1023.98px){.local-header{z-index:2;inset-block-start:var(--post-global-header-height);padding-block:8px;flex-wrap:wrap;gap:12px}.local-header.local-header-mobile-extended::after{inset-block-end:0}.local-header:not(.local-header-mobile-extended){box-shadow:var(--post-device-elevation-300)}}.local-sub{margin-inline-end:8px}@media screen and (max-width: 1023.98px){.local-sub{margin-inline-end:4px}}::slotted(.list-inline){margin:0 !important;z-index:3 !important;position:relative !important}@media screen and (min-width: 1024px){.mobile-toggle{display:none}}.navigation{width:100%}@media screen and (min-width: 1024px){.navigation{inset-block-start:var(--post-global-header-reduced-height)}.navigation::before{display:block;content:\"\";position:absolute;inset:0;z-index:2;background:#fff}}@media screen and (max-width: 1023.98px){.navigation{position:sticky;z-index:1;inset-inline:0;inset-block-start:var(--post-header-height)}.mobile-menu{background-color:#fafafa}::slotted(post-mainnavigation),.navigation-footer{display:none;flex-direction:column;padding-block:16px 24px;padding-inline:32px}.navigation.extended ::slotted(post-mainnavigation),.navigation.extended .navigation-footer{display:flex}.navigation.extended>div{display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;height:calc(min(var(--post-header-scroll-parent-height, 100dvh),100dvh) - var(--post-header-height))}.navigation.extended.megadropdown-open>div{overflow-y:hidden}.navigation.extended ::slotted(post-mainnavigation){flex-grow:1 !important}::slotted(post-mainnavigation){gap:32px}.navigation-footer{background-color:#f0efed;gap:24px}}@media screen and (max-width: 599.98px){::slotted(post-mainnavigation),.navigation-footer{padding-inline:16px}}";
197
+ const PostHeaderStyle0 = postHeaderCss;
198
+
199
+ const PostHeader = class {
200
+ get scrollParent() {
201
+ const frozenScrollParent = document.querySelector('[data-post-scroll-locked]');
202
+ if (frozenScrollParent)
203
+ return frozenScrollParent;
204
+ let element = this.host.parentElement;
205
+ while (element) {
206
+ const overflow = getComputedStyle(element).overflowY;
207
+ if (['auto', 'scroll'].includes(overflow)) {
208
+ return element;
209
+ }
210
+ element = element.parentElement;
211
+ }
212
+ return document.body;
213
+ }
214
+ lockBody(newValue, _oldValue, propName) {
215
+ const scrollParent = this.scrollParent;
216
+ const mobileMenuExtended = propName === 'mobileMenuExtended' ? newValue : this.mobileMenuExtended;
217
+ if (this.device !== 'desktop' && mobileMenuExtended) {
218
+ scrollParent.setAttribute('data-post-scroll-locked', '');
219
+ this.host.addEventListener('keydown', this.keyboardHandler);
220
+ }
221
+ else {
222
+ scrollParent.removeAttribute('data-post-scroll-locked');
223
+ this.host.removeEventListener('keydown', this.keyboardHandler);
224
+ }
225
+ }
226
+ constructor(hostRef) {
227
+ index.registerInstance(this, hostRef);
228
+ this.postUpdateDevice = index.createEvent(this, "postUpdateDevice", 7);
229
+ this.throttledResize = throttle(50, () => this.handleResize());
230
+ this.megedropdownStateHandler = (event) => {
231
+ eventGuard.eventGuard(this.host, event, {
232
+ targetLocalName: 'post-megadropdown',
233
+ delegatorSelector: 'post-header',
234
+ }, () => {
235
+ this.megadropdownOpen = event.detail.isVisible;
236
+ });
237
+ };
238
+ this.device = null;
239
+ this.mobileMenuExtended = false;
240
+ this.megadropdownOpen = false;
241
+ this.handleScrollEvent = this.handleScrollEvent.bind(this);
242
+ this.updateScrollParentHeight = this.updateScrollParentHeight.bind(this);
243
+ this.updateLocalHeaderHeight = this.updateLocalHeaderHeight.bind(this);
244
+ this.megedropdownStateHandler = this.megedropdownStateHandler.bind(this);
245
+ this.keyboardHandler = this.keyboardHandler.bind(this);
246
+ this.handleLinkClick = this.handleLinkClick.bind(this);
247
+ }
248
+ connectedCallback() {
249
+ window.addEventListener('resize', this.throttledResize, { passive: true });
250
+ window.addEventListener('scroll', this.handleScrollEvent, {
251
+ passive: true,
252
+ });
253
+ this.scrollParent.addEventListener('scroll', this.handleScrollEvent, {
254
+ passive: true,
255
+ });
256
+ document.addEventListener('postToggleMegadropdown', this.megedropdownStateHandler);
257
+ this.host.addEventListener('click', this.handleLinkClick);
258
+ this.handleResize();
259
+ this.handleScrollParentResize();
260
+ this.lockBody(false, this.mobileMenuExtended, 'mobileMenuExtended');
261
+ }
262
+ componentWillRender() {
263
+ this.handleScrollEvent();
264
+ }
265
+ componentDidRender() {
266
+ this.getFocusableElements();
267
+ this.handleLocalHeaderResize();
268
+ }
269
+ // Clean up possible side effects when post-header is disconnected
270
+ disconnectedCallback() {
271
+ const scrollParent = this.scrollParent;
272
+ window.removeEventListener('resize', this.throttledResize);
273
+ window.removeEventListener('scroll', this.handleScrollEvent);
274
+ scrollParent.removeEventListener('scroll', this.handleScrollEvent);
275
+ document.removeEventListener('postToggleMegadropdown', this.megedropdownStateHandler);
276
+ this.host.removeEventListener('keydown', this.keyboardHandler);
277
+ this.host.removeEventListener('click', this.handleLinkClick);
278
+ if (this.scrollParentResizeObserver) {
279
+ this.scrollParentResizeObserver.disconnect();
280
+ this.scrollParentResizeObserver = null;
281
+ }
282
+ if (this.localHeaderResizeObserver) {
283
+ this.localHeaderResizeObserver.disconnect();
284
+ this.localHeaderResizeObserver = null;
285
+ }
286
+ this.mobileMenuExtended = false;
287
+ }
288
+ /**
289
+ * Toggles the mobile navigation.
290
+ */
291
+ async toggleMobileMenu(force) {
292
+ if (this.device === 'desktop')
293
+ return;
294
+ this.mobileMenuAnimation = this.mobileMenuExtended
295
+ ? slide.slideUp(this.mobileMenu)
296
+ : slide.slideDown(this.mobileMenu);
297
+ // Update the state of the toggle button
298
+ const menuButton = this.host.querySelector('post-togglebutton');
299
+ menuButton.toggled = force ?? !this.mobileMenuExtended;
300
+ // Toggle menu visibility before it slides down and after it slides back up
301
+ if (this.mobileMenuExtended)
302
+ await this.mobileMenuAnimation.finished;
303
+ this.mobileMenuExtended = force ?? !this.mobileMenuExtended;
304
+ if (this.mobileMenuExtended === false) {
305
+ Array.from(this.host.querySelectorAll('post-megadropdown')).forEach(dropdown => {
306
+ dropdown.hide(false, true);
307
+ });
308
+ }
309
+ }
310
+ // Get all the focusable elements in the post-header mobile menu
311
+ getFocusableElements() {
312
+ // Get elements in the correct order (different as the DOM order)
313
+ const focusableEls = [
314
+ ...Array.from(this.host.querySelectorAll('.list-inline:not([slot="meta-navigation"]) > li')),
315
+ ...Array.from(this.host.querySelectorAll('nav > post-list > div > post-list-item, post-mainnavigation > .back-button, post-megadropdown-trigger')),
316
+ ...Array.from(this.host.querySelectorAll('.list-inline[slot="meta-navigation"] > li, post-language-option')),
317
+ ];
318
+ // Add the main toggle menu button to the list of focusable children
319
+ const focusableChildren = [
320
+ this.host.querySelector('post-togglebutton'),
321
+ ...focusableEls.flatMap(el => Array.from(getFocusableChildren(el))),
322
+ ];
323
+ this.firstFocusableEl = focusableChildren[0];
324
+ this.lastFocusableEl = focusableChildren[focusableChildren.length - 1];
325
+ }
326
+ keyboardHandler(e) {
327
+ if (e.key === 'Tab' && this.mobileMenuExtended) {
328
+ if (e.shiftKey && document.activeElement === this.firstFocusableEl) {
329
+ // If back tab (Tab + Shift) and first element is focused, focus goes to the last element of the megadropdown
330
+ e.preventDefault();
331
+ this.lastFocusableEl.focus();
332
+ }
333
+ else if (!e.shiftKey && document.activeElement === this.lastFocusableEl) {
334
+ // If Tab and last element is focused, focus goes back to the first element of the megadropdown
335
+ e.preventDefault();
336
+ this.firstFocusableEl.focus();
337
+ }
338
+ }
339
+ }
340
+ handleScrollEvent() {
341
+ const scrollTop = this.scrollParent === document.body ? window.scrollY : this.scrollParent.scrollTop;
342
+ document.documentElement.style.setProperty('--post-header-scroll-top', `${scrollTop}px`);
343
+ }
344
+ updateLocalHeaderHeight() {
345
+ const localHeaderHeight = this.host.shadowRoot.querySelector('.local-header')?.clientHeight || 0;
346
+ document.documentElement.style.setProperty('--post-local-header-height', `${localHeaderHeight}px`);
347
+ }
348
+ updateScrollParentHeight() {
349
+ this.host.style.setProperty('--post-header-scroll-parent-height', `${this.scrollParent.clientHeight}px`);
350
+ }
351
+ handleLinkClick(event) {
352
+ const target = event.target;
353
+ const isLinkInMainNav = target.closest('post-mainnavigation a');
354
+ const isLinkInMegadropdown = target.closest('post-megadropdown a');
355
+ if (!isLinkInMainNav && !isLinkInMegadropdown) {
356
+ return;
357
+ }
358
+ if (this.mobileMenuExtended && (isLinkInMainNav || isLinkInMegadropdown)) {
359
+ this.toggleMobileMenu(false);
360
+ }
361
+ if (this.device === 'desktop' && isLinkInMegadropdown) {
362
+ const megadropdownLink = target.closest('post-megadropdown a');
363
+ if (megadropdownLink) {
364
+ target.closest('post-megadropdown').hide(true);
365
+ }
366
+ }
367
+ }
368
+ handleResize() {
369
+ const previousDevice = this.device;
370
+ let newDevice;
371
+ const width = window?.innerWidth;
372
+ if (width >= 1024) {
373
+ newDevice = 'desktop';
374
+ }
375
+ else if (width >= 600) {
376
+ newDevice = 'tablet';
377
+ }
378
+ else {
379
+ newDevice = 'mobile';
380
+ }
381
+ // Apply only on change for doing work only when necessary
382
+ if (newDevice !== previousDevice) {
383
+ this.device = newDevice;
384
+ this.postUpdateDevice.emit(this.device);
385
+ window.requestAnimationFrame(() => {
386
+ this.switchLanguageSwitchMode();
387
+ });
388
+ }
389
+ }
390
+ handleScrollParentResize() {
391
+ if (this.scrollParent) {
392
+ this.scrollParentResizeObserver = new ResizeObserver(this.updateScrollParentHeight);
393
+ this.scrollParentResizeObserver.observe(this.scrollParent);
394
+ }
395
+ }
396
+ handleLocalHeaderResize() {
397
+ const localHeader = this.host.shadowRoot.querySelector('.local-header');
398
+ if (localHeader && !this.localHeaderResizeObserver) {
399
+ this.localHeaderResizeObserver = new ResizeObserver(this.updateLocalHeaderHeight);
400
+ this.localHeaderResizeObserver.observe(localHeader);
401
+ }
402
+ }
403
+ switchLanguageSwitchMode() {
404
+ const variant = this.device === 'desktop' ? 'menu' : 'list';
405
+ Array.from(this.host.querySelectorAll('post-language-switch')).forEach(languageSwitch => {
406
+ languageSwitch?.setAttribute('variant', variant);
407
+ });
408
+ }
409
+ renderNavigation() {
410
+ const navigationClasses = ['navigation'];
411
+ const mobileMenuScrollTop = this.mobileMenu?.scrollTop ?? 0;
412
+ if (this.mobileMenuExtended) {
413
+ navigationClasses.push('extended');
414
+ }
415
+ if (this.megadropdownOpen) {
416
+ navigationClasses.push('megadropdown-open');
417
+ }
418
+ return (index.h("div", { class: navigationClasses.join(' '), style: { '--post-header-navigation-current-inset': `${mobileMenuScrollTop}px` } }, index.h("div", { class: "mobile-menu", ref: el => (this.mobileMenu = el) }, index.h("slot", { name: "post-mainnavigation" }), (this.device === 'mobile' || this.device === 'tablet') && (index.h("div", { class: "navigation-footer" }, index.h("slot", { name: "meta-navigation" }), index.h("slot", { name: "post-language-switch" }))))));
419
+ }
420
+ render() {
421
+ return (index.h(index.Host, { key: '9705dc224bcf389c8836efbaf40d6d6617b2052f', "data-version": _package.version }, index.h("div", { key: '41a1b10ff4193b0a31eecc673935aabb70c1d1b4', class: "global-header" }, index.h("div", { key: '7e3692fca4130755c009447fcc20585386f1c65d', class: "global-sub" }, index.h("div", { key: '5b4d7fb16fcbeee3f07a1a160751b5c23e9f9edb', class: "logo" }, index.h("slot", { key: '67048479266ba86f2a1b739751be7bfe97ce4544', name: "post-logo" }))), index.h("div", { key: '83642103fae714a7c9ac1962e1433fd72899cf87', class: "global-sub" }, this.device === 'desktop' && index.h("slot", { key: 'ff672718574b3690d9ac8c2f54cb50e2b7052533', name: "meta-navigation" }), index.h("slot", { key: '782d10f094831da10cd9e9695944eee9c8003a05', name: "global-controls" }), this.device === 'desktop' && index.h("slot", { key: '5c5a277e3a627f5a731e1342c6604b6e064f3b52', name: "post-language-switch" }), index.h("div", { key: 'b07c9f1994fd99b170192ed4f4092afb92a1dd3e', onClick: () => this.toggleMobileMenu(), class: "mobile-toggle" }, index.h("slot", { key: '1bbb5a704cf1841e4845ff9921cd6662ee2d7387', name: "post-togglebutton" })))), index.h("div", { key: 'da8ecfd78835ab7431408558ee938d5054349955', class: 'local-header ' + (this.mobileMenuExtended ? 'local-header-mobile-extended' : '') }, index.h("slot", { key: '23c35a54fdf177a9b58054154e09f406f27fe049', name: "title" }), index.h("div", { key: 'de4dfdec5bd43a22587aa8e93842c4e16c73f82b', class: "local-sub" }, index.h("slot", { key: '35b09a33f3c87e382afb809f0c2b8153dd909097', name: "local-controls" }), index.h("slot", { key: 'bdfa7a68815e8d259cd346ef890904b652a5a7f2' })), this.device === 'desktop' && this.renderNavigation()), this.device !== 'desktop' && this.renderNavigation()));
422
+ }
423
+ get host() { return index.getElement(this); }
424
+ static get watchers() { return {
425
+ "device": ["lockBody"],
426
+ "mobileMenuExtended": ["lockBody"]
427
+ }; }
428
+ };
429
+ PostHeader.style = PostHeaderStyle0;
430
+
431
+ const postIconCss = ":host{display:inline-block;width:1em;height:1em;vertical-align:-0.15em}span{display:block;width:100%;height:100%;fill:currentColor;forced-color-adjust:preserve-parent-color;background-color:currentColor;-webkit-mask-position:center center;mask-position:center center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100%;mask-size:100%}:host([flip-h]:not([flip-h=false])){scale:-1 1}:host([flip-v]:not([flip-v=false])){scale:1 -1}:host([flip-h][flip-v]:not([flip-h=false],[flip-v=false])){scale:-1}:host([animation]){transform-origin:center}:host([animation=cylon]){animation:icon-animation-cylon .75s ease-in-out infinite alternate}:host([animation=cylon-vertical]){animation:icon-animation-cylon-vertical .75s ease-in-out infinite alternate}:host([animation=spin]){animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]){animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]){animation:icon-animation-fade .75s ease-in-out infinite alternate}:host([animation=throb]){animation:icon-animation-throb .75s ease-in-out infinite alternate}@keyframes icon-animation-cylon{from{transform:translateX(-25%)}to{transform:translateX(25%)}}@keyframes icon-animation-cylon-vertical{from{transform:translateY(25%)}to{transform:translateY(-25%)}}@keyframes icon-animation-fade{from{opacity:.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";
432
+ const PostIconStyle0 = postIconCss;
433
+
434
+ const CDN_URL = `https://unpkg.com/@swisspost/design-system-icons@${_package.version}/public/post-icons/`;
435
+ const ANIMATION_NAMES = [
436
+ 'cylon',
437
+ 'cylon-vertical',
438
+ 'spin',
439
+ 'spin-reverse',
440
+ 'fade',
441
+ 'throb',
442
+ ];
443
+ const ANIMATION_KEYS = [...ANIMATION_NAMES];
444
+ const PostIcon = class {
445
+ constructor(hostRef) {
446
+ index.registerInstance(this, hostRef);
447
+ this.animation = null;
448
+ this.base = null;
449
+ this.flipH = false;
450
+ this.flipV = false;
451
+ this.name = undefined;
452
+ this.rotate = null;
453
+ this.scale = null;
454
+ }
455
+ validateAnimation(newValue = this.animation) {
456
+ if (newValue !== undefined)
457
+ index$1.checkEmptyOrOneOf(this, 'animation', ANIMATION_KEYS);
458
+ }
459
+ validateBase() {
460
+ index$1.checkEmptyOrType(this, 'base', 'string');
461
+ }
462
+ validateFlipH() {
463
+ index$1.checkEmptyOrType(this, 'flipH', 'boolean');
464
+ }
465
+ validateFlipV() {
466
+ index$1.checkEmptyOrType(this, 'flipV', 'boolean');
467
+ }
468
+ validateName() {
469
+ checkNonEmpty.checkNonEmpty(this, 'name');
470
+ checkType.checkType(this, 'name', 'string');
471
+ }
472
+ validateRotate() {
473
+ index$1.checkEmptyOrType(this, 'rotate', 'number');
474
+ }
475
+ validateScale() {
476
+ index$1.checkEmptyOrType(this, 'scale', 'number');
477
+ }
478
+ // Construct the icon url from different possible sources
479
+ getUrl() {
480
+ let url;
481
+ const file = `${this.name}.svg`;
482
+ // the first definition object which defines a domain, will be used to set the domain of the file url
483
+ // the first definition object which defines a slug, will be used to set the slug of the file url
484
+ const urlDefinitions = [this.getUrlDefinition(this.base, 'both')];
485
+ if (breakpoints.IS_BROWSER) {
486
+ urlDefinitions.push(this.getUrlDefinition(document.head
487
+ .querySelector('meta[name="design-system-settings"][data-post-icon-base]')
488
+ ?.getAttribute('data-post-icon-base'), 'relative'));
489
+ urlDefinitions.push(this.getUrlDefinition(document.querySelector('base[href]')?.getAttribute('href'), 'both'));
490
+ }
491
+ // in case no definition defines a domain, a relative url is used to load the icon
492
+ const origin = urlDefinitions.find(d => d.definesDomain)?.url?.origin;
493
+ // in case no definition defines a slug either, the cdn url is used as a fallback
494
+ const slug = urlDefinitions.find(d => d.definesSlug)?.url?.pathname;
495
+ if (origin && slug) {
496
+ url = `${origin}${slug}${file}`;
497
+ }
498
+ else if (!origin && slug) {
499
+ url = `${slug}${file}`;
500
+ }
501
+ else {
502
+ url = `${CDN_URL}${file}`;
503
+ }
504
+ return url;
505
+ }
506
+ getUrlDefinition(url, allow) {
507
+ return {
508
+ url: this.getUrlObject(url),
509
+ definesDomain: allow !== 'relative' ? this.definesDomain(url) : false,
510
+ definesSlug: allow !== 'absolute' ? this.definesSlug(url) : false,
511
+ };
512
+ }
513
+ getUrlObject(url) {
514
+ if (url) {
515
+ url = url?.endsWith('/') ? url : `${url}/`;
516
+ return new URL(url, 'https://url.base');
517
+ }
518
+ else {
519
+ return null;
520
+ }
521
+ }
522
+ definesDomain(url) {
523
+ return url ? /^https?:\/\//.test(url) : false;
524
+ }
525
+ definesSlug(url) {
526
+ return Boolean(/^\/.+/.test(this.getUrlObject(url)?.pathname));
527
+ }
528
+ getStyles() {
529
+ const url = this.getUrl();
530
+ return Object.entries({
531
+ '-webkit-mask-image': `url(${url})`,
532
+ 'mask-image': `url('${url}')`,
533
+ 'transform': (this.scale && !isNaN(Number(this.scale)) ? 'scale(' + this.scale + ')' : '') +
534
+ (this.rotate && !isNaN(Number(this.rotate)) ? ' rotate(' + this.rotate + 'deg)' : ''),
535
+ })
536
+ .filter(([_key, value]) => value !== null)
537
+ .reduce((styles, [key, value]) => Object.assign(styles, { [key]: value }), {});
538
+ }
539
+ componentDidLoad() {
540
+ this.validateBase();
541
+ this.validateName();
542
+ this.validateFlipH();
543
+ this.validateFlipV();
544
+ this.validateScale();
545
+ this.validateRotate();
546
+ this.validateAnimation();
547
+ }
548
+ render() {
549
+ return (index.h(index.Host, { key: 'b3c3efcc03f423a248e231b4b4c5d79c93ae25a6', "data-version": _package.version }, index.h("span", { key: 'd73d4df11fcccb96d5346f3f8c3e18602bb8d484', style: this.getStyles() })));
550
+ }
551
+ get host() { return index.getElement(this); }
552
+ static get watchers() { return {
553
+ "animation": ["validateAnimation"],
554
+ "base": ["validateBase"],
555
+ "flipH": ["validateFlipH"],
556
+ "flipV": ["validateFlipV"],
557
+ "name": ["validateName"],
558
+ "rotate": ["validateRotate"],
559
+ "scale": ["validateScale"]
560
+ }; }
561
+ };
562
+ PostIcon.style = PostIconStyle0;
563
+
564
+ const postLanguageOptionCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}post-language-option{display:inline-block}post-language-option button{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option button{background-color:ButtonFace !important}post-language-option button:hover{background-color:Highlight !important}}post-language-option a{color:var(--post-scheme-color-surface-default-fg);text-decoration:none}post-language-option :is(a,button){cursor:pointer;display:flex;align-items:center;justify-content:center;width:100%;height:100%;border-radius:2px;text-transform:uppercase}post-language-option :is(a,button){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}post-language-option :is(a,button):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option :is(a,button):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){post-language-option :is(a,button):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option :is(a,button):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}post-language-option:where([variant=list]) :is(a,button){padding-inline:0;width:40px;height:40px;border-radius:2px}post-language-option:where([variant=list]) :is(a,button):hover{color:#504f4b}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option:where([variant=list]) :is(a,button){border:1px solid ButtonBorder;color:ButtonText}}post-language-option:where([variant=list])[active]:not([active=false]) :is(a,button){background-color:#050400 !important;color:#fff;pointer-events:none}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option:where([variant=list])[active]:not([active=false]) :is(a,button){background-color:Highlight !important;color:HighlightText}}post-language-option:where([variant=menu]){min-width:72px}post-language-option:where([variant=menu])[active]:not([active=false]){display:none}post-language-option:where([variant=menu]) :is(a,button){padding-block:13px;padding-inline:16px;box-sizing:border-box;justify-content:flex-start;position:relative}post-language-option:where([variant=menu]) :is(a,button):hover{color:#fff;background-color:#504f4b}";
565
+ const PostLanguageOptionStyle0 = postLanguageOptionCss;
566
+
567
+ const PostLanguageOption = class {
568
+ constructor(hostRef) {
569
+ index.registerInstance(this, hostRef);
570
+ this.postChange = index.createEvent(this, "postChange", 7);
571
+ this.postLanguageOptionInitiallyActive = index.createEvent(this, "postLanguageOptionInitiallyActive", 7);
572
+ this.code = undefined;
573
+ this.active = undefined;
574
+ this.variant = undefined;
575
+ this.name = undefined;
576
+ this.url = undefined;
577
+ }
578
+ validateCode() {
579
+ checkType.checkType(this, 'code', 'string');
580
+ }
581
+ validateActiveProp() {
582
+ index$1.checkEmptyOrType(this, 'active', 'boolean');
583
+ }
584
+ validateName() {
585
+ index$1.checkEmptyOrType(this, 'name', 'string');
586
+ }
587
+ validateUrl() {
588
+ index$1.checkEmptyOrType(this, 'url', 'string');
589
+ }
590
+ componentDidLoad() {
591
+ this.validateCode();
592
+ this.validateActiveProp();
593
+ this.validateName();
594
+ this.validateUrl();
595
+ if (!this.name && this.isNameRequired()) {
596
+ throw new Error('The "name" property of the post-language-option component is required when the full language name is not displayed.');
597
+ }
598
+ if (this.active) {
599
+ this.postLanguageOptionInitiallyActive.emit(this.code);
600
+ }
601
+ }
602
+ /**
603
+ * Selects the language option programmatically.
604
+ */
605
+ async select() {
606
+ this.active = true;
607
+ this.emitChange();
608
+ }
609
+ emitChange() {
610
+ this.postChange.emit(this.code);
611
+ }
612
+ isNameRequired() {
613
+ return this.host.textContent.toLowerCase() === this.code.toLowerCase();
614
+ }
615
+ render() {
616
+ const lang = this.code.toLowerCase();
617
+ const emitOnKeyDown = (e) => {
618
+ if (e.key === 'Enter' || e.key === ' ') {
619
+ this.emitChange();
620
+ }
621
+ };
622
+ return (index.h(index.Host, { key: '3a6b9a8f63c90f431a13c1df529a2e4716ede5d8', "data-version": _package.version }, this.url ? (index.h("a", { "aria-current": this.active ? 'page' : undefined, "aria-label": this.name, href: this.url, hrefLang: lang, lang: lang, onClick: () => this.emitChange(), onKeyDown: emitOnKeyDown }, index.h("slot", null))) : (index.h("button", { "aria-current": this.active ? 'true' : undefined, "aria-label": this.name, lang: lang, onClick: () => this.emitChange(), onKeyDown: emitOnKeyDown }, index.h("slot", null)))));
623
+ }
624
+ get host() { return index.getElement(this); }
625
+ static get watchers() { return {
626
+ "code": ["validateCode"],
627
+ "active": ["validateActiveProp"],
628
+ "name": ["validateName"],
629
+ "url": ["validateUrl"]
630
+ }; }
631
+ };
632
+ PostLanguageOption.style = PostLanguageOptionStyle0;
633
+
634
+ const SWITCH_VARIANTS = ['list', 'menu'];
635
+
636
+ const postLanguageSwitchCss = ":host{display:flex !important;flex-wrap:wrap;gap:.5rem}.post-language-switch-dropdown-container{display:flex;flex-direction:column}.post-language-switch-trigger{cursor:pointer;text-transform:uppercase;padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;text-decoration:none;display:inline-flex;align-items:center;gap:6px;border-radius:24px;font-size:16px;padding:3px 10px}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger{background-color:ButtonFace !important}.post-language-switch-trigger:hover{background-color:Highlight !important}}.post-language-switch-trigger{outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.post-language-switch-trigger:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.post-language-switch-trigger:is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger:is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.post-language-switch-trigger:not(:disabled):hover,.post-language-switch-trigger.pretend-hover{border-color:var(--post-scheme-color-interactive-button-tertiary-hover-stroke);background-color:var(--post-scheme-color-interactive-button-tertiary-hover-bg);color:var(--post-scheme-color-interactive-button-tertiary-hover-fg)}.post-language-switch-trigger post-icon{height:24px;width:24px}.post-language-switch-trigger[aria-expanded=true]{background-color:#050400;color:#fff}.post-language-switch-trigger[aria-expanded=true] post-icon{transform:rotate(180deg)}.post-language-switch-trigger[aria-expanded=true]:hover{background-color:#504f4b;color:#fff}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger{border:1px solid ButtonBorder}.post-language-switch-trigger[aria-expanded=true] post-icon,.post-language-switch-trigger:hover post-icon{color:HighlightText}}";
637
+ const PostLanguageSwitchStyle0 = postLanguageSwitchCss;
638
+
639
+ const PostLanguageSwitch = class {
640
+ constructor(hostRef) {
641
+ index.registerInstance(this, hostRef);
642
+ this.menuId = `p${index_browser.nanoid(11)}`;
643
+ this.caption = undefined;
644
+ this.description = undefined;
645
+ this.variant = 'list';
646
+ this.activeLang = undefined;
647
+ }
648
+ get languageOptions() {
649
+ return Array.from(this.host.querySelectorAll('post-language-option'));
650
+ }
651
+ validateCaption() {
652
+ checkType.checkType(this, 'caption', 'string');
653
+ }
654
+ validateDescription() {
655
+ checkType.checkType(this, 'description', 'string');
656
+ }
657
+ validateVariant() {
658
+ index$1.checkEmptyOrOneOf(this, 'variant', SWITCH_VARIANTS);
659
+ this.updateChildrenVariant();
660
+ }
661
+ componentDidLoad() {
662
+ this.validateCaption();
663
+ this.validateDescription();
664
+ this.validateVariant();
665
+ // Initially set variants and active language
666
+ // Handles cases where the language-switch is rendered after the language-options have been rendered
667
+ this.updateChildrenVariant();
668
+ }
669
+ /**
670
+ * Listen for the postChange event and guard it to run only for events originating from a <post-language-option> element.
671
+ */
672
+ handlePostChange(event) {
673
+ eventGuard.eventGuard(this.host, event, { targetLocalName: 'post-language-option', delegatorSelector: 'post-language-switch' }, () => {
674
+ this.activeLang = event.detail;
675
+ // Update the active state in the children post-language-option components
676
+ this.languageOptions.forEach(lang => {
677
+ if (lang.code && lang.code === this.activeLang) {
678
+ lang.setAttribute('active', '');
679
+ }
680
+ else {
681
+ lang.removeAttribute('active');
682
+ }
683
+ });
684
+ // Hides the dropdown when an option has been clicked
685
+ if (this.variant === 'menu') {
686
+ const menu = this.host.shadowRoot.querySelector('post-menu');
687
+ menu.hide();
688
+ }
689
+ });
690
+ }
691
+ /**
692
+ * Handles cases where the language switch is being rendered before options are available
693
+ * @param event Initially emitted by <post-langauge-option>
694
+ */
695
+ handleInitiallyActive(event) {
696
+ this.activeLang = event.detail;
697
+ }
698
+ // Update post-language-option variant to have the correct style
699
+ updateChildrenVariant() {
700
+ this.languageOptions.forEach(el => {
701
+ el.setAttribute('variant', this.variant);
702
+ });
703
+ }
704
+ renderList() {
705
+ return (index.h(index.Host, { "data-version": _package.version, role: "list", "aria-label": this.caption }, index.h("div", { class: "post-language-switch-list", role: "group", "aria-label": this.description }, index.h("slot", null))));
706
+ }
707
+ renderDropdown() {
708
+ return (index.h(index.Host, { "data-version": _package.version }, index.h("post-menu-trigger", { for: this.menuId }, index.h("button", { class: "post-language-switch-trigger", "aria-label": this.description }, this.activeLang, index.h("post-icon", { "aria-hidden": "true", name: "chevrondown" }))), index.h("post-menu", { id: this.menuId, class: "post-language-switch-dropdown-container", "aria-label": this.caption }, index.h("slot", null))));
709
+ }
710
+ render() {
711
+ return this.variant === 'list' ? this.renderList() : this.renderDropdown();
712
+ }
713
+ get host() { return index.getElement(this); }
714
+ static get watchers() { return {
715
+ "caption": ["validateCaption"],
716
+ "description": ["validateDescription"],
717
+ "variant": ["validateVariant"]
718
+ }; }
719
+ };
720
+ PostLanguageSwitch.style = PostLanguageSwitchStyle0;
721
+
722
+ const postListCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}post-list{display:flex;flex-direction:column;gap:var(--post-list-title-gap, 0)}post-list>[role=list]{display:flex;flex-direction:column;gap:var(--post-list-item-gap, 0)}post-list:where([horizontal]:not([horizontal=false])){flex-direction:row;align-items:center}post-list:where([horizontal]:not([horizontal=false]))>[role=list]{flex-direction:row;align-items:center}post-list>.list-title.visually-hidden{width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}post-list>.list-title.visually-hidden:not(caption){position:absolute !important}";
723
+ const PostListStyle0 = postListCss;
724
+
725
+ const PostList = class {
726
+ constructor(hostRef) {
727
+ index.registerInstance(this, hostRef);
728
+ this.titleId = undefined;
729
+ this.titleHidden = false;
730
+ this.horizontal = false;
731
+ }
732
+ componentWillLoad() {
733
+ /**
734
+ * Get the id set on the host element or use a random id by default
735
+ */
736
+ this.titleId = `title-${this.host.id || index_browser.nanoid(6)}`;
737
+ }
738
+ componentDidLoad() {
739
+ this.checkTitle();
740
+ }
741
+ checkTitle() {
742
+ if (!this.titleEl.textContent.trim()) {
743
+ console.error('Please provide a title to the list component. Title is mandatory for accessibility purposes.');
744
+ }
745
+ }
746
+ render() {
747
+ return (index.h(index.Host, { key: 'b003aa61735359b6a1d95aad8d29c609d5bb3c8b', "data-version": _package.version }, index.h("div", { key: '2f69a2c72dd357767735e10d16f1b7586da6d5a3', ref: el => (this.titleEl = el), id: this.titleId, class: `list-title${this.titleHidden ? ' visually-hidden' : ''}` }, index.h("slot", { key: '3982783d438519673a676323339a013d3edb84db' })), index.h("div", { key: 'b8a91c4430774f019cc46aa19393e2a1566204a5', role: "list", "aria-labelledby": this.titleId }, index.h("slot", { key: '378a51785c4d52df8ae422657a16e8295b405149', name: "post-list-item" }))));
748
+ }
749
+ get host() { return index.getElement(this); }
750
+ };
751
+ PostList.style = PostListStyle0;
752
+
753
+ const postListItemCss = ":host{display:flex}";
754
+ const PostListItemStyle0 = postListItemCss;
755
+
756
+ const PostListItem = class {
757
+ constructor(hostRef) {
758
+ index.registerInstance(this, hostRef);
759
+ }
760
+ connectedCallback() {
761
+ this.host.setAttribute('slot', 'post-list-item');
762
+ }
763
+ render() {
764
+ return (index.h(index.Host, { key: 'c826293ea2a7446bea2f5b223934b444655198a0', role: "listitem", slot: "post-list-item", version: _package.version }, index.h("slot", { key: 'b997f79da2fbc87fbc6a388c118a03c008ad2c23' })));
765
+ }
766
+ get host() { return index.getElement(this); }
767
+ };
768
+ PostListItem.style = PostListItemStyle0;
769
+
770
+ const postLogoCss = ":host,.logo{display:inline-block}:host,:host .logo>svg,.logo,.logo .logo>svg{height:100%}.description{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}.logo-link{outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.logo-link:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.logo-link:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.logo-link:is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.logo-link:is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.logo-link :focus,:focus-visible{border-radius:2px}";
771
+ const PostLogoStyle0 = postLogoCss;
772
+
773
+ const PostLogo = class {
774
+ constructor(hostRef) {
775
+ index.registerInstance(this, hostRef);
776
+ this.url = undefined;
777
+ }
778
+ validateUrl() {
779
+ index$1.checkEmptyOrUrl(this, 'url');
780
+ }
781
+ componentDidLoad() {
782
+ this.validateUrl();
783
+ this.checkDescription();
784
+ }
785
+ checkDescription() {
786
+ if (!this.host.textContent) {
787
+ console.warn('Be sure to add descriptive text in the post-logo to ensure good accessibility of the component.');
788
+ }
789
+ }
790
+ render() {
791
+ const logoLink = this.url && (typeof this.url === 'string' ? this.url : this.url.href);
792
+ const LogoTag = logoLink ? 'a' : 'span';
793
+ return (index.h(index.Host, { key: '7dee19302c0c560b29f09b1675135f10d41fc44a', "data-version": _package.version }, index.h(LogoTag, { key: '1d851ca305d1bfc24666b416ad5f210b96d39811', class: `logo ${logoLink ? 'logo-link' : ''}`, ...(logoLink ? { href: logoLink } : {}) }, index.h("span", { key: 'cd75bd4040bc2f0d62e5cec2afc9529fa7c43c49', class: "description" }, index.h("slot", { key: 'caf63c4f823873181fa52cfb0cf38217b6a45823', onSlotchange: () => this.checkDescription() })), index.h("svg", { key: 'd41c14973b829eb35764c9e562fe449e65f410b4', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 72 72", "aria-hidden": "true" }, index.h("g", { key: '90c52e528bf4fc8e075e6517c18a59686ffd39f6', id: "Logo" }, index.h("rect", { key: '50633d1110596123232f07272406ebd0a32ffce8', fill: "#ffcc00", x: "0", y: "0", width: "72", height: "72" }), index.h("polygon", { key: '7a617412c094669a66914edf769fba9ee9448b83', fill: "#ff0000", points: "34,32.3 34,19 19.7,19 19.7,29.1 10,29.1 10,42.9 19.7,42.9 19.7,53 34,53 34,39.7 30.6,39.7 30.6,49.8 23.1,49.8 23.1,39.7 13.4,39.7 13.4,32.3 23.1,32.3 23.1,22.2 30.6,22.2 30.6,32.3" }), index.h("path", { key: '74213b21fad18ba6a1dbb07e0b0b7dcf4a89b855', d: "M53.56234,31.10526c0,2.41272-1.99154,4.29475-4.51723,4.29475H45.2v-8.3h3.84511C51.66802,27.1,53.56234,28.78889,53.56234,31.10526z M50.69666,19H36v34h9.2V42.9h5.49666c6.75131,0,11.9971-5.15137,11.9971-11.8057C62.69376,24.39136,57.35099,19,50.69666,19z" }))))));
794
+ }
795
+ get host() { return index.getElement(this); }
796
+ static get watchers() { return {
797
+ "url": ["validateUrl"]
798
+ }; }
799
+ };
800
+ PostLogo.style = PostLogoStyle0;
801
+
802
+ const postMainnavigationCss = "post-mainnavigation post-list-item>a{text-decoration:none;border-radius:0}post-mainnavigation post-list-item post-megadropdown-trigger button{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;text-align:start}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-mainnavigation post-list-item post-megadropdown-trigger button{background-color:ButtonFace !important}post-mainnavigation post-list-item post-megadropdown-trigger button:hover{background-color:Highlight !important}}post-mainnavigation post-list-item>a,post-mainnavigation post-list-item post-megadropdown-trigger button{flex:0 0 fit-content;white-space:nowrap;display:flex;align-items:center;justify-content:space-between}post-mainnavigation post-list-item>a:hover,post-mainnavigation post-list-item post-megadropdown-trigger button:hover{color:var(--post-scheme-color-interactive-primary-hover-fg1)}post-mainnavigation post-list-item>a:focus-visible,post-mainnavigation post-list-item post-megadropdown-trigger button:focus-visible{border-radius:4px;outline-offset:-2px !important}@media screen and (max-width: 1023.98px){post-mainnavigation .back-button{font-size:16px}}@media screen and (max-width: 599.98px){post-mainnavigation .back-button{font-size:14px}}post-mainnavigation>button::after,post-mainnavigation post-megadropdown-trigger button::after{content:\"\";mask-image:url(\"data:image/svg+xml,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m23.6 13.2-7.5 7.6-7.6-7.6.9-.9 6.6 6.6 6.6-6.6z'/%3E%3C/svg%3E\");background-color:currentColor;color:currentColor;forced-color-adjust:preserve-parent-color;height:24px;width:24px}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-mainnavigation>button,post-mainnavigation post-megadropdown-trigger button{border:1px solid ButtonBorder !important}post-mainnavigation>button:hover::after,post-mainnavigation>button[aria-expanded=true]::after,post-mainnavigation post-megadropdown-trigger button:hover::after,post-mainnavigation post-megadropdown-trigger button[aria-expanded=true]::after{color:HighlightText}}@media screen and (min-width: 1024px){post-mainnavigation{display:block;position:relative;height:var(--post-main-navigation-height);background:#fff;user-select:none}post-mainnavigation nav{flex:1 1 auto;overflow:hidden;scroll-behavior:smooth}post-mainnavigation .scroll-control{cursor:pointer;position:absolute;inset-block:0;z-index:5;padding:16px;background:#fff;box-shadow:var(--post-device-elevation-500);line-height:1}post-mainnavigation .scroll-control.scroll-left{inset-inline-start:0}post-mainnavigation .scroll-control.scroll-right{inset-inline-end:0}post-mainnavigation .scroll-control.d-none{display:none}post-mainnavigation .scroll-control post-icon{font-size:1rem}post-mainnavigation post-list>[role=list]{flex-direction:row;max-width:100vw}post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{position:sticky;padding-inline:12px;height:var(--post-main-navigation-height);gap:4px;font-size:16px;z-index:4}post-mainnavigation post-list-item>a .nav-el-active,post-mainnavigation post-list-item>button .nav-el-active,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-active{font-weight:700;text-align:center;opacity:0}post-mainnavigation post-list-item>a .nav-el-inactive,post-mainnavigation post-list-item>button .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-inactive{position:absolute;opacity:1;text-align:center;width:100%;inset-inline-start:0}post-mainnavigation post-list-item>a.selected,post-mainnavigation post-list-item>a[aria-expanded=true],post-mainnavigation post-list-item>button.selected,post-mainnavigation post-list-item>button[aria-expanded=true],post-mainnavigation post-list-item post-megadropdown-trigger button.selected,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true]{background-color:#050400;color:#fff;font-weight:700}post-mainnavigation post-list-item>a.selected .nav-el-active,post-mainnavigation post-list-item>a[aria-expanded=true] .nav-el-active,post-mainnavigation post-list-item>button.selected .nav-el-active,post-mainnavigation post-list-item>button[aria-expanded=true] .nav-el-active,post-mainnavigation post-list-item post-megadropdown-trigger button.selected .nav-el-active,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true] .nav-el-active{opacity:1}post-mainnavigation post-list-item>a.selected .nav-el-inactive,post-mainnavigation post-list-item>a[aria-expanded=true] .nav-el-inactive,post-mainnavigation post-list-item>button.selected .nav-el-inactive,post-mainnavigation post-list-item>button[aria-expanded=true] .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button.selected .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true] .nav-el-inactive{opacity:0}post-mainnavigation post-list-item>a:hover,post-mainnavigation post-list-item>button:hover,post-mainnavigation post-list-item post-megadropdown-trigger button:hover{background-color:#504f4b;color:#fff}}@media screen and (min-width: 1024px)and (max-width: 599.98px){post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{font-size:14px}}@media screen and (min-width: 1024px){post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{padding-inline-end:12px;transition:border-block-end-color 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation post-list-item>button .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-inactive{width:calc(100% - 28px)}post-mainnavigation post-list-item>button::after,post-mainnavigation post-list-item post-megadropdown-trigger button::after{transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation post-list-item>button.selected::after,post-mainnavigation post-list-item>button[aria-expanded=true]::after,post-mainnavigation post-list-item post-megadropdown-trigger button.selected::after,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true]::after{transform:rotate(180deg)}}@media screen and (min-width: 1024px){post-mainnavigation post-megadropdown button:not(.btn-icon-close),post-mainnavigation post-megadropdown a{width:100%;min-width:100%;height:48px;padding-inline:8px 12px;gap:16px;font-weight:400;position:relative}post-mainnavigation post-megadropdown button:not(.btn-icon-close)::before,post-mainnavigation post-megadropdown a::before{content:\"\";background-color:#050400;bottom:0;width:100%;height:1px;position:absolute;left:0}post-mainnavigation post-megadropdown button:not(.btn-icon-close).selected,post-mainnavigation post-megadropdown button:not(.btn-icon-close)[aria-expanded=true],post-mainnavigation post-megadropdown a.selected,post-mainnavigation post-megadropdown a[aria-expanded=true]{background-color:#050400;color:#fff}post-mainnavigation post-megadropdown button:not(.btn-icon-close):hover,post-mainnavigation post-megadropdown a:hover{background-color:#504f4b;color:#fff}post-mainnavigation post-megadropdown button:not(.btn-icon-close):hover::before,post-mainnavigation post-megadropdown a:hover::before{background-color:#504f4b}}@media screen and (min-width: 1024px){post-mainnavigation [slot=back-button]{display:none}}@media screen and (max-width: 1023.98px){post-mainnavigation nav{transform:none !important}post-mainnavigation .scroll-control{display:none}post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{width:100%;min-width:100%;height:48px;padding-inline:8px 12px;gap:16px;font-weight:400;position:relative}post-mainnavigation post-list-item>a::before,post-mainnavigation post-list-item>button::before,post-mainnavigation post-list-item post-megadropdown-trigger button::before{content:\"\";background-color:#050400;bottom:0;width:100%;height:1px;position:absolute;left:0}post-mainnavigation post-list-item>a.selected,post-mainnavigation post-list-item>a[aria-expanded=true],post-mainnavigation post-list-item>button.selected,post-mainnavigation post-list-item>button[aria-expanded=true],post-mainnavigation post-list-item post-megadropdown-trigger button.selected,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true]{background-color:#050400;color:#fff}post-mainnavigation post-list-item>a:hover,post-mainnavigation post-list-item>button:hover,post-mainnavigation post-list-item post-megadropdown-trigger button:hover{background-color:#504f4b;color:#fff}post-mainnavigation post-list-item>a:hover::before,post-mainnavigation post-list-item>button:hover::before,post-mainnavigation post-list-item post-megadropdown-trigger button:hover::before{background-color:#504f4b}post-mainnavigation post-list-item>a .nav-el-inactive,post-mainnavigation post-list-item>button .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-inactive{display:none}post-mainnavigation>button::after,post-mainnavigation post-megadropdown-trigger button::after{transform:rotate(-90deg)}}post-mainnavigation .back-button .btn{padding-inline:0}";
803
+ const PostMainnavigationStyle0 = postMainnavigationCss;
804
+
805
+ const SCROLL_REPEAT_INTERVAL = 100; // Interval for repeated scrolling when holding down scroll button
806
+ const NAVBAR_DISABLE_DURATION = 400; // Duration to temporarily disable navbar interactions during scrolling
807
+ const PostMainnavigation = class {
808
+ constructor(hostRef) {
809
+ index.registerInstance(this, hostRef);
810
+ this.canScrollLeft = false;
811
+ this.canScrollRight = false;
812
+ this.scrollRight = this.scrollRight.bind(this);
813
+ this.scrollLeft = this.scrollLeft.bind(this);
814
+ this.handleMutations = this.handleMutations.bind(this);
815
+ this.checkScrollability = this.checkScrollability.bind(this);
816
+ this.resizeObserver = new ResizeObserver(this.checkScrollability);
817
+ this.mutationObserver = new MutationObserver(this.handleMutations);
818
+ }
819
+ componentDidLoad() {
820
+ setTimeout(() => {
821
+ this.fixLayoutShift();
822
+ this.checkScrollability();
823
+ });
824
+ // Observe the navbar for size changes
825
+ this.resizeObserver.observe(this.navbar);
826
+ // Observe the navabar for mutation changes
827
+ this.mutationObserver.observe(this.navbar, { subtree: true, childList: true }); // Recheck scrollability when navigation list changes
828
+ // Ensure the scroll buttons are correctly displayed or hidden whenever the navbar is scrolled
829
+ this.navbar.addEventListener('scrollend', this.checkScrollability);
830
+ }
831
+ /**
832
+ * Disconnects observers and remove event listeners when the main navigation is removed from the DOM.
833
+ */
834
+ disconnectedCallback() {
835
+ this.mutationObserver.disconnect();
836
+ this.resizeObserver.disconnect();
837
+ this.navbar.removeEventListener('scrollend', this.checkScrollability);
838
+ }
839
+ /**
840
+ * Stops the repeated scrolling when the mouse button is released.
841
+ */
842
+ stopScrolling() {
843
+ if (this.scrollRepeatInterval)
844
+ clearInterval(this.scrollRepeatInterval);
845
+ }
846
+ async handleMutations(mutations) {
847
+ const addedNodes = mutations.flatMap((mutation) => {
848
+ return Array.from(mutation.addedNodes);
849
+ });
850
+ // Wait for all elements to be hydrated
851
+ await Promise.all(addedNodes.map((item) => item.componentOnReady ? item.componentOnReady() : Promise.resolve(item)));
852
+ this.fixLayoutShift();
853
+ this.checkScrollability();
854
+ }
855
+ get navigationItems() {
856
+ return Array.from(this.navbar.querySelectorAll(':is(a, button):not(post-megadropdown *)'));
857
+ }
858
+ /**
859
+ * Hack to fix the layout shift due to bold text on active elements
860
+ */
861
+ fixLayoutShift() {
862
+ this.navigationItems
863
+ .filter(item => !item.matches(':has(.nav-el-active)'))
864
+ .forEach(item => {
865
+ item.innerHTML = `
866
+ <span class="nav-el-active">${item.innerHTML}</span>
867
+ <span class="nav-el-inactive" aria-hidden="true">${item.innerHTML}</span>
868
+ `;
869
+ });
870
+ }
871
+ handleBackButtonClick() {
872
+ const header = this.navbar.closest('post-header');
873
+ if (header)
874
+ header.toggleMobileMenu();
875
+ }
876
+ /**
877
+ * Returns whether scrolling is enabled in either the left or right direction.
878
+ */
879
+ get canScroll() {
880
+ return this.canScrollLeft || this.canScrollRight;
881
+ }
882
+ /**
883
+ * Checks if scrolling is possible in either direction (left or right) and updates the state accordingly.
884
+ */
885
+ checkScrollability() {
886
+ const { scrollLeft, scrollWidth, clientWidth } = this.navbar;
887
+ if (scrollWidth === clientWidth) {
888
+ // If scroll width equals client width, scrolling is disabled in both directions
889
+ this.canScrollLeft = this.canScrollRight = false;
890
+ }
891
+ else {
892
+ this.canScrollLeft = Math.floor(scrollLeft) > 0; // Scrolling left is possible if not at the start
893
+ this.canScrollRight = Math.ceil(clientWidth + scrollLeft) < scrollWidth; // Scrolling right is possible if not at the end
894
+ }
895
+ }
896
+ /**
897
+ * Handles the scrolling behavior when a user clicks on the left or right scroll buttons.
898
+ */
899
+ handleScrollButtonClick(e, direction) {
900
+ if (!this.canScroll || e.button !== 0)
901
+ return;
902
+ // Disable interaction with the navbar during scrolling
903
+ this.temporarilyDisableNavbar();
904
+ // Set up the correct scroll function
905
+ const scroll = direction === 'right' ? this.scrollRight : this.scrollLeft;
906
+ scroll();
907
+ // Repeat the scrolling action while the button is held down
908
+ this.scrollRepeatInterval = setInterval(() => {
909
+ scroll();
910
+ }, SCROLL_REPEAT_INTERVAL);
911
+ }
912
+ scrollRight() {
913
+ const scrollRightLeftEdge = document
914
+ .querySelector('.scroll-right')
915
+ .getBoundingClientRect().left;
916
+ for (const navigationItem of this.navigationItems) {
917
+ const { right, width } = navigationItem.getBoundingClientRect();
918
+ // Scroll to the first navigation item that is less than 75% visible
919
+ const isThreeQuartersVisible = right - 0.25 * width < scrollRightLeftEdge;
920
+ if (!isThreeQuartersVisible) {
921
+ this.navbar.scrollBy({ left: right - scrollRightLeftEdge });
922
+ return;
923
+ }
924
+ }
925
+ }
926
+ scrollLeft() {
927
+ const scrollLeftRightEdge = document
928
+ .querySelector('.scroll-left')
929
+ .getBoundingClientRect().right;
930
+ for (const navigationItem of this.navigationItems.reverse()) {
931
+ const { left, width } = navigationItem.getBoundingClientRect();
932
+ // Scroll to the first navigation item that is less than 75% visible
933
+ const isThreeQuartersVisible = left + 0.25 * width > scrollLeftRightEdge;
934
+ if (!isThreeQuartersVisible) {
935
+ this.navbar.scrollBy({ left: left - scrollLeftRightEdge });
936
+ return;
937
+ }
938
+ }
939
+ }
940
+ /**
941
+ * Temporarily disables interactions with the navbar during scrolling to prevent accidental clicks.
942
+ * Re-enables interactions after a brief delay to avoid blocking the user entirely.
943
+ */
944
+ temporarilyDisableNavbar() {
945
+ if (this.navbarDisableTimer)
946
+ clearTimeout(this.navbarDisableTimer);
947
+ this.navbar.setAttribute('inert', '');
948
+ this.navbarDisableTimer = setTimeout(() => {
949
+ this.navbar.removeAttribute('inert');
950
+ }, NAVBAR_DISABLE_DURATION);
951
+ }
952
+ render() {
953
+ return (index.h(index.Host, { key: '6cd850555585d87eb25e3f6892b8010f5e4d23d6', slot: "post-mainnavigation", version: _package.version }, index.h("div", { key: '3411008120d072920f4de0b71c9dc014748f1390', onClick: () => this.handleBackButtonClick(), class: "back-button" }, index.h("slot", { key: '2e3747380cb546bd6da77e5ffba2403586205a55', name: "back-button" })), index.h("div", { key: 'e9eedd836b3f679ba2861109db2d0811c1142677', "aria-hidden": "true", class: { 'scroll-control scroll-left': true, 'd-none': !this.canScrollLeft }, onMouseDown: e => this.handleScrollButtonClick(e, 'left') }, index.h("post-icon", { key: '628511a2c1812a08828e1aa2b51f26ad01a5a2cf', "aria-hidden": "true", name: "chevronleft" })), index.h("nav", { key: '1b660d65e1984e8701a98a369046f391fd177338', ref: el => (this.navbar = el) }, index.h("slot", { key: '0eb35366ac0bd58509afd6a12f68c2b09396a497' })), index.h("div", { key: '11145ad6602e2df78d3c3f4643cc6e4e960775aa', "aria-hidden": "true", class: { 'scroll-control scroll-right': true, 'd-none': !this.canScrollRight }, onMouseDown: e => this.handleScrollButtonClick(e, 'right') }, index.h("post-icon", { key: '26e795cd00221dbfb1a7632453d0d48993584b0b', "aria-hidden": "true", name: "chevronright" }))));
954
+ }
955
+ };
956
+ PostMainnavigation.style = PostMainnavigationStyle0;
957
+
958
+ const postMegadropdownCss = "@keyframes slide-in{0%{transform:translateX(100%)}100%{transform:translateX(0%)}}@keyframes slide-out{from{transform:translateX(0%)}to{transform:translateX(100%)}}@keyframes slide-down{from{transform:translateY(-100%)}to{transform:translateY(0%)}}@keyframes slide-up{0%{transform:translateY(0%)}100%{transform:translateY(-100%)}}*,::before,::after{box-sizing:border-box}.megadropdown-container{box-shadow:0 8px 6px rgba(0,0,0,.16);position:absolute;background-color:#fafafa;border:none;z-index:1;width:100%;inset-block-start:100%;inset-inline-start:0;border-radius:0}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.megadropdown-container{border-block-end:1px solid CanvasText}}.megadropdown-container.slide-in{animation:slide-down 350ms forwards}.megadropdown-container.slide-out{animation:slide-up 350ms forwards}@media screen and (max-width: 1023.98px){.megadropdown-container{z-index:4;position:fixed;inset-block-start:var(--post-header-navigation-current-inset);inset-inline:0;height:calc(min(var(--post-header-scroll-parent-height, 100dvh),100dvh) - var(--post-header-height));border-block-start:unset;overflow-y:auto;overscroll-behavior:contain}.megadropdown-container.slide-in{animation:slide-in 350ms forwards}.megadropdown-container.slide-out{animation:slide-out 350ms forwards}}@media screen and (min-width: 1024px){.megadropdown-container{max-height:calc(100vh - var(--post-header-height) - 48px);overflow-y:auto}}.megadropdown{padding:31px 40px 40px;background-color:#fafafa}@media screen and (max-width: 1023.98px){.megadropdown{display:flex;flex-direction:column;width:inherit;padding:16px 32px 24px}}@media screen and (max-width: 599.98px){.megadropdown{padding-inline:16px}}.megadropdown .megadropdown-content{gap:1.5rem;display:grid;grid-template-columns:repeat(auto-fit, minmax(min(15vw, 100%), 1fr));grid-auto-rows:1fr auto;grid-auto-flow:dense}@media screen and (max-width: 1023.98px){.megadropdown .megadropdown-content{grid-template-columns:repeat(auto-fit, minmax(min(35vw, 100%), 1fr))}}@media screen and (max-width: 599.98px){.megadropdown .megadropdown-content{grid-template-columns:1fr}}.megadropdown h2{display:none;margin-block:0 8px;font-weight:900}.megadropdown h2 a{text-decoration:none;display:none;font-weight:inherit;border-block:0}@media screen and (max-width: 1023.98px){.megadropdown h2{display:block;font-size:1.25rem}}@media screen and (max-width: 599.98px){.megadropdown h2{font-size:1.125rem}}.megadropdown post-list{display:grid;grid-row:span 2;grid-template-rows:subgrid;row-gap:0px}.megadropdown post-list>[role=list]{flex-direction:unset;display:unset}.megadropdown post-list>*{width:100%}.megadropdown post-list .list-title{display:flex;flex-direction:column-reverse;height:100%}.megadropdown post-list .list-title h3{font-size:20px;display:block;font-weight:900}.megadropdown post-list .list-title h3:not(:has(a)),.megadropdown post-list .list-title h3 a{padding:16px 12px 14px 8px}.megadropdown post-list .list-title h3:not(:has(a)){position:relative}.megadropdown post-list .list-title h3:not(:has(a))::before{content:\"\";background-color:#050400;inset-block-end:0;inset-inline-start:0;width:100%;height:2px;position:absolute}.megadropdown post-list .list-title h3 a{border-radius:0;text-decoration:none;font-size:inherit;display:flex;align-items:center;justify-content:space-between;min-height:53px;width:100%;min-width:100%;height:48px;padding-inline:8px 12px;gap:16px;font-weight:400;position:relative;height:unset;font-weight:900}.megadropdown post-list .list-title h3 a::before{content:\"\";background-color:#050400;bottom:0;width:100%;height:1px;position:absolute;left:0}.megadropdown post-list .list-title h3 a.selected,.megadropdown post-list .list-title h3 a[aria-expanded=true]{background-color:#050400;color:#fff}.megadropdown post-list .list-title h3 a:hover{background-color:#504f4b;color:#fff}.megadropdown post-list .list-title h3 a:hover::before{background-color:#504f4b}.megadropdown post-list .list-title h3 a::before{height:2px}@media screen and (max-width: 1023.98px){.megadropdown post-list .list-title h3{font-size:1rem}.megadropdown post-list .list-title h3:not(:has(a)),.megadropdown post-list .list-title h3 a{padding:14px 12px 12px 8px}}@media screen and (max-width: 599.98px){.megadropdown post-list .list-title h3{font-size:.875rem}}.megadropdown post-list-item>a{padding-block:13px 12px;padding-inline-start:8px;display:flex;text-decoration:none;width:100%;min-width:100%;height:auto;min-height:48px;white-space:normal;word-break:break-word}.megadropdown post-list-item>a:hover{border-block-width:0}@media screen and (min-width: 1024px){.megadropdown post-list-item>a{font-size:1.25rem}}@media screen and (max-width: 1023.98px){.megadropdown post-list-item>a{padding-block:12px 11px}}@media screen and (max-width: 599.98px){.megadropdown post-list-item>a{font-size:.875rem}}.megadropdown .back-button{display:none;margin-block-end:2rem}.megadropdown .back-button .btn{width:auto}@media screen and (max-width: 1023.98px){.megadropdown .back-button{order:-1;display:block}}.megadropdown .close-button{position:absolute;inset-block-start:1rem;inset-inline-end:1rem}@media screen and (max-width: 1023.98px){.megadropdown .close-button{display:none}}";
959
+ const PostMegadropdownStyle0 = postMegadropdownCss;
960
+
961
+ const PostMegadropdown = class {
962
+ constructor(hostRef) {
963
+ index.registerInstance(this, hostRef);
964
+ this.postToggleMegadropdown = index.createEvent(this, "postToggleMegadropdown", 7);
965
+ this.handleClickOutside = (event) => {
966
+ if (this.device !== 'desktop')
967
+ return;
968
+ const target = event.target;
969
+ if (this.host.contains(target)) {
970
+ return;
971
+ }
972
+ if (target instanceof HTMLElement) {
973
+ const trigger = target.closest('post-megadropdown-trigger');
974
+ if (trigger) {
975
+ const targetDropdownId = trigger.getAttribute('for');
976
+ if (targetDropdownId !== this.host.id) {
977
+ return;
978
+ }
979
+ }
980
+ }
981
+ this.hide(false);
982
+ };
983
+ this.device = breakpoints.breakpoint.get('name');
984
+ this.isVisible = false;
985
+ this.animationClass = null;
986
+ }
987
+ breakpointChange(e) {
988
+ this.device = e.detail;
989
+ if (this.device === 'desktop' && this.isVisible) {
990
+ this.animationClass = null;
991
+ }
992
+ }
993
+ disconnectedCallback() {
994
+ this.removeListeners();
995
+ window.removeEventListener('postBreakpoint:name', this.breakpointChange.bind(this));
996
+ if (PostMegadropdown.activeDropdown === this) {
997
+ PostMegadropdown.activeDropdown = null;
998
+ }
999
+ }
1000
+ componentWillRender() {
1001
+ this.getFocusableElements();
1002
+ }
1003
+ /**
1004
+ * Toggles the dropdown visibility based on its current state.
1005
+ */
1006
+ async toggle() {
1007
+ if (this.isVisible) {
1008
+ this.hide();
1009
+ }
1010
+ else {
1011
+ await this.show();
1012
+ }
1013
+ }
1014
+ /**
1015
+ * Displays the dropdown.
1016
+ */
1017
+ async show() {
1018
+ if (PostMegadropdown.activeDropdown && PostMegadropdown.activeDropdown !== this) {
1019
+ // Close the previously active dropdown without animation
1020
+ PostMegadropdown.activeDropdown.forceClose();
1021
+ }
1022
+ else {
1023
+ this.animationClass = 'slide-in';
1024
+ }
1025
+ this.isVisible = true;
1026
+ PostMegadropdown.activeDropdown = this;
1027
+ this.postToggleMegadropdown.emit({ isVisible: this.isVisible });
1028
+ if (this.firstFocusableEl &&
1029
+ window.getComputedStyle(this.firstFocusableEl).display !== 'none') {
1030
+ this.firstFocusableEl.focus();
1031
+ }
1032
+ this.addListeners();
1033
+ }
1034
+ /**
1035
+ * Hides the dropdown with an animation.
1036
+ */
1037
+ async hide(focusParent = true, forceClose = false) {
1038
+ this.postToggleMegadropdown.emit({ isVisible: false, focusParent: focusParent });
1039
+ if (forceClose) {
1040
+ this.forceClose();
1041
+ }
1042
+ else {
1043
+ this.animationClass = 'slide-out';
1044
+ }
1045
+ }
1046
+ /**
1047
+ * Sets focus to the first focusable element within the component.
1048
+ */
1049
+ async focusFirst() {
1050
+ this.firstFocusableEl?.focus();
1051
+ }
1052
+ connectedCallback() {
1053
+ window.addEventListener('postBreakpoint:name', this.breakpointChange.bind(this));
1054
+ }
1055
+ /**
1056
+ * Forces the dropdown to close without animation.
1057
+ */
1058
+ forceClose() {
1059
+ this.isVisible = false;
1060
+ this.animationClass = null;
1061
+ this.postToggleMegadropdown.emit({ isVisible: this.isVisible, focusParent: false });
1062
+ this.removeListeners();
1063
+ }
1064
+ handleAnimationEnd() {
1065
+ if (this.animationClass === 'slide-out') {
1066
+ this.isVisible = false;
1067
+ this.animationClass = null;
1068
+ PostMegadropdown.activeDropdown = null;
1069
+ this.removeListeners();
1070
+ }
1071
+ }
1072
+ addListeners() {
1073
+ this.host.addEventListener('keydown', e => this.keyboardHandler(e));
1074
+ document.addEventListener('keyup', e => this.handleTabOutside(e));
1075
+ document.addEventListener('mousedown', this.handleClickOutside);
1076
+ }
1077
+ removeListeners() {
1078
+ this.host.removeEventListener('keydown', e => this.keyboardHandler(e));
1079
+ document.removeEventListener('keyup', e => this.handleTabOutside(e));
1080
+ document.removeEventListener('mousedown', this.handleClickOutside);
1081
+ }
1082
+ getFocusableElements() {
1083
+ const focusableEls = Array.from(this.host.querySelectorAll('post-list-item, h3, .back-button'));
1084
+ const focusableChildren = focusableEls.flatMap(el => Array.from(getFocusableChildren(el)));
1085
+ this.firstFocusableEl = focusableChildren[0];
1086
+ this.lastFocusableEl = focusableChildren[focusableChildren.length - 1];
1087
+ }
1088
+ // Loop through the focusable children
1089
+ keyboardHandler(e) {
1090
+ if (e.key === 'Tab' && this.device !== 'desktop') {
1091
+ if (e.shiftKey && document.activeElement === this.firstFocusableEl) {
1092
+ // If back tab (TAB + Shift) and first element is focused, focus goes to the last element of the megadropdown
1093
+ e.preventDefault();
1094
+ this.lastFocusableEl.focus();
1095
+ }
1096
+ else if (!e.shiftKey && document.activeElement === this.lastFocusableEl) {
1097
+ // If TAB and last element is focused, focus goes back to the first element of the megadropdown
1098
+ e.preventDefault();
1099
+ this.firstFocusableEl.focus();
1100
+ }
1101
+ }
1102
+ }
1103
+ handleTabOutside(e) {
1104
+ if (e.key === 'Tab' && this.device === 'desktop') {
1105
+ if (!this.host.contains(e.target)) {
1106
+ this.hide(false);
1107
+ }
1108
+ }
1109
+ }
1110
+ render() {
1111
+ const containerStyle = this.isVisible ? {} : { display: 'none' };
1112
+ return (index.h(index.Host, { key: '7426a12ebaeac0ce3b8402c3da4d5393daca059b', version: _package.version }, index.h("div", { key: 'd47b60c334577f5662f19912f12ce941b4b52d94', class: `megadropdown-container ${this.animationClass || ''}`, style: containerStyle, onAnimationEnd: () => this.handleAnimationEnd() }, index.h("div", { key: '2798f217b2b3e43c3c63072884bbbbe7d99ed62f', class: "megadropdown" }, index.h("slot", { key: 'b61f82bbc7f87f65d9b6957e7a4e5d6790b6dd00', name: "megadropdown-title" }), index.h("div", { key: 'f4996a819511cb59185faeedbdcec4be6e6f8a24', class: "megadropdown-content" }, index.h("slot", { key: '54f695c3b3d30a6a1aae7f7dc6f65f4d4d27de68' })), index.h("div", { key: 'b1334295c7d758e20c85b6c6c8cefc31dcf09e20', onClick: () => this.hide(true), class: "back-button" }, index.h("slot", { key: 'c4db69fa3207ce4cb47b725e37b1993820a2a64c', name: "back-button" })), index.h("div", { key: '68b22a3222382586fc749dec63e36edae84360c1', onClick: () => this.hide(true), class: "close-button" }, index.h("slot", { key: '8023b75c931a95dbd9552c1a713790e77e40f526', name: "close-button" }))))));
1113
+ }
1114
+ get host() { return index.getElement(this); }
1115
+ };
1116
+ /** Tracks the currently active dropdown instance. */
1117
+ PostMegadropdown.activeDropdown = null;
1118
+ PostMegadropdown.style = PostMegadropdownStyle0;
1119
+
1120
+ const postMegadropdownTriggerCss = "post-megadropdown-trigger{width:100%;position:relative;z-index:3}";
1121
+ const PostMegadropdownTriggerStyle0 = postMegadropdownTriggerCss;
1122
+
1123
+ const PostMegadropdownTrigger = class {
1124
+ constructor(hostRef) {
1125
+ index.registerInstance(this, hostRef);
1126
+ /**
1127
+ * Reference to the slotted button within the trigger, if present.
1128
+ * Used to manage click and key events for mega dropdown control.
1129
+ */
1130
+ this.slottedButton = null;
1131
+ /**
1132
+ * Tracks whether this trigger's dropdown was expanded before a state change.
1133
+ * Used to determine if this trigger should handle focus when its dropdown closes.
1134
+ */
1135
+ this.wasExpanded = false;
1136
+ this.handleKeyDown = (event) => {
1137
+ if (event.key === 'Enter' || event.key === ' ') {
1138
+ event.preventDefault();
1139
+ this.handleToggle();
1140
+ if (this.megadropdown && !this.ariaExpanded) {
1141
+ setTimeout(() => this.megadropdown.focusFirst(), 100);
1142
+ }
1143
+ }
1144
+ };
1145
+ this.handleToggleMegadropdown = (event) => {
1146
+ eventGuard.eventGuard(this.host, event, { targetLocalName: 'post-megadropdown' }, () => {
1147
+ if (event.target.id === this.for) {
1148
+ this.ariaExpanded = event.detail.isVisible;
1149
+ // Focus on the trigger parent of the dropdown after it's closed if the close button had been clicked
1150
+ if (this.wasExpanded && !this.ariaExpanded && event.detail.focusParent) {
1151
+ setTimeout(() => {
1152
+ this.slottedButton?.focus();
1153
+ }, 100);
1154
+ }
1155
+ this.wasExpanded = this.ariaExpanded;
1156
+ if (this.slottedButton) {
1157
+ this.slottedButton.setAttribute('aria-expanded', this.ariaExpanded.toString());
1158
+ }
1159
+ }
1160
+ });
1161
+ };
1162
+ this.for = undefined;
1163
+ this.ariaExpanded = false;
1164
+ }
1165
+ /**
1166
+ * Watch for changes to the `for` property to validate its type and ensure it is a string.
1167
+ * @param forValue - The new value of the `for` property.
1168
+ */
1169
+ validateControlFor() {
1170
+ checkType.checkType(this, 'for', 'string');
1171
+ }
1172
+ get megadropdown() {
1173
+ const ref = document.getElementById(this.for);
1174
+ return ref && ref.localName === 'post-megadropdown'
1175
+ ? ref
1176
+ : null;
1177
+ }
1178
+ handleToggle() {
1179
+ if (this.megadropdown) {
1180
+ this.megadropdown.toggle();
1181
+ }
1182
+ else {
1183
+ console.warn(`No post-megadropdown found with ID: ${this.for}`);
1184
+ }
1185
+ }
1186
+ componentDidLoad() {
1187
+ this.validateControlFor();
1188
+ // Check if the mega dropdown attached to the trigger is expanded or not
1189
+ document.addEventListener('postToggleMegadropdown', this.handleToggleMegadropdown);
1190
+ this.slottedButton = this.host.querySelector('button');
1191
+ if (this.slottedButton) {
1192
+ this.slottedButton.setAttribute('aria-haspopup', 'menu');
1193
+ this.slottedButton.addEventListener('click', () => {
1194
+ this.handleToggle();
1195
+ });
1196
+ this.slottedButton.addEventListener('keydown', this.handleKeyDown);
1197
+ }
1198
+ else {
1199
+ console.warn('No button found within post-megadropdown-trigger');
1200
+ }
1201
+ }
1202
+ disconnectedCallback() {
1203
+ document.removeEventListener('postToggleMegadropdown', this.handleToggleMegadropdown);
1204
+ }
1205
+ render() {
1206
+ return (index.h(index.Host, { key: '86b85efede8d9b19f3f0560f500f33f5e172177f', "data-version": _package.version, "tab-index": "-1" }, index.h("button", { key: '0f810e4c38bc4abf23ac60ab27b36d408e7ced0d' }, index.h("slot", { key: '2a522ac7e15ef8ac077b73cdebf629b89ea173c6' }))));
1207
+ }
1208
+ get host() { return index.getElement(this); }
1209
+ static get watchers() { return {
1210
+ "for": ["validateControlFor"]
1211
+ }; }
1212
+ };
1213
+ PostMegadropdownTrigger.style = PostMegadropdownTriggerStyle0;
1214
+
1215
+ const postMenuCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}:host{display:block}post-popovercontainer{padding:var(--post-menu-padding);background-color:var(--post-menu-bg, #ffffff);border-color:var(--post-menu-bg, #ffffff)}.popover-container{display:flex;flex-direction:column}";
1216
+ const PostMenuStyle0 = postMenuCss;
1217
+
1218
+ const PostMenu = class {
1219
+ constructor(hostRef) {
1220
+ index.registerInstance(this, hostRef);
1221
+ this.toggleMenu = index.createEvent(this, "toggleMenu", 7);
1222
+ this.lastFocusedElement = null;
1223
+ this.KEYCODES = {
1224
+ SPACE: ' ',
1225
+ ENTER: 'Enter',
1226
+ UP: 'ArrowUp',
1227
+ DOWN: 'ArrowDown',
1228
+ TAB: 'Tab',
1229
+ HOME: 'Home',
1230
+ END: 'End',
1231
+ ESCAPE: 'Escape',
1232
+ };
1233
+ this.handleKeyDown = (e) => {
1234
+ e.stopPropagation();
1235
+ if (e.key === this.KEYCODES.ESCAPE) {
1236
+ this.toggle(this.host);
1237
+ return;
1238
+ }
1239
+ if (Object.values(this.KEYCODES).includes(e.key)) {
1240
+ this.controlKeyDownHandler(e);
1241
+ }
1242
+ };
1243
+ this.handlePostToggle = (event) => {
1244
+ eventGuard.eventGuard(this.host, event, { targetLocalName: 'post-popovercontainer', delegatorSelector: 'post-menu' }, () => {
1245
+ this.isVisible = event.detail;
1246
+ this.toggleMenu.emit(this.isVisible);
1247
+ requestAnimationFrame(() => {
1248
+ if (this.isVisible) {
1249
+ this.lastFocusedElement = this.root?.activeElement;
1250
+ const menuItems = this.getSlottedItems();
1251
+ if (menuItems.length > 0) {
1252
+ menuItems[0].focus();
1253
+ }
1254
+ }
1255
+ else if (this.lastFocusedElement) {
1256
+ this.lastFocusedElement.focus();
1257
+ }
1258
+ });
1259
+ });
1260
+ };
1261
+ this.handleClick = (e) => {
1262
+ const target = e.target;
1263
+ if (['BUTTON', 'A', 'INPUT', 'SELECT', 'TEXTAREA'].includes(target.tagName)) {
1264
+ this.toggle(this.host);
1265
+ }
1266
+ };
1267
+ this.placement = 'bottom';
1268
+ this.isVisible = false;
1269
+ }
1270
+ connectedCallback() {
1271
+ this.root = getRoot.getRoot(this.host);
1272
+ this.host.addEventListener('keydown', this.handleKeyDown);
1273
+ this.host.addEventListener('click', this.handleClick);
1274
+ }
1275
+ disconnectedCallback() {
1276
+ this.host.removeEventListener('keydown', this.handleKeyDown);
1277
+ this.host.removeEventListener('click', this.handleClick);
1278
+ this.popoverRef?.removeEventListener('postToggle', this.handlePostToggle);
1279
+ }
1280
+ componentDidLoad() {
1281
+ if (this.popoverRef) {
1282
+ this.popoverRef.addEventListener('postToggle', this.handlePostToggle);
1283
+ }
1284
+ }
1285
+ /**
1286
+ * Toggles the menu visibility based on its current state.
1287
+ */
1288
+ async toggle(target) {
1289
+ if (this.popoverRef) {
1290
+ await this.popoverRef.toggle(target);
1291
+ }
1292
+ else {
1293
+ console.error('toggle: popoverRef is null or undefined');
1294
+ }
1295
+ }
1296
+ /**
1297
+ * Displays the popover menu, focusing the first menu item.
1298
+ *
1299
+ * @param target - The HTML element relative to which the popover menu should be displayed.
1300
+ */
1301
+ async show(target) {
1302
+ if (this.popoverRef) {
1303
+ await this.popoverRef.show(target);
1304
+ }
1305
+ else {
1306
+ console.error('show: popoverRef is null or undefined');
1307
+ }
1308
+ }
1309
+ /**
1310
+ * Hides the popover menu and restores focus to the previously focused element.
1311
+ */
1312
+ async hide() {
1313
+ if (this.popoverRef) {
1314
+ await this.popoverRef.hide();
1315
+ }
1316
+ else {
1317
+ console.error('hide: popoverRef is null or undefined');
1318
+ }
1319
+ }
1320
+ controlKeyDownHandler(e) {
1321
+ const menuItems = this.getSlottedItems();
1322
+ if (!menuItems.length) {
1323
+ return;
1324
+ }
1325
+ let currentIndex = menuItems.findIndex(el => {
1326
+ // Check if the item is currently focused within its rendered scope (document or shadow root)
1327
+ return el === getRoot.getRoot(el).activeElement;
1328
+ });
1329
+ switch (e.key) {
1330
+ case this.KEYCODES.UP:
1331
+ e.preventDefault();
1332
+ currentIndex = (currentIndex - 1 + menuItems.length) % menuItems.length;
1333
+ break;
1334
+ case this.KEYCODES.DOWN:
1335
+ e.preventDefault();
1336
+ currentIndex = (currentIndex + 1) % menuItems.length;
1337
+ break;
1338
+ case this.KEYCODES.HOME:
1339
+ currentIndex = 0;
1340
+ break;
1341
+ case this.KEYCODES.END:
1342
+ e.preventDefault();
1343
+ currentIndex = menuItems.length - 1;
1344
+ break;
1345
+ case this.KEYCODES.SPACE:
1346
+ this.toggle(this.host);
1347
+ return;
1348
+ case this.KEYCODES.TAB:
1349
+ this.toggle(this.host);
1350
+ break;
1351
+ }
1352
+ if (menuItems[currentIndex]) {
1353
+ menuItems[currentIndex].focus();
1354
+ }
1355
+ }
1356
+ getSlottedItems() {
1357
+ const slot = this.host.shadowRoot.querySelector('slot');
1358
+ const slottedElements = slot ? slot.assignedElements() : [];
1359
+ return (slottedElements
1360
+ // If the element is a slot, get the assigned elements
1361
+ .flatMap(el => (el instanceof HTMLSlotElement ? el.assignedElements() : el))
1362
+ // For each menu item, get any focusable children (e.g., buttons, links)
1363
+ .flatMap(el => Array.from(getFocusableChildren(el))));
1364
+ }
1365
+ render() {
1366
+ return (index.h(index.Host, { key: 'dd3bbcbf568e529588bcf5c90b8c2d4d07d454fb', "data-version": _package.version, role: "menu" }, index.h("post-popovercontainer", { key: '17a24933ef087cc8699b00f7165fff33756da9a8', placement: this.placement, ref: e => (this.popoverRef = e) }, index.h("div", { key: '9ff3d687146c88cf153ea745abcaf7a3267be620', class: "popover-container", part: "popover-container" }, index.h("slot", { key: 'aff50800748410f6e2583690620c12e47b4c7a22' })))));
1367
+ }
1368
+ get host() { return index.getElement(this); }
1369
+ };
1370
+ PostMenu.style = PostMenuStyle0;
1371
+
1372
+ const postMenuTriggerCss = ":host{display:inline-block}";
1373
+ const PostMenuTriggerStyle0 = postMenuTriggerCss;
1374
+
1375
+ const PostMenuTrigger = class {
1376
+ constructor(hostRef) {
1377
+ index.registerInstance(this, hostRef);
1378
+ /**
1379
+ * Reference to the slotted button within the trigger, if present.
1380
+ * Used to manage click and key events for menu control.
1381
+ */
1382
+ this.slottedButton = null;
1383
+ this.handleKeyDown = (e) => {
1384
+ if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
1385
+ e.preventDefault();
1386
+ this.handleToggle();
1387
+ }
1388
+ };
1389
+ this.for = undefined;
1390
+ this.ariaExpanded = false;
1391
+ }
1392
+ /**
1393
+ * Watch for changes to the `for` property to validate its type and ensure it is a string.
1394
+ * @param forValue - The new value of the `for` property.
1395
+ */
1396
+ validateControlFor() {
1397
+ checkType.checkType(this, 'for', 'string');
1398
+ }
1399
+ get menu() {
1400
+ const ref = this.root.getElementById(this.for);
1401
+ return ref && ref.localName === 'post-menu' ? ref : null;
1402
+ }
1403
+ handleToggle() {
1404
+ if (this.menu) {
1405
+ this.menu.toggle(this.host);
1406
+ }
1407
+ else {
1408
+ console.warn(`No post-menu found with ID: ${this.for}`);
1409
+ }
1410
+ }
1411
+ connectedCallback() {
1412
+ this.root = getRoot.getRoot(this.host);
1413
+ }
1414
+ componentDidLoad() {
1415
+ this.validateControlFor();
1416
+ this.slottedButton = this.host.querySelector('button');
1417
+ // Check if the slottedButton is within a web component
1418
+ if (!this.slottedButton) {
1419
+ const webComponent = this.host.querySelector('.menu-trigger-webc');
1420
+ if (webComponent.shadowRoot) {
1421
+ const slottedButton = webComponent.shadowRoot.querySelector('button');
1422
+ if (slottedButton) {
1423
+ this.slottedButton = slottedButton;
1424
+ }
1425
+ }
1426
+ }
1427
+ if (this.slottedButton) {
1428
+ this.slottedButton.setAttribute('aria-haspopup', 'menu');
1429
+ // Listen to the `toggleMenu` event emitted by the `post-menu` component
1430
+ if (this.menu && this.slottedButton) {
1431
+ this.menu.addEventListener('toggleMenu', (event) => {
1432
+ this.ariaExpanded = event.detail;
1433
+ this.slottedButton.setAttribute('aria-expanded', this.ariaExpanded.toString());
1434
+ });
1435
+ }
1436
+ this.slottedButton.addEventListener('click', () => {
1437
+ this.handleToggle();
1438
+ });
1439
+ this.slottedButton.addEventListener('keydown', this.handleKeyDown);
1440
+ }
1441
+ else {
1442
+ console.warn('No button found within post-menu-trigger');
1443
+ }
1444
+ }
1445
+ render() {
1446
+ return (index.h(index.Host, { key: '1b9589febc2976d17eed3363d91b4321473b7b5e', "data-version": _package.version, "tab-index": "-1" }, index.h("slot", { key: 'bec55f97274084ab4721dc085dc9e1c3a216c0a3' })));
1447
+ }
1448
+ get host() { return index.getElement(this); }
1449
+ static get watchers() { return {
1450
+ "for": ["validateControlFor"]
1451
+ }; }
1452
+ };
1453
+ PostMenuTrigger.style = PostMenuTriggerStyle0;
1454
+
1455
+ /**
1456
+ * Custom positioning reference element.
1457
+ * @see https://floating-ui.com/docs/virtual-elements
1458
+ */
1459
+
1460
+ const sides = ['top', 'right', 'bottom', 'left'];
1461
+ const alignments = ['start', 'end'];
1462
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
1463
+ const min = Math.min;
1464
+ const max = Math.max;
1465
+ const round = Math.round;
1466
+ const floor = Math.floor;
1467
+ const createCoords = v => ({
1468
+ x: v,
1469
+ y: v
1470
+ });
1471
+ const oppositeSideMap = {
1472
+ left: 'right',
1473
+ right: 'left',
1474
+ bottom: 'top',
1475
+ top: 'bottom'
1476
+ };
1477
+ const oppositeAlignmentMap = {
1478
+ start: 'end',
1479
+ end: 'start'
1480
+ };
1481
+ function clamp(start, value, end) {
1482
+ return max(start, min(value, end));
1483
+ }
1484
+ function evaluate(value, param) {
1485
+ return typeof value === 'function' ? value(param) : value;
1486
+ }
1487
+ function getSide(placement) {
1488
+ return placement.split('-')[0];
1489
+ }
1490
+ function getAlignment(placement) {
1491
+ return placement.split('-')[1];
1492
+ }
1493
+ function getOppositeAxis(axis) {
1494
+ return axis === 'x' ? 'y' : 'x';
1495
+ }
1496
+ function getAxisLength(axis) {
1497
+ return axis === 'y' ? 'height' : 'width';
1498
+ }
1499
+ function getSideAxis(placement) {
1500
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
1501
+ }
1502
+ function getAlignmentAxis(placement) {
1503
+ return getOppositeAxis(getSideAxis(placement));
1504
+ }
1505
+ function getAlignmentSides(placement, rects, rtl) {
1506
+ if (rtl === void 0) {
1507
+ rtl = false;
1508
+ }
1509
+ const alignment = getAlignment(placement);
1510
+ const alignmentAxis = getAlignmentAxis(placement);
1511
+ const length = getAxisLength(alignmentAxis);
1512
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
1513
+ if (rects.reference[length] > rects.floating[length]) {
1514
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1515
+ }
1516
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1517
+ }
1518
+ function getExpandedPlacements(placement) {
1519
+ const oppositePlacement = getOppositePlacement(placement);
1520
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1521
+ }
1522
+ function getOppositeAlignmentPlacement(placement) {
1523
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
1524
+ }
1525
+ function getSideList(side, isStart, rtl) {
1526
+ const lr = ['left', 'right'];
1527
+ const rl = ['right', 'left'];
1528
+ const tb = ['top', 'bottom'];
1529
+ const bt = ['bottom', 'top'];
1530
+ switch (side) {
1531
+ case 'top':
1532
+ case 'bottom':
1533
+ if (rtl) return isStart ? rl : lr;
1534
+ return isStart ? lr : rl;
1535
+ case 'left':
1536
+ case 'right':
1537
+ return isStart ? tb : bt;
1538
+ default:
1539
+ return [];
1540
+ }
1541
+ }
1542
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1543
+ const alignment = getAlignment(placement);
1544
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
1545
+ if (alignment) {
1546
+ list = list.map(side => side + "-" + alignment);
1547
+ if (flipAlignment) {
1548
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1549
+ }
1550
+ }
1551
+ return list;
1552
+ }
1553
+ function getOppositePlacement(placement) {
1554
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
1555
+ }
1556
+ function expandPaddingObject(padding) {
1557
+ return {
1558
+ top: 0,
1559
+ right: 0,
1560
+ bottom: 0,
1561
+ left: 0,
1562
+ ...padding
1563
+ };
1564
+ }
1565
+ function getPaddingObject(padding) {
1566
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
1567
+ top: padding,
1568
+ right: padding,
1569
+ bottom: padding,
1570
+ left: padding
1571
+ };
1572
+ }
1573
+ function rectToClientRect(rect) {
1574
+ const {
1575
+ x,
1576
+ y,
1577
+ width,
1578
+ height
1579
+ } = rect;
1580
+ return {
1581
+ width,
1582
+ height,
1583
+ top: y,
1584
+ left: x,
1585
+ right: x + width,
1586
+ bottom: y + height,
1587
+ x,
1588
+ y
1589
+ };
1590
+ }
1591
+
1592
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1593
+ let {
1594
+ reference,
1595
+ floating
1596
+ } = _ref;
1597
+ const sideAxis = getSideAxis(placement);
1598
+ const alignmentAxis = getAlignmentAxis(placement);
1599
+ const alignLength = getAxisLength(alignmentAxis);
1600
+ const side = getSide(placement);
1601
+ const isVertical = sideAxis === 'y';
1602
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1603
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1604
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1605
+ let coords;
1606
+ switch (side) {
1607
+ case 'top':
1608
+ coords = {
1609
+ x: commonX,
1610
+ y: reference.y - floating.height
1611
+ };
1612
+ break;
1613
+ case 'bottom':
1614
+ coords = {
1615
+ x: commonX,
1616
+ y: reference.y + reference.height
1617
+ };
1618
+ break;
1619
+ case 'right':
1620
+ coords = {
1621
+ x: reference.x + reference.width,
1622
+ y: commonY
1623
+ };
1624
+ break;
1625
+ case 'left':
1626
+ coords = {
1627
+ x: reference.x - floating.width,
1628
+ y: commonY
1629
+ };
1630
+ break;
1631
+ default:
1632
+ coords = {
1633
+ x: reference.x,
1634
+ y: reference.y
1635
+ };
1636
+ }
1637
+ switch (getAlignment(placement)) {
1638
+ case 'start':
1639
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1640
+ break;
1641
+ case 'end':
1642
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1643
+ break;
1644
+ }
1645
+ return coords;
1646
+ }
1647
+
1648
+ /**
1649
+ * Computes the `x` and `y` coordinates that will place the floating element
1650
+ * next to a given reference element.
1651
+ *
1652
+ * This export does not have any `platform` interface logic. You will need to
1653
+ * write one for the platform you are using Floating UI with.
1654
+ */
1655
+ const computePosition$1 = async (reference, floating, config) => {
1656
+ const {
1657
+ placement = 'bottom',
1658
+ strategy = 'absolute',
1659
+ middleware = [],
1660
+ platform
1661
+ } = config;
1662
+ const validMiddleware = middleware.filter(Boolean);
1663
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1664
+ let rects = await platform.getElementRects({
1665
+ reference,
1666
+ floating,
1667
+ strategy
1668
+ });
1669
+ let {
1670
+ x,
1671
+ y
1672
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1673
+ let statefulPlacement = placement;
1674
+ let middlewareData = {};
1675
+ let resetCount = 0;
1676
+ for (let i = 0; i < validMiddleware.length; i++) {
1677
+ const {
1678
+ name,
1679
+ fn
1680
+ } = validMiddleware[i];
1681
+ const {
1682
+ x: nextX,
1683
+ y: nextY,
1684
+ data,
1685
+ reset
1686
+ } = await fn({
1687
+ x,
1688
+ y,
1689
+ initialPlacement: placement,
1690
+ placement: statefulPlacement,
1691
+ strategy,
1692
+ middlewareData,
1693
+ rects,
1694
+ platform,
1695
+ elements: {
1696
+ reference,
1697
+ floating
1698
+ }
1699
+ });
1700
+ x = nextX != null ? nextX : x;
1701
+ y = nextY != null ? nextY : y;
1702
+ middlewareData = {
1703
+ ...middlewareData,
1704
+ [name]: {
1705
+ ...middlewareData[name],
1706
+ ...data
1707
+ }
1708
+ };
1709
+ if (reset && resetCount <= 50) {
1710
+ resetCount++;
1711
+ if (typeof reset === 'object') {
1712
+ if (reset.placement) {
1713
+ statefulPlacement = reset.placement;
1714
+ }
1715
+ if (reset.rects) {
1716
+ rects = reset.rects === true ? await platform.getElementRects({
1717
+ reference,
1718
+ floating,
1719
+ strategy
1720
+ }) : reset.rects;
1721
+ }
1722
+ ({
1723
+ x,
1724
+ y
1725
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1726
+ }
1727
+ i = -1;
1728
+ }
1729
+ }
1730
+ return {
1731
+ x,
1732
+ y,
1733
+ placement: statefulPlacement,
1734
+ strategy,
1735
+ middlewareData
1736
+ };
1737
+ };
1738
+
1739
+ /**
1740
+ * Resolves with an object of overflow side offsets that determine how much the
1741
+ * element is overflowing a given clipping boundary on each side.
1742
+ * - positive = overflowing the boundary by that number of pixels
1743
+ * - negative = how many pixels left before it will overflow
1744
+ * - 0 = lies flush with the boundary
1745
+ * @see https://floating-ui.com/docs/detectOverflow
1746
+ */
1747
+ async function detectOverflow(state, options) {
1748
+ var _await$platform$isEle;
1749
+ if (options === void 0) {
1750
+ options = {};
1751
+ }
1752
+ const {
1753
+ x,
1754
+ y,
1755
+ platform,
1756
+ rects,
1757
+ elements,
1758
+ strategy
1759
+ } = state;
1760
+ const {
1761
+ boundary = 'clippingAncestors',
1762
+ rootBoundary = 'viewport',
1763
+ elementContext = 'floating',
1764
+ altBoundary = false,
1765
+ padding = 0
1766
+ } = evaluate(options, state);
1767
+ const paddingObject = getPaddingObject(padding);
1768
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1769
+ const element = elements[altBoundary ? altContext : elementContext];
1770
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1771
+ 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))),
1772
+ boundary,
1773
+ rootBoundary,
1774
+ strategy
1775
+ }));
1776
+ const rect = elementContext === 'floating' ? {
1777
+ x,
1778
+ y,
1779
+ width: rects.floating.width,
1780
+ height: rects.floating.height
1781
+ } : rects.reference;
1782
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1783
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1784
+ x: 1,
1785
+ y: 1
1786
+ } : {
1787
+ x: 1,
1788
+ y: 1
1789
+ };
1790
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1791
+ elements,
1792
+ rect,
1793
+ offsetParent,
1794
+ strategy
1795
+ }) : rect);
1796
+ return {
1797
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1798
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1799
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1800
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1801
+ };
1802
+ }
1803
+
1804
+ /**
1805
+ * Provides data to position an inner element of the floating element so that it
1806
+ * appears centered to the reference element.
1807
+ * @see https://floating-ui.com/docs/arrow
1808
+ */
1809
+ const arrow$1 = options => ({
1810
+ name: 'arrow',
1811
+ options,
1812
+ async fn(state) {
1813
+ const {
1814
+ x,
1815
+ y,
1816
+ placement,
1817
+ rects,
1818
+ platform,
1819
+ elements,
1820
+ middlewareData
1821
+ } = state;
1822
+ // Since `element` is required, we don't Partial<> the type.
1823
+ const {
1824
+ element,
1825
+ padding = 0
1826
+ } = evaluate(options, state) || {};
1827
+ if (element == null) {
1828
+ return {};
1829
+ }
1830
+ const paddingObject = getPaddingObject(padding);
1831
+ const coords = {
1832
+ x,
1833
+ y
1834
+ };
1835
+ const axis = getAlignmentAxis(placement);
1836
+ const length = getAxisLength(axis);
1837
+ const arrowDimensions = await platform.getDimensions(element);
1838
+ const isYAxis = axis === 'y';
1839
+ const minProp = isYAxis ? 'top' : 'left';
1840
+ const maxProp = isYAxis ? 'bottom' : 'right';
1841
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1842
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1843
+ const startDiff = coords[axis] - rects.reference[axis];
1844
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1845
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1846
+
1847
+ // DOM platform can return `window` as the `offsetParent`.
1848
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1849
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1850
+ }
1851
+ const centerToReference = endDiff / 2 - startDiff / 2;
1852
+
1853
+ // If the padding is large enough that it causes the arrow to no longer be
1854
+ // centered, modify the padding so that it is centered.
1855
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1856
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1857
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1858
+
1859
+ // Make sure the arrow doesn't overflow the floating element if the center
1860
+ // point is outside the floating element's bounds.
1861
+ const min$1 = minPadding;
1862
+ const max = clientSize - arrowDimensions[length] - maxPadding;
1863
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1864
+ const offset = clamp(min$1, center, max);
1865
+
1866
+ // If the reference is small enough that the arrow's padding causes it to
1867
+ // to point to nothing for an aligned placement, adjust the offset of the
1868
+ // floating element itself. To ensure `shift()` continues to take action,
1869
+ // a single reset is performed when this is true.
1870
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1871
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1872
+ return {
1873
+ [axis]: coords[axis] + alignmentOffset,
1874
+ data: {
1875
+ [axis]: offset,
1876
+ centerOffset: center - offset - alignmentOffset,
1877
+ ...(shouldAddOffset && {
1878
+ alignmentOffset
1879
+ })
1880
+ },
1881
+ reset: shouldAddOffset
1882
+ };
1883
+ }
1884
+ });
1885
+
1886
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1887
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1888
+ return allowedPlacementsSortedByAlignment.filter(placement => {
1889
+ if (alignment) {
1890
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1891
+ }
1892
+ return true;
1893
+ });
1894
+ }
1895
+ /**
1896
+ * Optimizes the visibility of the floating element by choosing the placement
1897
+ * that has the most space available automatically, without needing to specify a
1898
+ * preferred placement. Alternative to `flip`.
1899
+ * @see https://floating-ui.com/docs/autoPlacement
1900
+ */
1901
+ const autoPlacement = function (options) {
1902
+ if (options === void 0) {
1903
+ options = {};
1904
+ }
1905
+ return {
1906
+ name: 'autoPlacement',
1907
+ options,
1908
+ async fn(state) {
1909
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1910
+ const {
1911
+ rects,
1912
+ middlewareData,
1913
+ placement,
1914
+ platform,
1915
+ elements
1916
+ } = state;
1917
+ const {
1918
+ crossAxis = false,
1919
+ alignment,
1920
+ allowedPlacements = placements,
1921
+ autoAlignment = true,
1922
+ ...detectOverflowOptions
1923
+ } = evaluate(options, state);
1924
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1925
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1926
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1927
+ const currentPlacement = placements$1[currentIndex];
1928
+ if (currentPlacement == null) {
1929
+ return {};
1930
+ }
1931
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1932
+
1933
+ // Make `computeCoords` start from the right place.
1934
+ if (placement !== currentPlacement) {
1935
+ return {
1936
+ reset: {
1937
+ placement: placements$1[0]
1938
+ }
1939
+ };
1940
+ }
1941
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1942
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1943
+ placement: currentPlacement,
1944
+ overflows: currentOverflows
1945
+ }];
1946
+ const nextPlacement = placements$1[currentIndex + 1];
1947
+
1948
+ // There are more placements to check.
1949
+ if (nextPlacement) {
1950
+ return {
1951
+ data: {
1952
+ index: currentIndex + 1,
1953
+ overflows: allOverflows
1954
+ },
1955
+ reset: {
1956
+ placement: nextPlacement
1957
+ }
1958
+ };
1959
+ }
1960
+ const placementsSortedByMostSpace = allOverflows.map(d => {
1961
+ const alignment = getAlignment(d.placement);
1962
+ return [d.placement, alignment && crossAxis ?
1963
+ // Check along the mainAxis and main crossAxis side.
1964
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1965
+ // Check only the mainAxis.
1966
+ d.overflows[0], d.overflows];
1967
+ }).sort((a, b) => a[1] - b[1]);
1968
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1969
+ // Aligned placements should not check their opposite crossAxis
1970
+ // side.
1971
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1972
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1973
+ if (resetPlacement !== placement) {
1974
+ return {
1975
+ data: {
1976
+ index: currentIndex + 1,
1977
+ overflows: allOverflows
1978
+ },
1979
+ reset: {
1980
+ placement: resetPlacement
1981
+ }
1982
+ };
1983
+ }
1984
+ return {};
1985
+ }
1986
+ };
1987
+ };
1988
+
1989
+ /**
1990
+ * Optimizes the visibility of the floating element by flipping the `placement`
1991
+ * in order to keep it in view when the preferred placement(s) will overflow the
1992
+ * clipping boundary. Alternative to `autoPlacement`.
1993
+ * @see https://floating-ui.com/docs/flip
1994
+ */
1995
+ const flip$1 = function (options) {
1996
+ if (options === void 0) {
1997
+ options = {};
1998
+ }
1999
+ return {
2000
+ name: 'flip',
2001
+ options,
2002
+ async fn(state) {
2003
+ var _middlewareData$arrow, _middlewareData$flip;
2004
+ const {
2005
+ placement,
2006
+ middlewareData,
2007
+ rects,
2008
+ initialPlacement,
2009
+ platform,
2010
+ elements
2011
+ } = state;
2012
+ const {
2013
+ mainAxis: checkMainAxis = true,
2014
+ crossAxis: checkCrossAxis = true,
2015
+ fallbackPlacements: specifiedFallbackPlacements,
2016
+ fallbackStrategy = 'bestFit',
2017
+ fallbackAxisSideDirection = 'none',
2018
+ flipAlignment = true,
2019
+ ...detectOverflowOptions
2020
+ } = evaluate(options, state);
2021
+
2022
+ // If a reset by the arrow was caused due to an alignment offset being
2023
+ // added, we should skip any logic now since `flip()` has already done its
2024
+ // work.
2025
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
2026
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2027
+ return {};
2028
+ }
2029
+ const side = getSide(placement);
2030
+ const initialSideAxis = getSideAxis(initialPlacement);
2031
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
2032
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2033
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
2034
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
2035
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
2036
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
2037
+ }
2038
+ const placements = [initialPlacement, ...fallbackPlacements];
2039
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2040
+ const overflows = [];
2041
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
2042
+ if (checkMainAxis) {
2043
+ overflows.push(overflow[side]);
2044
+ }
2045
+ if (checkCrossAxis) {
2046
+ const sides = getAlignmentSides(placement, rects, rtl);
2047
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
2048
+ }
2049
+ overflowsData = [...overflowsData, {
2050
+ placement,
2051
+ overflows
2052
+ }];
2053
+
2054
+ // One or more sides is overflowing.
2055
+ if (!overflows.every(side => side <= 0)) {
2056
+ var _middlewareData$flip2, _overflowsData$filter;
2057
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
2058
+ const nextPlacement = placements[nextIndex];
2059
+ if (nextPlacement) {
2060
+ var _overflowsData$;
2061
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
2062
+ const hasInitialMainAxisOverflow = ((_overflowsData$ = overflowsData[0]) == null ? void 0 : _overflowsData$.overflows[0]) > 0;
2063
+ if (!ignoreCrossAxisOverflow || hasInitialMainAxisOverflow) {
2064
+ // Try next placement and re-run the lifecycle.
2065
+ return {
2066
+ data: {
2067
+ index: nextIndex,
2068
+ overflows: overflowsData
2069
+ },
2070
+ reset: {
2071
+ placement: nextPlacement
2072
+ }
2073
+ };
2074
+ }
2075
+ }
2076
+
2077
+ // First, find the candidates that fit on the mainAxis side of overflow,
2078
+ // then find the placement that fits the best on the main crossAxis side.
2079
+ 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;
2080
+
2081
+ // Otherwise fallback.
2082
+ if (!resetPlacement) {
2083
+ switch (fallbackStrategy) {
2084
+ case 'bestFit':
2085
+ {
2086
+ var _overflowsData$filter2;
2087
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
2088
+ if (hasFallbackAxisSideDirection) {
2089
+ const currentSideAxis = getSideAxis(d.placement);
2090
+ return currentSideAxis === initialSideAxis ||
2091
+ // Create a bias to the `y` side axis due to horizontal
2092
+ // reading directions favoring greater width.
2093
+ currentSideAxis === 'y';
2094
+ }
2095
+ return true;
2096
+ }).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];
2097
+ if (placement) {
2098
+ resetPlacement = placement;
2099
+ }
2100
+ break;
2101
+ }
2102
+ case 'initialPlacement':
2103
+ resetPlacement = initialPlacement;
2104
+ break;
2105
+ }
2106
+ }
2107
+ if (placement !== resetPlacement) {
2108
+ return {
2109
+ reset: {
2110
+ placement: resetPlacement
2111
+ }
2112
+ };
2113
+ }
2114
+ }
2115
+ return {};
2116
+ }
2117
+ };
2118
+ };
2119
+
2120
+ function getSideOffsets(overflow, rect) {
2121
+ return {
2122
+ top: overflow.top - rect.height,
2123
+ right: overflow.right - rect.width,
2124
+ bottom: overflow.bottom - rect.height,
2125
+ left: overflow.left - rect.width
2126
+ };
2127
+ }
2128
+ function isAnySideFullyClipped(overflow) {
2129
+ return sides.some(side => overflow[side] >= 0);
2130
+ }
2131
+ /**
2132
+ * Provides data to hide the floating element in applicable situations, such as
2133
+ * when it is not in the same clipping context as the reference element.
2134
+ * @see https://floating-ui.com/docs/hide
2135
+ */
2136
+ const hide = function (options) {
2137
+ if (options === void 0) {
2138
+ options = {};
2139
+ }
2140
+ return {
2141
+ name: 'hide',
2142
+ options,
2143
+ async fn(state) {
2144
+ const {
2145
+ rects
2146
+ } = state;
2147
+ const {
2148
+ strategy = 'referenceHidden',
2149
+ ...detectOverflowOptions
2150
+ } = evaluate(options, state);
2151
+ switch (strategy) {
2152
+ case 'referenceHidden':
2153
+ {
2154
+ const overflow = await detectOverflow(state, {
2155
+ ...detectOverflowOptions,
2156
+ elementContext: 'reference'
2157
+ });
2158
+ const offsets = getSideOffsets(overflow, rects.reference);
2159
+ return {
2160
+ data: {
2161
+ referenceHiddenOffsets: offsets,
2162
+ referenceHidden: isAnySideFullyClipped(offsets)
2163
+ }
2164
+ };
2165
+ }
2166
+ case 'escaped':
2167
+ {
2168
+ const overflow = await detectOverflow(state, {
2169
+ ...detectOverflowOptions,
2170
+ altBoundary: true
2171
+ });
2172
+ const offsets = getSideOffsets(overflow, rects.floating);
2173
+ return {
2174
+ data: {
2175
+ escapedOffsets: offsets,
2176
+ escaped: isAnySideFullyClipped(offsets)
2177
+ }
2178
+ };
2179
+ }
2180
+ default:
2181
+ {
2182
+ return {};
2183
+ }
2184
+ }
2185
+ }
2186
+ };
2187
+ };
2188
+
2189
+ function getBoundingRect(rects) {
2190
+ const minX = min(...rects.map(rect => rect.left));
2191
+ const minY = min(...rects.map(rect => rect.top));
2192
+ const maxX = max(...rects.map(rect => rect.right));
2193
+ const maxY = max(...rects.map(rect => rect.bottom));
2194
+ return {
2195
+ x: minX,
2196
+ y: minY,
2197
+ width: maxX - minX,
2198
+ height: maxY - minY
2199
+ };
2200
+ }
2201
+ function getRectsByLine(rects) {
2202
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
2203
+ const groups = [];
2204
+ let prevRect = null;
2205
+ for (let i = 0; i < sortedRects.length; i++) {
2206
+ const rect = sortedRects[i];
2207
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
2208
+ groups.push([rect]);
2209
+ } else {
2210
+ groups[groups.length - 1].push(rect);
2211
+ }
2212
+ prevRect = rect;
2213
+ }
2214
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
2215
+ }
2216
+ /**
2217
+ * Provides improved positioning for inline reference elements that can span
2218
+ * over multiple lines, such as hyperlinks or range selections.
2219
+ * @see https://floating-ui.com/docs/inline
2220
+ */
2221
+ const inline$1 = function (options) {
2222
+ if (options === void 0) {
2223
+ options = {};
2224
+ }
2225
+ return {
2226
+ name: 'inline',
2227
+ options,
2228
+ async fn(state) {
2229
+ const {
2230
+ placement,
2231
+ elements,
2232
+ rects,
2233
+ platform,
2234
+ strategy
2235
+ } = state;
2236
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
2237
+ // ClientRect's bounds, despite the event listener being triggered. A
2238
+ // padding of 2 seems to handle this issue.
2239
+ const {
2240
+ padding = 2,
2241
+ x,
2242
+ y
2243
+ } = evaluate(options, state);
2244
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
2245
+ const clientRects = getRectsByLine(nativeClientRects);
2246
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
2247
+ const paddingObject = getPaddingObject(padding);
2248
+ function getBoundingClientRect() {
2249
+ // There are two rects and they are disjoined.
2250
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
2251
+ // Find the first rect in which the point is fully inside.
2252
+ 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;
2253
+ }
2254
+
2255
+ // There are 2 or more connected rects.
2256
+ if (clientRects.length >= 2) {
2257
+ if (getSideAxis(placement) === 'y') {
2258
+ const firstRect = clientRects[0];
2259
+ const lastRect = clientRects[clientRects.length - 1];
2260
+ const isTop = getSide(placement) === 'top';
2261
+ const top = firstRect.top;
2262
+ const bottom = lastRect.bottom;
2263
+ const left = isTop ? firstRect.left : lastRect.left;
2264
+ const right = isTop ? firstRect.right : lastRect.right;
2265
+ const width = right - left;
2266
+ const height = bottom - top;
2267
+ return {
2268
+ top,
2269
+ bottom,
2270
+ left,
2271
+ right,
2272
+ width,
2273
+ height,
2274
+ x: left,
2275
+ y: top
2276
+ };
2277
+ }
2278
+ const isLeftSide = getSide(placement) === 'left';
2279
+ const maxRight = max(...clientRects.map(rect => rect.right));
2280
+ const minLeft = min(...clientRects.map(rect => rect.left));
2281
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
2282
+ const top = measureRects[0].top;
2283
+ const bottom = measureRects[measureRects.length - 1].bottom;
2284
+ const left = minLeft;
2285
+ const right = maxRight;
2286
+ const width = right - left;
2287
+ const height = bottom - top;
2288
+ return {
2289
+ top,
2290
+ bottom,
2291
+ left,
2292
+ right,
2293
+ width,
2294
+ height,
2295
+ x: left,
2296
+ y: top
2297
+ };
2298
+ }
2299
+ return fallback;
2300
+ }
2301
+ const resetRects = await platform.getElementRects({
2302
+ reference: {
2303
+ getBoundingClientRect
2304
+ },
2305
+ floating: elements.floating,
2306
+ strategy
2307
+ });
2308
+ 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) {
2309
+ return {
2310
+ reset: {
2311
+ rects: resetRects
2312
+ }
2313
+ };
2314
+ }
2315
+ return {};
2316
+ }
2317
+ };
2318
+ };
2319
+
2320
+ // For type backwards-compatibility, the `OffsetOptions` type was also
2321
+ // Derivable.
2322
+
2323
+ async function convertValueToCoords(state, options) {
2324
+ const {
2325
+ placement,
2326
+ platform,
2327
+ elements
2328
+ } = state;
2329
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2330
+ const side = getSide(placement);
2331
+ const alignment = getAlignment(placement);
2332
+ const isVertical = getSideAxis(placement) === 'y';
2333
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
2334
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
2335
+ const rawValue = evaluate(options, state);
2336
+
2337
+ // eslint-disable-next-line prefer-const
2338
+ let {
2339
+ mainAxis,
2340
+ crossAxis,
2341
+ alignmentAxis
2342
+ } = typeof rawValue === 'number' ? {
2343
+ mainAxis: rawValue,
2344
+ crossAxis: 0,
2345
+ alignmentAxis: null
2346
+ } : {
2347
+ mainAxis: rawValue.mainAxis || 0,
2348
+ crossAxis: rawValue.crossAxis || 0,
2349
+ alignmentAxis: rawValue.alignmentAxis
2350
+ };
2351
+ if (alignment && typeof alignmentAxis === 'number') {
2352
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
2353
+ }
2354
+ return isVertical ? {
2355
+ x: crossAxis * crossAxisMulti,
2356
+ y: mainAxis * mainAxisMulti
2357
+ } : {
2358
+ x: mainAxis * mainAxisMulti,
2359
+ y: crossAxis * crossAxisMulti
2360
+ };
2361
+ }
2362
+
2363
+ /**
2364
+ * Modifies the placement by translating the floating element along the
2365
+ * specified axes.
2366
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2367
+ * object may be passed.
2368
+ * @see https://floating-ui.com/docs/offset
2369
+ */
2370
+ const offset$1 = function (options) {
2371
+ if (options === void 0) {
2372
+ options = 0;
2373
+ }
2374
+ return {
2375
+ name: 'offset',
2376
+ options,
2377
+ async fn(state) {
2378
+ var _middlewareData$offse, _middlewareData$arrow;
2379
+ const {
2380
+ x,
2381
+ y,
2382
+ placement,
2383
+ middlewareData
2384
+ } = state;
2385
+ const diffCoords = await convertValueToCoords(state, options);
2386
+
2387
+ // If the placement is the same and the arrow caused an alignment offset
2388
+ // then we don't need to change the positioning coordinates.
2389
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2390
+ return {};
2391
+ }
2392
+ return {
2393
+ x: x + diffCoords.x,
2394
+ y: y + diffCoords.y,
2395
+ data: {
2396
+ ...diffCoords,
2397
+ placement
2398
+ }
2399
+ };
2400
+ }
2401
+ };
2402
+ };
2403
+
2404
+ /**
2405
+ * Optimizes the visibility of the floating element by shifting it in order to
2406
+ * keep it in view when it will overflow the clipping boundary.
2407
+ * @see https://floating-ui.com/docs/shift
2408
+ */
2409
+ const shift$1 = function (options) {
2410
+ if (options === void 0) {
2411
+ options = {};
2412
+ }
2413
+ return {
2414
+ name: 'shift',
2415
+ options,
2416
+ async fn(state) {
2417
+ const {
2418
+ x,
2419
+ y,
2420
+ placement
2421
+ } = state;
2422
+ const {
2423
+ mainAxis: checkMainAxis = true,
2424
+ crossAxis: checkCrossAxis = false,
2425
+ limiter = {
2426
+ fn: _ref => {
2427
+ let {
2428
+ x,
2429
+ y
2430
+ } = _ref;
2431
+ return {
2432
+ x,
2433
+ y
2434
+ };
2435
+ }
2436
+ },
2437
+ ...detectOverflowOptions
2438
+ } = evaluate(options, state);
2439
+ const coords = {
2440
+ x,
2441
+ y
2442
+ };
2443
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2444
+ const crossAxis = getSideAxis(getSide(placement));
2445
+ const mainAxis = getOppositeAxis(crossAxis);
2446
+ let mainAxisCoord = coords[mainAxis];
2447
+ let crossAxisCoord = coords[crossAxis];
2448
+ if (checkMainAxis) {
2449
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
2450
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2451
+ const min = mainAxisCoord + overflow[minSide];
2452
+ const max = mainAxisCoord - overflow[maxSide];
2453
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
2454
+ }
2455
+ if (checkCrossAxis) {
2456
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
2457
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2458
+ const min = crossAxisCoord + overflow[minSide];
2459
+ const max = crossAxisCoord - overflow[maxSide];
2460
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
2461
+ }
2462
+ const limitedCoords = limiter.fn({
2463
+ ...state,
2464
+ [mainAxis]: mainAxisCoord,
2465
+ [crossAxis]: crossAxisCoord
2466
+ });
2467
+ return {
2468
+ ...limitedCoords,
2469
+ data: {
2470
+ x: limitedCoords.x - x,
2471
+ y: limitedCoords.y - y,
2472
+ enabled: {
2473
+ [mainAxis]: checkMainAxis,
2474
+ [crossAxis]: checkCrossAxis
2475
+ }
2476
+ }
2477
+ };
2478
+ }
2479
+ };
2480
+ };
2481
+ /**
2482
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2483
+ */
2484
+ const limitShift$1 = function (options) {
2485
+ if (options === void 0) {
2486
+ options = {};
2487
+ }
2488
+ return {
2489
+ options,
2490
+ fn(state) {
2491
+ const {
2492
+ x,
2493
+ y,
2494
+ placement,
2495
+ rects,
2496
+ middlewareData
2497
+ } = state;
2498
+ const {
2499
+ offset = 0,
2500
+ mainAxis: checkMainAxis = true,
2501
+ crossAxis: checkCrossAxis = true
2502
+ } = evaluate(options, state);
2503
+ const coords = {
2504
+ x,
2505
+ y
2506
+ };
2507
+ const crossAxis = getSideAxis(placement);
2508
+ const mainAxis = getOppositeAxis(crossAxis);
2509
+ let mainAxisCoord = coords[mainAxis];
2510
+ let crossAxisCoord = coords[crossAxis];
2511
+ const rawOffset = evaluate(offset, state);
2512
+ const computedOffset = typeof rawOffset === 'number' ? {
2513
+ mainAxis: rawOffset,
2514
+ crossAxis: 0
2515
+ } : {
2516
+ mainAxis: 0,
2517
+ crossAxis: 0,
2518
+ ...rawOffset
2519
+ };
2520
+ if (checkMainAxis) {
2521
+ const len = mainAxis === 'y' ? 'height' : 'width';
2522
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2523
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2524
+ if (mainAxisCoord < limitMin) {
2525
+ mainAxisCoord = limitMin;
2526
+ } else if (mainAxisCoord > limitMax) {
2527
+ mainAxisCoord = limitMax;
2528
+ }
2529
+ }
2530
+ if (checkCrossAxis) {
2531
+ var _middlewareData$offse, _middlewareData$offse2;
2532
+ const len = mainAxis === 'y' ? 'width' : 'height';
2533
+ const isOriginSide = ['top', 'left'].includes(getSide(placement));
2534
+ 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);
2535
+ 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);
2536
+ if (crossAxisCoord < limitMin) {
2537
+ crossAxisCoord = limitMin;
2538
+ } else if (crossAxisCoord > limitMax) {
2539
+ crossAxisCoord = limitMax;
2540
+ }
2541
+ }
2542
+ return {
2543
+ [mainAxis]: mainAxisCoord,
2544
+ [crossAxis]: crossAxisCoord
2545
+ };
2546
+ }
2547
+ };
2548
+ };
2549
+
2550
+ /**
2551
+ * Provides data that allows you to change the size of the floating element —
2552
+ * for instance, prevent it from overflowing the clipping boundary or match the
2553
+ * width of the reference element.
2554
+ * @see https://floating-ui.com/docs/size
2555
+ */
2556
+ const size$1 = function (options) {
2557
+ if (options === void 0) {
2558
+ options = {};
2559
+ }
2560
+ return {
2561
+ name: 'size',
2562
+ options,
2563
+ async fn(state) {
2564
+ var _state$middlewareData, _state$middlewareData2;
2565
+ const {
2566
+ placement,
2567
+ rects,
2568
+ platform,
2569
+ elements
2570
+ } = state;
2571
+ const {
2572
+ apply = () => {},
2573
+ ...detectOverflowOptions
2574
+ } = evaluate(options, state);
2575
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2576
+ const side = getSide(placement);
2577
+ const alignment = getAlignment(placement);
2578
+ const isYAxis = getSideAxis(placement) === 'y';
2579
+ const {
2580
+ width,
2581
+ height
2582
+ } = rects.floating;
2583
+ let heightSide;
2584
+ let widthSide;
2585
+ if (side === 'top' || side === 'bottom') {
2586
+ heightSide = side;
2587
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
2588
+ } else {
2589
+ widthSide = side;
2590
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
2591
+ }
2592
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
2593
+ const maximumClippingWidth = width - overflow.left - overflow.right;
2594
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
2595
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
2596
+ const noShift = !state.middlewareData.shift;
2597
+ let availableHeight = overflowAvailableHeight;
2598
+ let availableWidth = overflowAvailableWidth;
2599
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
2600
+ availableWidth = maximumClippingWidth;
2601
+ }
2602
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
2603
+ availableHeight = maximumClippingHeight;
2604
+ }
2605
+ if (noShift && !alignment) {
2606
+ const xMin = max(overflow.left, 0);
2607
+ const xMax = max(overflow.right, 0);
2608
+ const yMin = max(overflow.top, 0);
2609
+ const yMax = max(overflow.bottom, 0);
2610
+ if (isYAxis) {
2611
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
2612
+ } else {
2613
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
2614
+ }
2615
+ }
2616
+ await apply({
2617
+ ...state,
2618
+ availableWidth,
2619
+ availableHeight
2620
+ });
2621
+ const nextDimensions = await platform.getDimensions(elements.floating);
2622
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
2623
+ return {
2624
+ reset: {
2625
+ rects: true
2626
+ }
2627
+ };
2628
+ }
2629
+ return {};
2630
+ }
2631
+ };
2632
+ };
2633
+
2634
+ function hasWindow() {
2635
+ return typeof window !== 'undefined';
2636
+ }
2637
+ function getNodeName(node) {
2638
+ if (isNode(node)) {
2639
+ return (node.nodeName || '').toLowerCase();
2640
+ }
2641
+ // Mocked nodes in testing environments may not be instances of Node. By
2642
+ // returning `#document` an infinite loop won't occur.
2643
+ // https://github.com/floating-ui/floating-ui/issues/2317
2644
+ return '#document';
2645
+ }
2646
+ function getWindow(node) {
2647
+ var _node$ownerDocument;
2648
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2649
+ }
2650
+ function getDocumentElement(node) {
2651
+ var _ref;
2652
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2653
+ }
2654
+ function isNode(value) {
2655
+ if (!hasWindow()) {
2656
+ return false;
2657
+ }
2658
+ return value instanceof Node || value instanceof getWindow(value).Node;
2659
+ }
2660
+ function isElement(value) {
2661
+ if (!hasWindow()) {
2662
+ return false;
2663
+ }
2664
+ return value instanceof Element || value instanceof getWindow(value).Element;
2665
+ }
2666
+ function isHTMLElement(value) {
2667
+ if (!hasWindow()) {
2668
+ return false;
2669
+ }
2670
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2671
+ }
2672
+ function isShadowRoot(value) {
2673
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
2674
+ return false;
2675
+ }
2676
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2677
+ }
2678
+ function isOverflowElement(element) {
2679
+ const {
2680
+ overflow,
2681
+ overflowX,
2682
+ overflowY,
2683
+ display
2684
+ } = getComputedStyle$1(element);
2685
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
2686
+ }
2687
+ function isTableElement(element) {
2688
+ return ['table', 'td', 'th'].includes(getNodeName(element));
2689
+ }
2690
+ function isTopLayer(element) {
2691
+ return [':popover-open', ':modal'].some(selector => {
2692
+ try {
2693
+ return element.matches(selector);
2694
+ } catch (e) {
2695
+ return false;
2696
+ }
2697
+ });
2698
+ }
2699
+ function isContainingBlock(elementOrCss) {
2700
+ const webkit = isWebKit();
2701
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2702
+
2703
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2704
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
2705
+ return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
2706
+ }
2707
+ function getContainingBlock(element) {
2708
+ let currentNode = getParentNode(element);
2709
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2710
+ if (isContainingBlock(currentNode)) {
2711
+ return currentNode;
2712
+ } else if (isTopLayer(currentNode)) {
2713
+ return null;
2714
+ }
2715
+ currentNode = getParentNode(currentNode);
2716
+ }
2717
+ return null;
2718
+ }
2719
+ function isWebKit() {
2720
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
2721
+ return CSS.supports('-webkit-backdrop-filter', 'none');
2722
+ }
2723
+ function isLastTraversableNode(node) {
2724
+ return ['html', 'body', '#document'].includes(getNodeName(node));
2725
+ }
2726
+ function getComputedStyle$1(element) {
2727
+ return getWindow(element).getComputedStyle(element);
2728
+ }
2729
+ function getNodeScroll(element) {
2730
+ if (isElement(element)) {
2731
+ return {
2732
+ scrollLeft: element.scrollLeft,
2733
+ scrollTop: element.scrollTop
2734
+ };
2735
+ }
2736
+ return {
2737
+ scrollLeft: element.scrollX,
2738
+ scrollTop: element.scrollY
2739
+ };
2740
+ }
2741
+ function getParentNode(node) {
2742
+ if (getNodeName(node) === 'html') {
2743
+ return node;
2744
+ }
2745
+ const result =
2746
+ // Step into the shadow DOM of the parent of a slotted node.
2747
+ node.assignedSlot ||
2748
+ // DOM Element detected.
2749
+ node.parentNode ||
2750
+ // ShadowRoot detected.
2751
+ isShadowRoot(node) && node.host ||
2752
+ // Fallback.
2753
+ getDocumentElement(node);
2754
+ return isShadowRoot(result) ? result.host : result;
2755
+ }
2756
+ function getNearestOverflowAncestor(node) {
2757
+ const parentNode = getParentNode(node);
2758
+ if (isLastTraversableNode(parentNode)) {
2759
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
2760
+ }
2761
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2762
+ return parentNode;
2763
+ }
2764
+ return getNearestOverflowAncestor(parentNode);
2765
+ }
2766
+ function getOverflowAncestors(node, list, traverseIframes) {
2767
+ var _node$ownerDocument2;
2768
+ if (list === void 0) {
2769
+ list = [];
2770
+ }
2771
+ if (traverseIframes === void 0) {
2772
+ traverseIframes = true;
2773
+ }
2774
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2775
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2776
+ const win = getWindow(scrollableAncestor);
2777
+ if (isBody) {
2778
+ const frameElement = getFrameElement(win);
2779
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2780
+ }
2781
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2782
+ }
2783
+ function getFrameElement(win) {
2784
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2785
+ }
2786
+
2787
+ function getCssDimensions(element) {
2788
+ const css = getComputedStyle$1(element);
2789
+ // In testing environments, the `width` and `height` properties are empty
2790
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2791
+ let width = parseFloat(css.width) || 0;
2792
+ let height = parseFloat(css.height) || 0;
2793
+ const hasOffset = isHTMLElement(element);
2794
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2795
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2796
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2797
+ if (shouldFallback) {
2798
+ width = offsetWidth;
2799
+ height = offsetHeight;
2800
+ }
2801
+ return {
2802
+ width,
2803
+ height,
2804
+ $: shouldFallback
2805
+ };
2806
+ }
2807
+
2808
+ function unwrapElement(element) {
2809
+ return !isElement(element) ? element.contextElement : element;
2810
+ }
2811
+
2812
+ function getScale(element) {
2813
+ const domElement = unwrapElement(element);
2814
+ if (!isHTMLElement(domElement)) {
2815
+ return createCoords(1);
2816
+ }
2817
+ const rect = domElement.getBoundingClientRect();
2818
+ const {
2819
+ width,
2820
+ height,
2821
+ $
2822
+ } = getCssDimensions(domElement);
2823
+ let x = ($ ? round(rect.width) : rect.width) / width;
2824
+ let y = ($ ? round(rect.height) : rect.height) / height;
2825
+
2826
+ // 0, NaN, or Infinity should always fallback to 1.
2827
+
2828
+ if (!x || !Number.isFinite(x)) {
2829
+ x = 1;
2830
+ }
2831
+ if (!y || !Number.isFinite(y)) {
2832
+ y = 1;
2833
+ }
2834
+ return {
2835
+ x,
2836
+ y
2837
+ };
2838
+ }
2839
+
2840
+ const noOffsets = /*#__PURE__*/createCoords(0);
2841
+ function getVisualOffsets(element) {
2842
+ const win = getWindow(element);
2843
+ if (!isWebKit() || !win.visualViewport) {
2844
+ return noOffsets;
2845
+ }
2846
+ return {
2847
+ x: win.visualViewport.offsetLeft,
2848
+ y: win.visualViewport.offsetTop
2849
+ };
2850
+ }
2851
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2852
+ if (isFixed === void 0) {
2853
+ isFixed = false;
2854
+ }
2855
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2856
+ return false;
2857
+ }
2858
+ return isFixed;
2859
+ }
2860
+
2861
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2862
+ if (includeScale === void 0) {
2863
+ includeScale = false;
2864
+ }
2865
+ if (isFixedStrategy === void 0) {
2866
+ isFixedStrategy = false;
2867
+ }
2868
+ const clientRect = element.getBoundingClientRect();
2869
+ const domElement = unwrapElement(element);
2870
+ let scale = createCoords(1);
2871
+ if (includeScale) {
2872
+ if (offsetParent) {
2873
+ if (isElement(offsetParent)) {
2874
+ scale = getScale(offsetParent);
2875
+ }
2876
+ } else {
2877
+ scale = getScale(element);
2878
+ }
2879
+ }
2880
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2881
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
2882
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
2883
+ let width = clientRect.width / scale.x;
2884
+ let height = clientRect.height / scale.y;
2885
+ if (domElement) {
2886
+ const win = getWindow(domElement);
2887
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2888
+ let currentWin = win;
2889
+ let currentIFrame = getFrameElement(currentWin);
2890
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2891
+ const iframeScale = getScale(currentIFrame);
2892
+ const iframeRect = currentIFrame.getBoundingClientRect();
2893
+ const css = getComputedStyle$1(currentIFrame);
2894
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2895
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2896
+ x *= iframeScale.x;
2897
+ y *= iframeScale.y;
2898
+ width *= iframeScale.x;
2899
+ height *= iframeScale.y;
2900
+ x += left;
2901
+ y += top;
2902
+ currentWin = getWindow(currentIFrame);
2903
+ currentIFrame = getFrameElement(currentWin);
2904
+ }
2905
+ }
2906
+ return rectToClientRect({
2907
+ width,
2908
+ height,
2909
+ x,
2910
+ y
2911
+ });
2912
+ }
2913
+
2914
+ // If <html> has a CSS width greater than the viewport, then this will be
2915
+ // incorrect for RTL.
2916
+ function getWindowScrollBarX(element, rect) {
2917
+ const leftScroll = getNodeScroll(element).scrollLeft;
2918
+ if (!rect) {
2919
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2920
+ }
2921
+ return rect.left + leftScroll;
2922
+ }
2923
+
2924
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
2925
+ if (ignoreScrollbarX === void 0) {
2926
+ ignoreScrollbarX = false;
2927
+ }
2928
+ const htmlRect = documentElement.getBoundingClientRect();
2929
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
2930
+ // RTL <body> scrollbar.
2931
+ getWindowScrollBarX(documentElement, htmlRect));
2932
+ const y = htmlRect.top + scroll.scrollTop;
2933
+ return {
2934
+ x,
2935
+ y
2936
+ };
2937
+ }
2938
+
2939
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2940
+ let {
2941
+ elements,
2942
+ rect,
2943
+ offsetParent,
2944
+ strategy
2945
+ } = _ref;
2946
+ const isFixed = strategy === 'fixed';
2947
+ const documentElement = getDocumentElement(offsetParent);
2948
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2949
+ if (offsetParent === documentElement || topLayer && isFixed) {
2950
+ return rect;
2951
+ }
2952
+ let scroll = {
2953
+ scrollLeft: 0,
2954
+ scrollTop: 0
2955
+ };
2956
+ let scale = createCoords(1);
2957
+ const offsets = createCoords(0);
2958
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2959
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2960
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2961
+ scroll = getNodeScroll(offsetParent);
2962
+ }
2963
+ if (isHTMLElement(offsetParent)) {
2964
+ const offsetRect = getBoundingClientRect(offsetParent);
2965
+ scale = getScale(offsetParent);
2966
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2967
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2968
+ }
2969
+ }
2970
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
2971
+ return {
2972
+ width: rect.width * scale.x,
2973
+ height: rect.height * scale.y,
2974
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
2975
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
2976
+ };
2977
+ }
2978
+
2979
+ function getClientRects(element) {
2980
+ return Array.from(element.getClientRects());
2981
+ }
2982
+
2983
+ // Gets the entire size of the scrollable document area, even extending outside
2984
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2985
+ function getDocumentRect(element) {
2986
+ const html = getDocumentElement(element);
2987
+ const scroll = getNodeScroll(element);
2988
+ const body = element.ownerDocument.body;
2989
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2990
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2991
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2992
+ const y = -scroll.scrollTop;
2993
+ if (getComputedStyle$1(body).direction === 'rtl') {
2994
+ x += max(html.clientWidth, body.clientWidth) - width;
2995
+ }
2996
+ return {
2997
+ width,
2998
+ height,
2999
+ x,
3000
+ y
3001
+ };
3002
+ }
3003
+
3004
+ function getViewportRect(element, strategy) {
3005
+ const win = getWindow(element);
3006
+ const html = getDocumentElement(element);
3007
+ const visualViewport = win.visualViewport;
3008
+ let width = html.clientWidth;
3009
+ let height = html.clientHeight;
3010
+ let x = 0;
3011
+ let y = 0;
3012
+ if (visualViewport) {
3013
+ width = visualViewport.width;
3014
+ height = visualViewport.height;
3015
+ const visualViewportBased = isWebKit();
3016
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
3017
+ x = visualViewport.offsetLeft;
3018
+ y = visualViewport.offsetTop;
3019
+ }
3020
+ }
3021
+ return {
3022
+ width,
3023
+ height,
3024
+ x,
3025
+ y
3026
+ };
3027
+ }
3028
+
3029
+ // Returns the inner client rect, subtracting scrollbars if present.
3030
+ function getInnerBoundingClientRect(element, strategy) {
3031
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
3032
+ const top = clientRect.top + element.clientTop;
3033
+ const left = clientRect.left + element.clientLeft;
3034
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
3035
+ const width = element.clientWidth * scale.x;
3036
+ const height = element.clientHeight * scale.y;
3037
+ const x = left * scale.x;
3038
+ const y = top * scale.y;
3039
+ return {
3040
+ width,
3041
+ height,
3042
+ x,
3043
+ y
3044
+ };
3045
+ }
3046
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
3047
+ let rect;
3048
+ if (clippingAncestor === 'viewport') {
3049
+ rect = getViewportRect(element, strategy);
3050
+ } else if (clippingAncestor === 'document') {
3051
+ rect = getDocumentRect(getDocumentElement(element));
3052
+ } else if (isElement(clippingAncestor)) {
3053
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
3054
+ } else {
3055
+ const visualOffsets = getVisualOffsets(element);
3056
+ rect = {
3057
+ x: clippingAncestor.x - visualOffsets.x,
3058
+ y: clippingAncestor.y - visualOffsets.y,
3059
+ width: clippingAncestor.width,
3060
+ height: clippingAncestor.height
3061
+ };
3062
+ }
3063
+ return rectToClientRect(rect);
3064
+ }
3065
+ function hasFixedPositionAncestor(element, stopNode) {
3066
+ const parentNode = getParentNode(element);
3067
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
3068
+ return false;
3069
+ }
3070
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
3071
+ }
3072
+
3073
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
3074
+ // clipping (or hiding) child elements. This returns all clipping ancestors
3075
+ // of the given element up the tree.
3076
+ function getClippingElementAncestors(element, cache) {
3077
+ const cachedResult = cache.get(element);
3078
+ if (cachedResult) {
3079
+ return cachedResult;
3080
+ }
3081
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
3082
+ let currentContainingBlockComputedStyle = null;
3083
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
3084
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
3085
+
3086
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
3087
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
3088
+ const computedStyle = getComputedStyle$1(currentNode);
3089
+ const currentNodeIsContaining = isContainingBlock(currentNode);
3090
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
3091
+ currentContainingBlockComputedStyle = null;
3092
+ }
3093
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
3094
+ if (shouldDropCurrentNode) {
3095
+ // Drop non-containing blocks.
3096
+ result = result.filter(ancestor => ancestor !== currentNode);
3097
+ } else {
3098
+ // Record last containing block for next iteration.
3099
+ currentContainingBlockComputedStyle = computedStyle;
3100
+ }
3101
+ currentNode = getParentNode(currentNode);
3102
+ }
3103
+ cache.set(element, result);
3104
+ return result;
3105
+ }
3106
+
3107
+ // Gets the maximum area that the element is visible in due to any number of
3108
+ // clipping ancestors.
3109
+ function getClippingRect(_ref) {
3110
+ let {
3111
+ element,
3112
+ boundary,
3113
+ rootBoundary,
3114
+ strategy
3115
+ } = _ref;
3116
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
3117
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
3118
+ const firstClippingAncestor = clippingAncestors[0];
3119
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
3120
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
3121
+ accRect.top = max(rect.top, accRect.top);
3122
+ accRect.right = min(rect.right, accRect.right);
3123
+ accRect.bottom = min(rect.bottom, accRect.bottom);
3124
+ accRect.left = max(rect.left, accRect.left);
3125
+ return accRect;
3126
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
3127
+ return {
3128
+ width: clippingRect.right - clippingRect.left,
3129
+ height: clippingRect.bottom - clippingRect.top,
3130
+ x: clippingRect.left,
3131
+ y: clippingRect.top
3132
+ };
3133
+ }
3134
+
3135
+ function getDimensions(element) {
3136
+ const {
3137
+ width,
3138
+ height
3139
+ } = getCssDimensions(element);
3140
+ return {
3141
+ width,
3142
+ height
3143
+ };
3144
+ }
3145
+
3146
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
3147
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
3148
+ const documentElement = getDocumentElement(offsetParent);
3149
+ const isFixed = strategy === 'fixed';
3150
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
3151
+ let scroll = {
3152
+ scrollLeft: 0,
3153
+ scrollTop: 0
3154
+ };
3155
+ const offsets = createCoords(0);
3156
+
3157
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
3158
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
3159
+ function setLeftRTLScrollbarOffset() {
3160
+ offsets.x = getWindowScrollBarX(documentElement);
3161
+ }
3162
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3163
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
3164
+ scroll = getNodeScroll(offsetParent);
3165
+ }
3166
+ if (isOffsetParentAnElement) {
3167
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
3168
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
3169
+ offsets.y = offsetRect.y + offsetParent.clientTop;
3170
+ } else if (documentElement) {
3171
+ setLeftRTLScrollbarOffset();
3172
+ }
3173
+ }
3174
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
3175
+ setLeftRTLScrollbarOffset();
3176
+ }
3177
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
3178
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
3179
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
3180
+ return {
3181
+ x,
3182
+ y,
3183
+ width: rect.width,
3184
+ height: rect.height
3185
+ };
3186
+ }
3187
+
3188
+ function isStaticPositioned(element) {
3189
+ return getComputedStyle$1(element).position === 'static';
3190
+ }
3191
+
3192
+ function getTrueOffsetParent(element, polyfill) {
3193
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
3194
+ return null;
3195
+ }
3196
+ if (polyfill) {
3197
+ return polyfill(element);
3198
+ }
3199
+ let rawOffsetParent = element.offsetParent;
3200
+
3201
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
3202
+ // while Chrome and Safari return the <body> element. The <body> element must
3203
+ // be used to perform the correct calculations even if the <html> element is
3204
+ // non-static.
3205
+ if (getDocumentElement(element) === rawOffsetParent) {
3206
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
3207
+ }
3208
+ return rawOffsetParent;
3209
+ }
3210
+
3211
+ // Gets the closest ancestor positioned element. Handles some edge cases,
3212
+ // such as table ancestors and cross browser bugs.
3213
+ function getOffsetParent(element, polyfill) {
3214
+ const win = getWindow(element);
3215
+ if (isTopLayer(element)) {
3216
+ return win;
3217
+ }
3218
+ if (!isHTMLElement(element)) {
3219
+ let svgOffsetParent = getParentNode(element);
3220
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
3221
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
3222
+ return svgOffsetParent;
3223
+ }
3224
+ svgOffsetParent = getParentNode(svgOffsetParent);
3225
+ }
3226
+ return win;
3227
+ }
3228
+ let offsetParent = getTrueOffsetParent(element, polyfill);
3229
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
3230
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
3231
+ }
3232
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
3233
+ return win;
3234
+ }
3235
+ return offsetParent || getContainingBlock(element) || win;
3236
+ }
3237
+
3238
+ const getElementRects = async function (data) {
3239
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
3240
+ const getDimensionsFn = this.getDimensions;
3241
+ const floatingDimensions = await getDimensionsFn(data.floating);
3242
+ return {
3243
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
3244
+ floating: {
3245
+ x: 0,
3246
+ y: 0,
3247
+ width: floatingDimensions.width,
3248
+ height: floatingDimensions.height
3249
+ }
3250
+ };
3251
+ };
3252
+
3253
+ function isRTL(element) {
3254
+ return getComputedStyle$1(element).direction === 'rtl';
3255
+ }
3256
+
3257
+ const platform = {
3258
+ convertOffsetParentRelativeRectToViewportRelativeRect,
3259
+ getDocumentElement,
3260
+ getClippingRect,
3261
+ getOffsetParent,
3262
+ getElementRects,
3263
+ getClientRects,
3264
+ getDimensions,
3265
+ getScale,
3266
+ isElement,
3267
+ isRTL
3268
+ };
3269
+
3270
+ function rectsAreEqual(a, b) {
3271
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
3272
+ }
3273
+
3274
+ // https://samthor.au/2021/observing-dom/
3275
+ function observeMove(element, onMove) {
3276
+ let io = null;
3277
+ let timeoutId;
3278
+ const root = getDocumentElement(element);
3279
+ function cleanup() {
3280
+ var _io;
3281
+ clearTimeout(timeoutId);
3282
+ (_io = io) == null || _io.disconnect();
3283
+ io = null;
3284
+ }
3285
+ function refresh(skip, threshold) {
3286
+ if (skip === void 0) {
3287
+ skip = false;
3288
+ }
3289
+ if (threshold === void 0) {
3290
+ threshold = 1;
3291
+ }
3292
+ cleanup();
3293
+ const elementRectForRootMargin = element.getBoundingClientRect();
3294
+ const {
3295
+ left,
3296
+ top,
3297
+ width,
3298
+ height
3299
+ } = elementRectForRootMargin;
3300
+ if (!skip) {
3301
+ onMove();
3302
+ }
3303
+ if (!width || !height) {
3304
+ return;
3305
+ }
3306
+ const insetTop = floor(top);
3307
+ const insetRight = floor(root.clientWidth - (left + width));
3308
+ const insetBottom = floor(root.clientHeight - (top + height));
3309
+ const insetLeft = floor(left);
3310
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
3311
+ const options = {
3312
+ rootMargin,
3313
+ threshold: max(0, min(1, threshold)) || 1
3314
+ };
3315
+ let isFirstUpdate = true;
3316
+ function handleObserve(entries) {
3317
+ const ratio = entries[0].intersectionRatio;
3318
+ if (ratio !== threshold) {
3319
+ if (!isFirstUpdate) {
3320
+ return refresh();
3321
+ }
3322
+ if (!ratio) {
3323
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
3324
+ // to prevent an infinite loop of updates.
3325
+ timeoutId = setTimeout(() => {
3326
+ refresh(false, 1e-7);
3327
+ }, 1000);
3328
+ } else {
3329
+ refresh(false, ratio);
3330
+ }
3331
+ }
3332
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
3333
+ // It's possible that even though the ratio is reported as 1, the
3334
+ // element is not actually fully within the IntersectionObserver's root
3335
+ // area anymore. This can happen under performance constraints. This may
3336
+ // be a bug in the browser's IntersectionObserver implementation. To
3337
+ // work around this, we compare the element's bounding rect now with
3338
+ // what it was at the time we created the IntersectionObserver. If they
3339
+ // are not equal then the element moved, so we refresh.
3340
+ refresh();
3341
+ }
3342
+ isFirstUpdate = false;
3343
+ }
3344
+
3345
+ // Older browsers don't support a `document` as the root and will throw an
3346
+ // error.
3347
+ try {
3348
+ io = new IntersectionObserver(handleObserve, {
3349
+ ...options,
3350
+ // Handle <iframe>s
3351
+ root: root.ownerDocument
3352
+ });
3353
+ } catch (_e) {
3354
+ io = new IntersectionObserver(handleObserve, options);
3355
+ }
3356
+ io.observe(element);
3357
+ }
3358
+ refresh(true);
3359
+ return cleanup;
3360
+ }
3361
+
3362
+ /**
3363
+ * Automatically updates the position of the floating element when necessary.
3364
+ * Should only be called when the floating element is mounted on the DOM or
3365
+ * visible on the screen.
3366
+ * @returns cleanup function that should be invoked when the floating element is
3367
+ * removed from the DOM or hidden from the screen.
3368
+ * @see https://floating-ui.com/docs/autoUpdate
3369
+ */
3370
+ function autoUpdate(reference, floating, update, options) {
3371
+ if (options === void 0) {
3372
+ options = {};
3373
+ }
3374
+ const {
3375
+ ancestorScroll = true,
3376
+ ancestorResize = true,
3377
+ elementResize = typeof ResizeObserver === 'function',
3378
+ layoutShift = typeof IntersectionObserver === 'function',
3379
+ animationFrame = false
3380
+ } = options;
3381
+ const referenceEl = unwrapElement(reference);
3382
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
3383
+ ancestors.forEach(ancestor => {
3384
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
3385
+ passive: true
3386
+ });
3387
+ ancestorResize && ancestor.addEventListener('resize', update);
3388
+ });
3389
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
3390
+ let reobserveFrame = -1;
3391
+ let resizeObserver = null;
3392
+ if (elementResize) {
3393
+ resizeObserver = new ResizeObserver(_ref => {
3394
+ let [firstEntry] = _ref;
3395
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
3396
+ // Prevent update loops when using the `size` middleware.
3397
+ // https://github.com/floating-ui/floating-ui/issues/1740
3398
+ resizeObserver.unobserve(floating);
3399
+ cancelAnimationFrame(reobserveFrame);
3400
+ reobserveFrame = requestAnimationFrame(() => {
3401
+ var _resizeObserver;
3402
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
3403
+ });
3404
+ }
3405
+ update();
3406
+ });
3407
+ if (referenceEl && !animationFrame) {
3408
+ resizeObserver.observe(referenceEl);
3409
+ }
3410
+ resizeObserver.observe(floating);
3411
+ }
3412
+ let frameId;
3413
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
3414
+ if (animationFrame) {
3415
+ frameLoop();
3416
+ }
3417
+ function frameLoop() {
3418
+ const nextRefRect = getBoundingClientRect(reference);
3419
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
3420
+ update();
3421
+ }
3422
+ prevRefRect = nextRefRect;
3423
+ frameId = requestAnimationFrame(frameLoop);
3424
+ }
3425
+ update();
3426
+ return () => {
3427
+ var _resizeObserver2;
3428
+ ancestors.forEach(ancestor => {
3429
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
3430
+ ancestorResize && ancestor.removeEventListener('resize', update);
3431
+ });
3432
+ cleanupIo == null || cleanupIo();
3433
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
3434
+ resizeObserver = null;
3435
+ if (animationFrame) {
3436
+ cancelAnimationFrame(frameId);
3437
+ }
3438
+ };
3439
+ }
3440
+
3441
+ /**
3442
+ * Modifies the placement by translating the floating element along the
3443
+ * specified axes.
3444
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
3445
+ * object may be passed.
3446
+ * @see https://floating-ui.com/docs/offset
3447
+ */
3448
+ const offset = offset$1;
3449
+
3450
+ /**
3451
+ * Optimizes the visibility of the floating element by choosing the placement
3452
+ * that has the most space available automatically, without needing to specify a
3453
+ * preferred placement. Alternative to `flip`.
3454
+ * @see https://floating-ui.com/docs/autoPlacement
3455
+ */
3456
+ autoPlacement;
3457
+
3458
+ /**
3459
+ * Optimizes the visibility of the floating element by shifting it in order to
3460
+ * keep it in view when it will overflow the clipping boundary.
3461
+ * @see https://floating-ui.com/docs/shift
3462
+ */
3463
+ const shift = shift$1;
3464
+
3465
+ /**
3466
+ * Optimizes the visibility of the floating element by flipping the `placement`
3467
+ * in order to keep it in view when the preferred placement(s) will overflow the
3468
+ * clipping boundary. Alternative to `autoPlacement`.
3469
+ * @see https://floating-ui.com/docs/flip
3470
+ */
3471
+ const flip = flip$1;
3472
+
3473
+ /**
3474
+ * Provides data that allows you to change the size of the floating element —
3475
+ * for instance, prevent it from overflowing the clipping boundary or match the
3476
+ * width of the reference element.
3477
+ * @see https://floating-ui.com/docs/size
3478
+ */
3479
+ const size = size$1;
3480
+
3481
+ /**
3482
+ * Provides data to hide the floating element in applicable situations, such as
3483
+ * when it is not in the same clipping context as the reference element.
3484
+ * @see https://floating-ui.com/docs/hide
3485
+ */
3486
+ hide;
3487
+
3488
+ /**
3489
+ * Provides data to position an inner element of the floating element so that it
3490
+ * appears centered to the reference element.
3491
+ * @see https://floating-ui.com/docs/arrow
3492
+ */
3493
+ const arrow = arrow$1;
3494
+
3495
+ /**
3496
+ * Provides improved positioning for inline reference elements that can span
3497
+ * over multiple lines, such as hyperlinks or range selections.
3498
+ * @see https://floating-ui.com/docs/inline
3499
+ */
3500
+ const inline = inline$1;
3501
+
3502
+ /**
3503
+ * Built-in `limiter` that will stop `shift()` at a certain point.
3504
+ */
3505
+ const limitShift = limitShift$1;
3506
+
3507
+ /**
3508
+ * Computes the `x` and `y` coordinates that will place the floating element
3509
+ * next to a given reference element.
3510
+ */
3511
+ const computePosition = (reference, floating, options) => {
3512
+ // This caches the expensive `getClippingElementAncestors` function so that
3513
+ // multiple lifecycle resets re-use the same result. It only lives for a
3514
+ // single call. If other functions become expensive, we can add them as well.
3515
+ const cache = new Map();
3516
+ const mergedOptions = {
3517
+ platform,
3518
+ ...options
3519
+ };
3520
+ const platformWithCache = {
3521
+ ...mergedOptions.platform,
3522
+ _c: cache
3523
+ };
3524
+ return computePosition$1(reference, floating, {
3525
+ ...mergedOptions,
3526
+ platform: platformWithCache
3527
+ });
3528
+ };
3529
+
3530
+ // src/events.ts
3531
+ var ToggleEvent = class extends Event {
3532
+ oldState;
3533
+ newState;
3534
+ constructor(type, { oldState = "", newState = "", ...init } = {}) {
3535
+ super(type, init);
3536
+ this.oldState = String(oldState || "");
3537
+ this.newState = String(newState || "");
3538
+ }
3539
+ };
3540
+ var popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();
3541
+ function queuePopoverToggleEventTask(element, oldState, newState) {
3542
+ popoverToggleTaskQueue.set(
3543
+ element,
3544
+ setTimeout(() => {
3545
+ if (!popoverToggleTaskQueue.has(element)) return;
3546
+ element.dispatchEvent(
3547
+ new ToggleEvent("toggle", {
3548
+ cancelable: false,
3549
+ oldState,
3550
+ newState
3551
+ })
3552
+ );
3553
+ }, 0)
3554
+ );
3555
+ }
3556
+
3557
+ // src/popover-helpers.ts
3558
+ var ShadowRoot$1 = globalThis.ShadowRoot || function() {
3559
+ };
3560
+ var HTMLDialogElement = globalThis.HTMLDialogElement || function() {
3561
+ };
3562
+ var topLayerElements = /* @__PURE__ */ new WeakMap();
3563
+ var autoPopoverList = /* @__PURE__ */ new WeakMap();
3564
+ var visibilityState = /* @__PURE__ */ new WeakMap();
3565
+ function getPopoverVisibilityState(popover) {
3566
+ return visibilityState.get(popover) || "hidden";
3567
+ }
3568
+ var popoverInvoker = /* @__PURE__ */ new WeakMap();
3569
+ function popoverTargetAttributeActivationBehavior(element) {
3570
+ const popover = element.popoverTargetElement;
3571
+ if (!(popover instanceof HTMLElement)) {
3572
+ return;
3573
+ }
3574
+ const visibility = getPopoverVisibilityState(popover);
3575
+ if (element.popoverTargetAction === "show" && visibility === "showing") {
3576
+ return;
3577
+ }
3578
+ if (element.popoverTargetAction === "hide" && visibility === "hidden") return;
3579
+ if (visibility === "showing") {
3580
+ hidePopover(popover, true, true);
3581
+ } else if (checkPopoverValidity(popover, false)) {
3582
+ popoverInvoker.set(popover, element);
3583
+ showPopover(popover);
3584
+ }
3585
+ }
3586
+ function checkPopoverValidity(element, expectedToBeShowing) {
3587
+ if (element.popover !== "auto" && element.popover !== "manual") {
3588
+ return false;
3589
+ }
3590
+ if (!element.isConnected) return false;
3591
+ if (expectedToBeShowing && getPopoverVisibilityState(element) !== "showing") {
3592
+ return false;
3593
+ }
3594
+ if (!expectedToBeShowing && getPopoverVisibilityState(element) !== "hidden") {
3595
+ return false;
3596
+ }
3597
+ if (element instanceof HTMLDialogElement && element.hasAttribute("open")) {
3598
+ return false;
3599
+ }
3600
+ if (document.fullscreenElement === element) return false;
3601
+ return true;
3602
+ }
3603
+ function getStackPosition(popover) {
3604
+ if (!popover) return 0;
3605
+ return Array.from(autoPopoverList.get(popover.ownerDocument) || []).indexOf(
3606
+ popover
3607
+ ) + 1;
3608
+ }
3609
+ function topMostClickedPopover(target) {
3610
+ const clickedPopover = nearestInclusiveOpenPopover(target);
3611
+ const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);
3612
+ if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {
3613
+ return clickedPopover;
3614
+ }
3615
+ return invokerPopover;
3616
+ }
3617
+ function topMostAutoPopover(document2) {
3618
+ const documentPopovers = autoPopoverList.get(document2);
3619
+ for (const popover of documentPopovers || []) {
3620
+ if (!popover.isConnected) {
3621
+ documentPopovers.delete(popover);
3622
+ } else {
3623
+ return popover;
3624
+ }
3625
+ }
3626
+ return null;
3627
+ }
3628
+ function getRootNode(node) {
3629
+ if (typeof node.getRootNode === "function") {
3630
+ return node.getRootNode();
3631
+ }
3632
+ if (node.parentNode) return getRootNode(node.parentNode);
3633
+ return node;
3634
+ }
3635
+ function nearestInclusiveOpenPopover(node) {
3636
+ while (node) {
3637
+ if (node instanceof HTMLElement && node.popover === "auto" && visibilityState.get(node) === "showing") {
3638
+ return node;
3639
+ }
3640
+ node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);
3641
+ if (node instanceof ShadowRoot$1) node = node.host;
3642
+ if (node instanceof Document) return;
3643
+ }
3644
+ }
3645
+ function nearestInclusiveTargetPopoverForInvoker(node) {
3646
+ while (node) {
3647
+ const nodePopover = node.popoverTargetElement;
3648
+ if (nodePopover instanceof HTMLElement) return nodePopover;
3649
+ node = node.parentElement || getRootNode(node);
3650
+ if (node instanceof ShadowRoot$1) node = node.host;
3651
+ if (node instanceof Document) return;
3652
+ }
3653
+ }
3654
+ function topMostPopoverAncestor(newPopover) {
3655
+ const popoverPositions = /* @__PURE__ */ new Map();
3656
+ let i = 0;
3657
+ for (const popover of autoPopoverList.get(newPopover.ownerDocument) || []) {
3658
+ popoverPositions.set(popover, i);
3659
+ i += 1;
3660
+ }
3661
+ popoverPositions.set(newPopover, i);
3662
+ i += 1;
3663
+ let topMostPopoverAncestor2 = null;
3664
+ function checkAncestor(candidate) {
3665
+ const candidateAncestor = nearestInclusiveOpenPopover(candidate);
3666
+ if (candidateAncestor === null) return null;
3667
+ const candidatePosition = popoverPositions.get(candidateAncestor);
3668
+ if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {
3669
+ topMostPopoverAncestor2 = candidateAncestor;
3670
+ }
3671
+ }
3672
+ checkAncestor(newPopover.parentElement || getRootNode(newPopover));
3673
+ return topMostPopoverAncestor2;
3674
+ }
3675
+ function isFocusable(focusTarget) {
3676
+ if (focusTarget.hidden || focusTarget instanceof ShadowRoot$1) return false;
3677
+ if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {
3678
+ if (focusTarget.disabled) return false;
3679
+ }
3680
+ if (focusTarget instanceof HTMLInputElement && focusTarget.type === "hidden") {
3681
+ return false;
3682
+ }
3683
+ if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === "") {
3684
+ return false;
3685
+ }
3686
+ return typeof focusTarget.tabIndex === "number" && focusTarget.tabIndex !== -1;
3687
+ }
3688
+ function focusDelegate(focusTarget) {
3689
+ if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {
3690
+ return null;
3691
+ }
3692
+ let whereToLook = focusTarget;
3693
+ if (whereToLook.shadowRoot) {
3694
+ whereToLook = whereToLook.shadowRoot;
3695
+ }
3696
+ let autoFocusDelegate = whereToLook.querySelector("[autofocus]");
3697
+ if (autoFocusDelegate) {
3698
+ return autoFocusDelegate;
3699
+ } else {
3700
+ const slots = whereToLook.querySelectorAll("slot");
3701
+ for (const slot of slots) {
3702
+ const assignedElements = slot.assignedElements({ flatten: true });
3703
+ for (const el of assignedElements) {
3704
+ if (el.hasAttribute("autofocus")) {
3705
+ return el;
3706
+ } else {
3707
+ autoFocusDelegate = el.querySelector("[autofocus]");
3708
+ if (autoFocusDelegate) {
3709
+ return autoFocusDelegate;
3710
+ }
3711
+ }
3712
+ }
3713
+ }
3714
+ }
3715
+ const walker = focusTarget.ownerDocument.createTreeWalker(
3716
+ whereToLook,
3717
+ NodeFilter.SHOW_ELEMENT
3718
+ );
3719
+ let descendant = walker.currentNode;
3720
+ while (descendant) {
3721
+ if (isFocusable(descendant)) {
3722
+ return descendant;
3723
+ }
3724
+ descendant = walker.nextNode();
3725
+ }
3726
+ }
3727
+ function popoverFocusingSteps(subject) {
3728
+ focusDelegate(subject)?.focus();
3729
+ }
3730
+ var previouslyFocusedElements = /* @__PURE__ */ new WeakMap();
3731
+ function showPopover(element) {
3732
+ if (!checkPopoverValidity(element, false)) {
3733
+ return;
3734
+ }
3735
+ const document2 = element.ownerDocument;
3736
+ if (!element.dispatchEvent(
3737
+ new ToggleEvent("beforetoggle", {
3738
+ cancelable: true,
3739
+ oldState: "closed",
3740
+ newState: "open"
3741
+ })
3742
+ )) {
3743
+ return;
3744
+ }
3745
+ if (!checkPopoverValidity(element, false)) {
3746
+ return;
3747
+ }
3748
+ let shouldRestoreFocus = false;
3749
+ if (element.popover === "auto") {
3750
+ const originalType = element.getAttribute("popover");
3751
+ const ancestor = topMostPopoverAncestor(element) || document2;
3752
+ hideAllPopoversUntil(ancestor, false, true);
3753
+ if (originalType !== element.getAttribute("popover") || !checkPopoverValidity(element, false)) {
3754
+ return;
3755
+ }
3756
+ }
3757
+ if (!topMostAutoPopover(document2)) {
3758
+ shouldRestoreFocus = true;
3759
+ }
3760
+ previouslyFocusedElements.delete(element);
3761
+ const originallyFocusedElement = document2.activeElement;
3762
+ element.classList.add(":popover-open");
3763
+ visibilityState.set(element, "showing");
3764
+ if (!topLayerElements.has(document2)) {
3765
+ topLayerElements.set(document2, /* @__PURE__ */ new Set());
3766
+ }
3767
+ topLayerElements.get(document2).add(element);
3768
+ popoverFocusingSteps(element);
3769
+ if (element.popover === "auto") {
3770
+ if (!autoPopoverList.has(document2)) {
3771
+ autoPopoverList.set(document2, /* @__PURE__ */ new Set());
3772
+ }
3773
+ autoPopoverList.get(document2).add(element);
3774
+ setInvokerAriaExpanded(popoverInvoker.get(element), true);
3775
+ }
3776
+ if (shouldRestoreFocus && originallyFocusedElement && element.popover === "auto") {
3777
+ previouslyFocusedElements.set(element, originallyFocusedElement);
3778
+ }
3779
+ queuePopoverToggleEventTask(element, "closed", "open");
3780
+ }
3781
+ function hidePopover(element, focusPreviousElement = false, fireEvents = false) {
3782
+ if (!checkPopoverValidity(element, true)) {
3783
+ return;
3784
+ }
3785
+ const document2 = element.ownerDocument;
3786
+ if (element.popover === "auto") {
3787
+ hideAllPopoversUntil(element, focusPreviousElement, fireEvents);
3788
+ if (!checkPopoverValidity(element, true)) {
3789
+ return;
3790
+ }
3791
+ }
3792
+ setInvokerAriaExpanded(popoverInvoker.get(element), false);
3793
+ popoverInvoker.delete(element);
3794
+ if (fireEvents) {
3795
+ element.dispatchEvent(
3796
+ new ToggleEvent("beforetoggle", {
3797
+ oldState: "open",
3798
+ newState: "closed"
3799
+ })
3800
+ );
3801
+ if (!checkPopoverValidity(element, true)) {
3802
+ return;
3803
+ }
3804
+ }
3805
+ topLayerElements.get(document2)?.delete(element);
3806
+ autoPopoverList.get(document2)?.delete(element);
3807
+ element.classList.remove(":popover-open");
3808
+ visibilityState.set(element, "hidden");
3809
+ if (fireEvents) {
3810
+ queuePopoverToggleEventTask(element, "open", "closed");
3811
+ }
3812
+ const previouslyFocusedElement = previouslyFocusedElements.get(element);
3813
+ if (previouslyFocusedElement) {
3814
+ previouslyFocusedElements.delete(element);
3815
+ if (focusPreviousElement) {
3816
+ previouslyFocusedElement.focus();
3817
+ }
3818
+ }
3819
+ }
3820
+ function closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {
3821
+ let popover = topMostAutoPopover(document2);
3822
+ while (popover) {
3823
+ hidePopover(popover, focusPreviousElement, fireEvents);
3824
+ popover = topMostAutoPopover(document2);
3825
+ }
3826
+ }
3827
+ function hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {
3828
+ const document2 = endpoint.ownerDocument || endpoint;
3829
+ if (endpoint instanceof Document) {
3830
+ return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);
3831
+ }
3832
+ let lastToHide = null;
3833
+ let foundEndpoint = false;
3834
+ for (const popover of autoPopoverList.get(document2) || []) {
3835
+ if (popover === endpoint) {
3836
+ foundEndpoint = true;
3837
+ } else if (foundEndpoint) {
3838
+ lastToHide = popover;
3839
+ break;
3840
+ }
3841
+ }
3842
+ if (!foundEndpoint) {
3843
+ return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);
3844
+ }
3845
+ while (lastToHide && getPopoverVisibilityState(lastToHide) === "showing" && autoPopoverList.get(document2)?.size) {
3846
+ hidePopover(lastToHide, focusPreviousElement, fireEvents);
3847
+ }
3848
+ }
3849
+ var popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();
3850
+ function lightDismissOpenPopovers(event) {
3851
+ if (!event.isTrusted) return;
3852
+ const target = event.composedPath()[0];
3853
+ if (!target) return;
3854
+ const document2 = target.ownerDocument;
3855
+ const topMostPopover = topMostAutoPopover(document2);
3856
+ if (!topMostPopover) return;
3857
+ const ancestor = topMostClickedPopover(target);
3858
+ if (ancestor && event.type === "pointerdown") {
3859
+ popoverPointerDownTargets.set(document2, ancestor);
3860
+ } else if (event.type === "pointerup") {
3861
+ const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;
3862
+ popoverPointerDownTargets.delete(document2);
3863
+ if (sameTarget) {
3864
+ hideAllPopoversUntil(ancestor || document2, false, true);
3865
+ }
3866
+ }
3867
+ }
3868
+ var initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();
3869
+ function setInvokerAriaExpanded(el, force = false) {
3870
+ if (!el) return;
3871
+ if (!initialAriaExpandedValue.has(el)) {
3872
+ initialAriaExpandedValue.set(el, el.getAttribute("aria-expanded"));
3873
+ }
3874
+ const popover = el.popoverTargetElement;
3875
+ if (popover instanceof HTMLElement && popover.popover === "auto") {
3876
+ el.setAttribute("aria-expanded", String(force));
3877
+ } else {
3878
+ const initialValue = initialAriaExpandedValue.get(el);
3879
+ if (!initialValue) {
3880
+ el.removeAttribute("aria-expanded");
3881
+ } else {
3882
+ el.setAttribute("aria-expanded", initialValue);
3883
+ }
3884
+ }
3885
+ }
3886
+
3887
+ // src/popover.ts
3888
+ var ShadowRoot2 = globalThis.ShadowRoot || function() {
3889
+ };
3890
+ function isSupported() {
3891
+ return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype === "object" && "popover" in HTMLElement.prototype;
3892
+ }
3893
+ function patchSelectorFn(object, name, mapper) {
3894
+ const original = object[name];
3895
+ Object.defineProperty(object, name, {
3896
+ value(selector) {
3897
+ return original.call(this, mapper(selector));
3898
+ }
3899
+ });
3900
+ }
3901
+ var nonEscapedPopoverSelector = /(^|[^\\]):popover-open\b/g;
3902
+ function hasLayerSupport() {
3903
+ return typeof globalThis.CSSLayerBlockRule === "function";
3904
+ }
3905
+ function getStyles() {
3906
+ const useLayer = hasLayerSupport();
3907
+ return `
3908
+ ${useLayer ? "@layer popover-polyfill {" : ""}
3909
+ :where([popover]) {
3910
+ position: fixed;
3911
+ z-index: 2147483647;
3912
+ inset: 0;
3913
+ padding: 0.25em;
3914
+ width: fit-content;
3915
+ height: fit-content;
3916
+ border-width: initial;
3917
+ border-color: initial;
3918
+ border-image: initial;
3919
+ border-style: solid;
3920
+ background-color: canvas;
3921
+ color: canvastext;
3922
+ overflow: auto;
3923
+ margin: auto;
3924
+ }
3925
+
3926
+ :where([popover]:not(.\\:popover-open)) {
3927
+ display: none;
3928
+ }
3929
+
3930
+ :where(dialog[popover].\\:popover-open) {
3931
+ display: block;
3932
+ }
3933
+
3934
+ :where(dialog[popover][open]) {
3935
+ display: revert;
3936
+ }
3937
+
3938
+ :where([anchor].\\:popover-open) {
3939
+ inset: auto;
3940
+ }
3941
+
3942
+ :where([anchor]:popover-open) {
3943
+ inset: auto;
3944
+ }
3945
+
3946
+ @supports not (background-color: canvas) {
3947
+ :where([popover]) {
3948
+ background-color: white;
3949
+ color: black;
3950
+ }
3951
+ }
3952
+
3953
+ @supports (width: -moz-fit-content) {
3954
+ :where([popover]) {
3955
+ width: -moz-fit-content;
3956
+ height: -moz-fit-content;
3957
+ }
3958
+ }
3959
+
3960
+ @supports not (inset: 0) {
3961
+ :where([popover]) {
3962
+ top: 0;
3963
+ left: 0;
3964
+ right: 0;
3965
+ bottom: 0;
3966
+ }
3967
+ }
3968
+ ${useLayer ? "}" : ""}
3969
+ `;
3970
+ }
3971
+ var popoverStyleSheet = null;
3972
+ function injectStyles(root) {
3973
+ const styles = getStyles();
3974
+ if (popoverStyleSheet === null) {
3975
+ try {
3976
+ popoverStyleSheet = new CSSStyleSheet();
3977
+ popoverStyleSheet.replaceSync(styles);
3978
+ } catch {
3979
+ popoverStyleSheet = false;
3980
+ }
3981
+ }
3982
+ if (popoverStyleSheet === false) {
3983
+ const sheet = document.createElement("style");
3984
+ sheet.textContent = styles;
3985
+ if (root instanceof Document) {
3986
+ root.head.prepend(sheet);
3987
+ } else {
3988
+ root.prepend(sheet);
3989
+ }
3990
+ } else {
3991
+ root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];
3992
+ }
3993
+ }
3994
+ function apply() {
3995
+ if (typeof window === "undefined") return;
3996
+ window.ToggleEvent = window.ToggleEvent || ToggleEvent;
3997
+ function rewriteSelector(selector) {
3998
+ if (selector?.includes(":popover-open")) {
3999
+ selector = selector.replace(
4000
+ nonEscapedPopoverSelector,
4001
+ "$1.\\:popover-open"
4002
+ );
4003
+ }
4004
+ return selector;
4005
+ }
4006
+ patchSelectorFn(Document.prototype, "querySelector", rewriteSelector);
4007
+ patchSelectorFn(Document.prototype, "querySelectorAll", rewriteSelector);
4008
+ patchSelectorFn(Element.prototype, "querySelector", rewriteSelector);
4009
+ patchSelectorFn(Element.prototype, "querySelectorAll", rewriteSelector);
4010
+ patchSelectorFn(Element.prototype, "matches", rewriteSelector);
4011
+ patchSelectorFn(Element.prototype, "closest", rewriteSelector);
4012
+ patchSelectorFn(
4013
+ DocumentFragment.prototype,
4014
+ "querySelectorAll",
4015
+ rewriteSelector
4016
+ );
4017
+ Object.defineProperties(HTMLElement.prototype, {
4018
+ popover: {
4019
+ enumerable: true,
4020
+ configurable: true,
4021
+ get() {
4022
+ if (!this.hasAttribute("popover")) return null;
4023
+ const value = (this.getAttribute("popover") || "").toLowerCase();
4024
+ if (value === "" || value == "auto") return "auto";
4025
+ return "manual";
4026
+ },
4027
+ set(value) {
4028
+ if (value === null) {
4029
+ this.removeAttribute("popover");
4030
+ } else {
4031
+ this.setAttribute("popover", value);
4032
+ }
4033
+ }
4034
+ },
4035
+ showPopover: {
4036
+ enumerable: true,
4037
+ configurable: true,
4038
+ value() {
4039
+ showPopover(this);
4040
+ }
4041
+ },
4042
+ hidePopover: {
4043
+ enumerable: true,
4044
+ configurable: true,
4045
+ value() {
4046
+ hidePopover(this, true, true);
4047
+ }
4048
+ },
4049
+ togglePopover: {
4050
+ enumerable: true,
4051
+ configurable: true,
4052
+ value(force) {
4053
+ if (visibilityState.get(this) === "showing" && force === void 0 || force === false) {
4054
+ hidePopover(this, true, true);
4055
+ } else if (force === void 0 || force === true) {
4056
+ showPopover(this);
4057
+ }
4058
+ }
4059
+ }
4060
+ });
4061
+ const originalAttachShadow = Element.prototype.attachShadow;
4062
+ if (originalAttachShadow) {
4063
+ Object.defineProperties(Element.prototype, {
4064
+ attachShadow: {
4065
+ enumerable: true,
4066
+ configurable: true,
4067
+ writable: true,
4068
+ value(options) {
4069
+ const shadowRoot = originalAttachShadow.call(this, options);
4070
+ injectStyles(shadowRoot);
4071
+ return shadowRoot;
4072
+ }
4073
+ }
4074
+ });
4075
+ }
4076
+ const originalAttachInternals = HTMLElement.prototype.attachInternals;
4077
+ if (originalAttachInternals) {
4078
+ Object.defineProperties(HTMLElement.prototype, {
4079
+ attachInternals: {
4080
+ enumerable: true,
4081
+ configurable: true,
4082
+ writable: true,
4083
+ value() {
4084
+ const internals = originalAttachInternals.call(this);
4085
+ if (internals.shadowRoot) {
4086
+ injectStyles(internals.shadowRoot);
4087
+ }
4088
+ return internals;
4089
+ }
4090
+ }
4091
+ });
4092
+ }
4093
+ const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();
4094
+ function applyPopoverInvokerElementMixin(ElementClass) {
4095
+ Object.defineProperties(ElementClass.prototype, {
4096
+ popoverTargetElement: {
4097
+ enumerable: true,
4098
+ configurable: true,
4099
+ set(targetElement) {
4100
+ if (targetElement === null) {
4101
+ this.removeAttribute("popovertarget");
4102
+ popoverTargetAssociatedElements.delete(this);
4103
+ } else if (!(targetElement instanceof Element)) {
4104
+ throw new TypeError(
4105
+ `popoverTargetElement must be an element or null`
4106
+ );
4107
+ } else {
4108
+ this.setAttribute("popovertarget", "");
4109
+ popoverTargetAssociatedElements.set(this, targetElement);
4110
+ }
4111
+ },
4112
+ get() {
4113
+ if (this.localName !== "button" && this.localName !== "input") {
4114
+ return null;
4115
+ }
4116
+ if (this.localName === "input" && this.type !== "reset" && this.type !== "image" && this.type !== "button") {
4117
+ return null;
4118
+ }
4119
+ if (this.disabled) {
4120
+ return null;
4121
+ }
4122
+ if (this.form && this.type === "submit") {
4123
+ return null;
4124
+ }
4125
+ const targetElement = popoverTargetAssociatedElements.get(this);
4126
+ if (targetElement && targetElement.isConnected) {
4127
+ return targetElement;
4128
+ } else if (targetElement && !targetElement.isConnected) {
4129
+ popoverTargetAssociatedElements.delete(this);
4130
+ return null;
4131
+ }
4132
+ const root = getRootNode(this);
4133
+ const idref = this.getAttribute("popovertarget");
4134
+ if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {
4135
+ return root.getElementById(idref) || null;
4136
+ }
4137
+ return null;
4138
+ }
4139
+ },
4140
+ popoverTargetAction: {
4141
+ enumerable: true,
4142
+ configurable: true,
4143
+ get() {
4144
+ const value = (this.getAttribute("popovertargetaction") || "").toLowerCase();
4145
+ if (value === "show" || value === "hide") return value;
4146
+ return "toggle";
4147
+ },
4148
+ set(value) {
4149
+ this.setAttribute("popovertargetaction", value);
4150
+ }
4151
+ }
4152
+ });
4153
+ }
4154
+ applyPopoverInvokerElementMixin(HTMLButtonElement);
4155
+ applyPopoverInvokerElementMixin(HTMLInputElement);
4156
+ const handleInvokerActivation = (event) => {
4157
+ const composedPath = event.composedPath();
4158
+ const target = composedPath[0];
4159
+ if (!(target instanceof Element) || target?.shadowRoot) {
4160
+ return;
4161
+ }
4162
+ const root = getRootNode(target);
4163
+ if (!(root instanceof ShadowRoot2 || root instanceof Document)) {
4164
+ return;
4165
+ }
4166
+ const invoker = composedPath.find(
4167
+ (el) => el.matches?.("[popovertargetaction],[popovertarget]")
4168
+ );
4169
+ if (invoker) {
4170
+ popoverTargetAttributeActivationBehavior(invoker);
4171
+ event.preventDefault();
4172
+ return;
4173
+ }
4174
+ };
4175
+ const onKeydown = (event) => {
4176
+ const key = event.key;
4177
+ const target = event.target;
4178
+ if (!event.defaultPrevented && target && (key === "Escape" || key === "Esc")) {
4179
+ hideAllPopoversUntil(target.ownerDocument, true, true);
4180
+ }
4181
+ };
4182
+ const addEventListeners = (root) => {
4183
+ root.addEventListener("click", handleInvokerActivation);
4184
+ root.addEventListener("keydown", onKeydown);
4185
+ root.addEventListener("pointerdown", lightDismissOpenPopovers);
4186
+ root.addEventListener("pointerup", lightDismissOpenPopovers);
4187
+ };
4188
+ addEventListeners(document);
4189
+ injectStyles(document);
4190
+ }
4191
+
4192
+ const postPopovercontainerCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}@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-palette-fg);background-color:var(--post-current-palette-bg);border:2px solid rgba(0,0,0,0);border-radius:4px}:where(post-popovercontainer)>div.animate-pop-in{animation:popIn .25s ease-out forwards}: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)}";
4193
+ const PostPopovercontainerStyle0 = postPopovercontainerCss;
4194
+
4195
+ const PostPopovercontainer = class {
4196
+ constructor(hostRef) {
4197
+ index.registerInstance(this, hostRef);
4198
+ this.postToggle = index.createEvent(this, "postToggle", 7);
4199
+ this.placement = 'top';
4200
+ this.edgeGap = 8;
4201
+ this.animation = null;
4202
+ this.arrow = false;
4203
+ this.manualClose = false;
4204
+ this.safeSpace = undefined;
4205
+ }
4206
+ /**
4207
+ * Updates cursor position for safe space feature when popover is open.
4208
+ * Sets CSS custom properties for dynamic styling of safe area.
4209
+ * @param event MouseEvent with cursor position
4210
+ */
4211
+ mouseTrackingHandler(event) {
4212
+ this.host.style.setProperty('--post-safe-space-cursor-x', `${event.clientX}px`);
4213
+ this.host.style.setProperty('--post-safe-space-cursor-y', `${event.clientY}px`);
4214
+ }
4215
+ connectedCallback() {
4216
+ if (breakpoints.IS_BROWSER && !isSupported()) {
4217
+ apply();
4218
+ }
4219
+ }
4220
+ componentDidLoad() {
4221
+ this.host.addEventListener('beforetoggle', this.handleToggle.bind(this));
4222
+ }
4223
+ disconnectedCallback() {
4224
+ if (typeof this.clearAutoUpdate === 'function') {
4225
+ this.clearAutoUpdate();
4226
+ }
4227
+ }
4228
+ /**
4229
+ * Programmatically display the popovercontainer
4230
+ * @param target An element with [data-popover-target="id"] where the popovercontainer should be shown
4231
+ */
4232
+ async show(target) {
4233
+ if (!this.toggleTimeoutId) {
4234
+ this.eventTarget = target;
4235
+ this.calculatePosition();
4236
+ this.host.showPopover();
4237
+ }
4238
+ }
4239
+ /**
4240
+ * Programmatically hide the popovercontainer
4241
+ */
4242
+ async hide() {
4243
+ if (!this.toggleTimeoutId) {
4244
+ this.eventTarget = null;
4245
+ this.host.hidePopover();
4246
+ }
4247
+ }
4248
+ /**
4249
+ * Toggle popovercontainer display
4250
+ * @param target An element with [data-popover-target="id"] where the popovercontainer should be shown
4251
+ * @param force Pass true to always show or false to always hide
4252
+ */
4253
+ async toggle(target, force) {
4254
+ // Prevent instant double toggle
4255
+ if (!this.toggleTimeoutId) {
4256
+ this.eventTarget = target;
4257
+ this.calculatePosition();
4258
+ this.host.togglePopover(force);
4259
+ this.toggleTimeoutId = null;
4260
+ }
4261
+ return this.host.matches(':where(:popover-open, .popover-open)');
4262
+ }
4263
+ /**
4264
+ * Start or stop auto updates based on popovercontainer events.
4265
+ * Popovercontainers can be closed or opened with other methods than class members,
4266
+ * therefore listening to the toggle event is safer for cleaning up.
4267
+ * @param e ToggleEvent
4268
+ */
4269
+ handleToggle(e) {
4270
+ this.toggleTimeoutId = window.setTimeout(() => (this.toggleTimeoutId = null), 10);
4271
+ const isOpen = e.newState === 'open';
4272
+ if (isOpen) {
4273
+ this.startAutoupdates();
4274
+ if (this.safeSpace)
4275
+ window.addEventListener('mousemove', this.mouseTrackingHandler.bind(this));
4276
+ }
4277
+ else {
4278
+ if (typeof this.clearAutoUpdate === 'function')
4279
+ this.clearAutoUpdate();
4280
+ if (this.safeSpace)
4281
+ window.removeEventListener('mousemove', this.mouseTrackingHandler.bind(this));
4282
+ }
4283
+ this.postToggle.emit(isOpen);
4284
+ }
4285
+ /**
4286
+ * Start listening for DOM updates, scroll events etc. that have
4287
+ * an influence on popovercontainer positioning
4288
+ */
4289
+ startAutoupdates() {
4290
+ this.clearAutoUpdate = autoUpdate(this.eventTarget, this.host, this.calculatePosition.bind(this));
4291
+ }
4292
+ /**
4293
+ * Retrieves the dynamic height of the header
4294
+ */
4295
+ getHeaderHeight() {
4296
+ const header = document.querySelector('post-header');
4297
+ return header ? parseFloat(getComputedStyle(header).height) : 0;
4298
+ }
4299
+ async calculatePosition() {
4300
+ const { x, y, middlewareData, placement } = await this.computeMainPosition();
4301
+ const currentPlacement = placement.split('-')[0];
4302
+ // Position popover
4303
+ this.host.style.left = `${x}px`;
4304
+ this.host.style.top = `${y}px`;
4305
+ // Position arrow if enabled
4306
+ if (this.arrow && middlewareData.arrow) {
4307
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
4308
+ const staticSide = PostPopovercontainer.STATIC_SIDES[currentPlacement];
4309
+ if (staticSide) {
4310
+ Object.assign(this.arrowRef.style, {
4311
+ left: arrowX ? `${arrowX}px` : '',
4312
+ top: arrowY ? `${arrowY}px` : '',
4313
+ [staticSide]: '-7px',
4314
+ });
4315
+ }
4316
+ }
4317
+ // Handle safe space if enabled
4318
+ if (this.safeSpace && this.eventTarget) {
4319
+ await this.updateSafeSpaceBoundaries(currentPlacement);
4320
+ }
4321
+ }
4322
+ async computeMainPosition() {
4323
+ const gap = this.edgeGap;
4324
+ const middleware = [
4325
+ flip({
4326
+ padding: this.getHeaderHeight(),
4327
+ }),
4328
+ inline(),
4329
+ shift({
4330
+ padding: gap,
4331
+ limiter: limitShift({
4332
+ offset: 32,
4333
+ }),
4334
+ }),
4335
+ size({
4336
+ apply({ availableWidth, elements }) {
4337
+ Object.assign(elements.floating.style, {
4338
+ maxWidth: `${availableWidth - gap * 2}px`,
4339
+ });
4340
+ },
4341
+ }),
4342
+ offset(this.arrow ? gap + 4 : gap),
4343
+ ];
4344
+ if (this.arrow) {
4345
+ middleware.push(arrow({ element: this.arrowRef, padding: gap }));
4346
+ }
4347
+ return computePosition(this.eventTarget, this.host, {
4348
+ placement: this.placement || 'top',
4349
+ strategy: 'fixed',
4350
+ middleware,
4351
+ });
4352
+ }
4353
+ async updateSafeSpaceBoundaries(currentPlacement) {
4354
+ const targetRect = this.eventTarget.getBoundingClientRect();
4355
+ const popoverRect = this.host.getBoundingClientRect();
4356
+ const isVertical = currentPlacement === 'top' || currentPlacement === 'bottom';
4357
+ // Helper function to get positioning data based on placement
4358
+ const getPositioningData = (placement, popoverRect, targetRect) => {
4359
+ if (placement === 'top' || placement === 'bottom') {
4360
+ return {
4361
+ popover: {
4362
+ y: placement === 'top' ? popoverRect.bottom : popoverRect.top,
4363
+ xStart: popoverRect.left,
4364
+ xEnd: popoverRect.right,
4365
+ },
4366
+ trigger: {
4367
+ y: placement === 'top' ? targetRect.top : targetRect.bottom,
4368
+ xStart: targetRect.left,
4369
+ xEnd: targetRect.right,
4370
+ },
4371
+ };
4372
+ }
4373
+ else {
4374
+ // left or right
4375
+ return {
4376
+ popover: {
4377
+ x: placement === 'left' ? popoverRect.right : popoverRect.left,
4378
+ yStart: popoverRect.top,
4379
+ yEnd: popoverRect.bottom,
4380
+ },
4381
+ trigger: {
4382
+ x: placement === 'left' ? targetRect.left : targetRect.right,
4383
+ yStart: targetRect.top,
4384
+ yEnd: targetRect.bottom,
4385
+ },
4386
+ };
4387
+ }
4388
+ };
4389
+ const posData = getPositioningData(currentPlacement, popoverRect, targetRect);
4390
+ // Clear previous values
4391
+ PostPopovercontainer.PROPERTIES_TO_CLEAR.forEach(prop => {
4392
+ this.host.style.removeProperty(prop);
4393
+ });
4394
+ if (isVertical) {
4395
+ // For top/bottom placement
4396
+ this.host.style.setProperty('--post-safe-space-popover-y', `${posData.popover.y}px`);
4397
+ this.host.style.setProperty('--post-safe-space-popover-x-start', `${posData.popover.xStart}px`);
4398
+ this.host.style.setProperty('--post-safe-space-popover-x-end', `${posData.popover.xEnd}px`);
4399
+ this.host.style.setProperty('--post-safe-space-trigger-y', `${posData.trigger.y}px`);
4400
+ this.host.style.setProperty('--post-safe-space-trigger-x-start', `${posData.trigger.xStart}px`);
4401
+ this.host.style.setProperty('--post-safe-space-trigger-x-end', `${posData.trigger.xEnd}px`);
4402
+ }
4403
+ else {
4404
+ // For left/right placement
4405
+ this.host.style.setProperty('--post-safe-space-popover-x', `${posData.popover.x}px`);
4406
+ this.host.style.setProperty('--post-safe-space-popover-y-start', `${posData.popover.yStart}px`);
4407
+ this.host.style.setProperty('--post-safe-space-popover-y-end', `${posData.popover.yEnd}px`);
4408
+ this.host.style.setProperty('--post-safe-space-trigger-x', `${posData.trigger.x}px`);
4409
+ this.host.style.setProperty('--post-safe-space-trigger-y-start', `${posData.trigger.yStart}px`);
4410
+ this.host.style.setProperty('--post-safe-space-trigger-y-end', `${posData.trigger.yEnd}px`);
4411
+ }
4412
+ }
4413
+ render() {
4414
+ const animationClass = this.animation ? `animate-${this.animation}` : '';
4415
+ return (index.h(index.Host, { key: '980c2d7531ef77f71ea51b069dc20bbf40cd0ac4', "data-version": _package.version, popover: this.manualClose ? 'manual' : 'auto' }, index.h("div", { key: '9fa08070a5e7f864aade0dc1afc2917e54693109', class: animationClass }, this.arrow && (index.h("span", { key: '4700f55c721387f2d918214309e87c9057e4831f', class: "arrow", ref: el => {
4416
+ this.arrowRef = el;
4417
+ } })), index.h("slot", { key: 'ec5304bc77d4f3eb91c79fb2a37d096b4d43b888' }))));
4418
+ }
4419
+ get host() { return index.getElement(this); }
4420
+ };
4421
+ PostPopovercontainer.STATIC_SIDES = {
4422
+ top: 'bottom',
4423
+ right: 'left',
4424
+ bottom: 'top',
4425
+ left: 'right',
4426
+ };
4427
+ PostPopovercontainer.PROPERTIES_TO_CLEAR = [
4428
+ '--post-safe-space-popover-x',
4429
+ '--post-safe-space-popover-y',
4430
+ '--post-safe-space-popover-x-start',
4431
+ '--post-safe-space-popover-x-end',
4432
+ '--post-safe-space-popover-y-start',
4433
+ '--post-safe-space-popover-y-end',
4434
+ '--post-safe-space-trigger-x',
4435
+ '--post-safe-space-trigger-y',
4436
+ '--post-safe-space-trigger-x-start',
4437
+ '--post-safe-space-trigger-x-end',
4438
+ '--post-safe-space-trigger-y-start',
4439
+ '--post-safe-space-trigger-y-end',
4440
+ ];
4441
+ PostPopovercontainer.style = PostPopovercontainerStyle0;
4442
+
4443
+ const postTogglebuttonCss = ":host{cursor:pointer;outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}:host(:focus-visible){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host(:focus-visible){outline-color:Highlight !important}}:host([aria-pressed=true]) ::slotted([data-showwhen=untoggled]){display:none}:host([aria-pressed=false]) ::slotted([data-showwhen=toggled]){display:none}";
4444
+ const PostTogglebuttonStyle0 = postTogglebuttonCss;
4445
+
4446
+ const PostTogglebutton = class {
4447
+ constructor(hostRef) {
4448
+ index.registerInstance(this, hostRef);
4449
+ this.handleClick = () => {
4450
+ this.toggled = !this.toggled;
4451
+ };
4452
+ this.handleKeydown = (event) => {
4453
+ // perform a click when enter or spaced are pressed to mimic the button behavior
4454
+ if (event.key === 'Enter' || event.key === ' ') {
4455
+ event.preventDefault(); // prevents the page from scrolling when space is pressed
4456
+ this.host.click();
4457
+ }
4458
+ };
4459
+ this.toggled = false;
4460
+ }
4461
+ validateToggled() {
4462
+ checkType.checkType(this, 'toggled', 'boolean');
4463
+ }
4464
+ componentWillLoad() {
4465
+ this.validateToggled();
4466
+ // add event listener to not override listener that might be set on the host
4467
+ this.host.addEventListener('click', () => this.handleClick());
4468
+ this.host.addEventListener('keydown', (e) => this.handleKeydown(e));
4469
+ }
4470
+ render() {
4471
+ return (index.h(index.Host, { key: '3a1429a9b67b8cfafae184fe0d060ee3a04974e0', "data-version": _package.version, role: "button", tabindex: "0", "aria-pressed": this.toggled.toString() }, index.h("slot", { key: '9ab1537574423740fc335fde732c699698acac25' })));
4472
+ }
4473
+ get host() { return index.getElement(this); }
4474
+ static get watchers() { return {
4475
+ "toggled": ["validateToggled"]
4476
+ }; }
4477
+ };
4478
+ PostTogglebutton.style = PostTogglebuttonStyle0;
4479
+
4480
+ exports.PostClosebutton = PostClosebutton;
4481
+ exports.PostHeader = PostHeader;
4482
+ exports.PostIcon = PostIcon;
4483
+ exports.PostLanguageOption = PostLanguageOption;
4484
+ exports.PostLanguageSwitch = PostLanguageSwitch;
4485
+ exports.PostList = PostList;
4486
+ exports.PostListItem = PostListItem;
4487
+ exports.PostLogo = PostLogo;
4488
+ exports.PostMainnavigation = PostMainnavigation;
4489
+ exports.PostMegadropdown = PostMegadropdown;
4490
+ exports.PostMegadropdownTrigger = PostMegadropdownTrigger;
4491
+ exports.PostMenu = PostMenu;
4492
+ exports.PostMenuTrigger = PostMenuTrigger;
4493
+ exports.PostPopovercontainer = PostPopovercontainer;
4494
+ exports.PostTogglebutton = PostTogglebutton;