@luzmo/lucero 1.0.1-alpha.14 → 1.0.1-alpha.16

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 (275) hide show
  1. package/components/accordion/index.cjs +183 -6
  2. package/components/accordion/index.js +136 -88
  3. package/components/action-bar/index.cjs +85 -4
  4. package/components/action-bar/index.js +72 -50
  5. package/components/action-button/index.cjs +205 -3
  6. package/components/action-button/index.js +167 -93
  7. package/components/action-group/index.cjs +7 -1
  8. package/components/action-group/index.js +12 -8
  9. package/components/action-group-DHp8RHDf.js +392 -0
  10. package/components/action-group-MPf19RPV.cjs +391 -0
  11. package/components/action-menu/index.cjs +91 -11
  12. package/components/action-menu/index.js +66 -47
  13. package/components/avatar/index.cjs +63 -3
  14. package/components/avatar/index.js +54 -42
  15. package/components/base-COw9n7UR.cjs +119 -0
  16. package/components/base-DmeVy0cq.js +120 -0
  17. package/components/button/index.cjs +134 -2
  18. package/components/button/index.js +106 -72
  19. package/components/button-base-7Ak55xFd.cjs +206 -0
  20. package/components/button-base-C3kf6BTK.js +207 -0
  21. package/components/button-group/index.cjs +45 -1
  22. package/components/button-group/index.js +37 -25
  23. package/components/calendar/index.cjs +632 -1
  24. package/components/calendar/index.js +637 -7
  25. package/components/checkbox/index.cjs +111 -4
  26. package/components/checkbox/index.js +98 -53
  27. package/components/checkbox-mixin-8cL-vfDy.js +84 -0
  28. package/components/checkbox-mixin-CE7dJj3J.cjs +83 -0
  29. package/components/clear-button-Co6oKSgl.js +59 -0
  30. package/components/clear-button-X_HDY2eH.cjs +58 -0
  31. package/components/close-button-DPBK6Kpu.cjs +59 -0
  32. package/components/close-button-Miw9ZjoJ.js +60 -0
  33. package/components/color-area/index.cjs +440 -13
  34. package/components/color-area/index.js +322 -187
  35. package/components/color-controller-BjDZaxhX.js +491 -0
  36. package/components/color-controller-C3c_vb2P.cjs +490 -0
  37. package/components/color-field/index.cjs +95 -2
  38. package/components/color-field/index.js +77 -41
  39. package/components/color-handle/index.cjs +64 -3
  40. package/components/color-handle/index.js +58 -37
  41. package/components/color-loupe/index.cjs +7 -1
  42. package/components/color-loupe/index.js +12 -8
  43. package/components/color-loupe-BQqNR8YD.cjs +88 -0
  44. package/components/color-loupe-B_DDFv8l.js +89 -0
  45. package/components/color-menu/index.cjs +217 -12
  46. package/components/color-menu/index.js +187 -93
  47. package/components/color-palette/index.cjs +89 -1
  48. package/components/color-palette/index.js +78 -51
  49. package/components/color-palette-group/index.cjs +259 -3
  50. package/components/color-palette-group/index.js +193 -105
  51. package/components/color-picker/index.cjs +114 -6
  52. package/components/color-picker/index.js +92 -72
  53. package/components/color-slider/index.cjs +585 -1
  54. package/components/color-slider/index.js +590 -7
  55. package/components/{directive-oAbCiebi.js → condition-attribute-with-id-Cn815e9W.js} +22 -22
  56. package/components/condition-attribute-with-id-DEc2Yjne.cjs +43 -0
  57. package/components/date-time-picker/index.cjs +1357 -31
  58. package/components/date-time-picker/index.js +951 -637
  59. package/components/dependency-manger-CcIE1uvQ.cjs +63 -0
  60. package/components/{dependency-manger-CEXvGQUV.js → dependency-manger-XHpQjFgK.js} +24 -14
  61. package/components/divider/index.cjs +54 -1
  62. package/components/divider/index.js +49 -30
  63. package/components/divider.module-Cm5LcDRV.cjs +20 -0
  64. package/components/divider.module-DauH6k2_.js +21 -0
  65. package/components/element-resolution-DCsrhGZO.cjs +112 -0
  66. package/components/element-resolution-nMlmW4Jy.js +113 -0
  67. package/components/field-group/index.cjs +7 -1
  68. package/components/field-group/index.js +12 -8
  69. package/components/field-group-DNmY8W9v.cjs +86 -0
  70. package/components/field-group-DVdAWCQF.js +87 -0
  71. package/components/field-label/index.cjs +7 -1
  72. package/components/field-label/index.js +12 -8
  73. package/components/field-label-CKH9EXpR.cjs +156 -0
  74. package/components/field-label-Dpsecoc6.js +157 -0
  75. package/components/focus-group-BqDAk9Is.js +337 -0
  76. package/components/focus-group-DFzOlalL.cjs +336 -0
  77. package/components/focus-visible-B-B8-P9R.cjs +104 -0
  78. package/components/focus-visible-BUPRWlsh.js +105 -0
  79. package/components/focusable-BPrTcZPd.cjs +262 -0
  80. package/components/focusable-ChCLg1k4.js +263 -0
  81. package/components/{directive-C7oCP5Bh.cjs → focusable-selectors-D0t_5P7C.cjs} +16 -5
  82. package/components/{focusable-selectors-B4YgbghQ.js → focusable-selectors-IltOAOd9.js} +7 -4
  83. package/components/icon/index.cjs +90 -1
  84. package/components/icon/index.js +74 -46
  85. package/components/index.cjs +174 -1
  86. package/components/index.js +174 -172
  87. package/components/infield-button/index.cjs +46 -2
  88. package/components/infield-button/index.js +41 -30
  89. package/components/label/index.cjs +37 -1
  90. package/components/label/index.js +36 -24
  91. package/components/{language-resolution-8yZa5r_P.js → language-resolution-BSGJAWiQ.js} +21 -16
  92. package/components/language-resolution-iN9EImbb.cjs +57 -0
  93. package/components/like-anchor-D62faRNG.cjs +79 -0
  94. package/components/like-anchor-v3cJ9RWM.js +80 -0
  95. package/components/manage-help-text-BYx84zZR.cjs +125 -0
  96. package/components/manage-help-text-DOuMTGht.js +126 -0
  97. package/components/menu/index.cjs +1297 -29
  98. package/components/menu/index.js +954 -499
  99. package/components/multi-language-field/index.cjs +132 -2
  100. package/components/multi-language-field/index.js +118 -88
  101. package/components/number-field/index.cjs +613 -10
  102. package/components/number-field/index.js +442 -243
  103. package/components/observe-slot-presence-9AwLGUQ_.cjs +78 -0
  104. package/components/observe-slot-presence-DcMdoumP.js +79 -0
  105. package/components/observe-slot-text-CSofZeeF.cjs +104 -0
  106. package/components/observe-slot-text-CjnkkBPn.js +105 -0
  107. package/components/options/index.cjs +693 -60
  108. package/components/options/index.js +519 -953
  109. package/components/overlay/index.cjs +367 -21
  110. package/components/overlay/index.js +273 -189
  111. package/components/overlay-CN8ISP1F.js +2485 -0
  112. package/components/overlay-LViy9VWM.cjs +2484 -0
  113. package/components/{pending-state-DTX7ggyF.js → pending-state-CXbe-Xul.js} +28 -13
  114. package/components/pending-state-e4RbXe9u.cjs +75 -0
  115. package/components/picker/index.cjs +9 -1
  116. package/components/picker/index.js +15 -11
  117. package/components/picker-DNde3awt.cjs +672 -0
  118. package/components/picker-PfUAF05y.js +673 -0
  119. package/components/picker-button/index.cjs +56 -4
  120. package/components/picker-button/index.js +45 -34
  121. package/components/platform-CxDar3Dn.cjs +68 -0
  122. package/components/platform-Cxn0WbyT.js +69 -0
  123. package/components/popover/index.cjs +7 -1
  124. package/components/popover/index.js +12 -8
  125. package/components/popover-BkbYhl3i.js +74 -0
  126. package/components/popover-BkgUf0kL.cjs +74 -0
  127. package/components/progress-circle/index.cjs +7 -1
  128. package/components/progress-circle/index.js +12 -8
  129. package/components/progress-circle-Hu_ivPHf.js +133 -0
  130. package/components/progress-circle-_Etqsj9f.cjs +132 -0
  131. package/components/radio/index.cjs +244 -2
  132. package/components/radio/index.js +192 -110
  133. package/components/{when-CDK1Tt5Y.js → random-id-BE6HA503.cjs} +7 -10
  134. package/components/{random-id-ByCz1xaq.js → random-id-BEc6QIUL.js} +3 -3
  135. package/components/roving-tabindex-AsmAh2In.cjs +95 -0
  136. package/components/roving-tabindex-DPF9NmrH.js +96 -0
  137. package/components/search/index.cjs +115 -8
  138. package/components/search/index.js +96 -66
  139. package/components/select/index.cjs +720 -51
  140. package/components/select/index.js +563 -347
  141. package/components/sized-mixin-DmkrNdWB.js +80 -0
  142. package/components/sized-mixin-UaTVa-AE.cjs +79 -0
  143. package/components/slider/index.cjs +119 -1
  144. package/components/slider/index.js +100 -1113
  145. package/components/{condition-attribute-with-id-Dv4lSRbe.js → slottable-request-event-CANixJnR.cjs} +15 -13
  146. package/components/{slottable-request-event-DggLA4Rx.js → slottable-request-event-D9WzrdWv.js} +12 -9
  147. package/components/strategies-DlMlaSJR.cjs +317 -0
  148. package/components/strategies-DlPQoTFE.js +318 -0
  149. package/components/streaming-listener-D4sHaMub.cjs +145 -0
  150. package/components/streaming-listener-cAz5zJyk.js +146 -0
  151. package/components/swatch/index.cjs +436 -7
  152. package/components/swatch/index.js +350 -205
  153. package/components/switch/index.cjs +61 -2
  154. package/components/switch/index.js +51 -34
  155. package/components/tabs/index.cjs +693 -26
  156. package/components/tabs/index.js +521 -388
  157. package/components/tags/index.cjs +201 -4
  158. package/components/tags/index.js +152 -87
  159. package/components/text-field/index.cjs +49 -3
  160. package/components/text-field/index.js +44 -30
  161. package/components/text-field-11tcnftU.cjs +338 -0
  162. package/components/text-field-Chi9J2Cz.js +339 -0
  163. package/components/text-field.module-CMBS0jSL.js +21 -0
  164. package/components/text-field.module-DIJdV_sA.cjs +20 -0
  165. package/components/toast/index.cjs +177 -12
  166. package/components/toast/index.js +145 -73
  167. package/components/tooltip/index.cjs +221 -6
  168. package/components/tooltip/index.js +156 -109
  169. package/components/unit-input/index.cjs +232 -8
  170. package/components/unit-input/index.js +201 -108
  171. package/components/utils.cjs +25 -1
  172. package/components/utils.js +22 -22
  173. package/package.json +1 -1
  174. package/components/NumberFormatter-DewVDY5w.cjs +0 -18
  175. package/components/NumberFormatter-DgOUVrge.js +0 -136
  176. package/components/NumberParser-Dik4a0h-.cjs +0 -18
  177. package/components/NumberParser-ci9J5EKv.js +0 -173
  178. package/components/action-group-DBImibFn.js +0 -258
  179. package/components/action-group-DJGMcRHb.cjs +0 -20
  180. package/components/async-directive-BX1T1e1_.cjs +0 -22
  181. package/components/async-directive-BfcqVjDp.js +0 -82
  182. package/components/base-BjTwmyRF.cjs +0 -22
  183. package/components/base-CBCg3yyw.cjs +0 -40
  184. package/components/base-D76d76ww.js +0 -26
  185. package/components/base-WsynuqaS.js +0 -677
  186. package/components/button-base-DbkDzb71.js +0 -144
  187. package/components/button-base-XgPLmwP-.cjs +0 -25
  188. package/components/checkbox-mixin-BDN0dBtS.cjs +0 -27
  189. package/components/checkbox-mixin-Do7EgtpQ.js +0 -70
  190. package/components/class-map-Di1D_rCm.cjs +0 -22
  191. package/components/class-map-NbVXqBU0.js +0 -51
  192. package/components/clear-button-DQcRdcUa.js +0 -53
  193. package/components/clear-button-OFUFFe7G.cjs +0 -18
  194. package/components/close-button-Cbnb7XXj.cjs +0 -18
  195. package/components/close-button-CqHYZhum.js +0 -51
  196. package/components/color-controller-B0uX6Zso.js +0 -3230
  197. package/components/color-controller-CoUL5f9K.cjs +0 -18
  198. package/components/color-loupe-CaA_Lfkk.cjs +0 -56
  199. package/components/color-loupe-CmMsXbjT.js +0 -81
  200. package/components/condition-attribute-with-id-DrQYZzFS.cjs +0 -18
  201. package/components/dependency-manger-C5HCkMMB.cjs +0 -18
  202. package/components/directive-helpers-Cm6gitnu.js +0 -62
  203. package/components/directive-helpers-DyIRTWwA.cjs +0 -22
  204. package/components/divider.module-DDvBo9zo.cjs +0 -18
  205. package/components/divider.module-DoQWQEIJ.js +0 -21
  206. package/components/element-resolution-BvRLGqIU.cjs +0 -18
  207. package/components/element-resolution-FCUT-wql.js +0 -91
  208. package/components/field-group-DXfBWrkO.js +0 -66
  209. package/components/field-group-DkGst3r5.cjs +0 -23
  210. package/components/field-label-CZ2zzChK.js +0 -106
  211. package/components/field-label-mO1AkUgR.cjs +0 -25
  212. package/components/flow-D-0MTYCm.js +0 -527
  213. package/components/flow-DM3dNAKs.cjs +0 -30
  214. package/components/focus-group-DHeTq18L.js +0 -218
  215. package/components/focus-group-DnxZUBhQ.cjs +0 -18
  216. package/components/focus-visible-B0P9aY_G.cjs +0 -18
  217. package/components/focus-visible-DBlJGoEW.js +0 -74
  218. package/components/focusable-BxtpnzWp.js +0 -153
  219. package/components/focusable-EbipgXRh.cjs +0 -18
  220. package/components/focusable-selectors-BgFlyFcY.cjs +0 -18
  221. package/components/if-defined-C9YGdo33.cjs +0 -22
  222. package/components/if-defined-DOaE2coe.js +0 -27
  223. package/components/index-BwxgAdzi.cjs +0 -57
  224. package/components/index-Cl54m8Yh.js +0 -1490
  225. package/components/index-HjQa8tew.js +0 -1174
  226. package/components/index-Wq3qZJGh.cjs +0 -113
  227. package/components/language-resolution-DJzmyzZq.cjs +0 -18
  228. package/components/like-anchor-Bvn_vLQ8.js +0 -69
  229. package/components/like-anchor-sod1C1fR.cjs +0 -32
  230. package/components/luzmo-icons-4nDFv1Lq.js +0 -229
  231. package/components/luzmo-icons-D4IvHgVd.cjs +0 -29
  232. package/components/manage-help-text-DhgARkZX.cjs +0 -30
  233. package/components/manage-help-text-syYnjKGL.js +0 -92
  234. package/components/mutation-controller-DH7YOCyj.js +0 -52
  235. package/components/mutation-controller-DkOMCW-c.cjs +0 -22
  236. package/components/observe-slot-presence-CmVi0zTc.js +0 -68
  237. package/components/observe-slot-presence-bc9chhsi.cjs +0 -18
  238. package/components/observe-slot-text-BPfIQQtz.js +0 -87
  239. package/components/observe-slot-text-Ceb7SvYT.cjs +0 -18
  240. package/components/overlay-Cig9r6uU.js +0 -2747
  241. package/components/overlay-KSKMzzkh.cjs +0 -47
  242. package/components/pending-state-CaH1si5b.cjs +0 -26
  243. package/components/picker-BfBP7XJN.js +0 -461
  244. package/components/picker-xIphqE6d.cjs +0 -123
  245. package/components/platform-BM-uMWpX.js +0 -69
  246. package/components/platform-BiXhwqk3.cjs +0 -18
  247. package/components/popover-DjX0aAnY.js +0 -67
  248. package/components/popover-KFfO0IYL.cjs +0 -30
  249. package/components/progress-circle-BvRJNuNo.cjs +0 -33
  250. package/components/progress-circle-DXH9z8-6.js +0 -97
  251. package/components/query-BL-TJj7K.cjs +0 -22
  252. package/components/query-D_KR_GUc.js +0 -51
  253. package/components/query-assigned-elements-DjfhL1cl.js +0 -36
  254. package/components/query-assigned-elements-DsKsfk7G.cjs +0 -22
  255. package/components/query-assigned-nodes-BcKWmGzy.cjs +0 -22
  256. package/components/query-assigned-nodes-C76XVPWY.js +0 -36
  257. package/components/random-id-CqvckpWe.cjs +0 -18
  258. package/components/roving-tabindex-By_fCy_e.cjs +0 -18
  259. package/components/roving-tabindex-DOg4z6ZU.js +0 -66
  260. package/components/sized-mixin-CPxE5C96.cjs +0 -18
  261. package/components/sized-mixin-D4ACoVUr.js +0 -63
  262. package/components/slottable-request-event-BfUUt1Mh.cjs +0 -18
  263. package/components/state-D8JEtYqe.cjs +0 -22
  264. package/components/state-Deh-vKYE.js +0 -29
  265. package/components/strategies-9indNIEb.js +0 -195
  266. package/components/strategies-BACP6MhR.cjs +0 -18
  267. package/components/streaming-listener-B00MvALi.cjs +0 -18
  268. package/components/streaming-listener-CP-JE6Fa.js +0 -91
  269. package/components/style-map-CeilmSgs.cjs +0 -22
  270. package/components/style-map-IgqIKvlE.js +0 -53
  271. package/components/text-field-CeG75PPO.cjs +0 -85
  272. package/components/text-field-DCl-AFM-.js +0 -314
  273. package/components/text-field.module-C2KVUJcX.js +0 -21
  274. package/components/text-field.module-DXhFA9G-.cjs +0 -18
  275. package/components/when-CDZyJPvd.cjs +0 -22
