@swisspost/design-system-components 9.0.0-next.2 → 9.0.0-next.21

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 (538) hide show
  1. package/dist/.config/bindings.angular.js +4 -0
  2. package/dist/cjs/{attribute-observer-10f08c04.js → attribute-observer-6d8b886b.js} +4 -4
  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/debounce-158fd76f.js +13 -0
  8. package/dist/cjs/fade-72d5ef55.js +14 -0
  9. package/dist/cjs/get-root-7a3498ef.js +11 -0
  10. package/dist/cjs/index-23e36ff7.js +37 -0
  11. package/dist/cjs/{index-c15bd800.js → index-5acef487.js} +54 -17
  12. package/dist/cjs/index.browser-2f65f583.js +15 -0
  13. package/dist/cjs/index.cjs.js +56 -27
  14. package/dist/cjs/loader.cjs.js +2 -2
  15. package/dist/cjs/{package-a7150f64.js → package-c6bc9e82.js} +1 -1
  16. package/dist/cjs/{post-accordion-62d2fd79.js → post-accordion-d1345784.js} +9 -8
  17. package/dist/cjs/post-accordion-item-a796d803.js +64 -0
  18. package/dist/cjs/post-accordion-item.cjs.entry.js +8 -5
  19. package/dist/cjs/post-accordion.cjs.entry.js +4 -4
  20. package/dist/cjs/post-avatar-b4e96354.js +144 -0
  21. package/dist/cjs/post-avatar.cjs.entry.js +13 -0
  22. package/dist/cjs/post-back-to-top-fc541c6b.js +76 -0
  23. package/dist/cjs/post-back-to-top.cjs.entry.js +15 -0
  24. package/dist/cjs/post-banner-46522b4f.js +96 -0
  25. package/dist/cjs/post-banner.cjs.entry.js +19 -0
  26. package/dist/cjs/post-breadcrumb-799d34da.js +112 -0
  27. package/dist/cjs/post-breadcrumb-item_2.cjs.entry.js +17 -0
  28. package/dist/cjs/post-breadcrumb.cjs.entry.js +13 -0
  29. package/dist/cjs/post-card-control-7bf7d3f2.js +283 -0
  30. package/dist/cjs/post-card-control.cjs.entry.js +5 -5
  31. package/dist/cjs/post-closebutton_15.cjs.entry.js +34 -0
  32. package/dist/cjs/{post-collapsible-trigger-9dca8493.js → post-collapsible-trigger-0568e3ec.js} +50 -56
  33. package/dist/cjs/post-collapsible_2.cjs.entry.js +10 -6
  34. package/dist/cjs/post-components.cjs.js +2 -2
  35. package/dist/cjs/post-footer-f87a556b.js +88 -0
  36. package/dist/cjs/post-footer.cjs.entry.js +11 -0
  37. package/dist/cjs/post-linkarea-0ccf93fc.js +30 -0
  38. package/dist/cjs/post-linkarea.cjs.entry.js +11 -0
  39. package/dist/cjs/post-menu-item-eba24c40.js +68 -0
  40. package/dist/cjs/post-popover-35f679f6.js +106 -0
  41. package/dist/cjs/post-popover.cjs.entry.js +4 -4
  42. package/dist/cjs/{post-rating-db5a397a.js → post-rating-d12fa214.js} +16 -6
  43. package/dist/cjs/post-rating.cjs.entry.js +3 -3
  44. package/dist/cjs/post-tab-header-89dca04b.js +33 -0
  45. package/dist/cjs/post-tab-header.cjs.entry.js +5 -4
  46. package/dist/cjs/{post-tab-panel-d59cf1ec.js → post-tab-panel-ad1ab180.js} +6 -5
  47. package/dist/cjs/post-tab-panel.cjs.entry.js +4 -3
  48. package/dist/cjs/{post-tabs-7afae61a.js → post-tabs-0db75745.js} +23 -16
  49. package/dist/cjs/post-tabs.cjs.entry.js +4 -4
  50. package/dist/cjs/post-tag-396a46c9.js +47 -0
  51. package/dist/cjs/post-tag.cjs.entry.js +3 -3
  52. package/dist/cjs/post-togglebutton-69983699.js +3861 -0
  53. package/dist/cjs/{post-tooltip-432852c7.js → post-tooltip-7174ea97.js} +38 -25
  54. package/dist/cjs/post-tooltip.cjs.entry.js +8 -6
  55. package/dist/cjs/slide-8ae17ee4.js +28 -0
  56. package/dist/collection/animations/collapse.js +5 -5
  57. package/dist/collection/animations/fade.js +6 -2
  58. package/dist/collection/animations/slide.js +23 -0
  59. package/dist/collection/collection-manifest.json +22 -3
  60. package/dist/collection/components/post-accordion/post-accordion.css +1 -1
  61. package/dist/collection/components/post-accordion/post-accordion.js +5 -3
  62. package/dist/collection/components/post-accordion-item/post-accordion-item.css +1 -1
  63. package/dist/collection/components/post-accordion-item/post-accordion-item.js +29 -11
  64. package/dist/collection/components/post-avatar/post-avatar.css +3 -0
  65. package/dist/collection/components/post-avatar/post-avatar.js +234 -0
  66. package/dist/collection/components/post-back-to-top/post-back-to-top.css +1 -0
  67. package/dist/collection/components/post-back-to-top/post-back-to-top.js +109 -0
  68. package/dist/collection/components/post-banner/banner-types.js +1 -0
  69. package/dist/collection/components/post-banner/post-banner.css +3 -0
  70. package/dist/collection/components/{post-alert/post-alert.js → post-banner/post-banner.js} +51 -73
  71. package/dist/collection/components/post-breadcrumb/post-breadcrumb.css +3 -0
  72. package/dist/collection/components/post-breadcrumb/post-breadcrumb.js +163 -0
  73. package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.css +1 -0
  74. package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.js +98 -0
  75. package/dist/collection/components/post-card-control/post-card-control.css +1 -1
  76. package/dist/collection/components/post-card-control/post-card-control.js +55 -43
  77. package/dist/collection/components/post-closebutton/post-closebutton.js +13 -0
  78. package/dist/collection/components/post-collapsible/post-collapsible.css +1 -1
  79. package/dist/collection/components/post-collapsible/post-collapsible.js +15 -6
  80. package/dist/collection/components/post-collapsible-trigger/post-collapsible-trigger.js +21 -20
  81. package/dist/collection/components/post-footer/post-footer.css +1 -0
  82. package/dist/collection/components/post-footer/post-footer.js +76 -0
  83. package/dist/collection/components/post-header/post-header.css +1 -0
  84. package/dist/collection/components/post-header/post-header.js +267 -0
  85. package/dist/collection/components/post-icon/post-icon.js +80 -47
  86. package/dist/collection/components/post-language-option/post-language-option.css +3 -0
  87. package/dist/collection/components/post-language-option/post-language-option.js +224 -0
  88. package/dist/collection/components/post-language-switch/post-language-switch.css +1 -0
  89. package/dist/collection/components/post-language-switch/post-language-switch.js +164 -0
  90. package/dist/collection/components/post-language-switch/switch-variants.js +1 -0
  91. package/dist/collection/components/post-linkarea/post-linkarea.css +1 -0
  92. package/dist/collection/components/post-linkarea/post-linkarea.js +30 -0
  93. package/dist/collection/components/post-list/post-list.css +3 -0
  94. package/dist/collection/components/post-list/post-list.js +90 -0
  95. package/dist/collection/components/post-list-item/post-list-item.css +1 -0
  96. package/dist/collection/components/post-list-item/post-list-item.js +26 -0
  97. package/dist/collection/components/post-logo/post-logo.css +1 -1
  98. package/dist/collection/components/post-logo/post-logo.js +4 -3
  99. package/dist/collection/components/post-mainnavigation/post-mainnavigation.css +1 -0
  100. package/dist/collection/components/post-mainnavigation/post-mainnavigation.js +255 -0
  101. package/dist/collection/components/post-megadropdown/post-megadropdown.css +1 -0
  102. package/dist/collection/components/post-megadropdown/post-megadropdown.js +268 -0
  103. package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.css +1 -0
  104. package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.js +127 -0
  105. package/dist/collection/components/post-menu/post-menu.css +3 -0
  106. package/dist/collection/components/post-menu/post-menu.js +297 -0
  107. package/dist/collection/components/post-menu-item/post-menu-item.js +8 -0
  108. package/dist/collection/components/post-menu-trigger/post-menu-trigger.css +1 -0
  109. package/dist/collection/components/post-menu-trigger/post-menu-trigger.js +122 -0
  110. package/dist/collection/components/post-popover/post-popover.css +1 -1
  111. package/dist/collection/components/post-popover/post-popover.js +6 -3
  112. package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -1
  113. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +193 -38
  114. package/dist/collection/components/post-rating/post-rating.css +1 -1
  115. package/dist/collection/components/post-rating/post-rating.js +13 -2
  116. package/dist/collection/components/post-tab-header/post-tab-header.css +2 -2
  117. package/dist/collection/components/post-tab-header/post-tab-header.js +6 -4
  118. package/dist/collection/components/post-tab-panel/post-tab-panel.js +4 -2
  119. package/dist/collection/components/post-tabs/post-tabs.css +1 -1
  120. package/dist/collection/components/post-tabs/post-tabs.js +17 -14
  121. package/dist/collection/components/post-tag/post-tag.css +1 -1
  122. package/dist/collection/components/post-tag/post-tag.js +3 -2
  123. package/dist/collection/components/post-togglebutton/post-togglebutton.css +1 -0
  124. package/dist/collection/components/post-togglebutton/post-togglebutton.js +75 -0
  125. package/dist/collection/components/post-tooltip/post-tooltip.css +1 -1
  126. package/dist/collection/components/post-tooltip/post-tooltip.js +35 -17
  127. package/dist/collection/index.js +21 -2
  128. package/dist/collection/utils/attribute-observer.js +4 -4
  129. package/dist/collection/utils/breakpoints.js +50 -0
  130. package/dist/collection/utils/component-on-ready.js +4 -4
  131. package/dist/collection/utils/debounce.js +2 -1
  132. package/dist/collection/utils/get-focusable-children.js +33 -0
  133. package/dist/collection/utils/property-checkers/check-non-empty.js +6 -2
  134. package/dist/collection/utils/property-checkers/check-one-of.js +8 -3
  135. package/dist/collection/utils/property-checkers/check-pattern.js +8 -3
  136. package/dist/collection/utils/property-checkers/check-type.js +11 -6
  137. package/dist/collection/utils/property-checkers/check-url.js +11 -6
  138. package/dist/collection/utils/property-checkers/empty-or.js +5 -2
  139. package/dist/collection/utils/sass-export.js +8 -5
  140. package/dist/components/attribute-observer.js +4 -4
  141. package/dist/components/check-non-empty.js +6 -2
  142. package/dist/components/check-one-of.js +8 -3
  143. package/dist/components/check-type.js +11 -6
  144. package/dist/components/debounce.js +11 -0
  145. package/dist/components/fade.js +6 -2
  146. package/dist/components/get-focusable-children.js +35 -0
  147. package/dist/components/get-root.js +9 -0
  148. package/dist/components/index.browser.js +13 -0
  149. package/dist/components/index.js +21 -2
  150. package/dist/components/index2.js +25 -12
  151. package/dist/components/index3.js +135 -0
  152. package/dist/components/package.js +1 -1
  153. package/dist/components/post-accordion-item2.js +36 -16
  154. package/dist/components/post-accordion2.js +6 -5
  155. package/dist/components/post-avatar.d.ts +11 -0
  156. package/dist/components/post-avatar.js +6 -0
  157. package/dist/components/post-avatar2.js +169 -0
  158. package/dist/components/post-back-to-top.d.ts +11 -0
  159. package/dist/components/post-back-to-top.js +6 -0
  160. package/dist/components/post-back-to-top2.js +101 -0
  161. package/dist/components/post-banner.d.ts +11 -0
  162. package/dist/components/post-banner.js +6 -0
  163. package/dist/components/post-banner2.js +131 -0
  164. package/dist/components/post-breadcrumb-item.d.ts +11 -0
  165. package/dist/components/post-breadcrumb-item.js +6 -0
  166. package/dist/components/post-breadcrumb-item2.js +82 -0
  167. package/dist/components/post-breadcrumb.d.ts +11 -0
  168. package/dist/components/post-breadcrumb.js +6 -0
  169. package/dist/components/post-breadcrumb2.js +169 -0
  170. package/dist/components/post-card-control2.js +50 -39
  171. package/dist/components/post-closebutton.d.ts +11 -0
  172. package/dist/components/post-closebutton.js +6 -0
  173. package/dist/components/post-closebutton2.js +34 -0
  174. package/dist/components/post-collapsible-trigger2.js +23 -38
  175. package/dist/components/post-collapsible2.js +22 -14
  176. package/dist/components/post-footer.d.ts +11 -0
  177. package/dist/components/post-footer.js +6 -0
  178. package/dist/components/post-footer2.js +128 -0
  179. package/dist/components/post-header.d.ts +11 -0
  180. package/dist/components/post-header.js +6 -0
  181. package/dist/components/post-header2.js +217 -0
  182. package/dist/components/post-icon2.js +82 -46
  183. package/dist/components/post-language-option.d.ts +11 -0
  184. package/dist/components/post-language-option.js +6 -0
  185. package/dist/components/post-language-option2.js +102 -0
  186. package/dist/components/post-language-switch.d.ts +11 -0
  187. package/dist/components/post-language-switch.js +6 -0
  188. package/dist/components/post-language-switch2.js +135 -0
  189. package/dist/components/post-linkarea.d.ts +11 -0
  190. package/dist/components/post-linkarea.js +6 -0
  191. package/dist/components/post-linkarea2.js +42 -0
  192. package/dist/components/post-list-item.d.ts +11 -0
  193. package/dist/components/post-list-item.js +6 -0
  194. package/dist/components/post-list-item2.js +35 -0
  195. package/dist/components/{post-alert.d.ts → post-list.d.ts} +4 -4
  196. package/dist/components/post-list.js +6 -0
  197. package/dist/components/post-list2.js +55 -0
  198. package/dist/components/post-logo2.js +5 -5
  199. package/dist/components/post-mainnavigation.d.ts +11 -0
  200. package/dist/components/post-mainnavigation.js +6 -0
  201. package/dist/components/post-mainnavigation2.js +258 -0
  202. package/dist/components/post-megadropdown-trigger.d.ts +11 -0
  203. package/dist/components/post-megadropdown-trigger.js +6 -0
  204. package/dist/components/post-megadropdown-trigger2.js +113 -0
  205. package/dist/components/post-megadropdown.d.ts +11 -0
  206. package/dist/components/post-megadropdown.js +6 -0
  207. package/dist/components/post-megadropdown2.js +186 -0
  208. package/dist/components/post-menu-item.d.ts +11 -0
  209. package/dist/components/post-menu-item.js +6 -0
  210. package/dist/components/post-menu-item2.js +27 -0
  211. package/dist/components/post-menu-trigger.d.ts +11 -0
  212. package/dist/components/post-menu-trigger.js +6 -0
  213. package/dist/components/post-menu-trigger2.js +109 -0
  214. package/dist/components/post-menu.d.ts +11 -0
  215. package/dist/components/post-menu.js +6 -0
  216. package/dist/components/post-menu2.js +193 -0
  217. package/dist/components/post-popover2.js +6 -4
  218. package/dist/components/post-popovercontainer2.js +227 -59
  219. package/dist/components/post-rating2.js +14 -4
  220. package/dist/components/post-tab-header2.js +7 -6
  221. package/dist/components/post-tab-panel2.js +4 -3
  222. package/dist/components/post-tabs2.js +20 -13
  223. package/dist/components/post-tag2.js +3 -3
  224. package/dist/components/post-togglebutton.d.ts +11 -0
  225. package/dist/components/post-togglebutton.js +6 -0
  226. package/dist/components/post-togglebutton2.js +61 -0
  227. package/dist/components/post-tooltip2.js +35 -22
  228. package/dist/components/slide.js +25 -0
  229. package/dist/docs.json +1956 -270
  230. package/dist/esm/{attribute-observer-37fa950a.js → attribute-observer-2f203993.js} +4 -4
  231. package/dist/esm/check-non-empty-258a56b3.js +13 -0
  232. package/dist/esm/check-one-of-0bee20f5.js +11 -0
  233. package/dist/esm/check-type-37d5d307.js +19 -0
  234. package/dist/esm/check-url-17962bc8.js +17 -0
  235. package/dist/esm/debounce-e54c7131.js +11 -0
  236. package/dist/esm/fade-1f3cacf4.js +11 -0
  237. package/dist/esm/get-root-7af2e0d1.js +9 -0
  238. package/dist/esm/{index-0b56fc28.js → index-40846676.js} +54 -17
  239. package/dist/esm/index-8f8fe5b0.js +32 -0
  240. package/dist/esm/index.browser-51485f85.js +13 -0
  241. package/dist/esm/index.js +32 -22
  242. package/dist/esm/loader.js +3 -3
  243. package/dist/esm/package-5614c98b.js +3 -0
  244. package/dist/esm/{post-accordion-6f4d2b9a.js → post-accordion-f6d1834d.js} +9 -8
  245. package/dist/esm/post-accordion-item-7cb93300.js +62 -0
  246. package/dist/esm/post-accordion-item.entry.js +8 -5
  247. package/dist/esm/post-accordion.entry.js +4 -4
  248. package/dist/esm/post-avatar-96108967.js +142 -0
  249. package/dist/esm/post-avatar.entry.js +5 -0
  250. package/dist/esm/post-back-to-top-7f8a61c8.js +74 -0
  251. package/dist/esm/post-back-to-top.entry.js +7 -0
  252. package/dist/esm/post-banner-bb69bce8.js +94 -0
  253. package/dist/esm/post-banner.entry.js +11 -0
  254. package/dist/esm/post-breadcrumb-9d9efa4e.js +110 -0
  255. package/dist/esm/post-breadcrumb-item_2.entry.js +8 -0
  256. package/dist/esm/post-breadcrumb.entry.js +5 -0
  257. package/dist/esm/post-card-control-fdced7d5.js +281 -0
  258. package/dist/esm/post-card-control.entry.js +5 -5
  259. package/dist/esm/post-closebutton_15.entry.js +12 -0
  260. package/dist/esm/{post-collapsible-trigger-85c2064a.js → post-collapsible-trigger-17b2f067.js} +49 -55
  261. package/dist/esm/post-collapsible_2.entry.js +10 -6
  262. package/dist/esm/post-components.js +3 -3
  263. package/dist/esm/post-footer-2dcd8159.js +86 -0
  264. package/dist/esm/post-footer.entry.js +3 -0
  265. package/dist/esm/post-linkarea-06c5144d.js +28 -0
  266. package/dist/esm/post-linkarea.entry.js +3 -0
  267. package/dist/esm/post-menu-item-e917bf99.js +65 -0
  268. package/dist/esm/post-popover-67a3cbf2.js +104 -0
  269. package/dist/esm/post-popover.entry.js +4 -4
  270. package/dist/esm/{post-rating-d9fc0b40.js → post-rating-9613bee8.js} +16 -6
  271. package/dist/esm/post-rating.entry.js +3 -3
  272. package/dist/esm/post-tab-header-dff3a025.js +31 -0
  273. package/dist/esm/post-tab-header.entry.js +5 -4
  274. package/dist/esm/{post-tab-panel-926439f4.js → post-tab-panel-2b3f82a8.js} +6 -5
  275. package/dist/esm/post-tab-panel.entry.js +4 -3
  276. package/dist/esm/{post-tabs-13b2d9a6.js → post-tabs-46d1165f.js} +23 -16
  277. package/dist/esm/post-tabs.entry.js +4 -4
  278. package/dist/esm/post-tag-4176268e.js +45 -0
  279. package/dist/esm/post-tag.entry.js +3 -3
  280. package/dist/esm/post-togglebutton-5892c5bd.js +3845 -0
  281. package/dist/esm/{post-tooltip-3cde6b53.js → post-tooltip-5a45a569.js} +38 -25
  282. package/dist/esm/post-tooltip.entry.js +8 -6
  283. package/dist/esm/slide-62768431.js +25 -0
  284. package/dist/post-components/index.esm.js +1 -1
  285. package/dist/post-components/p-017dc6c7.js +1 -0
  286. package/dist/post-components/p-0227b899.js +1 -0
  287. package/dist/post-components/p-04895a54.js +1 -0
  288. package/dist/post-components/p-04c38bfe.entry.js +1 -0
  289. package/dist/post-components/p-07a0a626.js +1 -0
  290. package/dist/post-components/p-12573893.js +1 -0
  291. package/dist/post-components/p-1289b0a7.entry.js +1 -0
  292. package/dist/post-components/p-12a11565.js +1 -0
  293. package/dist/post-components/p-1542a80e.entry.js +1 -0
  294. package/dist/post-components/p-181c73d5.js +1 -0
  295. package/dist/post-components/p-254a9bd2.entry.js +1 -0
  296. package/dist/post-components/p-28500934.entry.js +1 -0
  297. package/dist/post-components/p-2b1281af.js +1 -0
  298. package/dist/post-components/p-2c69e7f2.entry.js +1 -0
  299. package/dist/post-components/p-30132b19.entry.js +1 -0
  300. package/dist/post-components/p-30af1d48.js +1 -0
  301. package/dist/post-components/p-3bdeb686.entry.js +1 -0
  302. package/dist/post-components/p-47cb31dd.js +1 -0
  303. package/dist/post-components/p-4af6dbed.js +1 -0
  304. package/dist/post-components/p-4f41f63e.js +1 -0
  305. package/dist/post-components/p-52790b8b.js +1 -0
  306. package/dist/post-components/p-5959f2bd.js +1 -0
  307. package/dist/post-components/{p-82dcf8c6.js → p-59ca0a13.js} +3 -3
  308. package/dist/post-components/p-5aaa5703.entry.js +1 -0
  309. package/dist/post-components/p-64e3de38.js +1 -0
  310. package/dist/post-components/p-67a45f16.js +1 -0
  311. package/dist/post-components/p-6d8ac9bd.entry.js +1 -0
  312. package/dist/post-components/p-7709c14a.js +1 -0
  313. package/dist/post-components/p-77cc2a5e.entry.js +1 -0
  314. package/dist/post-components/p-79c552fb.js +1 -0
  315. package/dist/post-components/p-7dd05e6d.entry.js +1 -0
  316. package/dist/post-components/p-803b7598.js +1 -0
  317. package/dist/post-components/p-85fdc2d3.js +1 -0
  318. package/dist/post-components/p-9748a355.js +1 -0
  319. package/dist/post-components/p-98fcf90b.entry.js +1 -0
  320. package/dist/post-components/p-994fae4c.entry.js +1 -0
  321. package/dist/post-components/p-a805515a.entry.js +1 -0
  322. package/dist/post-components/p-b5b48f66.entry.js +1 -0
  323. package/dist/post-components/p-b9bf5a5f.js +1 -0
  324. package/dist/post-components/p-c6b3a926.js +1 -0
  325. package/dist/post-components/p-c9dd3cdb.entry.js +1 -0
  326. package/dist/post-components/p-cb5e4a06.js +1 -0
  327. package/dist/post-components/p-d45df336.js +1 -0
  328. package/dist/post-components/p-dd4a5c0a.entry.js +1 -0
  329. package/dist/post-components/p-e1baac59.js +1 -0
  330. package/dist/post-components/p-e585c6fe.js +1 -0
  331. package/dist/post-components/p-e6d54838.entry.js +1 -0
  332. package/dist/post-components/p-f4b0cc7d.js +1 -0
  333. package/dist/post-components/p-fc91cbc2.js +1 -0
  334. package/dist/post-components/p-fe8c300c.js +1 -0
  335. package/dist/post-components/p-ff95dcd3.js +2 -0
  336. package/dist/post-components/post-components.esm.js +1 -1
  337. package/dist/types/animations/collapse.d.ts +2 -2
  338. package/dist/types/animations/fade.d.ts +2 -2
  339. package/dist/types/animations/slide.d.ts +2 -0
  340. package/dist/types/components/post-accordion-item/post-accordion-item.d.ts +8 -2
  341. package/dist/types/components/post-avatar/post-avatar.d.ts +51 -0
  342. package/dist/types/components/post-back-to-top/post-back-to-top.d.ts +19 -0
  343. package/dist/types/components/post-banner/banner-types.d.ts +2 -0
  344. package/dist/types/components/post-banner/post-banner.d.ts +49 -0
  345. package/dist/types/components/post-breadcrumb/post-breadcrumb.d.ts +30 -0
  346. package/dist/types/components/post-breadcrumb-item/post-breadcrumb-item.d.ts +20 -0
  347. package/dist/types/components/post-card-control/post-card-control.d.ts +9 -9
  348. package/dist/types/components/post-closebutton/post-closebutton.d.ts +7 -0
  349. package/dist/types/components/post-footer/post-footer.d.ts +23 -0
  350. package/dist/types/components/post-header/post-header.d.ts +45 -0
  351. package/dist/types/components/post-icon/post-icon.d.ts +14 -12
  352. package/dist/types/components/post-language-option/post-language-option.d.ts +45 -0
  353. package/dist/types/components/post-language-switch/post-language-switch.d.ts +31 -0
  354. package/dist/types/components/post-language-switch/switch-variants.d.ts +2 -0
  355. package/dist/types/components/post-linkarea/post-linkarea.d.ts +5 -0
  356. package/dist/types/components/post-list/post-list.d.ts +24 -0
  357. package/dist/types/components/post-list-item/post-list-item.d.ts +8 -0
  358. package/dist/types/components/post-logo/post-logo.d.ts +1 -1
  359. package/dist/types/components/post-mainnavigation/post-mainnavigation.d.ts +70 -0
  360. package/dist/types/components/post-megadropdown/post-megadropdown.d.ts +57 -0
  361. package/dist/types/components/post-megadropdown-trigger/post-megadropdown-trigger.d.ts +31 -0
  362. package/dist/types/components/post-menu/post-menu.d.ts +48 -0
  363. package/dist/types/components/post-menu-item/post-menu-item.d.ts +3 -0
  364. package/dist/types/components/post-menu-trigger/post-menu-trigger.d.ts +28 -0
  365. package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +23 -1
  366. package/dist/types/components/post-tab-header/post-tab-header.d.ts +1 -1
  367. package/dist/types/components/post-tabs/post-tabs.d.ts +1 -1
  368. package/dist/types/components/post-tag/post-tag.d.ts +1 -1
  369. package/dist/types/components/post-togglebutton/post-togglebutton.d.ts +15 -0
  370. package/dist/types/components.d.ts +609 -48
  371. package/dist/types/home/runner/work/design-system/design-system/packages/components/.stencil/.config/bindings.angular.d.ts +2 -0
  372. package/dist/types/index.d.ts +22 -3
  373. package/dist/types/utils/attribute-observer.d.ts +1 -1
  374. package/dist/types/utils/breakpoints.d.ts +12 -0
  375. package/dist/types/utils/component-on-ready.d.ts +1 -1
  376. package/dist/types/utils/get-focusable-children.d.ts +1 -0
  377. package/dist/types/utils/get-root.d.ts +1 -1
  378. package/dist/types/utils/property-checkers/check-non-empty.d.ts +3 -1
  379. package/dist/types/utils/property-checkers/check-one-of.d.ts +3 -1
  380. package/dist/types/utils/property-checkers/check-pattern.d.ts +3 -1
  381. package/dist/types/utils/property-checkers/check-type.d.ts +3 -1
  382. package/dist/types/utils/property-checkers/check-url.d.ts +3 -1
  383. package/dist/types/utils/property-checkers/index.d.ts +12 -4
  384. package/dist/types/utils/sass-export.d.ts +5 -1
  385. package/loaders/attribute-observer.js +4 -4
  386. package/loaders/check-non-empty.js +6 -2
  387. package/loaders/check-one-of.js +8 -3
  388. package/loaders/check-type.js +11 -6
  389. package/loaders/debounce.js +11 -0
  390. package/loaders/fade.js +6 -2
  391. package/loaders/get-focusable-children.js +35 -0
  392. package/loaders/get-root.js +9 -0
  393. package/loaders/index.browser.js +13 -0
  394. package/loaders/index.d.ts +40 -2
  395. package/loaders/index.js +21 -2
  396. package/loaders/index2.js +25 -12
  397. package/loaders/index3.js +135 -0
  398. package/loaders/package.js +1 -1
  399. package/loaders/post-accordion-item.js +1 -81
  400. package/loaders/post-accordion-item2.js +103 -0
  401. package/loaders/post-accordion.js +6 -5
  402. package/loaders/post-avatar.d.ts +11 -0
  403. package/loaders/post-avatar.js +172 -0
  404. package/loaders/post-back-to-top.d.ts +11 -0
  405. package/loaders/post-back-to-top.js +104 -0
  406. package/loaders/post-banner.d.ts +11 -0
  407. package/loaders/post-banner.js +134 -0
  408. package/loaders/post-breadcrumb-item.d.ts +11 -0
  409. package/loaders/post-breadcrumb-item.js +6 -0
  410. package/loaders/post-breadcrumb-item2.js +82 -0
  411. package/loaders/post-breadcrumb.d.ts +11 -0
  412. package/loaders/post-breadcrumb.js +172 -0
  413. package/loaders/post-card-control.js +50 -39
  414. package/loaders/post-closebutton.d.ts +11 -0
  415. package/loaders/post-closebutton.js +37 -0
  416. package/loaders/post-collapsible-trigger2.js +23 -38
  417. package/loaders/post-collapsible2.js +21 -13
  418. package/loaders/post-footer.d.ts +11 -0
  419. package/loaders/post-footer.js +131 -0
  420. package/loaders/post-header.d.ts +11 -0
  421. package/loaders/post-header.js +220 -0
  422. package/loaders/post-icon2.js +82 -46
  423. package/loaders/post-language-option.d.ts +11 -0
  424. package/loaders/post-language-option.js +105 -0
  425. package/loaders/post-language-switch.d.ts +11 -0
  426. package/loaders/post-language-switch.js +138 -0
  427. package/loaders/post-linkarea.d.ts +11 -0
  428. package/loaders/post-linkarea.js +45 -0
  429. package/loaders/post-list-item.d.ts +11 -0
  430. package/loaders/post-list-item.js +38 -0
  431. package/loaders/{post-alert.d.ts → post-list.d.ts} +4 -4
  432. package/loaders/post-list.js +58 -0
  433. package/loaders/post-logo.js +6 -6
  434. package/loaders/post-mainnavigation.d.ts +11 -0
  435. package/loaders/post-mainnavigation.js +261 -0
  436. package/loaders/post-megadropdown-trigger.d.ts +11 -0
  437. package/loaders/post-megadropdown-trigger.js +116 -0
  438. package/loaders/post-megadropdown.d.ts +11 -0
  439. package/loaders/post-megadropdown.js +189 -0
  440. package/loaders/post-menu-item.d.ts +11 -0
  441. package/loaders/post-menu-item.js +6 -0
  442. package/loaders/post-menu-item2.js +27 -0
  443. package/loaders/post-menu-trigger.d.ts +11 -0
  444. package/loaders/post-menu-trigger.js +6 -0
  445. package/loaders/post-menu-trigger2.js +109 -0
  446. package/loaders/post-menu.d.ts +11 -0
  447. package/loaders/post-menu.js +6 -0
  448. package/loaders/post-menu2.js +193 -0
  449. package/loaders/post-popover.js +6 -4
  450. package/loaders/post-popovercontainer2.js +227 -59
  451. package/loaders/post-rating.js +14 -4
  452. package/loaders/post-tab-header.js +7 -6
  453. package/loaders/post-tab-panel.js +4 -3
  454. package/loaders/post-tabs.js +20 -13
  455. package/loaders/post-tag.js +3 -3
  456. package/loaders/post-togglebutton.d.ts +11 -0
  457. package/loaders/post-togglebutton.js +64 -0
  458. package/loaders/post-tooltip.js +34 -21
  459. package/loaders/slide.js +25 -0
  460. package/package.json +26 -20
  461. package/dist/cjs/check-non-empty-eeaa8f77.js +0 -11
  462. package/dist/cjs/check-one-of-f4f5d0c0.js +0 -8
  463. package/dist/cjs/fade-35a3633a.js +0 -10
  464. package/dist/cjs/index-01f30442.js +0 -52
  465. package/dist/cjs/post-accordion-item-7b348fa5.js +0 -51
  466. package/dist/cjs/post-alert-fca3a4a3.js +0 -98
  467. package/dist/cjs/post-alert.cjs.entry.js +0 -16
  468. package/dist/cjs/post-card-control-b4e4b4d5.js +0 -272
  469. package/dist/cjs/post-icon-3934be0b.js +0 -104
  470. package/dist/cjs/post-icon.cjs.entry.js +0 -15
  471. package/dist/cjs/post-logo-c3603fc7.js +0 -39
  472. package/dist/cjs/post-logo.cjs.entry.js +0 -14
  473. package/dist/cjs/post-popover-15f9620a.js +0 -104
  474. package/dist/cjs/post-popovercontainer-7d536276.js +0 -2186
  475. package/dist/cjs/post-popovercontainer.cjs.entry.js +0 -11
  476. package/dist/cjs/post-tab-header-29b8d4e1.js +0 -32
  477. package/dist/cjs/post-tag-b7d0bbff.js +0 -47
  478. package/dist/collection/components/post-alert/alert-types.js +0 -1
  479. package/dist/collection/components/post-alert/post-alert.css +0 -7
  480. package/dist/components/post-alert.js +0 -6
  481. package/dist/components/post-alert2.js +0 -136
  482. package/dist/esm/check-non-empty-58bd6b17.js +0 -9
  483. package/dist/esm/check-one-of-6b3ef8eb.js +0 -6
  484. package/dist/esm/fade-7fd71785.js +0 -7
  485. package/dist/esm/index-f41b763f.js +0 -46
  486. package/dist/esm/package-3d758f77.js +0 -3
  487. package/dist/esm/post-accordion-item-6b5a65ad.js +0 -49
  488. package/dist/esm/post-alert-f19db551.js +0 -96
  489. package/dist/esm/post-alert.entry.js +0 -8
  490. package/dist/esm/post-card-control-1b5df6cb.js +0 -270
  491. package/dist/esm/post-icon-40929043.js +0 -102
  492. package/dist/esm/post-icon.entry.js +0 -7
  493. package/dist/esm/post-logo-c6351ba8.js +0 -37
  494. package/dist/esm/post-logo.entry.js +0 -6
  495. package/dist/esm/post-popover-58149de7.js +0 -102
  496. package/dist/esm/post-popovercontainer-8bde9fc3.js +0 -2184
  497. package/dist/esm/post-popovercontainer.entry.js +0 -3
  498. package/dist/esm/post-tab-header-ae8feb19.js +0 -30
  499. package/dist/esm/post-tag-887d5fbe.js +0 -45
  500. package/dist/post-components/p-0b71bf5a.js +0 -1
  501. package/dist/post-components/p-0e09dc41.js +0 -1
  502. package/dist/post-components/p-19e54be9.js +0 -1
  503. package/dist/post-components/p-1e8f0f36.js +0 -1
  504. package/dist/post-components/p-22257eff.entry.js +0 -1
  505. package/dist/post-components/p-249ac168.entry.js +0 -1
  506. package/dist/post-components/p-2737eaf5.js +0 -1
  507. package/dist/post-components/p-2b10e265.js +0 -1
  508. package/dist/post-components/p-3325086e.js +0 -1
  509. package/dist/post-components/p-3b823fee.entry.js +0 -1
  510. package/dist/post-components/p-45f4c803.entry.js +0 -1
  511. package/dist/post-components/p-47935dbb.js +0 -1
  512. package/dist/post-components/p-486fbbce.entry.js +0 -1
  513. package/dist/post-components/p-4a7fb0f3.entry.js +0 -1
  514. package/dist/post-components/p-5f231c2c.js +0 -1
  515. package/dist/post-components/p-611b3c41.js +0 -1
  516. package/dist/post-components/p-6a28f8b9.js +0 -1
  517. package/dist/post-components/p-6adeaa6c.js +0 -1
  518. package/dist/post-components/p-6ed3497a.entry.js +0 -1
  519. package/dist/post-components/p-820c5c19.entry.js +0 -1
  520. package/dist/post-components/p-8aeb549f.entry.js +0 -1
  521. package/dist/post-components/p-92aeec3c.js +0 -1
  522. package/dist/post-components/p-9a99cfc7.js +0 -1
  523. package/dist/post-components/p-aa8a08dc.entry.js +0 -1
  524. package/dist/post-components/p-b095519d.js +0 -1
  525. package/dist/post-components/p-b99fdec3.js +0 -1
  526. package/dist/post-components/p-ba40b28a.entry.js +0 -1
  527. package/dist/post-components/p-c62de925.js +0 -1
  528. package/dist/post-components/p-d2101b8a.entry.js +0 -1
  529. package/dist/post-components/p-d2f9de94.js +0 -2
  530. package/dist/post-components/p-d7a44f45.js +0 -1
  531. package/dist/post-components/p-db4b8ea1.entry.js +0 -1
  532. package/dist/post-components/p-deb4131c.js +0 -1
  533. package/dist/post-components/p-eedc6ae8.entry.js +0 -1
  534. package/dist/post-components/p-f217f420.js +0 -1
  535. package/dist/post-components/p-f707d163.entry.js +0 -1
  536. package/dist/types/components/post-alert/alert-types.d.ts +0 -2
  537. package/dist/types/components/post-alert/post-alert.d.ts +0 -54
  538. package/loaders/post-alert.js +0 -139
