@aceshooting/lyra-ui 21.0.0 → 21.1.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 (272) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +6 -3
  3. package/custom-elements.json +1 -1
  4. package/dist/ai/runtime.js +1 -1
  5. package/dist/ai/types.d.ts +13 -5
  6. package/dist/cli/lyra-rename-ledger.mjs +1 -0
  7. package/dist/cli/migrate-wa.mjs +33 -13
  8. package/dist/cli/migration-contract.json +1 -1
  9. package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +5 -3
  10. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +3 -2
  11. package/dist/components/agent-tools/tool-call-block/tool-call-block.class.d.ts +15 -3
  12. package/dist/components/agent-tools/tool-call-block/tool-call-block.class.js +3 -3
  13. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +24 -8
  14. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +3 -3
  15. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +4 -0
  16. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.d.ts +9 -5
  17. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +2 -2
  18. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.styles.js +1 -1
  19. package/dist/components/agent-tools/tool-status.js +2 -2
  20. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +8 -0
  21. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +3 -2
  22. package/dist/components/agent-tools/tool-timeline/tool-timeline.styles.js +1 -1
  23. package/dist/components/agent-tools/trace-tree/span.d.ts +2 -2
  24. package/dist/components/charts/chart/box-plot.class.d.ts +3 -1
  25. package/dist/components/charts/chart/box-plot.class.js +9 -9
  26. package/dist/components/charts/chart/chart-bidi.d.ts +109 -0
  27. package/dist/components/charts/chart/chart-bidi.js +1 -0
  28. package/dist/components/charts/chart/chart.class.d.ts +17 -2
  29. package/dist/components/charts/chart/chart.class.js +10 -8
  30. package/dist/components/charts/chart/histogram.class.js +1 -1
  31. package/dist/components/charts/chart/lite-chart.class.d.ts +24 -5
  32. package/dist/components/charts/chart/lite-chart.class.js +9 -9
  33. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  34. package/dist/components/conversation/code-block/shiki-dark-theme.d.ts +2 -2
  35. package/dist/components/conversation/code-block/shiki-dark-theme.js +1 -1
  36. package/dist/components/conversation/conversation-item/conversation-item.class.d.ts +18 -2
  37. package/dist/components/conversation/conversation-item/conversation-item.class.js +3 -3
  38. package/dist/components/conversation/conversation-item/conversation-item.styles.js +1 -1
  39. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  40. package/dist/components/conversation/markdown/markdown-core.class.d.ts +3 -1
  41. package/dist/components/conversation/markdown/markdown.class.d.ts +3 -1
  42. package/dist/components/conversation/message-actions/message-actions.class.d.ts +7 -2
  43. package/dist/components/conversation/message-actions/message-actions.class.js +2 -2
  44. package/dist/components/conversation/message-parts/message-parts.class.d.ts +6 -2
  45. package/dist/components/conversation/message-parts/message-parts.class.js +5 -3
  46. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +3 -2
  47. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  48. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +1 -5
  49. package/dist/components/conversation/streaming-text/streaming-text-base.class.js +2 -2
  50. package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +7 -1
  51. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +3 -4
  52. package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +7 -1
  53. package/dist/components/conversation/streaming-text/streaming-text.class.js +3 -4
  54. package/dist/components/conversation/thread-list/thread-list.class.d.ts +13 -2
  55. package/dist/components/conversation/thread-list/thread-list.class.js +3 -3
  56. package/dist/components/data/data-grid/data-grid.class.js +1 -1
  57. package/dist/components/data/document-library/document-library.class.js +2 -0
  58. package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
  59. package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
  60. package/dist/components/data/flow-node/flow-node.class.d.ts +6 -2
  61. package/dist/components/data/flow-node/flow-node.class.js +6 -2
  62. package/dist/components/data/flow-node/flow-node.styles.js +1 -1
  63. package/dist/components/data/gauge/gauge.styles.js +1 -1
  64. package/dist/components/data/heatmap/heatmap.class.d.ts +3 -0
  65. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  66. package/dist/components/data/heatmap/heatmap.styles.js +1 -1
  67. package/dist/components/data/sparkline/sparkline.class.d.ts +5 -3
  68. package/dist/components/data/stat/stat.class.d.ts +4 -3
  69. package/dist/components/data/table/table.class.d.ts +32 -5
  70. package/dist/components/data/table/table.class.js +3 -2
  71. package/dist/components/forms/button/button.class.d.ts +7 -1
  72. package/dist/components/forms/button/button.styles.js +1 -1
  73. package/dist/components/forms/date-picker/date-input.styles.js +1 -1
  74. package/dist/components/forms/input/input.styles.js +1 -1
  75. package/dist/components/forms/rubric-form/rubric-form.class.js +1 -0
  76. package/dist/components/layout/app-rail/app-rail.class.d.ts +50 -11
  77. package/dist/components/layout/app-rail/app-rail.class.js +2 -2
  78. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  79. package/dist/components/layout/menu/menu.class.d.ts +6 -5
  80. package/dist/components/layout/split-panel/split-panel.class.d.ts +2 -1
  81. package/dist/components/media/flag/language-map.d.ts +8 -0
  82. package/dist/components/media/flag/language-map.js +1 -1
  83. package/dist/components/media/map/map-loader.d.ts +7 -1
  84. package/dist/components/media/map/map.class.d.ts +111 -5
  85. package/dist/components/media/map/map.class.js +3 -3
  86. package/dist/components/media/media-card/media-card.class.d.ts +18 -5
  87. package/dist/components/media/media-card/media-card.class.js +1 -1
  88. package/dist/components/overlays/overlay/popover.class.d.ts +20 -0
  89. package/dist/components/overlays/overlay/popover.class.js +2 -2
  90. package/dist/components/retrieval/graph/graph.class.d.ts +3 -3
  91. package/dist/components/retrieval/graph/graph.class.js +1 -1
  92. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +5 -3
  93. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +3 -2
  94. package/dist/components/retrieval/mind-map/mind-map.class.d.ts +3 -3
  95. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  96. package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +4 -1
  97. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +5 -1
  98. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +4 -1
  99. package/dist/components/retrieval/source-picker/source-picker.class.js +5 -1
  100. package/dist/components/utility/icon/icon.class.d.ts +9 -3
  101. package/dist/components/utility/icon/icon.class.js +1 -1
  102. package/dist/components/utility/mutation-observer/mutation-observer.class.d.ts +14 -8
  103. package/dist/components/utility/mutation-observer/mutation-observer.class.js +1 -1
  104. package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +6 -1
  105. package/dist/components/viewers/document-viewer/document-viewer.class.js +7 -1
  106. package/dist/components/viewers/document-viewer/registry.d.ts +12 -3
  107. package/dist/components/viewers/geojson-view/geojson-view.class.d.ts +13 -5
  108. package/dist/components/viewers/geojson-view/geojson-view.class.js +1 -1
  109. package/dist/components/viewers/geojson-view/geojson-viewer.class.d.ts +3 -2
  110. package/dist/custom-elements-jsx.d.ts +1 -1
  111. package/dist/events.d.ts +644 -1242
  112. package/dist/internal/anchored-overlay-runtime.d.ts +2 -2
  113. package/dist/internal/cell-range.d.ts +0 -6
  114. package/dist/internal/cell-range.js +1 -1
  115. package/dist/internal/css-token-length.d.ts +7 -0
  116. package/dist/internal/css-token-length.js +1 -0
  117. package/dist/internal/default-strings.generated.d.ts +1 -1
  118. package/dist/internal/default-strings.generated.js +1 -1
  119. package/dist/internal/deferred-focus-return.d.ts +7 -4
  120. package/dist/internal/deferred-focus-return.js +1 -1
  121. package/dist/internal/dev-mode-attribute-warning.d.ts +35 -0
  122. package/dist/internal/dev-mode-attribute-warning.js +1 -1
  123. package/dist/internal/localization-runtime.js +1 -1
  124. package/dist/internal/localization-types.d.ts +1 -1
  125. package/dist/internal/localization.js +2 -2
  126. package/dist/internal/package-metadata.d.ts +1 -1
  127. package/dist/internal/package-metadata.js +1 -1
  128. package/dist/internal/papaparse-loader.d.ts +1 -1
  129. package/dist/internal/papaparse-loader.js +1 -1
  130. package/dist/internal/positioner.d.ts +10 -0
  131. package/dist/internal/positioner.js +1 -1
  132. package/dist/internal/shared-unions.d.ts +2 -1
  133. package/dist/internal/slotted-overlay-controller.d.ts +20 -0
  134. package/dist/internal/slotted-overlay-controller.js +1 -0
  135. package/dist/internal/text-quote.d.ts +1 -1
  136. package/dist/internal/text-quote.js +1 -1
  137. package/dist/internal/theme-observation.d.ts +4 -0
  138. package/dist/internal/theme-observation.js +1 -0
  139. package/dist/internal/theme-watcher.js +1 -1
  140. package/dist/localization.d.ts +6 -1
  141. package/dist/localization.js +1 -1
  142. package/dist/lyra.d.ts +1 -1
  143. package/dist/lyra.js +1 -1
  144. package/dist/svelte.d.ts +1 -1
  145. package/dist/testing/lyra-tag-event-map.js +1 -1
  146. package/dist/translations/ar/agent-tools.js +1 -1
  147. package/dist/translations/cs/agent-tools.js +1 -1
  148. package/dist/translations/da/agent-tools.js +1 -1
  149. package/dist/translations/de/agent-tools.js +1 -1
  150. package/dist/translations/de-CH/agent-tools.js +1 -1
  151. package/dist/translations/es/agent-tools.js +1 -1
  152. package/dist/translations/fa/agent-tools.js +1 -1
  153. package/dist/translations/fi/agent-tools.js +1 -1
  154. package/dist/translations/fr/agent-tools.js +1 -1
  155. package/dist/translations/he/agent-tools.js +1 -1
  156. package/dist/translations/hi/agent-tools.js +1 -1
  157. package/dist/translations/hr/agent-tools.js +1 -1
  158. package/dist/translations/hu/agent-tools.js +1 -1
  159. package/dist/translations/id/agent-tools.js +1 -1
  160. package/dist/translations/it/agent-tools.js +1 -1
  161. package/dist/translations/ja/agent-tools.js +1 -1
  162. package/dist/translations/kk/agent-tools.js +1 -1
  163. package/dist/translations/ko/agent-tools.js +1 -1
  164. package/dist/translations/nb/agent-tools.js +1 -1
  165. package/dist/translations/nl/agent-tools.js +1 -1
  166. package/dist/translations/nn/agent-tools.js +1 -1
  167. package/dist/translations/pl/agent-tools.js +1 -1
  168. package/dist/translations/pt-BR/agent-tools.js +1 -1
  169. package/dist/translations/pt-PT/agent-tools.js +1 -1
  170. package/dist/translations/pt-PT/charts.js +1 -1
  171. package/dist/translations/pt-PT/conversation.js +1 -1
  172. package/dist/translations/pt-PT/data.js +1 -1
  173. package/dist/translations/pt-PT/forms.js +1 -1
  174. package/dist/translations/pt-PT/layout.js +1 -1
  175. package/dist/translations/pt-PT/media.js +1 -1
  176. package/dist/translations/pt-PT/retrieval.js +1 -1
  177. package/dist/translations/pt-PT/shared.js +1 -1
  178. package/dist/translations/pt-PT/utility.js +1 -1
  179. package/dist/translations/pt-PT/viewers.js +2 -2
  180. package/dist/translations/ro/agent-tools.js +1 -1
  181. package/dist/translations/ru/agent-tools.js +1 -1
  182. package/dist/translations/sl/agent-tools.js +1 -1
  183. package/dist/translations/sv/agent-tools.js +1 -1
  184. package/dist/translations/tr/agent-tools.js +1 -1
  185. package/dist/translations/uk/agent-tools.js +1 -1
  186. package/dist/translations/zh-CN/agent-tools.js +1 -1
  187. package/dist/translations/zh-TW/agent-tools.js +1 -1
  188. package/dist/utilities/index.d.ts +1 -1
  189. package/dist/utilities/index.js +1 -1
  190. package/dist/utilities/localization.d.ts +28 -10
  191. package/dist/vue.d.ts +1 -1
  192. package/llms/components/lr-accordion-item.md +2 -344
  193. package/llms/components/lr-accordion.md +2 -344
  194. package/llms/components/lr-app-rail-group.md +2 -721
  195. package/llms/components/lr-app-rail-item.md +2 -721
  196. package/llms/components/lr-app-rail.md +29 -4
  197. package/llms/components/lr-bar-chart.md +2 -87
  198. package/llms/components/lr-box-plot.md +1 -1
  199. package/llms/components/lr-breadcrumb-item.md +2 -67
  200. package/llms/components/lr-bubble-chart.md +2 -87
  201. package/llms/components/lr-button.md +7 -0
  202. package/llms/components/lr-chart.md +4 -5
  203. package/llms/components/lr-chip-group.md +2 -272
  204. package/llms/components/lr-conversation-item.md +20 -2
  205. package/llms/components/lr-date-input.md +2 -457
  206. package/llms/components/lr-date-picker.md +6 -2
  207. package/llms/components/lr-document-library.md +3 -3
  208. package/llms/components/lr-document-viewer.md +14 -5
  209. package/llms/components/lr-doughnut-chart.md +2 -87
  210. package/llms/components/lr-dropdown-item.md +2 -306
  211. package/llms/components/lr-dropdown.md +6 -0
  212. package/llms/components/lr-flag.md +9 -1
  213. package/llms/components/lr-flow-node.md +4 -1
  214. package/llms/components/lr-geojson-view.md +3 -90
  215. package/llms/components/lr-geojson-viewer.md +13 -5
  216. package/llms/components/lr-icon-button.md +4 -1
  217. package/llms/components/lr-icon.md +14 -6
  218. package/llms/components/lr-input.md +9 -2
  219. package/llms/components/lr-lite-chart.md +17 -9
  220. package/llms/components/lr-map.md +87 -2
  221. package/llms/components/lr-markdown-core.md +5 -4
  222. package/llms/components/lr-markdown.md +4 -2
  223. package/llms/components/lr-media-card.md +10 -5
  224. package/llms/components/lr-menu-item.md +2 -306
  225. package/llms/components/lr-menu.md +9 -6
  226. package/llms/components/lr-menubar-item.md +2 -125
  227. package/llms/components/lr-message-actions.md +4 -1
  228. package/llms/components/lr-message-parts.md +14 -5
  229. package/llms/components/lr-mutation-observer.md +12 -6
  230. package/llms/components/lr-navigation-menu-item.md +2 -237
  231. package/llms/components/lr-number-input.md +4 -0
  232. package/llms/components/lr-option.md +2 -712
  233. package/llms/components/lr-pie-chart.md +2 -87
  234. package/llms/components/lr-polar-area-chart.md +2 -87
  235. package/llms/components/lr-popover.md +10 -0
  236. package/llms/components/lr-prompt-input.md +5 -1
  237. package/llms/components/lr-radar-chart.md +2 -87
  238. package/llms/components/lr-reorder-item.md +2 -157
  239. package/llms/components/lr-result-field.md +2 -117
  240. package/llms/components/lr-retrieval-results.md +3 -1
  241. package/llms/components/lr-rubric-form.md +3 -2
  242. package/llms/components/lr-scatter-chart.md +2 -87
  243. package/llms/components/lr-selection-toolbar.md +4 -2
  244. package/llms/components/lr-source-card.md +2 -186
  245. package/llms/components/lr-source-picker.md +3 -1
  246. package/llms/components/lr-sparkline.md +9 -4
  247. package/llms/components/lr-split-panel.md +5 -3
  248. package/llms/components/lr-stat.md +4 -3
  249. package/llms/components/lr-streaming-text-core.md +7 -5
  250. package/llms/components/lr-streaming-text.md +9 -6
  251. package/llms/components/lr-swatch-picker.md +130 -0
  252. package/llms/components/lr-tag.md +2 -177
  253. package/llms/components/lr-thread-list.md +27 -4
  254. package/llms/components/lr-timeline-item.md +2 -120
  255. package/llms/components/lr-toast-item.md +2 -223
  256. package/llms/components/lr-tool-call-block.md +12 -3
  257. package/llms/components/lr-tool-call-chip.md +12 -6
  258. package/llms/components/lr-tool-param-form.md +3 -2
  259. package/llms/components/lr-tool-result-dialog.md +7 -3
  260. package/llms/components/lr-tool-result-view.md +4 -3
  261. package/llms/components/lr-tool-timeline.md +12 -5
  262. package/llms/components/lr-tree-item.md +2 -354
  263. package/llms/index.md +22 -4
  264. package/llms/migration.md +75 -1
  265. package/llms/peers.md +1 -1
  266. package/llms/shared.md +86 -39
  267. package/llms-full.txt +739 -163
  268. package/package.json +6 -6
  269. package/registrations.json +1 -1
  270. package/vscode-css-data.json +1 -1
  271. package/vscode-html-data.json +1 -1
  272. package/web-types.json +1 -1
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};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{focusFirstAvailable}from"../../../internal/focus-navigation.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"]),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{constructor(){super(...arguments),this.iconOnlyBreakpoint="960px",this.mobileBreakpoint="600px",this.triggerCollapses=!1,this.hotkey="",this.accessibleLabel=null,this.hideToggle=!1,this.collapsible=!1,this.trigger=null,this.for="",this.resizable=!1,this.persist="open width",this.minRailWidthPx=190,this.maxRailWidthPx=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.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))}}}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}}static{this.knownUnobservedAttributes=["mode","dragging"]}static{this.styles=[LyraElement.styles,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,"railWidthPx",{initial:void 0,attribute:"rail-width-px",type:Number})}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.minRailWidthPx,190,0)}get safeMaxRailWidthPx(){return Math.max(this.safeMinRailWidthPx,finiteRange(this.maxRailWidthPx,440,0))}get effectiveRailWidthPx(){return this.railWidthPx!=null?finiteRange(this.railWidthPx,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,"railWidthPx")&&typeof parsed.railWidthPx=="number"&&Number.isFinite(parsed.railWidthPx)&&(this.railWidthPx=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.railWidthPx),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.ownerDocument.defaultView)&&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._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("railWidthPx")&&!this.dragging||changed.has("preferredMode")||changed.has("persist"))&&this.persistState(),this.persistReady=!0,this.baseEl&&(this.resizable&&this.railWidthPx!=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.overlayHandle?.focusInitial())),this.hasUpdated&&queueMicrotask(()=>{this.isConnected&&(this.syncSlottedItems(),this.syncExternalTriggerA11y())})}disconnectedCallback(){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}activateMobileOverlay(){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){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()})}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)}focusFirstAvailable(this)||this.restoreFallbackTabIndex?.()}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.railWidthPx!=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});return}const mode=this._mode,open=this.open;this.emit("lr-toggle",{open:next},{cancelable:!0}).defaultPrevented||this._mode!==mode||this.open!==open||(this.open=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.railWidthPx=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 html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};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{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"]),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{constructor(){super(...arguments),this.iconOnlyBreakpoint="960px",this.mobileBreakpoint="600px",this.triggerCollapses=!1,this.hotkey="",this.accessibleLabel=null,this.hideToggle=!1,this.collapsible=!1,this.trigger=null,this.for="",this.focusFallback=null,this.resizable=!1,this.persist="open width",this.minRailWidthPx=190,this.maxRailWidthPx=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.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))}}}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}}static{this.knownUnobservedAttributes=["mode","dragging"]}static{this.styles=[LyraElement.styles,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,"railWidthPx",{initial:void 0,attribute:"rail-width-px",type:Number})}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.minRailWidthPx,190,0)}get safeMaxRailWidthPx(){return Math.max(this.safeMinRailWidthPx,finiteRange(this.maxRailWidthPx,440,0))}get effectiveRailWidthPx(){return this.railWidthPx!=null?finiteRange(this.railWidthPx,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,"railWidthPx")&&typeof parsed.railWidthPx=="number"&&Number.isFinite(parsed.railWidthPx)&&(this.railWidthPx=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.railWidthPx),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.ownerDocument.defaultView)&&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._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("railWidthPx")&&!this.dragging||changed.has("preferredMode")||changed.has("persist"))&&this.persistState(),this.persistReady=!0,this.baseEl&&(this.resizable&&this.railWidthPx!=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.overlayHandle?.focusInitial())),this.hasUpdated&&queueMicrotask(()=>{this.isConnected&&(this.syncSlottedItems(),this.syncExternalTriggerA11y())})}disconnectedCallback(){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(){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){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.railWidthPx!=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});return}const mode=this._mode,open=this.open;this.emit("lr-toggle",{open:next},{cancelable:!0}).defaultPrevented||this._mode!==mode||this.open!==open||(this.open=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.railWidthPx=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 html`
2
2
  <button
3
3
  part="toggle"
4
4
  type="button"
@@ -52,4 +52,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
52
52
  @pointerdown=${this.onResizerPointerDown}
53
53
  @keydown=${this.onResizerKeyDown}
54
54
  ><span part="resizer-track"></span></div>`:nothing}
55
- `}}__decorate([property({attribute:"icon-only-breakpoint",useDefault:!0})],LyraAppRail.prototype,"iconOnlyBreakpoint",void 0),__decorate([property({attribute:"mobile-breakpoint",useDefault:!0})],LyraAppRail.prototype,"mobileBreakpoint",void 0),__decorate([property({type:Boolean,reflect:!0,noAccessor:!0})],LyraAppRail.prototype,"open",void 0),__decorate([property({reflect:!0,converter:APP_RAIL_FRAME})],LyraAppRail.prototype,"frame",null),__decorate([property({type:Boolean,reflect:!0,attribute:"trigger-collapses"})],LyraAppRail.prototype,"triggerCollapses",void 0),__decorate([property({useDefault:!0})],LyraAppRail.prototype,"hotkey",void 0),__decorate([property()],LyraAppRail.prototype,"label",void 0),__decorate([property({attribute:"aria-label"})],LyraAppRail.prototype,"accessibleLabel",void 0),__decorate([property({attribute:"preferred-mode",noAccessor:!0})],LyraAppRail.prototype,"preferredMode",void 0),__decorate([property({attribute:"force-mode"})],LyraAppRail.prototype,"forceMode",null),__decorate([property({type:Boolean,reflect:!0,attribute:"hide-toggle"})],LyraAppRail.prototype,"hideToggle",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAppRail.prototype,"collapsible",void 0),__decorate([property({attribute:!1})],LyraAppRail.prototype,"trigger",void 0),__decorate([property()],LyraAppRail.prototype,"for",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAppRail.prototype,"resizable",void 0),__decorate([property({attribute:"storage-key"})],LyraAppRail.prototype,"storageKey",void 0),__decorate([property({useDefault:!0})],LyraAppRail.prototype,"persist",void 0),__decorate([property({type:Number,attribute:"rail-width-px",noAccessor:!0})],LyraAppRail.prototype,"railWidthPx",void 0),__decorate([property({type:Number,attribute:"min-rail-width-px",useDefault:!0})],LyraAppRail.prototype,"minRailWidthPx",void 0),__decorate([property({type:Number,attribute:"max-rail-width-px",useDefault:!0})],LyraAppRail.prototype,"maxRailWidthPx",void 0),__decorate([state()],LyraAppRail.prototype,"hasHeaderSlot",void 0),__decorate([state()],LyraAppRail.prototype,"hasFooterSlot",void 0),__decorate([query('[part="base"], [part="panel"]')],LyraAppRail.prototype,"baseEl",void 0),__decorate([query('[part="toggle"]')],LyraAppRail.prototype,"toggleEl",void 0);export{LyraAppRail,computeAppRailMode};
55
+ `}}__decorate([property({attribute:"icon-only-breakpoint",useDefault:!0})],LyraAppRail.prototype,"iconOnlyBreakpoint",void 0),__decorate([property({attribute:"mobile-breakpoint",useDefault:!0})],LyraAppRail.prototype,"mobileBreakpoint",void 0),__decorate([property({type:Boolean,reflect:!0,noAccessor:!0})],LyraAppRail.prototype,"open",void 0),__decorate([property({reflect:!0,converter:APP_RAIL_FRAME})],LyraAppRail.prototype,"frame",null),__decorate([property({type:Boolean,reflect:!0,attribute:"trigger-collapses"})],LyraAppRail.prototype,"triggerCollapses",void 0),__decorate([property({useDefault:!0})],LyraAppRail.prototype,"hotkey",void 0),__decorate([property()],LyraAppRail.prototype,"label",void 0),__decorate([property({attribute:"aria-label"})],LyraAppRail.prototype,"accessibleLabel",void 0),__decorate([property({attribute:"preferred-mode",noAccessor:!0})],LyraAppRail.prototype,"preferredMode",void 0),__decorate([property({attribute:"force-mode"})],LyraAppRail.prototype,"forceMode",null),__decorate([property({type:Boolean,reflect:!0,attribute:"hide-toggle"})],LyraAppRail.prototype,"hideToggle",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAppRail.prototype,"collapsible",void 0),__decorate([property({attribute:!1})],LyraAppRail.prototype,"trigger",void 0),__decorate([property()],LyraAppRail.prototype,"for",void 0),__decorate([property({attribute:"focus-fallback"})],LyraAppRail.prototype,"focusFallback",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAppRail.prototype,"resizable",void 0),__decorate([property({attribute:"storage-key"})],LyraAppRail.prototype,"storageKey",void 0),__decorate([property({useDefault:!0})],LyraAppRail.prototype,"persist",void 0),__decorate([property({type:Number,attribute:"rail-width-px",noAccessor:!0})],LyraAppRail.prototype,"railWidthPx",void 0),__decorate([property({type:Number,attribute:"min-rail-width-px",useDefault:!0})],LyraAppRail.prototype,"minRailWidthPx",void 0),__decorate([property({type:Number,attribute:"max-rail-width-px",useDefault:!0})],LyraAppRail.prototype,"maxRailWidthPx",void 0),__decorate([state()],LyraAppRail.prototype,"hasHeaderSlot",void 0),__decorate([state()],LyraAppRail.prototype,"hasFooterSlot",void 0),__decorate([query('[part="base"], [part="panel"]')],LyraAppRail.prototype,"baseEl",void 0),__decorate([query('[part="toggle"]')],LyraAppRail.prototype,"toggleEl",void 0);export{LyraAppRail,computeAppRailMode};
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};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{resolveCssLength}from"../../../internal/css-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.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.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,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){super.willUpdate(changed),changed.has("open")&&(this.open?this.activateOverlay():(this.overlay?.deactivate(),this.overlay=void 0));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.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=resolveCssLength(style.getPropertyValue("--lr-command-palette-row-height").trim()||style.getPropertyValue("--_lr-command-palette-row-height").trim(),{host:this}),group=resolveCssLength(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.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback();const view=this.runtimeWindow;view&&(unregisterHotkeyOwner(view,this),view.removeEventListener("keydown",this.onGlobalKeyDown)),this.overlay?.suspend(),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(),onBackdrop:()=>this.close(),lockScroll:!0,suspendWhenUnrendered:!0})}openPalette(){this.requestOpen(!0)}close(){this.requestOpen(!1)}requestOpen(next){if(next===this._open||this.openRequestTarget===next)return!1;this.openRequestTarget=next;let prevented;if(next){const showPrevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,openPrevented=this.emit("lr-open",null,{cancelable:!0}).defaultPrevented;prevented=showPrevented||openPrevented}else prevented=this.emit("lr-close",null,{cancelable:!0}).defaultPrevented;return this.openRequestTarget=void 0,prevented?(this.toggleAttribute("open",this._open),!1):(next&&this.resetOpeningState(),this.commitOpen(next),!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())}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
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};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.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.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,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){super.willUpdate(changed),changed.has("open")&&(this.open?this.activateOverlay():(this.overlay?.deactivate(),this.overlay=void 0));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.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.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback();const view=this.runtimeWindow;view&&(unregisterHotkeyOwner(view,this),view.removeEventListener("keydown",this.onGlobalKeyDown)),this.overlay?.suspend(),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(),onBackdrop:()=>this.close(),lockScroll:!0,suspendWhenUnrendered:!0})}openPalette(){this.requestOpen(!0)}close(){this.requestOpen(!1)}requestOpen(next){if(next===this._open||this.openRequestTarget===next)return!1;this.openRequestTarget=next;let prevented;if(next){const showPrevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,openPrevented=this.emit("lr-open",null,{cancelable:!0}).defaultPrevented;prevented=showPrevented||openPrevented}else prevented=this.emit("lr-close",null,{cancelable:!0}).defaultPrevented;return this.openRequestTarget=void 0,prevented?(this.toggleAttribute("open",this._open),!1):(next&&this.resetOpeningState(),this.commitOpen(next),!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())}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
2
2
  id=${this.optionId(row.index)}
3
3
  part="command"
4
4
  role="option"
@@ -23,11 +23,12 @@ export interface MenuItemSelectDetail{readonly item:LyraMenuItem;}export interfa
23
23
  * `lr-menu-item-select` nor `lr-menu-select` is part of the public contract.
24
24
  *
25
25
  * @customElement lr-menu
26
- * @slot - `<lr-menu-item>` elements, plus optionally plain `<hr>` dividers
27
- * between groups (native `<hr>` already carries an implicit `separator`
28
- * role, matching what `role="menu"` expects between item groups). Arbitrary
29
- * non-item content still renders here for backward compatibility, but the
30
- * `header`/`footer` slots below are the supported place for it.
26
+ * @slot - `<lr-menu-item>`/`<lr-dropdown-item>` rows, `<lr-menu-label>` captions, and `<hr>` or
27
+ * `<lr-divider>` separators between groups (native `<hr>` already carries an implicit `separator`
28
+ * role, matching what `role="menu"` expects between item groups). Any other default-slot content
29
+ * is deprecated (removal not before 23.0.0): it still renders, but inside `role="menu"` without a
30
+ * menu-item role and skipped by keyboard navigation, so put it in the `header` or `footer` slot
31
+ * below.
31
32
  * @slot header - Composed content rendered above the items and *outside* the
32
33
  * `role="menu"` list — a filter/search field, a section title, a summary row.
33
34
  * Keeps its own full default keyboard behavior, is reachable with Tab from
@@ -38,7 +38,8 @@ positionInPixels:number;}export interface LyraSplitPanelEventMap{
38
38
  * interaction moves the divider. Not fired when a consumer sets `position` or
39
39
  * `positionInPixels` directly.
40
40
  * @csspart base - The component's layout wrapper.
41
- * @csspart split-panel - Compatibility alias on the layout wrapper.
41
+ * @csspart split-panel - Deprecated alias of `base` on the same layout wrapper (removal not before
42
+ * 23.0.0); style `::part(base)` instead. Neither mirrored upstream publishes a wrapper part.
42
43
  * @csspart panel - Shared part on both pane wrappers.
43
44
  * @csspart start - The logical start pane.
44
45
  * @csspart end - The logical end pane.
@@ -32,6 +32,14 @@ export declare const LANGUAGE_TO_COUNTRY:Record<string,string>;
32
32
  * letters) can sit between the base language and the region, so every subtag after the base is
33
33
  * scanned for the first 2-letter alpha match rather than assuming it's always `parts[1]`. Base
34
34
  * language fallback accepts only the lookup table's own entries, never inherited object members.
35
+ *
36
+ * A region-less tag whose script implies a different likely region than its bare language does
37
+ * (`zh-Hant` → `tw`, where `zh` → `cn`) takes that region instead of the table default, so
38
+ * Traditional and Simplified Chinese never share one flag. The rule applies to every table
39
+ * language, not only Chinese: `kk-Arab` (Kazakh as written in China) takes `cn` over `kz`. The
40
+ * script only corrects a table default: a language with no table entry stays unresolved, and a
41
+ * script that implies the language's own likely region (`en-Latn`) keeps the table's convention
42
+ * (`gb`). Engines without `Intl.Locale` likely-subtags data fall back to the table default.
35
43
  */
36
44
  export declare function languageToCountry(language:string):string|undefined;
37
45
  /**
@@ -1 +1 @@
1
- import{getDisplayNames}from"../../../internal/intl-cache.js";const ALPHA2_RE=/^[a-z]{2}$/i,ALPHA3_RE=/^[a-z]{3}$/i,ALPHA3_TO_ALPHA2_PACKED="abwawafgafagoaoaiaaialaaxalbalandadareaeargararmamasmasataaqatftfatgagausauautatazeazbdibibelbebenbjbesbqbfabfbgdbdbgrbgbhrbhbhsbsbihbablmblblrbyblzbzbmubmbolbobrabrbrbbbbrnbnbtnbtbvtbvbwabwcafcfcancacckccchechchlclchncncivcicmrcmcodcdcogcgcokckcolcocomkmcpvcvcricrcubcucuwcwcxrcxcymkycypcyczeczdeudedjidjdmadmdnkdkdomdodzadzecuecegyegeriereshehespesesteeethetfinfifjifjflkfkfrafrfrofofsmfmgabgagbrgbgeogeggyggghaghgibgigingnglpgpgmbgmgnbgwgnqgqgrcgrgrdgdgrlglgtmgtgufgfgumguguygyhkghkhmdhmhndhnhrvhrhtihthunhuidnidimnimindiniotioirlieirnirirqiqislisisrilitaitjamjmjeyjejorjojpnjpkazkzkenkekgzkgkhmkhkirkiknaknkorkrkwtkwlaolalbnlblbrlrlbylylcalclielilkalklsolsltultluxlulvalvmacmomafmfmarmamcomcmdamdmdgmgmdvmvmexmxmhlmhmkdmkmlimlmltmtmmrmmmnememngmnmnpmpmozmzmrtmrmsrmsmtqmqmusmumwimwmysmymytytnamnanclncnernenfknfngangnicniniununldnlnornonplnpnrunrnzlnzomnompakpkpanpapcnpnperpephlphplwpwpngpgpolplpriprprkkpprtptprypypsepspyfpfqatqareurerourorusrurwarwsausasdnsdsensnsgpsgsgsgsshnshsjmsjslbsbsleslslvsvsmrsmsomsospmpmsrbrsssdssstpstsursrsvksksvnsisweseswzszsxmsxsycscsyrsytcatctcdtdtgotgthathtjktjtkltktkmtmtlstltontottotttuntnturtrtuvtvtwntwtzatzugaugukruaumiumuryuyusausuzbuzvatvavctvcvenvevgbvgvirvivnmvnvutvuwlfwfwsmwsyemyezafzazmbzmzwezw";let alpha3Lookup;function alpha3ToAlpha2(code){if(ALPHA3_RE.test(code)){if(!alpha3Lookup){alpha3Lookup=new Map;for(let index=0;index<ALPHA3_TO_ALPHA2_PACKED.length;index+=5)alpha3Lookup.set(ALPHA3_TO_ALPHA2_PACKED.slice(index,index+3),ALPHA3_TO_ALPHA2_PACKED.slice(index+3,index+5))}return alpha3Lookup.get(code.toLowerCase())}}const LANGUAGE_TO_COUNTRY={en:"gb",fr:"fr",de:"de",es:"es",it:"it",pt:"pt",nl:"nl",ar:"sa",zh:"cn",ja:"jp",ko:"kr",ru:"ru",pl:"pl",tr:"tr",sv:"se",da:"dk",fi:"fi",no:"no",nb:"no",nn:"no",cs:"cz",sk:"sk",el:"gr",he:"il",hi:"in",th:"th",vi:"vn",id:"id",ms:"my",uk:"ua",kk:"kz",ro:"ro",hu:"hu",bg:"bg",hr:"hr",sr:"rs",sl:"si",et:"ee",lv:"lv",lt:"lt",fa:"ir",ur:"pk",bn:"bd",ta:"in",ca:"es"};function mappedCountry(language){return Object.hasOwn(LANGUAGE_TO_COUNTRY,language)?LANGUAGE_TO_COUNTRY[language]:void 0}function languageToCountry(language){if(typeof language!="string")return;const normalized=language.trim().replaceAll("_","-");if(!normalized)return;try{const locale=new Intl.Locale(normalized);return locale.region&&ALPHA2_RE.test(locale.region)?locale.region.toLowerCase():mappedCountry(locale.language.toLowerCase())}catch{}const parts=normalized.toLowerCase().split("-").slice(0,16),base=parts[0];if(base.length!==1){for(const part of parts.slice(1)){if(!/^[a-z0-9]{1,8}$/.test(part)||part.length===1)break;if(ALPHA2_RE.test(part))return part}return mappedCountry(base)}}function localeNativeName(tag){try{return getDisplayNames(tag,{type:"language"}).of(tag)??tag}catch{return tag}}export{ALPHA2_RE,ALPHA3_RE,LANGUAGE_TO_COUNTRY,alpha3ToAlpha2,languageToCountry,localeNativeName};
1
+ import{getDisplayNames}from"../../../internal/intl-cache.js";const ALPHA2_RE=/^[a-z]{2}$/i,ALPHA3_RE=/^[a-z]{3}$/i,ALPHA3_TO_ALPHA2_PACKED="abwawafgafagoaoaiaaialaaxalbalandadareaeargararmamasmasataaqatftfatgagausauautatazeazbdibibelbebenbjbesbqbfabfbgdbdbgrbgbhrbhbhsbsbihbablmblblrbyblzbzbmubmbolbobrabrbrbbbbrnbnbtnbtbvtbvbwabwcafcfcancacckccchechchlclchncncivcicmrcmcodcdcogcgcokckcolcocomkmcpvcvcricrcubcucuwcwcxrcxcymkycypcyczeczdeudedjidjdmadmdnkdkdomdodzadzecuecegyegeriereshehespesesteeethetfinfifjifjflkfkfrafrfrofofsmfmgabgagbrgbgeogeggyggghaghgibgigingnglpgpgmbgmgnbgwgnqgqgrcgrgrdgdgrlglgtmgtgufgfgumguguygyhkghkhmdhmhndhnhrvhrhtihthunhuidnidimnimindiniotioirlieirnirirqiqislisisrilitaitjamjmjeyjejorjojpnjpkazkzkenkekgzkgkhmkhkirkiknaknkorkrkwtkwlaolalbnlblbrlrlbylylcalclielilkalklsolsltultluxlulvalvmacmomafmfmarmamcomcmdamdmdgmgmdvmvmexmxmhlmhmkdmkmlimlmltmtmmrmmmnememngmnmnpmpmozmzmrtmrmsrmsmtqmqmusmumwimwmysmymytytnamnanclncnernenfknfngangnicniniununldnlnornonplnpnrunrnzlnzomnompakpkpanpapcnpnperpephlphplwpwpngpgpolplpriprprkkpprtptprypypsepspyfpfqatqareurerourorusrurwarwsausasdnsdsensnsgpsgsgsgsshnshsjmsjslbsbsleslslvsvsmrsmsomsospmpmsrbrsssdssstpstsursrsvksksvnsisweseswzszsxmsxsycscsyrsytcatctcdtdtgotgthathtjktjtkltktkmtmtlstltontottotttuntnturtrtuvtvtwntwtzatzugaugukruaumiumuryuyusausuzbuzvatvavctvcvenvevgbvgvirvivnmvnvutvuwlfwfwsmwsyemyezafzazmbzmzwezw";let alpha3Lookup;function alpha3ToAlpha2(code){if(ALPHA3_RE.test(code)){if(!alpha3Lookup){alpha3Lookup=new Map;for(let index=0;index<ALPHA3_TO_ALPHA2_PACKED.length;index+=5)alpha3Lookup.set(ALPHA3_TO_ALPHA2_PACKED.slice(index,index+3),ALPHA3_TO_ALPHA2_PACKED.slice(index+3,index+5))}return alpha3Lookup.get(code.toLowerCase())}}const LANGUAGE_TO_COUNTRY={en:"gb",fr:"fr",de:"de",es:"es",it:"it",pt:"pt",nl:"nl",ar:"sa",zh:"cn",ja:"jp",ko:"kr",ru:"ru",pl:"pl",tr:"tr",sv:"se",da:"dk",fi:"fi",no:"no",nb:"no",nn:"no",cs:"cz",sk:"sk",el:"gr",he:"il",hi:"in",th:"th",vi:"vn",id:"id",ms:"my",uk:"ua",kk:"kz",ro:"ro",hu:"hu",bg:"bg",hr:"hr",sr:"rs",sl:"si",et:"ee",lv:"lv",lt:"lt",fa:"ir",ur:"pk",bn:"bd",ta:"in",ca:"es"};function mappedCountry(language){return Object.hasOwn(LANGUAGE_TO_COUNTRY,language)?LANGUAGE_TO_COUNTRY[language]:void 0}function scriptImpliedRegion(locale){if(!locale.script)return;const scriptRegion=locale.maximize().region,languageRegion=new Intl.Locale(locale.language).maximize().region;return scriptRegion&&ALPHA2_RE.test(scriptRegion)&&scriptRegion!==languageRegion?scriptRegion.toLowerCase():void 0}function languageToCountry(language){if(typeof language!="string")return;const normalized=language.trim().replaceAll("_","-");if(!normalized)return;try{const locale=new Intl.Locale(normalized);if(locale.region&&ALPHA2_RE.test(locale.region))return locale.region.toLowerCase();const mapped=mappedCountry(locale.language.toLowerCase());return mapped===void 0?void 0:scriptImpliedRegion(locale)??mapped}catch{}const parts=normalized.toLowerCase().split("-").slice(0,16),base=parts[0];if(base.length!==1){for(const part of parts.slice(1)){if(!/^[a-z0-9]{1,8}$/.test(part)||part.length===1)break;if(ALPHA2_RE.test(part))return part}return mappedCountry(base)}}function localeNativeName(tag){try{return getDisplayNames(tag,{type:"language"}).of(tag)??tag}catch{return tag}}export{ALPHA2_RE,ALPHA3_RE,LANGUAGE_TO_COUNTRY,alpha3ToAlpha2,languageToCountry,localeNativeName};
@@ -8,7 +8,13 @@ export interface MapLibreGeoJsonDiff{readonly remove?:readonly(string|number)[];
8
8
  * guard with `?.()` against a peer that satisfies the shape check and then lies at runtime. */
9
9
  getCanvas():HTMLCanvasElement;getCenter():{lng:number;lat:number;};getZoom():number;setCenter(center:[number,number]):unknown;setZoom(zoom:number):unknown;resize():unknown;
10
10
  /** Optional: absent on peers predating it, and the caller feature-detects before use. */
11
- setMaxBounds?(bounds:readonly[readonly[number,number],readonly[number,number]]|null):unknown;remove():void;on(type:'error',listener:(event:{error?:unknown;})=>void):this;on(type:'load',listener:()=>void):this;on(type:'click',listener:(event:{point:unknown;lngLat:{lng:number;lat:number;};})=>void):this;once(type:'style.load',listener:()=>void):this;setStyle(style:unknown):this;getSource(id:string):MapLibreGeoJsonSource|undefined;addSource(id:string,source:unknown):this;removeSource(id:string):this;getLayer(id:string):unknown;addLayer(layer:unknown):this;removeLayer(id:string):this;setPaintProperty(layerId:string,name:string,value:unknown):this;
11
+ setMaxBounds?(bounds:readonly[readonly[number,number],readonly[number,number]]|null):unknown;
12
+ /** Optional for the same reason; `LyraMap.fitBounds()` feature-detects it. The peer merges
13
+ * `eventData` into every movement event the fit fires, which is how its `moveend` is told
14
+ * apart from any other camera move. */
15
+ fitBounds?(bounds:[[number,number],[number,number]],options:Record<string,unknown>,eventData:Record<string,unknown>):unknown;
16
+ /** Optional and feature-detected: whether an animation or a gesture is moving the camera now. */
17
+ isMoving?():boolean;remove():void;on(type:'error',listener:(event:{error?:unknown;})=>void):this;on(type:'load',listener:()=>void):this;on(type:'moveend',listener:(event:Readonly<Record<string,unknown>> |undefined)=>void):this;on(type:'boxzoomend',listener:()=>void):this;on(type:'click',listener:(event:{point:unknown;lngLat:{lng:number;lat:number;};})=>void):this;once(type:'style.load',listener:()=>void):this;setStyle(style:unknown):this;getSource(id:string):MapLibreGeoJsonSource|undefined;addSource(id:string,source:unknown):this;removeSource(id:string):this;getLayer(id:string):unknown;addLayer(layer:unknown):this;removeLayer(id:string):this;setPaintProperty(layerId:string,name:string,value:unknown):this;
12
18
  /** Optional image-atlas capabilities; point circles remain usable when a partial peer lacks these. */
13
19
  hasImage?(id:string):boolean;addImage?(id:string,image:ImageData,options:{pixelRatio:number;}):unknown;updateImage?(id:string,image:ImageData):unknown;removeImage?(id:string):unknown;queryRenderedFeatures(point:unknown,options?:{layers?:string[];}):unknown[];}
14
20
  /** The MapLibre constructors Lyra consumes, structurally owned so the optional peer never leaks. */
@@ -367,7 +367,35 @@ export interface LyraMapInstance{getCanvas():HTMLCanvasElement;getCenter():{lng:
367
367
  */
368
368
  setMaxBounds?(bounds?:unknown):unknown;}
369
369
  /** A pan-constraining box, `[[west, south], [east, north]]`, in the order maplibre-gl takes. */
370
- export type LyraMapBounds=readonly[readonly[number,number],readonly[number,number]];export declare function buildGeoJsonPropertyDiff(previous:unknown,next:unknown):MapLibreGeoJsonDiff|null;
370
+ export type LyraMapBounds=readonly[readonly[number,number],readonly[number,number]];
371
+ /**
372
+ * Screen pixels kept clear on each side of a fitted box. The sides are the viewport's physical
373
+ * sides, because the map's projected space is physical in both text directions. An omitted side is
374
+ * `0`.
375
+ */
376
+ export interface LyraMapPadding{readonly top?:number;readonly right?:number;readonly bottom?:number;readonly left?:number;}
377
+ /** Options for `LyraMap.fitBounds()`. Every field is optional. */
378
+ export interface LyraMapFitBoundsOptions{
379
+ /** Screen pixels kept clear around the box: one number for every side, or per side. A negative
380
+ * or non-finite side counts as `0`. Defaults to `0`. */
381
+ readonly padding?:number|LyraMapPadding;
382
+ /** Highest zoom the fit may reach, so a single point or a tight cluster does not zoom to the
383
+ * street. Clamped into `[0, 22]`; a non-finite value sets no ceiling. */
384
+ readonly maxZoom?:number;
385
+ /** Whether the camera animates to the box. Defaults to `true`. It never animates under
386
+ * `prefers-reduced-motion: reduce`, or when the fit was queued before the map existed. */
387
+ readonly animate?:boolean;}
388
+ /** What settled the camera that a `lr-map-view-change` reports: a user gesture (drag, wheel,
389
+ * touch, keyboard, box zoom or a standard peer navigation button) or a `fitBounds()` call. These
390
+ * are the only two: camera moves made directly through `map` are never reported. */
391
+ export type LyraMapViewChangeSource='user'|'fit';
392
+ /** Detail of `lr-map-view-change`. Frozen, and detached from the component's own state. */
393
+ export interface LyraMapViewChangeDetail{
394
+ /** Settled `[longitude, latitude]`, longitude wrapped into `[-180, 180]`. Already written into
395
+ * `center`. */
396
+ readonly center:readonly[number,number];
397
+ /** Settled zoom. Already written into `zoom`. */
398
+ readonly zoom:number;readonly source:LyraMapViewChangeSource;}export declare function buildGeoJsonPropertyDiff(previous:unknown,next:unknown):MapLibreGeoJsonDiff|null;
371
399
  /**
372
400
  * Complete proposed visibility snapshot for one map legend category, mirroring
373
401
  * `LyraChartLegendVisibilityChangeDetail`'s shape so a host that already reconciles a chart legend
@@ -387,7 +415,7 @@ readonly hiddenCategories:readonly string[];}
387
415
  */
388
416
  export interface LyraMapLegendPanelToggleDetail{
389
417
  /** Proposed `legendOpen` after this activation. */
390
- readonly open:boolean;}export interface LyraMapEventMap{'lr-map-load':CustomEvent<null>;'lr-map-marker-activate':CustomEvent<LyraMapMarkerActivationDetail>;'lr-map-legend-toggle':CustomEvent<LyraMapLegendToggleDetail>;'lr-map-legend-panel-toggle':CustomEvent<LyraMapLegendPanelToggleDetail>;'lr-map-click':CustomEvent<{readonly lngLat:readonly[number,number];readonly feature:Feature|undefined;
418
+ readonly open:boolean;}export interface LyraMapEventMap{'lr-map-load':CustomEvent<null>;'lr-map-marker-activate':CustomEvent<LyraMapMarkerActivationDetail>;'lr-map-legend-toggle':CustomEvent<LyraMapLegendToggleDetail>;'lr-map-legend-panel-toggle':CustomEvent<LyraMapLegendPanelToggleDetail>;'lr-map-view-change':CustomEvent<LyraMapViewChangeDetail>;'lr-map-click':CustomEvent<{readonly lngLat:readonly[number,number];readonly feature:Feature|undefined;
391
419
  /** Which layer `feature` was hit on, so a click is attributable when both a choropleth and
392
420
  * `dataLayers` are painted. `'cluster'` marks a hit on a clustered entry's aggregate circle,
393
421
  * whose `point_count`/`cluster_id` properties describe the group rather than one feature.
@@ -460,6 +488,14 @@ readonly sourceId:string|undefined;}>;}
460
488
  * aggregate circle reports `origin: 'cluster'` and carries MapLibre's `point_count`/`cluster_id`
461
489
  * properties; a `kind: 'heatmap'` layer is never hit-tested, because MapLibre returns no features
462
490
  * for a density surface.
491
+ * @event lr-map-view-change - Fired once each time the camera settles after a user gesture (drag,
492
+ * wheel, touch, keyboard, box zoom or a standard peer navigation button) or a `fitBounds()` call,
493
+ * carrying the immutable `detail: { center, zoom, source }` (`LyraMapViewChangeDetail`). The
494
+ * element has already written that camera into `center` and `zoom`, so it never resets it on its
495
+ * next update, and a host mirroring camera state assigns the detail back, at any later time,
496
+ * without moving the map. `source` is `'user'` or `'fit'`. Assigning `center`/`zoom` reconciles
497
+ * without emitting it, so a controlled host cannot loop, and camera moves made directly through
498
+ * `map` are not reported.
463
499
  * @csspart base - The non-semantic map wrapper. It exposes `aria-busy="true"` while the optional
464
500
  * map library loads and contains ordinary, non-live localized loading text.
465
501
  * @csspart container - The MapLibre container. Its generated canvas is the actual focusable map
@@ -562,10 +598,31 @@ protected static readonly identityCollectionProperties:readonly string[];protect
562
598
  * peer is unavailable, so applications can decide whether to render their own fallback before
563
599
  * connecting an element. */
564
600
  static preload():Promise<boolean>;constructor();
565
- /** Initial and controlled map center as `[longitude, latitude]`. */
601
+ /** Initial and controlled map center as `[longitude, latitude]`. Once the camera settles after
602
+ * a user gesture or `fitBounds()`, it holds that camera (see `lr-map-view-change`), so a map
603
+ * rebuilt after a reconnect opens where the user left it. Assigning a value the map already
604
+ * shows moves nothing; an assignment that interrupts an animation or gesture applies `zoom`
605
+ * too, so the camera never keeps a half-finished axis. */
566
606
  center:readonly[number,number];
567
- /** Initial and controlled map zoom level. */
607
+ /** Initial and controlled map zoom level. Tracks the settled camera and reconciles the same way
608
+ * as `center`. */
568
609
  zoom:number;
610
+ /** A fit requested before the map existed; applied once, right after construction, unless
611
+ * `center` or `zoom` has meanwhile been given a different value. */
612
+ private pendingFit?;
613
+ /** Identifies this element's own fits when their `moveend` arrives from the peer. */
614
+ private readonly fitToken;
615
+ /** The camera just read back from the peer into `center`/`zoom`. The update that write schedules
616
+ * consumes it, so that update does not push the same camera straight back. */
617
+ private reflectedCamera?;
618
+ /** Set between the peer's `boxzoomend` and the `moveend` of the animation that follows it. The
619
+ * peer animates a box zoom with no event data, so this is the only thing that marks that
620
+ * `moveend` as the user's. */
621
+ private boxZoomSettling;
622
+ /** Set while `updated()` moves the peer's camera itself (`center`/`zoom`, a `maxBounds` revert).
623
+ * Such a move can stop a fit that is still animating, which makes the peer settle that fit
624
+ * early; the settle must not be written back over the value being applied. */
625
+ private writingCamera;
569
626
  /** Whether the constructed peer repeats the world horizontally. `undefined` leaves MapLibre's
570
627
  * own default in force. Construction-only; set before the map is created. */
571
628
  renderWorldCopies?:boolean;
@@ -812,7 +869,56 @@ private applyMaxBounds;
812
869
  * reach the constructor's initial `zoom` option or a live `setZoom()` call unnormalized. */
813
870
  private get safeZoom();
814
871
  /** Longitude/latitude normalized before reaching MapLibre's constructor or live setter. */
815
- private get safeCenter();connectedCallback():void;disconnectedCallback():void;private failureMessage;private failInitialization;private disposeMap;adoptedCallback():void;private syncErrorAnnouncementSink;private releaseErrorAnnouncementSink;
872
+ private get safeCenter();
873
+ /**
874
+ * Frames `bounds`, `[[west, south], [east, north]]`, in the viewport: the usual way to show every
875
+ * current marker or a selected region whenever the data set changes.
876
+ *
877
+ * The resulting camera is written into `center` and `zoom` once it settles, and reported through
878
+ * `lr-map-view-change` with `source: 'fit'`. Declarative state therefore stays the single source
879
+ * of truth, and the element's own reconciliation never resets the fitted camera. A later
880
+ * `center`/`zoom` assignment moves the camera as usual.
881
+ *
882
+ * Callable before the map exists (before the optional peer loads, or while an off-screen map is
883
+ * still waiting to be constructed). The most recent such request is queued and applied without
884
+ * animation right after construction, unless `center` or `zoom` has been given a different value
885
+ * since the call: that assignment is the newer intent. Re-assigning the value already held (a
886
+ * framework re-render building an equal array, say) keeps the queued fit.
887
+ *
888
+ * Latitudes lie in `[-90, 90]`, with `south <= north`, and longitudes in `[-180, 180]`. A box
889
+ * crossing the antimeridian takes either of MapLibre's forms: `west > east`, or `east` unwrapped
890
+ * past 180, up to one full turn east of `west` (what the peer's `LngLatBounds` produces). A single
891
+ * point is a valid zero-size box (pair it with `maxZoom`). The camera animates unless `animate` is
892
+ * `false`, the user prefers reduced motion, or the fit was queued.
893
+ *
894
+ * When the padded box cannot fit the map's current size (padding wider or taller than the map),
895
+ * the peer leaves the camera where it is and logs its own warning: the method still returns
896
+ * `true`, and no `lr-map-view-change` fires.
897
+ *
898
+ * There is deliberately no declarative `bounds` property. `center` and `zoom` already describe
899
+ * the camera; a third camera input would need a precedence rule against them, and a framework
900
+ * that rebuilds its arrays on every render would refit on every render and pull the camera away
901
+ * from a user who has just panned. A one-shot command that writes its result back into
902
+ * `center`/`zoom` keeps one camera input.
903
+ *
904
+ * Returns `false`, without moving or queueing anything, when `bounds` is unusable or the loaded
905
+ * peer cannot fit a box, and `true` once the fit is running or queued.
906
+ */
907
+ fitBounds(bounds:LyraMapBounds,options?:LyraMapFitBoundsOptions):boolean;private applyFit;private applyPendingFit;
908
+ /** Writes the peer's settled camera into `center`/`zoom`, then reports it. */
909
+ private reflectCamera;
910
+ /**
911
+ * Pushes assigned `center`/`zoom` into the peer.
912
+ *
913
+ * An axis the peer already shows is skipped: both the camera just read back into `center`/`zoom`
914
+ * and a host echoing a reported camera, however late, would otherwise push a redundant jump, and
915
+ * a jump stops any animation or gesture in flight. A push that does interrupt a movement applies
916
+ * the whole declared camera, because the interrupted movement would otherwise leave the axis that
917
+ * was not assigned wherever it stopped. With nothing in flight, only the assigned axis moves.
918
+ */
919
+ private pushCamera;
920
+ /** Runs a camera move this element makes on its own behalf, which it never reports. */
921
+ private writeCamera;connectedCallback():void;disconnectedCallback():void;private failureMessage;private failInitialization;private disposeMap;adoptedCallback():void;private syncErrorAnnouncementSink;private releaseErrorAnnouncementSink;
816
922
  /**
817
923
  * Constructs the underlying `maplibregl.Map` — called once both the
818
924
  * lazy-loaded `maplibre-gl` module has resolved and this element has been