@@ -0,0 +1,2485 @@
1
+ /*! * Lucero - The design system for Luzmo.
2
+ *
3
+ * Copyright © 2025 Luzmo
4
+ * All rights reserved.
5
+ * Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
6
+ * This license allows users with a current active Luzmo account to use Lucero.
7
+ * This license terminates automatically if a user no longer has an active Luzmo account.
8
+ * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
9
+ *
10
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
+ * SOFTWARE.
17
+ * */
18
+ var _a;
19
+ import { unsafeCSS, html } from "lit";
20
+ import { property, query, queryAssignedElements, state } from "lit/decorators.js";
21
+ import { ifDefined } from "lit/directives/if-defined.js";
22
+ import { styleMap } from "lit/directives/style-map.js";
23
+ import { r as randomID } from "./random-id-BEc6QIUL.js";
24
+ import { E as ElementResolutionController, e as elementResolverUpdatedSymbol } from "./element-resolution-nMlmW4Jy.js";
25
+ import { a as LuzmoElement } from "./base-DmeVy0cq.js";
26
+ import { u as userFocusableSelector } from "./focusable-selectors-IltOAOd9.js";
27
+ import { autoUpdate, flip, offset, shift, size, arrow, computePosition } from "@floating-ui/dom";
28
+ import { S as SlottableRequestEvent, r as removeSlottableRequest } from "./slottable-request-event-D9WzrdWv.js";
29
+ import { c as conditionAttributeWithId } from "./condition-attribute-with-id-Cn815e9W.js";
30
+ import { f as isWebKit, c as isIOS, j as isAndroid } from "./platform-Cxn0WbyT.js";
31
+ function restoreChildren(placeholderItems, srcElements, cleanupCallbacks = []) {
32
+ for (const [index, srcElement] of srcElements.entries()) {
33
+ const placeholderItem = placeholderItems[index];
34
+ const parentElement = placeholderItem.parentElement || placeholderItem.getRootNode();
35
+ if (cleanupCallbacks[index]) {
36
+ cleanupCallbacks[index](srcElement);
37
+ }
38
+ if (parentElement && parentElement !== placeholderItem) {
39
+ placeholderItem.replaceWith(srcElement);
40
+ }
41
+ delete placeholderItems[index];
42
+ }
43
+ return srcElements;
44
+ }
45
+ const reparentChildren = (srcElements, destination, {
46
+ position,
47
+ prepareCallback
48
+ } = { position: "beforeend" }) => {
49
+ let { length } = srcElements;
50
+ if (length === 0) {
51
+ return () => srcElements;
52
+ }
53
+ let step = 1;
54
+ let index = 0;
55
+ if (position === "afterbegin" || position === "afterend") {
56
+ step = -1;
57
+ index = length - 1;
58
+ }
59
+ const placeholderItems = new Array(length);
60
+ const cleanupCallbacks = new Array(length);
61
+ const placeholderTemplate = typeof document !== "undefined" ? document.createComment("placeholder for reparented element") : null;
62
+ do {
63
+ const srcElement = srcElements[index];
64
+ if (prepareCallback) {
65
+ cleanupCallbacks[index] = prepareCallback(srcElement);
66
+ }
67
+ placeholderItems[index] = placeholderTemplate.cloneNode();
68
+ const parentElement = srcElement.parentElement || srcElement.getRootNode();
69
+ if (parentElement && parentElement !== srcElement) {
70
+ parentElement.replaceChild(placeholderItems[index], srcElement);
71
+ }
72
+ destination.insertAdjacentElement(position, srcElement);
73
+ index += step;
74
+ } while (--length > 0);
75
+ return function() {
76
+ return restoreChildren(placeholderItems, srcElements, cleanupCallbacks);
77
+ };
78
+ };
79
+ const DEFAULT_WARMUP = 1e3;
80
+ const DEFAULT_COOLDOWN = 1e3;
81
+ class LuzmoOverlayTimer {
82
+ constructor(options = {}) {
83
+ this.warmUpDelay = DEFAULT_WARMUP;
84
+ this.coolDownDelay = DEFAULT_COOLDOWN;
85
+ this.isWarm = false;
86
+ this.timeout = 0;
87
+ Object.assign(this, options);
88
+ }
89
+ openTimer(component) {
90
+ this.cancelCooldownTimer();
91
+ if (!this.component || component !== this.component) {
92
+ if (this.component) {
93
+ this.close(this.component);
94
+ this.cancelCooldownTimer();
95
+ }
96
+ this.component = component;
97
+ if (this.isWarm) {
98
+ return Promise.resolve(false);
99
+ }
100
+ this.promise = new Promise((resolve) => {
101
+ this.resolve = resolve;
102
+ this.timeout = typeof window !== "undefined" ? window.setTimeout(() => {
103
+ if (this.resolve) {
104
+ this.resolve(false);
105
+ this.isWarm = true;
106
+ }
107
+ }, this.warmUpDelay) : 0;
108
+ });
109
+ return this.promise;
110
+ } else if (this.promise) {
111
+ return this.promise;
112
+ }
113
+ throw new Error("Inconsistent state");
114
+ }
115
+ close(component) {
116
+ if (this.component && this.component === component) {
117
+ this.resetCooldownTimer();
118
+ if (this.timeout > 0) {
119
+ clearTimeout(this.timeout);
120
+ this.timeout = 0;
121
+ }
122
+ if (this.resolve) {
123
+ this.resolve(true);
124
+ delete this.resolve;
125
+ }
126
+ delete this.promise;
127
+ delete this.component;
128
+ }
129
+ }
130
+ resetCooldownTimer() {
131
+ if (this.isWarm) {
132
+ if (this.cooldownTimeout && typeof window !== "undefined") {
133
+ window.clearTimeout(this.cooldownTimeout);
134
+ }
135
+ this.cooldownTimeout = typeof window !== "undefined" ? window.setTimeout(() => {
136
+ this.isWarm = false;
137
+ delete this.cooldownTimeout;
138
+ }, this.coolDownDelay) : void 0;
139
+ }
140
+ }
141
+ cancelCooldownTimer() {
142
+ if (this.cooldownTimeout && typeof window !== "undefined") {
143
+ window.clearTimeout(this.cooldownTimeout);
144
+ }
145
+ delete this.cooldownTimeout;
146
+ }
147
+ }
148
+ const overlayTimer = new LuzmoOverlayTimer();
149
+ const noop = () => {
150
+ };
151
+ const guaranteedAllTransitionend = (el, action, cb) => {
152
+ const abortController = new AbortController();
153
+ const runningTransitions = /* @__PURE__ */ new Map();
154
+ const cleanup = () => {
155
+ abortController.abort();
156
+ cb();
157
+ };
158
+ let guarantee2;
159
+ let guarantee3;
160
+ const guarantee1 = requestAnimationFrame(() => {
161
+ guarantee2 = requestAnimationFrame(() => {
162
+ guarantee3 = requestAnimationFrame(() => {
163
+ cleanup();
164
+ });
165
+ });
166
+ });
167
+ const handleTransitionend = (event) => {
168
+ if (event.target !== el) {
169
+ return;
170
+ }
171
+ runningTransitions.set(
172
+ event.propertyName,
173
+ runningTransitions.get(event.propertyName) - 1
174
+ );
175
+ if (!runningTransitions.get(event.propertyName)) {
176
+ runningTransitions.delete(event.propertyName);
177
+ }
178
+ if (runningTransitions.size === 0) {
179
+ cleanup();
180
+ }
181
+ };
182
+ const handleTransitionrun = (event) => {
183
+ if (event.target !== el) {
184
+ return;
185
+ }
186
+ if (!runningTransitions.has(event.propertyName)) {
187
+ runningTransitions.set(event.propertyName, 0);
188
+ }
189
+ runningTransitions.set(
190
+ event.propertyName,
191
+ runningTransitions.get(event.propertyName) + 1
192
+ );
193
+ cancelAnimationFrame(guarantee1);
194
+ cancelAnimationFrame(guarantee2);
195
+ cancelAnimationFrame(guarantee3);
196
+ };
197
+ el.addEventListener("transitionrun", handleTransitionrun, {
198
+ signal: abortController.signal
199
+ });
200
+ el.addEventListener("transitionend", handleTransitionend, {
201
+ signal: abortController.signal
202
+ });
203
+ el.addEventListener("transitioncancel", handleTransitionend, {
204
+ signal: abortController.signal
205
+ });
206
+ action();
207
+ };
208
+ function nextFrame() {
209
+ return new Promise((res) => requestAnimationFrame(() => res()));
210
+ }
211
+ class LuzmoAbstractOverlay extends LuzmoElement {
212
+ constructor() {
213
+ super(...arguments);
214
+ this.dispose = noop;
215
+ this.offset = 0;
216
+ this.willPreventClose = false;
217
+ }
218
+ applyFocus(_targetOpenState, _focusEl) {
219
+ return;
220
+ }
221
+ /* c8 ignore next 6 */
222
+ get delayed() {
223
+ return false;
224
+ }
225
+ set delayed(_delayed) {
226
+ return;
227
+ }
228
+ /* c8 ignore next 6 */
229
+ get disabled() {
230
+ return false;
231
+ }
232
+ set disabled(_disabled) {
233
+ return;
234
+ }
235
+ get elementResolver() {
236
+ return this._elementResolver;
237
+ }
238
+ set elementResolver(controller) {
239
+ this._elementResolver = controller;
240
+ }
241
+ /* c8 ignore next 3 */
242
+ ensureOnDOM(_targetOpenState) {
243
+ return;
244
+ }
245
+ /* c8 ignore next 5 */
246
+ makeTransition(_targetOpenState) {
247
+ return null;
248
+ }
249
+ manageDelay(_targetOpenState) {
250
+ return;
251
+ }
252
+ /* c8 ignore next 3 */
253
+ manageDialogOpen() {
254
+ return;
255
+ }
256
+ /* c8 ignore next 3 */
257
+ managePopoverOpen() {
258
+ return;
259
+ }
260
+ /* c8 ignore next 3 */
261
+ managePosition() {
262
+ return;
263
+ }
264
+ /* c8 ignore next 6 */
265
+ get open() {
266
+ return false;
267
+ }
268
+ set open(_open) {
269
+ return;
270
+ }
271
+ get placementController() {
272
+ return this._placementController;
273
+ }
274
+ set placementController(controller) {
275
+ this._placementController = controller;
276
+ }
277
+ requestSlottable() {
278
+ }
279
+ returnFocus() {
280
+ return;
281
+ }
282
+ /* c8 ignore next 6 */
283
+ get state() {
284
+ return "closed";
285
+ }
286
+ set state(_state) {
287
+ return;
288
+ }
289
+ /* c8 ignore next 3 */
290
+ manuallyKeepOpen() {
291
+ return;
292
+ }
293
+ static update() {
294
+ const overlayUpdateEvent = new CustomEvent("luzmo-update-overlays", {
295
+ bubbles: true,
296
+ composed: true,
297
+ cancelable: true
298
+ });
299
+ document.dispatchEvent(overlayUpdateEvent);
300
+ }
301
+ static async open(triggerOrContent, interactionOrOptions, content, optionsV1) {
302
+ await Promise.resolve().then(() => overlay);
303
+ const v2 = arguments.length === 2;
304
+ const overlayContent = content || triggerOrContent;
305
+ const overlay$1 = new this();
306
+ let restored = false;
307
+ const restoreContent = reparentChildren([overlayContent], overlay$1, {
308
+ position: "beforeend",
309
+ prepareCallback: (el) => {
310
+ const slot = el.slot;
311
+ el.removeAttribute("slot");
312
+ return () => {
313
+ el.slot = slot;
314
+ };
315
+ }
316
+ });
317
+ overlay$1.dispose = () => {
318
+ overlay$1.addEventListener("luzmo-closed", () => {
319
+ if (!restored) {
320
+ restoreContent();
321
+ restored = true;
322
+ }
323
+ requestAnimationFrame(() => {
324
+ overlay$1.remove();
325
+ });
326
+ });
327
+ overlay$1.open = false;
328
+ overlay$1.dispose = noop;
329
+ };
330
+ const v1 = !v2 && overlayContent && optionsV1;
331
+ if (v1) {
332
+ const trigger = triggerOrContent;
333
+ const interaction = interactionOrOptions;
334
+ const options2 = optionsV1;
335
+ LuzmoAbstractOverlay.applyOptions(overlay$1, {
336
+ ...options2,
337
+ delayed: options2.delayed || overlayContent.hasAttribute("delayed"),
338
+ trigger: options2.virtualTrigger || trigger,
339
+ type: interaction === "modal" ? "modal" : interaction === "hover" ? "hint" : "auto"
340
+ });
341
+ trigger.after(overlay$1);
342
+ await overlay$1.updateComplete;
343
+ overlay$1.open = true;
344
+ return overlay$1.dispose;
345
+ }
346
+ const options = interactionOrOptions;
347
+ overlay$1.append(overlayContent);
348
+ LuzmoAbstractOverlay.applyOptions(overlay$1, {
349
+ ...options,
350
+ delayed: options.delayed || overlayContent.hasAttribute("delayed")
351
+ });
352
+ overlay$1.updateComplete.then(() => {
353
+ overlay$1.open = true;
354
+ });
355
+ return overlay$1;
356
+ }
357
+ static applyOptions(overlay2, options) {
358
+ overlay2.delayed = !!options.delayed;
359
+ overlay2.receivesFocus = options.receivesFocus ?? "auto";
360
+ overlay2.triggerElement = options.trigger || null;
361
+ overlay2.type = options.type || "modal";
362
+ overlay2.offset = options.offset ?? 0;
363
+ overlay2.placement = options.placement;
364
+ overlay2.willPreventClose = !!options.notImmediatelyClosable;
365
+ }
366
+ }
367
+ const firstFocusableIn = (root) => {
368
+ const firstFocusable = root.querySelector(
369
+ userFocusableSelector
370
+ );
371
+ return firstFocusable;
372
+ };
373
+ const firstFocusableSlottedIn = (root) => {
374
+ const firstFocusable = root.assignedElements().find((element) => element.matches(userFocusableSelector));
375
+ return firstFocusable;
376
+ };
377
+ class BeforetoggleClosedEvent extends Event {
378
+ constructor() {
379
+ super("beforetoggle", {
380
+ bubbles: false,
381
+ composed: false
382
+ });
383
+ this.currentState = "open";
384
+ this.newState = "closed";
385
+ }
386
+ }
387
+ class BeforetoggleOpenEvent extends Event {
388
+ constructor() {
389
+ super("beforetoggle", {
390
+ bubbles: false,
391
+ composed: false
392
+ });
393
+ this.currentState = "closed";
394
+ this.newState = "open";
395
+ }
396
+ }
397
+ class OverlayStateEvent extends Event {
398
+ constructor(type, overlay2, {
399
+ publish,
400
+ interaction,
401
+ reason
402
+ }) {
403
+ super(type, {
404
+ bubbles: publish,
405
+ composed: publish
406
+ });
407
+ this.overlay = overlay2;
408
+ this.detail = {
409
+ interaction,
410
+ reason
411
+ };
412
+ }
413
+ }
414
+ class VirtualTrigger {
415
+ constructor(x, y) {
416
+ this.x = 0;
417
+ this.y = 0;
418
+ this.x = x;
419
+ this.y = y;
420
+ }
421
+ updateBoundingClientRect(x, y) {
422
+ this.x = x;
423
+ this.y = y;
424
+ LuzmoAbstractOverlay.update();
425
+ }
426
+ getBoundingClientRect() {
427
+ return {
428
+ width: 0,
429
+ height: 0,
430
+ top: this.y,
431
+ right: this.x,
432
+ y: this.y,
433
+ x: this.x,
434
+ bottom: this.y,
435
+ left: this.x,
436
+ /* c8 ignore next 3 */
437
+ toJSON() {
438
+ return;
439
+ }
440
+ };
441
+ }
442
+ }
443
+ function OverlayDialog(constructor) {
444
+ class OverlayWithDialog extends constructor {
445
+ async manageDialogOpen() {
446
+ const targetOpenState = this.open;
447
+ await nextFrame();
448
+ await this.managePosition();
449
+ if (this.open !== targetOpenState) {
450
+ return;
451
+ }
452
+ const focusEl = await this.dialogMakeTransition(targetOpenState);
453
+ if (this.open !== targetOpenState) {
454
+ return;
455
+ }
456
+ await this.dialogApplyFocus(targetOpenState, focusEl);
457
+ }
458
+ dialogMakeTransition(targetOpenState) {
459
+ let focusEl = null;
460
+ const start = (el, index) => () => {
461
+ el.open = targetOpenState;
462
+ if (!targetOpenState) {
463
+ const close = () => {
464
+ el.removeEventListener("close", close);
465
+ };
466
+ el.addEventListener("close", close);
467
+ }
468
+ if (index > 0) {
469
+ return;
470
+ }
471
+ const event = targetOpenState ? BeforetoggleOpenEvent : BeforetoggleClosedEvent;
472
+ this.dispatchEvent(new event());
473
+ if (!targetOpenState) {
474
+ return;
475
+ }
476
+ if (el.matches(userFocusableSelector)) {
477
+ focusEl = el;
478
+ }
479
+ focusEl = focusEl || firstFocusableIn(el);
480
+ if (!focusEl) {
481
+ const childSlots = el.querySelectorAll("slot");
482
+ childSlots.forEach((slot) => {
483
+ if (!focusEl) {
484
+ focusEl = firstFocusableSlottedIn(slot);
485
+ }
486
+ });
487
+ }
488
+ if (!this.isConnected || this.dialogEl.open) {
489
+ return;
490
+ }
491
+ this.dialogEl.showModal();
492
+ };
493
+ const finish = (el, index) => () => {
494
+ if (this.open !== targetOpenState) {
495
+ return;
496
+ }
497
+ const eventName = targetOpenState ? "luzmo-opened" : "luzmo-closed";
498
+ if (index > 0) {
499
+ el.dispatchEvent(
500
+ new OverlayStateEvent(eventName, this, {
501
+ interaction: this.type,
502
+ publish: false
503
+ })
504
+ );
505
+ return;
506
+ }
507
+ if (!this.isConnected || targetOpenState !== this.open) {
508
+ return;
509
+ }
510
+ const reportChange = async () => {
511
+ const hasVirtualTrigger = this.triggerElement instanceof VirtualTrigger;
512
+ this.dispatchEvent(
513
+ new OverlayStateEvent(eventName, this, {
514
+ interaction: this.type,
515
+ publish: hasVirtualTrigger
516
+ })
517
+ );
518
+ el.dispatchEvent(
519
+ new OverlayStateEvent(eventName, this, {
520
+ interaction: this.type,
521
+ publish: false
522
+ })
523
+ );
524
+ if (this.triggerElement && !hasVirtualTrigger) {
525
+ this.triggerElement.dispatchEvent(
526
+ new OverlayStateEvent(eventName, this, {
527
+ interaction: this.type,
528
+ publish: true
529
+ })
530
+ );
531
+ }
532
+ this.state = targetOpenState ? "opened" : "closed";
533
+ this.returnFocus();
534
+ await nextFrame();
535
+ await nextFrame();
536
+ if (targetOpenState === this.open && targetOpenState === false) {
537
+ this.requestSlottable();
538
+ }
539
+ };
540
+ if (!targetOpenState && this.dialogEl.open) {
541
+ this.dialogEl.addEventListener(
542
+ "close",
543
+ () => {
544
+ reportChange();
545
+ },
546
+ { once: true }
547
+ );
548
+ this.dialogEl.close();
549
+ } else {
550
+ reportChange();
551
+ }
552
+ };
553
+ this.elements.forEach((el, index) => {
554
+ guaranteedAllTransitionend(el, start(el, index), finish(el, index));
555
+ });
556
+ return focusEl;
557
+ }
558
+ dialogApplyFocus(targetOpenState, focusEl) {
559
+ this.applyFocus(targetOpenState, focusEl);
560
+ }
561
+ }
562
+ return OverlayWithDialog;
563
+ }
564
+ function OverlayNoPopover(constructor) {
565
+ class OverlayWithNoPopover extends constructor {
566
+ async managePopoverOpen() {
567
+ await this.managePosition();
568
+ }
569
+ async manageDelay(targetOpenState) {
570
+ if (targetOpenState === false || targetOpenState !== this.open) {
571
+ overlayTimer.close(this);
572
+ return;
573
+ }
574
+ if (this.delayed) {
575
+ const cancelled = await overlayTimer.openTimer(this);
576
+ if (cancelled) {
577
+ this.open = !targetOpenState;
578
+ }
579
+ }
580
+ }
581
+ ensureOnDOM(_targetOpenState) {
582
+ document.body.offsetHeight;
583
+ }
584
+ makeTransition(targetOpenState) {
585
+ if (this.open !== targetOpenState) {
586
+ return null;
587
+ }
588
+ let focusEl = null;
589
+ const start = (el, index) => () => {
590
+ if (targetOpenState !== this.open) {
591
+ return;
592
+ }
593
+ el.open = targetOpenState;
594
+ if (index === 0) {
595
+ const event = targetOpenState ? BeforetoggleOpenEvent : BeforetoggleClosedEvent;
596
+ this.dispatchEvent(new event());
597
+ }
598
+ if (targetOpenState !== true) {
599
+ return;
600
+ }
601
+ if (el.matches(userFocusableSelector)) {
602
+ focusEl = el;
603
+ }
604
+ focusEl = focusEl || firstFocusableIn(el);
605
+ if (focusEl) {
606
+ return;
607
+ }
608
+ const childSlots = el.querySelectorAll("slot");
609
+ childSlots.forEach((slot) => {
610
+ if (!focusEl) {
611
+ focusEl = firstFocusableSlottedIn(slot);
612
+ }
613
+ });
614
+ };
615
+ const finish = (el, index) => async () => {
616
+ if (this.open !== targetOpenState) {
617
+ return;
618
+ }
619
+ const eventName = targetOpenState ? "luzmo-opened" : "luzmo-closed";
620
+ el.dispatchEvent(
621
+ new OverlayStateEvent(eventName, this, {
622
+ interaction: this.type
623
+ })
624
+ );
625
+ if (index > 0) {
626
+ return;
627
+ }
628
+ const hasVirtualTrigger = this.triggerElement instanceof VirtualTrigger;
629
+ this.dispatchEvent(
630
+ new OverlayStateEvent(eventName, this, {
631
+ interaction: this.type,
632
+ publish: hasVirtualTrigger
633
+ })
634
+ );
635
+ if (this.triggerElement && !hasVirtualTrigger) {
636
+ this.triggerElement.dispatchEvent(
637
+ new OverlayStateEvent(eventName, this, {
638
+ interaction: this.type,
639
+ publish: true
640
+ })
641
+ );
642
+ }
643
+ this.state = targetOpenState ? "opened" : "closed";
644
+ this.returnFocus();
645
+ await nextFrame();
646
+ await nextFrame();
647
+ if (targetOpenState === this.open && targetOpenState === false) {
648
+ this.requestSlottable();
649
+ }
650
+ };
651
+ this.elements.forEach((el, index) => {
652
+ guaranteedAllTransitionend(el, start(el, index), finish(el, index));
653
+ });
654
+ return focusEl;
655
+ }
656
+ }
657
+ return OverlayWithNoPopover;
658
+ }
659
+ const supportsOverlayAuto = CSS.supports("(overlay: auto)");
660
+ function isOpen(el) {
661
+ let popoverOpen = false;
662
+ try {
663
+ popoverOpen = el.matches(":popover-open");
664
+ } catch {
665
+ }
666
+ let open = false;
667
+ try {
668
+ open = el.matches(":open");
669
+ } catch {
670
+ }
671
+ return popoverOpen || open;
672
+ }
673
+ function OverlayPopover(constructor) {
674
+ class OverlayWithPopover extends constructor {
675
+ async manageDelay(targetOpenState) {
676
+ if (targetOpenState === false || targetOpenState !== this.open) {
677
+ overlayTimer.close(this);
678
+ return;
679
+ }
680
+ if (this.delayed) {
681
+ const cancelled = await overlayTimer.openTimer(this);
682
+ if (cancelled) {
683
+ this.open = !targetOpenState;
684
+ }
685
+ }
686
+ }
687
+ /**
688
+ * A popover should be hidden _after_ it is no longer on top-layer because
689
+ * the position metrics will have changed from when it was originally positioned.
690
+ */
691
+ shouldHidePopover(targetOpenState) {
692
+ if (targetOpenState && this.open !== targetOpenState) {
693
+ return;
694
+ }
695
+ const update = async ({
696
+ newState
697
+ } = {}) => {
698
+ if (newState === "open") {
699
+ return;
700
+ }
701
+ await this.placementController.resetOverlayPosition();
702
+ };
703
+ if (!isOpen(this.dialogEl)) {
704
+ update();
705
+ return;
706
+ }
707
+ this.dialogEl.addEventListener("toggle", update, {
708
+ once: true
709
+ });
710
+ }
711
+ shouldShowPopover(targetOpenState) {
712
+ let popoverOpen = false;
713
+ try {
714
+ popoverOpen = this.dialogEl.matches(":popover-open");
715
+ } catch {
716
+ }
717
+ let open = false;
718
+ try {
719
+ open = this.dialogEl.matches(":open");
720
+ } catch {
721
+ }
722
+ if (targetOpenState && this.open === targetOpenState && !popoverOpen && !open && this.isConnected) {
723
+ this.dialogEl.showPopover();
724
+ this.managePosition();
725
+ }
726
+ }
727
+ async ensureOnDOM(targetOpenState) {
728
+ if (!supportsOverlayAuto) {
729
+ await this.shouldHidePopover(targetOpenState);
730
+ }
731
+ this.shouldShowPopover(targetOpenState);
732
+ await nextFrame();
733
+ }
734
+ makeTransition(targetOpenState) {
735
+ if (this.open !== targetOpenState) {
736
+ return null;
737
+ }
738
+ let focusEl = null;
739
+ const start = (el, index) => () => {
740
+ el.open = targetOpenState;
741
+ if (index === 0) {
742
+ const event = targetOpenState ? BeforetoggleOpenEvent : BeforetoggleClosedEvent;
743
+ this.dispatchEvent(new event());
744
+ }
745
+ if (!targetOpenState) {
746
+ return;
747
+ }
748
+ if (el.matches(userFocusableSelector)) {
749
+ focusEl = el;
750
+ }
751
+ focusEl = focusEl || firstFocusableIn(el);
752
+ if (focusEl) {
753
+ return;
754
+ }
755
+ const childSlots = el.querySelectorAll("slot");
756
+ childSlots.forEach((slot) => {
757
+ if (!focusEl) {
758
+ focusEl = firstFocusableSlottedIn(slot);
759
+ }
760
+ });
761
+ };
762
+ const finish = (el, index) => () => {
763
+ if (this.open !== targetOpenState) {
764
+ return;
765
+ }
766
+ const eventName = targetOpenState ? "luzmo-opened" : "luzmo-closed";
767
+ if (index > 0) {
768
+ el.dispatchEvent(
769
+ new OverlayStateEvent(eventName, this, {
770
+ interaction: this.type,
771
+ publish: false
772
+ })
773
+ );
774
+ return;
775
+ }
776
+ const reportChange = async () => {
777
+ if (this.open !== targetOpenState) {
778
+ return;
779
+ }
780
+ await nextFrame();
781
+ const hasVirtualTrigger = this.triggerElement instanceof VirtualTrigger;
782
+ this.dispatchEvent(
783
+ new OverlayStateEvent(eventName, this, {
784
+ interaction: this.type,
785
+ publish: hasVirtualTrigger
786
+ })
787
+ );
788
+ el.dispatchEvent(
789
+ new OverlayStateEvent(eventName, this, {
790
+ interaction: this.type,
791
+ publish: false
792
+ })
793
+ );
794
+ if (this.triggerElement && !hasVirtualTrigger) {
795
+ this.triggerElement.dispatchEvent(
796
+ new OverlayStateEvent(eventName, this, {
797
+ interaction: this.type,
798
+ publish: true
799
+ })
800
+ );
801
+ }
802
+ this.state = targetOpenState ? "opened" : "closed";
803
+ this.returnFocus();
804
+ await nextFrame();
805
+ await nextFrame();
806
+ if (targetOpenState === this.open && targetOpenState === false) {
807
+ this.requestSlottable();
808
+ }
809
+ };
810
+ if (this.open !== targetOpenState) {
811
+ return;
812
+ }
813
+ const open = isOpen(this.dialogEl);
814
+ if (targetOpenState !== true && open && this.isConnected) {
815
+ this.dialogEl.addEventListener(
816
+ "beforetoggle",
817
+ () => {
818
+ reportChange();
819
+ },
820
+ { once: true }
821
+ );
822
+ this.dialogEl.hidePopover();
823
+ } else {
824
+ reportChange();
825
+ }
826
+ };
827
+ this.elements.forEach((el, index) => {
828
+ guaranteedAllTransitionend(el, start(el, index), finish(el, index));
829
+ });
830
+ return focusEl;
831
+ }
832
+ }
833
+ return OverlayWithPopover;
834
+ }
835
+ const supportsPopover = typeof document !== "undefined" && "showPopover" in document.createElement("div");
836
+ class OverlayStack {
837
+ constructor() {
838
+ this.root = typeof document === "undefined" ? null : document.body;
839
+ this.stack = [];
840
+ this.handleScroll = (event) => {
841
+ if (typeof document !== "undefined" && event.target !== document && event.target !== document.documentElement && event.target !== document.body) {
842
+ return;
843
+ }
844
+ this.stack.forEach((overlay2) => {
845
+ if (overlay2.open) {
846
+ if (overlay2.type === "auto" && overlay2.triggerElement instanceof HTMLElement && overlay2.triggerElement.closest(
847
+ "luzmo-picker, luzmo-select, luzmo-action-menu"
848
+ )) {
849
+ event.stopPropagation();
850
+ }
851
+ if (typeof document !== "undefined") {
852
+ document.dispatchEvent(
853
+ new CustomEvent("luzmo-update-overlays", {
854
+ bubbles: true,
855
+ composed: true,
856
+ cancelable: true
857
+ })
858
+ );
859
+ }
860
+ }
861
+ });
862
+ };
863
+ this.handlePointerdown = (event) => {
864
+ this.pointerdownPath = event.composedPath();
865
+ this.lastOverlay = this.stack.at(-1);
866
+ };
867
+ this.handlePointerup = () => {
868
+ const composedPath = this.pointerdownPath;
869
+ this.pointerdownPath = void 0;
870
+ if (this.stack.length === 0) {
871
+ return;
872
+ }
873
+ if (!(composedPath == null ? void 0 : composedPath.length)) {
874
+ return;
875
+ }
876
+ const lastOverlay = this.lastOverlay;
877
+ this.lastOverlay = void 0;
878
+ const lastIndex = this.stack.length - 1;
879
+ const nonAncestorOverlays = this.stack.filter((overlay2, i) => {
880
+ const inStack = composedPath.find(
881
+ (el) => (
882
+ // The Overlay is in the stack
883
+ el === overlay2 || // The Overlay trigger is in the stack and the Overlay is a "hint"
884
+ el === (overlay2 == null ? void 0 : overlay2.triggerElement) && (overlay2 == null ? void 0 : overlay2.type) === "hint" || // The last Overlay in the stack is not the last Overlay at `pointerdown` time and has a
885
+ // `triggerInteraction` of "longpress", meaning it was opened by this poitner interaction
886
+ i === lastIndex && overlay2 !== lastOverlay && overlay2.triggerInteraction === "longpress"
887
+ )
888
+ );
889
+ return !inStack && !overlay2.shouldPreventClose() && overlay2.type !== "manual" && // Don't close if this overlay is modal and not on top of the overlay stack.
890
+ !(overlay2.type === "modal" && lastOverlay !== overlay2);
891
+ });
892
+ nonAncestorOverlays.reverse();
893
+ nonAncestorOverlays.forEach((overlay2) => {
894
+ this.closeOverlay(overlay2);
895
+ let parentToClose = overlay2.parentOverlayToForceClose;
896
+ while (parentToClose) {
897
+ this.closeOverlay(parentToClose);
898
+ parentToClose = parentToClose.parentOverlayToForceClose;
899
+ }
900
+ });
901
+ };
902
+ this.handleBeforetoggle = (event) => {
903
+ const { target, newState: open } = event;
904
+ if (open === "open") {
905
+ return;
906
+ }
907
+ this.closeOverlay(target);
908
+ };
909
+ this.handleKeydown = (event) => {
910
+ if (event.code !== "Escape") {
911
+ return;
912
+ }
913
+ if (this.stack.length === 0) {
914
+ return;
915
+ }
916
+ const last = this.stack.at(-1);
917
+ if ((last == null ? void 0 : last.type) === "page") {
918
+ event.preventDefault();
919
+ return;
920
+ }
921
+ if ((last == null ? void 0 : last.type) === "manual") {
922
+ this.closeOverlay(last);
923
+ return;
924
+ }
925
+ if (supportsPopover) {
926
+ return;
927
+ }
928
+ if (!last) {
929
+ return;
930
+ }
931
+ this.closeOverlay(last);
932
+ };
933
+ if (typeof document !== "undefined") {
934
+ this.bindEvents();
935
+ }
936
+ }
937
+ get document() {
938
+ return this.root.ownerDocument || document;
939
+ }
940
+ bindEvents() {
941
+ if (typeof document !== "undefined") {
942
+ this.document.addEventListener("pointerdown", this.handlePointerdown);
943
+ this.document.addEventListener("pointerup", this.handlePointerup);
944
+ this.document.addEventListener("keydown", this.handleKeydown);
945
+ this.document.addEventListener("scroll", this.handleScroll, {
946
+ capture: true
947
+ });
948
+ }
949
+ }
950
+ closeOverlay(overlay2) {
951
+ const overlayIndex = this.stack.indexOf(overlay2);
952
+ if (overlayIndex !== -1) {
953
+ this.stack.splice(overlayIndex, 1);
954
+ }
955
+ overlay2.open = false;
956
+ }
957
+ /**
958
+ * Get an array of Overlays that all share the same trigger element.
959
+ *
960
+ * @param triggerElement {HTMLELement}
961
+ * @returns
962
+ */
963
+ overlaysByTriggerElement(triggerElement) {
964
+ return this.stack.filter(
965
+ (overlay2) => overlay2.triggerElement === triggerElement
966
+ );
967
+ }
968
+ /**
969
+ * When overlays are added manage the open state of exisiting overlays appropriately:
970
+ * - 'modal': should close other non-'modal' and non-'manual' overlays
971
+ * - 'page': should close other non-'modal' and non-'manual' overlays
972
+ * - 'auto': should close other 'auto' overlays and other 'hint' overlays, but not 'manual' overlays
973
+ * - 'manual': shouldn't close other overlays
974
+ * - 'hint': shouldn't close other overlays and give way to all other overlays on a trigger
975
+ */
976
+ add(overlay2) {
977
+ if (this.stack.includes(overlay2)) {
978
+ const overlayIndex = this.stack.indexOf(overlay2);
979
+ if (overlayIndex !== -1) {
980
+ this.stack.splice(overlayIndex, 1);
981
+ this.stack.push(overlay2);
982
+ }
983
+ return;
984
+ }
985
+ if (overlay2.type === "auto" || overlay2.type === "modal" || overlay2.type === "page") {
986
+ const queryPathEventName = "luzmo-overlay-query-path";
987
+ const queryPathEvent = new Event(queryPathEventName, {
988
+ composed: true,
989
+ bubbles: true
990
+ });
991
+ overlay2.addEventListener(
992
+ queryPathEventName,
993
+ (event) => {
994
+ const path = event.composedPath();
995
+ this.stack.forEach((overlayEl) => {
996
+ const inPath = path.find((el) => el === overlayEl);
997
+ if (!inPath && overlayEl.type !== "manual" && overlayEl.type !== "modal") {
998
+ this.closeOverlay(overlayEl);
999
+ }
1000
+ });
1001
+ },
1002
+ { once: true }
1003
+ );
1004
+ overlay2.dispatchEvent(queryPathEvent);
1005
+ } else if (overlay2.type === "hint") {
1006
+ const hasPrevious = this.stack.some(
1007
+ (overlayEl) => overlayEl.type !== "manual" && overlayEl.triggerElement && overlayEl.triggerElement === overlay2.triggerElement
1008
+ );
1009
+ if (hasPrevious) {
1010
+ overlay2.open = false;
1011
+ return;
1012
+ }
1013
+ this.stack.forEach((overlayEl) => {
1014
+ if (overlayEl.type === "hint") {
1015
+ this.closeOverlay(overlayEl);
1016
+ }
1017
+ });
1018
+ }
1019
+ requestAnimationFrame(() => {
1020
+ this.stack.push(overlay2);
1021
+ overlay2.addEventListener("beforetoggle", this.handleBeforetoggle, {
1022
+ once: true
1023
+ });
1024
+ });
1025
+ }
1026
+ remove(overlay2) {
1027
+ this.closeOverlay(overlay2);
1028
+ }
1029
+ }
1030
+ const overlayStack = new OverlayStack();
1031
+ const styles = ':host{display:contents;pointer-events:none;--luzmo-overlay-animation-distance: .5rem}:host(:has(> luzmo-tooltip)){--luzmo-overlay-animation-distance: var( --luzmo-tooltip-animation-distance, 4px )}.dialog{margin:0;border:0;background:none;padding:0;position:fixed;overflow:visible;opacity:1!important;box-sizing:border-box;max-height:calc(100vh - 16px);max-height:calc(100dvh - 16px);max-width:calc(100vw - 16px);height:auto;inset:auto;top:0;left:0;display:flex;--luzmo-overlay-open: true}.dialog:not([is-visible]){display:none}.dialog:focus{outline:none}dialog:modal{--luzmo-popover-filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, .15))}:host(:not([open])) .dialog{--luzmo-overlay-open: false}.dialog::backdrop{display:none}.dialog:before{position:absolute;top:-999em;right:-999em;bottom:-999em;left:-999em;content:"";pointer-events:auto!important}.dialog:not(.not-immediately-closable):before{display:none}.dialog>div{width:100%}::slotted(*){pointer-events:auto;visibility:visible!important}::slotted(luzmo-popover){position:static}.dialog:not([actual-placement])[placement*=top]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:var(--luzmo-overlay-animation-distance)}.dialog:not([actual-placement])[placement*=right]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog:not([actual-placement])[placement*=bottom]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog:not([actual-placement])[placement*=left]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:var(--luzmo-overlay-animation-distance)}.dialog[actual-placement*=top]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:var(--luzmo-overlay-animation-distance)}.dialog[actual-placement*=right]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog[actual-placement*=bottom]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog[actual-placement*=left]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:var(--luzmo-overlay-animation-distance)}slot[name=longpress-describedby-descriptor]{display:none}@supports selector(:open){.dialog{opacity:0}.dialog:open{opacity:1;--luzmo-popover-filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, .15))}}@supports selector(:popover-open){.dialog{opacity:0}.dialog:popover-open{opacity:1;--luzmo-popover-filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, .15))}}@supports (overlay: auto){.dialog{display:none;transition:all var(--luzmo-overlay-animation-duration, .13s),translate 0s,display var(--luzmo-overlay-animation-duration, .13s);transition-behavior:allow-discrete}.dialog:popover-open,.dialog:modal{display:flex}}@supports (not selector(:open)) and (not selector(:popover-open)){:host:not([open]) .dialog{pointer-events:none}.dialog[actual-placement]{z-index:calc(var(--luzmo-overlay-z-index-base, 1000) + var(--luzmo-overlay-open-count))}}';
1032
+ function roundByDPR(num) {
1033
+ if (num === void 0) {
1034
+ return 0;
1035
+ }
1036
+ const dpr = window.devicePixelRatio || 1;
1037
+ return Math.round(num * dpr) / dpr;
1038
+ }
1039
+ const REQUIRED_DISTANCE_TO_EDGE = 8;
1040
+ const MIN_OVERLAY_HEIGHT = 100;
1041
+ const getFallbackPlacements = (placement) => {
1042
+ const fallbacks = {
1043
+ left: ["right", "bottom", "top"],
1044
+ "left-start": ["right-start", "bottom", "top"],
1045
+ "left-end": ["right-end", "bottom", "top"],
1046
+ right: ["left", "bottom", "top"],
1047
+ "right-start": ["left-start", "bottom", "top"],
1048
+ "right-end": ["left-end", "bottom", "top"],
1049
+ top: ["bottom", "left", "right"],
1050
+ "top-start": ["bottom-start", "left", "right"],
1051
+ "top-end": ["bottom-end", "left", "right"],
1052
+ bottom: ["top", "left", "right"],
1053
+ "bottom-start": ["top-start", "left", "right"],
1054
+ "bottom-end": ["top-end", "left", "right"]
1055
+ };
1056
+ return fallbacks[placement] ?? [placement];
1057
+ };
1058
+ const placementUpdatedSymbol = Symbol("placement updated");
1059
+ class PlacementController {
1060
+ /**
1061
+ * Creates an instance of the PlacementController.
1062
+ *
1063
+ * @param host - The host element that uses this controller.
1064
+ */
1065
+ constructor(host) {
1066
+ this.originalPlacements = /* @__PURE__ */ new WeakMap();
1067
+ this.allowPlacementUpdate = false;
1068
+ this.closeForAncestorUpdate = () => {
1069
+ if (!this.allowPlacementUpdate && this.options.type !== "modal" && this.cleanup) {
1070
+ this.target.dispatchEvent(new Event("close", { bubbles: true }));
1071
+ }
1072
+ this.allowPlacementUpdate = false;
1073
+ };
1074
+ this.updatePlacement = () => {
1075
+ this.computePlacement();
1076
+ };
1077
+ this.resetOverlayPosition = () => {
1078
+ if (!this.target || !this.options) {
1079
+ return;
1080
+ }
1081
+ this.clearOverlayPosition();
1082
+ this.host.offsetHeight;
1083
+ this.computePlacement();
1084
+ };
1085
+ this.host = host;
1086
+ this.host.addController(this);
1087
+ }
1088
+ /**
1089
+ * Places the overlay relative to the target element.
1090
+ *
1091
+ * This method sets up the necessary configurations and event listeners to manage the
1092
+ * positioning and constraints of the overlay element.
1093
+ *
1094
+ * @param [target=this.target] - The target element for the overlay.
1095
+ * @param [options=this.options] - The options for configuring the overlay placement.
1096
+ * @returns A promise that resolves when the overlay has been placed.
1097
+ */
1098
+ placeOverlay(target = this.target, options = this.options) {
1099
+ this.target = target;
1100
+ this.options = options;
1101
+ if (!target || !options) {
1102
+ return;
1103
+ }
1104
+ const cleanupAncestorResize = autoUpdate(
1105
+ options.trigger,
1106
+ target,
1107
+ this.closeForAncestorUpdate,
1108
+ {
1109
+ ancestorResize: false,
1110
+ elementResize: false,
1111
+ layoutShift: false
1112
+ }
1113
+ );
1114
+ const cleanupElementResize = autoUpdate(
1115
+ options.trigger,
1116
+ target,
1117
+ this.updatePlacement,
1118
+ {
1119
+ ancestorScroll: false
1120
+ }
1121
+ );
1122
+ this.cleanup = () => {
1123
+ var _a2;
1124
+ (_a2 = this.host.elements) == null ? void 0 : _a2.forEach((element) => {
1125
+ element.addEventListener(
1126
+ "luzmo-closed",
1127
+ () => {
1128
+ const placement = this.originalPlacements.get(element);
1129
+ if (placement) {
1130
+ element.setAttribute("placement", placement);
1131
+ }
1132
+ this.originalPlacements.delete(element);
1133
+ },
1134
+ { once: true }
1135
+ );
1136
+ });
1137
+ cleanupAncestorResize();
1138
+ cleanupElementResize();
1139
+ };
1140
+ }
1141
+ /**
1142
+ * Computes the placement of the overlay relative to the target element.
1143
+ *
1144
+ * This method calculates the necessary positioning and constraints for the overlay element
1145
+ * using various middleware functions. It updates the overlay's style and attributes based
1146
+ * on the computed position.
1147
+ *
1148
+ * @returns A promise that resolves when the placement has been computed.
1149
+ */
1150
+ async computePlacement() {
1151
+ var _a2, _b;
1152
+ const { options, target } = this;
1153
+ await (document.fonts ? document.fonts.ready : Promise.resolve());
1154
+ const flipMiddleware = options.trigger instanceof HTMLElement ? flip() : flip({
1155
+ padding: REQUIRED_DISTANCE_TO_EDGE,
1156
+ fallbackPlacements: getFallbackPlacements(options.placement)
1157
+ });
1158
+ const [mainAxis = 0, crossAxis = 0] = Array.isArray(options == null ? void 0 : options.offset) ? options.offset : [options.offset, 0];
1159
+ const tipElement = (_a2 = this.host.elements.find(
1160
+ (el) => el.tipElement
1161
+ )) == null ? void 0 : _a2.tipElement;
1162
+ const middleware = [
1163
+ offset({
1164
+ mainAxis,
1165
+ crossAxis
1166
+ }),
1167
+ shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),
1168
+ flipMiddleware,
1169
+ size({
1170
+ padding: REQUIRED_DISTANCE_TO_EDGE,
1171
+ apply: ({ availableWidth, availableHeight, rects: { floating } }) => {
1172
+ const maxHeight = Math.max(
1173
+ MIN_OVERLAY_HEIGHT,
1174
+ Math.floor(availableHeight)
1175
+ );
1176
+ const actualHeight = floating.height;
1177
+ this.initialHeight = this.isConstrained ? this.initialHeight || actualHeight : actualHeight;
1178
+ this.isConstrained = actualHeight < this.initialHeight || maxHeight <= actualHeight;
1179
+ const appliedHeight = this.isConstrained ? `${maxHeight}px` : "";
1180
+ Object.assign(target.style, {
1181
+ maxWidth: `${Math.floor(availableWidth)}px`,
1182
+ maxHeight: appliedHeight
1183
+ });
1184
+ }
1185
+ }),
1186
+ ...tipElement ? [
1187
+ arrow({
1188
+ element: tipElement,
1189
+ padding: options.tipPadding || REQUIRED_DISTANCE_TO_EDGE
1190
+ })
1191
+ ] : []
1192
+ ];
1193
+ const { x, y, placement, middlewareData } = await computePosition(
1194
+ options.trigger,
1195
+ target,
1196
+ {
1197
+ placement: options.placement,
1198
+ middleware,
1199
+ strategy: "fixed"
1200
+ }
1201
+ );
1202
+ Object.assign(target.style, {
1203
+ top: "0px",
1204
+ left: "0px",
1205
+ translate: `${roundByDPR(x)}px ${roundByDPR(y)}px`
1206
+ });
1207
+ target.setAttribute("actual-placement", placement);
1208
+ (_b = this.host.elements) == null ? void 0 : _b.forEach((element) => {
1209
+ if (!this.originalPlacements.has(element)) {
1210
+ this.originalPlacements.set(
1211
+ element,
1212
+ element.getAttribute("placement")
1213
+ );
1214
+ }
1215
+ element.setAttribute("placement", placement);
1216
+ });
1217
+ if (tipElement && middlewareData.arrow) {
1218
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
1219
+ Object.assign(tipElement.style, {
1220
+ top: placement.startsWith("right") || placement.startsWith("left") ? "0px" : "",
1221
+ left: placement.startsWith("bottom") || placement.startsWith("top") ? "0px" : "",
1222
+ translate: `${roundByDPR(arrowX)}px ${roundByDPR(arrowY)}px`
1223
+ });
1224
+ }
1225
+ }
1226
+ /**
1227
+ * Clears the overlay's position styles.
1228
+ *
1229
+ * This method removes the max-height and max-width styles from the target element,
1230
+ * and resets the initial height and constrained state of the overlay.
1231
+ */
1232
+ clearOverlayPosition() {
1233
+ if (!this.target) {
1234
+ return;
1235
+ }
1236
+ this.target.style.removeProperty("max-height");
1237
+ this.target.style.removeProperty("max-width");
1238
+ this.initialHeight = void 0;
1239
+ this.isConstrained = false;
1240
+ }
1241
+ /**
1242
+ * Lifecycle method called when the host element is connected to the DOM.
1243
+ *
1244
+ * This method sets up an event listener to reset the overlay's position when the 'luzmo-update-overlays' event is dispatched.
1245
+ */
1246
+ hostConnected() {
1247
+ document.addEventListener(
1248
+ "luzmo-update-overlays",
1249
+ this.resetOverlayPosition
1250
+ );
1251
+ }
1252
+ /**
1253
+ * Lifecycle method called when the host element is updated.
1254
+ *
1255
+ * This method cleans up resources if the overlay is not open.
1256
+ */
1257
+ hostUpdated() {
1258
+ var _a2;
1259
+ if (!this.host.open) {
1260
+ (_a2 = this.cleanup) == null ? void 0 : _a2.call(this);
1261
+ this.cleanup = void 0;
1262
+ }
1263
+ }
1264
+ /**
1265
+ * Lifecycle method called when the host element is disconnected from the DOM.
1266
+ *
1267
+ * This method removes the event listener and cleans up resources.
1268
+ */
1269
+ hostDisconnected() {
1270
+ var _a2;
1271
+ (_a2 = this.cleanup) == null ? void 0 : _a2.call(this);
1272
+ this.cleanup = void 0;
1273
+ document.removeEventListener(
1274
+ "luzmo-update-overlays",
1275
+ this.resetOverlayPosition
1276
+ );
1277
+ }
1278
+ }
1279
+ var InteractionTypes = /* @__PURE__ */ ((InteractionTypes2) => {
1280
+ InteractionTypes2["click"] = "click";
1281
+ InteractionTypes2["hover"] = "hover";
1282
+ InteractionTypes2["longpress"] = "longpress";
1283
+ return InteractionTypes2;
1284
+ })(InteractionTypes || {});
1285
+ const lastInteractionType = Symbol("lastInteractionType");
1286
+ const SAFARI_FOCUS_RING_CLASS = "remove-focus-ring-safari-hack";
1287
+ class InteractionController {
1288
+ constructor(target, { overlay: overlay2, isPersistent, handleOverlayReady }) {
1289
+ this.target = target;
1290
+ this.isLazilyOpen = false;
1291
+ this.isPersistent = false;
1292
+ this.isPersistent = !!isPersistent;
1293
+ this.handleOverlayReady = handleOverlayReady;
1294
+ if (this.isPersistent) {
1295
+ this.init();
1296
+ }
1297
+ this.overlay = overlay2;
1298
+ }
1299
+ get activelyOpening() {
1300
+ return false;
1301
+ }
1302
+ get open() {
1303
+ var _a2;
1304
+ return ((_a2 = this.overlay) == null ? void 0 : _a2.open) ?? this.isLazilyOpen;
1305
+ }
1306
+ /**
1307
+ * Set `open` against the associated Overlay lazily.
1308
+ */
1309
+ set open(open) {
1310
+ if (open === this.open) {
1311
+ return;
1312
+ }
1313
+ this.isLazilyOpen = open;
1314
+ if (this.overlay) {
1315
+ this.overlay.open = open;
1316
+ this.target[lastInteractionType] = this.type;
1317
+ return;
1318
+ }
1319
+ if (!open) {
1320
+ return;
1321
+ }
1322
+ customElements.whenDefined("luzmo-overlay").then(async () => {
1323
+ const { LuzmoOverlay: LuzmoOverlay2 } = await Promise.resolve().then(() => overlay);
1324
+ this.overlay = new LuzmoOverlay2();
1325
+ this.overlay.open = true;
1326
+ this.target[lastInteractionType] = this.type;
1327
+ });
1328
+ Promise.resolve().then(() => overlay);
1329
+ }
1330
+ get overlay() {
1331
+ return this._overlay;
1332
+ }
1333
+ set overlay(overlay2) {
1334
+ var _a2;
1335
+ if (!overlay2) {
1336
+ return;
1337
+ }
1338
+ if (this.overlay === overlay2) {
1339
+ return;
1340
+ }
1341
+ if (this.overlay) {
1342
+ this.overlay.removeController(this);
1343
+ }
1344
+ this._overlay = overlay2;
1345
+ this.overlay.addController(this);
1346
+ this.initOverlay();
1347
+ this.prepareDescription(this.target);
1348
+ (_a2 = this.handleOverlayReady) == null ? void 0 : _a2.call(this, this.overlay);
1349
+ }
1350
+ prepareDescription(_) {
1351
+ }
1352
+ releaseDescription() {
1353
+ }
1354
+ shouldCompleteOpen() {
1355
+ }
1356
+ /* c8 ignore next 3 */
1357
+ init() {
1358
+ }
1359
+ /* c8 ignore next 3 */
1360
+ initOverlay() {
1361
+ }
1362
+ abort() {
1363
+ var _a2;
1364
+ this.releaseDescription();
1365
+ (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1366
+ }
1367
+ hostConnected() {
1368
+ this.init();
1369
+ }
1370
+ hostDisconnected() {
1371
+ if (!this.isPersistent) {
1372
+ this.abort();
1373
+ }
1374
+ }
1375
+ }
1376
+ class ClickController extends InteractionController {
1377
+ constructor() {
1378
+ super(...arguments);
1379
+ this.type = InteractionTypes.click;
1380
+ this.preventNextToggle = false;
1381
+ }
1382
+ handleClick() {
1383
+ if (!this.preventNextToggle) {
1384
+ this.open = !this.open;
1385
+ }
1386
+ this.preventNextToggle = false;
1387
+ }
1388
+ handlePointerdown() {
1389
+ this.preventNextToggle = this.open;
1390
+ }
1391
+ init() {
1392
+ var _a2;
1393
+ (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1394
+ this.abortController = new AbortController();
1395
+ const { signal } = this.abortController;
1396
+ this.target.addEventListener("click", () => this.handleClick(), {
1397
+ signal
1398
+ });
1399
+ this.target.addEventListener(
1400
+ "pointerdown",
1401
+ () => this.handlePointerdown(),
1402
+ { signal }
1403
+ );
1404
+ }
1405
+ }
1406
+ const HOVER_DELAY = 300;
1407
+ class HoverController extends InteractionController {
1408
+ constructor() {
1409
+ super(...arguments);
1410
+ this.type = InteractionTypes.hover;
1411
+ this.elementIds = [];
1412
+ this.focusedin = false;
1413
+ this.pointerentered = false;
1414
+ }
1415
+ handleKeyup(event) {
1416
+ if (event.code === "Tab" || event.code === "Escape") {
1417
+ this.open = true;
1418
+ this.removeSafariFocusRingClass();
1419
+ }
1420
+ }
1421
+ handleTargetFocusin() {
1422
+ if (!this.target.matches(":focus-visible")) {
1423
+ return;
1424
+ }
1425
+ if (isWebKit() && this.target[lastInteractionType] === InteractionTypes.click) {
1426
+ this.target.classList.add(SAFARI_FOCUS_RING_CLASS);
1427
+ return;
1428
+ }
1429
+ this.open = true;
1430
+ this.focusedin = true;
1431
+ this.removeSafariFocusRingClass();
1432
+ }
1433
+ handleTargetFocusout() {
1434
+ this.removeSafariFocusRingClass();
1435
+ this.focusedin = false;
1436
+ if (this.pointerentered) {
1437
+ return;
1438
+ }
1439
+ this.open = false;
1440
+ }
1441
+ handleTargetPointerenter() {
1442
+ var _a2;
1443
+ if (this.hoverTimeout) {
1444
+ clearTimeout(this.hoverTimeout);
1445
+ this.hoverTimeout = void 0;
1446
+ }
1447
+ if ((_a2 = this.overlay) == null ? void 0 : _a2.disabled) {
1448
+ return;
1449
+ }
1450
+ this.open = true;
1451
+ this.pointerentered = true;
1452
+ }
1453
+ handleTargetPointerleave() {
1454
+ this.doPointerleave();
1455
+ }
1456
+ // set a timeout once the pointer enters and the overlay is shown
1457
+ // give the user time to enter the overlay
1458
+ handleHostPointerenter() {
1459
+ if (this.hoverTimeout) {
1460
+ clearTimeout(this.hoverTimeout);
1461
+ this.hoverTimeout = void 0;
1462
+ }
1463
+ }
1464
+ handleHostPointerleave() {
1465
+ this.doPointerleave();
1466
+ }
1467
+ prepareDescription() {
1468
+ if (this.overlay.elements.length === 0) {
1469
+ return;
1470
+ }
1471
+ const triggerRoot = this.target.getRootNode();
1472
+ const contentRoot = this.overlay.elements[0].getRootNode();
1473
+ const overlayRoot = this.overlay.getRootNode();
1474
+ if (triggerRoot === overlayRoot) {
1475
+ this.prepareOverlayRelativeDescription();
1476
+ } else if (triggerRoot === contentRoot) {
1477
+ this.prepareContentRelativeDescription();
1478
+ }
1479
+ }
1480
+ prepareOverlayRelativeDescription() {
1481
+ const releaseDescription = conditionAttributeWithId(
1482
+ this.target,
1483
+ "aria-describedby",
1484
+ [this.overlay.id]
1485
+ );
1486
+ this.releaseDescription = () => {
1487
+ releaseDescription();
1488
+ this.releaseDescription = noop;
1489
+ };
1490
+ }
1491
+ prepareContentRelativeDescription() {
1492
+ const elementIds = [];
1493
+ const appliedIds = this.overlay.elements.map((el) => {
1494
+ elementIds.push(el.id);
1495
+ if (!el.id) {
1496
+ el.id = `${this.overlay.tagName.toLowerCase()}-helper-${randomID()}`;
1497
+ }
1498
+ return el.id;
1499
+ });
1500
+ this.elementIds = elementIds;
1501
+ const releaseDescription = conditionAttributeWithId(
1502
+ this.target,
1503
+ "aria-describedby",
1504
+ appliedIds
1505
+ );
1506
+ this.releaseDescription = () => {
1507
+ releaseDescription();
1508
+ this.overlay.elements.map((el, index) => {
1509
+ el.id = this.elementIds[index];
1510
+ });
1511
+ this.releaseDescription = noop;
1512
+ };
1513
+ }
1514
+ doPointerleave() {
1515
+ this.pointerentered = false;
1516
+ const triggerElement = this.target;
1517
+ if (this.focusedin && triggerElement.matches(":focus-visible")) {
1518
+ return;
1519
+ }
1520
+ this.hoverTimeout = setTimeout(() => {
1521
+ this.open = false;
1522
+ }, HOVER_DELAY);
1523
+ }
1524
+ init() {
1525
+ var _a2;
1526
+ (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1527
+ this.abortController = new AbortController();
1528
+ const { signal } = this.abortController;
1529
+ this.target.addEventListener("keyup", (event) => this.handleKeyup(event), {
1530
+ signal
1531
+ });
1532
+ this.target.addEventListener("focusin", () => this.handleTargetFocusin(), {
1533
+ signal
1534
+ });
1535
+ this.target.addEventListener(
1536
+ "focusout",
1537
+ () => this.handleTargetFocusout(),
1538
+ { signal }
1539
+ );
1540
+ this.target.addEventListener(
1541
+ "pointerenter",
1542
+ () => this.handleTargetPointerenter(),
1543
+ { signal }
1544
+ );
1545
+ this.target.addEventListener(
1546
+ "pointerleave",
1547
+ () => this.handleTargetPointerleave(),
1548
+ { signal }
1549
+ );
1550
+ if (this.overlay) {
1551
+ this.initOverlay();
1552
+ }
1553
+ }
1554
+ initOverlay() {
1555
+ if (!this.abortController) {
1556
+ return;
1557
+ }
1558
+ const { signal } = this.abortController;
1559
+ this.overlay.addEventListener(
1560
+ "pointerenter",
1561
+ () => this.handleHostPointerenter(),
1562
+ { signal }
1563
+ );
1564
+ this.overlay.addEventListener(
1565
+ "pointerleave",
1566
+ () => this.handleHostPointerleave(),
1567
+ { signal }
1568
+ );
1569
+ }
1570
+ removeSafariFocusRingClass() {
1571
+ if (isWebKit() && this.target.classList.contains(SAFARI_FOCUS_RING_CLASS))
1572
+ this.target.classList.remove(SAFARI_FOCUS_RING_CLASS);
1573
+ }
1574
+ }
1575
+ const longPressDuration = 300;
1576
+ const LONGPRESS_INSTRUCTIONS = {
1577
+ touch: "Double tap and long press for additional options",
1578
+ keyboard: "Press Space or Alt+Down Arrow for additional options",
1579
+ mouse: "Click and hold for additional options"
1580
+ };
1581
+ class LongpressController extends InteractionController {
1582
+ constructor() {
1583
+ super(...arguments);
1584
+ this.type = InteractionTypes.longpress;
1585
+ this.longpressState = null;
1586
+ this.releaseDescription = noop;
1587
+ this.handlePointerup = () => {
1588
+ var _a2;
1589
+ clearTimeout(this.timeout);
1590
+ if (!this.target) {
1591
+ return;
1592
+ }
1593
+ this.longpressState = ((_a2 = this.overlay) == null ? void 0 : _a2.state) === "opening" ? "pressed" : null;
1594
+ document.removeEventListener("pointerup", this.handlePointerup);
1595
+ document.removeEventListener("pointercancel", this.handlePointerup);
1596
+ };
1597
+ }
1598
+ get activelyOpening() {
1599
+ return this.longpressState === "opening" || this.longpressState === "pressed";
1600
+ }
1601
+ handleLongpress() {
1602
+ this.open = true;
1603
+ this.longpressState = this.longpressState === "potential" ? "opening" : "pressed";
1604
+ }
1605
+ handlePointerdown(event) {
1606
+ if (!this.target) {
1607
+ return;
1608
+ }
1609
+ if (event.button !== 0) {
1610
+ return;
1611
+ }
1612
+ this.longpressState = "potential";
1613
+ document.addEventListener("pointerup", this.handlePointerup);
1614
+ document.addEventListener("pointercancel", this.handlePointerup);
1615
+ const triggerHandlesLongpress = "holdAffordance" in this.target;
1616
+ if (triggerHandlesLongpress) {
1617
+ return;
1618
+ }
1619
+ this.timeout = setTimeout(() => {
1620
+ if (!this.target) {
1621
+ return;
1622
+ }
1623
+ this.target.dispatchEvent(
1624
+ new CustomEvent("longpress", {
1625
+ bubbles: true,
1626
+ composed: true,
1627
+ detail: {
1628
+ source: "pointer"
1629
+ }
1630
+ })
1631
+ );
1632
+ }, longPressDuration);
1633
+ }
1634
+ handleKeydown(event) {
1635
+ const { code, altKey } = event;
1636
+ if (altKey && code === "ArrowDown") {
1637
+ event.stopPropagation();
1638
+ event.stopImmediatePropagation();
1639
+ }
1640
+ }
1641
+ handleKeyup(event) {
1642
+ const { code, altKey } = event;
1643
+ if (code === "Space" || altKey && code === "ArrowDown") {
1644
+ if (!this.target) {
1645
+ return;
1646
+ }
1647
+ event.stopPropagation();
1648
+ this.target.dispatchEvent(
1649
+ new CustomEvent("longpress", {
1650
+ bubbles: true,
1651
+ composed: true,
1652
+ detail: {
1653
+ source: "keyboard"
1654
+ }
1655
+ })
1656
+ );
1657
+ setTimeout(() => {
1658
+ this.longpressState = null;
1659
+ });
1660
+ }
1661
+ }
1662
+ prepareDescription(trigger) {
1663
+ if (
1664
+ // do not reapply until target is recycled
1665
+ this.releaseDescription !== noop || // require "longpress content" to apply relationship
1666
+ this.overlay.elements.length === 0
1667
+ ) {
1668
+ return;
1669
+ }
1670
+ const longpressDescription = document.createElement("div");
1671
+ longpressDescription.id = `longpress-describedby-descriptor-${randomID()}`;
1672
+ const messageType = isIOS() || isAndroid() ? "touch" : "keyboard";
1673
+ longpressDescription.textContent = LONGPRESS_INSTRUCTIONS[messageType];
1674
+ longpressDescription.slot = "longpress-describedby-descriptor";
1675
+ const triggerParent = trigger.getRootNode();
1676
+ const overlayParent = this.overlay.getRootNode();
1677
+ if (triggerParent === overlayParent) {
1678
+ this.overlay.append(longpressDescription);
1679
+ } else {
1680
+ longpressDescription.hidden = !("host" in triggerParent);
1681
+ trigger.after(longpressDescription);
1682
+ }
1683
+ const releaseDescription = conditionAttributeWithId(
1684
+ trigger,
1685
+ "aria-describedby",
1686
+ [longpressDescription.id]
1687
+ );
1688
+ this.releaseDescription = () => {
1689
+ releaseDescription();
1690
+ longpressDescription.remove();
1691
+ this.releaseDescription = noop;
1692
+ };
1693
+ }
1694
+ shouldCompleteOpen() {
1695
+ this.longpressState = this.longpressState === "pressed" ? null : this.longpressState;
1696
+ }
1697
+ init() {
1698
+ var _a2;
1699
+ (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1700
+ this.abortController = new AbortController();
1701
+ const { signal } = this.abortController;
1702
+ this.target.addEventListener("longpress", () => this.handleLongpress(), {
1703
+ signal
1704
+ });
1705
+ this.target.addEventListener(
1706
+ "pointerdown",
1707
+ (event) => this.handlePointerdown(event),
1708
+ { signal }
1709
+ );
1710
+ this.prepareDescription(this.target);
1711
+ if (this.target.holdAffordance) {
1712
+ return;
1713
+ }
1714
+ this.target.addEventListener(
1715
+ "keydown",
1716
+ (event) => this.handleKeydown(event),
1717
+ { signal }
1718
+ );
1719
+ this.target.addEventListener(
1720
+ "keyup",
1721
+ (event) => this.handleKeyup(event),
1722
+ { signal }
1723
+ );
1724
+ }
1725
+ }
1726
+ const strategies = {
1727
+ click: ClickController,
1728
+ longpress: LongpressController,
1729
+ hover: HoverController
1730
+ };
1731
+ var __defProp = Object.defineProperty;
1732
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1733
+ var __decorateClass = (decorators, target, key, kind) => {
1734
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
1735
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1736
+ if (decorator = decorators[i])
1737
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1738
+ if (kind && result) __defProp(target, key, result);
1739
+ return result;
1740
+ };
1741
+ const browserSupportsPopover = typeof document !== "undefined" && "showPopover" in document.createElement("div");
1742
+ let ComputedOverlayBase = OverlayDialog(LuzmoAbstractOverlay);
1743
+ ComputedOverlayBase = browserSupportsPopover ? OverlayPopover(ComputedOverlayBase) : OverlayNoPopover(ComputedOverlayBase);
1744
+ const _LuzmoOverlay = (_a = class extends ComputedOverlayBase {
1745
+ constructor() {
1746
+ super(...arguments);
1747
+ this._delayed = false;
1748
+ this._disabled = false;
1749
+ this.offset = 0;
1750
+ this._open = false;
1751
+ this.lastRequestSlottableState = false;
1752
+ this.receivesFocus = "auto";
1753
+ this._state = "closed";
1754
+ this.triggerElement = null;
1755
+ this.type = "auto";
1756
+ this.wasOpen = false;
1757
+ this.closeOnFocusOut = (event) => {
1758
+ if (!event.relatedTarget) {
1759
+ return;
1760
+ }
1761
+ const relationEvent = new Event("overlay-relation-query", {
1762
+ bubbles: true,
1763
+ composed: true
1764
+ });
1765
+ event.relatedTarget.addEventListener(relationEvent.type, (e) => {
1766
+ const path = e.composedPath();
1767
+ const isWithinOverlay = path.includes(this);
1768
+ if (!isWithinOverlay) {
1769
+ this.open = false;
1770
+ }
1771
+ });
1772
+ event.relatedTarget.dispatchEvent(relationEvent);
1773
+ };
1774
+ }
1775
+ get delayed() {
1776
+ var _a2;
1777
+ return ((_a2 = this.elements.at(-1)) == null ? void 0 : _a2.hasAttribute("delayed")) || this._delayed;
1778
+ }
1779
+ set delayed(delayed) {
1780
+ this._delayed = delayed;
1781
+ }
1782
+ get disabled() {
1783
+ return this._disabled;
1784
+ }
1785
+ set disabled(disabled) {
1786
+ var _a2;
1787
+ this._disabled = disabled;
1788
+ if (disabled) {
1789
+ (_a2 = this.strategy) == null ? void 0 : _a2.abort();
1790
+ this.wasOpen = this.open;
1791
+ this.open = false;
1792
+ } else {
1793
+ this.bindEvents();
1794
+ this.open = this.open || this.wasOpen;
1795
+ this.wasOpen = false;
1796
+ }
1797
+ }
1798
+ /**
1799
+ * Determines if the overlay has a non-virtual trigger element.
1800
+ *
1801
+ * @returns `true` if the trigger element is not a virtual trigger, otherwise `false`.
1802
+ */
1803
+ get hasNonVirtualTrigger() {
1804
+ return !!this.triggerElement && !(this.triggerElement instanceof VirtualTrigger);
1805
+ }
1806
+ /**
1807
+ * Provides an instance of the `PlacementController` for managing the positioning
1808
+ * of the overlay relative to its trigger element.
1809
+ *
1810
+ * If the `PlacementController` instance does not already exist, it is created and
1811
+ * assigned to the `_placementController` property.
1812
+ *
1813
+ * @protected
1814
+ * @returns The `PlacementController` instance.
1815
+ */
1816
+ get placementController() {
1817
+ if (!this._placementController) {
1818
+ this._placementController = new PlacementController(this);
1819
+ }
1820
+ return this._placementController;
1821
+ }
1822
+ get open() {
1823
+ return this._open;
1824
+ }
1825
+ set open(open) {
1826
+ var _a2;
1827
+ if (open && this.disabled) {
1828
+ return;
1829
+ }
1830
+ if (open === this.open) {
1831
+ return;
1832
+ }
1833
+ if (((_a2 = this.strategy) == null ? void 0 : _a2.activelyOpening) && !open) {
1834
+ return;
1835
+ }
1836
+ this._open = open;
1837
+ if (this.open) {
1838
+ _a.openCount += 1;
1839
+ }
1840
+ this.requestUpdate("open", !this.open);
1841
+ if (this.open) {
1842
+ this.requestSlottable();
1843
+ }
1844
+ }
1845
+ get state() {
1846
+ return this._state;
1847
+ }
1848
+ set state(state2) {
1849
+ var _a2;
1850
+ if (state2 === this.state) {
1851
+ return;
1852
+ }
1853
+ const oldState = this.state;
1854
+ this._state = state2;
1855
+ if (this.state === "opened" || this.state === "closed") {
1856
+ (_a2 = this.strategy) == null ? void 0 : _a2.shouldCompleteOpen();
1857
+ }
1858
+ this.requestUpdate("state", oldState);
1859
+ }
1860
+ /**
1861
+ * Provides an instance of the `ElementResolutionController` for managing the element
1862
+ * that the overlay should be associated with. If the instance does not already exist,
1863
+ * it is created and assigned to the `_elementResolver` property.
1864
+ *
1865
+ * @protected
1866
+ * @returns The `ElementResolutionController` instance.
1867
+ */
1868
+ get elementResolver() {
1869
+ if (!this._elementResolver) {
1870
+ this._elementResolver = new ElementResolutionController(this);
1871
+ }
1872
+ return this._elementResolver;
1873
+ }
1874
+ /**
1875
+ * Determines if the overlay uses a dialog.
1876
+ * Returns `true` if the overlay type is "modal" or "page".
1877
+ *
1878
+ * @private
1879
+ * @returns `true` if the overlay uses a dialog, otherwise `false`.
1880
+ */
1881
+ get usesDialog() {
1882
+ return this.type === "modal" || this.type === "page";
1883
+ }
1884
+ /**
1885
+ * Determines the value for the popover attribute based on the overlay type.
1886
+ *
1887
+ * @private
1888
+ * @returns The popover value or undefined if not applicable.
1889
+ */
1890
+ get popoverValue() {
1891
+ const hasPopoverAttribute = "popover" in this;
1892
+ if (!hasPopoverAttribute) {
1893
+ return void 0;
1894
+ }
1895
+ switch (this.type) {
1896
+ case "modal":
1897
+ case "page": {
1898
+ return void 0;
1899
+ }
1900
+ case "hint": {
1901
+ return "manual";
1902
+ }
1903
+ default: {
1904
+ return this.type;
1905
+ }
1906
+ }
1907
+ }
1908
+ /**
1909
+ * Determines if the overlay requires positioning based on its type and state.
1910
+ *
1911
+ * @protected
1912
+ * @returns True if the overlay requires positioning, otherwise false.
1913
+ */
1914
+ get requiresPositioning() {
1915
+ if (this.type === "page" || !this.open) {
1916
+ return false;
1917
+ }
1918
+ if (!this.triggerElement || !this.placement && this.type !== "hint") {
1919
+ return false;
1920
+ }
1921
+ return true;
1922
+ }
1923
+ /**
1924
+ * Manages the positioning of the overlay relative to its trigger element.
1925
+ *
1926
+ * This method calculates the necessary parameters for positioning the overlay,
1927
+ * such as offset, placement, and tip padding, and then delegates the actual
1928
+ * positioning to the `PlacementController`.
1929
+ *
1930
+ * @protected
1931
+ * @override
1932
+ */
1933
+ managePosition() {
1934
+ if (!this.requiresPositioning || !this.open) {
1935
+ return;
1936
+ }
1937
+ const offset2 = this.offset || 0;
1938
+ const trigger = this.triggerElement;
1939
+ const placement = this.placement || "right";
1940
+ const tipPadding = this.tipPadding;
1941
+ this.placementController.placeOverlay(this.dialogEl, {
1942
+ offset: offset2,
1943
+ placement,
1944
+ tipPadding,
1945
+ trigger,
1946
+ type: this.type
1947
+ });
1948
+ }
1949
+ /**
1950
+ * Manages the process of opening the popover.
1951
+ *
1952
+ * This method handles the necessary steps to open the popover, including managing delays,
1953
+ * ensuring the popover is in the DOM, making transitions, and applying focus.
1954
+ *
1955
+ * @protected
1956
+ * @override
1957
+ * @returns A promise that resolves when the popover has been fully opened.
1958
+ */
1959
+ async managePopoverOpen() {
1960
+ super.managePopoverOpen();
1961
+ const targetOpenState = this.open;
1962
+ if (this.open !== targetOpenState) {
1963
+ return;
1964
+ }
1965
+ await this.manageDelay(targetOpenState);
1966
+ if (this.open !== targetOpenState) {
1967
+ return;
1968
+ }
1969
+ if (this.triggerInteraction === "longpress") {
1970
+ await nextFrame();
1971
+ }
1972
+ await this.ensureOnDOM(targetOpenState);
1973
+ if (this.open !== targetOpenState) {
1974
+ return;
1975
+ }
1976
+ const focusEl = await this.makeTransition(targetOpenState);
1977
+ if (this.open !== targetOpenState) {
1978
+ return;
1979
+ }
1980
+ await this.applyFocus(targetOpenState, focusEl);
1981
+ }
1982
+ /**
1983
+ * Applies focus to the appropriate element after the popover has been opened.
1984
+ *
1985
+ * This method handles the focus management for the overlay, ensuring that the correct
1986
+ * element receives focus based on the overlay's type and state.
1987
+ *
1988
+ * @protected
1989
+ * @override
1990
+ * @param targetOpenState - The target open state of the overlay.
1991
+ * @param focusEl - The element to focus after opening the popover.
1992
+ * @returns A promise that resolves when the focus has been applied.
1993
+ */
1994
+ async applyFocus(targetOpenState, focusEl) {
1995
+ if (this.receivesFocus === "false" || this.type === "hint") {
1996
+ return;
1997
+ }
1998
+ await nextFrame();
1999
+ await nextFrame();
2000
+ if (targetOpenState === this.open && !this.open) {
2001
+ if (this.hasNonVirtualTrigger && this.contains(this.getRootNode().activeElement)) {
2002
+ this.triggerElement.focus();
2003
+ }
2004
+ return;
2005
+ }
2006
+ focusEl == null ? void 0 : focusEl.focus();
2007
+ }
2008
+ /**
2009
+ * Returns focus to the trigger element if the overlay is closed.
2010
+ *
2011
+ * This method ensures that focus is returned to the trigger element when the overlay is closed,
2012
+ * unless the overlay is of type "hint" or the focus is already outside the overlay.
2013
+ *
2014
+ * @protected
2015
+ * @override
2016
+ */
2017
+ returnFocus() {
2018
+ var _a2;
2019
+ if (this.open || this.type === "hint") {
2020
+ return;
2021
+ }
2022
+ const getAncestors = () => {
2023
+ var _a3, _b;
2024
+ const ancestors = [];
2025
+ let currentNode = typeof document !== "undefined" ? document.activeElement : null;
2026
+ while ((_a3 = currentNode == null ? void 0 : currentNode.shadowRoot) == null ? void 0 : _a3.activeElement) {
2027
+ currentNode = currentNode.shadowRoot.activeElement;
2028
+ }
2029
+ while (currentNode) {
2030
+ const ancestor = currentNode.assignedSlot || currentNode.parentElement || ((_b = currentNode.getRootNode()) == null ? void 0 : _b.host);
2031
+ if (ancestor) {
2032
+ ancestors.push(ancestor);
2033
+ }
2034
+ currentNode = ancestor;
2035
+ }
2036
+ return ancestors;
2037
+ };
2038
+ if (this.receivesFocus !== "false" && !!((_a2 = this.triggerElement) == null ? void 0 : _a2.focus) && (this.contains(this.getRootNode().activeElement) || getAncestors().includes(this) || typeof document !== "undefined" && document.activeElement === document.body)) {
2039
+ this.triggerElement.focus();
2040
+ }
2041
+ }
2042
+ /**
2043
+ * Manages the process of opening or closing the overlay.
2044
+ *
2045
+ * This method handles the necessary steps to open or close the overlay, including updating the state,
2046
+ * managing the overlay stack, and handling focus events.
2047
+ *
2048
+ * @protected
2049
+ * @param oldOpen - The previous open state of the overlay.
2050
+ * @returns A promise that resolves when the overlay has been fully managed.
2051
+ */
2052
+ async manageOpen(oldOpen) {
2053
+ if (!this.isConnected && this.open) {
2054
+ return;
2055
+ }
2056
+ if (!this.hasUpdated) {
2057
+ await this.updateComplete;
2058
+ }
2059
+ if (this.open) {
2060
+ overlayStack.add(this);
2061
+ if (this.willPreventClose) {
2062
+ document.addEventListener(
2063
+ "pointerup",
2064
+ () => {
2065
+ this.dialogEl.classList.toggle("not-immediately-closable", false);
2066
+ this.willPreventClose = false;
2067
+ },
2068
+ { once: true }
2069
+ );
2070
+ this.dialogEl.classList.toggle("not-immediately-closable", true);
2071
+ }
2072
+ } else {
2073
+ if (oldOpen) {
2074
+ this.dispose();
2075
+ }
2076
+ overlayStack.remove(this);
2077
+ }
2078
+ if (this.open && this.state !== "opened") {
2079
+ this.state = "opening";
2080
+ } else if (!this.open && this.state !== "closed") {
2081
+ this.state = "closing";
2082
+ }
2083
+ if (this.usesDialog) {
2084
+ this.manageDialogOpen();
2085
+ } else {
2086
+ this.managePopoverOpen();
2087
+ }
2088
+ if (this.type === "auto") {
2089
+ const listenerRoot = this.getRootNode();
2090
+ if (this.open) {
2091
+ listenerRoot.addEventListener("focusout", this.closeOnFocusOut, {
2092
+ capture: true
2093
+ });
2094
+ } else {
2095
+ listenerRoot.removeEventListener("focusout", this.closeOnFocusOut, {
2096
+ capture: true
2097
+ });
2098
+ }
2099
+ }
2100
+ }
2101
+ /**
2102
+ * Binds event handling strategies to the overlay based on the specified trigger interaction.
2103
+ *
2104
+ * This method sets up the appropriate event handling strategy for the overlay, ensuring that
2105
+ * it responds correctly to user interactions such as clicks, hovers, or long presses.
2106
+ *
2107
+ * @protected
2108
+ */
2109
+ bindEvents() {
2110
+ var _a2;
2111
+ (_a2 = this.strategy) == null ? void 0 : _a2.abort();
2112
+ this.strategy = void 0;
2113
+ if (!this.hasNonVirtualTrigger) {
2114
+ return;
2115
+ }
2116
+ if (!this.triggerInteraction) {
2117
+ return;
2118
+ }
2119
+ this.strategy = new strategies[this.triggerInteraction](
2120
+ this.triggerElement,
2121
+ {
2122
+ overlay: this
2123
+ }
2124
+ );
2125
+ }
2126
+ /**
2127
+ * Handles the `beforetoggle` event to manage the overlay's state.
2128
+ *
2129
+ * This method checks the new state of the event and calls `handleBrowserClose`
2130
+ * if the new state is not 'open'.
2131
+ *
2132
+ * @protected
2133
+ * @param event - The `beforetoggle` event with the new state.
2134
+ */
2135
+ handleBeforetoggle(event) {
2136
+ if (event.newState !== "open") {
2137
+ this.handleBrowserClose(event);
2138
+ }
2139
+ }
2140
+ /**
2141
+ * Handles the browser's close event to manage the overlay's state.
2142
+ *
2143
+ * This method stops the propagation of the event and closes the overlay if it is not
2144
+ * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.
2145
+ *
2146
+ * @protected
2147
+ * @param event - The browser's close event.
2148
+ */
2149
+ handleBrowserClose(event) {
2150
+ var _a2;
2151
+ event.stopPropagation();
2152
+ if (!((_a2 = this.strategy) == null ? void 0 : _a2.activelyOpening)) {
2153
+ this.open = false;
2154
+ return;
2155
+ }
2156
+ this.manuallyKeepOpen();
2157
+ }
2158
+ /**
2159
+ * Manually keeps the overlay open.
2160
+ *
2161
+ * This method sets the overlay to open, allows placement updates, and manages the open state.
2162
+ *
2163
+ * @public
2164
+ * @override
2165
+ */
2166
+ manuallyKeepOpen() {
2167
+ this.open = true;
2168
+ this.placementController.allowPlacementUpdate = true;
2169
+ this.manageOpen(false);
2170
+ }
2171
+ /**
2172
+ * Handles the `slotchange` event to manage the overlay's state.
2173
+ *
2174
+ * This method checks if there are any elements in the slot. If there are no elements,
2175
+ * it releases the description from the strategy. If there are elements and the trigger
2176
+ * is non-virtual, it prepares the description for the trigger element.
2177
+ *
2178
+ * @protected
2179
+ */
2180
+ handleSlotchange() {
2181
+ var _a2, _b;
2182
+ if (this.elements.length === 0) {
2183
+ (_a2 = this.strategy) == null ? void 0 : _a2.releaseDescription();
2184
+ } else if (this.hasNonVirtualTrigger) {
2185
+ (_b = this.strategy) == null ? void 0 : _b.prepareDescription(this.triggerElement);
2186
+ }
2187
+ }
2188
+ /**
2189
+ * Determines whether the overlay should prevent closing.
2190
+ *
2191
+ * This method checks the `willPreventClose` flag and resets it to `false`.
2192
+ * It returns the value of the `willPreventClose` flag.
2193
+ *
2194
+ * @public
2195
+ * @returns `true` if the overlay should prevent closing, otherwise `false`.
2196
+ */
2197
+ shouldPreventClose() {
2198
+ const shouldPreventClose = this.willPreventClose;
2199
+ this.willPreventClose = false;
2200
+ return shouldPreventClose;
2201
+ }
2202
+ /**
2203
+ * Requests slottable content for the overlay.
2204
+ *
2205
+ * This method dispatches a `SlottableRequestEvent` to request or remove slottable content
2206
+ * based on the current open state of the overlay. It ensures that the same state is not
2207
+ * dispatched twice in a row.
2208
+ *
2209
+ * @protected
2210
+ * @override
2211
+ */
2212
+ requestSlottable() {
2213
+ if (this.lastRequestSlottableState === this.open) {
2214
+ return;
2215
+ }
2216
+ if (!this.open) {
2217
+ document.body.offsetHeight;
2218
+ }
2219
+ this.dispatchEvent(
2220
+ new SlottableRequestEvent(
2221
+ "overlay-content",
2222
+ this.open ? {} : removeSlottableRequest
2223
+ )
2224
+ );
2225
+ this.lastRequestSlottableState = this.open;
2226
+ }
2227
+ /**
2228
+ * Lifecycle method called before the component updates.
2229
+ *
2230
+ * This method handles various tasks before the component updates, such as setting an ID,
2231
+ * managing the open state, resolving the trigger element, and binding events.
2232
+ *
2233
+ * @override
2234
+ * @param changes - The properties that have changed.
2235
+ */
2236
+ willUpdate(changes) {
2237
+ var _a2;
2238
+ if (!this.hasAttribute("id")) {
2239
+ this.setAttribute("id", `${this.tagName.toLowerCase()}-${randomID()}`);
2240
+ }
2241
+ if (changes.has("open") && (this.hasUpdated || this.open)) {
2242
+ this.manageOpen(changes.get("open"));
2243
+ }
2244
+ if (changes.has("trigger")) {
2245
+ const [id, interaction] = ((_a2 = this.trigger) == null ? void 0 : _a2.split("@")) || [];
2246
+ this.elementResolver.selector = id ? `#${id}` : "";
2247
+ this.triggerInteraction = interaction;
2248
+ }
2249
+ let oldTrigger = false;
2250
+ if (changes.has(elementResolverUpdatedSymbol)) {
2251
+ oldTrigger = this.triggerElement;
2252
+ this.triggerElement = this.elementResolver.element;
2253
+ }
2254
+ if (changes.has("triggerElement")) {
2255
+ oldTrigger = changes.get("triggerElement");
2256
+ }
2257
+ if (oldTrigger !== false) {
2258
+ this.bindEvents();
2259
+ }
2260
+ }
2261
+ /**
2262
+ * Lifecycle method called after the component updates.
2263
+ *
2264
+ * This method handles various tasks after the component updates, such as updating the placement
2265
+ * attribute, resetting the overlay position, and clearing the overlay position based on the state.
2266
+ *
2267
+ * @override
2268
+ * @param changes - The properties that have changed.
2269
+ */
2270
+ updated(changes) {
2271
+ super.updated(changes);
2272
+ if (changes.has("placement")) {
2273
+ if (this.placement) {
2274
+ this.dialogEl.setAttribute("actual-placement", this.placement);
2275
+ } else {
2276
+ this.dialogEl.removeAttribute("actual-placement");
2277
+ }
2278
+ if (this.open && changes.get("placement") !== void 0) {
2279
+ this.placementController.resetOverlayPosition();
2280
+ }
2281
+ }
2282
+ if (changes.has("state") && this.state === "closed" && changes.get("state") !== void 0) {
2283
+ this.placementController.clearOverlayPosition();
2284
+ }
2285
+ }
2286
+ /**
2287
+ * Renders the content of the overlay.
2288
+ *
2289
+ * This method returns a template result containing a slot element. The slot element
2290
+ * listens for the `slotchange` event to manage the overlay's state.
2291
+ *
2292
+ * @protected
2293
+ * @returns The template result containing the slot element.
2294
+ */
2295
+ renderContent() {
2296
+ return html` <slot @slotchange=${this.handleSlotchange}></slot> `;
2297
+ }
2298
+ /**
2299
+ * Generates a style map for the dialog element.
2300
+ *
2301
+ * This method returns an object containing CSS custom properties for the dialog element.
2302
+ * The `--luzmo-overlay-open-count` custom property is set to the current open count of overlays.
2303
+ *
2304
+ * @private
2305
+ * @returns The style map for the dialog element.
2306
+ */
2307
+ get dialogStyleMap() {
2308
+ return {
2309
+ "--luzmo-overlay-open-count": _a.openCount.toString()
2310
+ };
2311
+ }
2312
+ /**
2313
+ * Renders the dialog element for the overlay.
2314
+ *
2315
+ * This method returns a template result containing a dialog element. The dialog element
2316
+ * includes various attributes and event listeners to manage the overlay's state and behavior.
2317
+ *
2318
+ * @protected
2319
+ * @returns The template result containing the dialog element.
2320
+ */
2321
+ renderDialog() {
2322
+ return html`
2323
+ <dialog
2324
+ class="dialog"
2325
+ part="dialog"
2326
+ placement=${ifDefined(
2327
+ this.requiresPositioning ? this.placement || "right" : void 0
2328
+ )}
2329
+ style=${styleMap(this.dialogStyleMap)}
2330
+ @close=${this.handleBrowserClose}
2331
+ @cancel=${this.handleBrowserClose}
2332
+ @beforetoggle=${this.handleBeforetoggle}
2333
+ ?is-visible=${this.state !== "closed"}
2334
+ >
2335
+ ${this.renderContent()}
2336
+ </dialog>
2337
+ `;
2338
+ }
2339
+ /**
2340
+ * Renders the popover element for the overlay.
2341
+ *
2342
+ * This method returns a template result containing a div element styled as a popover.
2343
+ * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.
2344
+ *
2345
+ * @protected
2346
+ * @returns The template result containing the popover element.
2347
+ */
2348
+ renderPopover() {
2349
+ return html`
2350
+ <div
2351
+ class="dialog"
2352
+ part="dialog"
2353
+ placement=${ifDefined(
2354
+ this.requiresPositioning ? this.placement || "right" : void 0
2355
+ )}
2356
+ popover=${ifDefined(this.popoverValue)}
2357
+ style=${styleMap(this.dialogStyleMap)}
2358
+ @beforetoggle=${this.handleBeforetoggle}
2359
+ @close=${this.handleBrowserClose}
2360
+ ?is-visible=${this.state !== "closed"}
2361
+ >
2362
+ ${this.renderContent()}
2363
+ </div>
2364
+ `;
2365
+ }
2366
+ /**
2367
+ * Renders the overlay component.
2368
+ *
2369
+ * This method returns a template result containing either a dialog or popover element
2370
+ * based on the overlay type. It also includes a slot for longpress descriptors.
2371
+ *
2372
+ * @override
2373
+ * @returns The template result containing the overlay content.
2374
+ */
2375
+ render() {
2376
+ const isDialog = this.type === "modal" || this.type === "page";
2377
+ return html`
2378
+ ${isDialog ? this.renderDialog() : this.renderPopover()}
2379
+ <slot name="longpress-describedby-descriptor"></slot>
2380
+ `;
2381
+ }
2382
+ /**
2383
+ * Lifecycle method called when the component is added to the DOM.
2384
+ *
2385
+ * This method sets up event listeners and binds events if the component has already updated.
2386
+ *
2387
+ * @override
2388
+ */
2389
+ connectedCallback() {
2390
+ super.connectedCallback();
2391
+ this.addEventListener("close", () => {
2392
+ this.open = false;
2393
+ });
2394
+ if (this.hasUpdated) {
2395
+ this.bindEvents();
2396
+ }
2397
+ }
2398
+ /**
2399
+ * Lifecycle method called when the component is removed from the DOM.
2400
+ *
2401
+ * This method releases the description from the strategy and updates the 'open' property.
2402
+ *
2403
+ * @override
2404
+ */
2405
+ disconnectedCallback() {
2406
+ var _a2;
2407
+ (_a2 = this.strategy) == null ? void 0 : _a2.releaseDescription();
2408
+ this.open = false;
2409
+ super.disconnectedCallback();
2410
+ }
2411
+ }, _a.styles = [unsafeCSS(styles)], _a.openCount = 1, _a);
2412
+ __decorateClass([
2413
+ property({ type: Boolean })
2414
+ ], _LuzmoOverlay.prototype, "delayed", 1);
2415
+ __decorateClass([
2416
+ query(".dialog")
2417
+ ], _LuzmoOverlay.prototype, "dialogEl", 2);
2418
+ __decorateClass([
2419
+ property({ type: Boolean })
2420
+ ], _LuzmoOverlay.prototype, "disabled", 1);
2421
+ __decorateClass([
2422
+ queryAssignedElements({
2423
+ flatten: true,
2424
+ selector: ':not([slot="longpress-describedby-descriptor"], slot)'
2425
+ })
2426
+ ], _LuzmoOverlay.prototype, "elements", 2);
2427
+ __decorateClass([
2428
+ property({ type: Number })
2429
+ ], _LuzmoOverlay.prototype, "offset", 2);
2430
+ __decorateClass([
2431
+ property({ type: Boolean, reflect: true })
2432
+ ], _LuzmoOverlay.prototype, "open", 1);
2433
+ __decorateClass([
2434
+ property()
2435
+ ], _LuzmoOverlay.prototype, "placement", 2);
2436
+ __decorateClass([
2437
+ property({ attribute: "receives-focus" })
2438
+ ], _LuzmoOverlay.prototype, "receivesFocus", 2);
2439
+ __decorateClass([
2440
+ query("slot")
2441
+ ], _LuzmoOverlay.prototype, "slotEl", 2);
2442
+ __decorateClass([
2443
+ state()
2444
+ ], _LuzmoOverlay.prototype, "state", 1);
2445
+ __decorateClass([
2446
+ property({ type: Number, attribute: "tip-padding" })
2447
+ ], _LuzmoOverlay.prototype, "tipPadding", 2);
2448
+ __decorateClass([
2449
+ property()
2450
+ ], _LuzmoOverlay.prototype, "trigger", 2);
2451
+ __decorateClass([
2452
+ property({ attribute: false })
2453
+ ], _LuzmoOverlay.prototype, "triggerElement", 2);
2454
+ __decorateClass([
2455
+ property({ attribute: false })
2456
+ ], _LuzmoOverlay.prototype, "triggerInteraction", 2);
2457
+ __decorateClass([
2458
+ property()
2459
+ ], _LuzmoOverlay.prototype, "type", 2);
2460
+ let LuzmoOverlay = _LuzmoOverlay;
2461
+ const overlay = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2462
+ __proto__: null,
2463
+ LuzmoOverlay
2464
+ }, Symbol.toStringTag, { value: "Module" }));
2465
+ export {
2466
+ ClickController as C,
2467
+ HoverController as H,
2468
+ InteractionTypes as I,
2469
+ LuzmoAbstractOverlay as L,
2470
+ PlacementController as P,
2471
+ SAFARI_FOCUS_RING_CLASS as S,
2472
+ VirtualTrigger as V,
2473
+ nextFrame as a,
2474
+ InteractionController as b,
2475
+ LONGPRESS_INSTRUCTIONS as c,
2476
+ LongpressController as d,
2477
+ LuzmoOverlay as e,
2478
+ overlay as f,
2479
+ guaranteedAllTransitionend as g,
2480
+ lastInteractionType as l,
2481
+ noop as n,
2482
+ overlayTimer as o,
2483
+ placementUpdatedSymbol as p,
2484
+ strategies as s
2485
+ };