@@ -0,0 +1,3861 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-5acef487.js');
4
+ const _package = require('./package-c6bc9e82.js');
5
+ const slide = require('./slide-8ae17ee4.js');
6
+ const index$1 = require('./index-23e36ff7.js');
7
+ const checkNonEmpty = require('./check-non-empty-bd99d236.js');
8
+ const checkType = require('./check-type-cdbf6d29.js');
9
+ const index_browser = require('./index.browser-2f65f583.js');
10
+ const getRoot = require('./get-root-7a3498ef.js');
11
+
12
+ const PostClosebutton = class {
13
+ constructor(hostRef) {
14
+ index.registerInstance(this, hostRef);
15
+ }
16
+ get host() { return index.getElement(this); }
17
+ render() {
18
+ return (index.h(index.Host, { key: 'c03f50379252ba13992bc3d021989ac07dba9f79', "data-version": _package.version }, index.h("button", { key: 'e97a86bb6e1eace89a1a3a78fb231047f065dd5e', class: "btn btn-icon-close", type: "button" }, index.h("post-icon", { key: 'aca522d4c251a8183c91c2bd4d810d0716a2fe13', "aria-hidden": "true", name: "closex" }), index.h("span", { key: '6873522961b1683d1261163b07ee022f93eed836', class: "visually-hidden" }, index.h("slot", { key: 'bf4b13356c9a0164f1481d1fedc3a78a53e5f8e0' })))));
19
+ }
20
+ };
21
+
22
+ /* eslint-disable no-undefined,no-param-reassign,no-shadow */
23
+
24
+ /**
25
+ * Throttle execution of a function. Especially useful for rate limiting
26
+ * execution of handlers on events like resize and scroll.
27
+ *
28
+ * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
29
+ * are most useful.
30
+ * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
31
+ * as-is, to `callback` when the throttled-function is executed.
32
+ * @param {object} [options] - An object to configure options.
33
+ * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
34
+ * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
35
+ * one final time after the last throttled-function call. (After the throttled-function has not been called for
36
+ * `delay` milliseconds, the internal counter is reset).
37
+ * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
38
+ * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
39
+ * callback will never executed if both noLeading = true and noTrailing = true.
40
+ * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
41
+ * false (at end), schedule `callback` to execute after `delay` ms.
42
+ *
43
+ * @returns {Function} A new, throttled, function.
44
+ */
45
+ function throttle (delay, callback, options) {
46
+ var _ref = options || {},
47
+ _ref$noTrailing = _ref.noTrailing,
48
+ noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing,
49
+ _ref$noLeading = _ref.noLeading,
50
+ noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading,
51
+ _ref$debounceMode = _ref.debounceMode,
52
+ debounceMode = _ref$debounceMode === void 0 ? undefined : _ref$debounceMode;
53
+ /*
54
+ * After wrapper has stopped being called, this timeout ensures that
55
+ * `callback` is executed at the proper times in `throttle` and `end`
56
+ * debounce modes.
57
+ */
58
+ var timeoutID;
59
+ var cancelled = false;
60
+
61
+ // Keep track of the last time `callback` was executed.
62
+ var lastExec = 0;
63
+
64
+ // Function to clear existing timeout
65
+ function clearExistingTimeout() {
66
+ if (timeoutID) {
67
+ clearTimeout(timeoutID);
68
+ }
69
+ }
70
+
71
+ // Function to cancel next exec
72
+ function cancel(options) {
73
+ var _ref2 = options || {},
74
+ _ref2$upcomingOnly = _ref2.upcomingOnly,
75
+ upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;
76
+ clearExistingTimeout();
77
+ cancelled = !upcomingOnly;
78
+ }
79
+
80
+ /*
81
+ * The `wrapper` function encapsulates all of the throttling / debouncing
82
+ * functionality and when executed will limit the rate at which `callback`
83
+ * is executed.
84
+ */
85
+ function wrapper() {
86
+ for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {
87
+ arguments_[_key] = arguments[_key];
88
+ }
89
+ var self = this;
90
+ var elapsed = Date.now() - lastExec;
91
+ if (cancelled) {
92
+ return;
93
+ }
94
+
95
+ // Execute `callback` and update the `lastExec` timestamp.
96
+ function exec() {
97
+ lastExec = Date.now();
98
+ callback.apply(self, arguments_);
99
+ }
100
+
101
+ /*
102
+ * If `debounceMode` is true (at begin) this is used to clear the flag
103
+ * to allow future `callback` executions.
104
+ */
105
+ function clear() {
106
+ timeoutID = undefined;
107
+ }
108
+ if (!noLeading && debounceMode && !timeoutID) {
109
+ /*
110
+ * Since `wrapper` is being called for the first time and
111
+ * `debounceMode` is true (at begin), execute `callback`
112
+ * and noLeading != true.
113
+ */
114
+ exec();
115
+ }
116
+ clearExistingTimeout();
117
+ if (debounceMode === undefined && elapsed > delay) {
118
+ if (noLeading) {
119
+ /*
120
+ * In throttle mode with noLeading, if `delay` time has
121
+ * been exceeded, update `lastExec` and schedule `callback`
122
+ * to execute after `delay` ms.
123
+ */
124
+ lastExec = Date.now();
125
+ if (!noTrailing) {
126
+ timeoutID = setTimeout(debounceMode ? clear : exec, delay);
127
+ }
128
+ } else {
129
+ /*
130
+ * In throttle mode without noLeading, if `delay` time has been exceeded, execute
131
+ * `callback`.
132
+ */
133
+ exec();
134
+ }
135
+ } else if (noTrailing !== true) {
136
+ /*
137
+ * In trailing throttle mode, since `delay` time has not been
138
+ * exceeded, schedule `callback` to execute `delay` ms after most
139
+ * recent execution.
140
+ *
141
+ * If `debounceMode` is true (at begin), schedule `clear` to execute
142
+ * after `delay` ms.
143
+ *
144
+ * If `debounceMode` is false (at end), schedule `callback` to
145
+ * execute after `delay` ms.
146
+ */
147
+ timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
148
+ }
149
+ }
150
+ wrapper.cancel = cancel;
151
+
152
+ // Return the wrapper function.
153
+ return wrapper;
154
+ }
155
+
156
+ const focusableSelector = `:where(${[
157
+ 'button',
158
+ 'input:not([type="hidden"])',
159
+ '[tabindex]',
160
+ 'select',
161
+ 'textarea',
162
+ '[contenteditable]',
163
+ 'a[href]',
164
+ 'iframe',
165
+ 'audio[controls]',
166
+ 'video[controls]',
167
+ 'area[href]',
168
+ 'details > summary:first-of-type',
169
+ ].join(',')})`;
170
+ const focusDisablingSelector = `:where(${[
171
+ '[inert]',
172
+ '[inert] *',
173
+ ':disabled',
174
+ 'dialog:not([open]) *',
175
+ '[popover]:not(:popover-open) *',
176
+ 'details:not([open]) > *:not(details > summary:first-of-type)',
177
+ 'details:not([open]) > *:not(details > summary:first-of-type) *',
178
+ '[tabindex^="-"]',
179
+ '[hidden]:not([hidden="false"])',
180
+ ].join(',')})`;
181
+ function getFocusableChildren(element) {
182
+ const focusableChildren = element.querySelectorAll(`${focusableSelector}:not(${focusDisablingSelector})`);
183
+ const visibleFocusableChildren = Array.from(focusableChildren).filter(child => {
184
+ const style = window.getComputedStyle(child.parentElement);
185
+ return style.display !== 'none' && style.visibility !== 'hidden';
186
+ });
187
+ return visibleFocusableChildren;
188
+ }
189
+
190
+ const postHeaderCss = "*,::before,::after{box-sizing:border-box}:host{z-index:1020;position:relative}: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(--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:calc((var(--global-header-height) - var(--global-header-reduced-height))*-1)}}.global-sub{display:flex;align-items:center;gap:24px}.align-end{align-items:flex-end}.logo{flex:1 0 auto;height:var(--global-header-height);width:var(--global-header-height);min-height:var(--global-header-reduced-height);align-self:flex-end}@media screen and (min-width: 1024px){.logo{height:calc(var(--global-header-height) - var(--header-scroll-top))}}::slotted(ul){margin-block:0 !important;list-style:none;display:flex;padding-left: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(--local-header-min-height);background:#fff;transition:box-shadow .2s ease-in-out;border-block-end:1px solid #e1e0dc}@media screen and (min-width: 1024px){.local-header{z-index:3;inset-block-start:calc(-1*(var(--local-header-height) - var(--main-navigation-height)) + var(--global-header-reduced-height));padding-block-start:18px;box-shadow:var(--post-device-elevation-300)}}@media screen and (max-width: 1023.98px){.local-header{z-index:2;inset-block-start:var(--global-header-height);padding-block:12px;flex-wrap:wrap;gap:16px}.local-header.local-header-mobile-extended{border-bottom:1px solid #e1e0dc}.local-header:not(.local-header-mobile-extended){box-shadow:var(--post-device-elevation-300)}}.local-sub{margin-inline-end:16px}::slotted(.list-inline){margin:0 !important;z-index:3 !important;position:relative !important}::slotted(h1){margin:0 !important;flex-shrink:10;z-index:3}@media screen and (min-width: 600px){::slotted(h1){margin-inline-start:12px !important}}@media screen and (max-width: 599.98px){::slotted(h1){margin-inline-start:8px !important}}@media screen and (min-width: 1024px){::slotted(h1){font-size:28px !important}}@media screen and (max-width: 1023.98px){::slotted(h1){font-size:20px !important;max-width:calc(100vw - 8px - 16px)}}@media screen and (min-width: 1024px){.mobile-toggle{display:none}}.navigation{width:100%}@media screen and (min-width: 1024px){.navigation{inset-block-start:var(--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:fixed;z-index:1;inset-inline:0;background:#fff;inset-block-end:calc(100dvh - var(--header-height))}::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{height:calc(100dvh - var(--header-height));display:flex;flex-direction:column}.navigation.extended ::slotted(post-mainnavigation){flex-grow:1 !important}::slotted(post-mainnavigation){background-color:#fafafa;gap:32px}.navigation-footer{background-color:#f0efed;gap:24px}}@media screen and (max-width: 599.98px){::slotted(post-mainnavigation),.navigation-footer{padding-inline:16px}}";
191
+ const PostHeaderStyle0 = postHeaderCss;
192
+
193
+ const PostHeader = class {
194
+ constructor(hostRef) {
195
+ index.registerInstance(this, hostRef);
196
+ this.postUpdateDevice = index.createEvent(this, "postUpdateDevice", 7);
197
+ this.device = null;
198
+ this.mobileMenuExtended = false;
199
+ }
200
+ firstFocusableEl;
201
+ lastFocusableEl;
202
+ scrollParent = null;
203
+ mobileMenu;
204
+ mobileMenuAnimation;
205
+ throttledScroll = () => this.handleScrollEvent();
206
+ throttledResize = throttle(50, () => this.handleResize());
207
+ componentWillRender() {
208
+ this.scrollParent = this.getScrollParent(this.host);
209
+ this.scrollParent.addEventListener('scroll', this.throttledScroll, { passive: true });
210
+ window.addEventListener('resize', this.throttledResize, { passive: true });
211
+ this.handleResize();
212
+ this.handleScrollEvent();
213
+ this.getFocusableElements();
214
+ }
215
+ componentDidLoad() {
216
+ this.updateLocalHeaderHeight();
217
+ }
218
+ // Clean up possible side effects when post-header is disconnected
219
+ disconnectedCallback() {
220
+ this.mobileMenuExtended = false;
221
+ document.body.style.overflow = '';
222
+ this.host.removeEventListener('keydown', e => {
223
+ this.keyboardHandler(e);
224
+ });
225
+ }
226
+ get host() { return index.getElement(this); }
227
+ frozeBody(isMobileMenuExtended) {
228
+ document.body.style.overflow = isMobileMenuExtended ? 'hidden' : '';
229
+ if (isMobileMenuExtended) {
230
+ this.host.addEventListener('keydown', e => {
231
+ this.keyboardHandler(e);
232
+ });
233
+ }
234
+ else {
235
+ this.host.removeEventListener('keydown', e => {
236
+ this.keyboardHandler(e);
237
+ });
238
+ }
239
+ }
240
+ /**
241
+ * An event emitted when the device has changed
242
+ */
243
+ postUpdateDevice;
244
+ /**
245
+ * Toggles the mobile navigation.
246
+ */
247
+ async toggleMobileMenu() {
248
+ if (this.device === 'desktop')
249
+ return;
250
+ this.mobileMenuAnimation = this.mobileMenuExtended
251
+ ? slide.slideUp(this.mobileMenu)
252
+ : slide.slideDown(this.mobileMenu);
253
+ // Update the state of the toggle button
254
+ const menuButton = this.host.querySelector('post-togglebutton');
255
+ menuButton.toggled = !this.mobileMenuExtended;
256
+ // Toggle menu visibility before it slides down and after it slides back up
257
+ if (this.mobileMenuExtended)
258
+ await this.mobileMenuAnimation.finished;
259
+ this.mobileMenuExtended = !this.mobileMenuExtended;
260
+ if (!this.mobileMenuExtended)
261
+ await this.mobileMenuAnimation.finished;
262
+ }
263
+ // Get all the focusable elements in the post-header mobile menu
264
+ getFocusableElements() {
265
+ // Get elements in the correct order (different as the DOM order)
266
+ const focusableEls = [
267
+ ...Array.from(this.host.querySelectorAll('.list-inline:not([slot="meta-navigation"]) > li')),
268
+ ...Array.from(this.host.querySelectorAll('nav > post-list > div > post-list-item, post-mainnavigation > .back-button, post-megadropdown-trigger')),
269
+ ...Array.from(this.host.querySelectorAll('.list-inline[slot="meta-navigation"] > li, post-language-option')),
270
+ ];
271
+ // Add the main toggle menu button to the list of focusable children
272
+ const focusableChildren = [
273
+ this.host.querySelector('post-togglebutton'),
274
+ ...focusableEls.flatMap(el => Array.from(getFocusableChildren(el))),
275
+ ];
276
+ this.firstFocusableEl = focusableChildren[0];
277
+ this.lastFocusableEl = focusableChildren[focusableChildren.length - 1];
278
+ }
279
+ keyboardHandler(e) {
280
+ if (e.key === 'Tab' && this.mobileMenuExtended) {
281
+ if (e.shiftKey && document.activeElement === this.firstFocusableEl) {
282
+ // If back tab (Tab + Shift) and first element is focused, focus goes to the last element of the megadropdown
283
+ e.preventDefault();
284
+ this.lastFocusableEl.focus();
285
+ }
286
+ else if (!e.shiftKey && document.activeElement === this.lastFocusableEl) {
287
+ // If Tab and last element is focused, focus goes back to the first element of the megadropdown
288
+ e.preventDefault();
289
+ this.firstFocusableEl.focus();
290
+ }
291
+ }
292
+ }
293
+ handleScrollEvent() {
294
+ // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
295
+ const st = Math.max(0, this.scrollParent instanceof Document
296
+ ? this.scrollParent.documentElement.scrollTop
297
+ : this.scrollParent.scrollTop);
298
+ this.host.style.setProperty('--header-scroll-top', `${st}px`);
299
+ }
300
+ getScrollParent(node) {
301
+ let currentParent = node.parentElement;
302
+ while (currentParent) {
303
+ if (currentParent.nodeName === 'BODY') {
304
+ return document;
305
+ }
306
+ if (this.isScrollable(currentParent)) {
307
+ return currentParent;
308
+ }
309
+ currentParent = currentParent.parentElement;
310
+ }
311
+ return document;
312
+ }
313
+ isScrollable(node) {
314
+ if (!(node instanceof HTMLElement || node instanceof SVGElement)) {
315
+ return false;
316
+ }
317
+ const style = getComputedStyle(node);
318
+ return ['overflow', 'overflow-x', 'overflow-y'].some(propertyName => {
319
+ const value = style.getPropertyValue(propertyName);
320
+ return value === 'auto' || value === 'scroll';
321
+ });
322
+ }
323
+ updateLocalHeaderHeight() {
324
+ requestAnimationFrame(() => {
325
+ const mhh = this.host.shadowRoot.querySelector('.local-header')?.clientHeight || 0;
326
+ this.host.style.setProperty('--local-header-height', `${mhh}px`);
327
+ });
328
+ }
329
+ handleResize() {
330
+ const previousDevice = this.device;
331
+ let newDevice;
332
+ const width = window?.innerWidth;
333
+ if (width >= 1024) {
334
+ newDevice = 'desktop';
335
+ }
336
+ else if (width >= 600) {
337
+ newDevice = 'tablet';
338
+ }
339
+ else {
340
+ newDevice = 'mobile';
341
+ }
342
+ // Close any open mobile menu
343
+ if (newDevice === 'desktop' && this.mobileMenuExtended) {
344
+ this.toggleMobileMenu();
345
+ this.mobileMenuAnimation.finish(); // no animation
346
+ }
347
+ this.updateLocalHeaderHeight();
348
+ // Apply only on change for doing work only when necessary
349
+ if (newDevice !== previousDevice) {
350
+ this.device = newDevice;
351
+ this.postUpdateDevice.emit(this.device);
352
+ window.requestAnimationFrame(() => {
353
+ this.switchLanguageSwitchMode();
354
+ });
355
+ }
356
+ }
357
+ switchLanguageSwitchMode() {
358
+ const variant = this.device === 'desktop' ? 'menu' : 'list';
359
+ Array.from(this.host.querySelectorAll('post-language-switch')).forEach(languageSwitch => {
360
+ languageSwitch?.setAttribute('variant', variant);
361
+ });
362
+ }
363
+ renderNavigation() {
364
+ const navigationClasses = ['navigation'];
365
+ if (this.mobileMenuExtended) {
366
+ navigationClasses.push('extended');
367
+ }
368
+ return (index.h("div", { ref: el => (this.mobileMenu = el), class: navigationClasses.join(' ') }, 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" })))));
369
+ }
370
+ render() {
371
+ return (index.h(index.Host, { key: '45452d2c2f6ac9a067ce71330ea898a797040cca', version: _package.version }, index.h("div", { key: 'c50478141de45d0a718b18c0edc416eb9c832fde', class: "global-header" }, index.h("div", { key: 'a2ddc2de9a94fb3b16928fe9c1ac3b3ae61ff9bf', class: "global-sub" }, index.h("div", { key: '30083683ff7683202118471473f2a0ed98a1c920', class: "logo" }, index.h("slot", { key: '028bd4a8f03a228378b09a80dce8654d52c30e5c', name: "post-logo" }))), index.h("div", { key: '853bcf2e6c8a95d88f62795cef8d8e58c8996811', class: "global-sub" }, this.device === 'desktop' && index.h("slot", { key: '40e3027a4e4358b7a614558ed7e1f59fa65ed312', name: "meta-navigation" }), index.h("slot", { key: '31c141cc45aa12441557d9b817630328df3d3778', name: "global-controls" }), this.device === 'desktop' && index.h("slot", { key: 'afe4b2c3123a89c1a4390578c22e89dfff7be655', name: "post-language-switch" }), index.h("div", { key: 'aea74d0c7f25288afa18b5aeb3e557216d695ec3', onClick: () => this.toggleMobileMenu(), class: "mobile-toggle" }, index.h("slot", { key: '1efed8b7c823ef49b89120ed2e23f151c64b9c0e', name: "post-togglebutton" })))), index.h("div", { key: 'e09df2136d01c0516d0166f505055615cf1d70d3', class: 'local-header ' + (this.mobileMenuExtended ? 'local-header-mobile-extended' : '') }, index.h("slot", { key: '491f9bbcb2743519f544b24ae6f00405be85e589', name: "title" }), index.h("div", { key: 'e85c0a76597832a6966e989111b4508579fb9c4d', class: "local-sub" }, index.h("slot", { key: 'f2d504ea6a3d7592a15551e6be8cb0c1ba220fbc', name: "local-controls" }), index.h("slot", { key: 'e0dd0f9c12e0c6bf5d5d66cb29139af59f7c0b4d' })), this.device === 'desktop' && this.renderNavigation()), this.device !== 'desktop' && this.renderNavigation()));
372
+ }
373
+ static get watchers() { return {
374
+ "mobileMenuExtended": ["frozeBody"]
375
+ }; }
376
+ };
377
+ PostHeader.style = PostHeaderStyle0;
378
+
379
+ 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)}}";
380
+ const PostIconStyle0 = postIconCss;
381
+
382
+ const CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons/';
383
+ const ANIMATION_NAMES = [
384
+ 'cylon',
385
+ 'cylon-vertical',
386
+ 'spin',
387
+ 'spin-reverse',
388
+ 'fade',
389
+ 'throb',
390
+ ];
391
+ const ANIMATION_KEYS = [...ANIMATION_NAMES];
392
+ const PostIcon = class {
393
+ constructor(hostRef) {
394
+ index.registerInstance(this, hostRef);
395
+ this.animation = null;
396
+ this.base = null;
397
+ this.flipH = false;
398
+ this.flipV = false;
399
+ this.name = undefined;
400
+ this.rotate = null;
401
+ this.scale = null;
402
+ }
403
+ isSSR = typeof window === 'undefined';
404
+ get host() { return index.getElement(this); }
405
+ validateAnimation(newValue = this.animation) {
406
+ if (newValue !== undefined)
407
+ index$1.checkEmptyOrOneOf(this, 'animation', ANIMATION_KEYS);
408
+ }
409
+ validateBase() {
410
+ index$1.checkEmptyOrType(this, 'base', 'string');
411
+ }
412
+ validateFlipH() {
413
+ index$1.checkEmptyOrType(this, 'flipH', 'boolean');
414
+ }
415
+ validateFlipV() {
416
+ index$1.checkEmptyOrType(this, 'flipV', 'boolean');
417
+ }
418
+ validateName() {
419
+ checkNonEmpty.checkNonEmpty(this, 'name');
420
+ checkType.checkType(this, 'name', 'string');
421
+ }
422
+ validateRotate() {
423
+ index$1.checkEmptyOrType(this, 'rotate', 'number');
424
+ }
425
+ validateScale() {
426
+ index$1.checkEmptyOrType(this, 'scale', 'number');
427
+ }
428
+ // Construct the icon url from different possible sources
429
+ getUrl() {
430
+ let url;
431
+ const file = `${this.name}.svg`;
432
+ // the first definition object which defines a domain, will be used to set the domain of the file url
433
+ // the first definition object which defines a slug, will be used to set the slug of the file url
434
+ const urlDefinitions = [this.getUrlDefinition(this.base, 'both')];
435
+ if (!this.isSSR) {
436
+ urlDefinitions.push(this.getUrlDefinition(document.head
437
+ .querySelector('meta[name="design-system-settings"][data-post-icon-base]')
438
+ ?.getAttribute('data-post-icon-base'), 'relative'));
439
+ urlDefinitions.push(this.getUrlDefinition(document.querySelector('base[href]')?.getAttribute('href'), 'both'));
440
+ }
441
+ // in case no definition defines a domain, a relative url is used to load the icon
442
+ const origin = urlDefinitions.find(d => d.definesDomain)?.url?.origin;
443
+ // in case no definition defines a slug either, the cdn url is used as a fallback
444
+ const slug = urlDefinitions.find(d => d.definesSlug)?.url?.pathname;
445
+ if (origin && slug) {
446
+ url = `${origin}${slug}${file}`;
447
+ }
448
+ else if (!origin && slug) {
449
+ url = `${slug}${file}`;
450
+ }
451
+ else {
452
+ url = `${CDN_URL}${file}`;
453
+ }
454
+ return url;
455
+ }
456
+ getUrlDefinition(url, allow) {
457
+ return {
458
+ url: this.getUrlObject(url),
459
+ definesDomain: allow !== 'relative' ? this.definesDomain(url) : false,
460
+ definesSlug: allow !== 'absolute' ? this.definesSlug(url) : false,
461
+ };
462
+ }
463
+ getUrlObject(url) {
464
+ if (url) {
465
+ url = url?.endsWith('/') ? url : `${url}/`;
466
+ return new URL(url, 'https://url.base');
467
+ }
468
+ else {
469
+ return null;
470
+ }
471
+ }
472
+ definesDomain(url) {
473
+ return url ? /^https?:\/\//.test(url) : false;
474
+ }
475
+ definesSlug(url) {
476
+ return Boolean(/^\/.+/.test(this.getUrlObject(url)?.pathname));
477
+ }
478
+ getStyles() {
479
+ const url = this.getUrl();
480
+ return Object.entries({
481
+ '-webkit-mask-image': `url(${url})`,
482
+ 'mask-image': `url('${url}')`,
483
+ 'transform': (this.scale && !isNaN(Number(this.scale)) ? 'scale(' + this.scale + ')' : '') +
484
+ (this.rotate && !isNaN(Number(this.rotate)) ? ' rotate(' + this.rotate + 'deg)' : ''),
485
+ })
486
+ .filter(([_key, value]) => value !== null)
487
+ .reduce((styles, [key, value]) => Object.assign(styles, { [key]: value }), {});
488
+ }
489
+ componentDidLoad() {
490
+ this.validateBase();
491
+ this.validateName();
492
+ this.validateFlipH();
493
+ this.validateFlipV();
494
+ this.validateScale();
495
+ this.validateRotate();
496
+ this.validateAnimation();
497
+ }
498
+ render() {
499
+ return (index.h(index.Host, { key: 'c80aaf693f730902c4ae57ca78360eee5dedf624', "data-version": _package.version }, index.h("span", { key: '7e01e1cf7e4fec380e8f054d3cc8fa5404c7a829', style: this.getStyles() })));
500
+ }
501
+ static get watchers() { return {
502
+ "animation": ["validateAnimation"],
503
+ "base": ["validateBase"],
504
+ "flipH": ["validateFlipH"],
505
+ "flipV": ["validateFlipV"],
506
+ "name": ["validateName"],
507
+ "rotate": ["validateRotate"],
508
+ "scale": ["validateScale"]
509
+ }; }
510
+ };
511
+ PostIcon.style = PostIconStyle0;
512
+
513
+ const postLanguageOptionCss = "/*!\n * Copyright 2021 by Swiss Post, Information Technology\n */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:inherit;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}post-language-option:where([variant=list]):not([active=false]) :is(a,button){background-color:#050400 !important;color:#fff;pointer-events:none}post-language-option:where([variant=list]):not([active=false]) :hover{color:#fff}post-language-option:where([variant=menu]){width:100%}post-language-option:where([variant=menu]):not([active=false]){display:none}post-language-option:where([variant=menu]) :is(a,button){padding-block:13px;padding-inline:24px;box-sizing:border-box;position:relative;width:100%}post-language-option:where([variant=menu]) :is(a,button):hover{color:#fff;background-color:#504f4b}";
514
+ const PostLanguageOptionStyle0 = postLanguageOptionCss;
515
+
516
+ const PostLanguageOption = class {
517
+ constructor(hostRef) {
518
+ index.registerInstance(this, hostRef);
519
+ this.postChange = index.createEvent(this, "postChange", 7);
520
+ this.code = undefined;
521
+ this.active = undefined;
522
+ this.variant = undefined;
523
+ this.name = undefined;
524
+ this.url = undefined;
525
+ }
526
+ get host() { return index.getElement(this); }
527
+ validateCode() {
528
+ checkType.checkType(this, 'code', 'string');
529
+ }
530
+ validateActiveProp() {
531
+ index$1.checkEmptyOrType(this, 'active', 'boolean');
532
+ }
533
+ validateName() {
534
+ index$1.checkEmptyOrType(this, 'name', 'string');
535
+ }
536
+ validateUrl() {
537
+ index$1.checkEmptyOrType(this, 'url', 'string');
538
+ }
539
+ componentDidLoad() {
540
+ this.validateCode();
541
+ this.validateActiveProp();
542
+ this.validateName();
543
+ this.validateUrl();
544
+ if (!this.name && this.isNameRequired()) {
545
+ throw new Error('The "name" property of the post-language-option component is required when the full language name is not displayed.');
546
+ }
547
+ }
548
+ /**
549
+ * An event emitted when the language option is clicked. The payload is the ISO 639 code of the language.
550
+ */
551
+ postChange;
552
+ /**
553
+ * Selects the language option programmatically.
554
+ */
555
+ async select() {
556
+ this.active = true;
557
+ this.emitChange();
558
+ }
559
+ emitChange() {
560
+ this.postChange.emit(this.code);
561
+ }
562
+ isNameRequired() {
563
+ return this.host.textContent.toLowerCase() === this.code.toLowerCase();
564
+ }
565
+ render() {
566
+ const lang = this.code.toLowerCase();
567
+ const emitOnKeyDown = (e) => {
568
+ if (e.key === 'Enter' || e.key === ' ') {
569
+ this.emitChange();
570
+ }
571
+ };
572
+ return (index.h(index.Host, { key: 'f987cfc18bb86866781e0668516e86f89be6241b', "data-version": _package.version, role: this.variant ? `${this.variant}item` : null }, 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)))));
573
+ }
574
+ static get watchers() { return {
575
+ "code": ["validateCode"],
576
+ "active": ["validateActiveProp"],
577
+ "name": ["validateName"],
578
+ "url": ["validateUrl"]
579
+ }; }
580
+ };
581
+ PostLanguageOption.style = PostLanguageOptionStyle0;
582
+
583
+ const SWITCH_VARIANTS = ['list', 'menu'];
584
+
585
+ const postLanguageSwitchCss = ":host{display:flex !important;flex-wrap:wrap;gap:.5rem}.post-language-switch-dropdown-container{display:flex;flex-direction:column}.post-language-switch-dropdown-container>*{width:100%}.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:16px;width:16px}.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}";
586
+ const PostLanguageSwitchStyle0 = postLanguageSwitchCss;
587
+
588
+ const PostLanguageSwitch = class {
589
+ constructor(hostRef) {
590
+ index.registerInstance(this, hostRef);
591
+ this.caption = undefined;
592
+ this.description = undefined;
593
+ this.variant = 'list';
594
+ this.activeLang = undefined;
595
+ }
596
+ get host() { return index.getElement(this); }
597
+ validateCaption() {
598
+ checkType.checkType(this, 'caption', 'string');
599
+ }
600
+ validateDescription() {
601
+ checkType.checkType(this, 'description', 'string');
602
+ }
603
+ validateVariant() {
604
+ index$1.checkEmptyOrOneOf(this, 'variant', SWITCH_VARIANTS);
605
+ }
606
+ connectedCallback() {
607
+ this.updateChildrenVariant();
608
+ // Get the active language based on children's active state
609
+ const activeLanguageOption = this.host.querySelector('post-language-option[active]:not([active="false"])');
610
+ if (activeLanguageOption)
611
+ this.activeLang = activeLanguageOption.getAttribute('code');
612
+ }
613
+ // Update post-language-option variant to have the correct style
614
+ updateChildrenVariant() {
615
+ this.host.querySelectorAll('post-language-option').forEach(el => {
616
+ el.setAttribute('variant', this.variant);
617
+ });
618
+ }
619
+ componentWillUpdate() {
620
+ this.updateChildrenVariant();
621
+ }
622
+ componentDidLoad() {
623
+ this.validateCaption();
624
+ this.validateDescription();
625
+ this.validateVariant();
626
+ // Detects a change in the active language
627
+ this.host.addEventListener('postChange', (el) => {
628
+ this.activeLang = el.detail;
629
+ // Update the active state in the children post-language-option components
630
+ this.host.querySelectorAll('post-language-option').forEach(lang => {
631
+ if (lang.code && lang.code === this.activeLang) {
632
+ lang.setAttribute('active', 'true');
633
+ }
634
+ else {
635
+ lang.setAttribute('active', 'false');
636
+ }
637
+ });
638
+ // Hides the dropdown when an option has been clicked
639
+ if (this.variant === 'menu') {
640
+ const menu = this.host.shadowRoot.querySelector('post-menu');
641
+ menu.toggle(menu);
642
+ }
643
+ });
644
+ }
645
+ menuId = `p${index_browser.nanoid(11)}`;
646
+ renderList() {
647
+ 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))));
648
+ }
649
+ renderDropdown() {
650
+ 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))));
651
+ }
652
+ render() {
653
+ return this.variant === 'list' ? this.renderList() : this.renderDropdown();
654
+ }
655
+ static get watchers() { return {
656
+ "caption": ["validateCaption"],
657
+ "description": ["validateDescription"],
658
+ "variant": ["validateVariant"]
659
+ }; }
660
+ };
661
+ PostLanguageSwitch.style = PostLanguageSwitchStyle0;
662
+
663
+ const postListCss = "/*!\n * Copyright 2021 by Swiss Post, Information Technology\n */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}";
664
+ const PostListStyle0 = postListCss;
665
+
666
+ const PostList = class {
667
+ constructor(hostRef) {
668
+ index.registerInstance(this, hostRef);
669
+ this.titleId = undefined;
670
+ this.titleHidden = false;
671
+ this.horizontal = false;
672
+ }
673
+ get host() { return index.getElement(this); }
674
+ titleEl;
675
+ componentWillLoad() {
676
+ /**
677
+ * Get the id set on the host element or use a random id by default
678
+ */
679
+ this.titleId = `title-${this.host.id || index_browser.nanoid(6)}`;
680
+ }
681
+ componentDidLoad() {
682
+ this.checkTitle();
683
+ }
684
+ checkTitle() {
685
+ if (!this.titleEl.textContent.trim()) {
686
+ console.error('Please provide a title to the list component. Title is mandatory for accessibility purposes.');
687
+ }
688
+ }
689
+ render() {
690
+ return (index.h(index.Host, { key: '085a63d7b4cc85461f2c8fd0c7b9d9f48f42055a', "data-version": _package.version }, index.h("div", { key: 'd13a66ba16b71eff1a86666b04ca2f41957962e1', ref: el => (this.titleEl = el), id: this.titleId, class: `list-title${this.titleHidden ? ' visually-hidden' : ''}` }, index.h("slot", { key: '0270bcd71c8a3a34390b98b6374a1a2f06e0d606' })), index.h("div", { key: 'de04b08bf94900435c53f972c8fcd0798c8a5faf', role: "list", "aria-labelledby": this.titleId }, index.h("slot", { key: 'f7aa9976b3283ee4da3d32d84b36e2549c29e80f', name: "post-list-item" }))));
691
+ }
692
+ };
693
+ PostList.style = PostListStyle0;
694
+
695
+ const postListItemCss = ":host{display:flex}";
696
+ const PostListItemStyle0 = postListItemCss;
697
+
698
+ const PostListItem = class {
699
+ constructor(hostRef) {
700
+ index.registerInstance(this, hostRef);
701
+ }
702
+ get host() { return index.getElement(this); }
703
+ connectedCallback() {
704
+ this.host.setAttribute('slot', 'post-list-item');
705
+ }
706
+ render() {
707
+ return (index.h(index.Host, { key: '8e209e77859bd05d62cae41aec9dec6fb2e820cb', role: "listitem", slot: "post-list-item" }, index.h("slot", { key: 'ce79a335e80401465b74208957e22983d6df4ce0' })));
708
+ }
709
+ };
710
+ PostListItem.style = PostListItemStyle0;
711
+
712
+ 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}";
713
+ const PostLogoStyle0 = postLogoCss;
714
+
715
+ const PostLogo = class {
716
+ constructor(hostRef) {
717
+ index.registerInstance(this, hostRef);
718
+ this.url = undefined;
719
+ }
720
+ get host() { return index.getElement(this); }
721
+ validateUrl() {
722
+ index$1.checkEmptyOrUrl(this, 'url');
723
+ }
724
+ componentDidLoad() {
725
+ this.validateUrl();
726
+ this.checkDescription();
727
+ }
728
+ checkDescription() {
729
+ if (!this.host.textContent) {
730
+ console.warn('Be sure to add descriptive text in the post-logo to ensure good accessibility of the component.');
731
+ }
732
+ }
733
+ render() {
734
+ const logoLink = this.url && (typeof this.url === 'string' ? this.url : this.url.href);
735
+ const LogoTag = logoLink ? 'a' : 'span';
736
+ return (index.h(index.Host, { key: '128604612a51624b537f30b0b9c91d9ea6b950be', "data-version": _package.version }, index.h(LogoTag, { key: '885f057200f9da839fd38cb7070f319f6c89793e', class: `logo ${logoLink ? 'logo-link' : ''}`, ...(logoLink ? { href: logoLink } : {}) }, index.h("span", { key: 'bee12585bf74fe5c2ce8a644c540c86626295526', class: "description" }, index.h("slot", { key: 'e516075c5138cef9378d3dc7137eb6c28d02b279', onSlotchange: () => this.checkDescription() })), index.h("svg", { key: 'c0056463b93f7c0e5da07db4656d9c8dc9161c32', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 72 72", "aria-hidden": "true" }, index.h("g", { key: '1dfc33886c9b1fb6cd3b08f448a89c11a6080598', id: "Logo" }, index.h("rect", { key: 'dd84426568259714379a92a3f56349c6b3220a61', fill: "#ffcc00", x: "0", y: "0", width: "72", height: "72" }), index.h("polygon", { key: '56fa6445c184a41355a968365098b75387a16f48', 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: 'f2abb1db77a2e795f477662453d7296a28882756', 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" }))))));
737
+ }
738
+ static get watchers() { return {
739
+ "url": ["validateUrl"]
740
+ }; }
741
+ };
742
+ PostLogo.style = PostLogoStyle0;
743
+
744
+ 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 post-megadropdown-trigger 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-mainnavigation post-list-item post-megadropdown-trigger 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-mainnavigation post-list-item post-megadropdown-trigger button:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){post-mainnavigation post-list-item post-megadropdown-trigger 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-mainnavigation post-list-item post-megadropdown-trigger button:is(:focus-visible,:focus-within,.pretend-focus){outline-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}post-mainnavigation .back-button post-icon{transform:rotate(180deg)}@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 screen and (min-width: 1024px){post-mainnavigation{display:block}post-mainnavigation nav{max-width:100vw;background:#fff;max-height:var(--main-navigation-height);user-select:none;transition:margin 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation .left-scroll-button,post-mainnavigation .right-scroll-button{z-index:4;position:absolute;inset-block-end:0;overflow:hidden}post-mainnavigation .left-scroll-button button,post-mainnavigation .right-scroll-button 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;background:#fff;padding:16px;box-shadow:var(--post-device-elevation-500);line-height:100%;height:var(--main-navigation-height)}}@media screen and (min-width: 1024px)and (forced-colors: active),screen and (min-width: 1024px)and (-ms-high-contrast: active),screen and (min-width: 1024px)and (-ms-high-contrast: white-on-black){post-mainnavigation .left-scroll-button button,post-mainnavigation .right-scroll-button button{background-color:ButtonFace !important}post-mainnavigation .left-scroll-button button:hover,post-mainnavigation .right-scroll-button button:hover{background-color:Highlight !important}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button button post-icon,post-mainnavigation .right-scroll-button button post-icon{font-size:1rem}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button{inset-inline-start:0;padding-inline-end:2rem}}@media screen and (min-width: 1024px){post-mainnavigation .right-scroll-button{inset-inline-end:0;padding-inline-start:2rem}}@media screen and (min-width: 1024px){post-mainnavigation post-list>[role=list]{flex-direction:row;max-width:100vw}}@media screen and (min-width: 1024px){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(--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%;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;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 .left-scroll-button,post-mainnavigation .right-scroll-button{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}";
745
+ const PostMainnavigationStyle0 = postMainnavigationCss;
746
+
747
+ const SCROLL_REPEAT_INTERVAL = 100; // Interval for repeated scrolling when holding down scroll button
748
+ const NAVBAR_DISABLE_DURATION = 400; // Duration to temporarily disable navbar interactions during scrolling
749
+ const NAVIGATION_LIST_SELECTOR = 'post-list > [role="list"]:not(post-megadropdown *)';
750
+ const NAVIGATION_ITEM_SELECTOR = 'post-list-item :is(a, button):not(post-megadropdown *)';
751
+ const PostMainnavigation = class {
752
+ constructor(hostRef) {
753
+ index.registerInstance(this, hostRef);
754
+ this.canScrollLeft = false;
755
+ this.canScrollRight = false;
756
+ this.translationAmount = 0;
757
+ }
758
+ header;
759
+ navbar;
760
+ rightScrollButton;
761
+ leftScrollButton;
762
+ scrollRepeatInterval;
763
+ navbarDisableTimer;
764
+ mutationObserver = new MutationObserver(async (mutations) => {
765
+ // Wait for all elements to be hydrated
766
+ await Promise.all(mutations
767
+ .flatMap((mutation) => Array.from(mutation.addedNodes))
768
+ .map((item) => item.componentOnReady ? item.componentOnReady() : Promise.resolve(item)));
769
+ // Recalculate scrollability after DOM changes
770
+ this.checkScrollability();
771
+ });
772
+ get host() { return index.getElement(this); }
773
+ /**
774
+ * Update navbar translation when 'translateAmount' changes and recalculate scrollability
775
+ */
776
+ onTranslateAmountChanges(value) {
777
+ this.navbar.style.marginInlineStart = `-${value}px`;
778
+ this.checkScrollability();
779
+ }
780
+ /**
781
+ * Retrieves a reference to the closest 'post-header' element when the main navigation is added to the DOM.
782
+ * This ensures that we can interact with the header for mobile menu toggling.
783
+ */
784
+ connectedCallback() {
785
+ this.header = this.host.closest('post-header');
786
+ }
787
+ /**
788
+ * Cleans up references and disconnects the MutationObserver when the main navigation is removed from the DOM.
789
+ */
790
+ disconnectedCallback() {
791
+ this.header = null;
792
+ this.mutationObserver.disconnect();
793
+ }
794
+ componentDidLoad() {
795
+ setTimeout(() => this.checkScrollability()); // Initial check to determine if scrolling is needed
796
+ this.mutationObserver.observe(this.navigationList, { subtree: true, childList: true }); // Recheck scrollability when navigation list changes
797
+ this.fixLayoutShift();
798
+ window.addEventListener('resize', // Recheck scrollability on window resize
799
+ throttle(100, () => this.checkScrollability()));
800
+ // Handle focus changes and adjust scroll as needed
801
+ this.navbar.addEventListener('focusin', e => this.adjustTranslation(e));
802
+ }
803
+ // Hack that duplicates navigation elements to fix the layout shift on active elements
804
+ fixLayoutShift() {
805
+ // Select first level of main navigation elements, both the links and the megadropdown trigger buttons
806
+ const children = this.host.querySelectorAll('nav > post-list > div > post-list-item > a, nav > post-list > div > post-list-item > post-megadropdown-trigger > button');
807
+ // Update HTML so that the content is duplicated
808
+ children.forEach(child => (child.innerHTML = `<span class="nav-el-active">${child.innerHTML}</span><span class="nav-el-inactive"aria-hidden="true">${child.innerHTML}</span>`));
809
+ }
810
+ handleBackButtonClick() {
811
+ if (this.header)
812
+ this.header.toggleMobileMenu();
813
+ }
814
+ /**
815
+ * Moves focus on the navbar and adjusts scrolling to bring focused element into view.
816
+ */
817
+ adjustTranslation(e) {
818
+ const focusedElement = e.target;
819
+ if (!this.canScroll || !focusedElement.matches(NAVIGATION_ITEM_SELECTOR))
820
+ return;
821
+ // We need to move the element into the view before it is focused to avoid browser default behavior
822
+ e.preventDefault();
823
+ this.withoutTransition(() => {
824
+ // Try scrolling in both directions, only the necessary translation will actually occur
825
+ this.translateRightTo(focusedElement);
826
+ this.translateLeftTo(focusedElement);
827
+ focusedElement.focus();
828
+ });
829
+ }
830
+ /**
831
+ * Checks if scrolling is possible in either direction (left or right) and updates the state accordingly.
832
+ */
833
+ checkScrollability() {
834
+ const { scrollWidth, clientWidth } = this.navbar;
835
+ const couldScroll = this.canScroll;
836
+ if (scrollWidth === clientWidth) {
837
+ // If scroll width equals client width, scrolling is disabled in both directions
838
+ this.canScrollLeft = this.canScrollRight = false;
839
+ }
840
+ else {
841
+ this.canScrollLeft = this.translationAmount > 0; // Scrolling left is possible if not at the start
842
+ this.canScrollRight = clientWidth + this.translationAmount < scrollWidth; // Scrolling right is possible if not at the end
843
+ }
844
+ if (couldScroll && !this.canScroll) {
845
+ this.withoutTransition(() => (this.translationAmount = 0));
846
+ }
847
+ }
848
+ /**
849
+ * Returns whether scrolling is enabled in either the left or right direction.
850
+ */
851
+ get canScroll() {
852
+ return this.canScrollLeft || this.canScrollRight;
853
+ }
854
+ /**
855
+ * Handles the scrolling behavior when a user clicks on the left or right scroll buttons.
856
+ */
857
+ handleScrollButtonClick(direction) {
858
+ if (!this.canScroll)
859
+ return;
860
+ // Disable interaction with the navbar during scrolling
861
+ this.disableNavbar();
862
+ // Perform the initial scroll action
863
+ this.scroll(direction);
864
+ // Repeat the scrolling action while the button is held down
865
+ this.scrollRepeatInterval = setInterval(() => {
866
+ this.scroll(direction);
867
+ }, SCROLL_REPEAT_INTERVAL);
868
+ }
869
+ /**
870
+ * Stops the repeated scrolling when the mouse button is released.
871
+ */
872
+ stopScrolling() {
873
+ if (this.scrollRepeatInterval)
874
+ clearInterval(this.scrollRepeatInterval);
875
+ }
876
+ scroll(direction) {
877
+ const navigationItems = Array.from(this.navigationItems);
878
+ if (direction === 'left')
879
+ navigationItems.reverse();
880
+ for (const item of navigationItems) {
881
+ const couldScroll = direction === 'left' ? this.translateLeftTo(item, true) : this.translateRightTo(item, true);
882
+ if (couldScroll)
883
+ break;
884
+ }
885
+ }
886
+ translateRightTo(navigationItem, skipSmallTranslation = false) {
887
+ const listItem = navigationItem.closest('post-list-item');
888
+ // Calculate the right edge position of the list item relative to the left of the screen
889
+ const rightEdgePosition = listItem.offsetLeft + listItem.offsetWidth;
890
+ // Calculate the last visible position on the screen, right before the right scroll button
891
+ const lastVisiblePosition = this.host.clientWidth - this.rightScrollButton.clientWidth;
892
+ // If the item is already fully visible, no translation is needed
893
+ if (rightEdgePosition < lastVisiblePosition)
894
+ return false;
895
+ const translationIncrease = rightEdgePosition - lastVisiblePosition + 1; // + 1 because offset values are rounded
896
+ // If the required scroll distance is too small (less than half the width of the item), avoid unnecessary scroll
897
+ if (skipSmallTranslation && translationIncrease < listItem.clientWidth / 2)
898
+ return false;
899
+ // Calculate the maximum translation amount to prevent scrolling past the end of the content
900
+ const maximumTranslation = this.navbar.scrollWidth - this.host.clientWidth;
901
+ // Adjust the translation amount, ensuring it doesn't exceed the maximum scrollable area
902
+ const { marginRight } = getComputedStyle(this.navigationList);
903
+ this.translationAmount =
904
+ Math.min(this.translationAmount + translationIncrease, maximumTranslation) +
905
+ parseInt(marginRight);
906
+ return true;
907
+ }
908
+ translateLeftTo(navigationItem, skipSmallTranslation = false) {
909
+ const listItem = navigationItem.closest('post-list-item');
910
+ // Get the left edge position of the list item relative to the left of the screen
911
+ const leftEdgePosition = listItem.offsetLeft;
912
+ // Calculate the first visible position on the screen to the left, right after the left scroll button
913
+ const firstVisiblePosition = this.leftScrollButton.clientWidth;
914
+ // If the item is already fully visible, no translation is needed
915
+ if (leftEdgePosition > firstVisiblePosition)
916
+ return false;
917
+ const translationDecrease = firstVisiblePosition - leftEdgePosition + 1; // + 1 because offset values are rounded
918
+ // If the required scroll distance is too small (less than half the width of the item), don't perform the scroll
919
+ if (skipSmallTranslation && translationDecrease < listItem.clientWidth / 2)
920
+ return false;
921
+ // Calculate the minimum allowed translation amount (no negative scrolling allowed)
922
+ const minimumTranslation = 0;
923
+ // Adjust the translation amount, ensuring it doesn't go below the minimum scrollable area
924
+ const { marginLeft } = getComputedStyle(this.navigationList);
925
+ this.translationAmount = Math.max(this.translationAmount - translationDecrease - parseInt(marginLeft), minimumTranslation);
926
+ return true;
927
+ }
928
+ /**
929
+ * Returns the navigation list container element
930
+ */
931
+ get navigationList() {
932
+ return this.navbar.querySelector(NAVIGATION_LIST_SELECTOR);
933
+ }
934
+ /**
935
+ * Returns the navigation items
936
+ */
937
+ get navigationItems() {
938
+ return this.navbar.querySelectorAll(NAVIGATION_ITEM_SELECTOR);
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
+ disableNavbar() {
945
+ if (this.navbarDisableTimer)
946
+ clearTimeout(this.navbarDisableTimer);
947
+ this.navbar.style.pointerEvents = 'none';
948
+ this.navbarDisableTimer = setTimeout(() => {
949
+ this.navbar.style.pointerEvents = 'initial';
950
+ }, NAVBAR_DISABLE_DURATION);
951
+ }
952
+ /**
953
+ * Allows to translate the navbar without a transition
954
+ */
955
+ withoutTransition(callback) {
956
+ const transition = this.navbar.style.transition;
957
+ this.navbar.style.transition = 'none';
958
+ callback();
959
+ setTimeout(() => {
960
+ this.navbar.style.transition = transition;
961
+ });
962
+ }
963
+ render() {
964
+ return (index.h(index.Host, { key: 'd9be56167f714c041eb05283832986ec38c451cd', slot: "post-mainnavigation" }, index.h("div", { key: '5852c66b93a6eb9697fd7c7b1379e748804c6917', onClick: () => this.handleBackButtonClick(), class: "back-button" }, index.h("slot", { key: '0d4d98897fb5a8f8cf1c0871037ac01023c41cc2', name: "back-button" })), index.h("nav", { key: 'c60635b5db5a54b9e7661b92eeec29ed6d453cfe', ref: el => (this.navbar = el) }, index.h("slot", { key: 'd83facd6cb8c2a892ad432e42357123660c647ed' })), index.h("div", { key: 'e9afc48596b3e877d9efb9a4189abb8c84aadb6d', class: `left-scroll-button${this.canScrollLeft ? '' : ' d-none'}`, "aria-hidden": "true" }, index.h("button", { key: 'ef11720ec4f6d7811eb10027871a336e46ba6b84', type: "button", tabindex: "-1", ref: el => (this.leftScrollButton = el), onMouseDown: () => this.handleScrollButtonClick('left') }, index.h("post-icon", { key: 'f85ff2ef87841409f4b4f6c33e6d0dca4c764cc6', "aria-hidden": "true", name: "chevronleft" }))), index.h("div", { key: '181dc100ddedcba3f07b5f0ff9aedf165499f74f', class: `right-scroll-button${this.canScrollRight ? '' : ' d-none'}`, "aria-hidden": "true" }, index.h("button", { key: '83a8a824fcfe499207f6030e11381e68d530c67d', type: "button", tabindex: "-1", ref: el => (this.rightScrollButton = el), onMouseDown: () => this.handleScrollButtonClick('right') }, index.h("post-icon", { key: '52caec8a9a8c15e97ea5702ec3fe30bd4777c728', "aria-hidden": "true", name: "chevronright" })))));
965
+ }
966
+ static get watchers() { return {
967
+ "translationAmount": ["onTranslateAmountChanges"]
968
+ }; }
969
+ };
970
+ PostMainnavigation.style = PostMainnavigationStyle0;
971
+
972
+ 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;border-top:1px solid #e1e0dc;width:100%;top:100%;left: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;top:0 !important;left:0;width:100%;position:fixed;height:calc(100dvh - var(--header-height));max-height:calc(100dvh - var(--header-height));border-top:unset;overflow:auto}.megadropdown-container.slide-in{animation:slide-in 350ms forwards}.megadropdown-container.slide-out{animation:slide-out 350ms forwards}}.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-top:0;margin-bottom:8px;font-weight:900}.megadropdown h2 a{text-decoration:none;display:none;font-weight:inherit;border-bottom:0;border-top: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;bottom:0;width:100%;height:2px;position:absolute;left:0}.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}.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-bottom: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;top:1rem;right:1rem}@media screen and (max-width: 1023.98px){.megadropdown .close-button{display:none}}";
973
+ const PostMegadropdownStyle0 = postMegadropdownCss;
974
+
975
+ const PostMegadropdown = class {
976
+ constructor(hostRef) {
977
+ index.registerInstance(this, hostRef);
978
+ this.postToggleMegadropdown = index.createEvent(this, "postToggleMegadropdown", 7);
979
+ this.device = undefined;
980
+ this.isVisible = false;
981
+ this.animationClass = null;
982
+ }
983
+ header;
984
+ firstFocusableEl;
985
+ lastFocusableEl;
986
+ get host() { return index.getElement(this); }
987
+ /** Tracks the currently active dropdown instance. */
988
+ static activeDropdown = null;
989
+ /**
990
+ * Emits when the dropdown is shown or hidden.
991
+ * The event payload is an object.
992
+ * `isVisible` is true when the dropdown gets opened and false when it gets closed
993
+ * `focusParent` determines whether after the closing of the mega dropdown, the focus should go back to the trigger parent or naturally go to the next focusable element in the page
994
+ **/
995
+ postToggleMegadropdown;
996
+ disconnectedCallback() {
997
+ this.removeListeners();
998
+ if (PostMegadropdown.activeDropdown === this) {
999
+ PostMegadropdown.activeDropdown = null;
1000
+ }
1001
+ }
1002
+ componentWillRender() {
1003
+ this.getFocusableElements();
1004
+ }
1005
+ /**
1006
+ * Toggles the dropdown visibility based on its current state.
1007
+ */
1008
+ async toggle() {
1009
+ if (this.isVisible) {
1010
+ this.hide();
1011
+ }
1012
+ else {
1013
+ await this.show();
1014
+ }
1015
+ }
1016
+ /**
1017
+ * Displays the dropdown.
1018
+ */
1019
+ async show() {
1020
+ if (PostMegadropdown.activeDropdown && PostMegadropdown.activeDropdown !== this) {
1021
+ // Close the previously active dropdown without animation
1022
+ PostMegadropdown.activeDropdown.forceClose();
1023
+ }
1024
+ else {
1025
+ this.animationClass = 'slide-in';
1026
+ }
1027
+ this.isVisible = true;
1028
+ PostMegadropdown.activeDropdown = this;
1029
+ this.postToggleMegadropdown.emit({ isVisible: this.isVisible });
1030
+ if (this.firstFocusableEl &&
1031
+ window.getComputedStyle(this.firstFocusableEl).display !== 'none') {
1032
+ this.firstFocusableEl.focus();
1033
+ }
1034
+ this.addListeners();
1035
+ }
1036
+ /**
1037
+ * Hides the dropdown with an animation.
1038
+ */
1039
+ async hide(focusParent = true) {
1040
+ this.postToggleMegadropdown.emit({ isVisible: false, focusParent: focusParent });
1041
+ this.animationClass = 'slide-out';
1042
+ }
1043
+ async focusFirst() {
1044
+ this.firstFocusableEl?.focus();
1045
+ }
1046
+ connectedCallback() {
1047
+ this.header = this.host.closest('post-header');
1048
+ if (this.header) {
1049
+ this.header.addEventListener('postUpdateDevice', (event) => {
1050
+ this.device = event.detail;
1051
+ });
1052
+ }
1053
+ }
1054
+ /**
1055
+ * Forces the dropdown to close without animation.
1056
+ */
1057
+ forceClose() {
1058
+ this.isVisible = false;
1059
+ this.animationClass = null;
1060
+ this.postToggleMegadropdown.emit({ isVisible: this.isVisible, focusParent: false });
1061
+ this.removeListeners();
1062
+ }
1063
+ handleAnimationEnd() {
1064
+ if (this.animationClass === 'slide-out') {
1065
+ this.isVisible = false;
1066
+ this.animationClass = null;
1067
+ PostMegadropdown.activeDropdown = null;
1068
+ this.removeListeners();
1069
+ }
1070
+ }
1071
+ handleClickOutside = (event) => {
1072
+ const target = event.target;
1073
+ if (this.host.contains(target)) {
1074
+ return;
1075
+ }
1076
+ if (target instanceof HTMLElement) {
1077
+ const trigger = target.closest('post-megadropdown-trigger');
1078
+ if (trigger) {
1079
+ const targetDropdownId = trigger.getAttribute('for');
1080
+ if (targetDropdownId !== this.host.id) {
1081
+ return;
1082
+ }
1083
+ }
1084
+ }
1085
+ this.hide(false);
1086
+ };
1087
+ addListeners() {
1088
+ this.host.addEventListener('keydown', e => this.keyboardHandler(e));
1089
+ document.addEventListener('keyup', e => this.handleTabOutside(e));
1090
+ document.addEventListener('mousedown', this.handleClickOutside);
1091
+ }
1092
+ removeListeners() {
1093
+ this.host.removeEventListener('keydown', e => this.keyboardHandler(e));
1094
+ document.removeEventListener('keyup', e => this.handleTabOutside(e));
1095
+ document.removeEventListener('mousedown', this.handleClickOutside);
1096
+ }
1097
+ getFocusableElements() {
1098
+ const focusableEls = Array.from(this.host.querySelectorAll('post-list-item, h3, .back-button'));
1099
+ const focusableChildren = focusableEls.flatMap(el => Array.from(getFocusableChildren(el)));
1100
+ this.firstFocusableEl = focusableChildren[0];
1101
+ this.lastFocusableEl = focusableChildren[focusableChildren.length - 1];
1102
+ }
1103
+ // Loop through the focusable children
1104
+ keyboardHandler(e) {
1105
+ if (e.key === 'Tab' && this.device !== 'desktop') {
1106
+ if (e.shiftKey && document.activeElement === this.firstFocusableEl) {
1107
+ // If back tab (TAB + Shift) and first element is focused, focus goes to the last element of the megadropdown
1108
+ e.preventDefault();
1109
+ this.lastFocusableEl.focus();
1110
+ }
1111
+ else if (!e.shiftKey && document.activeElement === this.lastFocusableEl) {
1112
+ // If TAB and last element is focused, focus goes back to the first element of the megadropdown
1113
+ e.preventDefault();
1114
+ this.firstFocusableEl.focus();
1115
+ }
1116
+ }
1117
+ }
1118
+ handleTabOutside(e) {
1119
+ if (e.key === 'Tab' && this.device === 'desktop') {
1120
+ if (!this.host.contains(e.target)) {
1121
+ this.hide(false);
1122
+ }
1123
+ }
1124
+ }
1125
+ render() {
1126
+ const containerStyle = this.isVisible ? {} : { display: 'none' };
1127
+ return (index.h(index.Host, { key: '1475e9ff941f5333d5cfe4f00157f8b2fc826b5e' }, index.h("div", { key: 'f3da1ec8abc7d00be7020821be69ea3af16f3ad2', class: `megadropdown-container ${this.animationClass || ''}`, style: containerStyle, onAnimationEnd: () => this.handleAnimationEnd() }, index.h("div", { key: 'f02279d454c7413080ce52711fe0cb923950d066', class: "megadropdown" }, index.h("slot", { key: '87da859d1a8408c3a49ea1ab050ea5f27de45ec2', name: "megadropdown-title" }), index.h("div", { key: 'c389959cf97c2ea69dd7b3f6945071e0c1793458', class: "megadropdown-content" }, index.h("slot", { key: '1a1241624a5b5421de0e4a3a54ddba3eb1e0834f' })), index.h("div", { key: 'f8fad723719e1505730f679dfff6428f3a5f1340', onClick: () => this.hide(true), class: "back-button" }, index.h("slot", { key: '6ca62ac352810b6d3642ee69433de4aac4089117', name: "back-button" })), index.h("div", { key: '16200fc7dee7d5535399e0450e39a816f04dffd6', onClick: () => this.hide(true), class: "close-button" }, index.h("slot", { key: 'e9478713c07f69011f397af3e3ffa6a3b8b7fb6a', name: "close-button" }))))));
1128
+ }
1129
+ };
1130
+ PostMegadropdown.style = PostMegadropdownStyle0;
1131
+
1132
+ const postMegadropdownTriggerCss = "post-megadropdown-trigger{width:100%;position:relative;z-index:3}";
1133
+ const PostMegadropdownTriggerStyle0 = postMegadropdownTriggerCss;
1134
+
1135
+ const PostMegadropdownTrigger = class {
1136
+ constructor(hostRef) {
1137
+ index.registerInstance(this, hostRef);
1138
+ this.for = undefined;
1139
+ this.ariaExpanded = false;
1140
+ }
1141
+ get host() { return index.getElement(this); }
1142
+ /**
1143
+ * Reference to the slotted button within the trigger, if present.
1144
+ * Used to manage click and key events for mega dropdown control.
1145
+ */
1146
+ slottedButton = null;
1147
+ /**
1148
+ * Tracks whether this trigger's dropdown was expanded before a state change.
1149
+ * Used to determine if this trigger should handle focus when its dropdown closes.
1150
+ */
1151
+ wasExpanded = false;
1152
+ /**
1153
+ * Watch for changes to the `for` property to validate its type and ensure it is a string.
1154
+ * @param forValue - The new value of the `for` property.
1155
+ */
1156
+ validateControlFor() {
1157
+ checkType.checkType(this, 'for', 'string');
1158
+ }
1159
+ get megadropdown() {
1160
+ const ref = document.getElementById(this.for);
1161
+ return ref && ref.localName === 'post-megadropdown'
1162
+ ? ref
1163
+ : null;
1164
+ }
1165
+ handleToggle() {
1166
+ if (this.megadropdown) {
1167
+ this.megadropdown.toggle();
1168
+ }
1169
+ else {
1170
+ console.warn(`No post-megadropdown found with ID: ${this.for}`);
1171
+ }
1172
+ }
1173
+ handleKeyDown = (event) => {
1174
+ if (event.key === 'Enter') {
1175
+ event.preventDefault();
1176
+ this.handleToggle();
1177
+ if (this.megadropdown && !this.ariaExpanded) {
1178
+ setTimeout(() => this.megadropdown.focusFirst(), 100);
1179
+ }
1180
+ }
1181
+ };
1182
+ componentDidLoad() {
1183
+ this.validateControlFor();
1184
+ // Check if the mega dropdown attached to the trigger is expanded or not
1185
+ document.addEventListener('postToggleMegadropdown', (event) => {
1186
+ if (event.target.id === this.for) {
1187
+ this.ariaExpanded = event.detail.isVisible;
1188
+ // Focus on the trigger parent of the dropdown after it's closed if close button had been clicked
1189
+ if (this.wasExpanded && !this.ariaExpanded && event.detail.focusParent) {
1190
+ setTimeout(() => {
1191
+ this.slottedButton?.focus();
1192
+ }, 100);
1193
+ }
1194
+ this.wasExpanded = this.ariaExpanded;
1195
+ if (this.slottedButton) {
1196
+ this.slottedButton.setAttribute('aria-expanded', this.ariaExpanded.toString());
1197
+ }
1198
+ }
1199
+ });
1200
+ this.slottedButton = this.host.querySelector('button');
1201
+ if (this.slottedButton) {
1202
+ this.slottedButton.setAttribute('aria-haspopup', 'menu');
1203
+ this.slottedButton.addEventListener('click', () => {
1204
+ this.handleToggle();
1205
+ });
1206
+ this.slottedButton.addEventListener('keydown', this.handleKeyDown);
1207
+ }
1208
+ else {
1209
+ console.warn('No button found within post-megadropdown-trigger');
1210
+ }
1211
+ }
1212
+ render() {
1213
+ return (index.h(index.Host, { key: '99849b6b851d061c1365eb5d507cba0e7e6e3ae6', "data-version": _package.version, "tab-index": "-1" }, index.h("button", { key: 'ddd553c4b893538155263e5bd82c763be68eb3f3' }, index.h("slot", { key: 'eb006c5b13c69a8e089702f1b46f88bc3d74b045' }))));
1214
+ }
1215
+ static get watchers() { return {
1216
+ "for": ["validateControlFor"]
1217
+ }; }
1218
+ };
1219
+ PostMegadropdownTrigger.style = PostMegadropdownTriggerStyle0;
1220
+
1221
+ const postMenuCss = "/*!\n * Copyright 2021 by Swiss Post, Information Technology\n */: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}";
1222
+ const PostMenuStyle0 = postMenuCss;
1223
+
1224
+ const PostMenu = class {
1225
+ constructor(hostRef) {
1226
+ index.registerInstance(this, hostRef);
1227
+ this.toggleMenu = index.createEvent(this, "toggleMenu", 7);
1228
+ this.placement = 'bottom';
1229
+ this.isVisible = false;
1230
+ }
1231
+ popoverRef;
1232
+ lastFocusedElement = null;
1233
+ KEYCODES = {
1234
+ SPACE: ' ',
1235
+ ENTER: 'Enter',
1236
+ UP: 'ArrowUp',
1237
+ DOWN: 'ArrowDown',
1238
+ TAB: 'Tab',
1239
+ HOME: 'Home',
1240
+ END: 'End',
1241
+ ESCAPE: 'Escape',
1242
+ };
1243
+ get host() { return index.getElement(this); }
1244
+ /**
1245
+ * Emits when the menu is shown or hidden.
1246
+ * The event payload is a boolean: `true` when the menu was opened, `false` when it was closed.
1247
+ **/
1248
+ toggleMenu;
1249
+ root;
1250
+ connectedCallback() {
1251
+ this.root = getRoot.getRoot(this.host);
1252
+ this.host.addEventListener('keydown', this.handleKeyDown);
1253
+ this.host.addEventListener('click', this.handleClick);
1254
+ }
1255
+ disconnectedCallback() {
1256
+ this.host.removeEventListener('keydown', this.handleKeyDown);
1257
+ this.host.removeEventListener('click', this.handleClick);
1258
+ }
1259
+ componentDidLoad() {
1260
+ this.popoverRef.addEventListener('postToggle', (event) => {
1261
+ this.isVisible = event.detail;
1262
+ this.toggleMenu.emit(this.isVisible);
1263
+ requestAnimationFrame(() => {
1264
+ if (this.isVisible) {
1265
+ this.lastFocusedElement = this.root.activeElement;
1266
+ const menuItems = this.getSlottedItems();
1267
+ if (menuItems.length > 0) {
1268
+ menuItems[0].focus();
1269
+ }
1270
+ }
1271
+ else if (this.lastFocusedElement) {
1272
+ this.lastFocusedElement.focus();
1273
+ }
1274
+ });
1275
+ });
1276
+ }
1277
+ /**
1278
+ * Toggles the menu visibility based on its current state.
1279
+ */
1280
+ async toggle(target) {
1281
+ if (this.popoverRef) {
1282
+ await this.popoverRef.toggle(target);
1283
+ }
1284
+ else {
1285
+ console.error('toggle: popoverRef is null or undefined');
1286
+ }
1287
+ }
1288
+ /**
1289
+ * Displays the popover menu, focusing the first menu item.
1290
+ *
1291
+ * @param target - The HTML element relative to which the popover menu should be displayed.
1292
+ */
1293
+ async show(target) {
1294
+ if (this.popoverRef) {
1295
+ await this.popoverRef.show(target);
1296
+ }
1297
+ else {
1298
+ console.error('show: popoverRef is null or undefined');
1299
+ }
1300
+ }
1301
+ /**
1302
+ * Hides the popover menu and restores focus to the previously focused element.
1303
+ */
1304
+ async hide() {
1305
+ if (this.popoverRef) {
1306
+ await this.popoverRef.hide();
1307
+ }
1308
+ else {
1309
+ console.error('hide: popoverRef is null or undefined');
1310
+ }
1311
+ }
1312
+ handleKeyDown = (e) => {
1313
+ e.stopPropagation();
1314
+ if (e.key === this.KEYCODES.ESCAPE) {
1315
+ this.toggle(this.host);
1316
+ return;
1317
+ }
1318
+ if (Object.values(this.KEYCODES).includes(e.key)) {
1319
+ this.controlKeyDownHandler(e);
1320
+ }
1321
+ };
1322
+ handleClick = (e) => {
1323
+ const target = e.target;
1324
+ if (['BUTTON', 'A', 'INPUT', 'SELECT', 'TEXTAREA'].includes(target.tagName)) {
1325
+ this.toggle(this.host);
1326
+ }
1327
+ };
1328
+ controlKeyDownHandler(e) {
1329
+ const menuItems = this.getSlottedItems();
1330
+ if (!menuItems.length) {
1331
+ return;
1332
+ }
1333
+ let currentIndex = menuItems.findIndex(el => {
1334
+ // Check if the item is currently focused within its rendered scope (document or shadow root)
1335
+ return el === getRoot.getRoot(el).activeElement;
1336
+ });
1337
+ switch (e.key) {
1338
+ case this.KEYCODES.UP:
1339
+ e.preventDefault();
1340
+ currentIndex = (currentIndex - 1 + menuItems.length) % menuItems.length;
1341
+ break;
1342
+ case this.KEYCODES.DOWN:
1343
+ e.preventDefault();
1344
+ currentIndex = (currentIndex + 1) % menuItems.length;
1345
+ break;
1346
+ case this.KEYCODES.HOME:
1347
+ currentIndex = 0;
1348
+ break;
1349
+ case this.KEYCODES.END:
1350
+ e.preventDefault();
1351
+ currentIndex = menuItems.length - 1;
1352
+ break;
1353
+ case this.KEYCODES.SPACE:
1354
+ this.toggle(this.host);
1355
+ return;
1356
+ case this.KEYCODES.TAB:
1357
+ this.toggle(this.host);
1358
+ break;
1359
+ }
1360
+ if (menuItems[currentIndex]) {
1361
+ menuItems[currentIndex].focus();
1362
+ }
1363
+ }
1364
+ getSlottedItems() {
1365
+ const slot = this.host.shadowRoot.querySelector('slot');
1366
+ const slottedElements = slot ? slot.assignedElements() : [];
1367
+ return (slottedElements
1368
+ // If the element is a slot, get the assigned elements
1369
+ .flatMap(el => (el instanceof HTMLSlotElement ? el.assignedElements() : el))
1370
+ // Filter out elements that have a 'menuitem' role
1371
+ .filter(el => el.getAttribute('role') === 'menuitem')
1372
+ // For each menu item, get any focusable children (e.g., buttons, links)
1373
+ .flatMap(el => Array.from(getFocusableChildren(el))));
1374
+ }
1375
+ render() {
1376
+ return (index.h(index.Host, { key: '3a79b9df5a5d4c121aa9ca36883d6e17cbf2a66e', "data-version": _package.version }, index.h("post-popovercontainer", { key: '9c8a37a2c70b98ff9a960f467ab951af10c34726', placement: this.placement, ref: e => (this.popoverRef = e) }, index.h("div", { key: '0cda7fc8df3f201d4b4e0170bb8a94e72e123814', class: "popover-container", part: "popover-container" }, index.h("slot", { key: 'ac20e448dededb6ea79715c2c29122dccf0d7309' })))));
1377
+ }
1378
+ };
1379
+ PostMenu.style = PostMenuStyle0;
1380
+
1381
+ const postMenuTriggerCss = ":host{display:inline-block}";
1382
+ const PostMenuTriggerStyle0 = postMenuTriggerCss;
1383
+
1384
+ const PostMenuTrigger = class {
1385
+ constructor(hostRef) {
1386
+ index.registerInstance(this, hostRef);
1387
+ this.for = undefined;
1388
+ this.ariaExpanded = false;
1389
+ }
1390
+ get host() { return index.getElement(this); }
1391
+ /**
1392
+ * Reference to the slotted button within the trigger, if present.
1393
+ * Used to manage click and key events for menu control.
1394
+ */
1395
+ slottedButton = null;
1396
+ root;
1397
+ /**
1398
+ * Watch for changes to the `for` property to validate its type and ensure it is a string.
1399
+ * @param forValue - The new value of the `for` property.
1400
+ */
1401
+ validateControlFor() {
1402
+ checkType.checkType(this, 'for', 'string');
1403
+ }
1404
+ get menu() {
1405
+ const ref = this.root.getElementById(this.for);
1406
+ return ref && ref.localName === 'post-menu' ? ref : null;
1407
+ }
1408
+ handleToggle() {
1409
+ if (this.menu) {
1410
+ this.menu.toggle(this.host);
1411
+ }
1412
+ else {
1413
+ console.warn(`No post-menu found with ID: ${this.for}`);
1414
+ }
1415
+ }
1416
+ handleKeyDown = (e) => {
1417
+ if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
1418
+ e.preventDefault();
1419
+ this.handleToggle();
1420
+ }
1421
+ };
1422
+ connectedCallback() {
1423
+ this.root = getRoot.getRoot(this.host);
1424
+ }
1425
+ componentDidLoad() {
1426
+ this.validateControlFor();
1427
+ this.slottedButton = this.host.querySelector('button');
1428
+ // Check if the slottedButton is within a web component
1429
+ if (!this.slottedButton) {
1430
+ const webComponent = this.host.querySelector('.menu-trigger-webc');
1431
+ if (webComponent.shadowRoot) {
1432
+ const slottedButton = webComponent.shadowRoot.querySelector('button');
1433
+ if (slottedButton) {
1434
+ this.slottedButton = slottedButton;
1435
+ }
1436
+ }
1437
+ }
1438
+ if (this.slottedButton) {
1439
+ this.slottedButton.setAttribute('aria-haspopup', 'menu');
1440
+ // Listen to the `toggleMenu` event emitted by the `post-menu` component
1441
+ if (this.menu && this.slottedButton) {
1442
+ this.menu.addEventListener('toggleMenu', (event) => {
1443
+ this.ariaExpanded = event.detail;
1444
+ this.slottedButton.setAttribute('aria-expanded', this.ariaExpanded.toString());
1445
+ });
1446
+ }
1447
+ this.slottedButton.addEventListener('click', () => {
1448
+ this.handleToggle();
1449
+ });
1450
+ this.slottedButton.addEventListener('keydown', this.handleKeyDown);
1451
+ }
1452
+ else {
1453
+ console.warn('No button found within post-menu-trigger');
1454
+ }
1455
+ }
1456
+ render() {
1457
+ return (index.h(index.Host, { key: '84316d4a69c4231be636e5ff8971752d5af9bab2', "data-version": _package.version, "tab-index": "-1" }, index.h("slot", { key: 'd3091adcf7033c4dd25e49fa383ccb9773b2d226' })));
1458
+ }
1459
+ static get watchers() { return {
1460
+ "for": ["validateControlFor"]
1461
+ }; }
1462
+ };
1463
+ PostMenuTrigger.style = PostMenuTriggerStyle0;
1464
+
1465
+ /**
1466
+ * Custom positioning reference element.
1467
+ * @see https://floating-ui.com/docs/virtual-elements
1468
+ */
1469
+
1470
+ const sides = ['top', 'right', 'bottom', 'left'];
1471
+ const alignments = ['start', 'end'];
1472
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
1473
+ const min = Math.min;
1474
+ const max = Math.max;
1475
+ const round = Math.round;
1476
+ const floor = Math.floor;
1477
+ const createCoords = v => ({
1478
+ x: v,
1479
+ y: v
1480
+ });
1481
+ const oppositeSideMap = {
1482
+ left: 'right',
1483
+ right: 'left',
1484
+ bottom: 'top',
1485
+ top: 'bottom'
1486
+ };
1487
+ const oppositeAlignmentMap = {
1488
+ start: 'end',
1489
+ end: 'start'
1490
+ };
1491
+ function clamp(start, value, end) {
1492
+ return max(start, min(value, end));
1493
+ }
1494
+ function evaluate(value, param) {
1495
+ return typeof value === 'function' ? value(param) : value;
1496
+ }
1497
+ function getSide(placement) {
1498
+ return placement.split('-')[0];
1499
+ }
1500
+ function getAlignment(placement) {
1501
+ return placement.split('-')[1];
1502
+ }
1503
+ function getOppositeAxis(axis) {
1504
+ return axis === 'x' ? 'y' : 'x';
1505
+ }
1506
+ function getAxisLength(axis) {
1507
+ return axis === 'y' ? 'height' : 'width';
1508
+ }
1509
+ function getSideAxis(placement) {
1510
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
1511
+ }
1512
+ function getAlignmentAxis(placement) {
1513
+ return getOppositeAxis(getSideAxis(placement));
1514
+ }
1515
+ function getAlignmentSides(placement, rects, rtl) {
1516
+ if (rtl === void 0) {
1517
+ rtl = false;
1518
+ }
1519
+ const alignment = getAlignment(placement);
1520
+ const alignmentAxis = getAlignmentAxis(placement);
1521
+ const length = getAxisLength(alignmentAxis);
1522
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
1523
+ if (rects.reference[length] > rects.floating[length]) {
1524
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1525
+ }
1526
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1527
+ }
1528
+ function getExpandedPlacements(placement) {
1529
+ const oppositePlacement = getOppositePlacement(placement);
1530
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1531
+ }
1532
+ function getOppositeAlignmentPlacement(placement) {
1533
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
1534
+ }
1535
+ function getSideList(side, isStart, rtl) {
1536
+ const lr = ['left', 'right'];
1537
+ const rl = ['right', 'left'];
1538
+ const tb = ['top', 'bottom'];
1539
+ const bt = ['bottom', 'top'];
1540
+ switch (side) {
1541
+ case 'top':
1542
+ case 'bottom':
1543
+ if (rtl) return isStart ? rl : lr;
1544
+ return isStart ? lr : rl;
1545
+ case 'left':
1546
+ case 'right':
1547
+ return isStart ? tb : bt;
1548
+ default:
1549
+ return [];
1550
+ }
1551
+ }
1552
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1553
+ const alignment = getAlignment(placement);
1554
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
1555
+ if (alignment) {
1556
+ list = list.map(side => side + "-" + alignment);
1557
+ if (flipAlignment) {
1558
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1559
+ }
1560
+ }
1561
+ return list;
1562
+ }
1563
+ function getOppositePlacement(placement) {
1564
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
1565
+ }
1566
+ function expandPaddingObject(padding) {
1567
+ return {
1568
+ top: 0,
1569
+ right: 0,
1570
+ bottom: 0,
1571
+ left: 0,
1572
+ ...padding
1573
+ };
1574
+ }
1575
+ function getPaddingObject(padding) {
1576
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
1577
+ top: padding,
1578
+ right: padding,
1579
+ bottom: padding,
1580
+ left: padding
1581
+ };
1582
+ }
1583
+ function rectToClientRect(rect) {
1584
+ const {
1585
+ x,
1586
+ y,
1587
+ width,
1588
+ height
1589
+ } = rect;
1590
+ return {
1591
+ width,
1592
+ height,
1593
+ top: y,
1594
+ left: x,
1595
+ right: x + width,
1596
+ bottom: y + height,
1597
+ x,
1598
+ y
1599
+ };
1600
+ }
1601
+
1602
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1603
+ let {
1604
+ reference,
1605
+ floating
1606
+ } = _ref;
1607
+ const sideAxis = getSideAxis(placement);
1608
+ const alignmentAxis = getAlignmentAxis(placement);
1609
+ const alignLength = getAxisLength(alignmentAxis);
1610
+ const side = getSide(placement);
1611
+ const isVertical = sideAxis === 'y';
1612
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1613
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1614
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1615
+ let coords;
1616
+ switch (side) {
1617
+ case 'top':
1618
+ coords = {
1619
+ x: commonX,
1620
+ y: reference.y - floating.height
1621
+ };
1622
+ break;
1623
+ case 'bottom':
1624
+ coords = {
1625
+ x: commonX,
1626
+ y: reference.y + reference.height
1627
+ };
1628
+ break;
1629
+ case 'right':
1630
+ coords = {
1631
+ x: reference.x + reference.width,
1632
+ y: commonY
1633
+ };
1634
+ break;
1635
+ case 'left':
1636
+ coords = {
1637
+ x: reference.x - floating.width,
1638
+ y: commonY
1639
+ };
1640
+ break;
1641
+ default:
1642
+ coords = {
1643
+ x: reference.x,
1644
+ y: reference.y
1645
+ };
1646
+ }
1647
+ switch (getAlignment(placement)) {
1648
+ case 'start':
1649
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1650
+ break;
1651
+ case 'end':
1652
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1653
+ break;
1654
+ }
1655
+ return coords;
1656
+ }
1657
+
1658
+ /**
1659
+ * Computes the `x` and `y` coordinates that will place the floating element
1660
+ * next to a given reference element.
1661
+ *
1662
+ * This export does not have any `platform` interface logic. You will need to
1663
+ * write one for the platform you are using Floating UI with.
1664
+ */
1665
+ const computePosition$1 = async (reference, floating, config) => {
1666
+ const {
1667
+ placement = 'bottom',
1668
+ strategy = 'absolute',
1669
+ middleware = [],
1670
+ platform
1671
+ } = config;
1672
+ const validMiddleware = middleware.filter(Boolean);
1673
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1674
+ let rects = await platform.getElementRects({
1675
+ reference,
1676
+ floating,
1677
+ strategy
1678
+ });
1679
+ let {
1680
+ x,
1681
+ y
1682
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1683
+ let statefulPlacement = placement;
1684
+ let middlewareData = {};
1685
+ let resetCount = 0;
1686
+ for (let i = 0; i < validMiddleware.length; i++) {
1687
+ const {
1688
+ name,
1689
+ fn
1690
+ } = validMiddleware[i];
1691
+ const {
1692
+ x: nextX,
1693
+ y: nextY,
1694
+ data,
1695
+ reset
1696
+ } = await fn({
1697
+ x,
1698
+ y,
1699
+ initialPlacement: placement,
1700
+ placement: statefulPlacement,
1701
+ strategy,
1702
+ middlewareData,
1703
+ rects,
1704
+ platform,
1705
+ elements: {
1706
+ reference,
1707
+ floating
1708
+ }
1709
+ });
1710
+ x = nextX != null ? nextX : x;
1711
+ y = nextY != null ? nextY : y;
1712
+ middlewareData = {
1713
+ ...middlewareData,
1714
+ [name]: {
1715
+ ...middlewareData[name],
1716
+ ...data
1717
+ }
1718
+ };
1719
+ if (reset && resetCount <= 50) {
1720
+ resetCount++;
1721
+ if (typeof reset === 'object') {
1722
+ if (reset.placement) {
1723
+ statefulPlacement = reset.placement;
1724
+ }
1725
+ if (reset.rects) {
1726
+ rects = reset.rects === true ? await platform.getElementRects({
1727
+ reference,
1728
+ floating,
1729
+ strategy
1730
+ }) : reset.rects;
1731
+ }
1732
+ ({
1733
+ x,
1734
+ y
1735
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1736
+ }
1737
+ i = -1;
1738
+ }
1739
+ }
1740
+ return {
1741
+ x,
1742
+ y,
1743
+ placement: statefulPlacement,
1744
+ strategy,
1745
+ middlewareData
1746
+ };
1747
+ };
1748
+
1749
+ /**
1750
+ * Resolves with an object of overflow side offsets that determine how much the
1751
+ * element is overflowing a given clipping boundary on each side.
1752
+ * - positive = overflowing the boundary by that number of pixels
1753
+ * - negative = how many pixels left before it will overflow
1754
+ * - 0 = lies flush with the boundary
1755
+ * @see https://floating-ui.com/docs/detectOverflow
1756
+ */
1757
+ async function detectOverflow(state, options) {
1758
+ var _await$platform$isEle;
1759
+ if (options === void 0) {
1760
+ options = {};
1761
+ }
1762
+ const {
1763
+ x,
1764
+ y,
1765
+ platform,
1766
+ rects,
1767
+ elements,
1768
+ strategy
1769
+ } = state;
1770
+ const {
1771
+ boundary = 'clippingAncestors',
1772
+ rootBoundary = 'viewport',
1773
+ elementContext = 'floating',
1774
+ altBoundary = false,
1775
+ padding = 0
1776
+ } = evaluate(options, state);
1777
+ const paddingObject = getPaddingObject(padding);
1778
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1779
+ const element = elements[altBoundary ? altContext : elementContext];
1780
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1781
+ 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))),
1782
+ boundary,
1783
+ rootBoundary,
1784
+ strategy
1785
+ }));
1786
+ const rect = elementContext === 'floating' ? {
1787
+ ...rects.floating,
1788
+ x,
1789
+ y
1790
+ } : rects.reference;
1791
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1792
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1793
+ x: 1,
1794
+ y: 1
1795
+ } : {
1796
+ x: 1,
1797
+ y: 1
1798
+ };
1799
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1800
+ elements,
1801
+ rect,
1802
+ offsetParent,
1803
+ strategy
1804
+ }) : rect);
1805
+ return {
1806
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1807
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1808
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1809
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1810
+ };
1811
+ }
1812
+
1813
+ /**
1814
+ * Provides data to position an inner element of the floating element so that it
1815
+ * appears centered to the reference element.
1816
+ * @see https://floating-ui.com/docs/arrow
1817
+ */
1818
+ const arrow$1 = options => ({
1819
+ name: 'arrow',
1820
+ options,
1821
+ async fn(state) {
1822
+ const {
1823
+ x,
1824
+ y,
1825
+ placement,
1826
+ rects,
1827
+ platform,
1828
+ elements,
1829
+ middlewareData
1830
+ } = state;
1831
+ // Since `element` is required, we don't Partial<> the type.
1832
+ const {
1833
+ element,
1834
+ padding = 0
1835
+ } = evaluate(options, state) || {};
1836
+ if (element == null) {
1837
+ return {};
1838
+ }
1839
+ const paddingObject = getPaddingObject(padding);
1840
+ const coords = {
1841
+ x,
1842
+ y
1843
+ };
1844
+ const axis = getAlignmentAxis(placement);
1845
+ const length = getAxisLength(axis);
1846
+ const arrowDimensions = await platform.getDimensions(element);
1847
+ const isYAxis = axis === 'y';
1848
+ const minProp = isYAxis ? 'top' : 'left';
1849
+ const maxProp = isYAxis ? 'bottom' : 'right';
1850
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1851
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1852
+ const startDiff = coords[axis] - rects.reference[axis];
1853
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1854
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1855
+
1856
+ // DOM platform can return `window` as the `offsetParent`.
1857
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1858
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1859
+ }
1860
+ const centerToReference = endDiff / 2 - startDiff / 2;
1861
+
1862
+ // If the padding is large enough that it causes the arrow to no longer be
1863
+ // centered, modify the padding so that it is centered.
1864
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1865
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1866
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1867
+
1868
+ // Make sure the arrow doesn't overflow the floating element if the center
1869
+ // point is outside the floating element's bounds.
1870
+ const min$1 = minPadding;
1871
+ const max = clientSize - arrowDimensions[length] - maxPadding;
1872
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1873
+ const offset = clamp(min$1, center, max);
1874
+
1875
+ // If the reference is small enough that the arrow's padding causes it to
1876
+ // to point to nothing for an aligned placement, adjust the offset of the
1877
+ // floating element itself. To ensure `shift()` continues to take action,
1878
+ // a single reset is performed when this is true.
1879
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1880
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1881
+ return {
1882
+ [axis]: coords[axis] + alignmentOffset,
1883
+ data: {
1884
+ [axis]: offset,
1885
+ centerOffset: center - offset - alignmentOffset,
1886
+ ...(shouldAddOffset && {
1887
+ alignmentOffset
1888
+ })
1889
+ },
1890
+ reset: shouldAddOffset
1891
+ };
1892
+ }
1893
+ });
1894
+
1895
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1896
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1897
+ return allowedPlacementsSortedByAlignment.filter(placement => {
1898
+ if (alignment) {
1899
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1900
+ }
1901
+ return true;
1902
+ });
1903
+ }
1904
+ /**
1905
+ * Optimizes the visibility of the floating element by choosing the placement
1906
+ * that has the most space available automatically, without needing to specify a
1907
+ * preferred placement. Alternative to `flip`.
1908
+ * @see https://floating-ui.com/docs/autoPlacement
1909
+ */
1910
+ const autoPlacement = function (options) {
1911
+ if (options === void 0) {
1912
+ options = {};
1913
+ }
1914
+ return {
1915
+ name: 'autoPlacement',
1916
+ options,
1917
+ async fn(state) {
1918
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1919
+ const {
1920
+ rects,
1921
+ middlewareData,
1922
+ placement,
1923
+ platform,
1924
+ elements
1925
+ } = state;
1926
+ const {
1927
+ crossAxis = false,
1928
+ alignment,
1929
+ allowedPlacements = placements,
1930
+ autoAlignment = true,
1931
+ ...detectOverflowOptions
1932
+ } = evaluate(options, state);
1933
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1934
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1935
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1936
+ const currentPlacement = placements$1[currentIndex];
1937
+ if (currentPlacement == null) {
1938
+ return {};
1939
+ }
1940
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1941
+
1942
+ // Make `computeCoords` start from the right place.
1943
+ if (placement !== currentPlacement) {
1944
+ return {
1945
+ reset: {
1946
+ placement: placements$1[0]
1947
+ }
1948
+ };
1949
+ }
1950
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1951
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1952
+ placement: currentPlacement,
1953
+ overflows: currentOverflows
1954
+ }];
1955
+ const nextPlacement = placements$1[currentIndex + 1];
1956
+
1957
+ // There are more placements to check.
1958
+ if (nextPlacement) {
1959
+ return {
1960
+ data: {
1961
+ index: currentIndex + 1,
1962
+ overflows: allOverflows
1963
+ },
1964
+ reset: {
1965
+ placement: nextPlacement
1966
+ }
1967
+ };
1968
+ }
1969
+ const placementsSortedByMostSpace = allOverflows.map(d => {
1970
+ const alignment = getAlignment(d.placement);
1971
+ return [d.placement, alignment && crossAxis ?
1972
+ // Check along the mainAxis and main crossAxis side.
1973
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1974
+ // Check only the mainAxis.
1975
+ d.overflows[0], d.overflows];
1976
+ }).sort((a, b) => a[1] - b[1]);
1977
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1978
+ // Aligned placements should not check their opposite crossAxis
1979
+ // side.
1980
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1981
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1982
+ if (resetPlacement !== placement) {
1983
+ return {
1984
+ data: {
1985
+ index: currentIndex + 1,
1986
+ overflows: allOverflows
1987
+ },
1988
+ reset: {
1989
+ placement: resetPlacement
1990
+ }
1991
+ };
1992
+ }
1993
+ return {};
1994
+ }
1995
+ };
1996
+ };
1997
+
1998
+ /**
1999
+ * Optimizes the visibility of the floating element by flipping the `placement`
2000
+ * in order to keep it in view when the preferred placement(s) will overflow the
2001
+ * clipping boundary. Alternative to `autoPlacement`.
2002
+ * @see https://floating-ui.com/docs/flip
2003
+ */
2004
+ const flip$1 = function (options) {
2005
+ if (options === void 0) {
2006
+ options = {};
2007
+ }
2008
+ return {
2009
+ name: 'flip',
2010
+ options,
2011
+ async fn(state) {
2012
+ var _middlewareData$arrow, _middlewareData$flip;
2013
+ const {
2014
+ placement,
2015
+ middlewareData,
2016
+ rects,
2017
+ initialPlacement,
2018
+ platform,
2019
+ elements
2020
+ } = state;
2021
+ const {
2022
+ mainAxis: checkMainAxis = true,
2023
+ crossAxis: checkCrossAxis = true,
2024
+ fallbackPlacements: specifiedFallbackPlacements,
2025
+ fallbackStrategy = 'bestFit',
2026
+ fallbackAxisSideDirection = 'none',
2027
+ flipAlignment = true,
2028
+ ...detectOverflowOptions
2029
+ } = evaluate(options, state);
2030
+
2031
+ // If a reset by the arrow was caused due to an alignment offset being
2032
+ // added, we should skip any logic now since `flip()` has already done its
2033
+ // work.
2034
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
2035
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2036
+ return {};
2037
+ }
2038
+ const side = getSide(placement);
2039
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
2040
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2041
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
2042
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
2043
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
2044
+ }
2045
+ const placements = [initialPlacement, ...fallbackPlacements];
2046
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2047
+ const overflows = [];
2048
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
2049
+ if (checkMainAxis) {
2050
+ overflows.push(overflow[side]);
2051
+ }
2052
+ if (checkCrossAxis) {
2053
+ const sides = getAlignmentSides(placement, rects, rtl);
2054
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
2055
+ }
2056
+ overflowsData = [...overflowsData, {
2057
+ placement,
2058
+ overflows
2059
+ }];
2060
+
2061
+ // One or more sides is overflowing.
2062
+ if (!overflows.every(side => side <= 0)) {
2063
+ var _middlewareData$flip2, _overflowsData$filter;
2064
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
2065
+ const nextPlacement = placements[nextIndex];
2066
+ if (nextPlacement) {
2067
+ // Try next placement and re-run the lifecycle.
2068
+ return {
2069
+ data: {
2070
+ index: nextIndex,
2071
+ overflows: overflowsData
2072
+ },
2073
+ reset: {
2074
+ placement: nextPlacement
2075
+ }
2076
+ };
2077
+ }
2078
+
2079
+ // First, find the candidates that fit on the mainAxis side of overflow,
2080
+ // then find the placement that fits the best on the main crossAxis side.
2081
+ 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;
2082
+
2083
+ // Otherwise fallback.
2084
+ if (!resetPlacement) {
2085
+ switch (fallbackStrategy) {
2086
+ case 'bestFit':
2087
+ {
2088
+ var _overflowsData$map$so;
2089
+ const placement = (_overflowsData$map$so = overflowsData.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$map$so[0];
2090
+ if (placement) {
2091
+ resetPlacement = placement;
2092
+ }
2093
+ break;
2094
+ }
2095
+ case 'initialPlacement':
2096
+ resetPlacement = initialPlacement;
2097
+ break;
2098
+ }
2099
+ }
2100
+ if (placement !== resetPlacement) {
2101
+ return {
2102
+ reset: {
2103
+ placement: resetPlacement
2104
+ }
2105
+ };
2106
+ }
2107
+ }
2108
+ return {};
2109
+ }
2110
+ };
2111
+ };
2112
+
2113
+ function getSideOffsets(overflow, rect) {
2114
+ return {
2115
+ top: overflow.top - rect.height,
2116
+ right: overflow.right - rect.width,
2117
+ bottom: overflow.bottom - rect.height,
2118
+ left: overflow.left - rect.width
2119
+ };
2120
+ }
2121
+ function isAnySideFullyClipped(overflow) {
2122
+ return sides.some(side => overflow[side] >= 0);
2123
+ }
2124
+ /**
2125
+ * Provides data to hide the floating element in applicable situations, such as
2126
+ * when it is not in the same clipping context as the reference element.
2127
+ * @see https://floating-ui.com/docs/hide
2128
+ */
2129
+ const hide = function (options) {
2130
+ if (options === void 0) {
2131
+ options = {};
2132
+ }
2133
+ return {
2134
+ name: 'hide',
2135
+ options,
2136
+ async fn(state) {
2137
+ const {
2138
+ rects
2139
+ } = state;
2140
+ const {
2141
+ strategy = 'referenceHidden',
2142
+ ...detectOverflowOptions
2143
+ } = evaluate(options, state);
2144
+ switch (strategy) {
2145
+ case 'referenceHidden':
2146
+ {
2147
+ const overflow = await detectOverflow(state, {
2148
+ ...detectOverflowOptions,
2149
+ elementContext: 'reference'
2150
+ });
2151
+ const offsets = getSideOffsets(overflow, rects.reference);
2152
+ return {
2153
+ data: {
2154
+ referenceHiddenOffsets: offsets,
2155
+ referenceHidden: isAnySideFullyClipped(offsets)
2156
+ }
2157
+ };
2158
+ }
2159
+ case 'escaped':
2160
+ {
2161
+ const overflow = await detectOverflow(state, {
2162
+ ...detectOverflowOptions,
2163
+ altBoundary: true
2164
+ });
2165
+ const offsets = getSideOffsets(overflow, rects.floating);
2166
+ return {
2167
+ data: {
2168
+ escapedOffsets: offsets,
2169
+ escaped: isAnySideFullyClipped(offsets)
2170
+ }
2171
+ };
2172
+ }
2173
+ default:
2174
+ {
2175
+ return {};
2176
+ }
2177
+ }
2178
+ }
2179
+ };
2180
+ };
2181
+
2182
+ function getBoundingRect(rects) {
2183
+ const minX = min(...rects.map(rect => rect.left));
2184
+ const minY = min(...rects.map(rect => rect.top));
2185
+ const maxX = max(...rects.map(rect => rect.right));
2186
+ const maxY = max(...rects.map(rect => rect.bottom));
2187
+ return {
2188
+ x: minX,
2189
+ y: minY,
2190
+ width: maxX - minX,
2191
+ height: maxY - minY
2192
+ };
2193
+ }
2194
+ function getRectsByLine(rects) {
2195
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
2196
+ const groups = [];
2197
+ let prevRect = null;
2198
+ for (let i = 0; i < sortedRects.length; i++) {
2199
+ const rect = sortedRects[i];
2200
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
2201
+ groups.push([rect]);
2202
+ } else {
2203
+ groups[groups.length - 1].push(rect);
2204
+ }
2205
+ prevRect = rect;
2206
+ }
2207
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
2208
+ }
2209
+ /**
2210
+ * Provides improved positioning for inline reference elements that can span
2211
+ * over multiple lines, such as hyperlinks or range selections.
2212
+ * @see https://floating-ui.com/docs/inline
2213
+ */
2214
+ const inline$1 = function (options) {
2215
+ if (options === void 0) {
2216
+ options = {};
2217
+ }
2218
+ return {
2219
+ name: 'inline',
2220
+ options,
2221
+ async fn(state) {
2222
+ const {
2223
+ placement,
2224
+ elements,
2225
+ rects,
2226
+ platform,
2227
+ strategy
2228
+ } = state;
2229
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
2230
+ // ClientRect's bounds, despite the event listener being triggered. A
2231
+ // padding of 2 seems to handle this issue.
2232
+ const {
2233
+ padding = 2,
2234
+ x,
2235
+ y
2236
+ } = evaluate(options, state);
2237
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
2238
+ const clientRects = getRectsByLine(nativeClientRects);
2239
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
2240
+ const paddingObject = getPaddingObject(padding);
2241
+ function getBoundingClientRect() {
2242
+ // There are two rects and they are disjoined.
2243
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
2244
+ // Find the first rect in which the point is fully inside.
2245
+ 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;
2246
+ }
2247
+
2248
+ // There are 2 or more connected rects.
2249
+ if (clientRects.length >= 2) {
2250
+ if (getSideAxis(placement) === 'y') {
2251
+ const firstRect = clientRects[0];
2252
+ const lastRect = clientRects[clientRects.length - 1];
2253
+ const isTop = getSide(placement) === 'top';
2254
+ const top = firstRect.top;
2255
+ const bottom = lastRect.bottom;
2256
+ const left = isTop ? firstRect.left : lastRect.left;
2257
+ const right = isTop ? firstRect.right : lastRect.right;
2258
+ const width = right - left;
2259
+ const height = bottom - top;
2260
+ return {
2261
+ top,
2262
+ bottom,
2263
+ left,
2264
+ right,
2265
+ width,
2266
+ height,
2267
+ x: left,
2268
+ y: top
2269
+ };
2270
+ }
2271
+ const isLeftSide = getSide(placement) === 'left';
2272
+ const maxRight = max(...clientRects.map(rect => rect.right));
2273
+ const minLeft = min(...clientRects.map(rect => rect.left));
2274
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
2275
+ const top = measureRects[0].top;
2276
+ const bottom = measureRects[measureRects.length - 1].bottom;
2277
+ const left = minLeft;
2278
+ const right = maxRight;
2279
+ const width = right - left;
2280
+ const height = bottom - top;
2281
+ return {
2282
+ top,
2283
+ bottom,
2284
+ left,
2285
+ right,
2286
+ width,
2287
+ height,
2288
+ x: left,
2289
+ y: top
2290
+ };
2291
+ }
2292
+ return fallback;
2293
+ }
2294
+ const resetRects = await platform.getElementRects({
2295
+ reference: {
2296
+ getBoundingClientRect
2297
+ },
2298
+ floating: elements.floating,
2299
+ strategy
2300
+ });
2301
+ 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) {
2302
+ return {
2303
+ reset: {
2304
+ rects: resetRects
2305
+ }
2306
+ };
2307
+ }
2308
+ return {};
2309
+ }
2310
+ };
2311
+ };
2312
+
2313
+ // For type backwards-compatibility, the `OffsetOptions` type was also
2314
+ // Derivable.
2315
+
2316
+ async function convertValueToCoords(state, options) {
2317
+ const {
2318
+ placement,
2319
+ platform,
2320
+ elements
2321
+ } = state;
2322
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2323
+ const side = getSide(placement);
2324
+ const alignment = getAlignment(placement);
2325
+ const isVertical = getSideAxis(placement) === 'y';
2326
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
2327
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
2328
+ const rawValue = evaluate(options, state);
2329
+ let {
2330
+ mainAxis,
2331
+ crossAxis,
2332
+ alignmentAxis
2333
+ } = typeof rawValue === 'number' ? {
2334
+ mainAxis: rawValue,
2335
+ crossAxis: 0,
2336
+ alignmentAxis: null
2337
+ } : {
2338
+ mainAxis: 0,
2339
+ crossAxis: 0,
2340
+ alignmentAxis: null,
2341
+ ...rawValue
2342
+ };
2343
+ if (alignment && typeof alignmentAxis === 'number') {
2344
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
2345
+ }
2346
+ return isVertical ? {
2347
+ x: crossAxis * crossAxisMulti,
2348
+ y: mainAxis * mainAxisMulti
2349
+ } : {
2350
+ x: mainAxis * mainAxisMulti,
2351
+ y: crossAxis * crossAxisMulti
2352
+ };
2353
+ }
2354
+
2355
+ /**
2356
+ * Modifies the placement by translating the floating element along the
2357
+ * specified axes.
2358
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2359
+ * object may be passed.
2360
+ * @see https://floating-ui.com/docs/offset
2361
+ */
2362
+ const offset$1 = function (options) {
2363
+ if (options === void 0) {
2364
+ options = 0;
2365
+ }
2366
+ return {
2367
+ name: 'offset',
2368
+ options,
2369
+ async fn(state) {
2370
+ var _middlewareData$offse, _middlewareData$arrow;
2371
+ const {
2372
+ x,
2373
+ y,
2374
+ placement,
2375
+ middlewareData
2376
+ } = state;
2377
+ const diffCoords = await convertValueToCoords(state, options);
2378
+
2379
+ // If the placement is the same and the arrow caused an alignment offset
2380
+ // then we don't need to change the positioning coordinates.
2381
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2382
+ return {};
2383
+ }
2384
+ return {
2385
+ x: x + diffCoords.x,
2386
+ y: y + diffCoords.y,
2387
+ data: {
2388
+ ...diffCoords,
2389
+ placement
2390
+ }
2391
+ };
2392
+ }
2393
+ };
2394
+ };
2395
+
2396
+ /**
2397
+ * Optimizes the visibility of the floating element by shifting it in order to
2398
+ * keep it in view when it will overflow the clipping boundary.
2399
+ * @see https://floating-ui.com/docs/shift
2400
+ */
2401
+ const shift$1 = function (options) {
2402
+ if (options === void 0) {
2403
+ options = {};
2404
+ }
2405
+ return {
2406
+ name: 'shift',
2407
+ options,
2408
+ async fn(state) {
2409
+ const {
2410
+ x,
2411
+ y,
2412
+ placement
2413
+ } = state;
2414
+ const {
2415
+ mainAxis: checkMainAxis = true,
2416
+ crossAxis: checkCrossAxis = false,
2417
+ limiter = {
2418
+ fn: _ref => {
2419
+ let {
2420
+ x,
2421
+ y
2422
+ } = _ref;
2423
+ return {
2424
+ x,
2425
+ y
2426
+ };
2427
+ }
2428
+ },
2429
+ ...detectOverflowOptions
2430
+ } = evaluate(options, state);
2431
+ const coords = {
2432
+ x,
2433
+ y
2434
+ };
2435
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2436
+ const crossAxis = getSideAxis(getSide(placement));
2437
+ const mainAxis = getOppositeAxis(crossAxis);
2438
+ let mainAxisCoord = coords[mainAxis];
2439
+ let crossAxisCoord = coords[crossAxis];
2440
+ if (checkMainAxis) {
2441
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
2442
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2443
+ const min = mainAxisCoord + overflow[minSide];
2444
+ const max = mainAxisCoord - overflow[maxSide];
2445
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
2446
+ }
2447
+ if (checkCrossAxis) {
2448
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
2449
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2450
+ const min = crossAxisCoord + overflow[minSide];
2451
+ const max = crossAxisCoord - overflow[maxSide];
2452
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
2453
+ }
2454
+ const limitedCoords = limiter.fn({
2455
+ ...state,
2456
+ [mainAxis]: mainAxisCoord,
2457
+ [crossAxis]: crossAxisCoord
2458
+ });
2459
+ return {
2460
+ ...limitedCoords,
2461
+ data: {
2462
+ x: limitedCoords.x - x,
2463
+ y: limitedCoords.y - y
2464
+ }
2465
+ };
2466
+ }
2467
+ };
2468
+ };
2469
+ /**
2470
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2471
+ */
2472
+ const limitShift$1 = function (options) {
2473
+ if (options === void 0) {
2474
+ options = {};
2475
+ }
2476
+ return {
2477
+ options,
2478
+ fn(state) {
2479
+ const {
2480
+ x,
2481
+ y,
2482
+ placement,
2483
+ rects,
2484
+ middlewareData
2485
+ } = state;
2486
+ const {
2487
+ offset = 0,
2488
+ mainAxis: checkMainAxis = true,
2489
+ crossAxis: checkCrossAxis = true
2490
+ } = evaluate(options, state);
2491
+ const coords = {
2492
+ x,
2493
+ y
2494
+ };
2495
+ const crossAxis = getSideAxis(placement);
2496
+ const mainAxis = getOppositeAxis(crossAxis);
2497
+ let mainAxisCoord = coords[mainAxis];
2498
+ let crossAxisCoord = coords[crossAxis];
2499
+ const rawOffset = evaluate(offset, state);
2500
+ const computedOffset = typeof rawOffset === 'number' ? {
2501
+ mainAxis: rawOffset,
2502
+ crossAxis: 0
2503
+ } : {
2504
+ mainAxis: 0,
2505
+ crossAxis: 0,
2506
+ ...rawOffset
2507
+ };
2508
+ if (checkMainAxis) {
2509
+ const len = mainAxis === 'y' ? 'height' : 'width';
2510
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2511
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2512
+ if (mainAxisCoord < limitMin) {
2513
+ mainAxisCoord = limitMin;
2514
+ } else if (mainAxisCoord > limitMax) {
2515
+ mainAxisCoord = limitMax;
2516
+ }
2517
+ }
2518
+ if (checkCrossAxis) {
2519
+ var _middlewareData$offse, _middlewareData$offse2;
2520
+ const len = mainAxis === 'y' ? 'width' : 'height';
2521
+ const isOriginSide = ['top', 'left'].includes(getSide(placement));
2522
+ 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);
2523
+ 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);
2524
+ if (crossAxisCoord < limitMin) {
2525
+ crossAxisCoord = limitMin;
2526
+ } else if (crossAxisCoord > limitMax) {
2527
+ crossAxisCoord = limitMax;
2528
+ }
2529
+ }
2530
+ return {
2531
+ [mainAxis]: mainAxisCoord,
2532
+ [crossAxis]: crossAxisCoord
2533
+ };
2534
+ }
2535
+ };
2536
+ };
2537
+
2538
+ /**
2539
+ * Provides data that allows you to change the size of the floating element —
2540
+ * for instance, prevent it from overflowing the clipping boundary or match the
2541
+ * width of the reference element.
2542
+ * @see https://floating-ui.com/docs/size
2543
+ */
2544
+ const size$1 = function (options) {
2545
+ if (options === void 0) {
2546
+ options = {};
2547
+ }
2548
+ return {
2549
+ name: 'size',
2550
+ options,
2551
+ async fn(state) {
2552
+ const {
2553
+ placement,
2554
+ rects,
2555
+ platform,
2556
+ elements
2557
+ } = state;
2558
+ const {
2559
+ apply = () => {},
2560
+ ...detectOverflowOptions
2561
+ } = evaluate(options, state);
2562
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2563
+ const side = getSide(placement);
2564
+ const alignment = getAlignment(placement);
2565
+ const isYAxis = getSideAxis(placement) === 'y';
2566
+ const {
2567
+ width,
2568
+ height
2569
+ } = rects.floating;
2570
+ let heightSide;
2571
+ let widthSide;
2572
+ if (side === 'top' || side === 'bottom') {
2573
+ heightSide = side;
2574
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
2575
+ } else {
2576
+ widthSide = side;
2577
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
2578
+ }
2579
+ const overflowAvailableHeight = height - overflow[heightSide];
2580
+ const overflowAvailableWidth = width - overflow[widthSide];
2581
+ const noShift = !state.middlewareData.shift;
2582
+ let availableHeight = overflowAvailableHeight;
2583
+ let availableWidth = overflowAvailableWidth;
2584
+ if (isYAxis) {
2585
+ const maximumClippingWidth = width - overflow.left - overflow.right;
2586
+ availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
2587
+ } else {
2588
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
2589
+ availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
2590
+ }
2591
+ if (noShift && !alignment) {
2592
+ const xMin = max(overflow.left, 0);
2593
+ const xMax = max(overflow.right, 0);
2594
+ const yMin = max(overflow.top, 0);
2595
+ const yMax = max(overflow.bottom, 0);
2596
+ if (isYAxis) {
2597
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
2598
+ } else {
2599
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
2600
+ }
2601
+ }
2602
+ await apply({
2603
+ ...state,
2604
+ availableWidth,
2605
+ availableHeight
2606
+ });
2607
+ const nextDimensions = await platform.getDimensions(elements.floating);
2608
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
2609
+ return {
2610
+ reset: {
2611
+ rects: true
2612
+ }
2613
+ };
2614
+ }
2615
+ return {};
2616
+ }
2617
+ };
2618
+ };
2619
+
2620
+ function hasWindow() {
2621
+ return typeof window !== 'undefined';
2622
+ }
2623
+ function getNodeName(node) {
2624
+ if (isNode(node)) {
2625
+ return (node.nodeName || '').toLowerCase();
2626
+ }
2627
+ // Mocked nodes in testing environments may not be instances of Node. By
2628
+ // returning `#document` an infinite loop won't occur.
2629
+ // https://github.com/floating-ui/floating-ui/issues/2317
2630
+ return '#document';
2631
+ }
2632
+ function getWindow(node) {
2633
+ var _node$ownerDocument;
2634
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2635
+ }
2636
+ function getDocumentElement(node) {
2637
+ var _ref;
2638
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2639
+ }
2640
+ function isNode(value) {
2641
+ if (!hasWindow()) {
2642
+ return false;
2643
+ }
2644
+ return value instanceof Node || value instanceof getWindow(value).Node;
2645
+ }
2646
+ function isElement(value) {
2647
+ if (!hasWindow()) {
2648
+ return false;
2649
+ }
2650
+ return value instanceof Element || value instanceof getWindow(value).Element;
2651
+ }
2652
+ function isHTMLElement(value) {
2653
+ if (!hasWindow()) {
2654
+ return false;
2655
+ }
2656
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2657
+ }
2658
+ function isShadowRoot(value) {
2659
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
2660
+ return false;
2661
+ }
2662
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2663
+ }
2664
+ function isOverflowElement(element) {
2665
+ const {
2666
+ overflow,
2667
+ overflowX,
2668
+ overflowY,
2669
+ display
2670
+ } = getComputedStyle$1(element);
2671
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
2672
+ }
2673
+ function isTableElement(element) {
2674
+ return ['table', 'td', 'th'].includes(getNodeName(element));
2675
+ }
2676
+ function isTopLayer(element) {
2677
+ return [':popover-open', ':modal'].some(selector => {
2678
+ try {
2679
+ return element.matches(selector);
2680
+ } catch (e) {
2681
+ return false;
2682
+ }
2683
+ });
2684
+ }
2685
+ function isContainingBlock(elementOrCss) {
2686
+ const webkit = isWebKit();
2687
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2688
+
2689
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2690
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
2691
+ 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));
2692
+ }
2693
+ function getContainingBlock(element) {
2694
+ let currentNode = getParentNode(element);
2695
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2696
+ if (isContainingBlock(currentNode)) {
2697
+ return currentNode;
2698
+ } else if (isTopLayer(currentNode)) {
2699
+ return null;
2700
+ }
2701
+ currentNode = getParentNode(currentNode);
2702
+ }
2703
+ return null;
2704
+ }
2705
+ function isWebKit() {
2706
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
2707
+ return CSS.supports('-webkit-backdrop-filter', 'none');
2708
+ }
2709
+ function isLastTraversableNode(node) {
2710
+ return ['html', 'body', '#document'].includes(getNodeName(node));
2711
+ }
2712
+ function getComputedStyle$1(element) {
2713
+ return getWindow(element).getComputedStyle(element);
2714
+ }
2715
+ function getNodeScroll(element) {
2716
+ if (isElement(element)) {
2717
+ return {
2718
+ scrollLeft: element.scrollLeft,
2719
+ scrollTop: element.scrollTop
2720
+ };
2721
+ }
2722
+ return {
2723
+ scrollLeft: element.scrollX,
2724
+ scrollTop: element.scrollY
2725
+ };
2726
+ }
2727
+ function getParentNode(node) {
2728
+ if (getNodeName(node) === 'html') {
2729
+ return node;
2730
+ }
2731
+ const result =
2732
+ // Step into the shadow DOM of the parent of a slotted node.
2733
+ node.assignedSlot ||
2734
+ // DOM Element detected.
2735
+ node.parentNode ||
2736
+ // ShadowRoot detected.
2737
+ isShadowRoot(node) && node.host ||
2738
+ // Fallback.
2739
+ getDocumentElement(node);
2740
+ return isShadowRoot(result) ? result.host : result;
2741
+ }
2742
+ function getNearestOverflowAncestor(node) {
2743
+ const parentNode = getParentNode(node);
2744
+ if (isLastTraversableNode(parentNode)) {
2745
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
2746
+ }
2747
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2748
+ return parentNode;
2749
+ }
2750
+ return getNearestOverflowAncestor(parentNode);
2751
+ }
2752
+ function getOverflowAncestors(node, list, traverseIframes) {
2753
+ var _node$ownerDocument2;
2754
+ if (list === void 0) {
2755
+ list = [];
2756
+ }
2757
+ if (traverseIframes === void 0) {
2758
+ traverseIframes = true;
2759
+ }
2760
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2761
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2762
+ const win = getWindow(scrollableAncestor);
2763
+ if (isBody) {
2764
+ const frameElement = getFrameElement(win);
2765
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2766
+ }
2767
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2768
+ }
2769
+ function getFrameElement(win) {
2770
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2771
+ }
2772
+
2773
+ function getCssDimensions(element) {
2774
+ const css = getComputedStyle$1(element);
2775
+ // In testing environments, the `width` and `height` properties are empty
2776
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2777
+ let width = parseFloat(css.width) || 0;
2778
+ let height = parseFloat(css.height) || 0;
2779
+ const hasOffset = isHTMLElement(element);
2780
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2781
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2782
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2783
+ if (shouldFallback) {
2784
+ width = offsetWidth;
2785
+ height = offsetHeight;
2786
+ }
2787
+ return {
2788
+ width,
2789
+ height,
2790
+ $: shouldFallback
2791
+ };
2792
+ }
2793
+
2794
+ function unwrapElement(element) {
2795
+ return !isElement(element) ? element.contextElement : element;
2796
+ }
2797
+
2798
+ function getScale(element) {
2799
+ const domElement = unwrapElement(element);
2800
+ if (!isHTMLElement(domElement)) {
2801
+ return createCoords(1);
2802
+ }
2803
+ const rect = domElement.getBoundingClientRect();
2804
+ const {
2805
+ width,
2806
+ height,
2807
+ $
2808
+ } = getCssDimensions(domElement);
2809
+ let x = ($ ? round(rect.width) : rect.width) / width;
2810
+ let y = ($ ? round(rect.height) : rect.height) / height;
2811
+
2812
+ // 0, NaN, or Infinity should always fallback to 1.
2813
+
2814
+ if (!x || !Number.isFinite(x)) {
2815
+ x = 1;
2816
+ }
2817
+ if (!y || !Number.isFinite(y)) {
2818
+ y = 1;
2819
+ }
2820
+ return {
2821
+ x,
2822
+ y
2823
+ };
2824
+ }
2825
+
2826
+ const noOffsets = /*#__PURE__*/createCoords(0);
2827
+ function getVisualOffsets(element) {
2828
+ const win = getWindow(element);
2829
+ if (!isWebKit() || !win.visualViewport) {
2830
+ return noOffsets;
2831
+ }
2832
+ return {
2833
+ x: win.visualViewport.offsetLeft,
2834
+ y: win.visualViewport.offsetTop
2835
+ };
2836
+ }
2837
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2838
+ if (isFixed === void 0) {
2839
+ isFixed = false;
2840
+ }
2841
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2842
+ return false;
2843
+ }
2844
+ return isFixed;
2845
+ }
2846
+
2847
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2848
+ if (includeScale === void 0) {
2849
+ includeScale = false;
2850
+ }
2851
+ if (isFixedStrategy === void 0) {
2852
+ isFixedStrategy = false;
2853
+ }
2854
+ const clientRect = element.getBoundingClientRect();
2855
+ const domElement = unwrapElement(element);
2856
+ let scale = createCoords(1);
2857
+ if (includeScale) {
2858
+ if (offsetParent) {
2859
+ if (isElement(offsetParent)) {
2860
+ scale = getScale(offsetParent);
2861
+ }
2862
+ } else {
2863
+ scale = getScale(element);
2864
+ }
2865
+ }
2866
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2867
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
2868
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
2869
+ let width = clientRect.width / scale.x;
2870
+ let height = clientRect.height / scale.y;
2871
+ if (domElement) {
2872
+ const win = getWindow(domElement);
2873
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2874
+ let currentWin = win;
2875
+ let currentIFrame = getFrameElement(currentWin);
2876
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2877
+ const iframeScale = getScale(currentIFrame);
2878
+ const iframeRect = currentIFrame.getBoundingClientRect();
2879
+ const css = getComputedStyle$1(currentIFrame);
2880
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2881
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2882
+ x *= iframeScale.x;
2883
+ y *= iframeScale.y;
2884
+ width *= iframeScale.x;
2885
+ height *= iframeScale.y;
2886
+ x += left;
2887
+ y += top;
2888
+ currentWin = getWindow(currentIFrame);
2889
+ currentIFrame = getFrameElement(currentWin);
2890
+ }
2891
+ }
2892
+ return rectToClientRect({
2893
+ width,
2894
+ height,
2895
+ x,
2896
+ y
2897
+ });
2898
+ }
2899
+
2900
+ // If <html> has a CSS width greater than the viewport, then this will be
2901
+ // incorrect for RTL.
2902
+ function getWindowScrollBarX(element, rect) {
2903
+ const leftScroll = getNodeScroll(element).scrollLeft;
2904
+ if (!rect) {
2905
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2906
+ }
2907
+ return rect.left + leftScroll;
2908
+ }
2909
+
2910
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
2911
+ if (ignoreScrollbarX === void 0) {
2912
+ ignoreScrollbarX = false;
2913
+ }
2914
+ const htmlRect = documentElement.getBoundingClientRect();
2915
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
2916
+ // RTL <body> scrollbar.
2917
+ getWindowScrollBarX(documentElement, htmlRect));
2918
+ const y = htmlRect.top + scroll.scrollTop;
2919
+ return {
2920
+ x,
2921
+ y
2922
+ };
2923
+ }
2924
+
2925
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2926
+ let {
2927
+ elements,
2928
+ rect,
2929
+ offsetParent,
2930
+ strategy
2931
+ } = _ref;
2932
+ const isFixed = strategy === 'fixed';
2933
+ const documentElement = getDocumentElement(offsetParent);
2934
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2935
+ if (offsetParent === documentElement || topLayer && isFixed) {
2936
+ return rect;
2937
+ }
2938
+ let scroll = {
2939
+ scrollLeft: 0,
2940
+ scrollTop: 0
2941
+ };
2942
+ let scale = createCoords(1);
2943
+ const offsets = createCoords(0);
2944
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2945
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2946
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2947
+ scroll = getNodeScroll(offsetParent);
2948
+ }
2949
+ if (isHTMLElement(offsetParent)) {
2950
+ const offsetRect = getBoundingClientRect(offsetParent);
2951
+ scale = getScale(offsetParent);
2952
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2953
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2954
+ }
2955
+ }
2956
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
2957
+ return {
2958
+ width: rect.width * scale.x,
2959
+ height: rect.height * scale.y,
2960
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
2961
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
2962
+ };
2963
+ }
2964
+
2965
+ function getClientRects(element) {
2966
+ return Array.from(element.getClientRects());
2967
+ }
2968
+
2969
+ // Gets the entire size of the scrollable document area, even extending outside
2970
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2971
+ function getDocumentRect(element) {
2972
+ const html = getDocumentElement(element);
2973
+ const scroll = getNodeScroll(element);
2974
+ const body = element.ownerDocument.body;
2975
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2976
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2977
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2978
+ const y = -scroll.scrollTop;
2979
+ if (getComputedStyle$1(body).direction === 'rtl') {
2980
+ x += max(html.clientWidth, body.clientWidth) - width;
2981
+ }
2982
+ return {
2983
+ width,
2984
+ height,
2985
+ x,
2986
+ y
2987
+ };
2988
+ }
2989
+
2990
+ function getViewportRect(element, strategy) {
2991
+ const win = getWindow(element);
2992
+ const html = getDocumentElement(element);
2993
+ const visualViewport = win.visualViewport;
2994
+ let width = html.clientWidth;
2995
+ let height = html.clientHeight;
2996
+ let x = 0;
2997
+ let y = 0;
2998
+ if (visualViewport) {
2999
+ width = visualViewport.width;
3000
+ height = visualViewport.height;
3001
+ const visualViewportBased = isWebKit();
3002
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
3003
+ x = visualViewport.offsetLeft;
3004
+ y = visualViewport.offsetTop;
3005
+ }
3006
+ }
3007
+ return {
3008
+ width,
3009
+ height,
3010
+ x,
3011
+ y
3012
+ };
3013
+ }
3014
+
3015
+ // Returns the inner client rect, subtracting scrollbars if present.
3016
+ function getInnerBoundingClientRect(element, strategy) {
3017
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
3018
+ const top = clientRect.top + element.clientTop;
3019
+ const left = clientRect.left + element.clientLeft;
3020
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
3021
+ const width = element.clientWidth * scale.x;
3022
+ const height = element.clientHeight * scale.y;
3023
+ const x = left * scale.x;
3024
+ const y = top * scale.y;
3025
+ return {
3026
+ width,
3027
+ height,
3028
+ x,
3029
+ y
3030
+ };
3031
+ }
3032
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
3033
+ let rect;
3034
+ if (clippingAncestor === 'viewport') {
3035
+ rect = getViewportRect(element, strategy);
3036
+ } else if (clippingAncestor === 'document') {
3037
+ rect = getDocumentRect(getDocumentElement(element));
3038
+ } else if (isElement(clippingAncestor)) {
3039
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
3040
+ } else {
3041
+ const visualOffsets = getVisualOffsets(element);
3042
+ rect = {
3043
+ x: clippingAncestor.x - visualOffsets.x,
3044
+ y: clippingAncestor.y - visualOffsets.y,
3045
+ width: clippingAncestor.width,
3046
+ height: clippingAncestor.height
3047
+ };
3048
+ }
3049
+ return rectToClientRect(rect);
3050
+ }
3051
+ function hasFixedPositionAncestor(element, stopNode) {
3052
+ const parentNode = getParentNode(element);
3053
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
3054
+ return false;
3055
+ }
3056
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
3057
+ }
3058
+
3059
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
3060
+ // clipping (or hiding) child elements. This returns all clipping ancestors
3061
+ // of the given element up the tree.
3062
+ function getClippingElementAncestors(element, cache) {
3063
+ const cachedResult = cache.get(element);
3064
+ if (cachedResult) {
3065
+ return cachedResult;
3066
+ }
3067
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
3068
+ let currentContainingBlockComputedStyle = null;
3069
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
3070
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
3071
+
3072
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
3073
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
3074
+ const computedStyle = getComputedStyle$1(currentNode);
3075
+ const currentNodeIsContaining = isContainingBlock(currentNode);
3076
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
3077
+ currentContainingBlockComputedStyle = null;
3078
+ }
3079
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
3080
+ if (shouldDropCurrentNode) {
3081
+ // Drop non-containing blocks.
3082
+ result = result.filter(ancestor => ancestor !== currentNode);
3083
+ } else {
3084
+ // Record last containing block for next iteration.
3085
+ currentContainingBlockComputedStyle = computedStyle;
3086
+ }
3087
+ currentNode = getParentNode(currentNode);
3088
+ }
3089
+ cache.set(element, result);
3090
+ return result;
3091
+ }
3092
+
3093
+ // Gets the maximum area that the element is visible in due to any number of
3094
+ // clipping ancestors.
3095
+ function getClippingRect(_ref) {
3096
+ let {
3097
+ element,
3098
+ boundary,
3099
+ rootBoundary,
3100
+ strategy
3101
+ } = _ref;
3102
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
3103
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
3104
+ const firstClippingAncestor = clippingAncestors[0];
3105
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
3106
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
3107
+ accRect.top = max(rect.top, accRect.top);
3108
+ accRect.right = min(rect.right, accRect.right);
3109
+ accRect.bottom = min(rect.bottom, accRect.bottom);
3110
+ accRect.left = max(rect.left, accRect.left);
3111
+ return accRect;
3112
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
3113
+ return {
3114
+ width: clippingRect.right - clippingRect.left,
3115
+ height: clippingRect.bottom - clippingRect.top,
3116
+ x: clippingRect.left,
3117
+ y: clippingRect.top
3118
+ };
3119
+ }
3120
+
3121
+ function getDimensions(element) {
3122
+ const {
3123
+ width,
3124
+ height
3125
+ } = getCssDimensions(element);
3126
+ return {
3127
+ width,
3128
+ height
3129
+ };
3130
+ }
3131
+
3132
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
3133
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
3134
+ const documentElement = getDocumentElement(offsetParent);
3135
+ const isFixed = strategy === 'fixed';
3136
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
3137
+ let scroll = {
3138
+ scrollLeft: 0,
3139
+ scrollTop: 0
3140
+ };
3141
+ const offsets = createCoords(0);
3142
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3143
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
3144
+ scroll = getNodeScroll(offsetParent);
3145
+ }
3146
+ if (isOffsetParentAnElement) {
3147
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
3148
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
3149
+ offsets.y = offsetRect.y + offsetParent.clientTop;
3150
+ } else if (documentElement) {
3151
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
3152
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
3153
+ offsets.x = getWindowScrollBarX(documentElement);
3154
+ }
3155
+ }
3156
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
3157
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
3158
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
3159
+ return {
3160
+ x,
3161
+ y,
3162
+ width: rect.width,
3163
+ height: rect.height
3164
+ };
3165
+ }
3166
+
3167
+ function isStaticPositioned(element) {
3168
+ return getComputedStyle$1(element).position === 'static';
3169
+ }
3170
+
3171
+ function getTrueOffsetParent(element, polyfill) {
3172
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
3173
+ return null;
3174
+ }
3175
+ if (polyfill) {
3176
+ return polyfill(element);
3177
+ }
3178
+ let rawOffsetParent = element.offsetParent;
3179
+
3180
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
3181
+ // while Chrome and Safari return the <body> element. The <body> element must
3182
+ // be used to perform the correct calculations even if the <html> element is
3183
+ // non-static.
3184
+ if (getDocumentElement(element) === rawOffsetParent) {
3185
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
3186
+ }
3187
+ return rawOffsetParent;
3188
+ }
3189
+
3190
+ // Gets the closest ancestor positioned element. Handles some edge cases,
3191
+ // such as table ancestors and cross browser bugs.
3192
+ function getOffsetParent(element, polyfill) {
3193
+ const win = getWindow(element);
3194
+ if (isTopLayer(element)) {
3195
+ return win;
3196
+ }
3197
+ if (!isHTMLElement(element)) {
3198
+ let svgOffsetParent = getParentNode(element);
3199
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
3200
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
3201
+ return svgOffsetParent;
3202
+ }
3203
+ svgOffsetParent = getParentNode(svgOffsetParent);
3204
+ }
3205
+ return win;
3206
+ }
3207
+ let offsetParent = getTrueOffsetParent(element, polyfill);
3208
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
3209
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
3210
+ }
3211
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
3212
+ return win;
3213
+ }
3214
+ return offsetParent || getContainingBlock(element) || win;
3215
+ }
3216
+
3217
+ const getElementRects = async function (data) {
3218
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
3219
+ const getDimensionsFn = this.getDimensions;
3220
+ const floatingDimensions = await getDimensionsFn(data.floating);
3221
+ return {
3222
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
3223
+ floating: {
3224
+ x: 0,
3225
+ y: 0,
3226
+ width: floatingDimensions.width,
3227
+ height: floatingDimensions.height
3228
+ }
3229
+ };
3230
+ };
3231
+
3232
+ function isRTL(element) {
3233
+ return getComputedStyle$1(element).direction === 'rtl';
3234
+ }
3235
+
3236
+ const platform = {
3237
+ convertOffsetParentRelativeRectToViewportRelativeRect,
3238
+ getDocumentElement,
3239
+ getClippingRect,
3240
+ getOffsetParent,
3241
+ getElementRects,
3242
+ getClientRects,
3243
+ getDimensions,
3244
+ getScale,
3245
+ isElement,
3246
+ isRTL
3247
+ };
3248
+
3249
+ function rectsAreEqual(a, b) {
3250
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
3251
+ }
3252
+
3253
+ // https://samthor.au/2021/observing-dom/
3254
+ function observeMove(element, onMove) {
3255
+ let io = null;
3256
+ let timeoutId;
3257
+ const root = getDocumentElement(element);
3258
+ function cleanup() {
3259
+ var _io;
3260
+ clearTimeout(timeoutId);
3261
+ (_io = io) == null || _io.disconnect();
3262
+ io = null;
3263
+ }
3264
+ function refresh(skip, threshold) {
3265
+ if (skip === void 0) {
3266
+ skip = false;
3267
+ }
3268
+ if (threshold === void 0) {
3269
+ threshold = 1;
3270
+ }
3271
+ cleanup();
3272
+ const elementRectForRootMargin = element.getBoundingClientRect();
3273
+ const {
3274
+ left,
3275
+ top,
3276
+ width,
3277
+ height
3278
+ } = elementRectForRootMargin;
3279
+ if (!skip) {
3280
+ onMove();
3281
+ }
3282
+ if (!width || !height) {
3283
+ return;
3284
+ }
3285
+ const insetTop = floor(top);
3286
+ const insetRight = floor(root.clientWidth - (left + width));
3287
+ const insetBottom = floor(root.clientHeight - (top + height));
3288
+ const insetLeft = floor(left);
3289
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
3290
+ const options = {
3291
+ rootMargin,
3292
+ threshold: max(0, min(1, threshold)) || 1
3293
+ };
3294
+ let isFirstUpdate = true;
3295
+ function handleObserve(entries) {
3296
+ const ratio = entries[0].intersectionRatio;
3297
+ if (ratio !== threshold) {
3298
+ if (!isFirstUpdate) {
3299
+ return refresh();
3300
+ }
3301
+ if (!ratio) {
3302
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
3303
+ // to prevent an infinite loop of updates.
3304
+ timeoutId = setTimeout(() => {
3305
+ refresh(false, 1e-7);
3306
+ }, 1000);
3307
+ } else {
3308
+ refresh(false, ratio);
3309
+ }
3310
+ }
3311
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
3312
+ // It's possible that even though the ratio is reported as 1, the
3313
+ // element is not actually fully within the IntersectionObserver's root
3314
+ // area anymore. This can happen under performance constraints. This may
3315
+ // be a bug in the browser's IntersectionObserver implementation. To
3316
+ // work around this, we compare the element's bounding rect now with
3317
+ // what it was at the time we created the IntersectionObserver. If they
3318
+ // are not equal then the element moved, so we refresh.
3319
+ refresh();
3320
+ }
3321
+ isFirstUpdate = false;
3322
+ }
3323
+
3324
+ // Older browsers don't support a `document` as the root and will throw an
3325
+ // error.
3326
+ try {
3327
+ io = new IntersectionObserver(handleObserve, {
3328
+ ...options,
3329
+ // Handle <iframe>s
3330
+ root: root.ownerDocument
3331
+ });
3332
+ } catch (e) {
3333
+ io = new IntersectionObserver(handleObserve, options);
3334
+ }
3335
+ io.observe(element);
3336
+ }
3337
+ refresh(true);
3338
+ return cleanup;
3339
+ }
3340
+
3341
+ /**
3342
+ * Automatically updates the position of the floating element when necessary.
3343
+ * Should only be called when the floating element is mounted on the DOM or
3344
+ * visible on the screen.
3345
+ * @returns cleanup function that should be invoked when the floating element is
3346
+ * removed from the DOM or hidden from the screen.
3347
+ * @see https://floating-ui.com/docs/autoUpdate
3348
+ */
3349
+ function autoUpdate(reference, floating, update, options) {
3350
+ if (options === void 0) {
3351
+ options = {};
3352
+ }
3353
+ const {
3354
+ ancestorScroll = true,
3355
+ ancestorResize = true,
3356
+ elementResize = typeof ResizeObserver === 'function',
3357
+ layoutShift = typeof IntersectionObserver === 'function',
3358
+ animationFrame = false
3359
+ } = options;
3360
+ const referenceEl = unwrapElement(reference);
3361
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
3362
+ ancestors.forEach(ancestor => {
3363
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
3364
+ passive: true
3365
+ });
3366
+ ancestorResize && ancestor.addEventListener('resize', update);
3367
+ });
3368
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
3369
+ let reobserveFrame = -1;
3370
+ let resizeObserver = null;
3371
+ if (elementResize) {
3372
+ resizeObserver = new ResizeObserver(_ref => {
3373
+ let [firstEntry] = _ref;
3374
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
3375
+ // Prevent update loops when using the `size` middleware.
3376
+ // https://github.com/floating-ui/floating-ui/issues/1740
3377
+ resizeObserver.unobserve(floating);
3378
+ cancelAnimationFrame(reobserveFrame);
3379
+ reobserveFrame = requestAnimationFrame(() => {
3380
+ var _resizeObserver;
3381
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
3382
+ });
3383
+ }
3384
+ update();
3385
+ });
3386
+ if (referenceEl && !animationFrame) {
3387
+ resizeObserver.observe(referenceEl);
3388
+ }
3389
+ resizeObserver.observe(floating);
3390
+ }
3391
+ let frameId;
3392
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
3393
+ if (animationFrame) {
3394
+ frameLoop();
3395
+ }
3396
+ function frameLoop() {
3397
+ const nextRefRect = getBoundingClientRect(reference);
3398
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
3399
+ update();
3400
+ }
3401
+ prevRefRect = nextRefRect;
3402
+ frameId = requestAnimationFrame(frameLoop);
3403
+ }
3404
+ update();
3405
+ return () => {
3406
+ var _resizeObserver2;
3407
+ ancestors.forEach(ancestor => {
3408
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
3409
+ ancestorResize && ancestor.removeEventListener('resize', update);
3410
+ });
3411
+ cleanupIo == null || cleanupIo();
3412
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
3413
+ resizeObserver = null;
3414
+ if (animationFrame) {
3415
+ cancelAnimationFrame(frameId);
3416
+ }
3417
+ };
3418
+ }
3419
+
3420
+ /**
3421
+ * Modifies the placement by translating the floating element along the
3422
+ * specified axes.
3423
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
3424
+ * object may be passed.
3425
+ * @see https://floating-ui.com/docs/offset
3426
+ */
3427
+ const offset = offset$1;
3428
+
3429
+ /**
3430
+ * Optimizes the visibility of the floating element by choosing the placement
3431
+ * that has the most space available automatically, without needing to specify a
3432
+ * preferred placement. Alternative to `flip`.
3433
+ * @see https://floating-ui.com/docs/autoPlacement
3434
+ */
3435
+ autoPlacement;
3436
+
3437
+ /**
3438
+ * Optimizes the visibility of the floating element by shifting it in order to
3439
+ * keep it in view when it will overflow the clipping boundary.
3440
+ * @see https://floating-ui.com/docs/shift
3441
+ */
3442
+ const shift = shift$1;
3443
+
3444
+ /**
3445
+ * Optimizes the visibility of the floating element by flipping the `placement`
3446
+ * in order to keep it in view when the preferred placement(s) will overflow the
3447
+ * clipping boundary. Alternative to `autoPlacement`.
3448
+ * @see https://floating-ui.com/docs/flip
3449
+ */
3450
+ const flip = flip$1;
3451
+
3452
+ /**
3453
+ * Provides data that allows you to change the size of the floating element —
3454
+ * for instance, prevent it from overflowing the clipping boundary or match the
3455
+ * width of the reference element.
3456
+ * @see https://floating-ui.com/docs/size
3457
+ */
3458
+ const size = size$1;
3459
+
3460
+ /**
3461
+ * Provides data to hide the floating element in applicable situations, such as
3462
+ * when it is not in the same clipping context as the reference element.
3463
+ * @see https://floating-ui.com/docs/hide
3464
+ */
3465
+ hide;
3466
+
3467
+ /**
3468
+ * Provides data to position an inner element of the floating element so that it
3469
+ * appears centered to the reference element.
3470
+ * @see https://floating-ui.com/docs/arrow
3471
+ */
3472
+ const arrow = arrow$1;
3473
+
3474
+ /**
3475
+ * Provides improved positioning for inline reference elements that can span
3476
+ * over multiple lines, such as hyperlinks or range selections.
3477
+ * @see https://floating-ui.com/docs/inline
3478
+ */
3479
+ const inline = inline$1;
3480
+
3481
+ /**
3482
+ * Built-in `limiter` that will stop `shift()` at a certain point.
3483
+ */
3484
+ const limitShift = limitShift$1;
3485
+
3486
+ /**
3487
+ * Computes the `x` and `y` coordinates that will place the floating element
3488
+ * next to a given reference element.
3489
+ */
3490
+ const computePosition = (reference, floating, options) => {
3491
+ // This caches the expensive `getClippingElementAncestors` function so that
3492
+ // multiple lifecycle resets re-use the same result. It only lives for a
3493
+ // single call. If other functions become expensive, we can add them as well.
3494
+ const cache = new Map();
3495
+ const mergedOptions = {
3496
+ platform,
3497
+ ...options
3498
+ };
3499
+ const platformWithCache = {
3500
+ ...mergedOptions.platform,
3501
+ _c: cache
3502
+ };
3503
+ return computePosition$1(reference, floating, {
3504
+ ...mergedOptions,
3505
+ platform: platformWithCache
3506
+ });
3507
+ };
3508
+
3509
+ (()=>{var c=class extends Event{oldState;newState;constructor(t,{oldState:o="",newState:r="",...i}={}){super(t,i),this.oldState=String(o||""),this.newState=String(r||"");}},R=new WeakMap;function A(e,t,o){R.set(e,setTimeout(()=>{R.has(e)&&e.dispatchEvent(new c("toggle",{cancelable:!1,oldState:t,newState:o}));},0));}var D=globalThis.ShadowRoot||function(){},z=globalThis.HTMLDialogElement||function(){},M=new WeakMap,p=new WeakMap,h=new WeakMap;function L(e){return h.get(e)||"hidden"}var b=new WeakMap;function O(e){let t=e.popoverTargetElement;if(!(t instanceof HTMLElement))return;let o=L(t);e.popoverTargetAction==="show"&&o==="showing"||e.popoverTargetAction==="hide"&&o==="hidden"||(o==="showing"?m(t,!0,!0):d(t,!1)&&(b.set(t,e),S(t)));}function d(e,t){return !(e.popover!=="auto"&&e.popover!=="manual"||!e.isConnected||t&&L(e)!=="showing"||!t&&L(e)!=="hidden"||e instanceof z&&e.hasAttribute("open")||document.fullscreenElement===e)}function N(e){return e?Array.from(p.get(e.ownerDocument)||[]).indexOf(e)+1:0}function V(e){let t=W(e),o=U(e);return N(t)>N(o)?t:o}function y(e){let t=p.get(e);for(let o of t||[])if(!o.isConnected)t.delete(o);else return o;return null}function v(e){return typeof e.getRootNode=="function"?e.getRootNode():e.parentNode?v(e.parentNode):e}function W(e){for(;e;){if(e instanceof HTMLElement&&e.popover==="auto"&&h.get(e)==="showing")return e;if(e=e.parentElement||v(e),e instanceof D&&(e=e.host),e instanceof Document)return}}function U(e){for(;e;){let t=e.popoverTargetElement;if(t instanceof HTMLElement)return t;if(e=e.parentElement||v(e),e instanceof D&&(e=e.host),e instanceof Document)return}}function G(e){let t=new Map,o=0,r=e.ownerDocument;for(let a of p.get(r)||[])t.set(a,o),o+=1;t.set(e,o),o+=1;let i=null;function l(a){let g=W(a);if(g===null)return null;let n=t.get(g);(i===null||t.get(i)<n)&&(i=g);}return l(e?.parentElement),i}function Q(e){return e.hidden||e instanceof D||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement||e instanceof HTMLFieldSetElement)&&e.disabled||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&e.href===""?!1:typeof e.tabIndex=="number"&&e.tabIndex!==-1}function _(e){if(e.shadowRoot&&e.shadowRoot.delegatesFocus!==!0)return null;let t=e;t.shadowRoot&&(t=t.shadowRoot);let o=t.querySelector("[autofocus]");if(o)return o;{let l=t.querySelectorAll("slot");for(let a of l){let g=a.assignedElements({flatten:!0});for(let n of g){if(n.hasAttribute("autofocus"))return n;if(o=n.querySelector("[autofocus]"),o)return o}}}let r=e.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),i=r.currentNode;for(;i;){if(Q(i))return i;i=r.nextNode();}}function $(e){_(e)?.focus();}var H=new WeakMap;function S(e){if(!d(e,!1))return;let t=e.ownerDocument;if(!e.dispatchEvent(new c("beforetoggle",{cancelable:!0,oldState:"closed",newState:"open"}))||!d(e,!1))return;let o=!1;if(e.popover==="auto"){let i=e.getAttribute("popover"),l=G(e)||t;if(T(l,!1,!0),i!==e.getAttribute("popover")||!d(e,!1))return}y(t)||(o=!0),H.delete(e);let r=t.activeElement;e.classList.add(":popover-open"),h.set(e,"showing"),M.has(t)||M.set(t,new Set),M.get(t).add(e),$(e),e.popover==="auto"&&(p.has(t)||p.set(t,new Set),p.get(t).add(e),q(b.get(e),!0)),o&&r&&e.popover==="auto"&&H.set(e,r),A(e,"closed","open");}function m(e,t=!1,o=!1){if(!d(e,!0))return;let r=e.ownerDocument;if(e.popover==="auto"&&(T(e,t,o),!d(e,!0))||(q(b.get(e),!1),b.delete(e),o&&(e.dispatchEvent(new c("beforetoggle",{oldState:"open",newState:"closed"})),!d(e,!0))))return;M.get(r)?.delete(e),p.get(r)?.delete(e),e.classList.remove(":popover-open"),h.set(e,"hidden"),o&&A(e,"open","closed");let i=H.get(e);i&&(H.delete(e),t&&i.focus());}function F(e,t=!1,o=!1){let r=y(e);for(;r;)m(r,t,o),r=y(e);}function T(e,t,o){let r=e.ownerDocument||e;if(e instanceof Document)return F(r,t,o);let i=null,l=!1;for(let a of p.get(r)||[])if(a===e)l=!0;else if(l){i=a;break}if(!l)return F(r,t,o);for(;i&&L(i)==="showing"&&p.get(r)?.size;)m(i,t,o);}var P=new WeakMap;function x(e){if(!e.isTrusted)return;let t=e.composedPath()[0];if(!t)return;let o=t.ownerDocument;if(!y(o))return;let i=V(t);if(i&&e.type==="pointerdown")P.set(o,i);else if(e.type==="pointerup"){let l=P.get(o)===i;P.delete(o),l&&T(i||o,!1,!0);}}var k=new WeakMap;function q(e,t=!1){if(!e)return;k.has(e)||k.set(e,e.getAttribute("aria-expanded"));let o=e.popoverTargetElement;if(o instanceof HTMLElement&&o.popover==="auto")e.setAttribute("aria-expanded",String(t));else {let r=k.get(e);r?e.setAttribute("aria-expanded",r):e.removeAttribute("aria-expanded");}}var B=globalThis.ShadowRoot||function(){};function j(){return typeof HTMLElement<"u"&&typeof HTMLElement.prototype=="object"&&"popover"in HTMLElement.prototype}function f(e,t,o){let r=e[t];Object.defineProperty(e,t,{value(i){return r.call(this,o(i))}});}var J=/(^|[^\\]):popover-open\b/g,C=`
3510
+ :where([popover]) {
3511
+ position: fixed;
3512
+ z-index: 2147483647;
3513
+ inset: 0;
3514
+ padding: 0.25em;
3515
+ width: fit-content;
3516
+ height: fit-content;
3517
+ border-width: initial;
3518
+ border-color: initial;
3519
+ border-image: initial;
3520
+ border-style: solid;
3521
+ background-color: canvas;
3522
+ color: canvastext;
3523
+ overflow: auto;
3524
+ margin: auto;
3525
+ }
3526
+
3527
+ :where(dialog[popover][open]) {
3528
+ display: revert;
3529
+ }
3530
+
3531
+ :where([anchor].\\:popover-open) {
3532
+ inset: auto;
3533
+ }
3534
+
3535
+ :where([anchor]:popover-open) {
3536
+ inset: auto;
3537
+ }
3538
+
3539
+ @supports not (background-color: canvas) {
3540
+ :where([popover]) {
3541
+ background-color: white;
3542
+ color: black;
3543
+ }
3544
+ }
3545
+
3546
+ @supports (width: -moz-fit-content) {
3547
+ :where([popover]) {
3548
+ width: -moz-fit-content;
3549
+ height: -moz-fit-content;
3550
+ }
3551
+ }
3552
+
3553
+ @supports not (inset: 0) {
3554
+ :where([popover]) {
3555
+ top: 0;
3556
+ left: 0;
3557
+ right: 0;
3558
+ bottom: 0;
3559
+ }
3560
+ }
3561
+
3562
+ :where([popover]:not(.\\:popover-open)) {
3563
+ display: none;
3564
+ }
3565
+ `,E=null;function I(e){if(E===null)try{E=new CSSStyleSheet,E.replaceSync(C);}catch{E=!1;}if(E===!1){let t=document.createElement("style");t.textContent=C,e instanceof Document?e.head.prepend(t):e.prepend(t);}else e.adoptedStyleSheets=[E,...e.adoptedStyleSheets];}function K(){window.ToggleEvent=window.ToggleEvent||c;function e(n){return n?.includes(":popover-open")&&(n=n.replace(J,"$1.\\:popover-open")),n}f(Document.prototype,"querySelector",e),f(Document.prototype,"querySelectorAll",e),f(Element.prototype,"querySelector",e),f(Element.prototype,"querySelectorAll",e),f(Element.prototype,"matches",e),f(Element.prototype,"closest",e),f(DocumentFragment.prototype,"querySelectorAll",e),f(DocumentFragment.prototype,"querySelectorAll",e),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if(!this.hasAttribute("popover"))return null;let n=(this.getAttribute("popover")||"").toLowerCase();return n===""||n=="auto"?"auto":"manual"},set(n){this.setAttribute("popover",n);}},showPopover:{enumerable:!0,configurable:!0,value(){S(this);}},hidePopover:{enumerable:!0,configurable:!0,value(){m(this,!0,!0);}},togglePopover:{enumerable:!0,configurable:!0,value(n){h.get(this)==="showing"&&n===void 0||n===!1?m(this,!0,!0):(n===void 0||n===!0)&&S(this);}}});let t=Element.prototype.attachShadow;t&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(n){let s=t.call(this,n);return I(s),s}}});let o=HTMLElement.prototype.attachInternals;o&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){let n=o.call(this);return n.shadowRoot&&I(n.shadowRoot),n}}});let r=new WeakMap;function i(n){Object.defineProperties(n.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(s){if(s===null)this.removeAttribute("popovertarget"),r.delete(this);else if(s instanceof Element)this.setAttribute("popovertarget",""),r.set(this,s);else throw new TypeError("popoverTargetElement must be an element or null")},get(){if(this.localName!=="button"&&this.localName!=="input"||this.localName==="input"&&this.type!=="reset"&&this.type!=="image"&&this.type!=="button"||this.disabled||this.form&&this.type==="submit")return null;let s=r.get(this);if(s&&s.isConnected)return s;if(s&&!s.isConnected)return r.delete(this),null;let u=v(this),w=this.getAttribute("popovertarget");return (u instanceof Document||u instanceof B)&&w&&u.getElementById(w)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){let s=(this.getAttribute("popovertargetaction")||"").toLowerCase();return s==="show"||s==="hide"?s:"toggle"},set(s){this.setAttribute("popovertargetaction",s);}}});}i(HTMLButtonElement),i(HTMLInputElement);let l=n=>{if(!n.isTrusted)return;let s=n.composedPath()[0];if(!(s instanceof Element)||s?.shadowRoot)return;let u=v(s);if(!(u instanceof B||u instanceof Document))return;let w=s.closest("[popovertargetaction],[popovertarget]");if(w){O(w),n.preventDefault();return}},a=n=>{let s=n.key,u=n.target;!n.defaultPrevented&&u&&(s==="Escape"||s==="Esc")&&T(u.ownerDocument,!0,!0);};(n=>{n.addEventListener("click",l),n.addEventListener("keydown",a),n.addEventListener("pointerdown",x),n.addEventListener("pointerup",x);})(document),I(document);}j()||K();})();
3566
+
3567
+ const postPopovercontainerCss = "@layer polyfill{@supports not selector(:popover-open){[popover]:not(.\\:popover-open){display:none}}}:where(post-popovercontainer){background-color:rgba(0,0,0,0);border:rgba(0,0,0,0);position:fixed;z-index:1060;margin:0;padding:0;overflow:visible}:where(post-popovercontainer)>div{box-shadow:var(--post-device-elevation-300);width:max-content;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)[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(--safe-space-cursor-x, 0) var(--safe-space-cursor-y, 0), var(--safe-space-popover-x-start, var(--safe-space-popover-x, 0)) var(--safe-space-popover-y, var(--safe-space-popover-y-start, 0)), var(--safe-space-popover-x-end, var(--safe-space-popover-x, 0)) var(--safe-space-popover-y, var(--safe-space-popover-y-end, 0)))}:where(post-popovercontainer)[safe-space=trapezoid]::after{clip-path:polygon(var(--safe-space-trigger-x-start, var(--safe-space-trigger-x, 0)) var(--safe-space-trigger-y, var(--safe-space-trigger-y-start, 0)), var(--safe-space-trigger-x-end, var(--safe-space-trigger-x, 0)) var(--safe-space-trigger-y, var(--safe-space-trigger-y-end, 0)), var(--safe-space-popover-x-end, var(--safe-space-popover-x, 0)) var(--safe-space-popover-y, var(--safe-space-popover-y-end, 0)), var(--safe-space-popover-x-start, var(--safe-space-popover-x, 0)) var(--safe-space-popover-y, var(--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-left:2px solid rgba(0,0,0,0);border-top:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.right{border-right:2px solid rgba(0,0,0,0);border-top:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.left{border-left:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.bottom{border-right:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}";
3568
+ const PostPopovercontainerStyle0 = postPopovercontainerCss;
3569
+
3570
+ const PostPopovercontainer = class {
3571
+ constructor(hostRef) {
3572
+ index.registerInstance(this, hostRef);
3573
+ this.postToggle = index.createEvent(this, "postToggle", 7);
3574
+ this.manualClose = false;
3575
+ this.placement = 'top';
3576
+ this.edgeGap = 8;
3577
+ this.arrow = false;
3578
+ this.safeSpace = undefined;
3579
+ }
3580
+ static STATIC_SIDES = {
3581
+ top: 'bottom',
3582
+ right: 'left',
3583
+ bottom: 'top',
3584
+ left: 'right',
3585
+ };
3586
+ static PROPERTIES_TO_CLEAR = [
3587
+ '--safe-space-popover-x',
3588
+ '--safe-space-popover-y',
3589
+ '--safe-space-popover-x-start',
3590
+ '--safe-space-popover-x-end',
3591
+ '--safe-space-popover-y-start',
3592
+ '--safe-space-popover-y-end',
3593
+ '--safe-space-trigger-x',
3594
+ '--safe-space-trigger-y',
3595
+ '--safe-space-trigger-x-start',
3596
+ '--safe-space-trigger-x-end',
3597
+ '--safe-space-trigger-y-start',
3598
+ '--safe-space-trigger-y-end',
3599
+ ];
3600
+ get host() { return index.getElement(this); }
3601
+ arrowRef;
3602
+ eventTarget;
3603
+ clearAutoUpdate;
3604
+ toggleTimeoutId;
3605
+ /**
3606
+ * Fires whenever the popover gets shown or hidden, passing the new state in event.details as a boolean
3607
+ */
3608
+ postToggle;
3609
+ /**
3610
+ * Updates cursor position for safe space feature when popover is open.
3611
+ * Sets CSS custom properties for dynamic styling of safe area.
3612
+ * @param event MouseEvent with cursor position
3613
+ */
3614
+ mouseTrackingHandler(event) {
3615
+ this.host.style.setProperty('--safe-space-cursor-x', `${event.clientX}px`);
3616
+ this.host.style.setProperty('--safe-space-cursor-y', `${event.clientY}px`);
3617
+ }
3618
+ componentDidLoad() {
3619
+ this.host.addEventListener('beforetoggle', this.handleToggle.bind(this));
3620
+ }
3621
+ disconnectedCallback() {
3622
+ if (typeof this.clearAutoUpdate === 'function') {
3623
+ this.clearAutoUpdate();
3624
+ }
3625
+ }
3626
+ /**
3627
+ * Programmatically display the tooltip
3628
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
3629
+ */
3630
+ async show(target) {
3631
+ if (!this.toggleTimeoutId) {
3632
+ this.eventTarget = target;
3633
+ this.calculatePosition();
3634
+ this.host.showPopover();
3635
+ }
3636
+ }
3637
+ /**
3638
+ * Programmatically hide this tooltip
3639
+ */
3640
+ async hide() {
3641
+ if (!this.toggleTimeoutId) {
3642
+ this.eventTarget = null;
3643
+ this.host.hidePopover();
3644
+ }
3645
+ }
3646
+ /**
3647
+ * Toggle tooltip display
3648
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
3649
+ * @param force Pass true to always show or false to always hide
3650
+ */
3651
+ async toggle(target, force) {
3652
+ // Prevent instant double toggle
3653
+ if (!this.toggleTimeoutId) {
3654
+ this.eventTarget = target;
3655
+ this.calculatePosition();
3656
+ this.host.togglePopover(force);
3657
+ this.toggleTimeoutId = null;
3658
+ }
3659
+ return this.host.matches(':where(:popover-open, .popover-open)');
3660
+ }
3661
+ /**
3662
+ * Start or stop auto updates based on tooltip events.
3663
+ * Tooltips can be closed or opened with other methods than class members,
3664
+ * therefore listening to the toggle event is safer for cleaning up.
3665
+ * @param e ToggleEvent
3666
+ */
3667
+ handleToggle(e) {
3668
+ this.toggleTimeoutId = window.setTimeout(() => (this.toggleTimeoutId = null), 10);
3669
+ const isOpen = e.newState === 'open';
3670
+ if (isOpen) {
3671
+ this.startAutoupdates();
3672
+ if (this.safeSpace)
3673
+ window.addEventListener('mousemove', this.mouseTrackingHandler.bind(this));
3674
+ }
3675
+ else {
3676
+ if (typeof this.clearAutoUpdate === 'function')
3677
+ this.clearAutoUpdate();
3678
+ if (this.safeSpace)
3679
+ window.removeEventListener('mousemove', this.mouseTrackingHandler.bind(this));
3680
+ }
3681
+ this.postToggle.emit(isOpen);
3682
+ }
3683
+ /**
3684
+ * Start listening for DOM updates, scroll events etc. that have
3685
+ * an influence on tooltip positioning
3686
+ */
3687
+ startAutoupdates() {
3688
+ this.clearAutoUpdate = autoUpdate(this.eventTarget, this.host, this.calculatePosition.bind(this));
3689
+ }
3690
+ async calculatePosition() {
3691
+ const { x, y, middlewareData, placement } = await this.computeMainPosition();
3692
+ const currentPlacement = placement.split('-')[0];
3693
+ // Position popover
3694
+ this.host.style.left = `${x}px`;
3695
+ this.host.style.top = `${y}px`;
3696
+ // Position arrow if enabled
3697
+ if (this.arrow && middlewareData.arrow) {
3698
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
3699
+ const staticSide = PostPopovercontainer.STATIC_SIDES[currentPlacement];
3700
+ if (staticSide) {
3701
+ Object.assign(this.arrowRef.style, {
3702
+ left: arrowX ? `${arrowX}px` : '',
3703
+ top: arrowY ? `${arrowY}px` : '',
3704
+ [staticSide]: '-7px',
3705
+ });
3706
+ }
3707
+ }
3708
+ // Handle safe space if enabled
3709
+ if (this.safeSpace && this.eventTarget) {
3710
+ await this.updateSafeSpaceBoundaries(currentPlacement);
3711
+ }
3712
+ }
3713
+ async computeMainPosition() {
3714
+ const gap = this.edgeGap;
3715
+ const middleware = [
3716
+ flip(),
3717
+ inline(),
3718
+ shift({
3719
+ padding: gap,
3720
+ limiter: limitShift({
3721
+ offset: 32,
3722
+ }),
3723
+ }),
3724
+ size({
3725
+ apply({ availableWidth, elements }) {
3726
+ Object.assign(elements.floating.style, {
3727
+ maxWidth: `${availableWidth - gap * 2}px`,
3728
+ });
3729
+ },
3730
+ }),
3731
+ offset(this.arrow ? gap + 4 : gap),
3732
+ ];
3733
+ if (this.arrow) {
3734
+ middleware.push(arrow({ element: this.arrowRef, padding: gap }));
3735
+ }
3736
+ return computePosition(this.eventTarget, this.host, {
3737
+ placement: this.placement || 'top',
3738
+ strategy: 'fixed',
3739
+ middleware,
3740
+ });
3741
+ }
3742
+ async updateSafeSpaceBoundaries(currentPlacement) {
3743
+ const targetRect = this.eventTarget.getBoundingClientRect();
3744
+ const popoverRect = this.host.getBoundingClientRect();
3745
+ const isVertical = currentPlacement === 'top' || currentPlacement === 'bottom';
3746
+ // Helper function to get positioning data based on placement
3747
+ const getPositioningData = (placement, popoverRect, targetRect) => {
3748
+ if (placement === 'top' || placement === 'bottom') {
3749
+ return {
3750
+ popover: {
3751
+ y: placement === 'top' ? popoverRect.bottom : popoverRect.top,
3752
+ xStart: popoverRect.left,
3753
+ xEnd: popoverRect.right,
3754
+ },
3755
+ trigger: {
3756
+ y: placement === 'top' ? targetRect.top : targetRect.bottom,
3757
+ xStart: targetRect.left,
3758
+ xEnd: targetRect.right,
3759
+ },
3760
+ };
3761
+ }
3762
+ else {
3763
+ // left or right
3764
+ return {
3765
+ popover: {
3766
+ x: placement === 'left' ? popoverRect.right : popoverRect.left,
3767
+ yStart: popoverRect.top,
3768
+ yEnd: popoverRect.bottom,
3769
+ },
3770
+ trigger: {
3771
+ x: placement === 'left' ? targetRect.left : targetRect.right,
3772
+ yStart: targetRect.top,
3773
+ yEnd: targetRect.bottom,
3774
+ },
3775
+ };
3776
+ }
3777
+ };
3778
+ const posData = getPositioningData(currentPlacement, popoverRect, targetRect);
3779
+ // Clear previous values
3780
+ PostPopovercontainer.PROPERTIES_TO_CLEAR.forEach(prop => {
3781
+ this.host.style.removeProperty(prop);
3782
+ });
3783
+ if (isVertical) {
3784
+ // For top/bottom placement
3785
+ this.host.style.setProperty('--safe-space-popover-y', `${posData.popover.y}px`);
3786
+ this.host.style.setProperty('--safe-space-popover-x-start', `${posData.popover.xStart}px`);
3787
+ this.host.style.setProperty('--safe-space-popover-x-end', `${posData.popover.xEnd}px`);
3788
+ this.host.style.setProperty('--safe-space-trigger-y', `${posData.trigger.y}px`);
3789
+ this.host.style.setProperty('--safe-space-trigger-x-start', `${posData.trigger.xStart}px`);
3790
+ this.host.style.setProperty('--safe-space-trigger-x-end', `${posData.trigger.xEnd}px`);
3791
+ }
3792
+ else {
3793
+ // For left/right placement
3794
+ this.host.style.setProperty('--safe-space-popover-x', `${posData.popover.x}px`);
3795
+ this.host.style.setProperty('--safe-space-popover-y-start', `${posData.popover.yStart}px`);
3796
+ this.host.style.setProperty('--safe-space-popover-y-end', `${posData.popover.yEnd}px`);
3797
+ this.host.style.setProperty('--safe-space-trigger-x', `${posData.trigger.x}px`);
3798
+ this.host.style.setProperty('--safe-space-trigger-y-start', `${posData.trigger.yStart}px`);
3799
+ this.host.style.setProperty('--safe-space-trigger-y-end', `${posData.trigger.yEnd}px`);
3800
+ }
3801
+ }
3802
+ render() {
3803
+ return (index.h(index.Host, { key: '2d04c94fe2a6de0c0fe17c1e2dcb99481d13336b', "data-version": _package.version, popover: this.manualClose ? 'manual' : 'auto' }, index.h("div", { key: '3653be7880e5b896ae85e97ad709838732032f2d' }, this.arrow && (index.h("span", { key: '770f1727acf0ccb47e3940d034850df9fc3a6096', class: "arrow", ref: el => {
3804
+ this.arrowRef = el;
3805
+ } })), index.h("slot", { key: 'b12e95d51accec79a08fda3970f3b46ba7147ed7' }))));
3806
+ }
3807
+ };
3808
+ PostPopovercontainer.style = PostPopovercontainerStyle0;
3809
+
3810
+ 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}";
3811
+ const PostTogglebuttonStyle0 = postTogglebuttonCss;
3812
+
3813
+ const PostTogglebutton = class {
3814
+ constructor(hostRef) {
3815
+ index.registerInstance(this, hostRef);
3816
+ this.toggled = false;
3817
+ }
3818
+ get host() { return index.getElement(this); }
3819
+ validateToggled() {
3820
+ checkType.checkType(this, 'toggled', 'boolean');
3821
+ }
3822
+ componentWillLoad() {
3823
+ this.validateToggled();
3824
+ // add event listener to not override listener that might be set on the host
3825
+ this.host.addEventListener('click', () => this.handleClick());
3826
+ this.host.addEventListener('keydown', (e) => this.handleKeydown(e));
3827
+ }
3828
+ handleClick = () => {
3829
+ this.toggled = !this.toggled;
3830
+ };
3831
+ handleKeydown = (event) => {
3832
+ // perform a click when enter or spaced are pressed to mimic the button behavior
3833
+ if (event.key === 'Enter' || event.key === ' ') {
3834
+ event.preventDefault(); // prevents the page from scrolling when space is pressed
3835
+ this.host.click();
3836
+ }
3837
+ };
3838
+ render() {
3839
+ 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' })));
3840
+ }
3841
+ static get watchers() { return {
3842
+ "toggled": ["validateToggled"]
3843
+ }; }
3844
+ };
3845
+ PostTogglebutton.style = PostTogglebuttonStyle0;
3846
+
3847
+ exports.PostClosebutton = PostClosebutton;
3848
+ exports.PostHeader = PostHeader;
3849
+ exports.PostIcon = PostIcon;
3850
+ exports.PostLanguageOption = PostLanguageOption;
3851
+ exports.PostLanguageSwitch = PostLanguageSwitch;
3852
+ exports.PostList = PostList;
3853
+ exports.PostListItem = PostListItem;
3854
+ exports.PostLogo = PostLogo;
3855
+ exports.PostMainnavigation = PostMainnavigation;
3856
+ exports.PostMegadropdown = PostMegadropdown;
3857
+ exports.PostMegadropdownTrigger = PostMegadropdownTrigger;
3858
+ exports.PostMenu = PostMenu;
3859
+ exports.PostMenuTrigger = PostMenuTrigger;
3860
+ exports.PostPopovercontainer = PostPopovercontainer;
3861
+ exports.PostTogglebutton = PostTogglebutton;