@aceshooting/lyra-ui 23.0.0 → 24.0.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 (278) hide show
  1. package/CHANGELOG.md +9 -43
  2. package/README.md +72 -35
  3. package/custom-elements.json +1 -1
  4. package/design-tokens.json +1 -1
  5. package/dist/cli/lyra-rename-ledger.mjs +1 -1
  6. package/dist/cli/migration-contract.json +1 -1
  7. package/dist/cli/migration-contract.mjs +1 -1
  8. package/dist/cli/migration-renames.mjs +2 -2
  9. package/dist/cli/migration-transforms.mjs +2 -2
  10. package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -4
  11. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -3
  12. package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +1 -4
  13. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  14. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.d.ts +1 -7
  15. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
  16. package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -1
  17. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +2 -5
  18. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -3
  19. package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -4
  20. package/dist/components/agent-tools/terminal/terminal.class.js +2 -2
  21. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.d.ts +1 -7
  22. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
  23. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +1 -4
  24. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -3
  25. package/dist/components/charts/chart/lite-chart-axis-layout.d.ts +13 -0
  26. package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -0
  27. package/dist/components/charts/chart/lite-chart.class.d.ts +1 -11
  28. package/dist/components/charts/chart/lite-chart.class.js +4 -4
  29. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +2 -2
  30. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +0 -1
  31. package/dist/components/conversation/chat-message/chat-message.class.d.ts +3 -9
  32. package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
  33. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  34. package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -8
  35. package/dist/components/conversation/code-block/code-block-shared.d.ts +1 -4
  36. package/dist/components/conversation/code-block/code-block.class.d.ts +4 -6
  37. package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -3
  38. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  39. package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -4
  40. package/dist/components/conversation/markdown/markdown.class.d.ts +1 -4
  41. package/dist/components/conversation/message-actions/message-actions.class.d.ts +1 -4
  42. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  43. package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +1 -4
  44. package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
  45. package/dist/components/conversation/message-parts/message-parts.class.d.ts +2 -5
  46. package/dist/components/conversation/message-parts/message-parts.class.js +3 -3
  47. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +1 -1
  48. package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +2 -0
  49. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +0 -1
  50. package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +2 -0
  51. package/dist/components/conversation/streaming-text/streaming-text.class.js +0 -1
  52. package/dist/components/conversation/thread-list/thread-list.class.d.ts +6 -17
  53. package/dist/components/conversation/thread-list/thread-list.class.js +6 -6
  54. package/dist/components/data/context-meter/context-meter.class.d.ts +1 -6
  55. package/dist/components/data/context-meter/context-meter.class.js +1 -1
  56. package/dist/components/data/data-grid/data-grid.class.d.ts +0 -1
  57. package/dist/components/data/data-grid/data-grid.class.js +2 -2
  58. package/dist/components/data/document-library/document-library.class.d.ts +6 -13
  59. package/dist/components/data/document-library/document-library.class.js +1 -2
  60. package/dist/components/data/heatmap/heatmap-grid-navigation.d.ts +7 -0
  61. package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -0
  62. package/dist/components/data/heatmap/heatmap.class.d.ts +3 -23
  63. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  64. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +3 -9
  65. package/dist/components/data/sequence-strip/sequence-strip.class.js +3 -3
  66. package/dist/components/data/table/table.class.d.ts +5 -14
  67. package/dist/components/data/table/table.class.js +6 -6
  68. package/dist/components/forms/button/button.class.d.ts +2 -2
  69. package/dist/components/forms/button/button.class.js +9 -9
  70. package/dist/components/forms/combobox/combobox.class.d.ts +1 -4
  71. package/dist/components/forms/combobox/combobox.class.js +2 -2
  72. package/dist/components/forms/input/time-input.class.d.ts +1 -1
  73. package/dist/components/forms/input/time-input.class.js +1 -1
  74. package/dist/components/forms/select/select.class.d.ts +1 -2
  75. package/dist/components/layout/app-rail/app-rail-item.class.d.ts +3 -6
  76. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  77. package/dist/components/layout/app-rail/app-rail.class.d.ts +2 -4
  78. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  79. package/dist/components/layout/app-rail-group/app-rail-group.class.d.ts +2 -6
  80. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  81. package/dist/components/layout/carousel/carousel.class.d.ts +1 -4
  82. package/dist/components/layout/carousel/carousel.class.js +2 -2
  83. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  84. package/dist/components/layout/details/details.class.d.ts +2 -4
  85. package/dist/components/layout/details/details.class.js +1 -1
  86. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +3 -7
  87. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  88. package/dist/components/layout/menu/menu.class.js +1 -1
  89. package/dist/components/layout/multi-split/multi-split.class.d.ts +2 -4
  90. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  91. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +2 -4
  92. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
  93. package/dist/components/layout/reorder-list/reorder-item.class.d.ts +1 -4
  94. package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
  95. package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +5 -9
  96. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +5 -5
  97. package/dist/components/media/av-player/av-player.class.js +3 -3
  98. package/dist/components/media/file-input/file-input.class.d.ts +3 -6
  99. package/dist/components/media/file-input/file-input.class.js +3 -3
  100. package/dist/components/media/lightbox/lightbox.class.d.ts +11 -20
  101. package/dist/components/media/lightbox/lightbox.class.js +1 -1
  102. package/dist/components/media/map/map-data-layers.d.ts +20 -0
  103. package/dist/components/media/map/map-data-layers.js +1 -0
  104. package/dist/components/media/map/map.class.js +3 -3
  105. package/dist/components/media/media-time.d.ts +2 -0
  106. package/dist/components/media/media-time.js +1 -0
  107. package/dist/components/media/video/video.class.js +5 -5
  108. package/dist/components/media/video-playlist/video-playlist.class.js +2 -2
  109. package/dist/components/overlays/callout/callout.class.d.ts +2 -5
  110. package/dist/components/overlays/callout/callout.class.js +2 -2
  111. package/dist/components/overlays/dialog/dialog.class.d.ts +4 -7
  112. package/dist/components/overlays/dialog/dialog.class.js +2 -2
  113. package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -10
  114. package/dist/components/overlays/overlay/dropdown.class.js +2 -2
  115. package/dist/components/overlays/overlay/popover.class.d.ts +2 -3
  116. package/dist/components/overlays/popup/popup.class.js +1 -1
  117. package/dist/components/overlays/progress/progress-bar.class.d.ts +1 -4
  118. package/dist/components/overlays/progress/progress-bar.class.js +2 -2
  119. package/dist/components/overlays/progress/progress-ring.class.d.ts +1 -4
  120. package/dist/components/overlays/progress/progress-ring.class.js +2 -2
  121. package/dist/components/overlays/progress/progress-shared.d.ts +3 -3
  122. package/dist/components/overlays/progress/progress-shared.js +1 -1
  123. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  124. package/dist/components/retrieval/graph/graph.class.d.ts +5 -10
  125. package/dist/components/retrieval/graph/graph.class.js +1 -1
  126. package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +7 -14
  127. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +2 -3
  128. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +2 -8
  129. package/dist/components/retrieval/memory-panel/memory-panel.class.js +0 -4
  130. package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
  131. package/dist/components/utility/export-button/export-button.class.d.ts +6 -10
  132. package/dist/components/utility/export-button/export-button.class.js +1 -1
  133. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  134. package/dist/components/viewers/geojson-view/geojson-view.class.d.ts +1 -1
  135. package/dist/components/viewers/highlight-layer/highlight-layer-timing.js +1 -1
  136. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
  137. package/dist/events.d.ts +17 -78
  138. package/dist/framework-types.d.ts +1 -1
  139. package/dist/internal/catalog-picker.js +1 -1
  140. package/dist/internal/css-motion-time.d.ts +7 -0
  141. package/dist/internal/css-motion-time.js +1 -0
  142. package/dist/internal/data-state-renderer.d.ts +1 -3
  143. package/dist/internal/data-state-renderer.js +1 -1
  144. package/dist/internal/localization-runtime.d.ts +2 -0
  145. package/dist/internal/localization-runtime.js +1 -1
  146. package/dist/internal/lyra-element.js +2 -2
  147. package/dist/internal/package-metadata.d.ts +1 -1
  148. package/dist/internal/package-metadata.js +1 -1
  149. package/dist/looks/data.css +1 -1
  150. package/dist/looks/terminal.css +1 -1
  151. package/dist/lyra.d.ts +1 -592
  152. package/dist/lyra.js +1 -1
  153. package/dist/testing/event-factory.d.ts +2 -2
  154. package/dist/testing/interaction-drivers.d.ts +5 -3
  155. package/dist/testing/lyra-tag-event-map.js +1 -1
  156. package/dist/theme/looks/data.d.ts +1 -1
  157. package/dist/theme/looks/data.js +1 -1
  158. package/dist/theme/looks/terminal.d.ts +1 -1
  159. package/dist/theme/looks/terminal.js +1 -1
  160. package/dist/theme/theme.d.ts +2 -80
  161. package/dist/theme/theme.js +1 -1
  162. package/llms/components/lr-agent-workspace.md +1 -1
  163. package/llms/components/lr-alert.md +1 -1
  164. package/llms/components/lr-animation.md +1 -1
  165. package/llms/components/lr-app-rail.md +8 -10
  166. package/llms/components/lr-approval-queue.md +2 -4
  167. package/llms/components/lr-attachment-trigger.md +3 -4
  168. package/llms/components/lr-badge.md +2 -2
  169. package/llms/components/lr-button.md +45 -99
  170. package/llms/components/lr-callout.md +3 -4
  171. package/llms/components/lr-carousel.md +3 -5
  172. package/llms/components/lr-chat-message.md +1 -2
  173. package/llms/components/lr-claim-evidence.md +1 -1
  174. package/llms/components/lr-code-block-core.md +2 -2
  175. package/llms/components/lr-code-block.md +5 -6
  176. package/llms/components/lr-color-picker.md +1 -1
  177. package/llms/components/lr-combobox.md +5 -6
  178. package/llms/components/lr-compare-panel.md +2 -4
  179. package/llms/components/lr-confirm-bar.md +3 -7
  180. package/llms/components/lr-context-inspector.md +3 -2
  181. package/llms/components/lr-context-menu.md +2 -2
  182. package/llms/components/lr-context-meter.md +2 -4
  183. package/llms/components/lr-copy-button.md +1 -1
  184. package/llms/components/lr-data-grid.md +4 -7
  185. package/llms/components/lr-details.md +3 -3
  186. package/llms/components/lr-dialog.md +4 -6
  187. package/llms/components/lr-dock-panel.md +5 -6
  188. package/llms/components/lr-document-library.md +5 -7
  189. package/llms/components/lr-drawer.md +3 -3
  190. package/llms/components/lr-dropdown.md +4 -5
  191. package/llms/components/lr-eval-run.md +3 -5
  192. package/llms/components/lr-export-button.md +4 -7
  193. package/llms/components/lr-file-input.md +0 -5
  194. package/llms/components/lr-funnel.md +1 -1
  195. package/llms/components/lr-graph.md +3 -7
  196. package/llms/components/lr-icon.md +1 -1
  197. package/llms/components/lr-include.md +1 -1
  198. package/llms/components/lr-input.md +31 -79
  199. package/llms/components/lr-json-viewer.md +1 -1
  200. package/llms/components/lr-knowledge-base.md +4 -6
  201. package/llms/components/lr-knowledge-graph-explorer.md +2 -5
  202. package/llms/components/lr-known-date.md +1 -1
  203. package/llms/components/lr-lightbox.md +9 -7
  204. package/llms/components/lr-lite-chart.md +1 -5
  205. package/llms/components/lr-markdown-core.md +3 -4
  206. package/llms/components/lr-markdown.md +3 -5
  207. package/llms/components/lr-mcp-app.md +1 -1
  208. package/llms/components/lr-message-actions.md +2 -3
  209. package/llms/components/lr-message-feedback.md +1 -3
  210. package/llms/components/lr-message-parts.md +4 -5
  211. package/llms/components/lr-multi-split.md +8 -7
  212. package/llms/components/lr-native-time-input.md +1 -1
  213. package/llms/components/lr-navigation-menu.md +5 -5
  214. package/llms/components/lr-number-input.md +3 -1
  215. package/llms/components/lr-otp-input.md +2 -0
  216. package/llms/components/lr-page.md +1 -1
  217. package/llms/components/lr-pan-zoom.md +1 -1
  218. package/llms/components/lr-phone-input.md +3 -1
  219. package/llms/components/lr-popover.md +2 -2
  220. package/llms/components/lr-progress-bar.md +3 -5
  221. package/llms/components/lr-progress-ring.md +5 -7
  222. package/llms/components/lr-prompt-input.md +1 -1
  223. package/llms/components/lr-prompt-queue.md +1 -1
  224. package/llms/components/lr-prompt-studio.md +1 -1
  225. package/llms/components/lr-rag-eval-dashboard.md +1 -1
  226. package/llms/components/lr-rating.md +2 -2
  227. package/llms/components/lr-realtime-session.md +1 -1
  228. package/llms/components/lr-reorder-item.md +1 -1
  229. package/llms/components/lr-reorder-list.md +2 -3
  230. package/llms/components/lr-retrieval-compare.md +1 -1
  231. package/llms/components/lr-select.md +3 -1
  232. package/llms/components/lr-selection-toolbar.md +1 -1
  233. package/llms/components/lr-sequence-strip.md +3 -8
  234. package/llms/components/lr-span-waterfall.md +1 -1
  235. package/llms/components/lr-split-panel.md +1 -1
  236. package/llms/components/lr-streaming-text-core.md +2 -1
  237. package/llms/components/lr-streaming-text.md +3 -2
  238. package/llms/components/lr-subagent-panel.md +1 -1
  239. package/llms/components/lr-swatch-picker.md +4 -4
  240. package/llms/components/lr-switch.md +3 -1
  241. package/llms/components/lr-table.md +33 -85
  242. package/llms/components/lr-terminal.md +2 -5
  243. package/llms/components/lr-textarea.md +1 -1
  244. package/llms/components/lr-thread-list.md +8 -14
  245. package/llms/components/lr-time-input.md +1 -1
  246. package/llms/components/lr-toggle-group.md +2 -2
  247. package/llms/components/lr-toggle.md +1 -1
  248. package/llms/components/lr-tool-approval-dialog.md +4 -7
  249. package/llms/components/lr-tool-call-block.md +1 -1
  250. package/llms/components/lr-tool-timeline.md +2 -5
  251. package/llms/components/lr-video-playlist.md +1 -1
  252. package/llms/components/lr-video.md +1 -1
  253. package/llms/components/lr-widget-renderer.md +7 -6
  254. package/llms/components/lr-zoomable-frame.md +1 -1
  255. package/llms/index.md +3 -618
  256. package/llms/migration.md +614 -614
  257. package/llms/shared/events-and-types.md +25 -24
  258. package/llms/shared/frameworks-and-ssr.md +7 -3
  259. package/llms/shared/imports-and-registration.md +22 -22
  260. package/llms/shared/localization-and-rtl.md +2 -2
  261. package/llms/shared/native-styles-and-utilities.md +263 -0
  262. package/llms/shared/styles-and-tokens.md +85 -676
  263. package/llms/shared/testing-and-utilities.md +12 -11
  264. package/llms/shared/v23-to-v24-migration.md +167 -0
  265. package/llms/shared.md +142 -487
  266. package/llms/tokens.md +3 -3
  267. package/llms.txt +9 -4
  268. package/package.json +7 -311
  269. package/registrations.json +1 -1
  270. package/vscode-html-data.json +1 -1
  271. package/web-types.json +1 -1
  272. package/dist/ssr-loader.d.ts +0 -2
  273. package/dist/ssr-loader.js +0 -1
  274. package/dist/theme/presets/shadcn.d.ts +0 -22
  275. package/dist/theme/presets/shadcn.js +0 -1
  276. package/dist/theme/presets.d.ts +0 -49
  277. package/dist/theme/presets.js +0 -1
  278. package/dist/themes/shadcn.css +0 -1
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{activeElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{applyComposedFocusRepair,captureComposedFocusRepair,isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{chevronIcon}from"../../../internal/icons.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LyraElement}from"../../../internal/lyra-element.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{tag}from"../../../internal/prefix.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{safeLinkHref}from"../../../internal/safe-url.js";import{deferredPlace as place,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{styles}from"./app-rail-item.styles.js";import{LYRA_DEFAULT_appRailItemCollapse,LYRA_DEFAULT_appRailItemExpand}from"../../../internal/default-strings.generated.js";class LyraAppRailItem extends LyraElement{constructor(){super(...arguments),this.href="",this.target="",this.disabled=!1,this.current=!1,this.tooltip=!1,this.topLayer=!1,this.railTopLayer=!1,this._expanded=!1,this.toggleGuard=new VetoWriteGuard,this.showTooltip=!1,this.hasEndSlot=!1,this.hasMetaSlot=!1,this.recoverFocusAfterIconOnly=!1,this.childrenId=nextId("app-rail-item-children"),this.onToggleClick=event=>{event.stopPropagation();const next=!this._expanded;requestThenCommit({requestDetail:{open:next,expanded:next},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.expanded=next,this.emit("lr-toggle",{open:next,expanded:next})}})},this.onFocusShow=event=>{if(this.tooltip&&this.hasAttribute("icon-only")&&(event.type!=="focus"||isKeyboardFocusEvent(event))&&(this.showTooltip=!0),event.type!=="focus")return;const related=event.relatedTarget;related&&related.nodeType===1&&isComposedFocusAvailable(related)&&(this.focusReturnTarget=related)},this.onBlurHide=()=>{this.showTooltip=!1},this.onEndSlotChange=event=>{this.applyEndSlotPresence(event.target)},this.onMetaSlotChange=event=>{this.applyMetaSlotPresence(event.target)}}static{this.defaultStrings={...super.defaultStrings,appRailItemCollapse:LYRA_DEFAULT_appRailItemCollapse,appRailItemExpand:LYRA_DEFAULT_appRailItemExpand}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"icon-only"]}syncRailTopLayer(){const rail=this.closest(tag("app-rail"));this.railTopLayer=rail?.topLayer===!0}get effectiveTopLayer(){return this.topLayer||this.railTopLayer}get expanded(){return this._expanded}set expanded(next){const old=this._expanded;this._expanded=next,markVetoGuardWrite(this.toggleGuard),this.requestUpdate("expanded",old)}get hasChildrenSlotted(){return Array.from(this.children).some(el=>el.getAttribute("slot")==="children")}connectedCallback(){super.connectedCallback(),this.syncRailTopLayer(),this.armLabelObserver(),this.armChildrenObserver(),this.syncOwnedChildren()}armLabelObserver(){this.labelObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.labelObserver=new MutationObserverCtor(()=>{this.showTooltip&&this.requestUpdate()}),this.labelObserver.observe(this,{childList:!0,characterData:!0,subtree:!0}))}armChildrenObserver(){this.childrenObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.childrenObserver=new MutationObserverCtor(()=>{this.syncOwnedChildren(),this.requestUpdate()}),this.childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot"]}))}syncOwnedChildren(){if(!this.isConnected)return;const iconOnly=this.hasAttribute("icon-only"),itemTag=tag("app-rail-item");for(const node of this.querySelectorAll(itemTag))(node.parentElement?.closest(itemTag)??null)===this&&node.toggleAttribute("icon-only",iconOnly)}get labelText(){return Array.from(this.childNodes).filter(node=>{if(node.nodeType===3)return!0;if(node.nodeType!==1)return!1;const slot=node.getAttribute("slot");return slot!=="icon"&&slot!=="children"}).map(n=>n.textContent??"").join("").trim()}get tooltipText(){return hostAriaLabel(this)??(this.labelText||"")}applyEndSlotPresence(slot){this.hasEndSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}applyMetaSlotPresence(slot){this.hasMetaSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}attributeChangedCallback(name,oldValue,newValue){if(super.attributeChangedCallback(name,oldValue,newValue),!(name!=="icon-only"||oldValue===newValue)){if(newValue===null)this.showTooltip=!1;else{const active=deepActiveElement(this.ownerDocument),toggle=this.renderRoot?.querySelector('[part="toggle"]');this.recoverFocusAfterIconOnly=active===toggle||Array.from(this.children).some(child=>child.getAttribute("slot")==="children"&&composedContains(child,active))}this.syncOwnedChildren(),this.requestUpdate()}}firstUpdated(changed){super.firstUpdated(changed);const metaSlot=this.metaSlot,endSlot=this.endSlot;queueMicrotask(()=>{collectInitialSlotAssignment(metaSlot,s=>this.applyMetaSlotPresence(s)),collectInitialSlotAssignment(endSlot,s=>this.applyEndSlotPresence(s))})}willUpdate(changed){if(super.willUpdate(changed),changed.has("tooltip")&&!this.tooltip&&(this.showTooltip=!1),changed.has("href")||changed.has("disabled")){const previous=this.renderRoot?.querySelector('[part="base"]')??null,nextIsLink=!!safeLinkHref(this.href)&&!this.disabled,ownerReplaced=previous!==null&&previous.localName==="a"!==nextIsLink;this.semanticFocusRepair=ownerReplaced&&activeElementIn(this.shadowRoot)===previous?captureComposedFocusRepair(this,this.focusFallback()??previous)??void 0:void 0}}updated(changed){super.updated(changed),this.recoverFocusAfterIconOnly&&(this.recoverFocusAfterIconOnly=!1,this.scheduleAfterUpdate(()=>{const base=this.renderRoot.querySelector('[part="base"]');base&&isComposedFocusAvailable(base)&&!composedContains(base,deepActiveElement(this.ownerDocument))&&base.focus()},"app-rail-item-icon-only-focus"));const focusRepair=this.semanticFocusRepair;this.semanticFocusRepair=void 0,focusRepair&&this.scheduleAfterUpdate(()=>{const replacement=this.renderRoot.querySelector('[part="base"]'),target=replacement&&isComposedFocusAvailable(replacement)?replacement:this.focusFallback();applyComposedFocusRepair(focusRepair,target)},"app-rail-item-owner-focus");const popup=this.renderRoot.querySelector('[part="tooltip"]');if(!popup){this.stopPositioning?.(),this.stopPositioning=void 0;return}if(changed.has("showTooltip")||changed.has("topLayer")||changed.has("railTopLayer")||!this.stopPositioning){this.stopPositioning?.();const anchor=this.renderRoot.querySelector('[part="base"]'),topLayer=this.effectiveTopLayer;this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,topLayer),this.stopPositioning=place(anchor,popup,{placement:rtlAwarePlacement("right",this),...topLayerPlacement(topLayer,resolveEffectivePositioningStrategy(this,void 0,"fixed"))})}}disconnectedCallback(){super.disconnectedCallback(),this.semanticFocusRepair=void 0,this.focusReturnTarget=void 0,this.labelObserver?.disconnect(),this.labelObserver=void 0,this.childrenObserver?.disconnect(),this.childrenObserver=void 0,this.stopPositioning?.(),this.stopPositioning=void 0,this.showTooltip=!1}focusFallback(){if(this.focusReturnTarget&&isComposedFocusAvailable(this.focusReturnTarget))return this.focusReturnTarget;const owner=this.closest("lr-app-rail")?.shadowRoot?.querySelector('[part~="base"], [part~="panel"]')??null;return owner&&isComposedFocusAvailable(owner)?owner:null}click(){this.disabled||this.renderRoot.querySelector('[part~="base"]')?.click()}render(){const label=hostAriaLabel(this),href=safeLinkHref(this.href),content=html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{activeElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{applyComposedFocusRepair,captureComposedFocusRepair,isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{chevronIcon}from"../../../internal/icons.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LyraElement}from"../../../internal/lyra-element.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{tag}from"../../../internal/prefix.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{safeLinkHref}from"../../../internal/safe-url.js";import{deferredPlace as place,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{styles}from"./app-rail-item.styles.js";import{LYRA_DEFAULT_appRailItemCollapse,LYRA_DEFAULT_appRailItemExpand}from"../../../internal/default-strings.generated.js";class LyraAppRailItem extends LyraElement{constructor(){super(...arguments),this.href="",this.target="",this.disabled=!1,this.current=!1,this.tooltip=!1,this.topLayer=!1,this.railTopLayer=!1,this._expanded=!1,this.toggleGuard=new VetoWriteGuard,this.showTooltip=!1,this.hasEndSlot=!1,this.hasMetaSlot=!1,this.recoverFocusAfterIconOnly=!1,this.childrenId=nextId("app-rail-item-children"),this.onToggleClick=event=>{event.stopPropagation();const next=!this._expanded;requestThenCommit({requestDetail:{expanded:next},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.expanded=next,this.emit("lr-toggle",{expanded:next})}})},this.onFocusShow=event=>{if(this.tooltip&&this.hasAttribute("icon-only")&&(event.type!=="focus"||isKeyboardFocusEvent(event))&&(this.showTooltip=!0),event.type!=="focus")return;const related=event.relatedTarget;related&&related.nodeType===1&&isComposedFocusAvailable(related)&&(this.focusReturnTarget=related)},this.onBlurHide=()=>{this.showTooltip=!1},this.onEndSlotChange=event=>{this.applyEndSlotPresence(event.target)},this.onMetaSlotChange=event=>{this.applyMetaSlotPresence(event.target)}}static{this.defaultStrings={...super.defaultStrings,appRailItemCollapse:LYRA_DEFAULT_appRailItemCollapse,appRailItemExpand:LYRA_DEFAULT_appRailItemExpand}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"icon-only"]}syncRailTopLayer(){const rail=this.closest(tag("app-rail"));this.railTopLayer=rail?.topLayer===!0}get effectiveTopLayer(){return this.topLayer||this.railTopLayer}get expanded(){return this._expanded}set expanded(next){const old=this._expanded;this._expanded=next,markVetoGuardWrite(this.toggleGuard),this.requestUpdate("expanded",old)}get hasChildrenSlotted(){return Array.from(this.children).some(el=>el.getAttribute("slot")==="children")}connectedCallback(){super.connectedCallback(),this.syncRailTopLayer(),this.armLabelObserver(),this.armChildrenObserver(),this.syncOwnedChildren()}armLabelObserver(){this.labelObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.labelObserver=new MutationObserverCtor(()=>{this.showTooltip&&this.requestUpdate()}),this.labelObserver.observe(this,{childList:!0,characterData:!0,subtree:!0}))}armChildrenObserver(){this.childrenObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.childrenObserver=new MutationObserverCtor(()=>{this.syncOwnedChildren(),this.requestUpdate()}),this.childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot"]}))}syncOwnedChildren(){if(!this.isConnected)return;const iconOnly=this.hasAttribute("icon-only"),itemTag=tag("app-rail-item");for(const node of this.querySelectorAll(itemTag))(node.parentElement?.closest(itemTag)??null)===this&&node.toggleAttribute("icon-only",iconOnly)}get labelText(){return Array.from(this.childNodes).filter(node=>{if(node.nodeType===3)return!0;if(node.nodeType!==1)return!1;const slot=node.getAttribute("slot");return slot!=="icon"&&slot!=="children"}).map(n=>n.textContent??"").join("").trim()}get tooltipText(){return hostAriaLabel(this)??(this.labelText||"")}applyEndSlotPresence(slot){this.hasEndSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}applyMetaSlotPresence(slot){this.hasMetaSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}attributeChangedCallback(name,oldValue,newValue){if(super.attributeChangedCallback(name,oldValue,newValue),!(name!=="icon-only"||oldValue===newValue)){if(newValue===null)this.showTooltip=!1;else{const active=deepActiveElement(this.ownerDocument),toggle=this.renderRoot?.querySelector('[part="toggle"]');this.recoverFocusAfterIconOnly=active===toggle||Array.from(this.children).some(child=>child.getAttribute("slot")==="children"&&composedContains(child,active))}this.syncOwnedChildren(),this.requestUpdate()}}firstUpdated(changed){super.firstUpdated(changed);const metaSlot=this.metaSlot,endSlot=this.endSlot;queueMicrotask(()=>{collectInitialSlotAssignment(metaSlot,s=>this.applyMetaSlotPresence(s)),collectInitialSlotAssignment(endSlot,s=>this.applyEndSlotPresence(s))})}willUpdate(changed){if(super.willUpdate(changed),changed.has("tooltip")&&!this.tooltip&&(this.showTooltip=!1),changed.has("href")||changed.has("disabled")){const previous=this.renderRoot?.querySelector('[part="base"]')??null,nextIsLink=!!safeLinkHref(this.href)&&!this.disabled,ownerReplaced=previous!==null&&previous.localName==="a"!==nextIsLink;this.semanticFocusRepair=ownerReplaced&&activeElementIn(this.shadowRoot)===previous?captureComposedFocusRepair(this,this.focusFallback()??previous)??void 0:void 0}}updated(changed){super.updated(changed),this.recoverFocusAfterIconOnly&&(this.recoverFocusAfterIconOnly=!1,this.scheduleAfterUpdate(()=>{const base=this.renderRoot.querySelector('[part="base"]');base&&isComposedFocusAvailable(base)&&!composedContains(base,deepActiveElement(this.ownerDocument))&&base.focus()},"app-rail-item-icon-only-focus"));const focusRepair=this.semanticFocusRepair;this.semanticFocusRepair=void 0,focusRepair&&this.scheduleAfterUpdate(()=>{const replacement=this.renderRoot.querySelector('[part="base"]'),target=replacement&&isComposedFocusAvailable(replacement)?replacement:this.focusFallback();applyComposedFocusRepair(focusRepair,target)},"app-rail-item-owner-focus");const popup=this.renderRoot.querySelector('[part="tooltip"]');if(!popup){this.stopPositioning?.(),this.stopPositioning=void 0;return}if(changed.has("showTooltip")||changed.has("topLayer")||changed.has("railTopLayer")||!this.stopPositioning){this.stopPositioning?.();const anchor=this.renderRoot.querySelector('[part="base"]'),topLayer=this.effectiveTopLayer;this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,topLayer),this.stopPositioning=place(anchor,popup,{placement:rtlAwarePlacement("right",this),...topLayerPlacement(topLayer,resolveEffectivePositioningStrategy(this,void 0,"fixed"))})}}disconnectedCallback(){super.disconnectedCallback(),this.semanticFocusRepair=void 0,this.focusReturnTarget=void 0,this.labelObserver?.disconnect(),this.labelObserver=void 0,this.childrenObserver?.disconnect(),this.childrenObserver=void 0,this.stopPositioning?.(),this.stopPositioning=void 0,this.showTooltip=!1}focusFallback(){if(this.focusReturnTarget&&isComposedFocusAvailable(this.focusReturnTarget))return this.focusReturnTarget;const owner=this.closest("lr-app-rail")?.shadowRoot?.querySelector('[part~="base"], [part~="panel"]')??null;return owner&&isComposedFocusAvailable(owner)?owner:null}click(){this.disabled||this.renderRoot.querySelector('[part~="base"]')?.click()}render(){const label=hostAriaLabel(this),href=safeLinkHref(this.href),content=html`
2
2
  ${this.current?html`<span part="current-indicator" aria-hidden="true"></span>`:nothing}
3
3
  ${renderInertPresentation(html`<slot name="icon"></slot>`,{part:"icon"})}
4
4
  <span part="label"><slot></slot></span>
@@ -11,8 +11,6 @@ export type LyraAppRailModeInput=LyraAppRailMode|'auto';
11
11
  export type LyraAppRailPreferredMode=Exclude<LyraAppRailMode,'mobile'>;
12
12
  /** Whitespace-separated tokens accepted by the `persist` attribute. */
13
13
  export type LyraAppRailPersistField='open'|'width'|'preferred-mode';export interface LyraAppRailModeChangeDetail{mode:LyraAppRailMode;}export interface LyraAppRailToggleDetail{
14
- /** @deprecated Use `expanded`, which carries the same value; removal not before 23.0.0. */
15
- open:boolean;
16
14
  /** Whether the mobile overlay is (or, on a cancelable proposal, would be) open. */
17
15
  expanded:boolean;}export interface LyraAppRailResizeDetail{widthPx:number;}
18
16
  /**
@@ -80,10 +78,10 @@ export declare function computeAppRailMode(iconOnlyMatches:boolean,mobileMatches
80
78
  * (the ordinary default-mode mount stays silent).
81
79
  * `detail: LyraAppRailModeChangeDetail`.
82
80
  * @event lr-toggle-request - Cancelable proposal before an interactive overlay state change.
83
- * Detail includes `expanded` and the compatibility `open` key. Direct property writes and
81
+ * Detail carries the proposed `expanded` state. Direct property writes and
84
82
  * forced responsive closes do not propose an interactive change.
85
83
  * @event lr-toggle - Non-cancelable notification after an accepted or forced overlay change.
86
- * Detail includes the resulting `expanded` state and the compatibility `open` key.
84
+ * Detail carries the resulting `expanded` state.
87
85
  * @event lr-rail-resize-request - A cancelable request to change the `resizable` rail's width via
88
86
  * drag or keyboard stepping. Call `preventDefault()` to keep `railWidth` unchanged. Not fired
89
87
  * when a consumer sets `railWidth` directly. `detail: LyraAppRailResizeDetail`.
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay,collectFocusableElements,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{optionalLiteralSetConverter}from"../../../internal/converters.js";import{DeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{resolveCssLength}from"../../../internal/css-length.js";import{focusFirstAvailable}from"../../../internal/focus-navigation.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{detectPlatform}from"../../../internal/platform.js";import{parseHotkey,hasNonShiftModifier,matchesHotkey,hotkeyAriaKeyShortcuts,isIgnorableKeyEvent,isEditableKeyEventTarget,registerHotkeyOwner,unregisterHotkeyOwner,resolveHotkeyOwner}from"../../../internal/hotkey.js";import{nextId,isAccessibilityVisible}from"../../../internal/a11y.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{chevronIcon,closeIcon,menuIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{isRtl}from"../../../internal/rtl.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{definePersistedProperty,isPersistedPropertyExplicitlySet}from"../../../internal/persisted-restore.js";import{styles}from"./app-rail.styles.js";import"./app-rail-item.class.js";import{LYRA_DEFAULT_appRailCollapse,LYRA_DEFAULT_appRailExpand,LYRA_DEFAULT_closeNavigation,LYRA_DEFAULT_navigation,LYRA_DEFAULT_openNavigation,LYRA_DEFAULT_resizeNavigation,LYRA_DEFAULT_resizeValuePixels}from"../../../internal/default-strings.generated.js";const APP_RAIL_FRAME=optionalLiteralSetConverter(["card","plain"]),RAIL_WIDTH_CONVERTER={fromAttribute:value=>{if(value===null)return value;const number=Number(value);return Number.isNaN(number)?value:number}},APP_RAIL_PERSIST_FIELDS=new Set(["open","width","preferred-mode"]);function computeAppRailMode(iconOnlyMatches,mobileMatches,preferredMode){return mobileMatches?"mobile":preferredMode||(iconOnlyMatches?"icon-only":"full")}class LyraAppRail extends LyraElement{static{this.defaultStrings={...super.defaultStrings,appRailCollapse:LYRA_DEFAULT_appRailCollapse,appRailExpand:LYRA_DEFAULT_appRailExpand,closeNavigation:LYRA_DEFAULT_closeNavigation,navigation:LYRA_DEFAULT_navigation,openNavigation:LYRA_DEFAULT_openNavigation,resizeNavigation:LYRA_DEFAULT_resizeNavigation,resizeValuePixels:LYRA_DEFAULT_resizeValuePixels}}constructor(){super(),this.iconOnlyBreakpoint="960px",this.mobileBreakpoint="600px",this.triggerCollapses=!1,this.hotkey="",this.accessibleLabel=null,this.withoutToggle=!1,this.collapsible=!1,this.topLayer=!1,this.trigger=null,this.for="",this.focusFallback=null,this.resizable=!1,this.persist="open width",this.minRailWidth=190,this.maxRailWidth=440,this._dragging=!1,this.hasHeaderSlot=!1,this.hasFooterSlot=!1,this.persistReady=!1,this._mode="full",this.forced=!1,this.iconOnlyMatches=!1,this.mobileMatches=!1,this.overlayActive=!1,this.justOpened=!1,this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1)},onUnexpectedClose:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1),this.overlayActive&&this.nativeModal.show()}}),this.overlayReturnTarget=null,this.overlayOpener=null,this.overlayReturnIsExplicit=!1,this.deferredFocusReturn=new DeferredFocusReturn,this.recoverInlineFocusAfterResponsiveClose=!1,this.navId=nextId("app-rail-nav"),this.navRegionId=nextId("app-rail-nav-region"),this.resizeStartX=0,this.resizeStartWidth=0,this.resizeGestureChanged=!1,this.managedItems=new Set,this.onIconOnlyChange=e=>{this.iconOnlyMatches=e.matches,this.forced||this.applyComputedMode()},this.onMobileChange=e=>{this.mobileMatches=e.matches,this.forced||this.applyComputedMode()},this.onToggleClick=e=>{this.open||(this.explicitTrigger=e.currentTarget),this.setOpen(!this.open)},this.onBackdropClick=()=>{this.overlayHandle?.dismissBackdrop()},this.acceptsHotkey=event=>{const parsed=parseHotkey(this.hotkey);return this.isConnected&&!this.forced&&parsed!==null&&hasNonShiftModifier(parsed)&&matchesHotkey(parsed,event,detectPlatform(this.hotkeyWindow?.navigator)==="mac")&&!isEditableKeyEventTarget(event)&&isAccessibilityVisible(this)},this.onHotkeyKeyDown=event=>{if(event.defaultPrevented||isIgnorableKeyEvent(event)||!this.hotkeyWindow)return;const keyboard=event;!this.acceptsHotkey(keyboard)||resolveHotkeyOwner(this.hotkeyWindow,keyboard)!==this||(event.preventDefault(),this.toggle())},this.onPanelTransition=event=>{event.target===event.currentTarget&&event.propertyName==="transform"&&this.baseEl?.removeAttribute("data-sliding")},this.onCollapseToggleClick=()=>{this.toggleCollapse()},this.onNavItemClick=()=>{this.overlayActive&&this.setOpen(!1)},this.onHeaderSlotChange=()=>{this.hasHeaderSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="header")},this.onFooterSlotChange=()=>{this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")},this.onNavSlotChange=()=>{this.syncSlottedItems()},this.onResizerPointerDown=e=>{if(!e.isPrimary||e.button!==0||!this.resizable||this._mode!=="full"||this.resizePointerId!==void 0)return;const resizer=e.currentTarget,ownerWindow=resizer.ownerDocument.defaultView;ownerWindow&&(this.resizePointerId=e.pointerId,this.resizeOwnerWindow=ownerWindow,this.resizeStartX=e.clientX,this.resizeStartWidth=this.effectiveRailWidthPx,this.resizeGestureChanged=!1,resizer.setPointerCapture(e.pointerId),ownerWindow.addEventListener("pointermove",this.onResizerPointerMove),ownerWindow.addEventListener("pointerup",this.onResizerPointerUp),ownerWindow.addEventListener("pointercancel",this.onResizerPointerUp),ownerWindow.addEventListener("lostpointercapture",this.onResizerPointerUp),this.setDragging(!0))},this.onResizerPointerMove=e=>{if(e.pointerId!==this.resizePointerId)return;if(!this.resizable||this._mode!=="full"){this.endResizerGesture();return}let delta=e.clientX-this.resizeStartX;isRtl(this)&&(delta=-delta);const next=Math.min(this.safeMaxRailWidthPx,Math.max(this.safeMinRailWidthPx,this.resizeStartWidth+delta));this.requestRailResize(next,!1)},this.onResizerPointerUp=e=>{e.pointerId===this.resizePointerId&&this.endResizerGesture(e.type==="pointerup")},this.onResizerKeyDown=e=>{const rtl=this.getAttribute("dir")==="rtl"||isRtl(this),forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft",step=8;if(e.key===forwardKey){const next=Math.min(this.safeMaxRailWidthPx,this.effectiveRailWidthPx+step);next!==this.effectiveRailWidthPx&&(e.preventDefault(),this.requestRailResize(next))}else if(e.key===backwardKey){const next=Math.max(this.safeMinRailWidthPx,this.effectiveRailWidthPx-step);next!==this.effectiveRailWidthPx&&(e.preventDefault(),this.requestRailResize(next))}},new GlassScrollLayer(this,'[part="base"], [part="panel"]')}static{this.knownUnobservedAttributes=["mode","dragging"]}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}get frame(){return this._frame}set frame(next){const value=APP_RAIL_FRAME.normalizeReflected(this,"frame",next),old=this._frame;value!==old&&(this._frame=value,this.requestUpdate("frame",old))}get forceMode(){return this._forceMode}set forceMode(next){if(next!=null&&next!=="auto"&&next!=="full"&&next!=="icon-only")return;const old=this._forceMode;if(this._forceMode=next??void 0,this.requestUpdate("forceMode",old),next==null||next==="auto"){if(!this.forced)return;this.forced=!1,this.applyComputedMode();return}this.forced=!0,this.setEffectiveMode(next)}static{definePersistedProperty(this.prototype,"open",{initial:!1,attribute:!0,type:Boolean,reflect:!0}),definePersistedProperty(this.prototype,"preferredMode",{initial:void 0,attribute:"preferred-mode"}),definePersistedProperty(this.prototype,"railWidth",{initial:void 0,attribute:"rail-width",converter:RAIL_WIDTH_CONVERTER})}pixelsOf(value){return typeof value=="number"?value:typeof value=="string"?resolveCssLength(value,{host:this}):void 0}get railWidthInPixels(){const width=this.railWidth;return typeof width=="string"?this.pixelsOf(width):width}get dragging(){return this._dragging}setDragging(next){this._dragging=next,this.toggleAttribute("dragging",next)}syncSlottedItems(){const slot=this.shadowRoot?.querySelector('[part="nav"] > slot'),itemTag=tag("app-rail-item"),groupTag=tag("app-rail-group"),railTag=tag("app-rail"),next=new Set((slot?.assignedElements({flatten:!0})??[]).filter(item=>item.localName===itemTag||item.localName===groupTag));for(const item of this.managedItems){if(next.has(item))continue;const newOwner=item.closest(railTag);newOwner&&newOwner!==this&&item.parentElement===newOwner&&!item.hasAttribute("slot")?item.toggleAttribute("icon-only",newOwner.mode==="icon-only"):item.removeAttribute("icon-only")}for(const item of next)item.toggleAttribute("icon-only",this._mode==="icon-only");this.managedItems=next}get mode(){return this._mode}get safeMinRailWidthPx(){return finiteRange(this.pixelsOf(this.minRailWidth)??Number.NaN,190,0)}get safeMaxRailWidthPx(){return Math.max(this.safeMinRailWidthPx,finiteRange(this.pixelsOf(this.maxRailWidth)??Number.NaN,440,0))}get effectiveRailWidthPx(){return this.railWidth!=null?finiteRange(this.railWidthInPixels??Number.NaN,this.safeMinRailWidthPx,this.safeMinRailWidthPx,this.safeMaxRailWidthPx):this.baseEl?.getBoundingClientRect().width??240}resizeValueText(widthPx){return this.localize("resizeValuePixels",void 0,{value:getNumberFormat(this.effectiveLocale).format(Math.round(widthPx))})}get storageFullKey(){return this.storageKey?`lr-app-rail:${this.storageKey}`:void 0}get persistFields(){const persist=typeof this.persist=="string"?this.persist:"";return new Set(persist.split(/\s+/).filter(field=>APP_RAIL_PERSIST_FIELDS.has(field)))}loadPersisted(){const restored={open:!1,preferredMode:!1},parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);if(!parsed)return restored;const fields=this.persistFields;return fields.has("open")&&!isPersistedPropertyExplicitlySet(this,"open")&&typeof parsed.open=="boolean"&&(this.open=parsed.open,restored.open=!0),fields.has("width")&&!isPersistedPropertyExplicitlySet(this,"railWidth")&&typeof parsed.railWidthPx=="number"&&Number.isFinite(parsed.railWidthPx)&&(this.railWidth=parsed.railWidthPx),fields.has("preferred-mode")&&!isPersistedPropertyExplicitlySet(this,"preferredMode")&&(parsed.preferredMode==="full"||parsed.preferredMode==="icon-only")&&(this.preferredMode=parsed.preferredMode,restored.preferredMode=!0),restored}persistState(){const fields=this.persistFields;if(fields.size===0)return;const state2={};fields.has("open")&&(state2.open=this.open),fields.has("width")&&(state2.railWidthPx=this.railWidthInPixels),fields.has("preferred-mode")&&(state2.preferredMode=this.preferredMode??null),writePersistedState(this.storageFullKey,state2)}willUpdate(changed){if(super.willUpdate(changed),(changed.has("resizable")||changed.has("mode"))&&(!this.resizable||this._mode!=="full")&&this.endResizerGesture(),!this.hasUpdated){this.hasHeaderSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="header"),this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer");const restored=this.loadPersisted();if(restored.preferredMode&&!this.forced){const restoredMode=computeAppRailMode(this.iconOnlyMatches,this.mobileMatches,this.preferredMode);restoredMode!==this._mode&&(this._mode=restoredMode,this.pendingInitialModeAnnouncement=restoredMode)}restored.open&&this.open&&this._mode!=="mobile"&&(this.open=!1)}if(this.hasUpdated&&(changed.has("iconOnlyBreakpoint")||changed.has("mobileBreakpoint"))&&(this.teardownMediaQueries(),this.setupMediaQueries()),this.hasUpdated&&changed.has("preferredMode")&&!this.forced&&this.applyComputedMode(),changed.has("open")||changed.has("mode")){const next=this._mode==="mobile"&&this.open;next!==this.overlayActive&&(this.hasUpdated&&this._mode==="mobile"&&!prefersReducedMotion(this)&&this.baseEl?.toggleAttribute("data-sliding",!0),this.overlayActive=next,this.placeToggle(next),next?(this.justOpened=!0,this.activateMobileOverlay()):this.deactivateMobileOverlay(this._mode==="mobile"))}}updated(changed){if(super.updated(changed),this.overlayActive&&this.nativeModal.show(),changed.has("topLayer"))for(const item of this.querySelectorAll(tag("app-rail-item")))item.syncRailTopLayer?.();if(this._lastReflectedMode!==this._mode&&(this._lastReflectedMode=this._mode,this.setAttribute("mode",this._mode)),this.pendingInitialModeAnnouncement!==void 0){const mode=this.pendingInitialModeAnnouncement;this.pendingInitialModeAnnouncement=void 0,this.emit("lr-mode-change",{mode})}if(this.syncSlottedItems(),this.placeToggle(this.overlayActive),this.syncExternalTriggerA11y(),this.syncBuiltInKeyShortcuts(),this.baseEl&&(this._mode!=="mobile"||!this.baseEl.getAnimations().some(animation=>"transitionProperty"in animation&&animation.transitionProperty==="transform"))&&this.baseEl.removeAttribute("data-sliding"),this.recoverInlineFocusAfterResponsiveClose){this.recoverInlineFocusAfterResponsiveClose=!1;const active=deepActiveElement(this.ownerDocument);this.baseEl&&!composedContains(this.baseEl,active)&&this.baseEl.focus()}this.justOpened&&(this.justOpened=!1,this.overlayHandle?.focusInitial()),this.persistReady&&(changed.has("open")||changed.has("railWidth")&&!this.dragging||changed.has("preferredMode")||changed.has("persist"))&&this.persistState(),this.persistReady=!0,this.baseEl&&(this.resizable&&this.railWidth!=null&&this._mode==="full"?this.baseEl.style.setProperty("inline-size",`${this.effectiveRailWidthPx}px`):this.baseEl.style.removeProperty("inline-size")),this.syncResizerPosition()}connectedCallback(){super.connectedCallback(),this.hotkeyWindow=this.ownerDocument.defaultView??void 0,this.hotkeyWindow&&(registerHotkeyOwner(this.hotkeyWindow,this,this.acceptsHotkey),this.hotkeyWindow.addEventListener("keydown",this.onHotkeyKeyDown)),this.setupMediaQueries(),this.hasUpdated&&this._mode==="mobile"&&this.open&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateMobileOverlay(),queueMicrotask(()=>{this.nativeModal.show(),this.overlayHandle?.focusInitial()})),this.hasUpdated&&queueMicrotask(()=>{this.isConnected&&(this.syncSlottedItems(),this.syncExternalTriggerA11y())})}disconnectedCallback(){this.nativeModal.hide(),this.hotkeyWindow&&(this.hotkeyWindow.removeEventListener("keydown",this.onHotkeyKeyDown),unregisterHotkeyOwner(this.hotkeyWindow,this),this.hotkeyWindow=void 0),this.baseEl?.removeAttribute("data-sliding"),this.deferredFocusReturn.cancel(),super.disconnectedCallback(),this.restoreFallbackTabIndex?.(),this.teardownMediaQueries(),this.overlayHandle?.suspend(),this.endResizerGesture(),this.releaseExternalTriggerA11y()}adoptedCallback(){super.adoptedCallback(),this.teardownMediaQueries(),this.endResizerGesture()}resolveExternalTrigger(){if(this.trigger)return this.trigger;if(!this.for)return null;const found=this.getRootNode().getElementById?.(this.for);return found instanceof HTMLElement?found:null}resolveFocusFallback(){const value=this.focusFallback;if(!value)return null;const target=typeof value=="string"?this.getRootNode().getElementById?.(value)??null:value;return isHtmlElement(target)&&target.ownerDocument===this.ownerDocument?target:null}activateMobileOverlay(){this.nativeModal.prepare();const explicitTrigger=this.explicitTrigger;this.explicitTrigger=void 0;const restoreFocusTo=explicitTrigger??this.resolveExternalTrigger()??void 0;this.overlayReturnIsExplicit=explicitTrigger!==void 0,this.deferredFocusReturn.cancel();const active=deepActiveElement(this.ownerDocument);this.overlayOpener=active&&typeof active.focus=="function"&&!composedContains(this,active)?active:null,this.overlayReturnTarget=restoreFocusTo??this.overlayOpener,this.overlayHandle=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.setOpen(!1),onBackdrop:()=>this.setOpen(!1),restoreFocusTo,preferredInitialFocus:()=>{const panel=this.shadowRoot?.querySelector('[part="panel"]')??null;if(!panel)return null;const toggle=this.toggleEl??null;return collectFocusableElements(panel).filter(stop=>stop!==toggle)[0]??panel},lockScroll:!0,suspendWhenUnrendered:!0})}deactivateMobileOverlay(restoreFocus=!0){this.nativeModal.hide(),this.nativeModal.prepare(!1);const handle=this.overlayHandle;if(this.overlayHandle=void 0,this.deferredFocusReturn.cancel(),handle&&restoreFocus&&!this.overlayReturnIsExplicit){const external=this.resolveExternalTrigger();external&&external!==this.overlayReturnTarget&&(this.overlayReturnTarget=external,handle.updateRestoreFocusTo(external))}handle?.deactivate({restoreFocus}),handle&&restoreFocus&&this.scheduleDeferredFocusReturn()}scheduleDeferredFocusReturn(){const candidates=[this.overlayReturnTarget,this.overlayOpener];this.deferredFocusReturn.schedule({host:this,candidates:()=>[...candidates,this.toggleEl],isCurrent:()=>!this.overlayActive,fallback:()=>{this.focusHostFallback()||focusFirstAvailable([this.resolveFocusFallback()])}})}focusHostFallback(){if(!this.hasAttribute("tabindex")){this.setAttribute("tabindex","-1");const view=this.ownerDocument.defaultView,onFocusChange=()=>{deepActiveElement(this.ownerDocument)!==this&&restore()},restore=()=>{this.removeEventListener("blur",onFocusChange),view?.removeEventListener("focus",onFocusChange),this.getAttribute("tabindex")==="-1"&&this.removeAttribute("tabindex"),this.restoreFallbackTabIndex=void 0};this.restoreFallbackTabIndex=restore,this.addEventListener("blur",onFocusChange),view?.addEventListener("focus",onFocusChange)}return focusFirstAvailable(this)?!0:(this.restoreFallbackTabIndex?.(),!1)}placeToggle(insidePanel){const toggle=this.toggleEl,panel=this.baseEl;if(!(!toggle||!panel)){if(insidePanel){panel.firstChild!==toggle&&panel.insertBefore(toggle,panel.firstChild);return}toggle.nextSibling!==panel&&panel.parentNode?.insertBefore(toggle,panel)}}setupMediaQueries(){if(!this.isConnected)return;const view=this.ownerDocument.defaultView;if(!view?.matchMedia)return;const iconOnlyQuery=view.matchMedia(`(max-width: ${this.iconOnlyBreakpoint})`),mobileQuery=view.matchMedia(`(max-width: ${this.mobileBreakpoint})`),iconOnlyListener=event=>{this.mqIconOnly!==iconOnlyQuery||!this.isConnected||this.ownerDocument.defaultView!==view||this.onIconOnlyChange(event)},mobileListener=event=>{this.mqMobile!==mobileQuery||!this.isConnected||this.ownerDocument.defaultView!==view||this.onMobileChange(event)};this.mqIconOnly=iconOnlyQuery,this.mqMobile=mobileQuery,this.mqIconOnlyListener=iconOnlyListener,this.mqMobileListener=mobileListener,iconOnlyQuery.addEventListener("change",iconOnlyListener),mobileQuery.addEventListener("change",mobileListener),this.iconOnlyMatches=iconOnlyQuery.matches,this.mobileMatches=mobileQuery.matches,!this.forced&&this.applyComputedMode(this.hasUpdated?void 0:{silent:!0})}teardownMediaQueries(){this.mqIconOnly&&this.mqIconOnlyListener&&this.mqIconOnly.removeEventListener("change",this.mqIconOnlyListener),this.mqMobile&&this.mqMobileListener&&this.mqMobile.removeEventListener("change",this.mqMobileListener),this.mqIconOnly=void 0,this.mqMobile=void 0,this.mqIconOnlyListener=void 0,this.mqMobileListener=void 0}applyComputedMode(options){this.setEffectiveMode(computeAppRailMode(this.iconOnlyMatches,this.mobileMatches,this.preferredMode),options)}setEffectiveMode(next,options){if(this._mode===next)return;const old=this._mode,resizer=this.renderRoot?.querySelector('[part="resizer"]');old==="full"&&next==="icon-only"&&resizer&&composedContains(resizer,deepActiveElement(this.ownerDocument))&&(this.recoverInlineFocusAfterResponsiveClose=!0),next!=="mobile"&&this.baseEl?.removeAttribute("data-sliding"),old==="mobile"&&next!=="mobile"&&this.open&&(this.recoverInlineFocusAfterResponsiveClose=!0),this._mode=next,this.baseEl&&(this.resizable&&this.railWidth!=null&&next==="full"||this.baseEl.style.removeProperty("inline-size")),this.requestUpdate("mode",old),options?.silent?this.pendingInitialModeAnnouncement=next:this.emit("lr-mode-change",{mode:next}),next!=="mobile"&&this.open&&this.setOpen(!1,{force:!0})}setOpen(next,options){if(this.open===next)return;if(options?.force){this.open=next,this.emit("lr-toggle",{open:next,expanded:next});return}const mode=this._mode,open=this.open;this.emit("lr-toggle-request",{open:next,expanded:next},{cancelable:!0}).defaultPrevented||this._mode!==mode||this.open!==open||(this.open=next,this.emit("lr-toggle",{open:next,expanded:next}))}toggleCollapse(){this._mode!=="mobile"&&(this.preferredMode=(this.preferredMode??this._mode)==="icon-only"?"full":"icon-only")}toggle(){this.isConnected&&(this._mode==="mobile"?this.setOpen(!this.open):this.toggleCollapse())}get resolvedHotkeyShortcuts(){const parsed=parseHotkey(this.hotkey);return hotkeyAriaKeyShortcuts(parsed&&hasNonShiftModifier(parsed)?parsed:null,detectPlatform(this.ownerDocument.defaultView?.navigator)==="mac")}syncBuiltInKeyShortcuts(){const value=this.resolvedHotkeyShortcuts;for(const control of[this.toggleEl,this.renderRoot.querySelector('[part="collapse-toggle"]')])!control||control.getAttribute("aria-keyshortcuts")===value||(value===null?control.removeAttribute("aria-keyshortcuts"):control.setAttribute("aria-keyshortcuts",value))}syncExternalTriggerA11y(){const mobile=this._mode==="mobile",trigger=mobile||this.triggerCollapses?this.resolveExternalTrigger():null;if(!trigger){this.releaseExternalTriggerA11y();return}const panel=this.baseEl??null,contribution={attributes:{"aria-expanded":(mobile?this.open:this._mode==="full")?"true":"false","aria-keyshortcuts":this.resolvedHotkeyShortcuts},controls:panel?[panel]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution)}releaseExternalTriggerA11y(){this.triggerAria?.release(),this.triggerAria=void 0}endResizerGesture(commit=!1){const ownerWindow=this.resizeOwnerWindow,changed=this.resizeGestureChanged,widthPx=this.effectiveRailWidthPx;this.resizePointerId=void 0,this.resizeOwnerWindow=void 0,this.resizeGestureChanged=!1,this.setDragging(!1),ownerWindow?.removeEventListener("pointermove",this.onResizerPointerMove),ownerWindow?.removeEventListener("pointerup",this.onResizerPointerUp),ownerWindow?.removeEventListener("pointercancel",this.onResizerPointerUp),ownerWindow?.removeEventListener("lostpointercapture",this.onResizerPointerUp),commit&&changed&&(this.emit("lr-rail-resize",{widthPx}),this.persistReady&&this.persistState())}requestRailResize(next,commit=!0){if(!this.resizable||this._mode!=="full"||!this.isConnected||next===this.effectiveRailWidthPx)return!1;const event=this.emit("lr-rail-resize-request",{widthPx:next},{cancelable:!0});return!this.resizable||this._mode!=="full"||!this.isConnected?(this.endResizerGesture(),!1):event.defaultPrevented?!1:(this.railWidth=next,commit?this.emit("lr-rail-resize",{widthPx:next}):this.resizeGestureChanged=!0,!0)}syncResizerPosition(){const resizer=this.renderRoot.querySelector('[part="resizer"]');if(!resizer||!this.baseEl||this._mode!=="full"||!this.resizable)return;const hostRect=this.getBoundingClientRect(),baseRect=this.baseEl.getBoundingClientRect(),half=resizer.getBoundingClientRect().width/2,offset=this.getAttribute("dir")==="rtl"||isRtl(this)?hostRect.right-baseRect.left:baseRect.right-hostRect.left;resizer.style.setProperty("inset-inline-start",`${offset-half}px`),resizer.style.removeProperty("inset-inline-end")}render(){const mobile=this._mode==="mobile",railWidthPx=this.effectiveRailWidthPx,showCollapse=this.collapsible&&!mobile,expanded=this._mode!=="icon-only";return this.nativeModal.render(html`
1
+ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay,collectFocusableElements,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{optionalLiteralSetConverter}from"../../../internal/converters.js";import{DeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{resolveCssLength}from"../../../internal/css-length.js";import{focusFirstAvailable}from"../../../internal/focus-navigation.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{detectPlatform}from"../../../internal/platform.js";import{parseHotkey,hasNonShiftModifier,matchesHotkey,hotkeyAriaKeyShortcuts,isIgnorableKeyEvent,isEditableKeyEventTarget,registerHotkeyOwner,unregisterHotkeyOwner,resolveHotkeyOwner}from"../../../internal/hotkey.js";import{nextId,isAccessibilityVisible}from"../../../internal/a11y.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{chevronIcon,closeIcon,menuIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{isRtl}from"../../../internal/rtl.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{definePersistedProperty,isPersistedPropertyExplicitlySet}from"../../../internal/persisted-restore.js";import{styles}from"./app-rail.styles.js";import"./app-rail-item.class.js";import{LYRA_DEFAULT_appRailCollapse,LYRA_DEFAULT_appRailExpand,LYRA_DEFAULT_closeNavigation,LYRA_DEFAULT_navigation,LYRA_DEFAULT_openNavigation,LYRA_DEFAULT_resizeNavigation,LYRA_DEFAULT_resizeValuePixels}from"../../../internal/default-strings.generated.js";const APP_RAIL_FRAME=optionalLiteralSetConverter(["card","plain"]),RAIL_WIDTH_CONVERTER={fromAttribute:value=>{if(value===null)return value;const number=Number(value);return Number.isNaN(number)?value:number}},APP_RAIL_PERSIST_FIELDS=new Set(["open","width","preferred-mode"]);function computeAppRailMode(iconOnlyMatches,mobileMatches,preferredMode){return mobileMatches?"mobile":preferredMode||(iconOnlyMatches?"icon-only":"full")}class LyraAppRail extends LyraElement{static{this.defaultStrings={...super.defaultStrings,appRailCollapse:LYRA_DEFAULT_appRailCollapse,appRailExpand:LYRA_DEFAULT_appRailExpand,closeNavigation:LYRA_DEFAULT_closeNavigation,navigation:LYRA_DEFAULT_navigation,openNavigation:LYRA_DEFAULT_openNavigation,resizeNavigation:LYRA_DEFAULT_resizeNavigation,resizeValuePixels:LYRA_DEFAULT_resizeValuePixels}}constructor(){super(),this.iconOnlyBreakpoint="960px",this.mobileBreakpoint="600px",this.triggerCollapses=!1,this.hotkey="",this.accessibleLabel=null,this.withoutToggle=!1,this.collapsible=!1,this.topLayer=!1,this.trigger=null,this.for="",this.focusFallback=null,this.resizable=!1,this.persist="open width",this.minRailWidth=190,this.maxRailWidth=440,this._dragging=!1,this.hasHeaderSlot=!1,this.hasFooterSlot=!1,this.persistReady=!1,this._mode="full",this.forced=!1,this.iconOnlyMatches=!1,this.mobileMatches=!1,this.overlayActive=!1,this.justOpened=!1,this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1)},onUnexpectedClose:()=>{this.overlayHandle?.isTopmost()&&this.setOpen(!1),this.overlayActive&&this.nativeModal.show()}}),this.overlayReturnTarget=null,this.overlayOpener=null,this.overlayReturnIsExplicit=!1,this.deferredFocusReturn=new DeferredFocusReturn,this.recoverInlineFocusAfterResponsiveClose=!1,this.navId=nextId("app-rail-nav"),this.navRegionId=nextId("app-rail-nav-region"),this.resizeStartX=0,this.resizeStartWidth=0,this.resizeGestureChanged=!1,this.managedItems=new Set,this.onIconOnlyChange=e=>{this.iconOnlyMatches=e.matches,this.forced||this.applyComputedMode()},this.onMobileChange=e=>{this.mobileMatches=e.matches,this.forced||this.applyComputedMode()},this.onToggleClick=e=>{this.open||(this.explicitTrigger=e.currentTarget),this.setOpen(!this.open)},this.onBackdropClick=()=>{this.overlayHandle?.dismissBackdrop()},this.acceptsHotkey=event=>{const parsed=parseHotkey(this.hotkey);return this.isConnected&&!this.forced&&parsed!==null&&hasNonShiftModifier(parsed)&&matchesHotkey(parsed,event,detectPlatform(this.hotkeyWindow?.navigator)==="mac")&&!isEditableKeyEventTarget(event)&&isAccessibilityVisible(this)},this.onHotkeyKeyDown=event=>{if(event.defaultPrevented||isIgnorableKeyEvent(event)||!this.hotkeyWindow)return;const keyboard=event;!this.acceptsHotkey(keyboard)||resolveHotkeyOwner(this.hotkeyWindow,keyboard)!==this||(event.preventDefault(),this.toggle())},this.onPanelTransition=event=>{event.target===event.currentTarget&&event.propertyName==="transform"&&this.baseEl?.removeAttribute("data-sliding")},this.onCollapseToggleClick=()=>{this.toggleCollapse()},this.onNavItemClick=()=>{this.overlayActive&&this.setOpen(!1)},this.onHeaderSlotChange=()=>{this.hasHeaderSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="header")},this.onFooterSlotChange=()=>{this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")},this.onNavSlotChange=()=>{this.syncSlottedItems()},this.onResizerPointerDown=e=>{if(!e.isPrimary||e.button!==0||!this.resizable||this._mode!=="full"||this.resizePointerId!==void 0)return;const resizer=e.currentTarget,ownerWindow=resizer.ownerDocument.defaultView;ownerWindow&&(this.resizePointerId=e.pointerId,this.resizeOwnerWindow=ownerWindow,this.resizeStartX=e.clientX,this.resizeStartWidth=this.effectiveRailWidthPx,this.resizeGestureChanged=!1,resizer.setPointerCapture(e.pointerId),ownerWindow.addEventListener("pointermove",this.onResizerPointerMove),ownerWindow.addEventListener("pointerup",this.onResizerPointerUp),ownerWindow.addEventListener("pointercancel",this.onResizerPointerUp),ownerWindow.addEventListener("lostpointercapture",this.onResizerPointerUp),this.setDragging(!0))},this.onResizerPointerMove=e=>{if(e.pointerId!==this.resizePointerId)return;if(!this.resizable||this._mode!=="full"){this.endResizerGesture();return}let delta=e.clientX-this.resizeStartX;isRtl(this)&&(delta=-delta);const next=Math.min(this.safeMaxRailWidthPx,Math.max(this.safeMinRailWidthPx,this.resizeStartWidth+delta));this.requestRailResize(next,!1)},this.onResizerPointerUp=e=>{e.pointerId===this.resizePointerId&&this.endResizerGesture(e.type==="pointerup")},this.onResizerKeyDown=e=>{const rtl=this.getAttribute("dir")==="rtl"||isRtl(this),forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft",step=8;if(e.key===forwardKey){const next=Math.min(this.safeMaxRailWidthPx,this.effectiveRailWidthPx+step);next!==this.effectiveRailWidthPx&&(e.preventDefault(),this.requestRailResize(next))}else if(e.key===backwardKey){const next=Math.max(this.safeMinRailWidthPx,this.effectiveRailWidthPx-step);next!==this.effectiveRailWidthPx&&(e.preventDefault(),this.requestRailResize(next))}},new GlassScrollLayer(this,'[part="base"], [part="panel"]')}static{this.knownUnobservedAttributes=["mode","dragging"]}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}get frame(){return this._frame}set frame(next){const value=APP_RAIL_FRAME.normalizeReflected(this,"frame",next),old=this._frame;value!==old&&(this._frame=value,this.requestUpdate("frame",old))}get forceMode(){return this._forceMode}set forceMode(next){if(next!=null&&next!=="auto"&&next!=="full"&&next!=="icon-only")return;const old=this._forceMode;if(this._forceMode=next??void 0,this.requestUpdate("forceMode",old),next==null||next==="auto"){if(!this.forced)return;this.forced=!1,this.applyComputedMode();return}this.forced=!0,this.setEffectiveMode(next)}static{definePersistedProperty(this.prototype,"open",{initial:!1,attribute:!0,type:Boolean,reflect:!0}),definePersistedProperty(this.prototype,"preferredMode",{initial:void 0,attribute:"preferred-mode"}),definePersistedProperty(this.prototype,"railWidth",{initial:void 0,attribute:"rail-width",converter:RAIL_WIDTH_CONVERTER})}pixelsOf(value){return typeof value=="number"?value:typeof value=="string"?resolveCssLength(value,{host:this}):void 0}get railWidthInPixels(){const width=this.railWidth;return typeof width=="string"?this.pixelsOf(width):width}get dragging(){return this._dragging}setDragging(next){this._dragging=next,this.toggleAttribute("dragging",next)}syncSlottedItems(){const slot=this.shadowRoot?.querySelector('[part="nav"] > slot'),itemTag=tag("app-rail-item"),groupTag=tag("app-rail-group"),railTag=tag("app-rail"),next=new Set((slot?.assignedElements({flatten:!0})??[]).filter(item=>item.localName===itemTag||item.localName===groupTag));for(const item of this.managedItems){if(next.has(item))continue;const newOwner=item.closest(railTag);newOwner&&newOwner!==this&&item.parentElement===newOwner&&!item.hasAttribute("slot")?item.toggleAttribute("icon-only",newOwner.mode==="icon-only"):item.removeAttribute("icon-only")}for(const item of next)item.toggleAttribute("icon-only",this._mode==="icon-only");this.managedItems=next}get mode(){return this._mode}get safeMinRailWidthPx(){return finiteRange(this.pixelsOf(this.minRailWidth)??Number.NaN,190,0)}get safeMaxRailWidthPx(){return Math.max(this.safeMinRailWidthPx,finiteRange(this.pixelsOf(this.maxRailWidth)??Number.NaN,440,0))}get effectiveRailWidthPx(){return this.railWidth!=null?finiteRange(this.railWidthInPixels??Number.NaN,this.safeMinRailWidthPx,this.safeMinRailWidthPx,this.safeMaxRailWidthPx):this.baseEl?.getBoundingClientRect().width??240}resizeValueText(widthPx){return this.localize("resizeValuePixels",void 0,{value:getNumberFormat(this.effectiveLocale).format(Math.round(widthPx))})}get storageFullKey(){return this.storageKey?`lr-app-rail:${this.storageKey}`:void 0}get persistFields(){const persist=typeof this.persist=="string"?this.persist:"";return new Set(persist.split(/\s+/).filter(field=>APP_RAIL_PERSIST_FIELDS.has(field)))}loadPersisted(){const restored={open:!1,preferredMode:!1},parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);if(!parsed)return restored;const fields=this.persistFields;return fields.has("open")&&!isPersistedPropertyExplicitlySet(this,"open")&&typeof parsed.open=="boolean"&&(this.open=parsed.open,restored.open=!0),fields.has("width")&&!isPersistedPropertyExplicitlySet(this,"railWidth")&&typeof parsed.railWidthPx=="number"&&Number.isFinite(parsed.railWidthPx)&&(this.railWidth=parsed.railWidthPx),fields.has("preferred-mode")&&!isPersistedPropertyExplicitlySet(this,"preferredMode")&&(parsed.preferredMode==="full"||parsed.preferredMode==="icon-only")&&(this.preferredMode=parsed.preferredMode,restored.preferredMode=!0),restored}persistState(){const fields=this.persistFields;if(fields.size===0)return;const state2={};fields.has("open")&&(state2.open=this.open),fields.has("width")&&(state2.railWidthPx=this.railWidthInPixels),fields.has("preferred-mode")&&(state2.preferredMode=this.preferredMode??null),writePersistedState(this.storageFullKey,state2)}willUpdate(changed){if(super.willUpdate(changed),(changed.has("resizable")||changed.has("mode"))&&(!this.resizable||this._mode!=="full")&&this.endResizerGesture(),!this.hasUpdated){this.hasHeaderSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="header"),this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer");const restored=this.loadPersisted();if(restored.preferredMode&&!this.forced){const restoredMode=computeAppRailMode(this.iconOnlyMatches,this.mobileMatches,this.preferredMode);restoredMode!==this._mode&&(this._mode=restoredMode,this.pendingInitialModeAnnouncement=restoredMode)}restored.open&&this.open&&this._mode!=="mobile"&&(this.open=!1)}if(this.hasUpdated&&(changed.has("iconOnlyBreakpoint")||changed.has("mobileBreakpoint"))&&(this.teardownMediaQueries(),this.setupMediaQueries()),this.hasUpdated&&changed.has("preferredMode")&&!this.forced&&this.applyComputedMode(),changed.has("open")||changed.has("mode")){const next=this._mode==="mobile"&&this.open;next!==this.overlayActive&&(this.hasUpdated&&this._mode==="mobile"&&!prefersReducedMotion(this)&&this.baseEl?.toggleAttribute("data-sliding",!0),this.overlayActive=next,this.placeToggle(next),next?(this.justOpened=!0,this.activateMobileOverlay()):this.deactivateMobileOverlay(this._mode==="mobile"))}}updated(changed){if(super.updated(changed),this.overlayActive&&this.nativeModal.show(),changed.has("topLayer"))for(const item of this.querySelectorAll(tag("app-rail-item")))item.syncRailTopLayer?.();if(this._lastReflectedMode!==this._mode&&(this._lastReflectedMode=this._mode,this.setAttribute("mode",this._mode)),this.pendingInitialModeAnnouncement!==void 0){const mode=this.pendingInitialModeAnnouncement;this.pendingInitialModeAnnouncement=void 0,this.emit("lr-mode-change",{mode})}if(this.syncSlottedItems(),this.placeToggle(this.overlayActive),this.syncExternalTriggerA11y(),this.syncBuiltInKeyShortcuts(),this.baseEl&&(this._mode!=="mobile"||!this.baseEl.getAnimations().some(animation=>"transitionProperty"in animation&&animation.transitionProperty==="transform"))&&this.baseEl.removeAttribute("data-sliding"),this.recoverInlineFocusAfterResponsiveClose){this.recoverInlineFocusAfterResponsiveClose=!1;const active=deepActiveElement(this.ownerDocument);this.baseEl&&!composedContains(this.baseEl,active)&&this.baseEl.focus()}this.justOpened&&(this.justOpened=!1,this.overlayHandle?.focusInitial()),this.persistReady&&(changed.has("open")||changed.has("railWidth")&&!this.dragging||changed.has("preferredMode")||changed.has("persist"))&&this.persistState(),this.persistReady=!0,this.baseEl&&(this.resizable&&this.railWidth!=null&&this._mode==="full"?this.baseEl.style.setProperty("inline-size",`${this.effectiveRailWidthPx}px`):this.baseEl.style.removeProperty("inline-size")),this.syncResizerPosition()}connectedCallback(){super.connectedCallback(),this.hotkeyWindow=this.ownerDocument.defaultView??void 0,this.hotkeyWindow&&(registerHotkeyOwner(this.hotkeyWindow,this,this.acceptsHotkey),this.hotkeyWindow.addEventListener("keydown",this.onHotkeyKeyDown)),this.setupMediaQueries(),this.hasUpdated&&this._mode==="mobile"&&this.open&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateMobileOverlay(),queueMicrotask(()=>{this.nativeModal.show(),this.overlayHandle?.focusInitial()})),this.hasUpdated&&queueMicrotask(()=>{this.isConnected&&(this.syncSlottedItems(),this.syncExternalTriggerA11y())})}disconnectedCallback(){this.nativeModal.hide(),this.hotkeyWindow&&(this.hotkeyWindow.removeEventListener("keydown",this.onHotkeyKeyDown),unregisterHotkeyOwner(this.hotkeyWindow,this),this.hotkeyWindow=void 0),this.baseEl?.removeAttribute("data-sliding"),this.deferredFocusReturn.cancel(),super.disconnectedCallback(),this.restoreFallbackTabIndex?.(),this.teardownMediaQueries(),this.overlayHandle?.suspend(),this.endResizerGesture(),this.releaseExternalTriggerA11y()}adoptedCallback(){super.adoptedCallback(),this.teardownMediaQueries(),this.endResizerGesture()}resolveExternalTrigger(){if(this.trigger)return this.trigger;if(!this.for)return null;const found=this.getRootNode().getElementById?.(this.for);return found instanceof HTMLElement?found:null}resolveFocusFallback(){const value=this.focusFallback;if(!value)return null;const target=typeof value=="string"?this.getRootNode().getElementById?.(value)??null:value;return isHtmlElement(target)&&target.ownerDocument===this.ownerDocument?target:null}activateMobileOverlay(){this.nativeModal.prepare();const explicitTrigger=this.explicitTrigger;this.explicitTrigger=void 0;const restoreFocusTo=explicitTrigger??this.resolveExternalTrigger()??void 0;this.overlayReturnIsExplicit=explicitTrigger!==void 0,this.deferredFocusReturn.cancel();const active=deepActiveElement(this.ownerDocument);this.overlayOpener=active&&typeof active.focus=="function"&&!composedContains(this,active)?active:null,this.overlayReturnTarget=restoreFocusTo??this.overlayOpener,this.overlayHandle=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.setOpen(!1),onBackdrop:()=>this.setOpen(!1),restoreFocusTo,preferredInitialFocus:()=>{const panel=this.shadowRoot?.querySelector('[part="panel"]')??null;if(!panel)return null;const toggle=this.toggleEl??null;return collectFocusableElements(panel).filter(stop=>stop!==toggle)[0]??panel},lockScroll:!0,suspendWhenUnrendered:!0})}deactivateMobileOverlay(restoreFocus=!0){this.nativeModal.hide(),this.nativeModal.prepare(!1);const handle=this.overlayHandle;if(this.overlayHandle=void 0,this.deferredFocusReturn.cancel(),handle&&restoreFocus&&!this.overlayReturnIsExplicit){const external=this.resolveExternalTrigger();external&&external!==this.overlayReturnTarget&&(this.overlayReturnTarget=external,handle.updateRestoreFocusTo(external))}handle?.deactivate({restoreFocus}),handle&&restoreFocus&&this.scheduleDeferredFocusReturn()}scheduleDeferredFocusReturn(){const candidates=[this.overlayReturnTarget,this.overlayOpener];this.deferredFocusReturn.schedule({host:this,candidates:()=>[...candidates,this.toggleEl],isCurrent:()=>!this.overlayActive,fallback:()=>{this.focusHostFallback()||focusFirstAvailable([this.resolveFocusFallback()])}})}focusHostFallback(){if(!this.hasAttribute("tabindex")){this.setAttribute("tabindex","-1");const view=this.ownerDocument.defaultView,onFocusChange=()=>{deepActiveElement(this.ownerDocument)!==this&&restore()},restore=()=>{this.removeEventListener("blur",onFocusChange),view?.removeEventListener("focus",onFocusChange),this.getAttribute("tabindex")==="-1"&&this.removeAttribute("tabindex"),this.restoreFallbackTabIndex=void 0};this.restoreFallbackTabIndex=restore,this.addEventListener("blur",onFocusChange),view?.addEventListener("focus",onFocusChange)}return focusFirstAvailable(this)?!0:(this.restoreFallbackTabIndex?.(),!1)}placeToggle(insidePanel){const toggle=this.toggleEl,panel=this.baseEl;if(!(!toggle||!panel)){if(insidePanel){panel.firstChild!==toggle&&panel.insertBefore(toggle,panel.firstChild);return}toggle.nextSibling!==panel&&panel.parentNode?.insertBefore(toggle,panel)}}setupMediaQueries(){if(!this.isConnected)return;const view=this.ownerDocument.defaultView;if(!view?.matchMedia)return;const iconOnlyQuery=view.matchMedia(`(max-width: ${this.iconOnlyBreakpoint})`),mobileQuery=view.matchMedia(`(max-width: ${this.mobileBreakpoint})`),iconOnlyListener=event=>{this.mqIconOnly!==iconOnlyQuery||!this.isConnected||this.ownerDocument.defaultView!==view||this.onIconOnlyChange(event)},mobileListener=event=>{this.mqMobile!==mobileQuery||!this.isConnected||this.ownerDocument.defaultView!==view||this.onMobileChange(event)};this.mqIconOnly=iconOnlyQuery,this.mqMobile=mobileQuery,this.mqIconOnlyListener=iconOnlyListener,this.mqMobileListener=mobileListener,iconOnlyQuery.addEventListener("change",iconOnlyListener),mobileQuery.addEventListener("change",mobileListener),this.iconOnlyMatches=iconOnlyQuery.matches,this.mobileMatches=mobileQuery.matches,!this.forced&&this.applyComputedMode(this.hasUpdated?void 0:{silent:!0})}teardownMediaQueries(){this.mqIconOnly&&this.mqIconOnlyListener&&this.mqIconOnly.removeEventListener("change",this.mqIconOnlyListener),this.mqMobile&&this.mqMobileListener&&this.mqMobile.removeEventListener("change",this.mqMobileListener),this.mqIconOnly=void 0,this.mqMobile=void 0,this.mqIconOnlyListener=void 0,this.mqMobileListener=void 0}applyComputedMode(options){this.setEffectiveMode(computeAppRailMode(this.iconOnlyMatches,this.mobileMatches,this.preferredMode),options)}setEffectiveMode(next,options){if(this._mode===next)return;const old=this._mode,resizer=this.renderRoot?.querySelector('[part="resizer"]');old==="full"&&next==="icon-only"&&resizer&&composedContains(resizer,deepActiveElement(this.ownerDocument))&&(this.recoverInlineFocusAfterResponsiveClose=!0),next!=="mobile"&&this.baseEl?.removeAttribute("data-sliding"),old==="mobile"&&next!=="mobile"&&this.open&&(this.recoverInlineFocusAfterResponsiveClose=!0),this._mode=next,this.baseEl&&(this.resizable&&this.railWidth!=null&&next==="full"||this.baseEl.style.removeProperty("inline-size")),this.requestUpdate("mode",old),options?.silent?this.pendingInitialModeAnnouncement=next:this.emit("lr-mode-change",{mode:next}),next!=="mobile"&&this.open&&this.setOpen(!1,{force:!0})}setOpen(next,options){if(this.open===next)return;if(options?.force){this.open=next,this.emit("lr-toggle",{expanded:next});return}const mode=this._mode,open=this.open;this.emit("lr-toggle-request",{expanded:next},{cancelable:!0}).defaultPrevented||this._mode!==mode||this.open!==open||(this.open=next,this.emit("lr-toggle",{expanded:next}))}toggleCollapse(){this._mode!=="mobile"&&(this.preferredMode=(this.preferredMode??this._mode)==="icon-only"?"full":"icon-only")}toggle(){this.isConnected&&(this._mode==="mobile"?this.setOpen(!this.open):this.toggleCollapse())}get resolvedHotkeyShortcuts(){const parsed=parseHotkey(this.hotkey);return hotkeyAriaKeyShortcuts(parsed&&hasNonShiftModifier(parsed)?parsed:null,detectPlatform(this.ownerDocument.defaultView?.navigator)==="mac")}syncBuiltInKeyShortcuts(){const value=this.resolvedHotkeyShortcuts;for(const control of[this.toggleEl,this.renderRoot.querySelector('[part="collapse-toggle"]')])!control||control.getAttribute("aria-keyshortcuts")===value||(value===null?control.removeAttribute("aria-keyshortcuts"):control.setAttribute("aria-keyshortcuts",value))}syncExternalTriggerA11y(){const mobile=this._mode==="mobile",trigger=mobile||this.triggerCollapses?this.resolveExternalTrigger():null;if(!trigger){this.releaseExternalTriggerA11y();return}const panel=this.baseEl??null,contribution={attributes:{"aria-expanded":(mobile?this.open:this._mode==="full")?"true":"false","aria-keyshortcuts":this.resolvedHotkeyShortcuts},controls:panel?[panel]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution)}releaseExternalTriggerA11y(){this.triggerAria?.release(),this.triggerAria=void 0}endResizerGesture(commit=!1){const ownerWindow=this.resizeOwnerWindow,changed=this.resizeGestureChanged,widthPx=this.effectiveRailWidthPx;this.resizePointerId=void 0,this.resizeOwnerWindow=void 0,this.resizeGestureChanged=!1,this.setDragging(!1),ownerWindow?.removeEventListener("pointermove",this.onResizerPointerMove),ownerWindow?.removeEventListener("pointerup",this.onResizerPointerUp),ownerWindow?.removeEventListener("pointercancel",this.onResizerPointerUp),ownerWindow?.removeEventListener("lostpointercapture",this.onResizerPointerUp),commit&&changed&&(this.emit("lr-rail-resize",{widthPx}),this.persistReady&&this.persistState())}requestRailResize(next,commit=!0){if(!this.resizable||this._mode!=="full"||!this.isConnected||next===this.effectiveRailWidthPx)return!1;const event=this.emit("lr-rail-resize-request",{widthPx:next},{cancelable:!0});return!this.resizable||this._mode!=="full"||!this.isConnected?(this.endResizerGesture(),!1):event.defaultPrevented?!1:(this.railWidth=next,commit?this.emit("lr-rail-resize",{widthPx:next}):this.resizeGestureChanged=!0,!0)}syncResizerPosition(){const resizer=this.renderRoot.querySelector('[part="resizer"]');if(!resizer||!this.baseEl||this._mode!=="full"||!this.resizable)return;const hostRect=this.getBoundingClientRect(),baseRect=this.baseEl.getBoundingClientRect(),half=resizer.getBoundingClientRect().width/2,offset=this.getAttribute("dir")==="rtl"||isRtl(this)?hostRect.right-baseRect.left:baseRect.right-hostRect.left;resizer.style.setProperty("inset-inline-start",`${offset-half}px`),resizer.style.removeProperty("inset-inline-end")}render(){const mobile=this._mode==="mobile",railWidthPx=this.effectiveRailWidthPx,showCollapse=this.collapsible&&!mobile,expanded=this._mode!=="icon-only";return this.nativeModal.render(html`
2
2
  <button
3
3
  part="toggle"
4
4
  type="button"
@@ -1,6 +1,4 @@
1
1
  import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraHeadingLevel}from'../../../internal/heading-level.js';export interface LyraAppRailGroupToggleDetail{
2
- /** @deprecated Use `expanded`, which carries the same value; removal not before 23.0.0. */
3
- open:boolean;
4
2
  /** Whether the group's content is (or, on the request, would be) shown. */
5
3
  expanded:boolean;}export interface LyraAppRailGroupEventMap{'lr-toggle-request':CustomEvent<LyraAppRailGroupToggleDetail>;'lr-toggle':CustomEvent<LyraAppRailGroupToggleDetail>;}
6
4
  /**
@@ -41,12 +39,10 @@ expanded:boolean;}export interface LyraAppRailGroupEventMap{'lr-toggle-request':
41
39
  * built-in collapse control. Call `preventDefault()` to keep the current state, or assign
42
40
  * `collapsed` from the listener to resolve it yourself — a write during the dispatch suppresses
43
41
  * the default commit even when it assigns the value the property already held. Not emitted for
44
- * a direct `collapsed` write. `detail: LyraAppRailGroupToggleDetail` — `expanded` is the
45
- * proposed state; the deprecated `open` key carries the same value.
42
+ * a direct `collapsed` write. `detail: LyraAppRailGroupToggleDetail` — `expanded` is the proposed state.
46
43
  * @event lr-toggle - The group finished expanding or collapsing. Non-cancelable, emitted after
47
44
  * `collapsed` is written, and never emitted for a vetoed or listener-resolved request.
48
- * `detail: LyraAppRailGroupToggleDetail` — `expanded` is the settled state; the deprecated
49
- * `open` key carries the same value.
45
+ * `detail: LyraAppRailGroupToggleDetail` — `expanded` is the settled state.
50
46
  * @csspart base - The `role="group"` container.
51
47
  * @csspart header - The row holding the heading and any header actions.
52
48
  * @csspart heading - The heading landmark. Carries `role="heading"` and `aria-level`.
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{tag}from"../../../internal/prefix.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{styles}from"./app-rail-group.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_expand}from"../../../internal/default-strings.generated.js";class LyraAppRailGroup extends LyraElement{constructor(){super(...arguments),this.heading="",this.headingLevel="3",this.collapsible=!1,this._collapsed=!1,this.toggleGuard=new VetoWriteGuard,this.hasHeadingSlot=!1,this.hasHeaderActionsSlot=!1,this.headingId=nextId("app-rail-group-heading"),this.contentId=nextId("app-rail-group-content"),this.onHeadingSlotChange=event=>{this.applyHeadingSlotPresence(event.target)},this.onHeaderActionsSlotChange=event=>{this.applyHeaderActionsSlotPresence(event.target)},this.onContentSlotChange=()=>{this.syncOwnedItems()},this.onToggleClick=()=>{const expanded=this._collapsed;requestThenCommit({requestDetail:{open:expanded,expanded},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.collapsed=!expanded,this.emit("lr-toggle",{open:expanded,expanded})}})}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,expand:LYRA_DEFAULT_expand}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"icon-only"]}get collapsed(){return this._collapsed}set collapsed(next){const old=this._collapsed;this._collapsed=next,markVetoGuardWrite(this.toggleGuard),this.requestUpdate("collapsed",old)}get safeHeadingLevel(){return resolveHeadingLevel(this.headingLevel)}connectedCallback(){super.connectedCallback(),this.syncOwnedItems()}attributeChangedCallback(name,oldValue,newValue){super.attributeChangedCallback(name,oldValue,newValue),!(name!=="icon-only"||oldValue===newValue)&&(this.syncOwnedItems(),this.requestUpdate())}updated(changed){super.updated(changed),this.syncOwnedItems()}firstUpdated(changed){super.firstUpdated(changed);const headingSlot=this.headingSlot,headerActionsSlot=this.headerActionsSlot;queueMicrotask(()=>{collectInitialSlotAssignment(headingSlot,s=>this.applyHeadingSlotPresence(s)),collectInitialSlotAssignment(headerActionsSlot,s=>this.applyHeaderActionsSlotPresence(s))})}syncOwnedItems(){if(!this.isConnected)return;const iconOnly=this.hasAttribute("icon-only"),groupTag=tag("app-rail-group");for(const node of this.querySelectorAll(`${tag("app-rail-item")}, ${groupTag}`))(node.parentElement?.closest(groupTag)??null)===this&&node.toggleAttribute("icon-only",iconOnly)}applyHeadingSlotPresence(slot){this.hasHeadingSlot=slot.assignedNodes().length>0&&slot.assignedNodes({flatten:!0}).length>0}applyHeaderActionsSlotPresence(slot){this.hasHeaderActionsSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}render(){const named=this.hasHeadingSlot||this.heading.trim()!=="",headingContent=html`<span part="heading-text"
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{tag}from"../../../internal/prefix.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{styles}from"./app-rail-group.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_expand}from"../../../internal/default-strings.generated.js";class LyraAppRailGroup extends LyraElement{constructor(){super(...arguments),this.heading="",this.headingLevel="3",this.collapsible=!1,this._collapsed=!1,this.toggleGuard=new VetoWriteGuard,this.hasHeadingSlot=!1,this.hasHeaderActionsSlot=!1,this.headingId=nextId("app-rail-group-heading"),this.contentId=nextId("app-rail-group-content"),this.onHeadingSlotChange=event=>{this.applyHeadingSlotPresence(event.target)},this.onHeaderActionsSlotChange=event=>{this.applyHeaderActionsSlotPresence(event.target)},this.onContentSlotChange=()=>{this.syncOwnedItems()},this.onToggleClick=()=>{const expanded=this._collapsed;requestThenCommit({requestDetail:{expanded},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.collapsed=!expanded,this.emit("lr-toggle",{expanded})}})}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,expand:LYRA_DEFAULT_expand}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"icon-only"]}get collapsed(){return this._collapsed}set collapsed(next){const old=this._collapsed;this._collapsed=next,markVetoGuardWrite(this.toggleGuard),this.requestUpdate("collapsed",old)}get safeHeadingLevel(){return resolveHeadingLevel(this.headingLevel)}connectedCallback(){super.connectedCallback(),this.syncOwnedItems()}attributeChangedCallback(name,oldValue,newValue){super.attributeChangedCallback(name,oldValue,newValue),!(name!=="icon-only"||oldValue===newValue)&&(this.syncOwnedItems(),this.requestUpdate())}updated(changed){super.updated(changed),this.syncOwnedItems()}firstUpdated(changed){super.firstUpdated(changed);const headingSlot=this.headingSlot,headerActionsSlot=this.headerActionsSlot;queueMicrotask(()=>{collectInitialSlotAssignment(headingSlot,s=>this.applyHeadingSlotPresence(s)),collectInitialSlotAssignment(headerActionsSlot,s=>this.applyHeaderActionsSlotPresence(s))})}syncOwnedItems(){if(!this.isConnected)return;const iconOnly=this.hasAttribute("icon-only"),groupTag=tag("app-rail-group");for(const node of this.querySelectorAll(`${tag("app-rail-item")}, ${groupTag}`))(node.parentElement?.closest(groupTag)??null)===this&&node.toggleAttribute("icon-only",iconOnly)}applyHeadingSlotPresence(slot){this.hasHeadingSlot=slot.assignedNodes().length>0&&slot.assignedNodes({flatten:!0}).length>0}applyHeaderActionsSlotPresence(slot){this.hasHeaderActionsSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}render(){const named=this.hasHeadingSlot||this.heading.trim()!=="",headingContent=html`<span part="heading-text"
2
2
  ><slot name="heading" @slotchange=${this.onHeadingSlotChange}
3
3
  >${this.hasHeadingSlot?nothing:this.heading}</slot
4
4
  ></span
@@ -90,10 +90,7 @@ get currentSlide():number;set currentSlide(value:number);loop:boolean;autoplay:b
90
90
  get pagination():boolean;set pagination(value:boolean);orientation:LyraCarouselOrientation;mouseDragging:boolean;slidesPerPage:number;slidesPerMove:number;
91
91
  /** Live count of assigned slides.
92
92
  * @default 0 */
93
- get slides():number;private legacyAccessibleLabel;
94
- /** Compatibility fallback below the host aria-label, including an explicitly empty host value.
95
- * @deprecated Use the host aria-label attribute or the native ariaLabel property. */
96
- get accessibleLabel():string|undefined;set accessibleLabel(value:string|undefined);private hostAccessibleLabel;private slideSlot?;private viewport?;private scrollHintProbe?;private beforeClones?;private afterClones?;private timer?;private timerWindow?;private reduceMotion;private stopMotionWatch?;private visibilityDocument?;private readonly snapshots;private readonly appliedSnapshots;
93
+ get slides():number;private hostAccessibleLabel;private slideSlot?;private viewport?;private scrollHintProbe?;private beforeClones?;private afterClones?;private timer?;private timerWindow?;private reduceMotion;private stopMotionWatch?;private visibilityDocument?;private readonly snapshots;private readonly appliedSnapshots;
97
94
  /** The scroll-settle debounce: every `scroll` event restarts it, and the slide the viewport came
98
95
  * to rest on is published once the stream goes quiet. Scheduled on -- and cancelled through --
99
96
  * the realm this carousel lives in at the time, so one adopted into another document neither
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{prefersReducedMotion}from"../../../internal/motion.js";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{isAccessibilitySubtreeExcluded,isAccessibilityVisible,isAccessibilityVisibilityHidden}from"../../../internal/accessibility-visibility.js";import{activeElementIn,deepActiveElementIn}from"../../../internal/active-element.js";import{composedAccessibilityText}from"../../../internal/announcement-text.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{warnDeprecatedUsage}from"../../../internal/dev-mode-attribute-warning.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteDuration,finiteInteger}from"../../../internal/numbers.js";import{DebounceController}from"../../../internal/debounce-controller.js";import{composedContains}from"../../../internal/overlay-manager.js";import{SlottedOverlayController}from"../../../internal/slotted-overlay-controller.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./carousel.styles.js";import{LYRA_DEFAULT_carousel,LYRA_DEFAULT_carouselGoTo,LYRA_DEFAULT_carouselIndicators,LYRA_DEFAULT_carouselLabel,LYRA_DEFAULT_carouselSlide,LYRA_DEFAULT_carouselSlideAnnouncement,LYRA_DEFAULT_carouselSlideAnnouncementSeparator,LYRA_DEFAULT_carouselSlidePosition,LYRA_DEFAULT_next,LYRA_DEFAULT_previous}from"../../../internal/default-strings.generated.js";const SCROLL_SETTLE_MS=120,LOOP_SNAPSHOT_UNSAFE_TAGS=new Set(["audio","canvas","embed","form","iframe","img","input","link","object","picture","script","select","source","style","textarea","track","video"]),CAROUSEL_MANAGED_SLIDE_ATTRIBUTES=new Set(["aria-hidden","aria-label","aria-roledescription","hidden","inert","role"]),SLIDE_SNAPSHOT_KEYS=["hidden","inert","role","label","roleDescription","ariaHidden"];class LyraCarousel extends LyraElement{static{this.defaultStrings={...super.defaultStrings,carousel:LYRA_DEFAULT_carousel,carouselGoTo:LYRA_DEFAULT_carouselGoTo,carouselIndicators:LYRA_DEFAULT_carouselIndicators,carouselLabel:LYRA_DEFAULT_carouselLabel,carouselSlide:LYRA_DEFAULT_carouselSlide,carouselSlideAnnouncement:LYRA_DEFAULT_carouselSlideAnnouncement,carouselSlideAnnouncementSeparator:LYRA_DEFAULT_carouselSlideAnnouncementSeparator,carouselSlidePosition:LYRA_DEFAULT_carouselSlidePosition,next:LYRA_DEFAULT_next,previous:LYRA_DEFAULT_previous}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"currentslide"])]}get currentSlide(){return this._currentSlide}set currentSlide(value){this.setCurrentSlideState(value)}get pagination(){return this._pagination}set pagination(value){this.setPaginationState(!!value)}get slides(){return this._slides}get accessibleLabel(){return this.legacyAccessibleLabel}set accessibleLabel(value){warnDeprecatedUsage(this,"property","accessibleLabel","aria-label"),this.legacyAccessibleLabel=value}constructor(){super(),this._currentSlide=0,this._pagination=!1,this._slides=0,this.loop=!1,this.autoplay=!1,this.autoplayInterval=3e3,this.navigation=!1,this.orientation="horizontal",this.mouseDragging=!1,this.slidesPerPage=1,this.slidesPerMove=1,this.legacyAccessibleLabel=void 0,this.hostAccessibleLabel=null,this.reduceMotion=!1,this.snapshots=new Map,this.appliedSnapshots=new WeakMap,this.scrollSettle=new DebounceController(SCROLL_SETTLE_MS,()=>this.settleScrolledSlide(),()=>this.ownerDocument.defaultView),this.adoptingScrolledSlide=!1,this.hasAlignedOnce=!1,this.loopClonesDirty=!0,this.pointerInteracting=!1,this.focusInteracting=!1,this.slideOverlay=new SlottedOverlayController(this,()=>this.renderRoot?.querySelector("slot:not([name])")),this.slideOverlayWasOpen=!1,this.dragStartCoordinate=0,this.dragStartScroll=0,this.dragMoved=!1,this.suppressClick=!1,this.announcementsArmed=!1,this.changeOrigin="manual",this.manualPending=!1,this.observerGeneration=0,this.onMotionPreferenceChange=reduced=>{this.reduceMotion=reduced,this.restartAutoplay(),this.requestUpdate()},this.onVisibilityChange=()=>{this.restartAutoplay()},this.onSlotChange=()=>{this.handleSlidesChanged()},this.onViewportScroll=()=>{this.cancelScrollSettle(),this.ownerDocument.defaultView&&this.scrollSettle.push(void 0)},this.onViewportScrollEnd=()=>{this.cancelScrollSettle(),this.settleScrolledSlide()},this.settleScrolledSlide=()=>{if(!this.isConnected)return;const viewport=this.viewport;if(!viewport)return;if(this.alignTarget){if(Math.abs(this.axisOffsetOf(this.alignTarget,viewport))>2)return;const cloneSide=this.alignTarget.dataset.carouselClone;if(cloneSide==="before"||cloneSide==="after"){const realSlide=this.slideElements()[this.alignIndex??-1];if(realSlide){this.alignTarget=realSlide,this.scrollByAxis(viewport,this.axisOffsetOf(realSlide,viewport),"instant");return}}this.clearAlignment();return}const resting=this.restingSlide();if(!resting)return;const changed=resting.index!==this.currentSlide;!changed&&!resting.cloneSide||(this.adoptingScrolledSlide=!0,changed&&(this.currentSlide=resting.index,this.emit("lr-slide-change",{index:resting.index,slide:this.slideElements()[resting.index]})),this.updateComplete.then(()=>{if(resting.cloneSide&&this.isConnected&&this.viewport){const realSlide=this.slideElements()[resting.index];realSlide&&this.scrollByAxis(this.viewport,this.axisOffsetOf(realSlide,this.viewport),"instant")}this.adoptingScrolledSlide=!1}))},this.onViewportPointerEnter=()=>{this.pointerInteracting=!0,this.restartAutoplay()},this.onViewportPointerLeave=()=>{this.dragPointerId===void 0&&(this.pointerInteracting=!1,this.restartAutoplay())},this.onViewportFocusIn=event=>{this.focusInteracting=!0;const slides=new Set(this.slideElements()),focusedSlide=event.composedPath().find(candidate=>candidate.nodeType===1&&slides.has(candidate));focusedSlide&&(this.lastFocusedSlide=focusedSlide),this.restartAutoplay()},this.onViewportFocusOut=()=>{this.queueOwnerMicrotask(()=>{if(!this.isConnected)return;const active=deepActiveElementIn(this.ownerDocument);this.lastFocusedSlide&&!composedContains(this.lastFocusedSlide,active)&&(this.lastFocusedSlide.isConnected||active!==null&&active!==this.ownerDocument.body)&&(this.lastFocusedSlide=void 0),this.focusInteracting=this.matches(":focus-within"),this.restartAutoplay()})},this.onViewportPointerDown=event=>{if(!this.mouseDragging||event.pointerType!=="mouse"||!event.isPrimary||event.button!==0||this.dragPointerId!==void 0||this.targetsInteractiveContent(event))return;this.takeOverViewport();const viewport=this.viewport;if(viewport){this.dragPointerId=event.pointerId,this.dragStartCoordinate=this.effectiveOrientation()==="vertical"?event.clientY:event.clientX,this.dragStartScroll=this.effectiveOrientation()==="vertical"?viewport.scrollTop:viewport.scrollLeft,this.dragMoved=!1,viewport.setAttribute("data-dragging","");try{viewport.setPointerCapture(event.pointerId)}catch{}this.restartAutoplay()}},this.onViewportPointerMove=event=>{if(event.pointerId!==this.dragPointerId)return;const viewport=this.viewport;if(!viewport)return;const delta=(this.effectiveOrientation()==="vertical"?event.clientY:event.clientX)-this.dragStartCoordinate;Math.abs(delta)>2&&(this.dragMoved=!0),this.dragMoved&&(event.preventDefault(),this.effectiveOrientation()==="vertical"?viewport.scrollTo({top:this.dragStartScroll-delta,behavior:"instant"}):viewport.scrollTo({left:this.dragStartScroll-delta,behavior:"instant"}))},this.onViewportPointerUp=event=>{this.finishDrag(event.pointerId,!1)},this.onViewportPointerCancel=event=>{this.finishDrag(event.pointerId,!0)},this.onViewportLostPointerCapture=event=>{this.finishDrag(event.pointerId,!0)},this.onViewportClick=event=>{this.suppressClick&&(event.preventDefault(),event.stopImmediatePropagation())},this.onViewportKeyDown=event=>{if(this.targetsInteractiveContent(event,!0))return;const vertical=this.effectiveOrientation()==="vertical",rtl=this.effectiveDirection==="rtl",forwardKey=vertical?"ArrowDown":rtl?"ArrowLeft":"ArrowRight",backwardKey=vertical?"ArrowUp":rtl?"ArrowRight":"ArrowLeft";event.key===forwardKey?(event.preventDefault(),this.next()):event.key===backwardKey?(event.preventDefault(),this.previous()):event.key==="Home"?(event.preventDefault(),this.goToSlide(0)):event.key==="End"&&(event.preventDefault(),this.goToSlide(this.loop?this.slideElements().length-1:this.maxStartIndex()))},this.requestUpdate("currentSlide",void 0),this.requestUpdate("pagination",void 0)}attributeChangedCallback(name,oldValue,newValue){if(name==="currentslide"){oldValue!==newValue&&(this.currentSlide=finiteInteger(Number(newValue??0),0));return}super.attributeChangedCallback(name,oldValue,newValue),name==="current-slide"&&newValue===null&&oldValue!==newValue&&this.hasAttribute("currentslide")&&(this.currentSlide=finiteInteger(Number(this.getAttribute("currentslide")??0),0))}connectedCallback(){this.hasAttribute("current-slide")&&(this.currentSlide=finiteInteger(Number(this.getAttribute("current-slide")??0),0)),super.connectedCallback(),this.announcementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.announcementsArmed=!1,this.manualPending=!1,this.reduceMotion=prefersReducedMotion(this),this.stopMotionWatch=observeReducedMotion(this,this.onMotionPreferenceChange),this.visibilityDocument=this.ownerDocument,this.visibilityDocument.addEventListener("visibilitychange",this.onVisibilityChange),this.armSlideContentObserver(),this.restartAutoplay(),this.hasUpdated&&this.queueOwnerMicrotask(()=>{this.isConnected&&this.handleSlidesChanged()})}disconnectedCallback(){this.announcementSink?.release(),this.announcementSink=void 0,this.announcementsArmed=!1,this.manualPending=!1,this.cancelDrag(!1),this.stopAutoplay(),this.cancelScrollSettle(),this.cancelClickSuppression(),this.suppressClick=!1,this.pointerInteracting=!1,this.focusInteracting=!1,this.hasAlignedOnce=!1,this.clearAlignment(),this.stopMotionWatch?.(),this.stopMotionWatch=void 0,this.visibilityDocument?.removeEventListener("visibilitychange",this.onVisibilityChange),this.visibilityDocument=void 0,this.resetSlideContentObserver(),this.restoreSlides(),this.lastFocusedSlide=void 0,super.disconnectedCallback()}armSlideContentObserver(){const ownerDocument=this.ownerDocument,MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor||!this.isConnected)return;this.resetSlideContentObserver();const generation=this.observerGeneration,observer=new MutationObserverCtor(records=>{this.observer!==observer||this.observerDocument!==ownerDocument||this.observerGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||!records.some(record=>{if(record.type!=="attributes")return!0;if(record.target===this)return!1;if(!CAROUSEL_MANAGED_SLIDE_ATTRIBUTES.has(record.attributeName??""))return!0;const slide=record.target,snapshot=this.snapshots.get(slide);return snapshot?this.adoptChanges(slide,snapshot):!1})||(this.loop&&(this.loopClonesDirty=!0),this.syncSlides(),this.requestUpdate())});this.observer=observer,this.observerDocument=ownerDocument,observer.observe(this,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}resetSlideContentObserver(){this.observerGeneration+=1,this.observer?.disconnect(),this.observer=void 0,this.observerDocument=void 0}willUpdate(changed){if(super.willUpdate(changed),(changed.has("currentSlide")||changed.has("slidesPerPage"))&&this.slideSlot){const normalized=this.normalizedIndex();if(this.currentSlide!==normalized){const forcedBySibling=changed.has("slidesPerPage")&&!changed.has("currentSlide");if(this.currentSlide=normalized,forcedBySibling){const slide=this.slideElements()[normalized];slide&&this.emit("lr-slide-change",{index:normalized,slide})}}}}firstUpdated(changed){super.firstUpdated(changed);const slot=this.slideSlot;this.queueOwnerMicrotask(()=>{collectInitialSlotAssignment(slot,()=>this.handleSlidesChanged())})}updated(changed){super.updated(changed);const shouldAnnounceActivePage=this.announcementsArmed&&(this.manualPending||changed.has("slidesPerPage"));this.slideOverlay.open!==this.slideOverlayWasOpen&&(this.slideOverlayWasOpen=this.slideOverlay.open,this.restartAutoplay()),this.syncSlides(),(this.loopClonesDirty||changed.has("loop")||changed.has("slidesPerPage")||changed.has("slidesPerMove"))&&(this.syncLoopClones(),this.loopClonesDirty=!1),(changed.has("autoplay")||changed.has("autoplayInterval")||changed.has("loop")||changed.has("slidesPerPage"))&&this.restartAutoplay(),!this.adoptingScrolledSlide&&(changed.has("currentSlide")||changed.has("slidesPerPage")||changed.has("orientation")||!this.hasAlignedOnce)&&this.alignToActiveSlide(),this.hasAlignedOnce=!0,shouldAnnounceActivePage&&this.announceActivePage(),this.manualPending=!1,this.announcementsArmed=!0}setCurrentSlideState(value){const old=this._currentSlide,next=finiteInteger(value,0);old!==next&&(this._currentSlide=next,this.changeOrigin==="manual"&&(this.manualPending=!0),this.requestUpdate("currentSlide",old))}setPaginationState(value){const old=this._pagination;old!==value&&(this._pagination=value,this.requestUpdate("pagination",old))}queueOwnerMicrotask(callback){const view=this.ownerDocument.defaultView;view?view.queueMicrotask(callback):queueMicrotask(callback)}effectiveOrientation(){return this.orientation==="vertical"?"vertical":"horizontal"}slideElements(){return(this.slideSlot?.assignedElements({flatten:!0})??[]).filter(element=>element.nodeType===1&&element.namespaceURI==="http://www.w3.org/1999/xhtml")}pageSize(count=this.slideElements().length){return finiteInteger(this.slidesPerPage,1,1,Math.max(1,count))}moveSize(count=this.slideElements().length){return finiteInteger(this.slidesPerMove,1,1,this.pageSize(count))}maxStartIndex(count=this.slideElements().length){return Math.max(0,count-this.pageSize(count))}normalizedIndex(count=this.slideElements().length){if(count===0)return 0;const max=this.loop?count-1:this.maxStartIndex(count);return finiteInteger(this.currentSlide,0,0,max)}pageTargets(count=this.slideElements().length){if(count===0)return[];if(this.loop)return Array.from({length:count},(_unused,index)=>index);const max=this.maxStartIndex(count),move=this.moveSize(count),targets=[0];for(let target=move;target<max;target+=move)targets.push(target);return max>0&&targets.at(-1)!==max&&targets.push(max),targets}visibleIndices(count,current){const visible=new Set,perPage=this.pageSize(count);for(let offset=0;offset<perPage;offset+=1){const index=this.loop?(current+offset)%count:current+offset;index>=0&&index<count&&visible.add(index)}return visible}announceActivePage(){if(!isAccessibilityVisible(this))return;const slides=this.slideElements();if(slides.length===0)return;const current=this.normalizedIndex(slides.length),visible=this.visibleIndices(slides.length,current),format=getNumberFormat(this.effectiveLocale),messages=slides.flatMap((slide,index)=>{if(!visible.has(index))return[];if(isAccessibilitySubtreeExcluded(slide))return[];const slideTextVisible=!isAccessibilityVisibilityHidden(slide),authoredLabel=slideTextVisible?this.snapshots.get(slide)?.label?.trim():"";if(authoredLabel)return[authoredLabel];const position=this.localize("carouselSlidePosition",void 0,{index:format.format(index+1),total:format.format(slides.length)}),content=Array.from(slide.childNodes).map(node=>composedAccessibilityText(node,slideTextVisible)).join(" ").replace(/\s+/g," ").trim();return!slideTextVisible&&!content?[]:[content&&content!==position?this.localize("carouselSlideAnnouncement",void 0,{position,content}):position]});this.announcementSink?.announce(messages.join(this.localize("carouselSlideAnnouncementSeparator")))}restoreAttribute(slide,name,value){value===null?slide.removeAttribute(name):slide.setAttribute(name,value)}snapshotSlide(slide){return{hidden:slide.hidden,inert:slide.inert,role:slide.getAttribute("role"),label:slide.getAttribute("aria-label"),roleDescription:slide.getAttribute("aria-roledescription"),ariaHidden:slide.getAttribute("aria-hidden")}}adoptChanges(slide,snapshot){const applied=this.appliedSnapshots.get(slide);if(!applied)return!1;const current=this.snapshotSlide(slide);let changed=!1;for(const key of SLIDE_SNAPSHOT_KEYS)current[key]!==applied[key]&&(snapshot[key]=current[key],changed=!0);return changed}restoreSlide(slide,snapshot){slide.hidden=snapshot.hidden,slide.inert=snapshot.inert,this.restoreAttribute(slide,"role",snapshot.role),this.restoreAttribute(slide,"aria-label",snapshot.label),this.restoreAttribute(slide,"aria-roledescription",snapshot.roleDescription),this.restoreAttribute(slide,"aria-hidden",snapshot.ariaHidden)}restoreSlides(){for(const[slide,snapshot]of this.snapshots)this.adoptChanges(slide,snapshot),this.restoreSlide(slide,snapshot);this.snapshots.clear()}syncSlides(){const slides=this.slideElements(),assigned=new Set(slides);for(const[slide,snapshot]of this.snapshots)this.adoptChanges(slide,snapshot)&&(this.loopClonesDirty=!0),assigned.has(slide)||(this.restoreSlide(slide,snapshot),this.snapshots.delete(slide));const current=this.normalizedIndex(slides.length);if(this.currentSlide!==current){this.currentSlide=current;const slide=slides[current];slide&&this.emit("lr-slide-change",{index:current,slide})}const visible=this.visibleIndices(slides.length,current);this.repairFocusBeforeSlideExclusion(slides,visible);const format=getNumberFormat(this.effectiveLocale);slides.forEach((slide,slideIndex)=>{const existing=this.snapshots.get(slide),snapshot=existing??this.snapshotSlide(slide);existing||this.snapshots.set(slide,snapshot),slide.localName===tag("carousel-item")?(this.restoreAttribute(slide,"role",snapshot.role??"group"),this.restoreAttribute(slide,"aria-roledescription",snapshot.roleDescription??this.localize("carouselSlide")),this.restoreAttribute(slide,"aria-label",snapshot.label??this.localize("carouselSlidePosition",void 0,{index:format.format(slideIndex+1),total:format.format(slides.length)}))):(this.restoreAttribute(slide,"role",snapshot.role),this.restoreAttribute(slide,"aria-roledescription",snapshot.roleDescription),this.restoreAttribute(slide,"aria-label",snapshot.label)),slide.hidden=snapshot.hidden,visible.has(slideIndex)?(slide.inert=snapshot.inert,this.restoreAttribute(slide,"aria-hidden",snapshot.ariaHidden)):(slide.inert=!0,slide.setAttribute("aria-hidden","true")),this.appliedSnapshots.set(slide,this.snapshotSlide(slide))})}repairFocusBeforeSlideExclusion(slides,visible){const active=deepActiveElementIn(this.ownerDocument),focusedIndex=slides.findIndex(slide=>composedContains(slide,active)),focusedSlideWillBeExcluded=focusedIndex>=0&&!visible.has(focusedIndex),focusedSlideWasRemoved=focusedIndex<0&&this.lastFocusedSlide!==void 0&&!this.lastFocusedSlide.isConnected&&(active===null||active===this.ownerDocument.body);!focusedSlideWillBeExcluded&&!focusedSlideWasRemoved||(this.viewport?.focus(),this.lastFocusedSlide=void 0)}handleSlidesChanged(){const count=this.slideElements().length,active=activeElementIn(this.shadowRoot);if(active?.matches('[part~="pagination-item"]')){const children=active.parentElement.children,pages=this.pageTargets(count).length;(pages<2||[...children].indexOf(active)>=pages)&&(pages>1?children[pages-1]:this.viewport)?.focus()}else active?.matches('[part~="navigation-button"]')&&(!this.navigation||count<=this.pageSize(count))&&this.viewport?.focus();if(this._slides!==count){const previous=this._slides;this._slides=count,this.requestUpdate("slides",previous)}this.loopClonesDirty=!0,this.syncSlides(),this.syncLoopClones(),this.loopClonesDirty=!1,this.restartAutoplay(),this.requestUpdate()}prepareClone(original,index,side){if([original,...Array.from(original.querySelectorAll("*"))].some(element=>element.namespaceURI!=="http://www.w3.org/1999/xhtml"||element.localName.includes("-")||LOOP_SNAPSHOT_UNSAFE_TAGS.has(element.localName)))return;const clone=original.cloneNode(!0),descendants=[clone,...Array.from(clone.querySelectorAll("*"))];for(const descendant of descendants)descendant.removeAttribute("id"),descendant.removeAttribute("name"),descendant.removeAttribute("form"),descendant.removeAttribute("for"),descendant.removeAttribute("aria-controls"),descendant.removeAttribute("aria-describedby"),descendant.removeAttribute("aria-labelledby");return clone.removeAttribute("slot"),clone.dataset.carouselClone=side,clone.dataset.carouselIndex=String(index),clone.inert=!0,clone.setAttribute("aria-hidden","true"),clone}syncLoopClones(){const before=this.beforeClones,after=this.afterClones;if(!before||!after)return;before.replaceChildren(),after.replaceChildren();const slides=this.slideElements();if(!this.loop||slides.length<2)return;const cloneCount=Math.min(slides.length,Math.max(this.pageSize(slides.length),this.moveSize(slides.length))),beforeStart=slides.length-cloneCount;for(let index=beforeStart;index<slides.length;index+=1){const clone=this.prepareClone(slides[index],index,"before");clone&&before.append(clone)}for(let index=0;index<cloneCount;index+=1){const clone=this.prepareClone(slides[index],index,"after");clone&&after.append(clone)}}cloneFor(side,index){return(side==="before"?this.beforeClones:this.afterClones)?.querySelector(`[data-carousel-index="${index}"]`)??void 0}changeTo(index,behavior="smooth",origin="manual"){const slides=this.slideElements(),count=slides.length;if(count===0||!Number.isFinite(index))return;const requested=Math.trunc(index);let next,loopSide;if(this.loop?(next=(requested%count+count)%count,requested<0?loopSide="before":requested>=count&&(loopSide="after")):next=Math.min(this.maxStartIndex(count),Math.max(0,requested)),next===this.currentSlide)return;this.requestedBehavior=behavior,this.loopSide=loopSide;const previousOrigin=this.changeOrigin;this.changeOrigin=origin;try{this.currentSlide=next}finally{this.changeOrigin=previousOrigin}this.emit("lr-slide-change",{index:next,slide:slides[next]})}next(behavior="smooth"){this.changeTo(this.currentSlide+this.moveSize(),behavior)}previous(behavior="smooth"){this.changeTo(this.currentSlide-this.moveSize(),behavior)}goToSlide(index,behavior="smooth"){this.changeTo(index,behavior)}addSlide(slide){slide?.nodeType!==1||slide?.namespaceURI!=="http://www.w3.org/1999/xhtml"||(this.append(slide),this.queueOwnerMicrotask(()=>{this.isConnected&&this.handleSlidesChanged()}))}removeSlide(index){if(!Number.isFinite(index))return;const target=this.slideElements()[Math.trunc(index)];target&&(target.remove(),this.queueOwnerMicrotask(()=>{this.isConnected&&this.handleSlidesChanged()}))}stopAutoplay(){this.timer!==void 0&&this.timerWindow?.clearInterval(this.timer),this.timer=void 0,this.timerWindow=void 0}restartAutoplay(){this.stopAutoplay();const count=this.slideElements().length,doc=this.visibilityDocument??this.ownerDocument,view=doc.defaultView;if(!this.isConnected||!view||!this.autoplay||this.reduceMotion||this.pointerInteracting||this.focusInteracting||this.slideOverlay.open||this.dragPointerId!==void 0||doc.visibilityState!=="visible"||count<=this.pageSize(count))return;const interval=finiteDuration(this.autoplayInterval,3e3,1e3);this.timerWindow=view,this.timer=view.setInterval(()=>{this.loop||this.currentSlide<this.maxStartIndex()?this.changeTo(this.currentSlide+this.moveSize(),"smooth","autoplay"):this.stopAutoplay()},interval)}scrollPaddingStart(){const rect=this.scrollHintProbe?.getBoundingClientRect();if(!rect)return 0;const pixels=this.effectiveOrientation()==="vertical"?rect.height:rect.width;return Number.isFinite(pixels)?pixels:0}axisOffsetOf(slide,viewport){const viewportRect=viewport.getBoundingClientRect(),slideRect=slide.getBoundingClientRect(),padding=this.scrollPaddingStart();return this.effectiveOrientation()==="vertical"?slideRect.top-(viewportRect.top+padding):this.effectiveDirection==="rtl"?slideRect.right-(viewportRect.right-padding):slideRect.left-(viewportRect.left+padding)}scrollByAxis(viewport,distance,behavior){this.effectiveOrientation()==="vertical"?viewport.scrollBy({top:distance,behavior}):viewport.scrollBy({left:distance,behavior})}restingSlide(){const viewport=this.viewport,slides=this.slideElements();if(!viewport||slides.length===0)return;const candidates=slides.map((element,index)=>({element,index}));for(const clone of this.shadowRoot?.querySelectorAll("[data-carousel-clone]")??[]){const index=Number(clone.dataset.carouselIndex),cloneSide=clone.dataset.carouselClone;Number.isInteger(index)&&index>=0&&index<slides.length&&(cloneSide==="before"||cloneSide==="after")&&candidates.push({element:clone,index,cloneSide})}let nearest,nearestDistance=Number.POSITIVE_INFINITY;for(const candidate of candidates){const distance=Math.abs(this.axisOffsetOf(candidate.element,viewport));distance<nearestDistance&&(nearestDistance=distance,nearest=candidate)}return nearest}alignToActiveSlide(){const viewport=this.viewport,targetIndex=this.normalizedIndex(),realSlide=this.slideElements()[targetIndex];if(!viewport||!realSlide)return;const loopSide=this.loopSide,requestedBehavior=this.requestedBehavior;this.loopSide=void 0,this.requestedBehavior=void 0;const target=loopSide?this.cloneFor(loopSide,targetIndex)??realSlide:realSlide,offset=this.axisOffsetOf(target,viewport);if(Math.round(offset)===0){this.clearAlignment();return}this.alignIndex=targetIndex,this.alignTarget=target;const behavior=this.motionAwareScrollBehavior(requestedBehavior??"smooth",!0);this.scrollByAxis(viewport,offset,behavior)}motionAwareScrollBehavior(requested,instantBeforeFirstAlignment=!1){return this.reduceMotion||instantBeforeFirstAlignment&&!this.hasAlignedOnce?"instant":requested}cancelScrollSettle(){this.scrollSettle.cancel()}clearAlignment(){this.alignTarget=void 0,this.alignIndex=void 0,this.loopSide=void 0,this.requestedBehavior=void 0}takeOverViewport(){this.clearAlignment()}targetsInteractiveContent(event,includeSlideEditors=!1){const slides=new Set(this.slideElements());for(const target of event.composedPath()){if(!(target instanceof Element))continue;const slideRoot=slides.has(target);if(target===this||target===this.viewport||slideRoot&&!includeSlideEditors)continue;const name=target.localName;if(name==="a"||name==="button"||name==="input"||name==="label"||name==="select"||name==="textarea"||target.hasAttribute("contenteditable")||!slideRoot&&name.includes("-")&&target.getRootNode()!==this.shadowRoot)return!0;const role=target.getAttribute("role")?.trim().toLowerCase();if(role&&["button","checkbox","combobox","link","radio","slider","spinbutton","switch","textbox"].includes(role))return!0}return!1}finishDrag(pointerId,canceled){if(pointerId!==this.dragPointerId)return;const viewport=this.viewport,moved=this.dragMoved;if(this.dragPointerId=void 0,this.dragMoved=!1,viewport?.removeAttribute("data-dragging"),viewport?.hasPointerCapture(pointerId))try{viewport.releasePointerCapture(pointerId)}catch{}if(moved){this.suppressClick=!0,this.cancelClickSuppression();const view=this.ownerDocument.defaultView;view?(this.clickTimerWindow=view,this.clickTimer=view.setTimeout(()=>{this.suppressClick=!1,this.clickTimer=void 0,this.clickTimerWindow=void 0},0)):this.suppressClick=!1}if(canceled&&viewport){const active=this.slideElements()[this.normalizedIndex()];active&&this.scrollByAxis(viewport,this.axisOffsetOf(active,viewport),this.motionAwareScrollBehavior("smooth"))}else canceled||this.onViewportScroll();this.matches(":hover")||(this.pointerInteracting=!1),this.restartAutoplay()}cancelClickSuppression(){this.clickTimer!==void 0&&this.clickTimerWindow?.clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickTimerWindow=void 0}cancelDrag(realign){this.dragPointerId!==void 0&&this.finishDrag(this.dragPointerId,realign)}computedSlideBasis(perPage){return perPage===1?"100%":`calc((100% - (${perPage-1} * var(--slide-gap, var(--lr-space-m)))) / ${perPage})`}render(){const count=this.slideElements().length,current=this.normalizedIndex(count),pageTargets=this.pageTargets(count),exactCurrentPage=pageTargets.indexOf(current),currentPage=exactCurrentPage>=0?exactCurrentPage:pageTargets.reduce((nearest,target,pageIndex)=>Math.abs(target-current)<Math.abs(pageTargets[nearest]-current)?pageIndex:nearest,0),hasNavigation=this.navigation&&count>this.pageSize(count),hasPagination=this.pagination&&pageTargets.length>1,label=this.hostAccessibleLabel!==null?this.hostAccessibleLabel:this.accessibleLabel==null?this.localize("carouselLabel"):this.accessibleLabel,numberFormat=getNumberFormat(this.effectiveLocale),orientation=this.effectiveOrientation(),perPage=this.pageSize(count);return html`<section
1
+ import{__decorate}from"tslib";import{prefersReducedMotion}from"../../../internal/motion.js";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{isAccessibilitySubtreeExcluded,isAccessibilityVisible,isAccessibilityVisibilityHidden}from"../../../internal/accessibility-visibility.js";import{activeElementIn,deepActiveElementIn}from"../../../internal/active-element.js";import{composedAccessibilityText}from"../../../internal/announcement-text.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteDuration,finiteInteger}from"../../../internal/numbers.js";import{DebounceController}from"../../../internal/debounce-controller.js";import{composedContains}from"../../../internal/overlay-manager.js";import{SlottedOverlayController}from"../../../internal/slotted-overlay-controller.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./carousel.styles.js";import{LYRA_DEFAULT_carousel,LYRA_DEFAULT_carouselGoTo,LYRA_DEFAULT_carouselIndicators,LYRA_DEFAULT_carouselLabel,LYRA_DEFAULT_carouselSlide,LYRA_DEFAULT_carouselSlideAnnouncement,LYRA_DEFAULT_carouselSlideAnnouncementSeparator,LYRA_DEFAULT_carouselSlidePosition,LYRA_DEFAULT_next,LYRA_DEFAULT_previous}from"../../../internal/default-strings.generated.js";const SCROLL_SETTLE_MS=120,LOOP_SNAPSHOT_UNSAFE_TAGS=new Set(["audio","canvas","embed","form","iframe","img","input","link","object","picture","script","select","source","style","textarea","track","video"]),CAROUSEL_MANAGED_SLIDE_ATTRIBUTES=new Set(["aria-hidden","aria-label","aria-roledescription","hidden","inert","role"]),SLIDE_SNAPSHOT_KEYS=["hidden","inert","role","label","roleDescription","ariaHidden"];class LyraCarousel extends LyraElement{static{this.defaultStrings={...super.defaultStrings,carousel:LYRA_DEFAULT_carousel,carouselGoTo:LYRA_DEFAULT_carouselGoTo,carouselIndicators:LYRA_DEFAULT_carouselIndicators,carouselLabel:LYRA_DEFAULT_carouselLabel,carouselSlide:LYRA_DEFAULT_carouselSlide,carouselSlideAnnouncement:LYRA_DEFAULT_carouselSlideAnnouncement,carouselSlideAnnouncementSeparator:LYRA_DEFAULT_carouselSlideAnnouncementSeparator,carouselSlidePosition:LYRA_DEFAULT_carouselSlidePosition,next:LYRA_DEFAULT_next,previous:LYRA_DEFAULT_previous}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"currentslide"])]}get currentSlide(){return this._currentSlide}set currentSlide(value){this.setCurrentSlideState(value)}get pagination(){return this._pagination}set pagination(value){this.setPaginationState(!!value)}get slides(){return this._slides}constructor(){super(),this._currentSlide=0,this._pagination=!1,this._slides=0,this.loop=!1,this.autoplay=!1,this.autoplayInterval=3e3,this.navigation=!1,this.orientation="horizontal",this.mouseDragging=!1,this.slidesPerPage=1,this.slidesPerMove=1,this.hostAccessibleLabel=null,this.reduceMotion=!1,this.snapshots=new Map,this.appliedSnapshots=new WeakMap,this.scrollSettle=new DebounceController(SCROLL_SETTLE_MS,()=>this.settleScrolledSlide(),()=>this.ownerDocument.defaultView),this.adoptingScrolledSlide=!1,this.hasAlignedOnce=!1,this.loopClonesDirty=!0,this.pointerInteracting=!1,this.focusInteracting=!1,this.slideOverlay=new SlottedOverlayController(this,()=>this.renderRoot?.querySelector("slot:not([name])")),this.slideOverlayWasOpen=!1,this.dragStartCoordinate=0,this.dragStartScroll=0,this.dragMoved=!1,this.suppressClick=!1,this.announcementsArmed=!1,this.changeOrigin="manual",this.manualPending=!1,this.observerGeneration=0,this.onMotionPreferenceChange=reduced=>{this.reduceMotion=reduced,this.restartAutoplay(),this.requestUpdate()},this.onVisibilityChange=()=>{this.restartAutoplay()},this.onSlotChange=()=>{this.handleSlidesChanged()},this.onViewportScroll=()=>{this.cancelScrollSettle(),this.ownerDocument.defaultView&&this.scrollSettle.push(void 0)},this.onViewportScrollEnd=()=>{this.cancelScrollSettle(),this.settleScrolledSlide()},this.settleScrolledSlide=()=>{if(!this.isConnected)return;const viewport=this.viewport;if(!viewport)return;if(this.alignTarget){if(Math.abs(this.axisOffsetOf(this.alignTarget,viewport))>2)return;const cloneSide=this.alignTarget.dataset.carouselClone;if(cloneSide==="before"||cloneSide==="after"){const realSlide=this.slideElements()[this.alignIndex??-1];if(realSlide){this.alignTarget=realSlide,this.scrollByAxis(viewport,this.axisOffsetOf(realSlide,viewport),"instant");return}}this.clearAlignment();return}const resting=this.restingSlide();if(!resting)return;const changed=resting.index!==this.currentSlide;!changed&&!resting.cloneSide||(this.adoptingScrolledSlide=!0,changed&&(this.currentSlide=resting.index,this.emit("lr-slide-change",{index:resting.index,slide:this.slideElements()[resting.index]})),this.updateComplete.then(()=>{if(resting.cloneSide&&this.isConnected&&this.viewport){const realSlide=this.slideElements()[resting.index];realSlide&&this.scrollByAxis(this.viewport,this.axisOffsetOf(realSlide,this.viewport),"instant")}this.adoptingScrolledSlide=!1}))},this.onViewportPointerEnter=()=>{this.pointerInteracting=!0,this.restartAutoplay()},this.onViewportPointerLeave=()=>{this.dragPointerId===void 0&&(this.pointerInteracting=!1,this.restartAutoplay())},this.onViewportFocusIn=event=>{this.focusInteracting=!0;const slides=new Set(this.slideElements()),focusedSlide=event.composedPath().find(candidate=>candidate.nodeType===1&&slides.has(candidate));focusedSlide&&(this.lastFocusedSlide=focusedSlide),this.restartAutoplay()},this.onViewportFocusOut=()=>{this.queueOwnerMicrotask(()=>{if(!this.isConnected)return;const active=deepActiveElementIn(this.ownerDocument);this.lastFocusedSlide&&!composedContains(this.lastFocusedSlide,active)&&(this.lastFocusedSlide.isConnected||active!==null&&active!==this.ownerDocument.body)&&(this.lastFocusedSlide=void 0),this.focusInteracting=this.matches(":focus-within"),this.restartAutoplay()})},this.onViewportPointerDown=event=>{if(!this.mouseDragging||event.pointerType!=="mouse"||!event.isPrimary||event.button!==0||this.dragPointerId!==void 0||this.targetsInteractiveContent(event))return;this.takeOverViewport();const viewport=this.viewport;if(viewport){this.dragPointerId=event.pointerId,this.dragStartCoordinate=this.effectiveOrientation()==="vertical"?event.clientY:event.clientX,this.dragStartScroll=this.effectiveOrientation()==="vertical"?viewport.scrollTop:viewport.scrollLeft,this.dragMoved=!1,viewport.setAttribute("data-dragging","");try{viewport.setPointerCapture(event.pointerId)}catch{}this.restartAutoplay()}},this.onViewportPointerMove=event=>{if(event.pointerId!==this.dragPointerId)return;const viewport=this.viewport;if(!viewport)return;const delta=(this.effectiveOrientation()==="vertical"?event.clientY:event.clientX)-this.dragStartCoordinate;Math.abs(delta)>2&&(this.dragMoved=!0),this.dragMoved&&(event.preventDefault(),this.effectiveOrientation()==="vertical"?viewport.scrollTo({top:this.dragStartScroll-delta,behavior:"instant"}):viewport.scrollTo({left:this.dragStartScroll-delta,behavior:"instant"}))},this.onViewportPointerUp=event=>{this.finishDrag(event.pointerId,!1)},this.onViewportPointerCancel=event=>{this.finishDrag(event.pointerId,!0)},this.onViewportLostPointerCapture=event=>{this.finishDrag(event.pointerId,!0)},this.onViewportClick=event=>{this.suppressClick&&(event.preventDefault(),event.stopImmediatePropagation())},this.onViewportKeyDown=event=>{if(this.targetsInteractiveContent(event,!0))return;const vertical=this.effectiveOrientation()==="vertical",rtl=this.effectiveDirection==="rtl",forwardKey=vertical?"ArrowDown":rtl?"ArrowLeft":"ArrowRight",backwardKey=vertical?"ArrowUp":rtl?"ArrowRight":"ArrowLeft";event.key===forwardKey?(event.preventDefault(),this.next()):event.key===backwardKey?(event.preventDefault(),this.previous()):event.key==="Home"?(event.preventDefault(),this.goToSlide(0)):event.key==="End"&&(event.preventDefault(),this.goToSlide(this.loop?this.slideElements().length-1:this.maxStartIndex()))},this.requestUpdate("currentSlide",void 0),this.requestUpdate("pagination",void 0)}attributeChangedCallback(name,oldValue,newValue){if(name==="currentslide"){oldValue!==newValue&&(this.currentSlide=finiteInteger(Number(newValue??0),0));return}super.attributeChangedCallback(name,oldValue,newValue),name==="current-slide"&&newValue===null&&oldValue!==newValue&&this.hasAttribute("currentslide")&&(this.currentSlide=finiteInteger(Number(this.getAttribute("currentslide")??0),0))}connectedCallback(){this.hasAttribute("current-slide")&&(this.currentSlide=finiteInteger(Number(this.getAttribute("current-slide")??0),0)),super.connectedCallback(),this.announcementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.announcementsArmed=!1,this.manualPending=!1,this.reduceMotion=prefersReducedMotion(this),this.stopMotionWatch=observeReducedMotion(this,this.onMotionPreferenceChange),this.visibilityDocument=this.ownerDocument,this.visibilityDocument.addEventListener("visibilitychange",this.onVisibilityChange),this.armSlideContentObserver(),this.restartAutoplay(),this.hasUpdated&&this.queueOwnerMicrotask(()=>{this.isConnected&&this.handleSlidesChanged()})}disconnectedCallback(){this.announcementSink?.release(),this.announcementSink=void 0,this.announcementsArmed=!1,this.manualPending=!1,this.cancelDrag(!1),this.stopAutoplay(),this.cancelScrollSettle(),this.cancelClickSuppression(),this.suppressClick=!1,this.pointerInteracting=!1,this.focusInteracting=!1,this.hasAlignedOnce=!1,this.clearAlignment(),this.stopMotionWatch?.(),this.stopMotionWatch=void 0,this.visibilityDocument?.removeEventListener("visibilitychange",this.onVisibilityChange),this.visibilityDocument=void 0,this.resetSlideContentObserver(),this.restoreSlides(),this.lastFocusedSlide=void 0,super.disconnectedCallback()}armSlideContentObserver(){const ownerDocument=this.ownerDocument,MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor||!this.isConnected)return;this.resetSlideContentObserver();const generation=this.observerGeneration,observer=new MutationObserverCtor(records=>{this.observer!==observer||this.observerDocument!==ownerDocument||this.observerGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||!records.some(record=>{if(record.type!=="attributes")return!0;if(record.target===this)return!1;if(!CAROUSEL_MANAGED_SLIDE_ATTRIBUTES.has(record.attributeName??""))return!0;const slide=record.target,snapshot=this.snapshots.get(slide);return snapshot?this.adoptChanges(slide,snapshot):!1})||(this.loop&&(this.loopClonesDirty=!0),this.syncSlides(),this.requestUpdate())});this.observer=observer,this.observerDocument=ownerDocument,observer.observe(this,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}resetSlideContentObserver(){this.observerGeneration+=1,this.observer?.disconnect(),this.observer=void 0,this.observerDocument=void 0}willUpdate(changed){if(super.willUpdate(changed),(changed.has("currentSlide")||changed.has("slidesPerPage"))&&this.slideSlot){const normalized=this.normalizedIndex();if(this.currentSlide!==normalized){const forcedBySibling=changed.has("slidesPerPage")&&!changed.has("currentSlide");if(this.currentSlide=normalized,forcedBySibling){const slide=this.slideElements()[normalized];slide&&this.emit("lr-slide-change",{index:normalized,slide})}}}}firstUpdated(changed){super.firstUpdated(changed);const slot=this.slideSlot;this.queueOwnerMicrotask(()=>{collectInitialSlotAssignment(slot,()=>this.handleSlidesChanged())})}updated(changed){super.updated(changed);const shouldAnnounceActivePage=this.announcementsArmed&&(this.manualPending||changed.has("slidesPerPage"));this.slideOverlay.open!==this.slideOverlayWasOpen&&(this.slideOverlayWasOpen=this.slideOverlay.open,this.restartAutoplay()),this.syncSlides(),(this.loopClonesDirty||changed.has("loop")||changed.has("slidesPerPage")||changed.has("slidesPerMove"))&&(this.syncLoopClones(),this.loopClonesDirty=!1),(changed.has("autoplay")||changed.has("autoplayInterval")||changed.has("loop")||changed.has("slidesPerPage"))&&this.restartAutoplay(),!this.adoptingScrolledSlide&&(changed.has("currentSlide")||changed.has("slidesPerPage")||changed.has("orientation")||!this.hasAlignedOnce)&&this.alignToActiveSlide(),this.hasAlignedOnce=!0,shouldAnnounceActivePage&&this.announceActivePage(),this.manualPending=!1,this.announcementsArmed=!0}setCurrentSlideState(value){const old=this._currentSlide,next=finiteInteger(value,0);old!==next&&(this._currentSlide=next,this.changeOrigin==="manual"&&(this.manualPending=!0),this.requestUpdate("currentSlide",old))}setPaginationState(value){const old=this._pagination;old!==value&&(this._pagination=value,this.requestUpdate("pagination",old))}queueOwnerMicrotask(callback){const view=this.ownerDocument.defaultView;view?view.queueMicrotask(callback):queueMicrotask(callback)}effectiveOrientation(){return this.orientation==="vertical"?"vertical":"horizontal"}slideElements(){return(this.slideSlot?.assignedElements({flatten:!0})??[]).filter(element=>element.nodeType===1&&element.namespaceURI==="http://www.w3.org/1999/xhtml")}pageSize(count=this.slideElements().length){return finiteInteger(this.slidesPerPage,1,1,Math.max(1,count))}moveSize(count=this.slideElements().length){return finiteInteger(this.slidesPerMove,1,1,this.pageSize(count))}maxStartIndex(count=this.slideElements().length){return Math.max(0,count-this.pageSize(count))}normalizedIndex(count=this.slideElements().length){if(count===0)return 0;const max=this.loop?count-1:this.maxStartIndex(count);return finiteInteger(this.currentSlide,0,0,max)}pageTargets(count=this.slideElements().length){if(count===0)return[];if(this.loop)return Array.from({length:count},(_unused,index)=>index);const max=this.maxStartIndex(count),move=this.moveSize(count),targets=[0];for(let target=move;target<max;target+=move)targets.push(target);return max>0&&targets.at(-1)!==max&&targets.push(max),targets}visibleIndices(count,current){const visible=new Set,perPage=this.pageSize(count);for(let offset=0;offset<perPage;offset+=1){const index=this.loop?(current+offset)%count:current+offset;index>=0&&index<count&&visible.add(index)}return visible}announceActivePage(){if(!isAccessibilityVisible(this))return;const slides=this.slideElements();if(slides.length===0)return;const current=this.normalizedIndex(slides.length),visible=this.visibleIndices(slides.length,current),format=getNumberFormat(this.effectiveLocale),messages=slides.flatMap((slide,index)=>{if(!visible.has(index))return[];if(isAccessibilitySubtreeExcluded(slide))return[];const slideTextVisible=!isAccessibilityVisibilityHidden(slide),authoredLabel=slideTextVisible?this.snapshots.get(slide)?.label?.trim():"";if(authoredLabel)return[authoredLabel];const position=this.localize("carouselSlidePosition",void 0,{index:format.format(index+1),total:format.format(slides.length)}),content=Array.from(slide.childNodes).map(node=>composedAccessibilityText(node,slideTextVisible)).join(" ").replace(/\s+/g," ").trim();return!slideTextVisible&&!content?[]:[content&&content!==position?this.localize("carouselSlideAnnouncement",void 0,{position,content}):position]});this.announcementSink?.announce(messages.join(this.localize("carouselSlideAnnouncementSeparator")))}restoreAttribute(slide,name,value){value===null?slide.removeAttribute(name):slide.setAttribute(name,value)}snapshotSlide(slide){return{hidden:slide.hidden,inert:slide.inert,role:slide.getAttribute("role"),label:slide.getAttribute("aria-label"),roleDescription:slide.getAttribute("aria-roledescription"),ariaHidden:slide.getAttribute("aria-hidden")}}adoptChanges(slide,snapshot){const applied=this.appliedSnapshots.get(slide);if(!applied)return!1;const current=this.snapshotSlide(slide);let changed=!1;for(const key of SLIDE_SNAPSHOT_KEYS)current[key]!==applied[key]&&(snapshot[key]=current[key],changed=!0);return changed}restoreSlide(slide,snapshot){slide.hidden=snapshot.hidden,slide.inert=snapshot.inert,this.restoreAttribute(slide,"role",snapshot.role),this.restoreAttribute(slide,"aria-label",snapshot.label),this.restoreAttribute(slide,"aria-roledescription",snapshot.roleDescription),this.restoreAttribute(slide,"aria-hidden",snapshot.ariaHidden)}restoreSlides(){for(const[slide,snapshot]of this.snapshots)this.adoptChanges(slide,snapshot),this.restoreSlide(slide,snapshot);this.snapshots.clear()}syncSlides(){const slides=this.slideElements(),assigned=new Set(slides);for(const[slide,snapshot]of this.snapshots)this.adoptChanges(slide,snapshot)&&(this.loopClonesDirty=!0),assigned.has(slide)||(this.restoreSlide(slide,snapshot),this.snapshots.delete(slide));const current=this.normalizedIndex(slides.length);if(this.currentSlide!==current){this.currentSlide=current;const slide=slides[current];slide&&this.emit("lr-slide-change",{index:current,slide})}const visible=this.visibleIndices(slides.length,current);this.repairFocusBeforeSlideExclusion(slides,visible);const format=getNumberFormat(this.effectiveLocale);slides.forEach((slide,slideIndex)=>{const existing=this.snapshots.get(slide),snapshot=existing??this.snapshotSlide(slide);existing||this.snapshots.set(slide,snapshot),slide.localName===tag("carousel-item")?(this.restoreAttribute(slide,"role",snapshot.role??"group"),this.restoreAttribute(slide,"aria-roledescription",snapshot.roleDescription??this.localize("carouselSlide")),this.restoreAttribute(slide,"aria-label",snapshot.label??this.localize("carouselSlidePosition",void 0,{index:format.format(slideIndex+1),total:format.format(slides.length)}))):(this.restoreAttribute(slide,"role",snapshot.role),this.restoreAttribute(slide,"aria-roledescription",snapshot.roleDescription),this.restoreAttribute(slide,"aria-label",snapshot.label)),slide.hidden=snapshot.hidden,visible.has(slideIndex)?(slide.inert=snapshot.inert,this.restoreAttribute(slide,"aria-hidden",snapshot.ariaHidden)):(slide.inert=!0,slide.setAttribute("aria-hidden","true")),this.appliedSnapshots.set(slide,this.snapshotSlide(slide))})}repairFocusBeforeSlideExclusion(slides,visible){const active=deepActiveElementIn(this.ownerDocument),focusedIndex=slides.findIndex(slide=>composedContains(slide,active)),focusedSlideWillBeExcluded=focusedIndex>=0&&!visible.has(focusedIndex),focusedSlideWasRemoved=focusedIndex<0&&this.lastFocusedSlide!==void 0&&!this.lastFocusedSlide.isConnected&&(active===null||active===this.ownerDocument.body);!focusedSlideWillBeExcluded&&!focusedSlideWasRemoved||(this.viewport?.focus(),this.lastFocusedSlide=void 0)}handleSlidesChanged(){const count=this.slideElements().length,active=activeElementIn(this.shadowRoot);if(active?.matches('[part~="pagination-item"]')){const children=active.parentElement.children,pages=this.pageTargets(count).length;(pages<2||[...children].indexOf(active)>=pages)&&(pages>1?children[pages-1]:this.viewport)?.focus()}else active?.matches('[part~="navigation-button"]')&&(!this.navigation||count<=this.pageSize(count))&&this.viewport?.focus();if(this._slides!==count){const previous=this._slides;this._slides=count,this.requestUpdate("slides",previous)}this.loopClonesDirty=!0,this.syncSlides(),this.syncLoopClones(),this.loopClonesDirty=!1,this.restartAutoplay(),this.requestUpdate()}prepareClone(original,index,side){if([original,...Array.from(original.querySelectorAll("*"))].some(element=>element.namespaceURI!=="http://www.w3.org/1999/xhtml"||element.localName.includes("-")||LOOP_SNAPSHOT_UNSAFE_TAGS.has(element.localName)))return;const clone=original.cloneNode(!0),descendants=[clone,...Array.from(clone.querySelectorAll("*"))];for(const descendant of descendants)descendant.removeAttribute("id"),descendant.removeAttribute("name"),descendant.removeAttribute("form"),descendant.removeAttribute("for"),descendant.removeAttribute("aria-controls"),descendant.removeAttribute("aria-describedby"),descendant.removeAttribute("aria-labelledby");return clone.removeAttribute("slot"),clone.dataset.carouselClone=side,clone.dataset.carouselIndex=String(index),clone.inert=!0,clone.setAttribute("aria-hidden","true"),clone}syncLoopClones(){const before=this.beforeClones,after=this.afterClones;if(!before||!after)return;before.replaceChildren(),after.replaceChildren();const slides=this.slideElements();if(!this.loop||slides.length<2)return;const cloneCount=Math.min(slides.length,Math.max(this.pageSize(slides.length),this.moveSize(slides.length))),beforeStart=slides.length-cloneCount;for(let index=beforeStart;index<slides.length;index+=1){const clone=this.prepareClone(slides[index],index,"before");clone&&before.append(clone)}for(let index=0;index<cloneCount;index+=1){const clone=this.prepareClone(slides[index],index,"after");clone&&after.append(clone)}}cloneFor(side,index){return(side==="before"?this.beforeClones:this.afterClones)?.querySelector(`[data-carousel-index="${index}"]`)??void 0}changeTo(index,behavior="smooth",origin="manual"){const slides=this.slideElements(),count=slides.length;if(count===0||!Number.isFinite(index))return;const requested=Math.trunc(index);let next,loopSide;if(this.loop?(next=(requested%count+count)%count,requested<0?loopSide="before":requested>=count&&(loopSide="after")):next=Math.min(this.maxStartIndex(count),Math.max(0,requested)),next===this.currentSlide)return;this.requestedBehavior=behavior,this.loopSide=loopSide;const previousOrigin=this.changeOrigin;this.changeOrigin=origin;try{this.currentSlide=next}finally{this.changeOrigin=previousOrigin}this.emit("lr-slide-change",{index:next,slide:slides[next]})}next(behavior="smooth"){this.changeTo(this.currentSlide+this.moveSize(),behavior)}previous(behavior="smooth"){this.changeTo(this.currentSlide-this.moveSize(),behavior)}goToSlide(index,behavior="smooth"){this.changeTo(index,behavior)}addSlide(slide){slide?.nodeType!==1||slide?.namespaceURI!=="http://www.w3.org/1999/xhtml"||(this.append(slide),this.queueOwnerMicrotask(()=>{this.isConnected&&this.handleSlidesChanged()}))}removeSlide(index){if(!Number.isFinite(index))return;const target=this.slideElements()[Math.trunc(index)];target&&(target.remove(),this.queueOwnerMicrotask(()=>{this.isConnected&&this.handleSlidesChanged()}))}stopAutoplay(){this.timer!==void 0&&this.timerWindow?.clearInterval(this.timer),this.timer=void 0,this.timerWindow=void 0}restartAutoplay(){this.stopAutoplay();const count=this.slideElements().length,doc=this.visibilityDocument??this.ownerDocument,view=doc.defaultView;if(!this.isConnected||!view||!this.autoplay||this.reduceMotion||this.pointerInteracting||this.focusInteracting||this.slideOverlay.open||this.dragPointerId!==void 0||doc.visibilityState!=="visible"||count<=this.pageSize(count))return;const interval=finiteDuration(this.autoplayInterval,3e3,1e3);this.timerWindow=view,this.timer=view.setInterval(()=>{this.loop||this.currentSlide<this.maxStartIndex()?this.changeTo(this.currentSlide+this.moveSize(),"smooth","autoplay"):this.stopAutoplay()},interval)}scrollPaddingStart(){const rect=this.scrollHintProbe?.getBoundingClientRect();if(!rect)return 0;const pixels=this.effectiveOrientation()==="vertical"?rect.height:rect.width;return Number.isFinite(pixels)?pixels:0}axisOffsetOf(slide,viewport){const viewportRect=viewport.getBoundingClientRect(),slideRect=slide.getBoundingClientRect(),padding=this.scrollPaddingStart();return this.effectiveOrientation()==="vertical"?slideRect.top-(viewportRect.top+padding):this.effectiveDirection==="rtl"?slideRect.right-(viewportRect.right-padding):slideRect.left-(viewportRect.left+padding)}scrollByAxis(viewport,distance,behavior){this.effectiveOrientation()==="vertical"?viewport.scrollBy({top:distance,behavior}):viewport.scrollBy({left:distance,behavior})}restingSlide(){const viewport=this.viewport,slides=this.slideElements();if(!viewport||slides.length===0)return;const candidates=slides.map((element,index)=>({element,index}));for(const clone of this.shadowRoot?.querySelectorAll("[data-carousel-clone]")??[]){const index=Number(clone.dataset.carouselIndex),cloneSide=clone.dataset.carouselClone;Number.isInteger(index)&&index>=0&&index<slides.length&&(cloneSide==="before"||cloneSide==="after")&&candidates.push({element:clone,index,cloneSide})}let nearest,nearestDistance=Number.POSITIVE_INFINITY;for(const candidate of candidates){const distance=Math.abs(this.axisOffsetOf(candidate.element,viewport));distance<nearestDistance&&(nearestDistance=distance,nearest=candidate)}return nearest}alignToActiveSlide(){const viewport=this.viewport,targetIndex=this.normalizedIndex(),realSlide=this.slideElements()[targetIndex];if(!viewport||!realSlide)return;const loopSide=this.loopSide,requestedBehavior=this.requestedBehavior;this.loopSide=void 0,this.requestedBehavior=void 0;const target=loopSide?this.cloneFor(loopSide,targetIndex)??realSlide:realSlide,offset=this.axisOffsetOf(target,viewport);if(Math.round(offset)===0){this.clearAlignment();return}this.alignIndex=targetIndex,this.alignTarget=target;const behavior=this.motionAwareScrollBehavior(requestedBehavior??"smooth",!0);this.scrollByAxis(viewport,offset,behavior)}motionAwareScrollBehavior(requested,instantBeforeFirstAlignment=!1){return this.reduceMotion||instantBeforeFirstAlignment&&!this.hasAlignedOnce?"instant":requested}cancelScrollSettle(){this.scrollSettle.cancel()}clearAlignment(){this.alignTarget=void 0,this.alignIndex=void 0,this.loopSide=void 0,this.requestedBehavior=void 0}takeOverViewport(){this.clearAlignment()}targetsInteractiveContent(event,includeSlideEditors=!1){const slides=new Set(this.slideElements());for(const target of event.composedPath()){if(!(target instanceof Element))continue;const slideRoot=slides.has(target);if(target===this||target===this.viewport||slideRoot&&!includeSlideEditors)continue;const name=target.localName;if(name==="a"||name==="button"||name==="input"||name==="label"||name==="select"||name==="textarea"||target.hasAttribute("contenteditable")||!slideRoot&&name.includes("-")&&target.getRootNode()!==this.shadowRoot)return!0;const role=target.getAttribute("role")?.trim().toLowerCase();if(role&&["button","checkbox","combobox","link","radio","slider","spinbutton","switch","textbox"].includes(role))return!0}return!1}finishDrag(pointerId,canceled){if(pointerId!==this.dragPointerId)return;const viewport=this.viewport,moved=this.dragMoved;if(this.dragPointerId=void 0,this.dragMoved=!1,viewport?.removeAttribute("data-dragging"),viewport?.hasPointerCapture(pointerId))try{viewport.releasePointerCapture(pointerId)}catch{}if(moved){this.suppressClick=!0,this.cancelClickSuppression();const view=this.ownerDocument.defaultView;view?(this.clickTimerWindow=view,this.clickTimer=view.setTimeout(()=>{this.suppressClick=!1,this.clickTimer=void 0,this.clickTimerWindow=void 0},0)):this.suppressClick=!1}if(canceled&&viewport){const active=this.slideElements()[this.normalizedIndex()];active&&this.scrollByAxis(viewport,this.axisOffsetOf(active,viewport),this.motionAwareScrollBehavior("smooth"))}else canceled||this.onViewportScroll();this.matches(":hover")||(this.pointerInteracting=!1),this.restartAutoplay()}cancelClickSuppression(){this.clickTimer!==void 0&&this.clickTimerWindow?.clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickTimerWindow=void 0}cancelDrag(realign){this.dragPointerId!==void 0&&this.finishDrag(this.dragPointerId,realign)}computedSlideBasis(perPage){return perPage===1?"100%":`calc((100% - (${perPage-1} * var(--slide-gap, var(--lr-space-m)))) / ${perPage})`}render(){const count=this.slideElements().length,current=this.normalizedIndex(count),pageTargets=this.pageTargets(count),exactCurrentPage=pageTargets.indexOf(current),currentPage=exactCurrentPage>=0?exactCurrentPage:pageTargets.reduce((nearest,target,pageIndex)=>Math.abs(target-current)<Math.abs(pageTargets[nearest]-current)?pageIndex:nearest,0),hasNavigation=this.navigation&&count>this.pageSize(count),hasPagination=this.pagination&&pageTargets.length>1,label=this.hostAccessibleLabel??this.localize("carouselLabel"),numberFormat=getNumberFormat(this.effectiveLocale),orientation=this.effectiveOrientation(),perPage=this.pageSize(count);return html`<section
2
2
  part="base carousel"
3
3
  role="region"
4
4
  aria-roledescription=${this.localize("carousel")}
@@ -74,4 +74,4 @@ import{__decorate}from"tslib";import{prefersReducedMotion}from"../../../internal
74
74
  </button>`)}
75
75
  </div>`:nothing}
