luxen-ui 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/cdn/custom-elements.json +225 -192
  2. package/cdn/elements/avatar/avatar.js +1 -1
  3. package/cdn/elements/avatar/avatar.js.map +1 -1
  4. package/cdn/elements/combobox/combobox.d.ts +6 -1
  5. package/cdn/elements/combobox/combobox.d.ts.map +1 -1
  6. package/cdn/elements/combobox/combobox.js +19 -17
  7. package/cdn/elements/combobox/combobox.js.map +1 -1
  8. package/cdn/elements/dropdown/dropdown.d.ts +6 -7
  9. package/cdn/elements/dropdown/dropdown.d.ts.map +1 -1
  10. package/cdn/elements/dropdown/dropdown.js +2 -2
  11. package/cdn/elements/dropdown/dropdown.js.map +1 -1
  12. package/cdn/elements/dropdown-item/dropdown-item.d.ts +0 -1
  13. package/cdn/elements/dropdown-item/dropdown-item.d.ts.map +1 -1
  14. package/cdn/elements/dropdown-item/dropdown-item.js +2 -2
  15. package/cdn/elements/dropdown-item/dropdown-item.js.map +1 -1
  16. package/cdn/elements/dropdown-label/dropdown-label.js +1 -1
  17. package/cdn/elements/dropdown-label/dropdown-label.js.map +1 -1
  18. package/cdn/elements/form-field/form-field.d.ts +1 -1
  19. package/cdn/elements/form-field/form-field.js.map +1 -1
  20. package/cdn/elements/input/input.meta.d.ts +2 -0
  21. package/cdn/elements/input/input.meta.d.ts.map +1 -1
  22. package/cdn/elements/input-otp/input-otp.d.ts +3 -3
  23. package/cdn/elements/input-otp/input-otp.js.map +1 -1
  24. package/cdn/elements/popover/popover.d.ts +3 -4
  25. package/cdn/elements/popover/popover.d.ts.map +1 -1
  26. package/cdn/elements/popover/popover.js +1 -1
  27. package/cdn/elements/popover/popover.js.map +1 -1
  28. package/cdn/elements/prose-editor/prose-editor.js +1 -1
  29. package/cdn/elements/prose-editor/prose-editor.js.map +1 -1
  30. package/cdn/elements/select/select.d.ts +6 -1
  31. package/cdn/elements/select/select.d.ts.map +1 -1
  32. package/cdn/elements/select/select.js +8 -7
  33. package/cdn/elements/select/select.js.map +1 -1
  34. package/cdn/elements/stories-viewer/stories-viewer.d.ts.map +1 -1
  35. package/cdn/elements/stories-viewer/stories-viewer.js +4 -4
  36. package/cdn/elements/stories-viewer/stories-viewer.js.map +1 -1
  37. package/cdn/elements/tag/tag.js +1 -1
  38. package/cdn/elements/tag/tag.js.map +1 -1
  39. package/cdn/elements/tooltip/tooltip.d.ts +0 -1
  40. package/cdn/elements/tooltip/tooltip.d.ts.map +1 -1
  41. package/cdn/elements/tooltip/tooltip.js +1 -1
  42. package/cdn/elements/tooltip/tooltip.js.map +1 -1
  43. package/cdn/elements/tree/tree.js +1 -1
  44. package/cdn/elements/tree/tree.js.map +1 -1
  45. package/cdn/elements/tree-item/tree-item.js +1 -1
  46. package/cdn/elements/tree-item/tree-item.js.map +1 -1
  47. package/cdn/shared/controllers/listbox-nav.d.ts +15 -1
  48. package/cdn/shared/controllers/listbox-nav.d.ts.map +1 -1
  49. package/cdn/shared/controllers/listbox-nav.js +1 -1
  50. package/cdn/shared/controllers/listbox-nav.js.map +1 -1
  51. package/cdn/shared/controllers/popover.d.ts +10 -2
  52. package/cdn/shared/controllers/popover.d.ts.map +1 -1
  53. package/cdn/shared/controllers/popover.js +1 -1
  54. package/cdn/shared/controllers/popover.js.map +1 -1
  55. package/cdn/shared/styles/button-core.styles.js +1 -1
  56. package/cdn/shared/styles/button-core.styles.js.map +1 -1
  57. package/cdn/shared/styles/checkbox-appearance.styles.js +1 -1
  58. package/cdn/shared/styles/checkbox-appearance.styles.js.map +1 -1
  59. package/cdn/shared/styles/menu-panel.styles.d.ts +8 -0
  60. package/cdn/shared/styles/menu-panel.styles.d.ts.map +1 -0
  61. package/cdn/shared/styles/menu-panel.styles.js +2 -0
  62. package/cdn/shared/styles/menu-panel.styles.js.map +1 -0
  63. package/cdn/shared/styles/picker-core.styles.d.ts +9 -0
  64. package/cdn/shared/styles/picker-core.styles.d.ts.map +1 -0
  65. package/cdn/shared/styles/picker-core.styles.js +2 -0
  66. package/cdn/shared/styles/picker-core.styles.js.map +1 -0
  67. package/cdn/shared/styles/select-item-suffix.styles.js +1 -1
  68. package/cdn/shared/styles/select-item-suffix.styles.js.map +1 -1
  69. package/cdn/shared/styles/select-item.styles.d.ts +8 -0
  70. package/cdn/shared/styles/select-item.styles.d.ts.map +1 -0
  71. package/cdn/shared/styles/select-item.styles.js +2 -0
  72. package/cdn/shared/styles/select-item.styles.js.map +1 -0
  73. package/cdn/shared/styles/visually-hidden.styles.d.ts +8 -0
  74. package/cdn/shared/styles/visually-hidden.styles.d.ts.map +1 -0
  75. package/cdn/shared/styles/visually-hidden.styles.js +2 -0
  76. package/cdn/shared/styles/visually-hidden.styles.js.map +1 -0
  77. package/cdn/standalone.css +518 -260
  78. package/cdn/standalone.js +154 -81
  79. package/cdn/standalone.js.map +1 -1
  80. package/cdn/styles/base.css +30 -20
  81. package/cdn/styles/elements/breadcrumb.css +1 -1
  82. package/cdn/styles/elements/button.css +1 -1
  83. package/cdn/styles/elements/checkbox.css +3 -3
  84. package/cdn/styles/elements/close-button/circle.css +1 -1
  85. package/cdn/styles/elements/close-button/ring.css +1 -1
  86. package/cdn/styles/elements/close-button/square.css +1 -1
  87. package/cdn/styles/elements/disclosure.css +2 -2
  88. package/cdn/styles/elements/form-field.css +16 -9
  89. package/cdn/styles/elements/input-otp.css +18 -11
  90. package/cdn/styles/elements/input-stepper/default.css +6 -6
  91. package/cdn/styles/elements/input-stepper/pill.css +6 -6
  92. package/cdn/styles/elements/input-stepper/rounded.css +5 -5
  93. package/cdn/styles/elements/input.css +130 -42
  94. package/cdn/styles/elements/prose-editor.css +23 -8
  95. package/cdn/styles/elements/radio-group.css +1 -1
  96. package/cdn/styles/elements/radio.css +3 -3
  97. package/cdn/styles/elements/segmented-control.css +2 -2
  98. package/cdn/styles/elements/select.css +162 -84
  99. package/cdn/styles/elements/story.css +1 -1
  100. package/cdn/styles/elements/switch.css +4 -4
  101. package/cdn/styles/elements/tabs/enclosed.css +3 -3
  102. package/cdn/styles/elements/tabs/line.css +3 -3
  103. package/cdn/styles/elements/textarea.css +27 -13
  104. package/cdn/styles/preset.css +99 -50
  105. package/cdn/styles/tokens/aliases.css +3 -1
  106. package/cdn/styles/tokens/forms.css +37 -30
  107. package/cdn/styles/tokens.css +69 -30
  108. package/dist/css/base.css +30 -20
  109. package/dist/css/elements/breadcrumb.css +1 -1
  110. package/dist/css/elements/button.css +1 -1
  111. package/dist/css/elements/checkbox.css +3 -3
  112. package/dist/css/elements/close-button/circle.css +1 -1
  113. package/dist/css/elements/close-button/ring.css +1 -1
  114. package/dist/css/elements/close-button/square.css +1 -1
  115. package/dist/css/elements/disclosure.css +2 -2
  116. package/dist/css/elements/form-field.css +16 -9
  117. package/dist/css/elements/input-otp.css +18 -11
  118. package/dist/css/elements/input-stepper/default.css +6 -6
  119. package/dist/css/elements/input-stepper/pill.css +6 -6
  120. package/dist/css/elements/input-stepper/rounded.css +5 -5
  121. package/dist/css/elements/input.css +130 -42
  122. package/dist/css/elements/prose-editor.css +23 -8
  123. package/dist/css/elements/radio-group.css +1 -1
  124. package/dist/css/elements/radio.css +3 -3
  125. package/dist/css/elements/segmented-control.css +2 -2
  126. package/dist/css/elements/select.css +162 -84
  127. package/dist/css/elements/story.css +1 -1
  128. package/dist/css/elements/switch.css +4 -4
  129. package/dist/css/elements/tabs/enclosed.css +3 -3
  130. package/dist/css/elements/tabs/line.css +3 -3
  131. package/dist/css/elements/textarea.css +27 -13
  132. package/dist/css/preset.css +99 -50
  133. package/dist/css/tokens/aliases.css +3 -1
  134. package/dist/css/tokens/forms.css +37 -30
  135. package/dist/css/tokens.css +69 -30
  136. package/dist/custom-elements.json +225 -192
  137. package/dist/elements/avatar/avatar.css +1 -1
  138. package/dist/elements/combobox/combobox.css +30 -187
  139. package/dist/elements/combobox/combobox.d.ts +6 -1
  140. package/dist/elements/combobox/combobox.d.ts.map +1 -1
  141. package/dist/elements/combobox/combobox.js +48 -20
  142. package/dist/elements/dropdown/dropdown.css +7 -30
  143. package/dist/elements/dropdown/dropdown.d.ts +6 -7
  144. package/dist/elements/dropdown/dropdown.d.ts.map +1 -1
  145. package/dist/elements/dropdown/dropdown.js +17 -14
  146. package/dist/elements/dropdown-item/dropdown-item.css +12 -40
  147. package/dist/elements/dropdown-item/dropdown-item.d.ts +0 -1
  148. package/dist/elements/dropdown-item/dropdown-item.d.ts.map +1 -1
  149. package/dist/elements/dropdown-item/dropdown-item.js +4 -7
  150. package/dist/elements/dropdown-label/dropdown-label.css +3 -3
  151. package/dist/elements/form-field/form-field.d.ts +1 -1
  152. package/dist/elements/form-field/form-field.js +2 -2
  153. package/dist/elements/input/input.meta.d.ts +2 -0
  154. package/dist/elements/input/input.meta.d.ts.map +1 -1
  155. package/dist/elements/input/input.meta.js +2 -0
  156. package/dist/elements/input-otp/input-otp.d.ts +3 -3
  157. package/dist/elements/input-otp/input-otp.js +3 -3
  158. package/dist/elements/popover/popover.css +4 -4
  159. package/dist/elements/popover/popover.d.ts +3 -4
  160. package/dist/elements/popover/popover.d.ts.map +1 -1
  161. package/dist/elements/popover/popover.js +5 -9
  162. package/dist/elements/prose-editor/prose-editor.css +1 -1
  163. package/dist/elements/select/select.css +24 -264
  164. package/dist/elements/select/select.d.ts +6 -1
  165. package/dist/elements/select/select.d.ts.map +1 -1
  166. package/dist/elements/select/select.js +27 -9
  167. package/dist/elements/stories-viewer/stories-viewer.css +0 -12
  168. package/dist/elements/stories-viewer/stories-viewer.d.ts.map +1 -1
  169. package/dist/elements/stories-viewer/stories-viewer.js +4 -3
  170. package/dist/elements/tag/tag.css +3 -3
  171. package/dist/elements/tooltip/tooltip.d.ts +0 -1
  172. package/dist/elements/tooltip/tooltip.d.ts.map +1 -1
  173. package/dist/elements/tooltip/tooltip.js +2 -6
  174. package/dist/elements/tree/tree.css +1 -1
  175. package/dist/elements/tree-item/tree-item.css +1 -1
  176. package/dist/metadata/combobox.json +16 -1
  177. package/dist/metadata/dropdown.json +10 -10
  178. package/dist/metadata/form-field.json +1 -1
  179. package/dist/metadata/index.json +57 -22
  180. package/dist/metadata/input-otp.json +3 -3
  181. package/dist/metadata/input.json +5 -0
  182. package/dist/metadata/popover.json +5 -5
  183. package/dist/metadata/select.json +16 -1
  184. package/dist/shared/controllers/listbox-nav.d.ts +15 -1
  185. package/dist/shared/controllers/listbox-nav.d.ts.map +1 -1
  186. package/dist/shared/controllers/listbox-nav.js +32 -1
  187. package/dist/shared/controllers/popover.d.ts +10 -2
  188. package/dist/shared/controllers/popover.d.ts.map +1 -1
  189. package/dist/shared/controllers/popover.js +16 -2
  190. package/dist/shared/styles/button-core.css +1 -1
  191. package/dist/shared/styles/checkbox-appearance.css +3 -3
  192. package/dist/shared/styles/menu-panel.css +37 -0
  193. package/dist/shared/styles/menu-panel.styles.d.ts +8 -0
  194. package/dist/shared/styles/menu-panel.styles.d.ts.map +1 -0
  195. package/dist/shared/styles/menu-panel.styles.js +8 -0
  196. package/dist/shared/styles/picker-core.css +271 -0
  197. package/dist/shared/styles/picker-core.styles.d.ts +9 -0
  198. package/dist/shared/styles/picker-core.styles.d.ts.map +1 -0
  199. package/dist/shared/styles/picker-core.styles.js +9 -0
  200. package/dist/shared/styles/select-item-suffix.css +4 -4
  201. package/dist/shared/styles/select-item.css +98 -0
  202. package/dist/shared/styles/select-item.styles.d.ts +8 -0
  203. package/dist/shared/styles/select-item.styles.d.ts.map +1 -0
  204. package/dist/shared/styles/select-item.styles.js +8 -0
  205. package/dist/shared/styles/visually-hidden.css +27 -0
  206. package/dist/shared/styles/visually-hidden.styles.d.ts +8 -0
  207. package/dist/shared/styles/visually-hidden.styles.d.ts.map +1 -0
  208. package/dist/shared/styles/visually-hidden.styles.js +8 -0
  209. package/dist/templates/elements/combobox.md +26 -1
  210. package/dist/templates/elements/disclosure.md +2 -0
  211. package/dist/templates/elements/dropdown.md +6 -6
  212. package/dist/templates/elements/form-field.md +2 -2
  213. package/dist/templates/elements/input-otp.md +3 -3
  214. package/dist/templates/elements/input.md +1 -0
  215. package/dist/templates/elements/popover.md +3 -3
  216. package/dist/templates/elements/select.md +30 -1
  217. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"stories-viewer.js","names":["unsafeCSS","rawStyles","hostStyles","map","nothing","_decorate","property","query","state","r","u","__decorate","e","A","o","host_styles_default","styles","StoryChangeEvent","index","story","StoryEndEvent","ChapterChangeEvent","chapter","MuteChangeEvent","muted","SCROLL_LOCK_SHEET","sheet","tagName","LuxenStoriesViewer","LuxenElement","_args","LocalizeController","start","dx","dy","elapsed","v","seg","end","span","p","openBecoming","changed","indexChanged","ShowEvent","HideEvent","i","nextStory","link","links","target","node","child","clone","direction","previousStory","previousLast","stories","source","anims","a","name","AfterShowEvent","AfterHideEvent","total","currentStory","isFirstStory","isLastStory","chapterStarts","iconTag","staticTag","spinnerTag","n","r$1"],"sources":["../../../src/html/elements/stories-viewer/stories-viewer.css?inline","../../../src/html/elements/stories-viewer/stories-viewer.ts"],"sourcesContent":[":host {\n --width: min(420px, 100vw);\n --aspect-ratio: 9 / 16;\n --progress-color: white;\n --progress-bg: rgb(255 255 255 / 35%);\n --progress-gap: 4px;\n --show-duration: 200ms;\n --hide-duration: 200ms;\n /* Semi-transparent backdrop so the underlying page (e.g. a product page) stays visible behind the player, but with enough darkness to focus attention on the frame. Override with `--backdrop: …` or set to `oklch(0% 0 0 / 90%)` for an opaque blackout. */\n --backdrop: var(--l-backdrop-strong);\n\n display: contents;\n}\n\ndialog {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100dvh;\n max-width: none;\n max-height: none;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: white;\n overflow: clip;\n\n /* Center the frame at all times. `place-items` is on the base rule so it survives the close transition (only `display` and `opacity` are transitioned with `allow-discrete`; non-transitioned properties revert immediately when `[open]` is removed and would un-center the frame to top-left for one frame). */\n place-items: center;\n\n /* EXIT STATE */\n opacity: 0;\n\n transition-property: opacity, display, overlay;\n transition-duration: var(--hide-duration);\n transition-behavior: allow-discrete;\n\n &::backdrop {\n background: var(--backdrop);\n }\n\n /* OPEN STATE */\n &[open] {\n display: grid;\n opacity: 1;\n transition-duration: var(--show-duration);\n }\n\n /* BEFORE-OPEN STATE */\n @starting-style {\n &[open] {\n opacity: 0;\n }\n }\n}\n\n.frame {\n position: relative;\n width: var(--width);\n max-width: 100vw;\n max-height: 100dvh;\n aspect-ratio: var(--aspect-ratio);\n background: black;\n border-radius: 0.75rem;\n overflow: clip;\n isolation: isolate;\n user-select: none;\n -webkit-user-select: none;\n touch-action: pan-y;\n}\n\n@media (max-width: 480px) {\n .frame {\n width: 100vw;\n height: 100dvh;\n aspect-ratio: auto;\n border-radius: 0;\n }\n}\n\n.video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n background: black;\n}\n\n/* Loading spinner — centered over the video. Delayed fade-in so a fast buffer never visibly flashes the spinner. */\n.spinner {\n position: absolute;\n inset: 0;\n margin: auto;\n z-index: 1;\n width: 2rem;\n height: 2rem;\n color: white;\n pointer-events: none;\n opacity: 0;\n transition: opacity 150ms ease;\n}\n\n.spinner[data-state='loading'] {\n opacity: 1;\n /* Only paint the spinner if loading actually exceeds 200ms. */\n transition-delay: 200ms;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .spinner {\n transition: none;\n }\n}\n\n.progress {\n position: absolute;\n top: 0.5rem;\n left: 0.5rem;\n right: 0.5rem;\n z-index: 2;\n display: flex;\n gap: var(--progress-gap);\n pointer-events: none;\n}\n\n.progress-segment {\n flex: 1 1 0;\n height: 2.5px;\n border-radius: 999px;\n background: var(--progress-bg);\n overflow: clip;\n}\n\n.progress-fill {\n display: block;\n width: 100%;\n height: 100%;\n background: var(--progress-color);\n transform: scaleX(var(--p, 0));\n transform-origin: left;\n transition: transform 80ms linear;\n}\n\n.progress-segment[data-state='past'] .progress-fill {\n transform: scaleX(1);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .progress-fill {\n transition: none;\n }\n :host {\n --show-duration: 0ms;\n --hide-duration: 0ms;\n }\n}\n\n/* Top-left header — story thumbnail + label (slot fallback) or consumer-supplied content. */\n.header {\n position: absolute;\n top: 1.25rem;\n left: 0.75rem;\n right: 4rem; /* leave room for the right-side action stack */\n z-index: 2;\n display: flex;\n align-items: center;\n gap: 0.625rem;\n min-width: 0;\n pointer-events: none;\n}\n\n.header > ::slotted(*) {\n pointer-events: auto;\n}\n\n.header-thumb {\n width: 2rem;\n height: 2rem;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n pointer-events: auto;\n}\n\n.header-text {\n display: flex;\n flex-direction: column;\n min-width: 0;\n pointer-events: auto;\n}\n\n.header-label {\n font-size: 0.875rem;\n font-weight: var(--l-font-weight-semibold);\n line-height: 1.2;\n color: white;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Top-right vertical action stack — close, play/pause, mute. */\n.actions {\n position: absolute;\n top: 1.25rem;\n right: 0.75rem;\n z-index: 2;\n display: flex;\n flex-direction: column;\n /* 12px gap leaves room for the 6px hit-area extension on each adjacent button (see `.btn::before` below). */\n gap: 0.75rem;\n pointer-events: none;\n}\n\n.actions > ::slotted(*),\n.actions .btn {\n pointer-events: auto;\n}\n\n.btn {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border: 0;\n border-radius: 999px;\n background: rgb(0 0 0 / 25%);\n color: white;\n font-size: 1rem;\n cursor: pointer;\n transition: background 150ms ease;\n\n &:hover {\n background: rgb(0 0 0 / 45%);\n }\n\n &:focus-visible {\n outline: 2px solid var(--progress-color);\n outline-offset: 2px;\n }\n\n /* WCAG 2.1 SC 2.5.5 / RGAA 13.4 — 44×44 hit area without changing the visible 32×32 disc. The pseudo carries no paint, only hit testing. */\n &::before {\n content: '';\n position: absolute;\n inset: -6px;\n }\n}\n\n.btn-nav {\n position: absolute;\n z-index: 2;\n width: 2.25rem;\n height: 2.25rem;\n font-size: 1.25rem;\n\n /* Chevrons start at 36×36 — 4px each side reaches 44. */\n &::before {\n inset: -4px;\n }\n}\n\n.btn-previous,\n.btn-next {\n top: 50%;\n transform: translateY(-50%);\n}\n\n/* Desktop ≥ 768px: chevrons sit outside the frame, on the dim backdrop. */\n@media (min-width: 768px) {\n .btn-previous {\n left: calc(50% - var(--width) / 2 - 3rem);\n }\n .btn-next {\n right: calc(50% - var(--width) / 2 - 3rem);\n }\n}\n\n/* Mobile < 768px: hide chevrons entirely — tap zones drive nav. */\n@media (max-width: 767px) {\n .btn-previous,\n .btn-next {\n display: none;\n }\n}\n\n/*\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🆃🅰🅿 zones (invisible click/tap targets — left = previous, rest = next)\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n*/\n\n.tap-zone {\n position: absolute;\n top: 0;\n bottom: 0;\n z-index: 0;\n}\n\n.tap-previous {\n left: 0;\n width: 30%;\n}\n\n.tap-next {\n left: 30%;\n right: 0;\n}\n\n.overlay {\n position: absolute;\n inset: auto 0 0 0;\n z-index: 1;\n padding: 1rem;\n pointer-events: none;\n}\n\n.overlay > ::slotted(*) {\n pointer-events: auto;\n}\n\n.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n","import { nothing, unsafeCSS, type CSSResultGroup, type PropertyValues } from 'lit';\nimport { html } from 'lit/static-html.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport { LuxenElement } from '../../shared/luxen-element.js';\nimport { LocalizeController } from '../../shared/localize.js';\nimport { tagName } from '../../registry.js';\nimport { staticTag } from '../../static-tag.js';\nimport { ShowEvent, AfterShowEvent, HideEvent, AfterHideEvent } from '../../events/index.js';\nimport hostStyles from '../../shared/styles/host.styles.js';\nimport type { LuxenStories } from '../stories/stories.js';\nimport type { LuxenStory } from '../story/story.js';\nimport rawStyles from './stories-viewer.css?inline';\n\nconst styles = unsafeCSS(rawStyles);\n\n/** Fired when the active story changes. */\nexport class StoryChangeEvent extends Event {\n readonly index: number;\n readonly story: LuxenStory;\n constructor(index: number, story: LuxenStory) {\n super('story-change', { bubbles: false, composed: false, cancelable: false });\n this.index = index;\n this.story = story;\n }\n}\n\n/** Fired when the active story finishes playback. */\nexport class StoryEndEvent extends Event {\n readonly index: number;\n constructor(index: number) {\n super('story-end', { bubbles: false, composed: false, cancelable: false });\n this.index = index;\n }\n}\n\n/** Fired when the active chapter (within a story) changes. */\nexport class ChapterChangeEvent extends Event {\n readonly chapter: number;\n readonly story: LuxenStory;\n constructor(chapter: number, story: LuxenStory) {\n super('chapter-change', { bubbles: false, composed: false, cancelable: false });\n this.chapter = chapter;\n this.story = story;\n }\n}\n\n/** Fired when the mute state changes. */\nexport class MuteChangeEvent extends Event {\n readonly muted: boolean;\n constructor(muted: boolean) {\n super('mute-change', { bubbles: false, composed: false, cancelable: false });\n this.muted = muted;\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'story-change': StoryChangeEvent;\n 'story-end': StoryEndEvent;\n 'chapter-change': ChapterChangeEvent;\n 'mute-change': MuteChangeEvent;\n }\n}\n\nconst SCROLL_LOCK_SHEET = Symbol.for('luxen-stories-viewer-scroll-lock');\nif (typeof document !== 'undefined' && !(SCROLL_LOCK_SHEET in document)) {\n const sheet = new CSSStyleSheet();\n // Runs at import time, after the consumer has called `setPrefix()` (or the\n // vite-plugin baked it into registry.js) — same ordering `define()` relies on.\n sheet.replaceSync(\n `html:has(${tagName('stories-viewer')}[data-modal]) { overflow: hidden; scrollbar-gutter: stable; }`,\n );\n document.adoptedStyleSheets.push(sheet);\n Object.defineProperty(document, SCROLL_LOCK_SHEET, { value: sheet });\n}\n\n/**\n * @summary Fullscreen modal that plays a sequence of `<l-story>` videos with an\n * Instagram-style segmented progress bar, previous/next navigation, mute toggle,\n * and auto-advance.\n *\n * Linked to one or more `<l-stories>` rows via matching `id` ↔ `for`. Open\n * programmatically via `open()` or by clicking a thumbnail in a linked row.\n *\n * @slot cta - Default CTA overlay (e.g. shoppable card). Per-story `slot=\"cta\"` inside `<l-story>` overrides this when that story is active.\n * @slot header - Default header overlay (e.g. avatar + author). Per-story override available the same way.\n * @slot close - Override the default close button.\n *\n * @csspart dialog - The native `<dialog>` element.\n * @csspart frame - The aspect-ratio video frame.\n * @csspart progress - The progress bar wrapper.\n * @csspart progress-segment - A single progress segment.\n * @csspart progress-fill - The fill element inside an active segment.\n * @csspart video - The `<video>` element.\n * @csspart overlay - The overlay wrapper that hosts CTA/header slots.\n * @csspart header - The top-left header area (story thumbnail + label fallback, or consumer-supplied content via the `header` slot).\n * @csspart header-label - The default story label inside the header.\n * @csspart actions - The top-right vertical button stack (close, play/pause, mute).\n * @csspart button-close - The close button.\n * @csspart button-pause - The play/pause toggle.\n * @csspart button-mute - The mute toggle.\n * @csspart button-previous - The previous story button.\n * @csspart button-next - The next story button.\n * @csspart spinner - The loading spinner shown while the current video is buffering.\n *\n * @cssproperty --width - Frame width. Default `min(420px, 100vw)`.\n * @cssproperty --progress-color - Active progress fill color. Default `white`.\n * @cssproperty --progress-bg - Inactive progress segment background. Default `rgb(255 255 255 / 35%)`.\n * @cssproperty --progress-gap - Gap between segments. Default `4px`.\n * @cssproperty --show-duration - Open transition duration. Default `200ms`.\n * @cssproperty --hide-duration - Close transition duration. Default `200ms`.\n * @cssproperty --backdrop - Backdrop color. Default `var(--l-backdrop-strong)` — darker than `--l-backdrop` to focus attention on the immersive frame, but still translucent so the page stays perceptible.\n *\n * @event show - Fired when the viewer is about to open. Cancelable — call `event.preventDefault()` to keep it closed.\n * @event after-show - Fired after the open transition completes. Not cancelable.\n * @event hide - Fired when the viewer is about to close. Cancelable.\n * @event after-hide - Fired after the close transition completes. Not cancelable.\n * @event story-change - Fired when the active story changes. Properties: `index: number`, `story: LuxenStory`.\n * @event story-end - Fired when the active story finishes playback. Properties: `index: number`.\n * @event chapter-change - Fired when the active chapter (within a story) changes. Properties: `chapter: number`, `story: LuxenStory`.\n * @event mute-change - Fired when the mute state changes. Properties: `muted: boolean`.\n *\n * @customElement l-stories-viewer\n */\nexport class LuxenStoriesViewer extends LuxenElement {\n static override styles: CSSResultGroup = [hostStyles, styles];\n\n private _localize = new LocalizeController(this);\n\n /** Whether the viewer is open. */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /** Active story index (0-based). */\n @property({ type: Number, reflect: true })\n index = 0;\n\n /** Whether playback is muted. Defaults to `true` so autoplay always succeeds across browsers. The user can unmute via the dedicated button or the `m` keyboard shortcut. */\n @property({ type: Boolean, reflect: true })\n muted = true;\n\n /** Loop the active story instead of advancing. */\n @property({ type: Boolean, reflect: true })\n loop = false;\n\n /** Move to the next story when the current one ends; close after the last story. */\n @property({ type: Boolean, reflect: true, attribute: 'auto-advance' })\n autoAdvance = true;\n\n /** Close when the backdrop is clicked. */\n @property({ type: Boolean, reflect: true, attribute: 'light-dismiss' })\n lightDismiss = true;\n\n /** Active chapter index within the current story. Reflected. */\n @property({ type: Number, reflect: true })\n chapter = 0;\n\n /** Internal: the playlist set by the source `<l-stories>`. */\n stories: LuxenStory[] = [];\n\n /** Internal: the source `<l-stories>` element that opened the viewer. */\n source: LuxenStories | null = null;\n\n @query('dialog') private _dialog!: HTMLDialogElement;\n @query('video') private _video!: HTMLVideoElement;\n\n /** Tracks the underlying `<video>` paused state so the play/pause button stays in sync. */\n @state() private _paused = false;\n\n /** True while the video is buffering / waiting for data. Drives the loading spinner. */\n @state() private _loading = false;\n\n private _raf = 0;\n private _holdTimer = 0;\n private _pointerStart: { x: number; y: number; t: number } | null = null;\n private _segments: HTMLElement[] = [];\n private _chapterStarts: number[] = [0];\n /** Tracks the URL we've already injected a prefetch hint for so we don't duplicate. */\n private _prefetchedSrc: string | null = null;\n\n // --- Lifecycle ---\n\n override connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this._onKeyDown);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('keydown', this._onKeyDown);\n cancelAnimationFrame(this._raf);\n clearTimeout(this._holdTimer);\n this._clearPrefetchHints();\n }\n\n override firstUpdated() {\n this._dialog.addEventListener('cancel', (e) => this._onCancel(e));\n this._dialog.addEventListener('close', () => this._onNativeClose());\n this._dialog.addEventListener('click', (e) => this._onDialogClick(e));\n this._video.addEventListener('ended', () => this._onEnded());\n this._video.addEventListener('loadedmetadata', () => this._tick());\n this._video.addEventListener('play', () => (this._paused = false));\n this._video.addEventListener('pause', () => (this._paused = true));\n // Loading spinner state — shown during initial buffer and any subsequent stalls,\n // hidden as soon as the video is actually painting frames.\n this._video.addEventListener('loadstart', () => (this._loading = true));\n this._video.addEventListener('waiting', () => (this._loading = true));\n this._video.addEventListener('playing', () => (this._loading = false));\n this._video.addEventListener('canplay', () => (this._loading = false));\n this._video.addEventListener('error', () => (this._loading = false));\n // Prefetch the next story's video once the current one is past 50% so the\n // transition feels instantaneous. Idempotent via `_prefetchedSrc`.\n this._video.addEventListener('timeupdate', () => this._maybePrefetchNext());\n }\n\n override willUpdate(changed: PropertyValues<this>) {\n // Reset chapter state synchronously so it folds into the same update cycle —\n // avoids writing reactive props from updated() which would schedule a second update.\n const openBecoming = changed.has('open') && this.open;\n const indexChanged = changed.has('index');\n if (openBecoming || indexChanged) {\n const story = this.stories[this.index];\n if (story) {\n this._chapterStarts = story.getChapterStarts();\n this.chapter = 0;\n }\n }\n }\n\n override updated(changed: PropertyValues<this>) {\n if (changed.has('open')) {\n if (this.open && !this._dialog.open) {\n if (!this.dispatchEvent(new ShowEvent())) {\n // Defer the revert so it lands outside the current update cycle and\n // doesn't schedule a new update from inside updated().\n queueMicrotask(() => {\n this.open = false;\n });\n return;\n }\n this.toggleAttribute('data-modal', true);\n this._dialog.showModal();\n queueMicrotask(() => this._loadCurrent());\n void this._emitAfter('after-show');\n } else if (!this.open && this._dialog.open) {\n if (!this.dispatchEvent(new HideEvent())) {\n // Defer the revert so it lands outside the current update cycle and\n // doesn't schedule a new update from inside updated().\n queueMicrotask(() => {\n this.open = true;\n });\n return;\n }\n this._dialog.close();\n }\n }\n\n // Story change → reload current story (refreshes chapters, segments, slots, video).\n if (changed.has('index') && this.open) {\n queueMicrotask(() => this._loadCurrent());\n const story = this.stories[this.index];\n if (story) this.dispatchEvent(new StoryChangeEvent(this.index, story));\n }\n\n // Chapter change within the current story → seek + refresh segment fills.\n if (changed.has('chapter') && this.open && !changed.has('index')) {\n this._applyChapterSeek();\n }\n\n if (changed.has('muted') && this._video) {\n this._video.muted = this.muted;\n }\n }\n\n // --- Dialog event handlers ---\n\n private _onCancel(e: Event) {\n if (!this.dispatchEvent(new HideEvent())) {\n e.preventDefault();\n }\n }\n\n private _onNativeClose() {\n cancelAnimationFrame(this._raf);\n this._video.pause();\n this._video.removeAttribute('src');\n this._video.load();\n this._clearPrefetchHints();\n // Mark all stories up to and including this.index as seen.\n for (let i = 0; i <= this.index && i < this.stories.length; i++) {\n this.stories[i].seen = true;\n }\n this._restoreFocus();\n this.open = false;\n this.removeAttribute('data-modal');\n void this._emitAfter('after-hide');\n }\n\n private _onDialogClick(e: MouseEvent) {\n if (!this.lightDismiss) return;\n // Backdrop click: target is the <dialog>, not a child.\n if (e.target === this._dialog) {\n this.open = false;\n }\n }\n\n // --- Keyboard ---\n\n private _onKeyDown = (e: KeyboardEvent) => {\n if (!this.open) return;\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n this.previous();\n break;\n case 'ArrowRight':\n e.preventDefault();\n this.next();\n break;\n case ' ':\n e.preventDefault();\n if (this._video.paused) this.play();\n else this.pause();\n break;\n case 'm':\n case 'M':\n e.preventDefault();\n this.muted = !this.muted;\n this.dispatchEvent(new MuteChangeEvent(this.muted));\n break;\n }\n };\n\n // --- Pointer / touch (long-press to pause, tap-to-advance, swipe to close) ---\n\n private _onFramePointerDown = (e: PointerEvent) => {\n // Skip buttons, links, and explicitly-marked no-gesture areas.\n if ((e.target as HTMLElement).closest('button, a, [data-no-gesture]')) return;\n this._pointerStart = { x: e.clientX, y: e.clientY, t: performance.now() };\n this._holdTimer = window.setTimeout(() => this.pause(), 200);\n };\n\n private _onFramePointerUp = (e: PointerEvent) => {\n clearTimeout(this._holdTimer);\n const start = this._pointerStart;\n this._pointerStart = null;\n if (!start) return;\n\n const dx = e.clientX - start.x;\n const dy = e.clientY - start.y;\n const elapsed = performance.now() - start.t;\n const isTap = elapsed < 200 && Math.abs(dx) < 10 && Math.abs(dy) < 10;\n const wasLongPress = elapsed >= 200 && Math.abs(dx) < 10 && Math.abs(dy) < 10;\n const SWIPE = 50;\n\n if (wasLongPress) {\n if (this._video.paused) this.play();\n return;\n }\n\n if (isTap) {\n // Tap zones: chapter-aware nav. Left ~30% = previous chapter (or previous\n // story at the chapter boundary), anywhere else = next chapter (or next\n // story at the last chapter). Chevron buttons remain story-to-story.\n const tap = (e.target as HTMLElement).closest<HTMLElement>('[data-tap]');\n if (tap?.dataset.tap === 'previous') this.previous();\n else this.next();\n return;\n }\n\n if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > SWIPE) {\n if (dx < 0) this.nextStory();\n else this.previousStory();\n } else if (dy > SWIPE) {\n this.close();\n }\n };\n\n // --- Segments / progress (chapter-based) ---\n\n private _refreshSegmentRefs() {\n this._segments = Array.from(\n this.shadowRoot!.querySelectorAll<HTMLElement>('[part~=\"progress-fill\"]'),\n );\n }\n\n private _resetSegmentFills() {\n this._refreshSegmentRefs();\n for (let i = 0; i < this._segments.length; i++) {\n const p = i < this.chapter ? 1 : 0;\n this._segments[i].style.setProperty('--p', String(p));\n }\n }\n\n private _loadCurrent() {\n // Guard against a close racing the microtask: if the viewer is no longer\n // open, don't restart the video with stale state.\n if (!this.open || !this._dialog.open) return;\n const story = this.stories[this.index];\n if (!story) return;\n cancelAnimationFrame(this._raf);\n // Reset the prefetch tracker when the active story changes — the next\n // candidate has shifted and may need its own preload hint.\n this._prefetchedSrc = null;\n this._syncSlots(story);\n this._video.muted = this.muted;\n this._video.loop = this.loop;\n if (this._video.src !== story.src) {\n this._video.src = story.src;\n } else {\n this._video.currentTime = 0;\n }\n // Wait one frame for the new segment DOM to render before resetting fills.\n requestAnimationFrame(() => this._resetSegmentFills());\n this._video.play().catch(() => {\n // Autoplay-with-sound rejection: force muted, retry.\n this.muted = true;\n this._video.muted = true;\n this._video.play().catch(() => {});\n });\n }\n\n /**\n * Inject a `<link rel=\"preload\" as=\"video\">` for the next story once the\n * current video crosses 50% playback. Idempotent: tracked by `_prefetchedSrc`,\n * cleaned up on viewer close.\n */\n private _maybePrefetchNext() {\n const v = this._video;\n if (!v.duration || v.currentTime / v.duration < 0.5) return;\n const nextStory = this.stories[this.index + 1];\n if (!nextStory?.src) return;\n if (this._prefetchedSrc === nextStory.src) return;\n this._prefetchedSrc = nextStory.src;\n\n const link = document.createElement('link');\n link.rel = 'preload';\n link.as = 'video';\n link.href = nextStory.src;\n link.crossOrigin = 'anonymous';\n link.dataset.luxenStoriesPrefetch = '';\n document.head.appendChild(link);\n }\n\n /** Remove every prefetch hint we've injected. Called when the viewer closes. */\n private _clearPrefetchHints() {\n const links = document.head.querySelectorAll<HTMLLinkElement>(\n 'link[data-luxen-stories-prefetch]',\n );\n for (const link of links) link.remove();\n this._prefetchedSrc = null;\n }\n\n private _applyChapterSeek() {\n const target = this._chapterStarts[this.chapter] ?? 0;\n this._video.currentTime = target;\n this._resetSegmentFills();\n const story = this.stories[this.index];\n if (story) this.dispatchEvent(new ChapterChangeEvent(this.chapter, story));\n }\n\n private get _lastChapter() {\n return Math.max(0, this._chapterStarts.length - 1);\n }\n\n // Clone the active story's slot-marked children (cta, header) into the\n // viewer's own light DOM so the shadow root's `<slot name=\"cta\">` and\n // `<slot name=\"header\">` project them. Originals stay attached to the\n // story (hidden via CSS) and are reused on every `index` change.\n private _syncSlots(story: LuxenStory) {\n for (const node of Array.from(this.children)) {\n if ((node as HTMLElement).dataset.storySlot !== undefined) node.remove();\n }\n for (const child of Array.from(story.children)) {\n const slotName = (child as HTMLElement).getAttribute?.('slot');\n if (!slotName) continue;\n const clone = child.cloneNode(true) as HTMLElement;\n clone.dataset.storySlot = '';\n this.appendChild(clone);\n }\n }\n\n private _tick = () => {\n if (!this.open) return;\n const v = this._video;\n const seg = this._segments[this.chapter];\n if (v && seg) {\n const start = this._chapterStarts[this.chapter] ?? 0;\n const end = this._chapterStarts[this.chapter + 1] ?? v.duration;\n const span = Math.max(0, end - start);\n const p = span ? Math.max(0, Math.min((v.currentTime - start) / span, 1)) : 0;\n seg.style.setProperty('--p', String(p));\n // Auto-advance chapter when its segment is full and there's a next chapter in this story.\n // (The video element's `ended` event handles the last chapter via `_onEnded`.)\n if (p >= 1 && this.chapter < this._lastChapter) {\n this._advance(1);\n }\n }\n this._raf = requestAnimationFrame(this._tick);\n };\n\n private _onEnded() {\n // Last chapter of the current story finished.\n const story = this.stories[this.index];\n if (story) this.dispatchEvent(new StoryEndEvent(this.index));\n if (this.loop) {\n this._video.currentTime = this._chapterStarts[0] ?? 0;\n this.chapter = 0;\n this._video.play().catch(() => {});\n return;\n }\n if (!this.autoAdvance) return;\n if (this.index < this.stories.length - 1) {\n this.index = this.index + 1;\n } else {\n this.close();\n }\n }\n\n /** chapter-then-story navigation. */\n private _advance(direction: 1 | -1) {\n if (direction === 1) {\n if (this.chapter < this._lastChapter) {\n this.chapter = this.chapter + 1;\n } else if (this.index < this.stories.length - 1) {\n this.index = this.index + 1;\n } else {\n this.close();\n }\n return;\n }\n // direction === -1: Instagram pattern — restart the current chapter if past 1s in.\n const start = this._chapterStarts[this.chapter] ?? 0;\n if (this._video.currentTime > start + 1) {\n this._video.currentTime = start;\n this._resetSegmentFills();\n return;\n }\n if (this.chapter > 0) {\n this.chapter = this.chapter - 1;\n } else if (this.index > 0) {\n // Crossing into the previous story: load it, then jump to its last chapter.\n const previousStory = this.stories[this.index - 1];\n const previousLast = Math.max(0, previousStory.getChapterStarts().length - 1);\n this.index = this.index - 1;\n // After `index` updates, `_loadCurrent()` runs and resets `chapter` to 0.\n // Set `chapter` to the previous story's last chapter on the next microtask.\n queueMicrotask(() => {\n this.chapter = previousLast;\n });\n }\n }\n\n // --- Public API ---\n\n /** Open the viewer at the given index with an explicit playlist. */\n openAt(stories: LuxenStory[], index = 0, source: LuxenStories | null = null) {\n this.stories = stories;\n this.source = source;\n this.index = Math.max(0, Math.min(index, stories.length - 1));\n this.open = true;\n }\n\n close() {\n this.open = false;\n }\n\n /** Advance one chapter, or to the next story at the chapter boundary. */\n next() {\n this._advance(1);\n }\n\n /** Retreat one chapter, restart the current chapter past 1s in, or cross into the previous story. */\n previous() {\n this._advance(-1);\n }\n\n /** Jump to the next story, skipping any remaining chapters in the current story. */\n nextStory() {\n if (this.index < this.stories.length - 1) {\n this.index = this.index + 1;\n } else {\n this.close();\n }\n }\n\n /** Jump to the previous story regardless of current chapter. Lands on chapter 0 of the previous story. */\n previousStory() {\n if (this.index > 0) {\n this.index = this.index - 1;\n }\n }\n\n play() {\n this._video?.play().catch(() => {});\n this._raf = requestAnimationFrame(this._tick);\n }\n\n pause() {\n this._video?.pause();\n cancelAnimationFrame(this._raf);\n }\n\n // --- Helpers ---\n\n private async _emitAfter(name: 'after-show' | 'after-hide') {\n await new Promise((r) => requestAnimationFrame(() => r(null)));\n const anims = this._dialog.getAnimations({ subtree: false });\n await Promise.all(anims.map((a) => a.finished.catch(() => {})));\n if ((name === 'after-show') !== this.open) return;\n this.dispatchEvent(name === 'after-show' ? new AfterShowEvent() : new AfterHideEvent());\n if (name === 'after-show') {\n this._raf = requestAnimationFrame(this._tick);\n }\n }\n\n private _restoreFocus() {\n const stories = this.source?.stories() ?? this.stories;\n const story = stories[this.index];\n const trigger = story?.querySelector<HTMLButtonElement>('button[data-story-trigger]');\n trigger?.focus({ preventScroll: false });\n }\n\n override render() {\n const total = this.stories.length;\n const currentStory = this.stories[this.index];\n // Chevrons navigate story-to-story, so visibility depends on `index` only (not chapter).\n const isFirstStory = this.index === 0;\n const isLastStory = this.index >= total - 1;\n // Render one segment per chapter of the CURRENT story. Use `_chapterStarts` if present\n // (set after `_loadCurrent`), or fall back to the current story's parsed chapters.\n const chapterStarts = this._chapterStarts.length\n ? this._chapterStarts\n : (currentStory?.getChapterStarts() ?? [0]);\n const iconTag = staticTag('icon');\n const spinnerTag = staticTag('spinner');\n\n return html`\n <dialog\n part=\"dialog\"\n aria-label=${this._localize.term('stories')}\n >\n <div\n part=\"frame\"\n class=\"frame\"\n @pointerdown=${this._onFramePointerDown}\n @pointerup=${this._onFramePointerUp}\n @pointercancel=${this._onFramePointerUp}\n >\n <div\n part=\"progress\"\n class=\"progress\"\n role=\"progressbar\"\n aria-label=${this._localize.term('storyProgress')}\n aria-valuenow=${this.chapter + 1}\n aria-valuemin=\"1\"\n aria-valuemax=${chapterStarts.length || 1}\n >\n ${map(\n chapterStarts,\n (_, i) => html`\n <span\n part=\"progress-segment\"\n class=\"progress-segment\"\n data-state=${i < this.chapter ? 'past' : i === this.chapter ? 'active' : 'future'}\n >\n <span\n part=\"progress-fill\"\n class=\"progress-fill\"\n ></span>\n </span>\n `,\n )}\n </div>\n\n <header\n part=\"header\"\n class=\"header\"\n data-no-gesture\n >\n <slot name=\"header\">\n ${\n currentStory?.poster\n ? html`<img\n class=\"header-thumb\"\n src=${currentStory.poster}\n alt=\"\"\n />`\n : nothing\n }\n ${\n currentStory?.label\n ? html`<div class=\"header-text\">\n <div\n part=\"header-label\"\n class=\"header-label\"\n >\n ${currentStory.label}\n </div>\n </div>`\n : nothing\n }\n </slot>\n </header>\n\n <div\n part=\"actions\"\n class=\"actions\"\n data-no-gesture\n >\n <slot name=\"close\">\n <button\n type=\"button\"\n part=\"button-close\"\n class=\"btn btn-close\"\n aria-label=${this._localize.term('close')}\n @click=${() => this.close()}\n >\n <${iconTag} name=\"mdi:close\"></${iconTag}>\n </button>\n </slot>\n <button\n type=\"button\"\n part=\"button-pause\"\n class=\"btn btn-pause\"\n aria-label=${this._paused ? 'Play' : 'Pause'}\n aria-pressed=${this._paused ? 'true' : 'false'}\n @click=${() => (this._paused ? this.play() : this.pause())}\n >\n <${iconTag} name=${this._paused ? 'mdi:play' : 'mdi:pause'}></${iconTag}>\n </button>\n <button\n type=\"button\"\n part=\"button-mute\"\n class=\"btn btn-mute\"\n aria-label=${this.muted ? this._localize.term('unmute') : this._localize.term('mute')}\n aria-pressed=${this.muted ? 'false' : 'true'}\n @click=${() => {\n this.muted = !this.muted;\n this.dispatchEvent(new MuteChangeEvent(this.muted));\n }}\n >\n <${iconTag} name=${this.muted ? 'mdi:volume-off' : 'mdi:volume-high'}></${iconTag}>\n </button>\n </div>\n\n <video\n part=\"video\"\n class=\"video\"\n playsinline\n preload=\"metadata\"\n ?muted=${this.muted}\n ></video>\n\n <${spinnerTag}\n part=\"spinner\"\n class=\"spinner\"\n aria-label=${this._localize.term('loading')}\n data-no-gesture\n data-state=${this._loading ? 'loading' : 'idle'}\n ></${spinnerTag}>\n\n <!-- Tap zones: invisible overlays that translate clicks into previous/next.\n Sit BELOW header / overlay / chevron buttons in z-order, above the video. -->\n <div\n class=\"tap-zone tap-previous\"\n data-tap=\"previous\"\n aria-hidden=\"true\"\n ></div>\n <div\n class=\"tap-zone tap-next\"\n data-tap=\"next\"\n aria-hidden=\"true\"\n ></div>\n\n <div\n part=\"overlay\"\n class=\"overlay\"\n data-no-gesture\n >\n <slot name=\"cta\"></slot>\n </div>\n\n <div\n class=\"sr-only\"\n aria-live=\"polite\"\n >\n ${\n total\n ? `Story ${this.index + 1} of ${total}${\n this.stories[this.index]?.label ? ` — ${this.stories[this.index].label}` : ''\n }${chapterStarts.length > 1 ? ` — chapter ${this.chapter + 1} of ${chapterStarts.length}` : ''}`\n : ''\n }\n </div>\n </div>\n\n ${\n isFirstStory\n ? nothing\n : html`<button\n type=\"button\"\n part=\"button-previous\"\n class=\"btn btn-nav btn-previous\"\n aria-label=${this._localize.term('previousStory')}\n @click=${() => this.previousStory()}\n >\n <${iconTag} name=\"mdi:chevron-left\"></${iconTag}>\n </button>`\n }\n ${\n isLastStory\n ? nothing\n : html`<button\n type=\"button\"\n part=\"button-next\"\n class=\"btn btn-nav btn-next\"\n aria-label=${this._localize.term('nextStory')}\n @click=${() => this.nextStory()}\n >\n <${iconTag} name=\"mdi:chevron-right\"></${iconTag}>\n </button>`\n }\n </dialog>\n `;\n }\n}\n"],"mappings":"A,2uBCcA,IAAMgB,EAAShB,EAAUC,4tHAAS,EAGrBgB,EAAb,cAAsC,KAAM,CAG1C,YAAY,EAAe,EAAmB,CAC5C,MAAM,eAAgB,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EAC5E,KAAK,MAAQC,EACb,KAAK,MAAQC,CACf,CACF,EAGaC,EAAb,cAAmC,KAAM,CAEvC,YAAY,EAAe,CACzB,MAAM,YAAa,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EACzE,KAAK,MAAQF,CACf,CACF,EAGaG,EAAb,cAAwC,KAAM,CAG5C,YAAY,EAAiB,EAAmB,CAC9C,MAAM,iBAAkB,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EAC9E,KAAK,QAAUC,EACf,KAAK,MAAQH,CACf,CACF,EAGaI,EAAb,cAAqC,KAAM,CAEzC,YAAY,EAAgB,CAC1B,MAAM,cAAe,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EAC3E,KAAK,MAAQC,C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A,EAAAoB,EAAA,UAAA,WAAA,IAAA,EAAA,E"}