76
76
  </div>`:nothing}
77
- </section>`}}__decorate([property({type:Number,attribute:"current-slide",reflect:!0})],LyraCarousel.prototype,"currentSlide",null),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"loop",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"autoplay",void 0),__decorate([property({type:Number,attribute:"autoplay-interval",useDefault:!0})],LyraCarousel.prototype,"autoplayInterval",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"navigation",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"pagination",null),__decorate([property({useDefault:!0})],LyraCarousel.prototype,"orientation",void 0),__decorate([property({type:Boolean,attribute:"mouse-dragging",reflect:!0})],LyraCarousel.prototype,"mouseDragging",void 0),__decorate([property({type:Number,attribute:"slides-per-page",useDefault:!0})],LyraCarousel.prototype,"slidesPerPage",void 0),__decorate([property({type:Number,attribute:"slides-per-move",useDefault:!0})],LyraCarousel.prototype,"slidesPerMove",void 0),__decorate([property({attribute:!1})],LyraCarousel.prototype,"accessibleLabel",null),__decorate([property({attribute:"aria-label"})],LyraCarousel.prototype,"hostAccessibleLabel",void 0),__decorate([query("slot:not([name])")],LyraCarousel.prototype,"slideSlot",void 0),__decorate([query('[part~="scroll-container"]')],LyraCarousel.prototype,"viewport",void 0),__decorate([query(".scroll-hint-probe")],LyraCarousel.prototype,"scrollHintProbe",void 0),__decorate([query('[data-clone-set="before"]')],LyraCarousel.prototype,"beforeClones",void 0),__decorate([query('[data-clone-set="after"]')],LyraCarousel.prototype,"afterClones",void 0);export{LyraCarousel};
77
+ </section>`}}__decorate([property({type:Number,attribute:"current-slide",reflect:!0})],LyraCarousel.prototype,"currentSlide",null),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"loop",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"autoplay",void 0),__decorate([property({type:Number,attribute:"autoplay-interval",useDefault:!0})],LyraCarousel.prototype,"autoplayInterval",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"navigation",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCarousel.prototype,"pagination",null),__decorate([property({useDefault:!0})],LyraCarousel.prototype,"orientation",void 0),__decorate([property({type:Boolean,attribute:"mouse-dragging",reflect:!0})],LyraCarousel.prototype,"mouseDragging",void 0),__decorate([property({type:Number,attribute:"slides-per-page",useDefault:!0})],LyraCarousel.prototype,"slidesPerPage",void 0),__decorate([property({type:Number,attribute:"slides-per-move",useDefault:!0})],LyraCarousel.prototype,"slidesPerMove",void 0),__decorate([property({attribute:"aria-label"})],LyraCarousel.prototype,"hostAccessibleLabel",void 0),__decorate([query("slot:not([name])")],LyraCarousel.prototype,"slideSlot",void 0),__decorate([query('[part~="scroll-container"]')],LyraCarousel.prototype,"viewport",void 0),__decorate([query(".scroll-hint-probe")],LyraCarousel.prototype,"scrollHintProbe",void 0),__decorate([query('[data-clone-set="before"]')],LyraCarousel.prototype,"beforeClones",void 0),__decorate([query('[data-clone-set="after"]')],LyraCarousel.prototype,"afterClones",void 0);export{LyraCarousel};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{DeferredFocusReturn,captureFocusReturnOpener}from"../../../internal/deferred-focus-return.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{parseHotkey,matchesHotkey,isIgnorableKeyEvent,registerHotkeyOwner,unregisterHotkeyOwner,resolveHotkeyOwner}from"../../../internal/hotkey.js";import{detectPlatform}from"../../../internal/platform.js";import{nextId}from"../../../internal/a11y.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{styles}from"./command-palette.styles.js";import{resolveCssTokenLength}from"../../../internal/css-token-length.js";import{closeIcon}from"../../../internal/icons.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_commandPaletteEmpty,LYRA_DEFAULT_commandPaletteLabel,LYRA_DEFAULT_commandPalettePlaceholder,LYRA_DEFAULT_commandPaletteResults}from"../../../internal/default-strings.generated.js";const COMMAND_ROW_HEIGHT=48,GROUP_ROW_HEIGHT=32,RESULT_OVERSCAN_ROWS=6,MAX_COMMAND_PALETTE_COMMANDS=1e4,MAX_COMMAND_PALETTE_KEYWORDS=1e4,EMPTY_CANONICAL_COMMANDS=Object.freeze([]),EMPTY_COMMAND_KEYWORDS=Object.freeze([]);function projectCommandKeywords(value){try{if(!Array.isArray(value))return EMPTY_COMMAND_KEYWORDS;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return EMPTY_COMMAND_KEYWORDS;const keywords=[];for(let index=0;index<Math.min(length.value,MAX_COMMAND_PALETTE_KEYWORDS);index+=1){const entry=getOwnDataDescriptor(value,String(index));entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR||typeof entry.value!="string"||keywords.push(entry.value)}return Object.freeze(keywords)}catch{return EMPTY_COMMAND_KEYWORDS}}function projectCommand(candidate){try{if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))return;const commandId=getOwnDataDescriptor(candidate,"commandId"),label=getOwnDataDescriptor(candidate,"label"),description=getOwnDataDescriptor(candidate,"description"),group=getOwnDataDescriptor(candidate,"group"),shortcut=getOwnDataDescriptor(candidate,"shortcut"),keywords=getOwnDataDescriptor(candidate,"keywords"),disabled=getOwnDataDescriptor(candidate,"disabled"),icon=getOwnDataDescriptor(candidate,"icon"),onSelect=getOwnDataDescriptor(candidate,"onSelect");if(commandId===MISSING_OWN_DATA_DESCRIPTOR||commandId===UNSAFE_OWN_DATA_DESCRIPTOR||label===MISSING_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||description===UNSAFE_OWN_DATA_DESCRIPTOR||group===UNSAFE_OWN_DATA_DESCRIPTOR||shortcut===UNSAFE_OWN_DATA_DESCRIPTOR||keywords===UNSAFE_OWN_DATA_DESCRIPTOR||disabled===UNSAFE_OWN_DATA_DESCRIPTOR||icon===UNSAFE_OWN_DATA_DESCRIPTOR||onSelect===UNSAFE_OWN_DATA_DESCRIPTOR||typeof commandId.value!="string"||commandId.value.trim()===""||typeof label.value!="string"||label.value.trim()==="")return;const descriptionValue=description===MISSING_OWN_DATA_DESCRIPTOR?void 0:description.value,groupValue=group===MISSING_OWN_DATA_DESCRIPTOR?void 0:group.value,shortcutValue=shortcut===MISSING_OWN_DATA_DESCRIPTOR?void 0:shortcut.value,keywordsValue=keywords===MISSING_OWN_DATA_DESCRIPTOR?void 0:keywords.value,disabledValue=disabled===MISSING_OWN_DATA_DESCRIPTOR?void 0:disabled.value,iconValue=icon===MISSING_OWN_DATA_DESCRIPTOR?void 0:icon.value,onSelectValue=onSelect===MISSING_OWN_DATA_DESCRIPTOR?void 0:onSelect.value;if(descriptionValue!==void 0&&typeof descriptionValue!="string"||groupValue!==void 0&&typeof groupValue!="string"||shortcutValue!==void 0&&typeof shortcutValue!="string"||disabledValue!==void 0&&typeof disabledValue!="boolean"||onSelectValue!==void 0&&typeof onSelectValue!="function")return;const keywordValues=projectCommandKeywords(keywordsValue);return Object.freeze({source:candidate,commandId:commandId.value,label:label.value,...descriptionValue===void 0?{}:{description:descriptionValue},...groupValue===void 0?{}:{group:groupValue},...shortcutValue===void 0?{}:{shortcut:shortcutValue},keywords:keywordValues,disabled:disabledValue??!1,...iconValue===void 0?{}:{icon:iconValue},...onSelectValue===void 0?{}:{onSelect:onSelectValue}})}catch{return}}function projectCommands(value){try{if(!Array.isArray(value))return EMPTY_CANONICAL_COMMANDS;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return EMPTY_CANONICAL_COMMANDS;const commands=[],seen=new Set;for(let index=0;index<Math.min(length.value,MAX_COMMAND_PALETTE_COMMANDS);index+=1){const entry=getOwnDataDescriptor(value,String(index));if(entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const command=projectCommand(entry.value);!command||seen.has(command.commandId)||(seen.add(command.commandId),commands.push(command))}return Object.freeze(commands)}catch{return EMPTY_CANONICAL_COMMANDS}}class LyraCommandPalette extends LyraElement{constructor(){super(...arguments),this._open=!1,this.commands=[],this.hotkey="mod+k",this.queryText="",this.activeIndex=0,this.listScrollTop=0,this.listViewportHeight=COMMAND_ROW_HEIGHT*10,this.rowPitch=COMMAND_ROW_HEIGHT,this.groupPitch=GROUP_ROW_HEIGHT,this.listId=nextId("command-list"),this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlay?.isTopmost()&&this.close("escape")},onUnexpectedClose:()=>{this.close("escape"),this.open&&this.nativeModal.show()}}),this.focusReturnOpener=null,this.deferredFocusReturn=new DeferredFocusReturn,this.haystacksLocale="",this.haystacks=[],this.filteredForQuery="",this.filteredForLocale="",this.filteredRows=[],this.normalizedRows=EMPTY_CANONICAL_COMMANDS,this.onGlobalKeyDown=event=>{if(isIgnorableKeyEvent(event))return;const view=this.runtimeWindow;!view||!this.matchesShortcut(event)||resolveHotkeyOwner(view,event)!==this||(event.preventDefault(),this.openPalette())},this.onKeyDown=event=>{if(event.isComposing||event.keyCode===229)return;const rows=this.filtered;if(event.key==="ArrowDown"){event.preventDefault();const next=this.seekEnabled(rows,this.activeIndex+1,1);next!==-1&&this.setActiveIndex(rows,next)}else if(event.key==="ArrowUp"){event.preventDefault();const previous=this.seekEnabled(rows,this.activeIndex-1,-1);previous!==-1&&this.setActiveIndex(rows,previous)}else if(event.key==="Enter"){const active=rows[this.activeIndex];active&&(event.preventDefault(),this.select(active))}},this.onInput=event=>{event.stopPropagation(),this.queryText=event.target.value,this.listScrollTop=0;const list=this.renderRoot.querySelector('[part="list"]');list&&(list.scrollTop=0);const rows=this.filtered;this.setActiveIndex(rows,this.seekEnabled(rows,0,1))},this.onClearSearch=()=>{if(this.queryText==="")return;this.queryText="",this.listScrollTop=0;const list=this.renderRoot.querySelector('[part="list"]');list&&(list.scrollTop=0);const rows=this.filtered;this.setActiveIndex(rows,this.seekEnabled(rows,0,1)),this.renderRoot.querySelector('[part="input"]')?.focus()},this.onSearchFocus=()=>{this.emit("focus")},this.onSearchBlur=()=>{this.emit("blur")},this.onListScroll=event=>{const list=event.currentTarget;if(this.listScrollFrame!==void 0)return;const view=this.runtimeWindow??this.ownerDocument.defaultView;if(!view){this.listScrollTop=list.scrollTop;return}this.listScrollFrame=view.requestAnimationFrame(()=>{this.listScrollFrame=void 0,this.listScrollTop=list.scrollTop})}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,commandPaletteEmpty:LYRA_DEFAULT_commandPaletteEmpty,commandPaletteLabel:LYRA_DEFAULT_commandPaletteLabel,commandPalettePlaceholder:LYRA_DEFAULT_commandPalettePlaceholder,commandPaletteResults:LYRA_DEFAULT_commandPaletteResults}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["commands"])}static{this.identityCollectionProperties=Object.freeze(["commands"])}static{this.identityEventDetailProperties=Object.freeze({"lr-select":Object.freeze(["command"])})}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-select"])}get open(){return this._open}set open(next){const normalized=!!next;if(normalized!==this._open){if(!this.hasUpdated){this.commitOpen(normalized);return}this.requestOpen(normalized)}}get effectiveCommands(){return this.normalizedForCommands!==this.commands&&(this.normalizedForCommands=this.commands,this.normalizedRows=projectCommands(this.commands)),this.normalizedRows}get searchHaystacks(){const locale=this.effectiveLocale,commands=this.effectiveCommands;return(this.haystacksFor!==commands||this.haystacksLocale!==locale)&&(this.haystacksFor=commands,this.haystacksLocale=locale,this.haystacks=commands.map(command=>[command.label,command.description??"",command.group??"",...command.keywords].join(" ").toLocaleLowerCase(locale))),this.haystacks}willUpdate(changed){if(super.willUpdate(changed),changed.has("open"))if(this.open)this.deferredFocusReturn.cancel(),this.focusReturnOpener=captureFocusReturnOpener(this),this.nativeModal.prepare(),this.activateOverlay();else{const hadOverlay=this.overlay!==void 0;this.nativeModal.hide(),this.overlay?.deactivate(),this.overlay=void 0;const opener=this.focusReturnOpener;this.focusReturnOpener=null,hadOverlay&&opener&&this.isConnected&&this.deferredFocusReturn.schedule({host:this,candidates:()=>[opener],isCurrent:()=>!this.open})}const rows=this.filtered;let nextIndex=this.activeCommandId?rows.findIndex(command=>command.commandId===this.activeCommandId):-1;if(nextIndex<0||rows[nextIndex]?.disabled){const start=Math.min(Math.max(this.activeIndex,0),Math.max(0,rows.length-1));nextIndex=this.seekEnabled(rows,start,1),nextIndex===-1&&(nextIndex=this.seekEnabled(rows,start-1,-1))}this.activeIndex=nextIndex,this.activeCommandId=nextIndex>=0?rows[nextIndex].commandId:void 0}updated(changed){super.updated(changed),changed.has("open")&&this.open&&(this.nativeModal.show(),this.overlay?.focusInitial()),changed.has("activeIndex")&&(this.renderRoot.querySelector('[part="command"][data-active="true"]')?.scrollIntoView({block:"nearest"}),this.scrollActiveIntoView());const list=this.renderRoot.querySelector('[part="list"]');this.observeList(list??void 0)}observeList(list){list!==this.observedList&&(this.observedList&&this.listResizeObserver?.unobserve(this.observedList),this.clearPitchSentinels(),this.observedList=list,list&&(this.listResizeObserver?.observe(list),queueMicrotask(()=>{this.isConnected&&this.observedList===list&&this.measureRowPitch()}))),this.observePitchSentinels()}observePitchSentinels(){const row=this.renderRoot.querySelector('[part="command"]')??void 0,group=this.renderRoot.querySelector('[part="group"]')??void 0;row!==this.observedRow&&(this.observedRow&&this.listResizeObserver?.unobserve(this.observedRow),this.observedRow=row,row&&this.listResizeObserver?.observe(row)),group!==this.observedGroup&&(this.observedGroup&&this.listResizeObserver?.unobserve(this.observedGroup),this.observedGroup=group,group&&this.listResizeObserver?.observe(group))}clearPitchSentinels(){this.observedRow&&this.listResizeObserver?.unobserve(this.observedRow),this.observedGroup&&this.listResizeObserver?.unobserve(this.observedGroup),this.observedRow=void 0,this.observedGroup=void 0}measureRowPitch(){const style=this.ownerDocument.defaultView?.getComputedStyle(this);if(!style)return;const row=resolveCssTokenLength(style.getPropertyValue("--lr-command-palette-row-height").trim()||style.getPropertyValue("--_lr-command-palette-row-height").trim(),{host:this}),group=resolveCssTokenLength(style.getPropertyValue("--lr-command-palette-group-height").trim()||style.getPropertyValue("--_lr-command-palette-group-height").trim(),{host:this});row!==void 0&&row>0&&row!==this.rowPitch&&(this.rowPitch=row),group!==void 0&&group>0&&group!==this.groupPitch&&(this.groupPitch=group)}scheduleRowPitchMeasurement(){if(this.rowPitchFrame!==void 0)return;const view=this.runtimeWindow??this.ownerDocument.defaultView;if(!view){this.measureRowPitch();return}this.rowPitchFrame=view.requestAnimationFrame(()=>{this.rowPitchFrame=void 0,this.isConnected&&this.measureRowPitch()})}connectedCallback(){super.connectedCallback();const view=this.ownerDocument.defaultView;this.runtimeWindow=view??void 0,view&&(registerHotkeyOwner(view,this,event=>this.isConnected&&this.matchesShortcut(event)),view.addEventListener("keydown",this.onGlobalKeyDown));const ResizeObserverCtor=view?.ResizeObserver;if(ResizeObserverCtor&&view){let observer;observer=new ResizeObserverCtor(entries=>{if(this.listResizeObserver!==observer||this.runtimeWindow!==view)return;this.scheduleRowPitchMeasurement();const entry=entries.find(candidate=>candidate.target===this.observedList);if(!entry)return;const height=entry.borderBoxSize?.[0]?.blockSize??entry.contentRect.height;height>0&&this.listViewportHeight!==height&&(this.listViewportHeight=height)}),this.listResizeObserver=observer}else this.listResizeObserver=void 0;this.hasUpdated&&this.observeList(this.renderRoot.querySelector('[part="list"]')??void 0),this.hasUpdated&&this.open&&(this.activateOverlay(),queueMicrotask(()=>{!this.isConnected||!this.open||(this.nativeModal.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){super.disconnectedCallback();const view=this.runtimeWindow;view&&(unregisterHotkeyOwner(view,this),view.removeEventListener("keydown",this.onGlobalKeyDown)),this.nativeModal.hide(),this.overlay?.suspend(),this.deferredFocusReturn.cancel(),this.listResizeObserver?.disconnect(),this.listResizeObserver=void 0,this.observedList=void 0,this.observedRow=void 0,this.observedGroup=void 0,this.listScrollFrame!==void 0&&(view?.cancelAnimationFrame(this.listScrollFrame),this.listScrollFrame=void 0),this.rowPitchFrame!==void 0&&(view?.cancelAnimationFrame(this.rowPitchFrame),this.rowPitchFrame=void 0),this.runtimeWindow=void 0}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="dialog"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>this.close("backdrop"),lockScroll:!0,suspendWhenUnrendered:!0})}openPalette(){this.requestOpen(!0)}close(reason="api"){this.requestOpen(!1,reason)}requestOpen(next,reason="api"){if(next===this._open||this.openRequestTarget===next)return!1;this.openRequestTarget=next;let prevented;return next?prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented:prevented=this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented,this.openRequestTarget=void 0,prevented?(this.toggleAttribute("open",this._open),!1):(next&&this.resetOpeningState(),this.commitOpen(next),next||this.emit("lr-close",{reason}),!0)}resetOpeningState(){this.queryText="",this.listScrollTop=0;const rows=this.filtered;this.setActiveIndex(rows,this.seekEnabled(rows,0,1))}commitOpen(next){if(next===this._open)return;const old=this._open;this._open=next,this.requestUpdate("open",old)}registerCommand(command){return this.commands=[...this.commands,command],()=>{this.commands=this.commands.filter(item=>item!==command)}}matchesShortcut(event){return matchesHotkey(parseHotkey(this.hotkey),event,detectPlatform((this.runtimeWindow??this.ownerDocument.defaultView)?.navigator)==="mac")}get filtered(){const locale=this.effectiveLocale,query=this.queryText.trim().toLocaleLowerCase(locale),commands=this.effectiveCommands;if(this.filteredForCommands!==commands||this.filteredForQuery!==query||this.filteredForLocale!==locale)if(this.filteredForCommands=commands,this.filteredForQuery=query,this.filteredForLocale=locale,!query)this.filteredRows=[...commands];else{const haystacks=this.searchHaystacks;this.filteredRows=commands.filter((_,index)=>haystacks[index].includes(query))}return this.filteredRows}select(command){command.disabled||(this.emit("lr-select",{command:command.source}),command.onSelect?.(),this.close("select"))}seekEnabled(rows,from,step){for(let index=from;index>=0&&index<rows.length;index+=step)if(!rows[index].disabled)return index;return-1}setActiveIndex(rows,index){this.activeIndex=index,this.activeCommandId=index>=0?rows[index].commandId:void 0}get resultModel(){const rows=this.filtered;if(this.resultModelFor===rows&&this.resultModelRowPitch===this.rowPitch&&this.resultModelGroupPitch===this.groupPitch&&this.resultModelCache)return this.resultModelCache;const resultRows=[],groups=[];let top=0,previousGroup,group;for(let index=0;index<rows.length;index++){const command=rows[index],label=command.group??"";(!group||label!==previousGroup)&&(group={index:groups.length,label,headingTop:label?top:void 0,rows:[]},groups.push(group),previousGroup=label,label&&(top+=this.groupPitch));const row={command,index,top,groupIndex:group.index};group.rows.push(row),resultRows.push(row),top+=this.rowPitch}return this.resultModelFor=rows,this.resultModelRowPitch=this.rowPitch,this.resultModelGroupPitch=this.groupPitch,this.resultModelCache={rows:resultRows,groups,totalHeight:top},this.resultModelCache}visibleGroups(model){if(model.rows.length===0)return[];const minimum=Math.max(0,this.listScrollTop-this.rowPitch*RESULT_OVERSCAN_ROWS),maximum=this.listScrollTop+this.listViewportHeight+this.rowPitch*RESULT_OVERSCAN_ROWS;let low=0,high=model.rows.length-1;for(;low<high;){const middle=low+high>>1;model.rows[middle].top+this.rowPitch<minimum?low=middle+1:high=middle}const visibleIndexes=new Set;for(let index=low;index<model.rows.length&&!(model.rows[index].top>maximum);index++)visibleIndexes.add(index);return this.activeIndex>=0&&visibleIndexes.add(this.activeIndex),model.groups.map(entry=>({...entry,rows:entry.rows.filter(row=>visibleIndexes.has(row.index))})).filter(entry=>entry.rows.length>0)}optionId(index){return`${this.listId}-opt-${index}`}scrollActiveIntoView(){if(this.activeIndex<0)return;const list=this.renderRoot.querySelector('[part="list"]'),row=this.resultModel.rows[this.activeIndex];if(!list||!row)return;const top=row.top,bottom=top+this.rowPitch;top<list.scrollTop?list.scrollTop=top:bottom>list.scrollTop+list.clientHeight&&(list.scrollTop=Math.max(0,bottom-list.clientHeight))}renderCommand(row,total){const command=row.command,active=row.index===this.activeIndex;return html`<button
1
+ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{DeferredFocusReturn,captureFocusReturnOpener}from"../../../internal/deferred-focus-return.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{parseHotkey,matchesHotkey,isIgnorableKeyEvent,registerHotkeyOwner,unregisterHotkeyOwner,resolveHotkeyOwner}from"../../../internal/hotkey.js";import{detectPlatform}from"../../../internal/platform.js";import{nextId}from"../../../internal/a11y.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{styles}from"./command-palette.styles.js";import{resolveCssTokenLength}from"../../../internal/css-token-length.js";import{closeIcon}from"../../../internal/icons.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_commandPaletteEmpty,LYRA_DEFAULT_commandPaletteLabel,LYRA_DEFAULT_commandPalettePlaceholder,LYRA_DEFAULT_commandPaletteResults}from"../../../internal/default-strings.generated.js";const COMMAND_ROW_HEIGHT=48,GROUP_ROW_HEIGHT=32,RESULT_OVERSCAN_ROWS=6,MAX_COMMAND_PALETTE_COMMANDS=1e4,MAX_COMMAND_PALETTE_KEYWORDS=1e4,EMPTY_CANONICAL_COMMANDS=Object.freeze([]),EMPTY_COMMAND_KEYWORDS=Object.freeze([]);function projectCommandKeywords(value){try{if(!Array.isArray(value))return EMPTY_COMMAND_KEYWORDS;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return EMPTY_COMMAND_KEYWORDS;const keywords=[];for(let index=0;index<Math.min(length.value,MAX_COMMAND_PALETTE_KEYWORDS);index+=1){const entry=getOwnDataDescriptor(value,String(index));entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR||typeof entry.value!="string"||keywords.push(entry.value)}return Object.freeze(keywords)}catch{return EMPTY_COMMAND_KEYWORDS}}function projectCommand(candidate){try{if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))return;const commandId=getOwnDataDescriptor(candidate,"commandId"),label=getOwnDataDescriptor(candidate,"label"),description=getOwnDataDescriptor(candidate,"description"),group=getOwnDataDescriptor(candidate,"group"),shortcut=getOwnDataDescriptor(candidate,"shortcut"),keywords=getOwnDataDescriptor(candidate,"keywords"),disabled=getOwnDataDescriptor(candidate,"disabled"),icon=getOwnDataDescriptor(candidate,"icon"),onSelect=getOwnDataDescriptor(candidate,"onSelect");if(commandId===MISSING_OWN_DATA_DESCRIPTOR||commandId===UNSAFE_OWN_DATA_DESCRIPTOR||label===MISSING_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||description===UNSAFE_OWN_DATA_DESCRIPTOR||group===UNSAFE_OWN_DATA_DESCRIPTOR||shortcut===UNSAFE_OWN_DATA_DESCRIPTOR||keywords===UNSAFE_OWN_DATA_DESCRIPTOR||disabled===UNSAFE_OWN_DATA_DESCRIPTOR||icon===UNSAFE_OWN_DATA_DESCRIPTOR||onSelect===UNSAFE_OWN_DATA_DESCRIPTOR||typeof commandId.value!="string"||commandId.value.trim()===""||typeof label.value!="string"||label.value.trim()==="")return;const descriptionValue=description===MISSING_OWN_DATA_DESCRIPTOR?void 0:description.value,groupValue=group===MISSING_OWN_DATA_DESCRIPTOR?void 0:group.value,shortcutValue=shortcut===MISSING_OWN_DATA_DESCRIPTOR?void 0:shortcut.value,keywordsValue=keywords===MISSING_OWN_DATA_DESCRIPTOR?void 0:keywords.value,disabledValue=disabled===MISSING_OWN_DATA_DESCRIPTOR?void 0:disabled.value,iconValue=icon===MISSING_OWN_DATA_DESCRIPTOR?void 0:icon.value,onSelectValue=onSelect===MISSING_OWN_DATA_DESCRIPTOR?void 0:onSelect.value;if(descriptionValue!==void 0&&typeof descriptionValue!="string"||groupValue!==void 0&&typeof groupValue!="string"||shortcutValue!==void 0&&typeof shortcutValue!="string"||disabledValue!==void 0&&typeof disabledValue!="boolean"||onSelectValue!==void 0&&typeof onSelectValue!="function")return;const keywordValues=projectCommandKeywords(keywordsValue);return Object.freeze({source:candidate,commandId:commandId.value,label:label.value,...descriptionValue===void 0?{}:{description:descriptionValue},...groupValue===void 0?{}:{group:groupValue},...shortcutValue===void 0?{}:{shortcut:shortcutValue},keywords:keywordValues,disabled:disabledValue??!1,...iconValue===void 0?{}:{icon:iconValue},...onSelectValue===void 0?{}:{onSelect:onSelectValue}})}catch{return}}function projectCommands(value){try{if(!Array.isArray(value))return EMPTY_CANONICAL_COMMANDS;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return EMPTY_CANONICAL_COMMANDS;const commands=[],seen=new Set;for(let index=0;index<Math.min(length.value,MAX_COMMAND_PALETTE_COMMANDS);index+=1){const entry=getOwnDataDescriptor(value,String(index));if(entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const command=projectCommand(entry.value);!command||seen.has(command.commandId)||(seen.add(command.commandId),commands.push(command))}return Object.freeze(commands)}catch{return EMPTY_CANONICAL_COMMANDS}}class LyraCommandPalette extends LyraElement{constructor(){super(...arguments),this._open=!1,this.commands=[],this.hotkey="mod+k",this.queryText="",this.activeIndex=0,this.listScrollTop=0,this.listViewportHeight=COMMAND_ROW_HEIGHT*10,this.rowPitch=COMMAND_ROW_HEIGHT,this.groupPitch=GROUP_ROW_HEIGHT,this.listId=nextId("command-list"),this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlay?.isTopmost()&&this.close("escape")},onUnexpectedClose:()=>{this.close("escape"),this.open&&this.nativeModal.show()}}),this.focusReturnOpener=null,this.deferredFocusReturn=new DeferredFocusReturn,this.haystacksLocale="",this.haystacks=[],this.filteredForQuery="",this.filteredForLocale="",this.filteredRows=[],this.normalizedRows=EMPTY_CANONICAL_COMMANDS,this.onGlobalKeyDown=event=>{if(isIgnorableKeyEvent(event))return;const view=this.runtimeWindow;!view||!this.matchesShortcut(event)||resolveHotkeyOwner(view,event)!==this||(event.preventDefault(),this.openPalette())},this.onKeyDown=event=>{if(event.isComposing||event.keyCode===229)return;const rows=this.filtered;if(event.key==="ArrowDown"){event.preventDefault();const next=this.seekEnabled(rows,this.activeIndex+1,1);next!==-1&&this.setActiveIndex(rows,next)}else if(event.key==="ArrowUp"){event.preventDefault();const previous=this.seekEnabled(rows,this.activeIndex-1,-1);previous!==-1&&this.setActiveIndex(rows,previous)}else if(event.key==="Enter"){const active=rows[this.activeIndex];active&&(event.preventDefault(),this.select(active))}},this.onInput=event=>{event.stopPropagation(),this.queryText=event.target.value,this.listScrollTop=0;const list=this.renderRoot.querySelector('[part="list"]');list&&(list.scrollTop=0);const rows=this.filtered;this.setActiveIndex(rows,this.seekEnabled(rows,0,1))},this.onClearSearch=()=>{if(this.queryText==="")return;this.queryText="",this.listScrollTop=0;const list=this.renderRoot.querySelector('[part="list"]');list&&(list.scrollTop=0);const rows=this.filtered;this.setActiveIndex(rows,this.seekEnabled(rows,0,1)),this.renderRoot.querySelector('[part="input"]')?.focus()},this.onSearchFocus=()=>{this.emit("focus")},this.onSearchBlur=()=>{this.emit("blur")},this.onListScroll=event=>{const list=event.currentTarget;if(this.listScrollFrame!==void 0)return;const view=this.runtimeWindow??this.ownerDocument.defaultView;if(!view){this.listScrollTop=list.scrollTop;return}this.listScrollFrame=view.requestAnimationFrame(()=>{this.listScrollFrame=void 0,this.listScrollTop=list.scrollTop})}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,commandPaletteEmpty:LYRA_DEFAULT_commandPaletteEmpty,commandPaletteLabel:LYRA_DEFAULT_commandPaletteLabel,commandPalettePlaceholder:LYRA_DEFAULT_commandPalettePlaceholder,commandPaletteResults:LYRA_DEFAULT_commandPaletteResults}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["commands"])}static{this.identityCollectionProperties=Object.freeze(["commands"])}static{this.identityEventDetailProperties=Object.freeze({"lr-select":Object.freeze(["command"])})}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-select"])}get open(){return this._open}set open(next){const normalized=!!next;if(normalized!==this._open){if(!this.hasUpdated){this.commitOpen(normalized);return}this.requestOpen(normalized)}}get effectiveCommands(){return this.normalizedForCommands!==this.commands&&(this.normalizedForCommands=this.commands,this.normalizedRows=projectCommands(this.commands)),this.normalizedRows}get searchHaystacks(){const locale=this.effectiveLocale,commands=this.effectiveCommands;return(this.haystacksFor!==commands||this.haystacksLocale!==locale)&&(this.haystacksFor=commands,this.haystacksLocale=locale,this.haystacks=commands.map(command=>[command.label,command.description??"",command.group??"",...command.keywords].join(" ").toLocaleLowerCase(locale))),this.haystacks}willUpdate(changed){if(super.willUpdate(changed),changed.has("open"))if(this.open)this.deferredFocusReturn.cancel(),this.focusReturnOpener=captureFocusReturnOpener(this),this.nativeModal.prepare(),this.activateOverlay();else{const hadOverlay=this.overlay!==void 0;this.nativeModal.hide(),this.overlay?.deactivate(),this.overlay=void 0;const opener=this.focusReturnOpener;this.focusReturnOpener=null,hadOverlay&&opener&&this.isConnected&&this.deferredFocusReturn.schedule({host:this,candidates:()=>[opener],isCurrent:()=>!this.open})}const rows=this.filtered;let nextIndex=this.activeCommandId?rows.findIndex(command=>command.commandId===this.activeCommandId):-1;if(nextIndex<0||rows[nextIndex]?.disabled){const start=Math.min(Math.max(this.activeIndex,0),Math.max(0,rows.length-1));nextIndex=this.seekEnabled(rows,start,1),nextIndex===-1&&(nextIndex=this.seekEnabled(rows,start-1,-1))}this.activeIndex=nextIndex,this.activeCommandId=nextIndex>=0?rows[nextIndex].commandId:void 0}updated(changed){super.updated(changed),changed.has("open")&&this.open&&(this.nativeModal.show(),this.overlay?.focusInitial()),changed.has("activeIndex")&&(this.renderRoot.querySelector('[part="command"][data-active="true"]')?.scrollIntoView({block:"nearest"}),this.scrollActiveIntoView());const list=this.renderRoot.querySelector('[part="list"]');this.observeList(list??void 0)}observeList(list){list!==this.observedList&&(this.observedList&&this.listResizeObserver?.unobserve(this.observedList),this.clearPitchSentinels(),this.observedList=list,list&&(this.listResizeObserver?.observe(list),queueMicrotask(()=>{this.isConnected&&this.observedList===list&&this.measureRowPitch()}))),this.observePitchSentinels()}observePitchSentinels(){const row=this.renderRoot.querySelector('[part="command"]')??void 0,group=this.renderRoot.querySelector('[part="group"]')??void 0;row!==this.observedRow&&(this.observedRow&&this.listResizeObserver?.unobserve(this.observedRow),this.observedRow=row,row&&this.listResizeObserver?.observe(row)),group!==this.observedGroup&&(this.observedGroup&&this.listResizeObserver?.unobserve(this.observedGroup),this.observedGroup=group,group&&this.listResizeObserver?.observe(group))}clearPitchSentinels(){this.observedRow&&this.listResizeObserver?.unobserve(this.observedRow),this.observedGroup&&this.listResizeObserver?.unobserve(this.observedGroup),this.observedRow=void 0,this.observedGroup=void 0}measureRowPitch(){const style=this.ownerDocument.defaultView?.getComputedStyle(this);if(!style)return;const row=resolveCssTokenLength(style.getPropertyValue("--lr-command-palette-row-height").trim()||style.getPropertyValue("--_lr-command-palette-row-height").trim(),{host:this}),group=resolveCssTokenLength(style.getPropertyValue("--lr-command-palette-group-height").trim()||style.getPropertyValue("--_lr-command-palette-group-height").trim(),{host:this});row!==void 0&&row>0&&row!==this.rowPitch&&(this.rowPitch=row),group!==void 0&&group>0&&group!==this.groupPitch&&(this.groupPitch=group)}scheduleRowPitchMeasurement(){if(this.rowPitchFrame!==void 0)return;const view=this.runtimeWindow??this.ownerDocument.defaultView;if(!view){this.measureRowPitch();return}this.rowPitchFrame=view.requestAnimationFrame(()=>{this.rowPitchFrame=void 0,this.isConnected&&this.measureRowPitch()})}connectedCallback(){super.connectedCallback();const view=this.ownerDocument.defaultView;this.runtimeWindow=view??void 0,view&&(registerHotkeyOwner(view,this,event=>this.isConnected&&this.matchesShortcut(event)),view.addEventListener("keydown",this.onGlobalKeyDown));const ResizeObserverCtor=view?.ResizeObserver;if(ResizeObserverCtor&&view){let observer;observer=new ResizeObserverCtor(entries=>{if(this.listResizeObserver!==observer||this.runtimeWindow!==view)return;this.scheduleRowPitchMeasurement();const entry=entries.find(candidate=>candidate.target===this.observedList);if(!entry)return;const height=entry.borderBoxSize?.[0]?.blockSize??entry.contentRect.height;height>0&&this.listViewportHeight!==height&&(this.listViewportHeight=height)}),this.listResizeObserver=observer}else this.listResizeObserver=void 0;this.hasUpdated&&this.observeList(this.renderRoot.querySelector('[part="list"]')??void 0),this.hasUpdated&&this.open&&(this.activateOverlay(),queueMicrotask(()=>{!this.isConnected||!this.open||(this.nativeModal.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){super.disconnectedCallback();const view=this.runtimeWindow;view&&(unregisterHotkeyOwner(view,this),view.removeEventListener("keydown",this.onGlobalKeyDown)),this.nativeModal.hide(),this.overlay?.suspend(),this.deferredFocusReturn.cancel(),this.listResizeObserver?.disconnect(),this.listResizeObserver=void 0,this.observedList=void 0,this.observedRow=void 0,this.observedGroup=void 0,this.listScrollFrame!==void 0&&(view?.cancelAnimationFrame(this.listScrollFrame),this.listScrollFrame=void 0),this.rowPitchFrame!==void 0&&(view?.cancelAnimationFrame(this.rowPitchFrame),this.rowPitchFrame=void 0),this.runtimeWindow=void 0}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="dialog"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>this.close("backdrop"),lockScroll:!0,suspendWhenUnrendered:!0})}openPalette(){this.requestOpen(!0)}close(reason="api"){this.requestOpen(!1,reason)}requestOpen(next,reason="api"){if(next===this._open||this.openRequestTarget===next)return!1;this.openRequestTarget=next;let prevented;return next?prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented:prevented=this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented,this.openRequestTarget=void 0,prevented?(this.toggleAttribute("open",this._open),!1):(next&&this.resetOpeningState(),this.commitOpen(next),next||this.emit("lr-close",{reason}),!0)}resetOpeningState(){this.queryText="",this.listScrollTop=0;const rows=this.filtered;this.setActiveIndex(rows,this.seekEnabled(rows,0,1))}commitOpen(next){if(next===this._open)return;const old=this._open;this._open=next,this.requestUpdate("open",old)}registerCommand(command){return this.commands=[...this.commands,command],()=>{this.commands=this.commands.filter(item=>item!==command)}}matchesShortcut(event){return matchesHotkey(parseHotkey(this.hotkey),event,detectPlatform((this.runtimeWindow??this.ownerDocument.defaultView)?.navigator)==="mac")}get filtered(){const locale=this.effectiveLocale,query=this.queryText.trim().toLocaleLowerCase(locale),commands=this.effectiveCommands;if(this.filteredForCommands!==commands||this.filteredForQuery!==query||this.filteredForLocale!==locale)if(this.filteredForCommands=commands,this.filteredForQuery=query,this.filteredForLocale=locale,!query)this.filteredRows=[...commands];else{const haystacks=this.searchHaystacks;this.filteredRows=commands.filter((_,index)=>haystacks[index].includes(query))}return this.filteredRows}select(command){command.disabled||(this.emit("lr-select",{command:command.source}),command.onSelect?.(),this.close("select"))}seekEnabled(rows,from,step){for(let index=from;index>=0&&index<rows.length;index+=step)if(!rows[index].disabled)return index;return-1}setActiveIndex(rows,index){this.activeIndex=index,this.activeCommandId=index>=0?rows[index].commandId:void 0}get resultModel(){const rows=this.filtered;if(this.resultModelFor===rows&&this.resultModelRowPitch===this.rowPitch&&this.resultModelGroupPitch===this.groupPitch&&this.resultModelCache)return this.resultModelCache;const resultRows=[],groups=[];let top=0,previousGroup,group;for(let index=0;index<rows.length;index++){const command=rows[index],label=command.group??"";(!group||label!==previousGroup)&&(group={index:groups.length,label,headingTop:label?top:void 0,rows:[]},groups.push(group),previousGroup=label,label&&(top+=this.groupPitch));const row={command,index,top,groupIndex:group.index};group.rows.push(row),resultRows.push(row),top+=this.rowPitch}return this.resultModelFor=rows,this.resultModelRowPitch=this.rowPitch,this.resultModelGroupPitch=this.groupPitch,this.resultModelCache={rows:resultRows,groups,totalHeight:top},this.resultModelCache}visibleGroups(model){if(model.rows.length===0)return[];const minimum=Math.max(0,this.listScrollTop-this.rowPitch*RESULT_OVERSCAN_ROWS),maximum=this.listScrollTop+this.listViewportHeight+this.rowPitch*RESULT_OVERSCAN_ROWS;let low=0,high=model.rows.length-1;for(;low<high;){const middle=low+high>>1;model.rows[middle].top+this.rowPitch<minimum?low=middle+1:high=middle}const groups=[];let group;const appendRow=row=>{group?.index!==row.groupIndex&&(group={...model.groups[row.groupIndex],rows:[]},groups.push(group)),group.rows.push(row)},active=model.rows[this.activeIndex];active&&this.activeIndex<low&&appendRow(active);let index=low;for(;index<model.rows.length;index++){const row=model.rows[index];if(row.top>maximum)break;appendRow(row)}return active&&this.activeIndex>=index&&appendRow(active),groups}optionId(index){return`${this.listId}-opt-${index}`}scrollActiveIntoView(){if(this.activeIndex<0)return;const list=this.renderRoot.querySelector('[part="list"]'),row=this.resultModel.rows[this.activeIndex];if(!list||!row)return;const top=row.top,bottom=top+this.rowPitch;top<list.scrollTop?list.scrollTop=top:bottom>list.scrollTop+list.clientHeight&&(list.scrollTop=Math.max(0,bottom-list.clientHeight))}renderCommand(row,total){const command=row.command,active=row.index===this.activeIndex;return html`<button
2
2
  id=${this.optionId(row.index)}
3
3
  part="command"
4
4
  role="option"
@@ -9,8 +9,6 @@ export type LyraDetailsIconPlacement='start'|'end';
9
9
  export type LyraDetailsToggleSource='user'|'programmatic'|'peer';
10
10
  /** Payload emitted with `lr-toggle` after an accepted disclosure transition renders. */
11
11
  export interface LyraDetailsToggleDetail{
12
- /** @deprecated Use `expanded`, which carries the same value; removal not before 23.0.0. */
13
- open:boolean;
14
12
  /** Whether the disclosure is now open. */
15
13
  expanded:boolean;source:LyraDetailsToggleSource;}export interface LyraDetailsEventMap{'lr-show':CustomEvent<null>;'lr-after-show':CustomEvent<null>;'lr-hide':CustomEvent<null>;'lr-after-hide':CustomEvent<null>;'lr-toggle':CustomEvent<LyraDetailsToggleDetail>;}
16
14
  /**
@@ -52,8 +50,8 @@ expanded:boolean;source:LyraDetailsToggleSource;}export interface LyraDetailsEve
52
50
  * @event lr-after-hide - The panel is closed and its marker transition has finished. Nested
53
51
  * disclosures emit the same name; handle it as this panel's event only when
54
52
  * `event.target === event.currentTarget` (see `lr-toggle`).
55
- * @event lr-toggle - The disclosure state changed. `detail: { expanded, open, source }`, where
56
- * `expanded` is the new state (the deprecated `open` key carries the same value) and `source` is
53
+ * @event lr-toggle - The disclosure state changed. `detail: { expanded, source }`, where
54
+ * `expanded` is the new state and `source` is
57
55
  * `user` for summary activation, `programmatic` for `show()`/`hide()`/`open`, or `peer` when a
58
56
  * named disclosure closes this panel. Reports the direction and source of an accepted state
59
57
  * change. `<lr-accordion>` coordinates its direct `<lr-accordion-item>` children; Details