1
+ {"version":3,"file":"stories-viewer.js","names":["unsafeCSS","rawStyles","hostStyles","visuallyHiddenStyles","map","nothing","_decorate","property","query","state","r","u","__decorate","e","A","o","host_styles_default","visually_hidden_styles_default","styles","StoryChangeEvent","index","story","StoryEndEvent","ChapterChangeEvent","chapter","MuteChangeEvent","muted","SCROLL_LOCK_SHEET","sheet","tagName","LuxenStoriesViewer","LuxenElement","_args","LocalizeController","start","dx","dy","elapsed","v","seg","end","span","p","openBecoming","changed","indexChanged","ShowEvent","HideEvent","i","nextStory","link","links","target","node","child","clone","direction","previousStory","previousLast","stories","source","anims","a","name","AfterShowEvent","AfterHideEvent","total","currentStory","isFirstStory","isLastStory","chapterStarts","iconTag","staticTag","spinnerTag","cls","n","r$1"],"sources":["../../../src/html/elements/stories-viewer/stories-viewer.css?inline","../../../src/html/elements/stories-viewer/stories-viewer.ts"],"sourcesContent":[":host {\n --width: min(420px, 100vw);\n --aspect-ratio: 9 / 16;\n --progress-color: white;\n --progress-bg: rgb(255 255 255 / 35%);\n --progress-gap: 4px;\n --show-duration: 200ms;\n --hide-duration: 200ms;\n /* Semi-transparent backdrop so the underlying page (e.g. a product page) stays visible behind the player, but with enough darkness to focus attention on the frame. Override with `--backdrop: …` or set to `oklch(0% 0 0 / 90%)` for an opaque blackout. */\n --backdrop: var(--l-backdrop-strong);\n\n display: contents;\n}\n\ndialog {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100dvh;\n max-width: none;\n max-height: none;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: white;\n overflow: clip;\n\n /* Center the frame at all times. `place-items` is on the base rule so it survives the close transition (only `display` and `opacity` are transitioned with `allow-discrete`; non-transitioned properties revert immediately when `[open]` is removed and would un-center the frame to top-left for one frame). */\n place-items: center;\n\n /* EXIT STATE */\n opacity: 0;\n\n transition-property: opacity, display, overlay;\n transition-duration: var(--hide-duration);\n transition-behavior: allow-discrete;\n\n &::backdrop {\n background: var(--backdrop);\n }\n\n /* OPEN STATE */\n &[open] {\n display: grid;\n opacity: 1;\n transition-duration: var(--show-duration);\n }\n\n /* BEFORE-OPEN STATE */\n @starting-style {\n &[open] {\n opacity: 0;\n }\n }\n}\n\n.frame {\n position: relative;\n width: var(--width);\n max-width: 100vw;\n max-height: 100dvh;\n aspect-ratio: var(--aspect-ratio);\n background: black;\n border-radius: 0.75rem;\n overflow: clip;\n isolation: isolate;\n user-select: none;\n -webkit-user-select: none;\n touch-action: pan-y;\n}\n\n@media (max-width: 480px) {\n .frame {\n width: 100vw;\n height: 100dvh;\n aspect-ratio: auto;\n border-radius: 0;\n }\n}\n\n.video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n background: black;\n}\n\n/* Loading spinner — centered over the video. Delayed fade-in so a fast buffer never visibly flashes the spinner. */\n.spinner {\n position: absolute;\n inset: 0;\n margin: auto;\n z-index: 1;\n width: 2rem;\n height: 2rem;\n color: white;\n pointer-events: none;\n opacity: 0;\n transition: opacity 150ms ease;\n}\n\n.spinner[data-state='loading'] {\n opacity: 1;\n /* Only paint the spinner if loading actually exceeds 200ms. */\n transition-delay: 200ms;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .spinner {\n transition: none;\n }\n}\n\n.progress {\n position: absolute;\n top: 0.5rem;\n left: 0.5rem;\n right: 0.5rem;\n z-index: 2;\n display: flex;\n gap: var(--progress-gap);\n pointer-events: none;\n}\n\n.progress-segment {\n flex: 1 1 0;\n height: 2.5px;\n border-radius: 999px;\n background: var(--progress-bg);\n overflow: clip;\n}\n\n.progress-fill {\n display: block;\n width: 100%;\n height: 100%;\n background: var(--progress-color);\n transform: scaleX(var(--p, 0));\n transform-origin: left;\n transition: transform 80ms linear;\n}\n\n.progress-segment[data-state='past'] .progress-fill {\n transform: scaleX(1);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .progress-fill {\n transition: none;\n }\n :host {\n --show-duration: 0ms;\n --hide-duration: 0ms;\n }\n}\n\n/* Top-left header — story thumbnail + label (slot fallback) or consumer-supplied content. */\n.header {\n position: absolute;\n top: 1.25rem;\n left: 0.75rem;\n right: 4rem; /* leave room for the right-side action stack */\n z-index: 2;\n display: flex;\n align-items: center;\n gap: 0.625rem;\n min-width: 0;\n pointer-events: none;\n}\n\n.header > ::slotted(*) {\n pointer-events: auto;\n}\n\n.header-thumb {\n width: 2rem;\n height: 2rem;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n pointer-events: auto;\n}\n\n.header-text {\n display: flex;\n flex-direction: column;\n min-width: 0;\n pointer-events: auto;\n}\n\n.header-label {\n font-size: 0.875rem;\n font-weight: var(--l-font-weight-semibold);\n line-height: 1.2;\n color: white;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Top-right vertical action stack — close, play/pause, mute. */\n.actions {\n position: absolute;\n top: 1.25rem;\n right: 0.75rem;\n z-index: 2;\n display: flex;\n flex-direction: column;\n /* 12px gap leaves room for the 6px hit-area extension on each adjacent button (see `.btn::before` below). */\n gap: 0.75rem;\n pointer-events: none;\n}\n\n.actions > ::slotted(*),\n.actions .btn {\n pointer-events: auto;\n}\n\n.btn {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border: 0;\n border-radius: 999px;\n background: rgb(0 0 0 / 25%);\n color: white;\n font-size: 1rem;\n cursor: pointer;\n transition: background 150ms ease;\n\n &:hover {\n background: rgb(0 0 0 / 45%);\n }\n\n &:focus-visible {\n outline: 2px solid var(--progress-color);\n outline-offset: 2px;\n }\n\n /* WCAG 2.1 SC 2.5.5 / RGAA 13.4 — 44×44 hit area without changing the visible 32×32 disc. The pseudo carries no paint, only hit testing. */\n &::before {\n content: '';\n position: absolute;\n inset: -6px;\n }\n}\n\n.btn-nav {\n position: absolute;\n z-index: 2;\n width: 2.25rem;\n height: 2.25rem;\n font-size: 1.25rem;\n\n /* Chevrons start at 36×36 — 4px each side reaches 44. */\n &::before {\n inset: -4px;\n }\n}\n\n.btn-previous,\n.btn-next {\n top: 50%;\n transform: translateY(-50%);\n}\n\n/* Desktop ≥ 768px: chevrons sit outside the frame, on the dim backdrop. */\n@media (min-width: 768px) {\n .btn-previous {\n left: calc(50% - var(--width) / 2 - 3rem);\n }\n .btn-next {\n right: calc(50% - var(--width) / 2 - 3rem);\n }\n}\n\n/* Mobile < 768px: hide chevrons entirely — tap zones drive nav. */\n@media (max-width: 767px) {\n .btn-previous,\n .btn-next {\n display: none;\n }\n}\n\n/*\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🆃🅰🅿 zones (invisible click/tap targets — left = previous, rest = next)\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n*/\n\n.tap-zone {\n position: absolute;\n top: 0;\n bottom: 0;\n z-index: 0;\n}\n\n.tap-previous {\n left: 0;\n width: 30%;\n}\n\n.tap-next {\n left: 30%;\n right: 0;\n}\n\n.overlay {\n position: absolute;\n inset: auto 0 0 0;\n z-index: 1;\n padding: 1rem;\n pointer-events: none;\n}\n\n.overlay > ::slotted(*) {\n pointer-events: auto;\n}\n","import { nothing, unsafeCSS, type CSSResultGroup, type PropertyValues } from 'lit';\nimport { html } from 'lit/static-html.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport { LuxenElement } from '../../shared/luxen-element.js';\nimport { LocalizeController } from '../../shared/localize.js';\nimport { cls, tagName } from '../../registry.js';\nimport { staticTag } from '../../static-tag.js';\nimport { ShowEvent, AfterShowEvent, HideEvent, AfterHideEvent } from '../../events/index.js';\nimport hostStyles from '../../shared/styles/host.styles.js';\nimport visuallyHiddenStyles from '../../shared/styles/visually-hidden.styles.js';\nimport type { LuxenStories } from '../stories/stories.js';\nimport type { LuxenStory } from '../story/story.js';\nimport rawStyles from './stories-viewer.css?inline';\n\nconst styles = unsafeCSS(rawStyles);\n\n/** Fired when the active story changes. */\nexport class StoryChangeEvent extends Event {\n readonly index: number;\n readonly story: LuxenStory;\n constructor(index: number, story: LuxenStory) {\n super('story-change', { bubbles: false, composed: false, cancelable: false });\n this.index = index;\n this.story = story;\n }\n}\n\n/** Fired when the active story finishes playback. */\nexport class StoryEndEvent extends Event {\n readonly index: number;\n constructor(index: number) {\n super('story-end', { bubbles: false, composed: false, cancelable: false });\n this.index = index;\n }\n}\n\n/** Fired when the active chapter (within a story) changes. */\nexport class ChapterChangeEvent extends Event {\n readonly chapter: number;\n readonly story: LuxenStory;\n constructor(chapter: number, story: LuxenStory) {\n super('chapter-change', { bubbles: false, composed: false, cancelable: false });\n this.chapter = chapter;\n this.story = story;\n }\n}\n\n/** Fired when the mute state changes. */\nexport class MuteChangeEvent extends Event {\n readonly muted: boolean;\n constructor(muted: boolean) {\n super('mute-change', { bubbles: false, composed: false, cancelable: false });\n this.muted = muted;\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'story-change': StoryChangeEvent;\n 'story-end': StoryEndEvent;\n 'chapter-change': ChapterChangeEvent;\n 'mute-change': MuteChangeEvent;\n }\n}\n\nconst SCROLL_LOCK_SHEET = Symbol.for('luxen-stories-viewer-scroll-lock');\nif (typeof document !== 'undefined' && !(SCROLL_LOCK_SHEET in document)) {\n const sheet = new CSSStyleSheet();\n // Runs at import time, after the consumer has called `setPrefix()` (or the\n // vite-plugin baked it into registry.js) — same ordering `define()` relies on.\n sheet.replaceSync(\n `html:has(${tagName('stories-viewer')}[data-modal]) { overflow: hidden; scrollbar-gutter: stable; }`,\n );\n document.adoptedStyleSheets.push(sheet);\n Object.defineProperty(document, SCROLL_LOCK_SHEET, { value: sheet });\n}\n\n/**\n * @summary Fullscreen modal that plays a sequence of `<l-story>` videos with an\n * Instagram-style segmented progress bar, previous/next navigation, mute toggle,\n * and auto-advance.\n *\n * Linked to one or more `<l-stories>` rows via matching `id` ↔ `for`. Open\n * programmatically via `open()` or by clicking a thumbnail in a linked row.\n *\n * @slot cta - Default CTA overlay (e.g. shoppable card). Per-story `slot=\"cta\"` inside `<l-story>` overrides this when that story is active.\n * @slot header - Default header overlay (e.g. avatar + author). Per-story override available the same way.\n * @slot close - Override the default close button.\n *\n * @csspart dialog - The native `<dialog>` element.\n * @csspart frame - The aspect-ratio video frame.\n * @csspart progress - The progress bar wrapper.\n * @csspart progress-segment - A single progress segment.\n * @csspart progress-fill - The fill element inside an active segment.\n * @csspart video - The `<video>` element.\n * @csspart overlay - The overlay wrapper that hosts CTA/header slots.\n * @csspart header - The top-left header area (story thumbnail + label fallback, or consumer-supplied content via the `header` slot).\n * @csspart header-label - The default story label inside the header.\n * @csspart actions - The top-right vertical button stack (close, play/pause, mute).\n * @csspart button-close - The close button.\n * @csspart button-pause - The play/pause toggle.\n * @csspart button-mute - The mute toggle.\n * @csspart button-previous - The previous story button.\n * @csspart button-next - The next story button.\n * @csspart spinner - The loading spinner shown while the current video is buffering.\n *\n * @cssproperty --width - Frame width. Default `min(420px, 100vw)`.\n * @cssproperty --progress-color - Active progress fill color. Default `white`.\n * @cssproperty --progress-bg - Inactive progress segment background. Default `rgb(255 255 255 / 35%)`.\n * @cssproperty --progress-gap - Gap between segments. Default `4px`.\n * @cssproperty --show-duration - Open transition duration. Default `200ms`.\n * @cssproperty --hide-duration - Close transition duration. Default `200ms`.\n * @cssproperty --backdrop - Backdrop color. Default `var(--l-backdrop-strong)` — darker than `--l-backdrop` to focus attention on the immersive frame, but still translucent so the page stays perceptible.\n *\n * @event show - Fired when the viewer is about to open. Cancelable — call `event.preventDefault()` to keep it closed.\n * @event after-show - Fired after the open transition completes. Not cancelable.\n * @event hide - Fired when the viewer is about to close. Cancelable.\n * @event after-hide - Fired after the close transition completes. Not cancelable.\n * @event story-change - Fired when the active story changes. Properties: `index: number`, `story: LuxenStory`.\n * @event story-end - Fired when the active story finishes playback. Properties: `index: number`.\n * @event chapter-change - Fired when the active chapter (within a story) changes. Properties: `chapter: number`, `story: LuxenStory`.\n * @event mute-change - Fired when the mute state changes. Properties: `muted: boolean`.\n *\n * @customElement l-stories-viewer\n */\nexport class LuxenStoriesViewer extends LuxenElement {\n static override styles: CSSResultGroup = [hostStyles, visuallyHiddenStyles, styles];\n\n private _localize = new LocalizeController(this);\n\n /** Whether the viewer is open. */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /** Active story index (0-based). */\n @property({ type: Number, reflect: true })\n index = 0;\n\n /** Whether playback is muted. Defaults to `true` so autoplay always succeeds across browsers. The user can unmute via the dedicated button or the `m` keyboard shortcut. */\n @property({ type: Boolean, reflect: true })\n muted = true;\n\n /** Loop the active story instead of advancing. */\n @property({ type: Boolean, reflect: true })\n loop = false;\n\n /** Move to the next story when the current one ends; close after the last story. */\n @property({ type: Boolean, reflect: true, attribute: 'auto-advance' })\n autoAdvance = true;\n\n /** Close when the backdrop is clicked. */\n @property({ type: Boolean, reflect: true, attribute: 'light-dismiss' })\n lightDismiss = true;\n\n /** Active chapter index within the current story. Reflected. */\n @property({ type: Number, reflect: true })\n chapter = 0;\n\n /** Internal: the playlist set by the source `<l-stories>`. */\n stories: LuxenStory[] = [];\n\n /** Internal: the source `<l-stories>` element that opened the viewer. */\n source: LuxenStories | null = null;\n\n @query('dialog') private _dialog!: HTMLDialogElement;\n @query('video') private _video!: HTMLVideoElement;\n\n /** Tracks the underlying `<video>` paused state so the play/pause button stays in sync. */\n @state() private _paused = false;\n\n /** True while the video is buffering / waiting for data. Drives the loading spinner. */\n @state() private _loading = false;\n\n private _raf = 0;\n private _holdTimer = 0;\n private _pointerStart: { x: number; y: number; t: number } | null = null;\n private _segments: HTMLElement[] = [];\n private _chapterStarts: number[] = [0];\n /** Tracks the URL we've already injected a prefetch hint for so we don't duplicate. */\n private _prefetchedSrc: string | null = null;\n\n // --- Lifecycle ---\n\n override connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this._onKeyDown);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('keydown', this._onKeyDown);\n cancelAnimationFrame(this._raf);\n clearTimeout(this._holdTimer);\n this._clearPrefetchHints();\n }\n\n override firstUpdated() {\n this._dialog.addEventListener('cancel', (e) => this._onCancel(e));\n this._dialog.addEventListener('close', () => this._onNativeClose());\n this._dialog.addEventListener('click', (e) => this._onDialogClick(e));\n this._video.addEventListener('ended', () => this._onEnded());\n this._video.addEventListener('loadedmetadata', () => this._tick());\n this._video.addEventListener('play', () => (this._paused = false));\n this._video.addEventListener('pause', () => (this._paused = true));\n // Loading spinner state — shown during initial buffer and any subsequent stalls,\n // hidden as soon as the video is actually painting frames.\n this._video.addEventListener('loadstart', () => (this._loading = true));\n this._video.addEventListener('waiting', () => (this._loading = true));\n this._video.addEventListener('playing', () => (this._loading = false));\n this._video.addEventListener('canplay', () => (this._loading = false));\n this._video.addEventListener('error', () => (this._loading = false));\n // Prefetch the next story's video once the current one is past 50% so the\n // transition feels instantaneous. Idempotent via `_prefetchedSrc`.\n this._video.addEventListener('timeupdate', () => this._maybePrefetchNext());\n }\n\n override willUpdate(changed: PropertyValues<this>) {\n // Reset chapter state synchronously so it folds into the same update cycle —\n // avoids writing reactive props from updated() which would schedule a second update.\n const openBecoming = changed.has('open') && this.open;\n const indexChanged = changed.has('index');\n if (openBecoming || indexChanged) {\n const story = this.stories[this.index];\n if (story) {\n this._chapterStarts = story.getChapterStarts();\n this.chapter = 0;\n }\n }\n }\n\n override updated(changed: PropertyValues<this>) {\n if (changed.has('open')) {\n if (this.open && !this._dialog.open) {\n if (!this.dispatchEvent(new ShowEvent())) {\n // Defer the revert so it lands outside the current update cycle and\n // doesn't schedule a new update from inside updated().\n queueMicrotask(() => {\n this.open = false;\n });\n return;\n }\n this.toggleAttribute('data-modal', true);\n this._dialog.showModal();\n queueMicrotask(() => this._loadCurrent());\n void this._emitAfter('after-show');\n } else if (!this.open && this._dialog.open) {\n if (!this.dispatchEvent(new HideEvent())) {\n // Defer the revert so it lands outside the current update cycle and\n // doesn't schedule a new update from inside updated().\n queueMicrotask(() => {\n this.open = true;\n });\n return;\n }\n this._dialog.close();\n }\n }\n\n // Story change → reload current story (refreshes chapters, segments, slots, video).\n if (changed.has('index') && this.open) {\n queueMicrotask(() => this._loadCurrent());\n const story = this.stories[this.index];\n if (story) this.dispatchEvent(new StoryChangeEvent(this.index, story));\n }\n\n // Chapter change within the current story → seek + refresh segment fills.\n if (changed.has('chapter') && this.open && !changed.has('index')) {\n this._applyChapterSeek();\n }\n\n if (changed.has('muted') && this._video) {\n this._video.muted = this.muted;\n }\n }\n\n // --- Dialog event handlers ---\n\n private _onCancel(e: Event) {\n if (!this.dispatchEvent(new HideEvent())) {\n e.preventDefault();\n }\n }\n\n private _onNativeClose() {\n cancelAnimationFrame(this._raf);\n this._video.pause();\n this._video.removeAttribute('src');\n this._video.load();\n this._clearPrefetchHints();\n // Mark all stories up to and including this.index as seen.\n for (let i = 0; i <= this.index && i < this.stories.length; i++) {\n this.stories[i].seen = true;\n }\n this._restoreFocus();\n this.open = false;\n this.removeAttribute('data-modal');\n void this._emitAfter('after-hide');\n }\n\n private _onDialogClick(e: MouseEvent) {\n if (!this.lightDismiss) return;\n // Backdrop click: target is the <dialog>, not a child.\n if (e.target === this._dialog) {\n this.open = false;\n }\n }\n\n // --- Keyboard ---\n\n private _onKeyDown = (e: KeyboardEvent) => {\n if (!this.open) return;\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n this.previous();\n break;\n case 'ArrowRight':\n e.preventDefault();\n this.next();\n break;\n case ' ':\n e.preventDefault();\n if (this._video.paused) this.play();\n else this.pause();\n break;\n case 'm':\n case 'M':\n e.preventDefault();\n this.muted = !this.muted;\n this.dispatchEvent(new MuteChangeEvent(this.muted));\n break;\n }\n };\n\n // --- Pointer / touch (long-press to pause, tap-to-advance, swipe to close) ---\n\n private _onFramePointerDown = (e: PointerEvent) => {\n // Skip buttons, links, and explicitly-marked no-gesture areas.\n if ((e.target as HTMLElement).closest('button, a, [data-no-gesture]')) return;\n this._pointerStart = { x: e.clientX, y: e.clientY, t: performance.now() };\n this._holdTimer = window.setTimeout(() => this.pause(), 200);\n };\n\n private _onFramePointerUp = (e: PointerEvent) => {\n clearTimeout(this._holdTimer);\n const start = this._pointerStart;\n this._pointerStart = null;\n if (!start) return;\n\n const dx = e.clientX - start.x;\n const dy = e.clientY - start.y;\n const elapsed = performance.now() - start.t;\n const isTap = elapsed < 200 && Math.abs(dx) < 10 && Math.abs(dy) < 10;\n const wasLongPress = elapsed >= 200 && Math.abs(dx) < 10 && Math.abs(dy) < 10;\n const SWIPE = 50;\n\n if (wasLongPress) {\n if (this._video.paused) this.play();\n return;\n }\n\n if (isTap) {\n // Tap zones: chapter-aware nav. Left ~30% = previous chapter (or previous\n // story at the chapter boundary), anywhere else = next chapter (or next\n // story at the last chapter). Chevron buttons remain story-to-story.\n const tap = (e.target as HTMLElement).closest<HTMLElement>('[data-tap]');\n if (tap?.dataset.tap === 'previous') this.previous();\n else this.next();\n return;\n }\n\n if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > SWIPE) {\n if (dx < 0) this.nextStory();\n else this.previousStory();\n } else if (dy > SWIPE) {\n this.close();\n }\n };\n\n // --- Segments / progress (chapter-based) ---\n\n private _refreshSegmentRefs() {\n this._segments = Array.from(\n this.shadowRoot!.querySelectorAll<HTMLElement>('[part~=\"progress-fill\"]'),\n );\n }\n\n private _resetSegmentFills() {\n this._refreshSegmentRefs();\n for (let i = 0; i < this._segments.length; i++) {\n const p = i < this.chapter ? 1 : 0;\n this._segments[i].style.setProperty('--p', String(p));\n }\n }\n\n private _loadCurrent() {\n // Guard against a close racing the microtask: if the viewer is no longer\n // open, don't restart the video with stale state.\n if (!this.open || !this._dialog.open) return;\n const story = this.stories[this.index];\n if (!story) return;\n cancelAnimationFrame(this._raf);\n // Reset the prefetch tracker when the active story changes — the next\n // candidate has shifted and may need its own preload hint.\n this._prefetchedSrc = null;\n this._syncSlots(story);\n this._video.muted = this.muted;\n this._video.loop = this.loop;\n if (this._video.src !== story.src) {\n this._video.src = story.src;\n } else {\n this._video.currentTime = 0;\n }\n // Wait one frame for the new segment DOM to render before resetting fills.\n requestAnimationFrame(() => this._resetSegmentFills());\n this._video.play().catch(() => {\n // Autoplay-with-sound rejection: force muted, retry.\n this.muted = true;\n this._video.muted = true;\n this._video.play().catch(() => {});\n });\n }\n\n /**\n * Inject a `<link rel=\"preload\" as=\"video\">` for the next story once the\n * current video crosses 50% playback. Idempotent: tracked by `_prefetchedSrc`,\n * cleaned up on viewer close.\n */\n private _maybePrefetchNext() {\n const v = this._video;\n if (!v.duration || v.currentTime / v.duration < 0.5) return;\n const nextStory = this.stories[this.index + 1];\n if (!nextStory?.src) return;\n if (this._prefetchedSrc === nextStory.src) return;\n this._prefetchedSrc = nextStory.src;\n\n const link = document.createElement('link');\n link.rel = 'preload';\n link.as = 'video';\n link.href = nextStory.src;\n link.crossOrigin = 'anonymous';\n link.dataset.luxenStoriesPrefetch = '';\n document.head.appendChild(link);\n }\n\n /** Remove every prefetch hint we've injected. Called when the viewer closes. */\n private _clearPrefetchHints() {\n const links = document.head.querySelectorAll<HTMLLinkElement>(\n 'link[data-luxen-stories-prefetch]',\n );\n for (const link of links) link.remove();\n this._prefetchedSrc = null;\n }\n\n private _applyChapterSeek() {\n const target = this._chapterStarts[this.chapter] ?? 0;\n this._video.currentTime = target;\n this._resetSegmentFills();\n const story = this.stories[this.index];\n if (story) this.dispatchEvent(new ChapterChangeEvent(this.chapter, story));\n }\n\n private get _lastChapter() {\n return Math.max(0, this._chapterStarts.length - 1);\n }\n\n // Clone the active story's slot-marked children (cta, header) into the\n // viewer's own light DOM so the shadow root's `<slot name=\"cta\">` and\n // `<slot name=\"header\">` project them. Originals stay attached to the\n // story (hidden via CSS) and are reused on every `index` change.\n private _syncSlots(story: LuxenStory) {\n for (const node of Array.from(this.children)) {\n if ((node as HTMLElement).dataset.storySlot !== undefined) node.remove();\n }\n for (const child of Array.from(story.children)) {\n const slotName = (child as HTMLElement).getAttribute?.('slot');\n if (!slotName) continue;\n const clone = child.cloneNode(true) as HTMLElement;\n clone.dataset.storySlot = '';\n this.appendChild(clone);\n }\n }\n\n private _tick = () => {\n if (!this.open) return;\n const v = this._video;\n const seg = this._segments[this.chapter];\n if (v && seg) {\n const start = this._chapterStarts[this.chapter] ?? 0;\n const end = this._chapterStarts[this.chapter + 1] ?? v.duration;\n const span = Math.max(0, end - start);\n const p = span ? Math.max(0, Math.min((v.currentTime - start) / span, 1)) : 0;\n seg.style.setProperty('--p', String(p));\n // Auto-advance chapter when its segment is full and there's a next chapter in this story.\n // (The video element's `ended` event handles the last chapter via `_onEnded`.)\n if (p >= 1 && this.chapter < this._lastChapter) {\n this._advance(1);\n }\n }\n this._raf = requestAnimationFrame(this._tick);\n };\n\n private _onEnded() {\n // Last chapter of the current story finished.\n const story = this.stories[this.index];\n if (story) this.dispatchEvent(new StoryEndEvent(this.index));\n if (this.loop) {\n this._video.currentTime = this._chapterStarts[0] ?? 0;\n this.chapter = 0;\n this._video.play().catch(() => {});\n return;\n }\n if (!this.autoAdvance) return;\n if (this.index < this.stories.length - 1) {\n this.index = this.index + 1;\n } else {\n this.close();\n }\n }\n\n /** chapter-then-story navigation. */\n private _advance(direction: 1 | -1) {\n if (direction === 1) {\n if (this.chapter < this._lastChapter) {\n this.chapter = this.chapter + 1;\n } else if (this.index < this.stories.length - 1) {\n this.index = this.index + 1;\n } else {\n this.close();\n }\n return;\n }\n // direction === -1: Instagram pattern — restart the current chapter if past 1s in.\n const start = this._chapterStarts[this.chapter] ?? 0;\n if (this._video.currentTime > start + 1) {\n this._video.currentTime = start;\n this._resetSegmentFills();\n return;\n }\n if (this.chapter > 0) {\n this.chapter = this.chapter - 1;\n } else if (this.index > 0) {\n // Crossing into the previous story: load it, then jump to its last chapter.\n const previousStory = this.stories[this.index - 1];\n const previousLast = Math.max(0, previousStory.getChapterStarts().length - 1);\n this.index = this.index - 1;\n // After `index` updates, `_loadCurrent()` runs and resets `chapter` to 0.\n // Set `chapter` to the previous story's last chapter on the next microtask.\n queueMicrotask(() => {\n this.chapter = previousLast;\n });\n }\n }\n\n // --- Public API ---\n\n /** Open the viewer at the given index with an explicit playlist. */\n openAt(stories: LuxenStory[], index = 0, source: LuxenStories | null = null) {\n this.stories = stories;\n this.source = source;\n this.index = Math.max(0, Math.min(index, stories.length - 1));\n this.open = true;\n }\n\n close() {\n this.open = false;\n }\n\n /** Advance one chapter, or to the next story at the chapter boundary. */\n next() {\n this._advance(1);\n }\n\n /** Retreat one chapter, restart the current chapter past 1s in, or cross into the previous story. */\n previous() {\n this._advance(-1);\n }\n\n /** Jump to the next story, skipping any remaining chapters in the current story. */\n nextStory() {\n if (this.index < this.stories.length - 1) {\n this.index = this.index + 1;\n } else {\n this.close();\n }\n }\n\n /** Jump to the previous story regardless of current chapter. Lands on chapter 0 of the previous story. */\n previousStory() {\n if (this.index > 0) {\n this.index = this.index - 1;\n }\n }\n\n play() {\n this._video?.play().catch(() => {});\n this._raf = requestAnimationFrame(this._tick);\n }\n\n pause() {\n this._video?.pause();\n cancelAnimationFrame(this._raf);\n }\n\n // --- Helpers ---\n\n private async _emitAfter(name: 'after-show' | 'after-hide') {\n await new Promise((r) => requestAnimationFrame(() => r(null)));\n const anims = this._dialog.getAnimations({ subtree: false });\n await Promise.all(anims.map((a) => a.finished.catch(() => {})));\n if ((name === 'after-show') !== this.open) return;\n this.dispatchEvent(name === 'after-show' ? new AfterShowEvent() : new AfterHideEvent());\n if (name === 'after-show') {\n this._raf = requestAnimationFrame(this._tick);\n }\n }\n\n private _restoreFocus() {\n const stories = this.source?.stories() ?? this.stories;\n const story = stories[this.index];\n const trigger = story?.querySelector<HTMLButtonElement>('button[data-story-trigger]');\n trigger?.focus({ preventScroll: false });\n }\n\n override render() {\n const total = this.stories.length;\n const currentStory = this.stories[this.index];\n // Chevrons navigate story-to-story, so visibility depends on `index` only (not chapter).\n const isFirstStory = this.index === 0;\n const isLastStory = this.index >= total - 1;\n // Render one segment per chapter of the CURRENT story. Use `_chapterStarts` if present\n // (set after `_loadCurrent`), or fall back to the current story's parsed chapters.\n const chapterStarts = this._chapterStarts.length\n ? this._chapterStarts\n : (currentStory?.getChapterStarts() ?? [0]);\n const iconTag = staticTag('icon');\n const spinnerTag = staticTag('spinner');\n\n return html`\n <dialog\n part=\"dialog\"\n aria-label=${this._localize.term('stories')}\n >\n <div\n part=\"frame\"\n class=\"frame\"\n @pointerdown=${this._onFramePointerDown}\n @pointerup=${this._onFramePointerUp}\n @pointercancel=${this._onFramePointerUp}\n >\n <div\n part=\"progress\"\n class=\"progress\"\n role=\"progressbar\"\n aria-label=${this._localize.term('storyProgress')}\n aria-valuenow=${this.chapter + 1}\n aria-valuemin=\"1\"\n aria-valuemax=${chapterStarts.length || 1}\n >\n ${map(\n chapterStarts,\n (_, i) => html`\n <span\n part=\"progress-segment\"\n class=\"progress-segment\"\n data-state=${i < this.chapter ? 'past' : i === this.chapter ? 'active' : 'future'}\n >\n <span\n part=\"progress-fill\"\n class=\"progress-fill\"\n ></span>\n </span>\n `,\n )}\n </div>\n\n <header\n part=\"header\"\n class=\"header\"\n data-no-gesture\n >\n <slot name=\"header\">\n ${\n currentStory?.poster\n ? html`<img\n class=\"header-thumb\"\n src=${currentStory.poster}\n alt=\"\"\n />`\n : nothing\n }\n ${\n currentStory?.label\n ? html`<div class=\"header-text\">\n <div\n part=\"header-label\"\n class=\"header-label\"\n >\n ${currentStory.label}\n </div>\n </div>`\n : nothing\n }\n </slot>\n </header>\n\n <div\n part=\"actions\"\n class=\"actions\"\n data-no-gesture\n >\n <slot name=\"close\">\n <button\n type=\"button\"\n part=\"button-close\"\n class=\"btn btn-close\"\n aria-label=${this._localize.term('close')}\n @click=${() => this.close()}\n >\n <${iconTag} name=\"mdi:close\"></${iconTag}>\n </button>\n </slot>\n <button\n type=\"button\"\n part=\"button-pause\"\n class=\"btn btn-pause\"\n aria-label=${this._paused ? 'Play' : 'Pause'}\n aria-pressed=${this._paused ? 'true' : 'false'}\n @click=${() => (this._paused ? this.play() : this.pause())}\n >\n <${iconTag} name=${this._paused ? 'mdi:play' : 'mdi:pause'}></${iconTag}>\n </button>\n <button\n type=\"button\"\n part=\"button-mute\"\n class=\"btn btn-mute\"\n aria-label=${this.muted ? this._localize.term('unmute') : this._localize.term('mute')}\n aria-pressed=${this.muted ? 'false' : 'true'}\n @click=${() => {\n this.muted = !this.muted;\n this.dispatchEvent(new MuteChangeEvent(this.muted));\n }}\n >\n <${iconTag} name=${this.muted ? 'mdi:volume-off' : 'mdi:volume-high'}></${iconTag}>\n </button>\n </div>\n\n <video\n part=\"video\"\n class=\"video\"\n playsinline\n preload=\"metadata\"\n ?muted=${this.muted}\n ></video>\n\n <${spinnerTag}\n part=\"spinner\"\n class=\"spinner\"\n aria-label=${this._localize.term('loading')}\n data-no-gesture\n data-state=${this._loading ? 'loading' : 'idle'}\n ></${spinnerTag}>\n\n <!-- Tap zones: invisible overlays that translate clicks into previous/next.\n Sit BELOW header / overlay / chevron buttons in z-order, above the video. -->\n <div\n class=\"tap-zone tap-previous\"\n data-tap=\"previous\"\n aria-hidden=\"true\"\n ></div>\n <div\n class=\"tap-zone tap-next\"\n data-tap=\"next\"\n aria-hidden=\"true\"\n ></div>\n\n <div\n part=\"overlay\"\n class=\"overlay\"\n data-no-gesture\n >\n <slot name=\"cta\"></slot>\n </div>\n\n <div\n class=${cls('visually-hidden')}\n aria-live=\"polite\"\n >\n ${\n total\n ? `Story ${this.index + 1} of ${total}${\n this.stories[this.index]?.label ? ` — ${this.stories[this.index].label}` : ''\n }${chapterStarts.length > 1 ? ` — chapter ${this.chapter + 1} of ${chapterStarts.length}` : ''}`\n : ''\n }\n </div>\n </div>\n\n ${\n isFirstStory\n ? nothing\n : html`<button\n type=\"button\"\n part=\"button-previous\"\n class=\"btn btn-nav btn-previous\"\n aria-label=${this._localize.term('previousStory')}\n @click=${() => this.previousStory()}\n >\n <${iconTag} name=\"mdi:chevron-left\"></${iconTag}>\n </button>`\n }\n ${\n isLastStory\n ? nothing\n : html`<button\n type=\"button\"\n part=\"button-next\"\n class=\"btn btn-nav btn-next\"\n aria-label=${this._localize.term('nextStory')}\n @click=${() => this.nextStory()}\n >\n <${iconTag} name=\"mdi:chevron-right\"></${iconTag}>\n </button>`\n }\n </dialog>\n `;\n }\n}\n"],"mappings":"A,izBCeA,IAAMkB,EAASlB,EAAUC,olHAAS,EAGrBkB,EAAb,cAAsC,KAAM,CAG1C,YAAY,EAAe,EAAmB,CAC5C,MAAM,eAAgB,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EAC5E,KAAK,MAAQC,EACb,KAAK,MAAQC,CACf,CACF,EAGaC,EAAb,cAAmC,KAAM,CAEvC,YAAY,EAAe,CACzB,MAAM,YAAa,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EACzE,KAAK,MAAQF,CACf,CACF,EAGaG,EAAb,cAAwC,KAAM,CAG5C,YAAY,EAAiB,EAAmB,CAC9C,MAAM,iBAAkB,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EAC9E,KAAK,QAAUC,EACf,KAAK,MAAQH,CACf,CACF,EAGaI,EAAb,cAAqC,KAAM,CAEzC,YAAY,EAAgB,CAC1B,MAAM,cAAe,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAM,CAAC,EAC3E,KAAK,MAAQC,CACf,CACF,EAWMC,EAAoB,OAAO,IAAI,kCAAkC,EACvE,GAAI,OAAO,SAAa,KAAe,EAAEA,KAAqB,UAAW,CACvE,IAAMC,EAAQ,I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unks/lit.js";import{r as t,t as n}from"../../chunks/decorate.js";import{LuxenElement as r}from"../../shared/luxen-element.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{LocalizeController as o}from"../../shared/localize.js";import{cls as s}from"../../registry.js";import c from"../../shared/styles/host.styles.js";import l from"../../shared/styles/checkbox-appearance.styles.js";var u=e(`@layer components{:host{--_height:var(--height,1.5rem);--_font-size:var(--font-size,var(--l-text-xs));--_padding-inline:var(--padding-inline,.5rem);--_gap:.25rem;--_background:var(--background-color,var(--l-color-bg-fill-neutral-subtle));--_color:var(--text-color,var(--l-color-text-neutral));--_border-strength:14%;--_border-color:var(--border-color,color-mix(in oklab, currentColor var(--_border-strength), transparent));--_border-color-hover:var(--border-color,color-mix(in oklab, currentColor calc(var(--_border-strength) + 12%), transparent));--_border-radius:var(--border-radius,var(--l-radius-full));--_remove-glyph:.75rem;vertical-align:middle;max-inline-size:100%;display:inline-flex}:host([size=sm]){--_padding-inline:var(--padding-inline,.375rem);--_gap:.125rem}:host([size=lg]){--_height:var(--height,1.75rem);--_font-size:var(--font-size,var(--l-text-sm));--_padding-inline:var(--padding-inline,.625rem);--_remove-glyph:.875rem}:host([disabled]) .base{cursor:not-allowed}.base{align-items:center;gap:var(--_gap);min-block-size:var(--_height);padding-inline:var(--_padding-inline);border:1px solid var(--_border-color);border-radius:var(--_border-radius);background-color:var(--_background);color:var(--_color);font-family:var(--l-font-neo-grotesque);font-size:var(--_font-size);font-weight:var(--l-font-weight-medium);min-inline-size:0;line-height:1;transition:background-color .12s,border-color .12s;display:inline-flex}:host([removable]) .base{min-block-size:max(1.5rem, var(--_height))}@media (hover:hover){:host([selectable]:hover:not([disabled])) .base{background-color:color-mix(in oklab, var(--_background), currentColor 7%);border-color:var(--_border-color-hover)}}.content{text-overflow:ellipsis;white-space:nowrap;align-items:center;min-inline-size:0;display:inline-flex;overflow:clip visible}::slotted([slot=prefix]){flex:none;display:inline-flex}::slotted([slot=suffix]){font-weight:var(--l-font-weight-normal);font-variant-numeric:tabular-nums;flex:none}:host([selectable]){--_height:var(--height,1.75rem);--_accent:var(--l-form-control-activated-color);--_selected-color:var(--selected-text-color,var(--lightningcss-light,color-mix(in oklab, var(--_accent), black 14%))var(--lightningcss-dark,color-mix(in oklab, var(--_accent), white 45%)));--_selected-background:var(--selected-background-color,color-mix(in oklab, var(--_selected-color) 10%, var(--l-color-surface)));--_selected-border-color:var(--selected-border-color,color-mix(in oklab, var(--_selected-color) 45%, transparent))}:host([selectable][size=lg]){--_height:var(--height,2rem)}:host([selectable][selected]){--_background:var(--_selected-background);--_color:var(--_selected-color);--_border-color:var(--_selected-border-color);--_border-color-hover:var(--selected-border-color,color-mix(in oklab, var(--_selected-color) 57%, transparent))}:host([selectable]) .base{cursor:pointer;-webkit-user-select:none;user-select:none}:host([selectable][disabled]) .base{cursor:not-allowed}.toggle{align-self:stretch;align-items:center;gap:var(--_gap);min-inline-size:0;margin-inline:calc(var(--_padding-inline) * -1);padding-inline:var(--_padding-inline);color:inherit;font:inherit;text-align:start;cursor:inherit;background:0 0;border:0;flex:auto;display:inline-flex}:host([removable]) .toggle{margin-inline-end:0;padding-inline-end:0}:host([selectable]) .toggle:focus-visible,:host([selectable]) .checkbox:focus-visible{outline:none}.base:has(:is(.toggle,.checkbox):focus-visible){outline:2px solid var(--l-focus-ring);outline-offset:2px}.checkbox{--accent:var(--selected-text-color,var(--l-form-control-activated-color));--_halo:var(--l-form-control-border-color-hover);font:inherit;flex:none;transition-property:background-color,border-color,box-shadow}.checkbox:checked,.checkbox:indeterminate{--_halo:var(--accent)}@media (hover:hover){:host([selectable]:not([disabled])) .base:hover .checkbox:not(:disabled){box-shadow:0 0 0 calc(var(--size) * var(--l-form-control-toggle-halo-ratio)) color-mix(in oklab, var(--_halo), transparent 84%)}}@media (forced-colors:active){:host([selectable][selected]) .base{border-color:highlight}}.remove{inline-size:max(1.5rem, var(--_height));margin-block:-1px;margin-inline:calc(var(--_padding-inline) - var(--_gap)) calc(var(--_padding-inline) * -1 - 1px);border:1px solid #0000;border-inline-start-color:var(--_border-color);color:inherit;cursor:pointer;--_press-scale:.86;background-color:#0000;background-clip:padding-box;border-start-end-radius:var(--_border-radius);border-end-end-radius:var(--_border-radius);flex:none;align-self:stretch;place-items:center;padding:0;transition:background-color .12s;display:grid}.remove:after{content:"";inline-size:var(--_remove-glyph);block-size:var(--_remove-glyph);background-color:currentColor;transition:scale .12s;-webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\"><path d=\\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\\" /></svg>") 50%/contain no-repeat;mask:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\"><path d=\\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\\" /></svg>") 50%/contain no-repeat}@media (hover:hover){.remove:hover:not(:disabled){background-color:color-mix(in oklab, transparent, currentColor 12%)}}.remove:active:not(:disabled){background-color:color-mix(in oklab, transparent, currentColor 22%)}.remove:active:not(:disabled):after{scale:var(--_press-scale)}.remove:focus-visible{outline:2px solid var(--l-focus-ring);outline-offset:-2px}.remove:disabled{cursor:not-allowed;opacity:.4}@media (forced-colors:active){.remove:after{background-color:buttontext}}@media (prefers-reduced-motion:reduce){.base,.checkbox,.remove,.remove:after{transition-duration:0s}.remove{--_press-scale:1}}}`),d=class extends Event{constructor(){super(`remove`,{bubbles:!1,composed:!1,cancelable:!0})}},f=class extends Event{constructor(e){super(`change`,{bubbles:!0,composed:!1,cancelable:!1}),this.selected=e}},p=class extends r{static{this.styles=[c,l,u]}#e;get size(){return this.#e}set size(e){this.#e=e}#t;get removable(){return this.#t}set removable(e){this.#t=e}#n;get selectable(){return this.#n}set selectable(e){this.#n=e}#r;get selected(){return this.#r}set selected(e){this.#r=e}#i;get control(){return this.#i}set control(e){this.#i=e}#a;get disabled(){return this.#a}set disabled(e){this.#a=e}constructor(){super(),this._localize=new o(this),this.#e=`md`,this.#t=!1,this.#n=!1,this.#r=!1,this.#i=`none`,this.#a=!1,this._requestRemove=()=>{if(this.disabled)return;let e=new d;this.dispatchEvent(e),e.defaultPrevented||this.remove()},this._onKeyDown=e=>{this.removable&&!this.disabled&&(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),this._requestRemove())},this._toggle=()=>{this.disabled||(this.selected=!this.selected,this.dispatchEvent(new f(this.selected)))},this._onHostClick=e=>{this.selectable&&!this.disabled&&e.composedPath()[0]===this&&this._toggle()},this._onCheckboxChange=e=>{this.selected=e.target.checked,this.dispatchEvent(new f(this.selected))},this.addEventListener(`click`,this._onHostClick)}willUpdate(){this.control===`checkbox`&&(this.selectable=!0)}updated(){let e=this.renderRoot.querySelector(`.checkbox`);e&&(e.checked=this.selected)}_label(){return i`
1
+ import{i as e}from"../../chunks/lit.js";import{r as t,t as n}from"../../chunks/decorate.js";import{LuxenElement as r}from"../../shared/luxen-element.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{LocalizeController as o}from"../../shared/localize.js";import{cls as s}from"../../registry.js";import c from"../../shared/styles/host.styles.js";import l from"../../shared/styles/checkbox-appearance.styles.js";var u=e(`@layer components{:host{--_height:var(--height,1.5rem);--_font-size:var(--font-size,var(--l-text-xs));--_padding-inline:var(--padding-inline,.5rem);--_gap:.25rem;--_background:var(--background-color,var(--l-color-bg-fill-neutral-subtle));--_color:var(--text-color,var(--l-color-text-neutral));--_border-strength:14%;--_border-color:var(--border-color,color-mix(in oklab, currentColor var(--_border-strength), transparent));--_border-color-hover:var(--border-color,color-mix(in oklab, currentColor calc(var(--_border-strength) + 12%), transparent));--_border-radius:var(--border-radius,var(--l-radius-full));--_remove-glyph:.75rem;vertical-align:middle;max-inline-size:100%;display:inline-flex}:host([size=sm]){--_padding-inline:var(--padding-inline,.375rem);--_gap:.125rem}:host([size=lg]){--_height:var(--height,1.75rem);--_font-size:var(--font-size,var(--l-text-sm));--_padding-inline:var(--padding-inline,.625rem);--_remove-glyph:.875rem}:host([disabled]) .base{cursor:not-allowed}.base{align-items:center;gap:var(--_gap);min-block-size:var(--_height);padding-inline:var(--_padding-inline);border:1px solid var(--_border-color);border-radius:var(--_border-radius);background-color:var(--_background);color:var(--_color);font-family:var(--l-font-neo-grotesque);font-size:var(--_font-size);font-weight:var(--l-font-weight-medium);min-inline-size:0;line-height:1;transition:background-color .12s,border-color .12s;display:inline-flex}:host([removable]) .base{min-block-size:max(1.5rem, var(--_height))}@media (hover:hover){:host([selectable]:hover:not([disabled])) .base{background-color:color-mix(in oklab, var(--_background), currentColor 7%);border-color:var(--_border-color-hover)}}.content{text-overflow:ellipsis;white-space:nowrap;align-items:center;min-inline-size:0;display:inline-flex;overflow:clip visible}::slotted([slot=prefix]){flex:none;display:inline-flex}::slotted([slot=suffix]){font-weight:var(--l-font-weight-normal);font-variant-numeric:tabular-nums;flex:none}:host([selectable]){--_height:var(--height,1.75rem);--_accent:var(--l-form-control-activated-color);--_selected-color:var(--selected-text-color,var(--lightningcss-light,color-mix(in oklab, var(--_accent), black 14%))var(--lightningcss-dark,color-mix(in oklab, var(--_accent), white 45%)));--_selected-background:var(--selected-background-color,color-mix(in oklab, var(--_selected-color) 10%, var(--l-color-surface)));--_selected-border-color:var(--selected-border-color,color-mix(in oklab, var(--_selected-color) 45%, transparent))}:host([selectable][size=lg]){--_height:var(--height,2rem)}:host([selectable][selected]){--_background:var(--_selected-background);--_color:var(--_selected-color);--_border-color:var(--_selected-border-color);--_border-color-hover:var(--selected-border-color,color-mix(in oklab, var(--_selected-color) 57%, transparent))}:host([selectable]) .base{cursor:pointer;-webkit-user-select:none;user-select:none}:host([selectable][disabled]) .base{cursor:not-allowed}.toggle{align-self:stretch;align-items:center;gap:var(--_gap);min-inline-size:0;margin-inline:calc(var(--_padding-inline) * -1);padding-inline:var(--_padding-inline);color:inherit;font:inherit;text-align:start;cursor:inherit;background:0 0;border:0;flex:auto;display:inline-flex}:host([removable]) .toggle{margin-inline-end:0;padding-inline-end:0}:host([selectable]) .toggle:focus-visible,:host([selectable]) .checkbox:focus-visible{outline:none}.base:has(:is(.toggle,.checkbox):focus-visible){outline:var(--l-focus-ring-width) solid var(--l-focus-ring);outline-offset:2px}.checkbox{--accent:var(--selected-text-color,var(--l-form-control-activated-color));--_halo:var(--l-form-control-border-color-hover);font:inherit;flex:none;transition-property:background-color,border-color,box-shadow}.checkbox:checked,.checkbox:indeterminate{--_halo:var(--accent)}@media (hover:hover){:host([selectable]:not([disabled])) .base:hover .checkbox:not(:disabled){box-shadow:0 0 0 calc(var(--size) * var(--l-form-control-toggle-halo-ratio)) color-mix(in oklab, var(--_halo), transparent 84%)}}@media (forced-colors:active){:host([selectable][selected]) .base{border-color:highlight}}.remove{inline-size:max(1.5rem, var(--_height));margin-block:-1px;margin-inline:calc(var(--_padding-inline) - var(--_gap)) calc(var(--_padding-inline) * -1 - 1px);border:1px solid #0000;border-inline-start-color:var(--_border-color);color:inherit;cursor:pointer;--_press-scale:.86;background-color:#0000;background-clip:padding-box;border-start-end-radius:var(--_border-radius);border-end-end-radius:var(--_border-radius);flex:none;align-self:stretch;place-items:center;padding:0;transition:background-color .12s;display:grid}.remove:after{content:"";inline-size:var(--_remove-glyph);block-size:var(--_remove-glyph);background-color:currentColor;transition:scale .12s;-webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\"><path d=\\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\\" /></svg>") 50%/contain no-repeat;mask:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\"><path d=\\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\\" /></svg>") 50%/contain no-repeat}@media (hover:hover){.remove:hover:not(:disabled){background-color:color-mix(in oklab, transparent, currentColor 12%)}}.remove:active:not(:disabled){background-color:color-mix(in oklab, transparent, currentColor 22%)}.remove:active:not(:disabled):after{scale:var(--_press-scale)}.remove:focus-visible{outline:var(--l-focus-ring-width) solid var(--l-focus-ring);outline-offset:calc(var(--l-focus-ring-width) * -1)}.remove:disabled{cursor:not-allowed;opacity:.4}@media (forced-colors:active){.remove:after{background-color:buttontext}}@media (prefers-reduced-motion:reduce){.base,.checkbox,.remove,.remove:after{transition-duration:0s}.remove{--_press-scale:1}}}`),d=class extends Event{constructor(){super(`remove`,{bubbles:!1,composed:!1,cancelable:!0})}},f=class extends Event{constructor(e){super(`change`,{bubbles:!0,composed:!1,cancelable:!1}),this.selected=e}},p=class extends r{static{this.styles=[c,l,u]}#e;get size(){return this.#e}set size(e){this.#e=e}#t;get removable(){return this.#t}set removable(e){this.#t=e}#n;get selectable(){return this.#n}set selectable(e){this.#n=e}#r;get selected(){return this.#r}set selected(e){this.#r=e}#i;get control(){return this.#i}set control(e){this.#i=e}#a;get disabled(){return this.#a}set disabled(e){this.#a=e}constructor(){super(),this._localize=new o(this),this.#e=`md`,this.#t=!1,this.#n=!1,this.#r=!1,this.#i=`none`,this.#a=!1,this._requestRemove=()=>{if(this.disabled)return;let e=new d;this.dispatchEvent(e),e.defaultPrevented||this.remove()},this._onKeyDown=e=>{this.removable&&!this.disabled&&(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),this._requestRemove())},this._toggle=()=>{this.disabled||(this.selected=!this.selected,this.dispatchEvent(new f(this.selected)))},this._onHostClick=e=>{this.selectable&&!this.disabled&&e.composedPath()[0]===this&&this._toggle()},this._onCheckboxChange=e=>{this.selected=e.target.checked,this.dispatchEvent(new f(this.selected))},this.addEventListener(`click`,this._onHostClick)}willUpdate(){this.control===`checkbox`&&(this.selectable=!0)}updated(){let e=this.renderRoot.querySelector(`.checkbox`);e&&(e.checked=this.selected)}_label(){return i`
2
2
  <slot name="prefix"></slot>
3
3
  <span
4
4
  class="content"
@@ -1 +1 @@
1
- {"version":3,"file":"tag.js","names":["unsafeCSS","rawStyles","hostStyles","checkboxAppearance","nothing","_decorate","property","r","n","__decorate","b","A","host_styles_default","checkbox_appearance_styles_default","styles","TagRemoveEvent","TagChangeEvent","selected","Tag","LuxenElement","#_size_accessor_storage","value","#_removable_accessor_storage","#_selectable_accessor_storage","#_selected_accessor_storage","#_control_accessor_storage","#_disabled_accessor_storage","LocalizeController","event","box","cls"],"sources":["../../../src/html/elements/tag/tag.css?inline","../../../src/html/elements/tag/tag.ts"],"sourcesContent":["@layer components {\n :host {\n /* Size defaults (md). A removable tag is always ≥24px tall (target-size).\n The three public knobs are folded into the private vars here rather than\n at each use site, so an override also carries to what derives from them —\n the toggle's negative inline margins and the × button's spacing math. The\n trio mirrors `.l-button` (`--height` / `--padding-inline` / `--font-size`)\n so a chip can be tuned to a dense filter panel without ::part(base). */\n --_height: var(--height, 1.5rem);\n --_font-size: var(--font-size, var(--l-text-xs));\n --_padding-inline: var(--padding-inline, 0.5rem);\n --_gap: 0.25rem;\n\n /* Skin, resolved once so `[selected]` can swap all three at the source\n instead of re-declaring the properties that consume them. */\n --_background: var(--background-color, var(--l-color-bg-fill-neutral-subtle));\n --_color: var(--text-color, var(--l-color-text-neutral));\n --_border-strength: 14%;\n /* By default the line is a tint of the ink, so a chip stays coherent under\n any `--text-color` with one declaration. `--border-color` replaces that\n derivation outright rather than shifting it: a consumer with a token\n system wants *its* line token, not a 14% mix of its text color — and\n wants it to hold in every state, which is why it is the fallback in both\n of the pair below rather than a value the hover rule mixes further.\n `--_border-strength` stays private. Selecting a chip swaps the pair\n wholesale, the same way it swaps the fill and the ink. */\n --_border-color: var(\n --border-color,\n color-mix(in oklab, currentColor var(--_border-strength), transparent)\n );\n --_border-color-hover: var(\n --border-color,\n color-mix(in oklab, currentColor calc(var(--_border-strength) + 12%), transparent)\n );\n /* Resolved here rather than at `.base`, because the × segment has to round\n its outer end to the same curve. */\n --_border-radius: var(--border-radius, var(--l-radius-full));\n --_remove-glyph: 0.75rem;\n\n display: inline-flex;\n vertical-align: middle;\n max-inline-size: 100%;\n }\n\n :host([size='sm']) {\n --_padding-inline: var(--padding-inline, 0.375rem);\n --_gap: 0.125rem;\n }\n\n :host([size='lg']) {\n --_height: var(--height, 1.75rem);\n --_font-size: var(--font-size, var(--l-text-sm));\n --_padding-inline: var(--padding-inline, 0.625rem);\n --_remove-glyph: 0.875rem;\n }\n\n /* Disabled is conveyed by the greyed × button + cursor, NOT by washing out\n * the label — dimming the whole chip with opacity composites the text below\n * the WCAG AA contrast floor (axe flags it; a disabled <button> is exempt but\n * the label span is not). */\n :host([disabled]) .base {\n cursor: not-allowed;\n }\n\n /*\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🅲🅷🅸🅿\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n */\n\n .base {\n display: inline-flex;\n align-items: center;\n gap: var(--_gap);\n min-block-size: var(--_height);\n padding-inline: var(--_padding-inline);\n border: 1px solid var(--_border-color);\n border-radius: var(--_border-radius);\n background-color: var(--_background);\n color: var(--_color);\n font-family: var(--l-font-neo-grotesque);\n font-size: var(--_font-size);\n font-weight: var(--l-font-weight-medium);\n line-height: 1;\n min-inline-size: 0;\n transition:\n background-color 120ms ease,\n border-color 120ms ease;\n }\n\n /* The remove segment is exactly as tall as the chip, so the chip is where the\n target floor has to live: `--height` still tunes a removable chip, but not\n under the 24px minimum (WCAG 2.5.8). Without this the promise held only for\n the default value. */\n :host([removable]) .base {\n min-block-size: max(1.5rem, var(--_height));\n }\n\n /* Whole-chip hover — only on a chip that is *wholly* a control. A display chip\n has no target at all, and a removable one has exactly its × segment: tinting\n the label under the pointer there promises a click that does nothing, and on\n a filter bar it fights the segment for the eye. `[selectable]` also covers\n `control=\"checkbox\"`, which derives the attribute. */\n @media (hover: hover) {\n :host([selectable]:hover:not([disabled])) .base {\n background-color: color-mix(in oklab, var(--_background), currentColor 7%);\n border-color: var(--_border-color-hover);\n }\n }\n\n .content {\n display: inline-flex;\n align-items: center;\n min-inline-size: 0;\n /* `.base` sets `line-height: 1` so the chip's height comes from its own size\n tokens rather than the document's leading. That makes the line box exactly\n one em tall, and a plain `overflow: hidden` then shears every descender\n (g, j, p, q, y) at all three sizes — measured 1px short.\n\n Fixed by clipping the inline axis only — the one the ellipsis needs — so\n nothing is ever cut vertically and the box keeps its exact geometry.\n Growing the line box instead (`line-height: normal`) moves the text half a\n pixel against the × and the prefix icon, since the font's ascent and\n descent are not symmetrical; widening the clip with\n `overflow-clip-margin` leaves Safari shearing the text (WebKit has no\n such property). `clip` — unlike `hidden` — lets the block axis stay\n `visible`. */\n overflow-x: clip;\n overflow-y: visible;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n ::slotted([slot='prefix']) {\n display: inline-flex;\n flex: none;\n }\n\n /* A count or trailing glyph. It sits in its own slot so `.base`'s gap gives it\n a gutter by construction — the label is a bare text node and can never be\n targeted from the outside. Lighter weight than the medium label, and\n tabular so a column of counts stays aligned. */\n ::slotted([slot='suffix']) {\n flex: none;\n font-weight: var(--l-font-weight-normal);\n font-variant-numeric: tabular-nums;\n }\n\n /*\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🆂🅴🅻🅴🅲🆃🅰🅱🅻🅴 (filter chip — toggle button, or a checkbox riding inside)\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n */\n\n :host([selectable]) {\n /* Taller than a display chip at the same `size`: a chip you click is a\n target (WCAG 2.5.8), and this is the dense step between `sm` and `lg` —\n more room, same 12px label, where `lg` would jump the label to body size.\n `--height` / `--font-size` tune it from there. */\n --_height: var(--height, 1.75rem);\n\n /* The selection accent is the same one the library's checkbox, radio and\n switch use, so a chip with a checkbox inside reads as a single control. */\n --_accent: var(--l-form-control-activated-color);\n /* The label is 12px, so it owes 4.5:1 over its own tint — and the raw accent\n misses it on the light one (4.35:1 measured). Darken it there, lighten it\n on the dark tint, and both modes clear 6:1. `color-mix()` resolves\n reliably inside `light-dark()` — `oklch(from …)` does not. */\n --_selected-color: var(\n --selected-text-color,\n light-dark(\n color-mix(in oklab, var(--_accent), black 14%),\n color-mix(in oklab, var(--_accent), white 45%)\n )\n );\n /* Derived from the text color, so overriding `--selected-text-color` alone\n repaints the whole chip coherently. Kept at 10%: a consumer accent skips\n the mode correction above, so the tint has to stay pale enough for a\n semantic token (`--l-color-text-success` and friends) to clear 4.5:1 on\n it unaided. The border carries the rest of the emphasis. */\n --_selected-background: var(\n --selected-background-color,\n color-mix(in oklab, var(--_selected-color) 10%, var(--l-color-surface))\n );\n /* The third member of the trio, beside `--selected-text-color` and\n `--selected-background-color`. Selection already replaces the fill and the ink\n outright, so the line has to be replaceable the same way — without this,\n a chip that sets `--border-color` keeps that exact line when picked and\n the emphasis step that says \"selected\" never happens. 45% by default, the\n strength the derived line has always used here. */\n --_selected-border-color: var(\n --selected-border-color,\n color-mix(in oklab, var(--_selected-color) 45%, transparent)\n );\n }\n\n :host([selectable][size='lg']) {\n --_height: var(--height, 2rem);\n }\n\n :host([selectable][selected]) {\n --_background: var(--_selected-background);\n --_color: var(--_selected-color);\n --_border-color: var(--_selected-border-color);\n /* Same +12 step the resting line takes on hover, and pinned in the same way\n when the consumer supplies the value. */\n --_border-color-hover: var(\n --selected-border-color,\n color-mix(in oklab, var(--_selected-color) 57%, transparent)\n );\n }\n\n :host([selectable]) .base {\n cursor: pointer;\n /* A chip is tapped, not read: never leave a text selection behind a\n double-click on a filter. */\n user-select: none;\n }\n\n :host([selectable][disabled]) .base {\n cursor: not-allowed;\n }\n\n /* The chip *is* the button. Negative inline margins let it cover `.base`'s\n padding so the whole pill is the target, while `.base` keeps owning the\n border, background, and the × button's spacing math. */\n .toggle {\n flex: 1 1 auto;\n display: inline-flex;\n align-items: center;\n align-self: stretch;\n gap: var(--_gap);\n min-inline-size: 0;\n margin-inline: calc(var(--_padding-inline) * -1);\n padding-inline: var(--_padding-inline);\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: inherit;\n }\n\n /* Stop before the × instead of running under it. */\n :host([removable]) .toggle {\n margin-inline-end: 0;\n padding-inline-end: 0;\n }\n\n /* One ring for the whole chip: the inner control is a detail of how the chip\n is operated, not a second thing to focus visually — and the ring drawn\n below fully encloses the box, so the indicator only grows (WCAG 2.4.7 /\n 2.4.13).\n\n Qualified by `:host(…)` on purpose. The shared appearance nests\n `&:focus-visible` under a selector list, so it lands as\n `:is(.l-checkbox, … input[type='checkbox']:not(…)):focus-visible` — 0,3,1,\n which outranks a bare `.checkbox:focus-visible` (0,2,0) and paints a second\n ring around the box. `:host([selectable])` brings this to 0,4,0. */\n :host([selectable]) .toggle:focus-visible,\n :host([selectable]) .checkbox:focus-visible {\n outline: none;\n }\n\n .base:has(:is(.toggle, .checkbox):focus-visible) {\n outline: 2px solid var(--l-focus-ring);\n outline-offset: 2px;\n }\n\n /* The skin comes from the shared `.l-checkbox` appearance, applied through\n `cls('checkbox')` rather than a static class literal: `dist` ships that CSS\n as a real file, so a consumer's PostCSS rewrites its selector under a\n renamed `cssPrefix` — a baked `l-checkbox` in the template would stop\n matching it. This rule only carries what is specific to a chip.\n\n The shared appearance sizes the box in `em`, and a UA gives `<input>` its\n own font — inheriting the chip's makes the box track the `size` step. The\n accent follows the selected color, so a themed chip keeps its checkbox in\n the same hue. */\n .checkbox {\n --accent: var(--selected-text-color, var(--l-form-control-activated-color));\n /* Hover halo — same ratio and same token flip as the light-DOM\n `.l-checkbox`, which keeps this rule out of the shared partial (see\n `css/elements/checkbox.css`). Repeated here rather than moved into the\n partial: `l-tree-item` shares that file and never opted into a glow. */\n --_halo: var(--l-form-control-border-color-hover);\n\n flex: none;\n font: inherit;\n transition-property: background-color, border-color, box-shadow;\n }\n\n .checkbox:checked,\n .checkbox:indeterminate {\n --_halo: var(--accent);\n }\n\n /* Driven by the chip, not by the box: the chip is the label and the whole\n click target, so a halo lighting up only over 15px of a 28px pill would\n read as a glitch. */\n @media (hover: hover) {\n :host([selectable]:not([disabled])) .base:hover .checkbox:not(:disabled) {\n box-shadow: 0 0 0 calc(var(--size) * var(--l-form-control-toggle-halo-ratio))\n color-mix(in oklab, var(--_halo), transparent 84%);\n }\n }\n\n /* Forced colors drop the tint (backgrounds are forced to Canvas), so pin the\n border to the system highlight — otherwise selection becomes invisible. */\n @media (forced-colors: active) {\n :host([selectable][selected]) .base {\n border-color: Highlight;\n }\n }\n\n /*\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🆁🅴🅼🅾🆅🅴 (≥24px target-size, mdi:close mask — mirrors l-close)\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n */\n\n .remove {\n flex: none;\n display: grid;\n place-items: center;\n /* Full height, and split off by a rule: the affordance is drawn *at rest*\n rather than conjured on hover. Keyboard and touch users never get a hover\n state, and a filter bar of chips whose delete zone only appears under the\n pointer is a row of faint marks until you go hunting. */\n align-self: stretch;\n /* Square, and never under the 24px hit target (WCAG 2.5.8) however a\n consumer tunes `--height`. */\n inline-size: max(1.5rem, var(--_height));\n /* The segment spans `.base`'s *border* box, not its content box: the −1px\n block margins cancel the border on each side (a stretched flex item is\n sized by the line minus its own margins), which both lands the target on\n a full 24px — 22px otherwise, one short — and runs the rule edge to edge\n so it meets the chip's own border instead of stopping just inside it. */\n margin-block: -1px;\n /* End: flush to the chip's inner edge. Start: pushed off the label so it\n gets the same air on both sides. `.base`'s `gap` spaces *slotted items*\n (icon ↔ label) and is deliberately tighter than the chip's padding, so\n letting it also front the rule left the label with 8px on its left and\n 4px on its right — visibly crammed against the divider. This tops the gap\n back up to a full `--_padding-inline`, at every size. */\n margin-inline: calc(var(--_padding-inline) - var(--_gap))\n calc(var(--_padding-inline) * -1 - 1px);\n padding: 0;\n /* Transparent on three sides, so `background-clip` below keeps the hover\n fill off the 1px the chip's own border occupies. */\n border: 1px solid transparent;\n border-inline-start-color: var(--_border-color);\n /* The chip's own curve — the padding box rounds to one pixel less on its\n own, so the fill stops on the arc rather than squaring off the pill. */\n border-start-end-radius: var(--_border-radius);\n border-end-end-radius: var(--_border-radius);\n background-color: transparent;\n background-clip: padding-box;\n color: inherit;\n cursor: pointer;\n transition: background-color 120ms ease;\n /* The press dip goes through a variable so the reduced-motion block can\n cancel it by re-declaring *this* one line. Pairing the two `:active`\n selectors instead is a trap: the override only wins on source order while\n the specificities tie, and adding the `:not(:disabled)` guard below was\n enough to silently break it. */\n --_press-scale: 0.86;\n\n &::after {\n content: '';\n inline-size: var(--_remove-glyph);\n block-size: var(--_remove-glyph);\n background-color: currentColor;\n transition: scale 120ms ease;\n /* https://pictogrammers.com/library/mdi/icon/close */\n mask: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\" /></svg>')\n center / contain no-repeat;\n }\n\n /* The whole segment fills. The chip already tints under the pointer (7%),\n so this has to read as the stronger of the two — it is what will actually\n be clicked. */\n @media (hover: hover) {\n &:hover:not(:disabled) {\n background-color: color-mix(in oklab, transparent, currentColor 12%);\n }\n }\n\n &:active:not(:disabled) {\n background-color: color-mix(in oklab, transparent, currentColor 22%);\n }\n\n /* The glyph dips, not the segment: scaling the box would shrink the rule\n and pull it away from the chip's border. */\n &:active:not(:disabled)::after {\n scale: var(--_press-scale);\n }\n\n /* Inset, unlike the library's usual +2px: the segment is flush with the\n chip's border on three sides, so an outset ring would sit half outside\n the chip and clip against its neighbour in a wrapped filter bar. */\n &:focus-visible {\n outline: 2px solid var(--l-focus-ring);\n outline-offset: -2px;\n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.4;\n }\n\n /* `background-color` is forced to Canvas in high contrast, which would erase\n a masked glyph entirely — repaint it in the system button color. */\n @media (forced-colors: active) {\n &::after {\n background-color: ButtonText;\n }\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .base,\n .checkbox,\n .remove,\n .remove::after {\n transition-duration: 0ms;\n }\n .remove {\n --_press-scale: 1;\n }\n }\n}\n","import { html, nothing, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { LuxenElement } from '../../shared/luxen-element.js';\nimport { LocalizeController } from '../../shared/localize.js';\nimport { cls } from '../../registry.js';\nimport hostStyles from '../../shared/styles/host.styles.js';\nimport checkboxAppearance from '../../shared/styles/checkbox-appearance.styles.js';\nimport rawStyles from './tag.css?inline';\n\nconst styles = unsafeCSS(rawStyles);\n\nexport type TagSize = 'sm' | 'md' | 'lg';\nexport type TagControl = 'none' | 'checkbox';\n\n/**\n * Fired when the user asks to remove the tag — clicking the × button, or\n * pressing Backspace/Delete while it is focused. Cancelable: call\n * `preventDefault()` to keep the tag (the controlling host then manages the\n * list itself); otherwise the tag removes itself from the DOM. Does not bubble.\n */\nexport class TagRemoveEvent extends Event {\n constructor() {\n super('remove', { bubbles: false, composed: false, cancelable: true });\n }\n}\n\n/** Fired when a `selectable` tag is toggled. Bubbles; not composed. */\nexport class TagChangeEvent extends Event {\n readonly selected: boolean;\n constructor(selected: boolean) {\n super('change', { bubbles: true, composed: false, cancelable: false });\n this.selected = selected;\n }\n}\n\ninterface TagEventMap {\n change: TagChangeEvent;\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n remove: TagRemoveEvent;\n }\n}\n\n/**\n * A compact chip for tokens, filters, and multi-select values. Shadow DOM so its\n * styles are self-contained and it renders correctly **anywhere**, including\n * inside another element's shadow root (e.g. the `<l-select>` multi-select\n * trigger).\n *\n * Add `selectable` to turn the chip into a filter control: the tag itself\n * becomes a toggle button (`aria-pressed`), and re-activating a selected tag\n * deselects it — the affordance a radio group cannot offer, so a facet always\n * has a way back to \"all\". Add `control=\"checkbox\"` for a multi-select axis and\n * the library's own checkbox rides inside, with the chip as its label.\n *\n * @summary A compact, optionally removable or selectable chip.\n *\n * @example\n * ```html\n * <l-tag removable>Design</l-tag>\n * <l-tag selectable selected>A3</l-tag>\n * <l-tag selectable control=\"checkbox\">Color <span slot=\"suffix\">79</span></l-tag>\n * ```\n *\n * @event remove - Fired when the user removes the tag (× click or Backspace/Delete). Cancelable; if not prevented the tag removes itself. Not composed, does not bubble.\n * @event change - Fired when a `selectable` tag is toggled. Not cancelable — like the platform's own `change`, and like `l-segmented-control`. Bubbles. Properties: `selected: boolean`. The chip is uncontrolled: it applies the new state before dispatching, so a host that vetoes a toggle (a \"max 3 filters\" rule, an async guard) sets `selected` back in the listener — the revert lands in the same render and is never painted.\n *\n * @slot - The tag label.\n * @slot prefix - Leading content, e.g. an `<l-icon>` or `<l-avatar>`.\n * @slot suffix - Trailing content, e.g. a result count. Gets the chip's own gutter, so no margin is needed.\n *\n * @csspart base - The chip container.\n * @csspart content - The label wrapper.\n * @csspart toggle - The toggle button rendered by `selectable` (not with `control=\"checkbox\"`).\n * @csspart checkbox - The native checkbox rendered by `control=\"checkbox\"`.\n * @csspart remove - The remove button — a full-height segment at the end of the chip.\n *\n * @cssproperty [--text-color] - Label color.\n * @cssproperty [--background-color] - Chip fill.\n * @cssproperty [--border-color] - Chip border, and the rule that splits off the remove button. Defaults to a tint of `--text-color`; setting it pins the line in every state, so a token-based theme keeps its own value on hover.\n * @cssproperty [--selected-text-color] - Label, border, and checkbox accent when selected. Defaults to the library's form-control accent, lightened in dark mode.\n * @cssproperty [--selected-background-color] - Chip fill when selected. Defaults to a tint of `--selected-text-color`.\n * @cssproperty [--selected-border-color] - Chip border when selected. Defaults to a 45% tint of `--selected-text-color`. Selection replaces the line the same way it replaces the fill and the ink, so a chip themed with `--border-color` still gets its emphasis step; set this to theme that step too.\n * @cssproperty [--height] - Chip height. Defaults to the `size` step (a selectable chip is taller, to keep a comfortable target).\n * @cssproperty [--font-size] - Label size. Defaults to the `size` step — 12px, or 14px at `size=\"lg\"`. Set it with `--height` to land between the two steps in a dense filter panel.\n * @cssproperty [--padding-inline] - Horizontal padding. Defaults to the `size` step.\n * @cssproperty [--border-radius] - Corner radius. Defaults to a full pill.\n *\n * @customElement l-tag\n */\n// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- typed addEventListener overloads merged below; no uninitialized properties.\nexport class Tag extends LuxenElement {\n static override styles = [hostStyles, checkboxAppearance, styles];\n\n private _localize = new LocalizeController(this);\n\n /** Tag size: `sm`, `md` (default), or `lg`. */\n @property({ reflect: true })\n accessor size: TagSize = 'md';\n\n /** Show a remove button (and enable Backspace/Delete removal). */\n @property({ type: Boolean, reflect: true })\n accessor removable = false;\n\n /** Make the tag a filter control the user can toggle on and off. */\n @property({ type: Boolean, reflect: true })\n accessor selectable = false;\n\n /** Whether the tag is selected. Reflected, so `[selected]` is styleable. */\n @property({ type: Boolean, reflect: true })\n accessor selected = false;\n\n /**\n * What drives the selection: `none` (default) makes the chip itself a toggle\n * button; `checkbox` renders a checkbox inside and makes the chip its label —\n * the right choice for a multi-select facet. Implies `selectable`.\n */\n @property({ reflect: true })\n accessor control: TagControl = 'none';\n\n /** Disable the tag — dims it and blocks selection and removal. */\n @property({ type: Boolean, reflect: true })\n accessor disabled = false;\n\n constructor() {\n super();\n // The chip is operated from inside the shadow root, which a click\n // dispatched on the host never reaches — see `_onHostClick`.\n this.addEventListener('click', this._onHostClick);\n }\n\n override willUpdate() {\n // A checkbox is only ever rendered on a selectable chip, so the attribute\n // (which every selectable style rule keys off) is derived rather than\n // duplicated in every selector — and in the consumer's markup.\n if (this.control === 'checkbox') this.selectable = true;\n }\n\n override updated() {\n // Re-assert the box, don't rely on the `.checked` binding. Lit dirty-checks\n // a property part against the value it last wrote, and a click has the user\n // agent flip `checked` behind its back — so when a controlling host vetoes\n // the toggle by setting `selected` back to what it already was, Lit sees no\n // change, skips the write, and leaves a checked box on an unselected chip\n // (announced \"checked\" too). Cheap: the query is null on every other path.\n const box = this.renderRoot.querySelector<HTMLInputElement>('.checkbox');\n if (box) box.checked = this.selected;\n }\n\n private _requestRemove = () => {\n if (this.disabled) return;\n const event = new TagRemoveEvent();\n this.dispatchEvent(event);\n if (!event.defaultPrevented) this.remove();\n };\n\n private _onKeyDown = (e: KeyboardEvent) => {\n if (!this.removable || this.disabled) return;\n if (e.key === 'Backspace' || e.key === 'Delete') {\n e.preventDefault();\n this._requestRemove();\n }\n };\n\n private _toggle = () => {\n if (this.disabled) return;\n // Toggling, not setting: re-activating a selected tag releases it.\n this.selected = !this.selected;\n this.dispatchEvent(new TagChangeEvent(this.selected));\n };\n\n /**\n * Events do not propagate *down* into a shadow tree, so a click dispatched on\n * the host — `tag.click()`, a test runner resolving the chip by its test id,\n * a runner computing the chip's centre (`elementFromPoint()` retargets shadow\n * content back to the host) — never reaches the toggle button or the\n * checkbox, and silently does nothing. Delegate it.\n *\n * Only when the host *is* the target: a real gesture originates at the inner\n * button, at the checkbox, or at slotted content, and is already handled\n * where it lands — so this never double-toggles. `removable` stays out of it;\n * removing is the × button's own gesture.\n */\n private _onHostClick = (e: Event) => {\n if (!this.selectable || this.disabled) return;\n if (e.composedPath()[0] !== this) return;\n // Right for `control=\"checkbox\"` too: `_toggle()` flips `selected` and\n // fires `change`, and `updated()` re-asserts `box.checked` from it.\n this._toggle();\n };\n\n private _onCheckboxChange = (e: Event) => {\n this.selected = (e.target as HTMLInputElement).checked;\n this.dispatchEvent(new TagChangeEvent(this.selected));\n };\n\n private _label() {\n return html`\n <slot name=\"prefix\"></slot>\n <span\n class=\"content\"\n part=\"content\"\n >\n <slot></slot>\n </span>\n <slot name=\"suffix\"></slot>\n `;\n }\n\n private _removeButton() {\n return this.removable\n ? html`<button\n class=\"remove\"\n part=\"remove\"\n type=\"button\"\n ?disabled=${this.disabled}\n aria-label=${this._localize.term('remove')}\n @click=${this._requestRemove}\n ></button>`\n : nothing;\n }\n\n override render() {\n if (this.control === 'checkbox') {\n return html`\n <label\n class=\"base\"\n part=\"base\"\n @keydown=${this._onKeyDown}\n >\n <input\n class=\"checkbox ${cls('checkbox')}\"\n part=\"checkbox\"\n type=\"checkbox\"\n .checked=${this.selected}\n ?disabled=${this.disabled}\n @change=${this._onCheckboxChange}\n />\n ${this._label()}${this._removeButton()}\n </label>\n `;\n }\n\n if (this.selectable) {\n return html`\n <span\n class=\"base\"\n part=\"base\"\n @keydown=${this._onKeyDown}\n >\n <button\n class=\"toggle\"\n part=\"toggle\"\n type=\"button\"\n aria-pressed=${this.selected ? 'true' : 'false'}\n ?disabled=${this.disabled}\n @click=${this._toggle}\n >\n ${this._label()}\n </button>\n ${this._removeButton()}\n </span>\n `;\n }\n\n return html`\n <span\n class=\"base\"\n part=\"base\"\n @keydown=${this._onKeyDown}\n >\n ${this._label()}${this._removeButton()}\n </span>\n `;\n }\n}\n\n// Type `addEventListener('change', …)` so listeners receive a `TagChangeEvent`\n// (with `.selected`) instead of a bare `Event`. `change` collides with lib.dom's\n// `GlobalEventHandlersEventMap`, so it can't be augmented globally — the\n// overloads are declaration-merged onto this element's interface instead. The\n// interface MUST come after the class (the CEM analyzer dedups on the first\n// declaration of the name). See `tabs.ts` for the fully-annotated reference.\nexport interface Tag {\n addEventListener<K extends keyof TagEventMap>(\n type: K,\n listener: (this: Tag, ev: TagEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n removeEventListener<K extends keyof TagEventMap>(\n type: K,\n listener: (this: Tag, ev: TagEventMap[K]) => void,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n"],"mappings":"A,saCSA,IAAMc,EAASd,EAAUC,6xLAAS,EAWrBc,EAAb,cAAoC,KAAM,CACxC,aAAc,CACZ,MAAM,SAAU,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAK,CAAC,CACvE,CACF,EAGaC,EAAb,cAAoC,KAAM,CAExC,YAAY,EAAmB,CAC7B,MAAM,SAAU,CAAE,QAAS,GAAM,SAAU,GAAO,WAAY,EAAM,CAAC,EACrE,KAAK,SAAWC,CAClB,CACF,EA4DaC,EAAb,cAAyBC,CAAa,C,OACX,KAAA,OAAA,CAACjB,EAAYC,EAAoBW,CAAM,C,IAMvD,IAAA,MAAA,C,wCAIA,IAAA,WAAA,C,6CAIA,IAAA,YAAA,C,8C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zB,CACN,CAEA,QAAkB,CA2ChB,OA1CI,KAAK,UAAY,WACZ,CAAI;;;;qBAII,KAAK,WAAW;;;8BAGP0B,EAAI,UAAU,EAAE;;;uBAGvB,KAAK,SAAS;wBACb,KAAK,SAAS;sBAChB,KAAK,kBAAkB;;YAEjC,KAAK,OAAO,IAAI,KAAK,cAAc,EAAE;;QAKzC,KAAK,WACA,CAAI;;;;qBAII,KAAK,WAAW;;;;;;2BAMV,KAAK,SAAW,OAAS,QAAQ;wBACpC,KAAK,SAAS;qBACjB,KAAK,QAAQ;;cAEpB,KAAK,OAAO,EAAE;;YAEhB,KAAK,cAAc,EAAE;;QAKtB,CAAI;;;;mBAII,KAAK,WAAW;;UAEzB,KAAK,OAAO,IAAI,KAAK,cAAc,EAAE;;KAG7C,CACF,EAlLGzB,EAAA,CAAAC,EAAS,CAAE,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,OAAA,IAAA,EAI1Bb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,YAAA,IAAA,EAIzCb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,aAAA,IAAA,EAIzCb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,WAAA,IAAA,EAQzCb,EAAA,CAAAC,EAAS,CAAE,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,UAAA,IAAA,EAI1Bb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,WAAA,IAAA,E"}
1
+ {"version":3,"file":"tag.js","names":["unsafeCSS","rawStyles","hostStyles","checkboxAppearance","nothing","_decorate","property","r","n","__decorate","b","A","host_styles_default","checkbox_appearance_styles_default","styles","TagRemoveEvent","TagChangeEvent","selected","Tag","LuxenElement","#_size_accessor_storage","value","#_removable_accessor_storage","#_selectable_accessor_storage","#_selected_accessor_storage","#_control_accessor_storage","#_disabled_accessor_storage","LocalizeController","event","box","cls"],"sources":["../../../src/html/elements/tag/tag.css?inline","../../../src/html/elements/tag/tag.ts"],"sourcesContent":["@layer components {\n :host {\n /* Size defaults (md). A removable tag is always ≥24px tall (target-size).\n The three public knobs are folded into the private vars here rather than\n at each use site, so an override also carries to what derives from them —\n the toggle's negative inline margins and the × button's spacing math. The\n trio mirrors `.l-button` (`--height` / `--padding-inline` / `--font-size`)\n so a chip can be tuned to a dense filter panel without ::part(base). */\n --_height: var(--height, 1.5rem);\n --_font-size: var(--font-size, var(--l-text-xs));\n --_padding-inline: var(--padding-inline, 0.5rem);\n --_gap: 0.25rem;\n\n /* Skin, resolved once so `[selected]` can swap all three at the source\n instead of re-declaring the properties that consume them. */\n --_background: var(--background-color, var(--l-color-bg-fill-neutral-subtle));\n --_color: var(--text-color, var(--l-color-text-neutral));\n --_border-strength: 14%;\n /* By default the line is a tint of the ink, so a chip stays coherent under\n any `--text-color` with one declaration. `--border-color` replaces that\n derivation outright rather than shifting it: a consumer with a token\n system wants *its* line token, not a 14% mix of its text color — and\n wants it to hold in every state, which is why it is the fallback in both\n of the pair below rather than a value the hover rule mixes further.\n `--_border-strength` stays private. Selecting a chip swaps the pair\n wholesale, the same way it swaps the fill and the ink. */\n --_border-color: var(\n --border-color,\n color-mix(in oklab, currentColor var(--_border-strength), transparent)\n );\n --_border-color-hover: var(\n --border-color,\n color-mix(in oklab, currentColor calc(var(--_border-strength) + 12%), transparent)\n );\n /* Resolved here rather than at `.base`, because the × segment has to round\n its outer end to the same curve. */\n --_border-radius: var(--border-radius, var(--l-radius-full));\n --_remove-glyph: 0.75rem;\n\n display: inline-flex;\n vertical-align: middle;\n max-inline-size: 100%;\n }\n\n :host([size='sm']) {\n --_padding-inline: var(--padding-inline, 0.375rem);\n --_gap: 0.125rem;\n }\n\n :host([size='lg']) {\n --_height: var(--height, 1.75rem);\n --_font-size: var(--font-size, var(--l-text-sm));\n --_padding-inline: var(--padding-inline, 0.625rem);\n --_remove-glyph: 0.875rem;\n }\n\n /* Disabled is conveyed by the greyed × button + cursor, NOT by washing out\n * the label — dimming the whole chip with opacity composites the text below\n * the WCAG AA contrast floor (axe flags it; a disabled <button> is exempt but\n * the label span is not). */\n :host([disabled]) .base {\n cursor: not-allowed;\n }\n\n /*\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🅲🅷🅸🅿\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n */\n\n .base {\n display: inline-flex;\n align-items: center;\n gap: var(--_gap);\n min-block-size: var(--_height);\n padding-inline: var(--_padding-inline);\n border: 1px solid var(--_border-color);\n border-radius: var(--_border-radius);\n background-color: var(--_background);\n color: var(--_color);\n font-family: var(--l-font-neo-grotesque);\n font-size: var(--_font-size);\n font-weight: var(--l-font-weight-medium);\n line-height: 1;\n min-inline-size: 0;\n transition:\n background-color 120ms ease,\n border-color 120ms ease;\n }\n\n /* The remove segment is exactly as tall as the chip, so the chip is where the\n target floor has to live: `--height` still tunes a removable chip, but not\n under the 24px minimum (WCAG 2.5.8). Without this the promise held only for\n the default value. */\n :host([removable]) .base {\n min-block-size: max(1.5rem, var(--_height));\n }\n\n /* Whole-chip hover — only on a chip that is *wholly* a control. A display chip\n has no target at all, and a removable one has exactly its × segment: tinting\n the label under the pointer there promises a click that does nothing, and on\n a filter bar it fights the segment for the eye. `[selectable]` also covers\n `control=\"checkbox\"`, which derives the attribute. */\n @media (hover: hover) {\n :host([selectable]:hover:not([disabled])) .base {\n background-color: color-mix(in oklab, var(--_background), currentColor 7%);\n border-color: var(--_border-color-hover);\n }\n }\n\n .content {\n display: inline-flex;\n align-items: center;\n min-inline-size: 0;\n /* `.base` sets `line-height: 1` so the chip's height comes from its own size\n tokens rather than the document's leading. That makes the line box exactly\n one em tall, and a plain `overflow: hidden` then shears every descender\n (g, j, p, q, y) at all three sizes — measured 1px short.\n\n Fixed by clipping the inline axis only — the one the ellipsis needs — so\n nothing is ever cut vertically and the box keeps its exact geometry.\n Growing the line box instead (`line-height: normal`) moves the text half a\n pixel against the × and the prefix icon, since the font's ascent and\n descent are not symmetrical; widening the clip with\n `overflow-clip-margin` leaves Safari shearing the text (WebKit has no\n such property). `clip` — unlike `hidden` — lets the block axis stay\n `visible`. */\n overflow-x: clip;\n overflow-y: visible;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n ::slotted([slot='prefix']) {\n display: inline-flex;\n flex: none;\n }\n\n /* A count or trailing glyph. It sits in its own slot so `.base`'s gap gives it\n a gutter by construction — the label is a bare text node and can never be\n targeted from the outside. Lighter weight than the medium label, and\n tabular so a column of counts stays aligned. */\n ::slotted([slot='suffix']) {\n flex: none;\n font-weight: var(--l-font-weight-normal);\n font-variant-numeric: tabular-nums;\n }\n\n /*\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🆂🅴🅻🅴🅲🆃🅰🅱🅻🅴 (filter chip — toggle button, or a checkbox riding inside)\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n */\n\n :host([selectable]) {\n /* Taller than a display chip at the same `size`: a chip you click is a\n target (WCAG 2.5.8), and this is the dense step between `sm` and `lg` —\n more room, same 12px label, where `lg` would jump the label to body size.\n `--height` / `--font-size` tune it from there. */\n --_height: var(--height, 1.75rem);\n\n /* The selection accent is the same one the library's checkbox, radio and\n switch use, so a chip with a checkbox inside reads as a single control. */\n --_accent: var(--l-form-control-activated-color);\n /* The label is 12px, so it owes 4.5:1 over its own tint — and the raw accent\n misses it on the light one (4.35:1 measured). Darken it there, lighten it\n on the dark tint, and both modes clear 6:1. `color-mix()` resolves\n reliably inside `light-dark()` — `oklch(from …)` does not. */\n --_selected-color: var(\n --selected-text-color,\n light-dark(\n color-mix(in oklab, var(--_accent), black 14%),\n color-mix(in oklab, var(--_accent), white 45%)\n )\n );\n /* Derived from the text color, so overriding `--selected-text-color` alone\n repaints the whole chip coherently. Kept at 10%: a consumer accent skips\n the mode correction above, so the tint has to stay pale enough for a\n semantic token (`--l-color-text-success` and friends) to clear 4.5:1 on\n it unaided. The border carries the rest of the emphasis. */\n --_selected-background: var(\n --selected-background-color,\n color-mix(in oklab, var(--_selected-color) 10%, var(--l-color-surface))\n );\n /* The third member of the trio, beside `--selected-text-color` and\n `--selected-background-color`. Selection already replaces the fill and the ink\n outright, so the line has to be replaceable the same way — without this,\n a chip that sets `--border-color` keeps that exact line when picked and\n the emphasis step that says \"selected\" never happens. 45% by default, the\n strength the derived line has always used here. */\n --_selected-border-color: var(\n --selected-border-color,\n color-mix(in oklab, var(--_selected-color) 45%, transparent)\n );\n }\n\n :host([selectable][size='lg']) {\n --_height: var(--height, 2rem);\n }\n\n :host([selectable][selected]) {\n --_background: var(--_selected-background);\n --_color: var(--_selected-color);\n --_border-color: var(--_selected-border-color);\n /* Same +12 step the resting line takes on hover, and pinned in the same way\n when the consumer supplies the value. */\n --_border-color-hover: var(\n --selected-border-color,\n color-mix(in oklab, var(--_selected-color) 57%, transparent)\n );\n }\n\n :host([selectable]) .base {\n cursor: pointer;\n /* A chip is tapped, not read: never leave a text selection behind a\n double-click on a filter. */\n user-select: none;\n }\n\n :host([selectable][disabled]) .base {\n cursor: not-allowed;\n }\n\n /* The chip *is* the button. Negative inline margins let it cover `.base`'s\n padding so the whole pill is the target, while `.base` keeps owning the\n border, background, and the × button's spacing math. */\n .toggle {\n flex: 1 1 auto;\n display: inline-flex;\n align-items: center;\n align-self: stretch;\n gap: var(--_gap);\n min-inline-size: 0;\n margin-inline: calc(var(--_padding-inline) * -1);\n padding-inline: var(--_padding-inline);\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: inherit;\n }\n\n /* Stop before the × instead of running under it. */\n :host([removable]) .toggle {\n margin-inline-end: 0;\n padding-inline-end: 0;\n }\n\n /* One ring for the whole chip: the inner control is a detail of how the chip\n is operated, not a second thing to focus visually — and the ring drawn\n below fully encloses the box, so the indicator only grows (WCAG 2.4.7 /\n 2.4.13).\n\n Qualified by `:host(…)` on purpose. The shared appearance nests\n `&:focus-visible` under a selector list, so it lands as\n `:is(.l-checkbox, … input[type='checkbox']:not(…)):focus-visible` — 0,3,1,\n which outranks a bare `.checkbox:focus-visible` (0,2,0) and paints a second\n ring around the box. `:host([selectable])` brings this to 0,4,0. */\n :host([selectable]) .toggle:focus-visible,\n :host([selectable]) .checkbox:focus-visible {\n outline: none;\n }\n\n .base:has(:is(.toggle, .checkbox):focus-visible) {\n outline: var(--l-focus-ring-width) solid var(--l-focus-ring);\n outline-offset: 2px;\n }\n\n /* The skin comes from the shared `.l-checkbox` appearance, applied through\n `cls('checkbox')` rather than a static class literal: `dist` ships that CSS\n as a real file, so a consumer's PostCSS rewrites its selector under a\n renamed `cssPrefix` — a baked `l-checkbox` in the template would stop\n matching it. This rule only carries what is specific to a chip.\n\n The shared appearance sizes the box in `em`, and a UA gives `<input>` its\n own font — inheriting the chip's makes the box track the `size` step. The\n accent follows the selected color, so a themed chip keeps its checkbox in\n the same hue. */\n .checkbox {\n --accent: var(--selected-text-color, var(--l-form-control-activated-color));\n /* Hover halo — same ratio and same token flip as the light-DOM\n `.l-checkbox`, which keeps this rule out of the shared partial (see\n `css/elements/checkbox.css`). Repeated here rather than moved into the\n partial: `l-tree-item` shares that file and never opted into a glow. */\n --_halo: var(--l-form-control-border-color-hover);\n\n flex: none;\n font: inherit;\n transition-property: background-color, border-color, box-shadow;\n }\n\n .checkbox:checked,\n .checkbox:indeterminate {\n --_halo: var(--accent);\n }\n\n /* Driven by the chip, not by the box: the chip is the label and the whole\n click target, so a halo lighting up only over 15px of a 28px pill would\n read as a glitch. */\n @media (hover: hover) {\n :host([selectable]:not([disabled])) .base:hover .checkbox:not(:disabled) {\n box-shadow: 0 0 0 calc(var(--size) * var(--l-form-control-toggle-halo-ratio))\n color-mix(in oklab, var(--_halo), transparent 84%);\n }\n }\n\n /* Forced colors drop the tint (backgrounds are forced to Canvas), so pin the\n border to the system highlight — otherwise selection becomes invisible. */\n @media (forced-colors: active) {\n :host([selectable][selected]) .base {\n border-color: Highlight;\n }\n }\n\n /*\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n 🆁🅴🅼🅾🆅🅴 (≥24px target-size, mdi:close mask — mirrors l-close)\n ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n */\n\n .remove {\n flex: none;\n display: grid;\n place-items: center;\n /* Full height, and split off by a rule: the affordance is drawn *at rest*\n rather than conjured on hover. Keyboard and touch users never get a hover\n state, and a filter bar of chips whose delete zone only appears under the\n pointer is a row of faint marks until you go hunting. */\n align-self: stretch;\n /* Square, and never under the 24px hit target (WCAG 2.5.8) however a\n consumer tunes `--height`. */\n inline-size: max(1.5rem, var(--_height));\n /* The segment spans `.base`'s *border* box, not its content box: the −1px\n block margins cancel the border on each side (a stretched flex item is\n sized by the line minus its own margins), which both lands the target on\n a full 24px — 22px otherwise, one short — and runs the rule edge to edge\n so it meets the chip's own border instead of stopping just inside it. */\n margin-block: -1px;\n /* End: flush to the chip's inner edge. Start: pushed off the label so it\n gets the same air on both sides. `.base`'s `gap` spaces *slotted items*\n (icon ↔ label) and is deliberately tighter than the chip's padding, so\n letting it also front the rule left the label with 8px on its left and\n 4px on its right — visibly crammed against the divider. This tops the gap\n back up to a full `--_padding-inline`, at every size. */\n margin-inline: calc(var(--_padding-inline) - var(--_gap))\n calc(var(--_padding-inline) * -1 - 1px);\n padding: 0;\n /* Transparent on three sides, so `background-clip` below keeps the hover\n fill off the 1px the chip's own border occupies. */\n border: 1px solid transparent;\n border-inline-start-color: var(--_border-color);\n /* The chip's own curve — the padding box rounds to one pixel less on its\n own, so the fill stops on the arc rather than squaring off the pill. */\n border-start-end-radius: var(--_border-radius);\n border-end-end-radius: var(--_border-radius);\n background-color: transparent;\n background-clip: padding-box;\n color: inherit;\n cursor: pointer;\n transition: background-color 120ms ease;\n /* The press dip goes through a variable so the reduced-motion block can\n cancel it by re-declaring *this* one line. Pairing the two `:active`\n selectors instead is a trap: the override only wins on source order while\n the specificities tie, and adding the `:not(:disabled)` guard below was\n enough to silently break it. */\n --_press-scale: 0.86;\n\n &::after {\n content: '';\n inline-size: var(--_remove-glyph);\n block-size: var(--_remove-glyph);\n background-color: currentColor;\n transition: scale 120ms ease;\n /* https://pictogrammers.com/library/mdi/icon/close */\n mask: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\" /></svg>')\n center / contain no-repeat;\n }\n\n /* The whole segment fills. The chip already tints under the pointer (7%),\n so this has to read as the stronger of the two — it is what will actually\n be clicked. */\n @media (hover: hover) {\n &:hover:not(:disabled) {\n background-color: color-mix(in oklab, transparent, currentColor 12%);\n }\n }\n\n &:active:not(:disabled) {\n background-color: color-mix(in oklab, transparent, currentColor 22%);\n }\n\n /* The glyph dips, not the segment: scaling the box would shrink the rule\n and pull it away from the chip's border. */\n &:active:not(:disabled)::after {\n scale: var(--_press-scale);\n }\n\n /* Inset, unlike the library's usual +2px: the segment is flush with the\n chip's border on three sides, so an outset ring would sit half outside\n the chip and clip against its neighbour in a wrapped filter bar. */\n &:focus-visible {\n outline: var(--l-focus-ring-width) solid var(--l-focus-ring);\n outline-offset: calc(var(--l-focus-ring-width) * -1);\n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.4;\n }\n\n /* `background-color` is forced to Canvas in high contrast, which would erase\n a masked glyph entirely — repaint it in the system button color. */\n @media (forced-colors: active) {\n &::after {\n background-color: ButtonText;\n }\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .base,\n .checkbox,\n .remove,\n .remove::after {\n transition-duration: 0ms;\n }\n .remove {\n --_press-scale: 1;\n }\n }\n}\n","import { html, nothing, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { LuxenElement } from '../../shared/luxen-element.js';\nimport { LocalizeController } from '../../shared/localize.js';\nimport { cls } from '../../registry.js';\nimport hostStyles from '../../shared/styles/host.styles.js';\nimport checkboxAppearance from '../../shared/styles/checkbox-appearance.styles.js';\nimport rawStyles from './tag.css?inline';\n\nconst styles = unsafeCSS(rawStyles);\n\nexport type TagSize = 'sm' | 'md' | 'lg';\nexport type TagControl = 'none' | 'checkbox';\n\n/**\n * Fired when the user asks to remove the tag — clicking the × button, or\n * pressing Backspace/Delete while it is focused. Cancelable: call\n * `preventDefault()` to keep the tag (the controlling host then manages the\n * list itself); otherwise the tag removes itself from the DOM. Does not bubble.\n */\nexport class TagRemoveEvent extends Event {\n constructor() {\n super('remove', { bubbles: false, composed: false, cancelable: true });\n }\n}\n\n/** Fired when a `selectable` tag is toggled. Bubbles; not composed. */\nexport class TagChangeEvent extends Event {\n readonly selected: boolean;\n constructor(selected: boolean) {\n super('change', { bubbles: true, composed: false, cancelable: false });\n this.selected = selected;\n }\n}\n\ninterface TagEventMap {\n change: TagChangeEvent;\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n remove: TagRemoveEvent;\n }\n}\n\n/**\n * A compact chip for tokens, filters, and multi-select values. Shadow DOM so its\n * styles are self-contained and it renders correctly **anywhere**, including\n * inside another element's shadow root (e.g. the `<l-select>` multi-select\n * trigger).\n *\n * Add `selectable` to turn the chip into a filter control: the tag itself\n * becomes a toggle button (`aria-pressed`), and re-activating a selected tag\n * deselects it — the affordance a radio group cannot offer, so a facet always\n * has a way back to \"all\". Add `control=\"checkbox\"` for a multi-select axis and\n * the library's own checkbox rides inside, with the chip as its label.\n *\n * @summary A compact, optionally removable or selectable chip.\n *\n * @example\n * ```html\n * <l-tag removable>Design</l-tag>\n * <l-tag selectable selected>A3</l-tag>\n * <l-tag selectable control=\"checkbox\">Color <span slot=\"suffix\">79</span></l-tag>\n * ```\n *\n * @event remove - Fired when the user removes the tag (× click or Backspace/Delete). Cancelable; if not prevented the tag removes itself. Not composed, does not bubble.\n * @event change - Fired when a `selectable` tag is toggled. Not cancelable — like the platform's own `change`, and like `l-segmented-control`. Bubbles. Properties: `selected: boolean`. The chip is uncontrolled: it applies the new state before dispatching, so a host that vetoes a toggle (a \"max 3 filters\" rule, an async guard) sets `selected` back in the listener — the revert lands in the same render and is never painted.\n *\n * @slot - The tag label.\n * @slot prefix - Leading content, e.g. an `<l-icon>` or `<l-avatar>`.\n * @slot suffix - Trailing content, e.g. a result count. Gets the chip's own gutter, so no margin is needed.\n *\n * @csspart base - The chip container.\n * @csspart content - The label wrapper.\n * @csspart toggle - The toggle button rendered by `selectable` (not with `control=\"checkbox\"`).\n * @csspart checkbox - The native checkbox rendered by `control=\"checkbox\"`.\n * @csspart remove - The remove button — a full-height segment at the end of the chip.\n *\n * @cssproperty [--text-color] - Label color.\n * @cssproperty [--background-color] - Chip fill.\n * @cssproperty [--border-color] - Chip border, and the rule that splits off the remove button. Defaults to a tint of `--text-color`; setting it pins the line in every state, so a token-based theme keeps its own value on hover.\n * @cssproperty [--selected-text-color] - Label, border, and checkbox accent when selected. Defaults to the library's form-control accent, lightened in dark mode.\n * @cssproperty [--selected-background-color] - Chip fill when selected. Defaults to a tint of `--selected-text-color`.\n * @cssproperty [--selected-border-color] - Chip border when selected. Defaults to a 45% tint of `--selected-text-color`. Selection replaces the line the same way it replaces the fill and the ink, so a chip themed with `--border-color` still gets its emphasis step; set this to theme that step too.\n * @cssproperty [--height] - Chip height. Defaults to the `size` step (a selectable chip is taller, to keep a comfortable target).\n * @cssproperty [--font-size] - Label size. Defaults to the `size` step — 12px, or 14px at `size=\"lg\"`. Set it with `--height` to land between the two steps in a dense filter panel.\n * @cssproperty [--padding-inline] - Horizontal padding. Defaults to the `size` step.\n * @cssproperty [--border-radius] - Corner radius. Defaults to a full pill.\n *\n * @customElement l-tag\n */\n// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- typed addEventListener overloads merged below; no uninitialized properties.\nexport class Tag extends LuxenElement {\n static override styles = [hostStyles, checkboxAppearance, styles];\n\n private _localize = new LocalizeController(this);\n\n /** Tag size: `sm`, `md` (default), or `lg`. */\n @property({ reflect: true })\n accessor size: TagSize = 'md';\n\n /** Show a remove button (and enable Backspace/Delete removal). */\n @property({ type: Boolean, reflect: true })\n accessor removable = false;\n\n /** Make the tag a filter control the user can toggle on and off. */\n @property({ type: Boolean, reflect: true })\n accessor selectable = false;\n\n /** Whether the tag is selected. Reflected, so `[selected]` is styleable. */\n @property({ type: Boolean, reflect: true })\n accessor selected = false;\n\n /**\n * What drives the selection: `none` (default) makes the chip itself a toggle\n * button; `checkbox` renders a checkbox inside and makes the chip its label —\n * the right choice for a multi-select facet. Implies `selectable`.\n */\n @property({ reflect: true })\n accessor control: TagControl = 'none';\n\n /** Disable the tag — dims it and blocks selection and removal. */\n @property({ type: Boolean, reflect: true })\n accessor disabled = false;\n\n constructor() {\n super();\n // The chip is operated from inside the shadow root, which a click\n // dispatched on the host never reaches — see `_onHostClick`.\n this.addEventListener('click', this._onHostClick);\n }\n\n override willUpdate() {\n // A checkbox is only ever rendered on a selectable chip, so the attribute\n // (which every selectable style rule keys off) is derived rather than\n // duplicated in every selector — and in the consumer's markup.\n if (this.control === 'checkbox') this.selectable = true;\n }\n\n override updated() {\n // Re-assert the box, don't rely on the `.checked` binding. Lit dirty-checks\n // a property part against the value it last wrote, and a click has the user\n // agent flip `checked` behind its back — so when a controlling host vetoes\n // the toggle by setting `selected` back to what it already was, Lit sees no\n // change, skips the write, and leaves a checked box on an unselected chip\n // (announced \"checked\" too). Cheap: the query is null on every other path.\n const box = this.renderRoot.querySelector<HTMLInputElement>('.checkbox');\n if (box) box.checked = this.selected;\n }\n\n private _requestRemove = () => {\n if (this.disabled) return;\n const event = new TagRemoveEvent();\n this.dispatchEvent(event);\n if (!event.defaultPrevented) this.remove();\n };\n\n private _onKeyDown = (e: KeyboardEvent) => {\n if (!this.removable || this.disabled) return;\n if (e.key === 'Backspace' || e.key === 'Delete') {\n e.preventDefault();\n this._requestRemove();\n }\n };\n\n private _toggle = () => {\n if (this.disabled) return;\n // Toggling, not setting: re-activating a selected tag releases it.\n this.selected = !this.selected;\n this.dispatchEvent(new TagChangeEvent(this.selected));\n };\n\n /**\n * Events do not propagate *down* into a shadow tree, so a click dispatched on\n * the host — `tag.click()`, a test runner resolving the chip by its test id,\n * a runner computing the chip's centre (`elementFromPoint()` retargets shadow\n * content back to the host) — never reaches the toggle button or the\n * checkbox, and silently does nothing. Delegate it.\n *\n * Only when the host *is* the target: a real gesture originates at the inner\n * button, at the checkbox, or at slotted content, and is already handled\n * where it lands — so this never double-toggles. `removable` stays out of it;\n * removing is the × button's own gesture.\n */\n private _onHostClick = (e: Event) => {\n if (!this.selectable || this.disabled) return;\n if (e.composedPath()[0] !== this) return;\n // Right for `control=\"checkbox\"` too: `_toggle()` flips `selected` and\n // fires `change`, and `updated()` re-asserts `box.checked` from it.\n this._toggle();\n };\n\n private _onCheckboxChange = (e: Event) => {\n this.selected = (e.target as HTMLInputElement).checked;\n this.dispatchEvent(new TagChangeEvent(this.selected));\n };\n\n private _label() {\n return html`\n <slot name=\"prefix\"></slot>\n <span\n class=\"content\"\n part=\"content\"\n >\n <slot></slot>\n </span>\n <slot name=\"suffix\"></slot>\n `;\n }\n\n private _removeButton() {\n return this.removable\n ? html`<button\n class=\"remove\"\n part=\"remove\"\n type=\"button\"\n ?disabled=${this.disabled}\n aria-label=${this._localize.term('remove')}\n @click=${this._requestRemove}\n ></button>`\n : nothing;\n }\n\n override render() {\n if (this.control === 'checkbox') {\n return html`\n <label\n class=\"base\"\n part=\"base\"\n @keydown=${this._onKeyDown}\n >\n <input\n class=\"checkbox ${cls('checkbox')}\"\n part=\"checkbox\"\n type=\"checkbox\"\n .checked=${this.selected}\n ?disabled=${this.disabled}\n @change=${this._onCheckboxChange}\n />\n ${this._label()}${this._removeButton()}\n </label>\n `;\n }\n\n if (this.selectable) {\n return html`\n <span\n class=\"base\"\n part=\"base\"\n @keydown=${this._onKeyDown}\n >\n <button\n class=\"toggle\"\n part=\"toggle\"\n type=\"button\"\n aria-pressed=${this.selected ? 'true' : 'false'}\n ?disabled=${this.disabled}\n @click=${this._toggle}\n >\n ${this._label()}\n </button>\n ${this._removeButton()}\n </span>\n `;\n }\n\n return html`\n <span\n class=\"base\"\n part=\"base\"\n @keydown=${this._onKeyDown}\n >\n ${this._label()}${this._removeButton()}\n </span>\n `;\n }\n}\n\n// Type `addEventListener('change', …)` so listeners receive a `TagChangeEvent`\n// (with `.selected`) instead of a bare `Event`. `change` collides with lib.dom's\n// `GlobalEventHandlersEventMap`, so it can't be augmented globally — the\n// overloads are declaration-merged onto this element's interface instead. The\n// interface MUST come after the class (the CEM analyzer dedups on the first\n// declaration of the name). See `tabs.ts` for the fully-annotated reference.\nexport interface Tag {\n addEventListener<K extends keyof TagEventMap>(\n type: K,\n listener: (this: Tag, ev: TagEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n removeEventListener<K extends keyof TagEventMap>(\n type: K,\n listener: (this: Tag, ev: TagEventMap[K]) => void,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n"],"mappings":"A,saCSA,IAAMc,EAASd,EAAUC,y2LAAS,EAWrBc,EAAb,cAAoC,KAAM,CACxC,aAAc,CACZ,MAAM,SAAU,CAAE,QAAS,GAAO,SAAU,GAAO,WAAY,EAAK,CAAC,CACvE,CACF,EAGaC,EAAb,cAAoC,KAAM,CAExC,YAAY,EAAmB,CAC7B,MAAM,SAAU,CAAE,QAAS,GAAM,SAAU,GAAO,WAAY,EAAM,CAAC,EACrE,KAAK,SAAWC,CAClB,CACF,EA4DaC,EAAb,cAAyBC,CAAa,C,OACX,KAAA,OAAA,CAACjB,EAAYC,EAAoBW,CAAM,C,IAMvD,IAAA,MAAA,C,wCAIA,IAAA,WAAA,C,6CAIA,IAAA,YAAA,C,8CAIA,IAAA,UAAA,C,4CAQA,IAAA,SAAA,C,2CAIA,IAAA,UAAA,C,yCAET,aAAc,CACZ,MAAM,EA/BY,KAAA,UAAA,IAAIa,EAAmB,IAAI,EAItB,KAAAP,GAAA,KAIJ,KAAAE,GAAA,GAIC,KAAAC,GAAA,GAIF,KAAAC,GAAA,GAQW,KAAAC,GAAA,OAIX,KAAAC,GAAA,GA2BW,KAAA,mBAAA,C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W;;;;;;2BAMV,KAAK,SAAW,OAAS,QAAQ;wBACpC,KAAK,SAAS;qBACjB,KAAK,QAAQ;;cAEpB,KAAK,OAAO,EAAE;;YAEhB,KAAK,cAAc,EAAE;;QAKtB,CAAI;;;;mBAII,KAAK,WAAW;;UAEzB,KAAK,OAAO,IAAI,KAAK,cAAc,EAAE;;KAG7C,CACF,EAlLGzB,EAAA,CAAAC,EAAS,CAAE,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,OAAA,IAAA,EAI1Bb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,YAAA,IAAA,EAIzCb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,aAAA,IAAA,EAIzCb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,WAAA,IAAA,EAQzCb,EAAA,CAAAC,EAAS,CAAE,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,UAAA,IAAA,EAI1Bb,EAAA,CAAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,CAAA,EAAAY,EAAA,UAAA,WAAA,IAAA,E"}
@@ -52,7 +52,6 @@ export declare class Tooltip extends LuxenElement {
52
52
  private _triggerFor;
53
53
  private get _popover();
54
54
  private get _arrowEl();
55
- private _getDuration;
56
55
  connectedCallback(): void;
57
56
  disconnectedCallback(): void;
58
57
  updated(changed: PropertyValues<this>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/html/elements/tooltip/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EA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AiB,SAIzB;IAEQ,oBAAoB,SAQ5B;IAEQ,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,QAgB7C;IAED,sFAAsF;IACtF,OAAO,CAAC,YAAY;IAOpB,IAAI,SAEH;IAED,IAAI,SAEH;IAED,MAAM,SAEL;IAED;;;;OAIG;IAKG,UAAU,kBAGf;IAED;;;;;OAKG;YACW,oBAAoB;IAqBlC,OAAO,CAAC,gBAAgB;YAIV,iBAAiB;IAgC/B,OAAO,CAAC,eAAe,CAwBrB;IAEF,OAAO,CAAC,eAAe,CAarB;IAEF,gFAAgF;IAChF,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,UAAU,CAYhB;IACF,OAAO,CAAC,WAAW,CAOjB;IACF,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,UAAU,CAKhB;IAEF,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,uBAAuB;IAItB,MAAM,oCAqBd;CACF"}
@@ -1,4 +1,4 @@
1
- import{i as e}from"../../chunks/lit.js";import{LuxenElement as t}from"../../shared/luxen-element.js";import{r as n,t as r}from"../../chunks/decorate.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{PopoverController as o}from"../../shared/controllers/popover.js";import{uniqueId as s}from"../../registry.js";import c from"../../shared/styles/host.styles.js";var l=e(`:host{--background-color:var(--l-tooltip-background-color);--border-radius:4px;--max-width:180px;--arrow-size:6px;--show-duration:.15s;--hide-duration:.15s;display:contents}[popover]{inset:unset;box-sizing:border-box;width:max-content;max-width:var(--max-width);border-radius:var(--border-radius);background:var(--background-color);--_on:calc(255 * ( 1 - sign(.2126 * (r / 255) * (r / 255) + .7152 * (g / 255) * (g / 255) + .0722 * (b / 255) * (b / 255) - .2) ) / 2);color:var(--text-color,rgb(from var(--background-color) var(--_on) var(--_on) var(--_on)));filter:drop-shadow(0 1px 2px #00000029);pointer-events:none;border:0;padding:4px 8px;font-size:.8125rem;line-height:1.4;overflow:visible}@supports (color:contrast-color(red)){[popover]{color:var(--text-color,contrast-color(var(--background-color)))}}i{width:var(--arrow-size);height:var(--arrow-size);background:var(--background-color);display:block;position:absolute;transform:rotate(45deg)}`),u=new Set,d=null,f=class extends t{constructor(...e){super(...e),this._tooltipId=s(`tooltip`),this._floating=new o(this,{getTriggerElement:()=>this._trigger,getFloatingElement:()=>this._popover,getArrowElement:()=>this._arrowEl}),this.#e=``,this.#t=`top`,this.#n=8,this.#r=0,this.#i=0,this.#a=!1,this.#o=!1,this.#s=`hover focus`,this._onPointerEnter=()=>{if(this._hasTrigger(`hover`)){this._floating.cleanupSafePolygon();for(let e of u)e===this||e._hasTrigger(`manual`)||(e._floating.cleanupSafePolygon(),e.hide());clearTimeout(this._hideTimer),this._hideTimer=void 0,this.showDelay>0&&!this.open?(clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>this.show(),this.showDelay)):this.show()}},this._onPointerLeave=e=>{clearTimeout(this._showTimer),this._showTimer=void 0,this._hasTrigger(`hover`)&&this.open&&this._floating.handlePointerLeave(e,e=>{e===`settled`?this.hide():this._scheduleHide()})},this._onFocusIn=()=>{this._hasTrigger(`focus`)&&this._trigger?.matches(`:focus-visible`)&&(clearTimeout(this._hideTimer),this._hideTimer=void 0,this.show())},this._onFocusOut=()=>{this._hasTrigger(`focus`)&&(clearTimeout(this._showTimer),this._showTimer=void 0,this.hide())},this._onClick=()=>{this._hasTrigger(`click`)&&this.toggle()},this._onKeyDown=e=>{this.open&&e.key===`Escape`&&(e.stopPropagation(),this.hide())}}static{this.styles=[c,l]}#e;get for(){return this.#e}set for(e){this.#e=e}#t;get placement(){return this.#t}set placement(e){this.#t=e}#n;get distance(){return this.#n}set distance(e){this.#n=e}#r;get showDelay(){return this.#r}set showDelay(e){this.#r=e}#i;get hideDelay(){return this.#i}set hideDelay(e){this.#i=e}#a;get open(){return this.#a}set open(e){this.#a=e}#o;get withoutArrow(){return this.#o}set withoutArrow(e){this.#o=e}#s;get trigger(){return this.#s}set trigger(e){this.#s=e}_hasTrigger(e){return this.trigger.split(` `).includes(e)}get _trigger(){return this._triggerFor(this.for)}_triggerFor(e){if(!e)return null;let t=this.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.getElementById(e):null}get _popover(){return this.shadowRoot.querySelector(`[popover]`)}get _arrowEl(){return this.withoutArrow?null:this.shadowRoot.querySelector(`i`)}_getDuration(e){let t=parseFloat(getComputedStyle(this).getPropertyValue(e));return Number.isNaN(t)?150:t}connectedCallback(){super.connectedCallback(),u.add(this),requestAnimationFrame(()=>this._addTriggerListeners())}disconnectedCallback(){super.disconnectedCallback(),u.delete(this),d===this&&(d=null),this._clearTimers(),this._removeTriggerListeners()}updated(e){e.has(`for`)&&(this._clearTimers(),this._removeTriggerListeners(e.get(`for`)),this._addTriggerListeners(),this.open&&!e.has(`open`)&&this._repositionToTrigger()),e.has(`open`)&&this._handleOpenChange()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=void 0,this._hideTimer=void 0}show(){this.open||=!0}hide(){this.open&&=!1}toggle(){this.open=!this.open}async reposition(){this.open&&await this._repositionToTrigger()}async _repositionToTrigger(){this._floating.cleanupSafePolygon();let e=this.for,t=await this._floating.reposition(this._positionOptions(),()=>this.open&&this.for===e);t!==`stale`&&(t===`no-anchor`?this.hide():this._floating.markTrigger(`aria-describedby`,this._tooltipId,null))}_positionOptions(){return{placement:this.placement,distance:this.distance}}async _handleOpenChange(){let e=this._popover;if(!e)return;let t=this._positionOptions();if(this.open){if(this._hasTrigger(`manual`)||(d&&d!==this&&d.hide(),d=this),e.showPopover(),await this._floating.updatePosition(t),!this.open)return;await this._floating.animateShow(e,this._getDuration(`--show-duration`)),this._floating.startPositioning(t),this._floating.markTrigger(`aria-describedby`,this._tooltipId,null)}else d===this&&(d=null),this._floating.stopPositioning(),this._floating.cleanupSafePolygon(),this._floating.releaseTrigger(null),await this._floating.animateHide(e,this._getDuration(`--hide-duration`)),e.matches(`:popover-open`)&&e.hidePopover()}_scheduleHide(){this.hideDelay>0?(clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay)):this.hide()}_addTriggerListeners(){this._floating.addTriggerListeners({onPointerEnter:this._onPointerEnter,onPointerLeave:this._onPointerLeave,onFocusIn:this._onFocusIn,onFocusOut:this._onFocusOut,onClick:this._onClick,onKeyDown:this._onKeyDown})}_removeTriggerListeners(e){this._floating.removeTriggerListeners(e?this._triggerFor(e):void 0)}render(){return i`
1
+ import{i as e}from"../../chunks/lit.js";import{LuxenElement as t}from"../../shared/luxen-element.js";import{r as n,t as r}from"../../chunks/decorate.js";import{a as i,t as a}from"../../chunks/lit-html.js";import{PopoverController as o}from"../../shared/controllers/popover.js";import{uniqueId as s}from"../../registry.js";import c from"../../shared/styles/host.styles.js";var l=e(`:host{--background-color:var(--l-tooltip-background-color);--border-radius:4px;--max-width:180px;--arrow-size:6px;--show-duration:.15s;--hide-duration:.15s;display:contents}[popover]{inset:unset;box-sizing:border-box;width:max-content;max-width:var(--max-width);border-radius:var(--border-radius);background:var(--background-color);--_on:calc(255 * ( 1 - sign(.2126 * (r / 255) * (r / 255) + .7152 * (g / 255) * (g / 255) + .0722 * (b / 255) * (b / 255) - .2) ) / 2);color:var(--text-color,rgb(from var(--background-color) var(--_on) var(--_on) var(--_on)));filter:drop-shadow(0 1px 2px #00000029);pointer-events:none;border:0;padding:4px 8px;font-size:.8125rem;line-height:1.4;overflow:visible}@supports (color:contrast-color(red)){[popover]{color:var(--text-color,contrast-color(var(--background-color)))}}i{width:var(--arrow-size);height:var(--arrow-size);background:var(--background-color);display:block;position:absolute;transform:rotate(45deg)}`),u=new Set,d=null,f=class extends t{constructor(...e){super(...e),this._tooltipId=s(`tooltip`),this._floating=new o(this,{getTriggerElement:()=>this._trigger,getFloatingElement:()=>this._popover,getArrowElement:()=>this._arrowEl}),this.#e=``,this.#t=`top`,this.#n=8,this.#r=0,this.#i=0,this.#a=!1,this.#o=!1,this.#s=`hover focus`,this._onPointerEnter=()=>{if(this._hasTrigger(`hover`)){this._floating.cleanupSafePolygon();for(let e of u)e===this||e._hasTrigger(`manual`)||(e._floating.cleanupSafePolygon(),e.hide());clearTimeout(this._hideTimer),this._hideTimer=void 0,this.showDelay>0&&!this.open?(clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>this.show(),this.showDelay)):this.show()}},this._onPointerLeave=e=>{clearTimeout(this._showTimer),this._showTimer=void 0,this._hasTrigger(`hover`)&&this.open&&this._floating.handlePointerLeave(e,e=>{e===`settled`?this.hide():this._scheduleHide()})},this._onFocusIn=()=>{this._hasTrigger(`focus`)&&this._trigger?.matches(`:focus-visible`)&&(clearTimeout(this._hideTimer),this._hideTimer=void 0,this.show())},this._onFocusOut=()=>{this._hasTrigger(`focus`)&&(clearTimeout(this._showTimer),this._showTimer=void 0,this.hide())},this._onClick=()=>{this._hasTrigger(`click`)&&this.toggle()},this._onKeyDown=e=>{this.open&&e.key===`Escape`&&(e.stopPropagation(),this.hide())}}static{this.styles=[c,l]}#e;get for(){return this.#e}set for(e){this.#e=e}#t;get placement(){return this.#t}set placement(e){this.#t=e}#n;get distance(){return this.#n}set distance(e){this.#n=e}#r;get showDelay(){return this.#r}set showDelay(e){this.#r=e}#i;get hideDelay(){return this.#i}set hideDelay(e){this.#i=e}#a;get open(){return this.#a}set open(e){this.#a=e}#o;get withoutArrow(){return this.#o}set withoutArrow(e){this.#o=e}#s;get trigger(){return this.#s}set trigger(e){this.#s=e}_hasTrigger(e){return this.trigger.split(` `).includes(e)}get _trigger(){return this._triggerFor(this.for)}_triggerFor(e){if(!e)return null;let t=this.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.getElementById(e):null}get _popover(){return this.shadowRoot.querySelector(`[popover]`)}get _arrowEl(){return this.withoutArrow?null:this.shadowRoot.querySelector(`i`)}connectedCallback(){super.connectedCallback(),u.add(this),requestAnimationFrame(()=>this._addTriggerListeners())}disconnectedCallback(){super.disconnectedCallback(),u.delete(this),d===this&&(d=null),this._clearTimers(),this._removeTriggerListeners()}updated(e){e.has(`for`)&&(this._clearTimers(),this._removeTriggerListeners(e.get(`for`)),this._addTriggerListeners(),this.open&&!e.has(`open`)&&this._repositionToTrigger()),e.has(`open`)&&this._handleOpenChange()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=void 0,this._hideTimer=void 0}show(){this.open||=!0}hide(){this.open&&=!1}toggle(){this.open=!this.open}async reposition(){this.open&&await this._repositionToTrigger()}async _repositionToTrigger(){this._floating.cleanupSafePolygon();let e=this.for,t=await this._floating.reposition(this._positionOptions(),()=>this.open&&this.for===e);t!==`stale`&&(t===`no-anchor`?this.hide():this._floating.markTrigger(`aria-describedby`,this._tooltipId,null))}_positionOptions(){return{placement:this.placement,distance:this.distance}}async _handleOpenChange(){let e=this._popover;if(!e)return;let t=this._positionOptions();if(this.open){if(this._hasTrigger(`manual`)||(d&&d!==this&&d.hide(),d=this),e.showPopover(),await this._floating.updatePosition(t),!this.open)return;await this._floating.animateShow(e),this._floating.startPositioning(t),this._floating.markTrigger(`aria-describedby`,this._tooltipId,null)}else d===this&&(d=null),this._floating.stopPositioning(),this._floating.cleanupSafePolygon(),this._floating.releaseTrigger(null),await this._floating.animateHide(e),e.matches(`:popover-open`)&&e.hidePopover()}_scheduleHide(){this.hideDelay>0?(clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay)):this.hide()}_addTriggerListeners(){this._floating.addTriggerListeners({onPointerEnter:this._onPointerEnter,onPointerLeave:this._onPointerLeave,onFocusIn:this._onFocusIn,onFocusOut:this._onFocusOut,onClick:this._onClick,onKeyDown:this._onKeyDown})}_removeTriggerListeners(e){this._floating.removeTriggerListeners(e?this._triggerFor(e):void 0)}render(){return i`
2
2
  <div
3
3
  id=${this._tooltipId}
4
4
  popover="manual"