@aceshooting/lyra-ui 23.0.0 → 24.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 (280) hide show
  1. package/CHANGELOG.md +16 -39
  2. package/README.md +72 -35
  3. package/custom-elements.json +1 -1
  4. package/design-tokens.json +1 -1
  5. package/dist/cli/lyra-rename-ledger.mjs +1 -1
  6. package/dist/cli/migration-contract.json +1 -1
  7. package/dist/cli/migration-contract.mjs +1 -1
  8. package/dist/cli/migration-renames.mjs +2 -2
  9. package/dist/cli/migration-transforms.mjs +2 -2
  10. package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -4
  11. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -3
  12. package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +1 -4
  13. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  14. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.d.ts +1 -7
  15. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
  16. package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -1
  17. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +2 -5
  18. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -3
  19. package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -4
  20. package/dist/components/agent-tools/terminal/terminal.class.js +2 -2
  21. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.d.ts +1 -7
  22. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
  23. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +1 -4
  24. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -3
  25. package/dist/components/charts/chart/lite-chart-axis-layout.d.ts +13 -0
  26. package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -0
  27. package/dist/components/charts/chart/lite-chart.class.d.ts +1 -11
  28. package/dist/components/charts/chart/lite-chart.class.js +4 -4
  29. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +13 -3
  30. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +1 -2
  31. package/dist/components/conversation/chat-message/chat-message.class.d.ts +3 -9
  32. package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
  33. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  34. package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -8
  35. package/dist/components/conversation/code-block/code-block-shared.d.ts +1 -4
  36. package/dist/components/conversation/code-block/code-block.class.d.ts +4 -6
  37. package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -3
  38. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  39. package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -4
  40. package/dist/components/conversation/markdown/markdown.class.d.ts +1 -4
  41. package/dist/components/conversation/message-actions/message-actions.class.d.ts +1 -4
  42. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  43. package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +1 -4
  44. package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
  45. package/dist/components/conversation/message-parts/message-parts.class.d.ts +2 -5
  46. package/dist/components/conversation/message-parts/message-parts.class.js +3 -3
  47. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +1 -1
  48. package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +2 -0
  49. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +0 -1
  50. package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +2 -0
  51. package/dist/components/conversation/streaming-text/streaming-text.class.js +0 -1
  52. package/dist/components/conversation/thread-list/thread-list.class.d.ts +6 -17
  53. package/dist/components/conversation/thread-list/thread-list.class.js +6 -6
  54. package/dist/components/data/context-meter/context-meter.class.d.ts +1 -6
  55. package/dist/components/data/context-meter/context-meter.class.js +1 -1
  56. package/dist/components/data/data-grid/data-grid.class.d.ts +0 -1
  57. package/dist/components/data/data-grid/data-grid.class.js +2 -2
  58. package/dist/components/data/document-library/document-library.class.d.ts +6 -13
  59. package/dist/components/data/document-library/document-library.class.js +1 -2
  60. package/dist/components/data/heatmap/heatmap-grid-navigation.d.ts +7 -0
  61. package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -0
  62. package/dist/components/data/heatmap/heatmap.class.d.ts +3 -23
  63. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  64. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +3 -9
  65. package/dist/components/data/sequence-strip/sequence-strip.class.js +3 -3
  66. package/dist/components/data/table/table.class.d.ts +5 -14
  67. package/dist/components/data/table/table.class.js +6 -6
  68. package/dist/components/forms/button/button.class.d.ts +2 -2
  69. package/dist/components/forms/button/button.class.js +9 -9
  70. package/dist/components/forms/combobox/combobox.class.d.ts +1 -4
  71. package/dist/components/forms/combobox/combobox.class.js +2 -2
  72. package/dist/components/forms/input/time-input.class.d.ts +1 -1
  73. package/dist/components/forms/input/time-input.class.js +1 -1
  74. package/dist/components/forms/select/select.class.d.ts +1 -2
  75. package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +3 -1
  76. package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
  77. package/dist/components/layout/app-rail/app-rail-item.class.d.ts +3 -6
  78. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  79. package/dist/components/layout/app-rail/app-rail.class.d.ts +2 -4
  80. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  81. package/dist/components/layout/app-rail-group/app-rail-group.class.d.ts +2 -6
  82. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  83. package/dist/components/layout/carousel/carousel.class.d.ts +1 -4
  84. package/dist/components/layout/carousel/carousel.class.js +2 -2
  85. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  86. package/dist/components/layout/details/details.class.d.ts +2 -4
  87. package/dist/components/layout/details/details.class.js +1 -1
  88. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +3 -7
  89. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  90. package/dist/components/layout/menu/menu.class.js +1 -1
  91. package/dist/components/layout/multi-split/multi-split.class.d.ts +2 -4
  92. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  93. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +2 -4
  94. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
  95. package/dist/components/layout/reorder-list/reorder-item.class.d.ts +1 -4
  96. package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
  97. package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +5 -9
  98. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +5 -5
  99. package/dist/components/media/av-player/av-player.class.js +3 -3
  100. package/dist/components/media/file-input/file-input.class.d.ts +3 -6
  101. package/dist/components/media/file-input/file-input.class.js +3 -3
  102. package/dist/components/media/lightbox/lightbox.class.d.ts +11 -20
  103. package/dist/components/media/lightbox/lightbox.class.js +1 -1
  104. package/dist/components/media/map/map-data-layers.d.ts +20 -0
  105. package/dist/components/media/map/map-data-layers.js +1 -0
  106. package/dist/components/media/map/map.class.js +3 -3
  107. package/dist/components/media/media-time.d.ts +2 -0
  108. package/dist/components/media/media-time.js +1 -0
  109. package/dist/components/media/video/video.class.js +5 -5
  110. package/dist/components/media/video-playlist/video-playlist.class.js +2 -2
  111. package/dist/components/overlays/callout/callout.class.d.ts +2 -5
  112. package/dist/components/overlays/callout/callout.class.js +2 -2
  113. package/dist/components/overlays/dialog/dialog.class.d.ts +4 -7
  114. package/dist/components/overlays/dialog/dialog.class.js +2 -2
  115. package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -10
  116. package/dist/components/overlays/overlay/dropdown.class.js +2 -2
  117. package/dist/components/overlays/overlay/popover.class.d.ts +2 -3
  118. package/dist/components/overlays/popup/popup.class.js +1 -1
  119. package/dist/components/overlays/progress/progress-bar.class.d.ts +1 -4
  120. package/dist/components/overlays/progress/progress-bar.class.js +2 -2
  121. package/dist/components/overlays/progress/progress-ring.class.d.ts +1 -4
  122. package/dist/components/overlays/progress/progress-ring.class.js +2 -2
  123. package/dist/components/overlays/progress/progress-shared.d.ts +3 -3
  124. package/dist/components/overlays/progress/progress-shared.js +1 -1
  125. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  126. package/dist/components/retrieval/graph/graph.class.d.ts +5 -10
  127. package/dist/components/retrieval/graph/graph.class.js +1 -1
  128. package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +7 -14
  129. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +2 -3
  130. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +2 -8
  131. package/dist/components/retrieval/memory-panel/memory-panel.class.js +0 -4
  132. package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
  133. package/dist/components/utility/export-button/export-button.class.d.ts +6 -10
  134. package/dist/components/utility/export-button/export-button.class.js +1 -1
  135. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  136. package/dist/components/viewers/geojson-view/geojson-view.class.d.ts +1 -1
  137. package/dist/components/viewers/highlight-layer/highlight-layer-timing.js +1 -1
  138. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
  139. package/dist/events.d.ts +17 -78
  140. package/dist/framework-types.d.ts +1 -1
  141. package/dist/internal/catalog-picker.js +1 -1
  142. package/dist/internal/css-motion-time.d.ts +7 -0
  143. package/dist/internal/css-motion-time.js +1 -0
  144. package/dist/internal/data-state-renderer.d.ts +1 -3
  145. package/dist/internal/data-state-renderer.js +1 -1
  146. package/dist/internal/localization-runtime.d.ts +2 -0
  147. package/dist/internal/localization-runtime.js +1 -1
  148. package/dist/internal/lyra-element.js +2 -2
  149. package/dist/internal/package-metadata.d.ts +1 -1
  150. package/dist/internal/package-metadata.js +1 -1
  151. package/dist/looks/data.css +1 -1
  152. package/dist/looks/terminal.css +1 -1
  153. package/dist/lyra.d.ts +1 -592
  154. package/dist/lyra.js +1 -1
  155. package/dist/testing/event-factory.d.ts +2 -2
  156. package/dist/testing/interaction-drivers.d.ts +5 -3
  157. package/dist/testing/lyra-tag-event-map.js +1 -1
  158. package/dist/theme/looks/data.d.ts +1 -1
  159. package/dist/theme/looks/data.js +1 -1
  160. package/dist/theme/looks/terminal.d.ts +1 -1
  161. package/dist/theme/looks/terminal.js +1 -1
  162. package/dist/theme/theme.d.ts +2 -80
  163. package/dist/theme/theme.js +1 -1
  164. package/llms/components/lr-agent-workspace.md +24 -2
  165. package/llms/components/lr-alert.md +1 -1
  166. package/llms/components/lr-animation.md +1 -1
  167. package/llms/components/lr-app-rail.md +8 -10
  168. package/llms/components/lr-approval-queue.md +2 -4
  169. package/llms/components/lr-attachment-trigger.md +3 -4
  170. package/llms/components/lr-badge.md +2 -2
  171. package/llms/components/lr-button.md +45 -99
  172. package/llms/components/lr-callout.md +3 -4
  173. package/llms/components/lr-carousel.md +3 -5
  174. package/llms/components/lr-chat-message.md +1 -2
  175. package/llms/components/lr-claim-evidence.md +1 -1
  176. package/llms/components/lr-code-block-core.md +2 -2
  177. package/llms/components/lr-code-block.md +5 -6
  178. package/llms/components/lr-color-picker.md +1 -1
  179. package/llms/components/lr-combobox.md +5 -6
  180. package/llms/components/lr-compare-panel.md +2 -4
  181. package/llms/components/lr-confirm-bar.md +3 -7
  182. package/llms/components/lr-context-inspector.md +3 -2
  183. package/llms/components/lr-context-menu.md +2 -2
  184. package/llms/components/lr-context-meter.md +2 -4
  185. package/llms/components/lr-copy-button.md +1 -1
  186. package/llms/components/lr-data-grid.md +4 -7
  187. package/llms/components/lr-details.md +3 -3
  188. package/llms/components/lr-dialog.md +4 -6
  189. package/llms/components/lr-dock-panel.md +5 -6
  190. package/llms/components/lr-document-library.md +5 -7
  191. package/llms/components/lr-drawer.md +3 -3
  192. package/llms/components/lr-dropdown.md +4 -5
  193. package/llms/components/lr-eval-run.md +3 -5
  194. package/llms/components/lr-export-button.md +4 -7
  195. package/llms/components/lr-file-input.md +0 -5
  196. package/llms/components/lr-funnel.md +1 -1
  197. package/llms/components/lr-graph.md +3 -7
  198. package/llms/components/lr-icon.md +1 -1
  199. package/llms/components/lr-include.md +1 -1
  200. package/llms/components/lr-input.md +31 -79
  201. package/llms/components/lr-json-viewer.md +1 -1
  202. package/llms/components/lr-knowledge-base.md +4 -6
  203. package/llms/components/lr-knowledge-graph-explorer.md +2 -5
  204. package/llms/components/lr-known-date.md +1 -1
  205. package/llms/components/lr-lightbox.md +9 -7
  206. package/llms/components/lr-lite-chart.md +1 -5
  207. package/llms/components/lr-markdown-core.md +3 -4
  208. package/llms/components/lr-markdown.md +3 -5
  209. package/llms/components/lr-mcp-app.md +1 -1
  210. package/llms/components/lr-message-actions.md +2 -3
  211. package/llms/components/lr-message-feedback.md +1 -3
  212. package/llms/components/lr-message-parts.md +4 -5
  213. package/llms/components/lr-multi-split.md +8 -7
  214. package/llms/components/lr-native-time-input.md +1 -1
  215. package/llms/components/lr-navigation-menu.md +5 -5
  216. package/llms/components/lr-number-input.md +3 -1
  217. package/llms/components/lr-otp-input.md +2 -0
  218. package/llms/components/lr-page.md +1 -1
  219. package/llms/components/lr-pan-zoom.md +1 -1
  220. package/llms/components/lr-phone-input.md +3 -1
  221. package/llms/components/lr-popover.md +2 -2
  222. package/llms/components/lr-progress-bar.md +3 -5
  223. package/llms/components/lr-progress-ring.md +5 -7
  224. package/llms/components/lr-prompt-input.md +1 -1
  225. package/llms/components/lr-prompt-queue.md +1 -1
  226. package/llms/components/lr-prompt-studio.md +1 -1
  227. package/llms/components/lr-rag-eval-dashboard.md +1 -1
  228. package/llms/components/lr-rating.md +2 -2
  229. package/llms/components/lr-realtime-session.md +1 -1
  230. package/llms/components/lr-reorder-item.md +1 -1
  231. package/llms/components/lr-reorder-list.md +2 -3
  232. package/llms/components/lr-retrieval-compare.md +1 -1
  233. package/llms/components/lr-select.md +3 -1
  234. package/llms/components/lr-selection-toolbar.md +1 -1
  235. package/llms/components/lr-sequence-strip.md +3 -8
  236. package/llms/components/lr-span-waterfall.md +1 -1
  237. package/llms/components/lr-split-panel.md +1 -1
  238. package/llms/components/lr-streaming-text-core.md +2 -1
  239. package/llms/components/lr-streaming-text.md +3 -2
  240. package/llms/components/lr-subagent-panel.md +1 -1
  241. package/llms/components/lr-swatch-picker.md +7 -6
  242. package/llms/components/lr-switch.md +3 -1
  243. package/llms/components/lr-table.md +33 -85
  244. package/llms/components/lr-terminal.md +2 -5
  245. package/llms/components/lr-textarea.md +1 -1
  246. package/llms/components/lr-thread-list.md +8 -14
  247. package/llms/components/lr-time-input.md +1 -1
  248. package/llms/components/lr-toggle-group.md +2 -2
  249. package/llms/components/lr-toggle.md +1 -1
  250. package/llms/components/lr-tool-approval-dialog.md +4 -7
  251. package/llms/components/lr-tool-call-block.md +1 -1
  252. package/llms/components/lr-tool-timeline.md +2 -5
  253. package/llms/components/lr-video-playlist.md +1 -1
  254. package/llms/components/lr-video.md +1 -1
  255. package/llms/components/lr-widget-renderer.md +7 -6
  256. package/llms/components/lr-zoomable-frame.md +1 -1
  257. package/llms/index.md +3 -618
  258. package/llms/migration.md +614 -614
  259. package/llms/shared/events-and-types.md +32 -31
  260. package/llms/shared/frameworks-and-ssr.md +7 -3
  261. package/llms/shared/imports-and-registration.md +22 -22
  262. package/llms/shared/localization-and-rtl.md +2 -2
  263. package/llms/shared/native-styles-and-utilities.md +263 -0
  264. package/llms/shared/styles-and-tokens.md +85 -676
  265. package/llms/shared/testing-and-utilities.md +12 -11
  266. package/llms/shared/v23-to-v24-migration.md +167 -0
  267. package/llms/shared.md +149 -494
  268. package/llms/tokens.md +3 -3
  269. package/llms.txt +9 -4
  270. package/package.json +7 -311
  271. package/registrations.json +1 -1
  272. package/vscode-html-data.json +1 -1
  273. package/web-types.json +1 -1
  274. package/dist/ssr-loader.d.ts +0 -2
  275. package/dist/ssr-loader.js +0 -1
  276. package/dist/theme/presets/shadcn.d.ts +0 -22
  277. package/dist/theme/presets/shadcn.js +0 -1
  278. package/dist/theme/presets.d.ts +0 -49
  279. package/dist/theme/presets.js +0 -1
  280. package/dist/themes/shadcn.css +0 -1
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import"lit";import{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteInteger}from"../../../internal/numbers.js";import{DocumentAnchorTarget}from"../../../internal/anchor-target.js";import{buildQuoteAnchor,createTextQuoteIndex,scopeFromElement,TEXT_QUOTE_LIMITS}from"../../../internal/text-quote.js";import{acquireHighlightHandle,supportsCustomHighlights}from"../../../internal/text-highlights.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{MarkdownCodeHeaderController,renderMarkdownCodeHeader}from"./markdown-code-header.js";import{MarkdownFallbackCodeScanner}from"./markdown-fallback-code.js";import{MarkdownProgressiveSession,markdownProgressiveEligible}from"./markdown-progressive.js";import{addFailedHighlightKey,applyMarkdownAriaBusy,applyMarkdownFragmentAnchor,applyMarkdownTextQuoteAnchor,beginMarkdownDepsLoad,getCachedHighlight,hitTestHighlightRanges,HIGHLIGHT_CACHE_MAX,internalLinkHrefFrom,markdownAnchorFromTarget,markdownTableRegionLabel,markdownHasTableWrappers,labelMarkdownTableWrappers,markdownHighlightConfigChanged,markdownLanguageSetChanged,markdownMathPeerError,markdownNeedsReparse,MarkdownOwnedAnimationFrameController,MarkdownParserController,normalizeMarkdownHtmlMode,normalizeMarkdownStreamingRender,createMarkdownRenderContext,finishMarkdownHtml,markdownSanitizerPolicy,normalizeMarkdownLeadingTabs,parseMarkdownDocument,processPendingHighlights,renderMarkdownContent,renderMarkdownDocument,repaintMarkdownHighlights,resolveMarkdownDarkTheme,setCachedHighlight}from"./markdown-shared.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_markdownTableRegion}from"../../../internal/default-strings.generated.js";const HIGHLIGHT_FAILURE_WARNING_KEY="lyra-markdown-highlight-failed",HIGHLIGHT_FAILURE_WARNING="<lr-markdown>/<lr-markdown-core>: Syntax highlighting could not complete. Code is rendered as plain text.";function keyboardHighlightIdFrom(ranges,event){const coordinateLess=event.clientX===0&&event.clientY===0&&event.screenX===0&&event.screenY===0;if(event.detail!==0&&!coordinateLess)return null;const anchor=event.composedPath().find(target=>markdownAnchorFromTarget(target)!==void 0);if(!anchor)return null;for(let index=ranges.length-1;index>=0;index--){const range=ranges[index];if(range)try{if(range.range.intersectsNode(anchor))return range.id}catch{}}return null}class LyraMarkdownRuntimeElement extends LyraElement{static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed,markdownTableRegion:LYRA_DEFAULT_markdownTableRegion}}}function createMarkdownVariantContext(tag,katexState){return{tag,connectedInstances:new Set,sharedParser:new MarkdownParserController,katexState}}class MarkdownRuntimeBase extends DocumentAnchorTarget(LyraMarkdownRuntimeElement){constructor(){super(),this.anchorKinds=["fragment","text-quote"],this.renderedHtml=null,this.renderedBlocks=[],this.streamingTail=null,this.progressiveRevision=0,this.isDarkTheme=!1,this.boundLocalize=this.localize.bind(this),this.hasTableWrappers=!1,this.fallbackCode=new MarkdownFallbackCodeScanner,this.parser=new MarkdownParserController,this.headingTree=[],this.markdownTextScopeBuilds=0,this.resolvedHighlightRanges=[],this.mathFailureReported=!1,this.highlightCache=new Map,this.highlightToken=0,this.streamingRenderFrames=new MarkdownOwnedAnimationFrameController,this.failedHighlightKeys=new Set,this.inFlightHighlightKeys=new Map,this.progressiveAdopted=!1,this.progressiveRebuild=!1,this.progressiveInputGeneration=0,this.codeBlocks=[],this.handleKatexResolved=()=>{this.isConnected&&(this.progressiveSession&&this.streaming?(this.progressiveSession.invalidateMath(),this.scheduleStreamingRender()):this.renderMarkdown())},this.onContentClick=event=>{if(this.codeHeader.handleClick(event))return;const href=internalLinkHrefFrom(event,this.internalLinkPrefix);href!==null&&event.preventDefault();const highlightId=hitTestHighlightRanges(this.resolvedHighlightRanges,event.clientX,event.clientY)??keyboardHighlightIdFrom(this.resolvedHighlightRanges,event);highlightId&&this.emit("lr-highlight-activate",{highlightId}),href!==null&&(this.emit("lr-link-activate",{href}),this.emit("lr-link-click",{href}))},new ThemeWatcher(this,()=>this.refreshTheme()),this.codeHeader=new MarkdownCodeHeaderController(this,{isEnabled:()=>this.codeBlockHeader,contentVersion:()=>this.progressiveSession?this.renderedBlocks:this.renderedHtml,getContentRoot:()=>this.contentRoot(),localize:this.boundLocalize,buildHeader:(frame,language)=>renderMarkdownCodeHeader(frame,language),emitCopy:outcome=>this.emit("lr-copy",outcome),emitCopyError:outcome=>this.emit("lr-copy-error",outcome)})}get marked(){return this.parser.get(this.deps?.marked)}refreshTheme(){this.isDarkTheme=resolveMarkdownDarkTheme(this)}connectedCallback(){super.connectedCallback(),this.markdownVariant.connectedInstances.add(this),this.refreshTheme(),beginMarkdownDepsLoad(this,resolved=>{this.deps=resolved,this.renderMarkdown(),this.requestUpdate()})}disconnectedCallback(){this.markdownVariant.connectedInstances.delete(this),super.disconnectedCallback(),this.highlightToken++,this.cancelStreamingRender(),this.highlightHandle?.release(),this.highlightHandle=void 0,this.textQuoteIndexCache=void 0,this.fallbackCode.reset()}adoptedCallback(){super.adoptedCallback(),this.codeHeader.hostAdopted(),this.cancelStreamingRender(),this.streaming&&this.progressiveSession&&this.scheduleStreamingRender()}firstUpdated(changed){super.firstUpdated(changed);const contentRoot=this.renderRoot.querySelector('[part="content"]');contentRoot&&this.bindTextSelection(contentRoot)}willUpdate(changed){super.willUpdate(changed);const active=this.shadowRoot?.activeElement,selector='[part~="code-block"], [part~="code-block-copy"], [part~="table-wrapper"]';if(active?.matches(selector)&&(this.rememberedFocus={node:active,index:[...this.renderRoot.querySelectorAll(selector)].indexOf(active),selector}),changed.has("math")&&(this.mathFailureReported=!1),!this.deps||!markdownNeedsReparse(changed))return;const progressive=normalizeMarkdownStreamingRender(this.streamingRender)==="progressive",configurationChanged=[...changed.keys()].some(key=>key!=="content"&&key!=="streaming"&&markdownNeedsReparse(new Map([[key,void 0]])));(markdownHighlightConfigChanged(changed)||!progressive&&(changed.has("content")||changed.has("streaming")))&&this.highlightToken++,markdownHighlightConfigChanged(changed)&&(this.failedHighlightKeys.clear(),markdownLanguageSetChanged(changed)&&this.highlightCache.clear()),progressive?configurationChanged&&(this.progressiveRebuild=!0):this.resetProgressiveMarkdown(),changed.has("content")&&this.progressiveInputGeneration++,this.streaming?(this.progressiveAdopted&&(this.progressiveSession?.resume(),this.progressiveAdopted=!1),this.progressiveSession?.update(this.content??""),this.progressiveSession&&this.syncProgressiveMarkdown(),this.scheduleStreamingRender()):(this.cancelStreamingRender(),(changed.has("content")&&!changed.has("streaming")||configurationChanged)&&this.resetProgressiveMarkdown(),this.renderMarkdown())}cancelStreamingRender(){const handle=this.streamingRenderRaf;this.streamingRenderRaf=void 0,!this.streamingRenderFrames.cancel()&&handle!==void 0&&this.ownerDocument.defaultView?.cancelAnimationFrame(handle)}scheduleStreamingRender(){if(this.streamingRenderRaf!==void 0)return;const view=this.ownerDocument.defaultView;if(!view){this.isConnected&&this.runStreamingFrame();return}const handle=this.streamingRenderFrames.request(view,()=>{this.streamingRenderRaf=void 0,this.isConnected&&this.ownerDocument.defaultView===view&&this.runStreamingFrame()});handle===void 0?this.isConnected&&this.runStreamingFrame():this.streamingRenderFrames.handle===handle&&(this.streamingRenderRaf=handle)}runStreamingFrame(){normalizeMarkdownStreamingRender(this.streamingRender)==="progressive"?this.renderProgressiveMarkdown():this.renderMarkdown()}async getUpdateComplete(){await super.getUpdateComplete();const generation=this.progressiveInputGeneration,remaining=(this.content?.length??0)-(this.progressiveSession?.end??0),cap=Math.ceil(Math.max(0,remaining)/65536)+2;for(let frames=0;frames<cap&&this.streamingRenderRaf!==void 0&&(await this.streamingRenderFrames.settled,await super.getUpdateComplete(),generation===this.progressiveInputGeneration);frames++);return super.getUpdateComplete()}updated(changed){super.updated(changed),applyMarkdownAriaBusy(this,!this.deps||this.streaming);const renderedChanged=changed.has("renderedHtml")||changed.has("renderedBlocks");if(renderedChanged&&(this.hasTableWrappers=markdownHasTableWrappers(this.contentRoot())),!this.hasTableWrappers)this.tableRegionLabel=void 0;else{const tableLabel=markdownTableRegionLabel(this.boundLocalize);(renderedChanged||tableLabel!==this.tableRegionLabel)&&(this.tableRegionLabel=tableLabel,labelMarkdownTableWrappers(this.contentRoot(),tableLabel))}const remembered=this.rememberedFocus;if(this.rememberedFocus=void 0,remembered&&!remembered.node.isConnected){let active=this.ownerDocument.activeElement;for(;active?.shadowRoot?.activeElement;)active=active.shadowRoot.activeElement;if(!active||active===this.ownerDocument.body||active===this.ownerDocument.documentElement){const target=this.renderRoot.querySelectorAll(remembered.selector)[remembered.index];target?target.focus({preventScroll:!0}):this.streaming&&(this.rememberedFocus=remembered)}}const locale=this.effectiveLocale,localeChanged=this.textQuoteLocale!==void 0&&this.textQuoteLocale!==locale;this.textQuoteLocale=locale;const renderedContentChanged=changed.has("renderedHtml")||changed.has("renderedBlocks")||changed.has("streamingTail")||changed.has("progressiveRevision");(localeChanged||renderedContentChanged||changed.has("content"))&&(this.textQuoteIndexCache=void 0),(renderedContentChanged||changed.has("highlights")||changed.has("activeHighlightId")||localeChanged&&this.highlights.length>0)&&this.repaintHighlights(),(changed.has("content")&&!(this.streaming&&this.streamingRender==="progressive"&&this.renderedHtml!==null)||renderedContentChanged)&&this.isConnected&&this.emit("lr-content-settled",null)}renderMarkdown(){if(this.streaming){if(normalizeMarkdownStreamingRender(this.streamingRender)==="progressive"){this.progressiveRebuild=!!this.progressiveSession,this.scheduleStreamingRender();return}this.renderedHtml=null,this.resetProgressiveMarkdown(),this.headingTree=[],this.codeHeader.setBlocks([]);return}const deps=this.deps;if(!deps)return;const session=this.progressiveSession;session?.update(this.content??""),session?.step(!0,!0),this.codeBlocks=[];const outcome=renderMarkdownDocument({tag:this.markdownVariant.tag,deps,htmlMode:normalizeMarkdownHtmlMode(this.htmlMode),math:this.math,codeBlockHeader:this.codeBlockHeader,parse:(marked,pendingKeys,headingTreeOut)=>this.parseMarkdown(marked,pendingKeys,headingTreeOut),onParsed:()=>this.maybeLoadKatex(),isKatexConfirmedMissing:()=>this.markdownVariant.katexState.isConfirmedMissing()});if(outcome.headingTree&&(this.headingTree=outcome.headingTree),outcome.status==="fallback"){this.renderedHtml=null,this.resetProgressiveMarkdown(),this.codeHeader.setBlocks([]),this.emit("lr-render-error",{error:outcome.error});return}const mode=normalizeMarkdownHtmlMode(this.htmlMode);session&&!session.failed&&session.blocks.map(block=>block.html).join("")===outcome.html&&(mode!=="trusted"||!session.blocks.some(block=>block.hasRawHtml))&&(mode==="sanitize"||session.blocks.slice(0,-1).every(block=>block.balanced))?(this.progressiveAdopted=!0,this.syncProgressiveMarkdown()):this.resetProgressiveMarkdown(),this.renderedHtml=outcome.html,this.codeHeader.setBlocks(this.codeBlocks),outcome.mathFailed&&this.reportMathFailure(),outcome.pendingKeys.length>0&&!this.withoutSyntaxHighlighting&&this.highlightPending(outcome.pendingKeys)}resetProgressiveMarkdown(){this.progressiveSession=void 0,this.progressiveAdopted=!1,this.progressiveRebuild=!1,this.renderedBlocks.length&&(this.renderedBlocks=[]),this.streamingTail=null}createProgressiveSession(previous){const deps=this.deps,mode=normalizeMarkdownHtmlMode(this.htmlMode);if(!deps?.marked||mode==="sanitize"&&!deps.DOMPurify)return;const context=createMarkdownRenderContext(this.markdownParseOptions(deps.marked,"",[],[],void 0,[]));if(!markdownProgressiveEligible(context.instance,!this.withoutGfm)){devWarnOnce("lyra-markdown-progressive-unavailable","<lr-markdown>: this parser configuration uses plain streaming.");return}const policy=markdownSanitizerPolicy({htmlMode:mode,math:this.math,codeBlockHeader:this.codeBlockHeader}),activeHighlightKeys=new Set,session=new MarkdownProgressiveSession({parser:context.instance,gfm:!this.withoutGfm,tabSize:finiteInteger(this.tabSize,4,1,32),render:(source,rawSource,links,state2,slugger,prefix)=>{const pendingKeys=[],headings=[],records=[],options=this.markdownParseOptions(deps.marked,source,pendingKeys,headings,slugger,records,rawSource);options.codeBlockIndexOffset=prefix.length,options.activeHighlightKeys=activeHighlightKeys,options.highlightCodeOption=!this.withoutSyntaxHighlighting;const result=createMarkdownRenderContext(options).render(source,{links,state:state2});return this.maybeLoadKatex(),{...result,rawHtml:result.html,html:finishMarkdownHtml(deps,policy,result.html),headings,codeBlocks:records,pendingKeys}}},previous?.blocks);return session.update(this.content??""),previous&&session.step(!1,!0,previous.end),session}renderProgressiveMarkdown(){const previous=this.progressiveSession;(!previous||this.progressiveRebuild)&&(this.progressiveSession=this.createProgressiveSession(previous),this.progressiveRebuild=!1);const session=this.progressiveSession;if(!session){this.renderedHtml=null,this.renderedBlocks=[],this.streamingTail=null,this.headingTree=[],this.codeHeader.setBlocks([]);return}session.update(this.content??""),session.step(),this.renderedHtml="",this.syncProgressiveMarkdown();const pending=session.nextHighlight();pending&&!this.withoutSyntaxHighlighting&&this.highlightPending([pending]),session.pending&&this.scheduleStreamingRender()}syncProgressiveMarkdown(){const session=this.progressiveSession;if(!session)return;(session.blocks.length!==this.renderedBlocks.length||session.blocks.some((block,index)=>block.html!==this.renderedBlocks[index]?.html))&&(this.renderedBlocks=session.blocks.map((block,index)=>({id:`stream-${index}`,html:block.html})),this.progressiveRevision++);const tail=session.tail;(tail?.kind!==this.streamingTail?.kind||tail?.text!==this.streamingTail?.text)&&(this.streamingTail=tail),this.headingTree=session.headings,this.codeHeader.setBlocks(session.records)}progressiveStats(){return this.progressiveSession?.stats}maybeLoadKatex(){this.math&&this.markdownVariant.katexState.startLoad(this.handleKatexResolved)}reportMathFailure(){this.mathFailureReported||(this.mathFailureReported=!0,this.emit("lr-render-error",{error:markdownMathPeerError(this.markdownVariant.tag)}))}getCachedHighlight(key){return getCachedHighlight(this.highlightCache,key)}setCachedHighlight(key,html){return setCachedHighlight(this.highlightCache,key,html,HIGHLIGHT_CACHE_MAX)}async highlightPending(pendingKeys){const work=pendingKeys.filter(({key})=>this.inFlightHighlightKeys.get(key)!==this.highlightToken);if(work.length===0)return;const token=this.highlightToken;for(const{key}of work)this.inFlightHighlightKeys.set(key,token);const languages=this.languages,isCurrent=()=>token===this.highlightToken&&this.isConnected,tokenizeOne=async pending=>{const html=await this.tokenizePendingHighlight(pending,languages,isCurrent);!isCurrent()||html===void 0||(html===null||!this.setCachedHighlight(pending.key,html))&&addFailedHighlightKey(this.failedHighlightKeys,pending.key)};try{await processPendingHighlights(work,tokenizeOne)}catch{for(const{key}of work)addFailedHighlightKey(this.failedHighlightKeys,key);devWarnOnce(HIGHLIGHT_FAILURE_WARNING_KEY,HIGHLIGHT_FAILURE_WARNING)}finally{for(const{key}of work)this.inFlightHighlightKeys.get(key)===token&&this.inFlightHighlightKeys.delete(key)}this.isConnected&&(this.progressiveSession?(this.progressiveSession.invalidateHighlights(work.map(({key})=>key)),this.streaming?this.scheduleStreamingRender():this.renderMarkdown()):this.renderMarkdown())}parseMarkdown(marked,pendingKeys,headingTreeOut){const source=this.content??"";return parseMarkdownDocument(this.markdownParseOptions(marked,normalizeMarkdownLeadingTabs(source,finiteInteger(this.tabSize,4,1,32)),pendingKeys,headingTreeOut,void 0,this.codeBlocks,source))}markdownParseOptions(marked,content,pendingKeys,headingTreeOut,slugger,codeBlocksOut=[],rawContent=content){const variant=this.markdownVariant;return{marked,slugger,content,pendingKeys,headingTreeOut,codeBlocksOut,rawContent,markedConfigurations:[variant.sharedParser.get(marked)?.defaults,this.marked?.defaults],gfm:!this.withoutGfm,linkTarget:this.linkTarget,headingOffset:finiteInteger(this.headingOffset,0,0,6),escapeHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="escape",trustedHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="trusted",codeBlockHeaderOption:this.codeBlockHeader,codeFrameNonce:this.codeBlockHeader?this.codeHeader.nonce:void 0,tabSize:finiteInteger(this.tabSize,4,1,32),highlightCodeOption:!this.withoutSyntaxHighlighting&&!this.streaming,getCachedHighlight:key=>this.getCachedHighlight(key),failedHighlightKeys:this.failedHighlightKeys,headingAnchorsOption:this.headingAnchors,mathOption:this.math,cachedKatex:this.math?variant.katexState.getIfLoaded():null}}getHeadingTree(){return[...this.headingTree]}contentRoot(){return this.renderRoot.querySelector('[part="content"]')}async applyAnchor(anchor){const root=this.contentRoot();if(!root)return!1;if(anchor.kind==="fragment")return applyMarkdownFragmentAnchor(root,anchor,this.headingTree);if(anchor.kind==="text-quote"){const index=this.markdownTextIndex(root),found=applyMarkdownTextQuoteAnchor(root,anchor,this.effectiveLocale,index);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.repaintHighlights(),found}return!1}computeSelectionAnchor(range){const root=this.contentRoot();if(!root)return null;const anchor=buildQuoteAnchor(range,this.markdownTextIndex(root).scope);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.scheduleAfterUpdate(()=>this.repaintHighlights()),anchor}ensureHighlightHandle(){return this.highlightHandle??=acquireHighlightHandle(this,this.ownerDocument),this.highlightHandle}markdownTextIndex(root){const locale=this.effectiveLocale,cached=this.textQuoteIndexCache;if(cached?.root===root&&cached.locale===locale&&!cached.mappingDirty)return cached.index;if(cached?.mappingDirty){const handle=this.ensureHighlightHandle();for(const tone of["accent","success","warning","danger","neutral"])handle.setRanges(tone,[]);handle.setActive(null)}const markers=this.progressiveSession?this.renderedBlocks.length*2+8:0,scope=scopeFromElement(root,{maxTraversalNodes:TEXT_QUOTE_LIMITS.maxTraversalNodes+markers});if(this.markdownTextScopeBuilds++,cached?.root===root&&cached.locale===locale&&cached.index.rebindScope(scope))return cached.mappingDirty=!1,cached.index;const index=createTextQuoteIndex(scope,locale);return this.textQuoteIndexCache={root,locale,index,mappingDirty:!1},index}markdownTextScopeBuildCount(){return this.markdownTextScopeBuilds}markdownTextQuoteScanCount(){return this.textQuoteIndexCache?.index.scanCount??0}repaintHighlights(){this.resolvedHighlightRanges=[];const root=this.contentRoot();if(!root)return;if(this.highlights.length===0){this.highlightHandle?.release(),this.highlightHandle=void 0;return}if(this.streaming&&this.progressiveSession&&!supportsCustomHighlights(this.ownerDocument)){this.highlightHandle?.release(),this.highlightHandle=void 0;return}const index=this.markdownTextIndex(root);this.resolvedHighlightRanges=repaintMarkdownHighlights({locale:this.effectiveLocale,root,handle:this.ensureHighlightHandle(),highlights:this.highlights,activeHighlightId:this.activeHighlightId,index}),!supportsCustomHighlights(this.ownerDocument)&&this.textQuoteIndexCache&&(this.textQuoteIndexCache.mappingDirty=!0)}render(){const progressiveRendering=!!(this.progressiveSession&&(this.streaming||this.progressiveAdopted));return renderMarkdownContent({content:this.content??"",sanitized:normalizeMarkdownHtmlMode(this.htmlMode)==="sanitize",renderedHtml:this.renderedHtml,fallbackSegments:!progressiveRendering&&this.renderedHtml===null?this.fallbackCode.segments(this.content??""):null,progressive:progressiveRendering?{blocks:this.renderedBlocks,tail:this.streamingTail}:null,hostAriaLabel:this.getAttribute("aria-label"),isDarkTheme:this.isDarkTheme,onClick:this.onContentClick,liveRegion:this.renderAnchorLiveRegion(),maxHeight:this.maxHeight})}}__decorate([state()],MarkdownRuntimeBase.prototype,"renderedHtml",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"renderedBlocks",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"streamingTail",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"progressiveRevision",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"isDarkTheme",void 0);export{MarkdownRuntimeBase,createMarkdownVariantContext};
1
+ import{__decorate}from"tslib";import"lit";import{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteInteger}from"../../../internal/numbers.js";import{DocumentAnchorTarget}from"../../../internal/anchor-target.js";import{buildQuoteAnchor,createTextQuoteIndex,scopeFromElement,TEXT_QUOTE_LIMITS}from"../../../internal/text-quote.js";import{acquireHighlightHandle,supportsCustomHighlights}from"../../../internal/text-highlights.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{MarkdownCodeHeaderController,renderMarkdownCodeHeader}from"./markdown-code-header.js";import{MarkdownFallbackCodeScanner}from"./markdown-fallback-code.js";import{MarkdownProgressiveSession,markdownProgressiveEligible}from"./markdown-progressive.js";import{addFailedHighlightKey,applyMarkdownAriaBusy,applyMarkdownFragmentAnchor,applyMarkdownTextQuoteAnchor,beginMarkdownDepsLoad,getCachedHighlight,hitTestHighlightRanges,HIGHLIGHT_CACHE_MAX,internalLinkHrefFrom,markdownAnchorFromTarget,markdownTableRegionLabel,markdownHasTableWrappers,labelMarkdownTableWrappers,markdownHighlightConfigChanged,markdownLanguageSetChanged,markdownMathPeerError,markdownNeedsReparse,MarkdownOwnedAnimationFrameController,MarkdownParserController,normalizeMarkdownHtmlMode,normalizeMarkdownStreamingRender,createMarkdownRenderContext,finishMarkdownHtml,markdownSanitizerPolicy,normalizeMarkdownLeadingTabs,parseMarkdownDocument,processPendingHighlights,renderMarkdownContent,renderMarkdownDocument,repaintMarkdownHighlights,resolveMarkdownDarkTheme,setCachedHighlight}from"./markdown-shared.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_markdownTableRegion}from"../../../internal/default-strings.generated.js";const HIGHLIGHT_FAILURE_WARNING_KEY="lyra-markdown-highlight-failed",HIGHLIGHT_FAILURE_WARNING="<lr-markdown>/<lr-markdown-core>: Syntax highlighting could not complete. Code is rendered as plain text.";function keyboardHighlightIdFrom(ranges,event){const coordinateLess=event.clientX===0&&event.clientY===0&&event.screenX===0&&event.screenY===0;if(event.detail!==0&&!coordinateLess)return null;const anchor=event.composedPath().find(target=>markdownAnchorFromTarget(target)!==void 0);if(!anchor)return null;for(let index=ranges.length-1;index>=0;index--){const range=ranges[index];if(range)try{if(range.range.intersectsNode(anchor))return range.id}catch{}}return null}class LyraMarkdownRuntimeElement extends LyraElement{static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed,markdownTableRegion:LYRA_DEFAULT_markdownTableRegion}}}function createMarkdownVariantContext(tag,katexState){return{tag,connectedInstances:new Set,sharedParser:new MarkdownParserController,katexState}}class MarkdownRuntimeBase extends DocumentAnchorTarget(LyraMarkdownRuntimeElement){constructor(){super(),this.anchorKinds=["fragment","text-quote"],this.renderedHtml=null,this.renderedBlocks=[],this.streamingTail=null,this.progressiveRevision=0,this.isDarkTheme=!1,this.boundLocalize=this.localize.bind(this),this.hasTableWrappers=!1,this.fallbackCode=new MarkdownFallbackCodeScanner,this.parser=new MarkdownParserController,this.headingTree=[],this.markdownTextScopeBuilds=0,this.resolvedHighlightRanges=[],this.mathFailureReported=!1,this.highlightCache=new Map,this.highlightToken=0,this.streamingRenderFrames=new MarkdownOwnedAnimationFrameController,this.failedHighlightKeys=new Set,this.inFlightHighlightKeys=new Map,this.progressiveAdopted=!1,this.progressiveRebuild=!1,this.progressiveInputGeneration=0,this.codeBlocks=[],this.handleKatexResolved=()=>{this.isConnected&&(this.progressiveSession&&this.streaming?(this.progressiveSession.invalidateMath(),this.scheduleStreamingRender()):this.renderMarkdown())},this.onContentClick=event=>{if(this.codeHeader.handleClick(event))return;const href=internalLinkHrefFrom(event,this.internalLinkPrefix);href!==null&&event.preventDefault();const highlightId=hitTestHighlightRanges(this.resolvedHighlightRanges,event.clientX,event.clientY)??keyboardHighlightIdFrom(this.resolvedHighlightRanges,event);highlightId&&this.emit("lr-highlight-activate",{highlightId}),href!==null&&this.emit("lr-link-activate",{href})},new ThemeWatcher(this,()=>this.refreshTheme()),this.codeHeader=new MarkdownCodeHeaderController(this,{isEnabled:()=>this.codeBlockHeader,contentVersion:()=>this.progressiveSession?this.renderedBlocks:this.renderedHtml,getContentRoot:()=>this.contentRoot(),localize:this.boundLocalize,buildHeader:(frame,language)=>renderMarkdownCodeHeader(frame,language),emitCopy:outcome=>this.emit("lr-copy",outcome),emitCopyError:outcome=>this.emit("lr-copy-error",outcome)})}get marked(){return this.parser.get(this.deps?.marked)}refreshTheme(){this.isDarkTheme=resolveMarkdownDarkTheme(this)}connectedCallback(){super.connectedCallback(),this.markdownVariant.connectedInstances.add(this),this.refreshTheme(),beginMarkdownDepsLoad(this,resolved=>{this.deps=resolved,this.renderMarkdown(),this.requestUpdate()})}disconnectedCallback(){this.markdownVariant.connectedInstances.delete(this),super.disconnectedCallback(),this.highlightToken++,this.cancelStreamingRender(),this.highlightHandle?.release(),this.highlightHandle=void 0,this.textQuoteIndexCache=void 0,this.fallbackCode.reset()}adoptedCallback(){super.adoptedCallback(),this.codeHeader.hostAdopted(),this.cancelStreamingRender(),this.streaming&&this.progressiveSession&&this.scheduleStreamingRender()}firstUpdated(changed){super.firstUpdated(changed);const contentRoot=this.renderRoot.querySelector('[part="content"]');contentRoot&&this.bindTextSelection(contentRoot)}willUpdate(changed){super.willUpdate(changed);const active=this.shadowRoot?.activeElement,selector='[part~="code-block"], [part~="code-block-copy"], [part~="table-wrapper"]';if(active?.matches(selector)&&(this.rememberedFocus={node:active,index:[...this.renderRoot.querySelectorAll(selector)].indexOf(active),selector}),changed.has("math")&&(this.mathFailureReported=!1),!this.deps||!markdownNeedsReparse(changed))return;const progressive=normalizeMarkdownStreamingRender(this.streamingRender)==="progressive",configurationChanged=[...changed.keys()].some(key=>key!=="content"&&key!=="streaming"&&markdownNeedsReparse(new Map([[key,void 0]])));(markdownHighlightConfigChanged(changed)||!progressive&&(changed.has("content")||changed.has("streaming")))&&this.highlightToken++,markdownHighlightConfigChanged(changed)&&(this.failedHighlightKeys.clear(),markdownLanguageSetChanged(changed)&&this.highlightCache.clear()),progressive?configurationChanged&&(this.progressiveRebuild=!0):this.resetProgressiveMarkdown(),changed.has("content")&&this.progressiveInputGeneration++,this.streaming?(this.progressiveAdopted&&(this.progressiveSession?.resume(),this.progressiveAdopted=!1),this.progressiveSession?.update(this.content??""),this.progressiveSession&&this.syncProgressiveMarkdown(),this.scheduleStreamingRender()):(this.cancelStreamingRender(),(changed.has("content")&&!changed.has("streaming")||configurationChanged)&&this.resetProgressiveMarkdown(),this.renderMarkdown())}cancelStreamingRender(){const handle=this.streamingRenderRaf;this.streamingRenderRaf=void 0,!this.streamingRenderFrames.cancel()&&handle!==void 0&&this.ownerDocument.defaultView?.cancelAnimationFrame(handle)}scheduleStreamingRender(){if(this.streamingRenderRaf!==void 0)return;const view=this.ownerDocument.defaultView;if(!view){this.isConnected&&this.runStreamingFrame();return}const handle=this.streamingRenderFrames.request(view,()=>{this.streamingRenderRaf=void 0,this.isConnected&&this.ownerDocument.defaultView===view&&this.runStreamingFrame()});handle===void 0?this.isConnected&&this.runStreamingFrame():this.streamingRenderFrames.handle===handle&&(this.streamingRenderRaf=handle)}runStreamingFrame(){normalizeMarkdownStreamingRender(this.streamingRender)==="progressive"?this.renderProgressiveMarkdown():this.renderMarkdown()}async getUpdateComplete(){await super.getUpdateComplete();const generation=this.progressiveInputGeneration,remaining=(this.content?.length??0)-(this.progressiveSession?.end??0),cap=Math.ceil(Math.max(0,remaining)/65536)+2;for(let frames=0;frames<cap&&this.streamingRenderRaf!==void 0&&(await this.streamingRenderFrames.settled,await super.getUpdateComplete(),generation===this.progressiveInputGeneration);frames++);return super.getUpdateComplete()}updated(changed){super.updated(changed),applyMarkdownAriaBusy(this,!this.deps||this.streaming);const renderedChanged=changed.has("renderedHtml")||changed.has("renderedBlocks");if(renderedChanged&&(this.hasTableWrappers=markdownHasTableWrappers(this.contentRoot())),!this.hasTableWrappers)this.tableRegionLabel=void 0;else{const tableLabel=markdownTableRegionLabel(this.boundLocalize);(renderedChanged||tableLabel!==this.tableRegionLabel)&&(this.tableRegionLabel=tableLabel,labelMarkdownTableWrappers(this.contentRoot(),tableLabel))}const remembered=this.rememberedFocus;if(this.rememberedFocus=void 0,remembered&&!remembered.node.isConnected){let active=this.ownerDocument.activeElement;for(;active?.shadowRoot?.activeElement;)active=active.shadowRoot.activeElement;if(!active||active===this.ownerDocument.body||active===this.ownerDocument.documentElement){const target=this.renderRoot.querySelectorAll(remembered.selector)[remembered.index];target?target.focus({preventScroll:!0}):this.streaming&&(this.rememberedFocus=remembered)}}const locale=this.effectiveLocale,localeChanged=this.textQuoteLocale!==void 0&&this.textQuoteLocale!==locale;this.textQuoteLocale=locale;const renderedContentChanged=changed.has("renderedHtml")||changed.has("renderedBlocks")||changed.has("streamingTail")||changed.has("progressiveRevision");(localeChanged||renderedContentChanged||changed.has("content"))&&(this.textQuoteIndexCache=void 0),(renderedContentChanged||changed.has("highlights")||changed.has("activeHighlightId")||localeChanged&&this.highlights.length>0)&&this.repaintHighlights(),(changed.has("content")&&!(this.streaming&&this.streamingRender==="progressive"&&this.renderedHtml!==null)||renderedContentChanged)&&this.isConnected&&this.emit("lr-content-settled",null)}renderMarkdown(){if(this.streaming){if(normalizeMarkdownStreamingRender(this.streamingRender)==="progressive"){this.progressiveRebuild=!!this.progressiveSession,this.scheduleStreamingRender();return}this.renderedHtml=null,this.resetProgressiveMarkdown(),this.headingTree=[],this.codeHeader.setBlocks([]);return}const deps=this.deps;if(!deps)return;const session=this.progressiveSession;session?.update(this.content??""),session?.step(!0,!0),this.codeBlocks=[];const outcome=renderMarkdownDocument({tag:this.markdownVariant.tag,deps,htmlMode:normalizeMarkdownHtmlMode(this.htmlMode),math:this.math,codeBlockHeader:this.codeBlockHeader,parse:(marked,pendingKeys,headingTreeOut)=>this.parseMarkdown(marked,pendingKeys,headingTreeOut),onParsed:()=>this.maybeLoadKatex(),isKatexConfirmedMissing:()=>this.markdownVariant.katexState.isConfirmedMissing()});if(outcome.headingTree&&(this.headingTree=outcome.headingTree),outcome.status==="fallback"){this.renderedHtml=null,this.resetProgressiveMarkdown(),this.codeHeader.setBlocks([]),this.emit("lr-render-error",{error:outcome.error});return}const mode=normalizeMarkdownHtmlMode(this.htmlMode);session&&!session.failed&&session.blocks.map(block=>block.html).join("")===outcome.html&&(mode!=="trusted"||!session.blocks.some(block=>block.hasRawHtml))&&(mode==="sanitize"||session.blocks.slice(0,-1).every(block=>block.balanced))?(this.progressiveAdopted=!0,this.syncProgressiveMarkdown()):this.resetProgressiveMarkdown(),this.renderedHtml=outcome.html,this.codeHeader.setBlocks(this.codeBlocks),outcome.mathFailed&&this.reportMathFailure(),outcome.pendingKeys.length>0&&!this.withoutSyntaxHighlighting&&this.highlightPending(outcome.pendingKeys)}resetProgressiveMarkdown(){this.progressiveSession=void 0,this.progressiveAdopted=!1,this.progressiveRebuild=!1,this.renderedBlocks.length&&(this.renderedBlocks=[]),this.streamingTail=null}createProgressiveSession(previous){const deps=this.deps,mode=normalizeMarkdownHtmlMode(this.htmlMode);if(!deps?.marked||mode==="sanitize"&&!deps.DOMPurify)return;const context=createMarkdownRenderContext(this.markdownParseOptions(deps.marked,"",[],[],void 0,[]));if(!markdownProgressiveEligible(context.instance,!this.withoutGfm)){devWarnOnce("lyra-markdown-progressive-unavailable","<lr-markdown>: this parser configuration uses plain streaming.");return}const policy=markdownSanitizerPolicy({htmlMode:mode,math:this.math,codeBlockHeader:this.codeBlockHeader}),activeHighlightKeys=new Set,session=new MarkdownProgressiveSession({parser:context.instance,gfm:!this.withoutGfm,tabSize:finiteInteger(this.tabSize,4,1,32),render:(source,rawSource,links,state2,slugger,prefix)=>{const pendingKeys=[],headings=[],records=[],options=this.markdownParseOptions(deps.marked,source,pendingKeys,headings,slugger,records,rawSource);options.codeBlockIndexOffset=prefix.length,options.activeHighlightKeys=activeHighlightKeys,options.highlightCodeOption=!this.withoutSyntaxHighlighting;const result=createMarkdownRenderContext(options).render(source,{links,state:state2});return this.maybeLoadKatex(),{...result,rawHtml:result.html,html:finishMarkdownHtml(deps,policy,result.html),headings,codeBlocks:records,pendingKeys}}},previous?.blocks);return session.update(this.content??""),previous&&session.step(!1,!0,previous.end),session}renderProgressiveMarkdown(){const previous=this.progressiveSession;(!previous||this.progressiveRebuild)&&(this.progressiveSession=this.createProgressiveSession(previous),this.progressiveRebuild=!1);const session=this.progressiveSession;if(!session){this.renderedHtml=null,this.renderedBlocks=[],this.streamingTail=null,this.headingTree=[],this.codeHeader.setBlocks([]);return}session.update(this.content??""),session.step(),this.renderedHtml="",this.syncProgressiveMarkdown();const pending=session.nextHighlight();pending&&!this.withoutSyntaxHighlighting&&this.highlightPending([pending]),session.pending&&this.scheduleStreamingRender()}syncProgressiveMarkdown(){const session=this.progressiveSession;if(!session)return;(session.blocks.length!==this.renderedBlocks.length||session.blocks.some((block,index)=>block.html!==this.renderedBlocks[index]?.html))&&(this.renderedBlocks=session.blocks.map((block,index)=>({id:`stream-${index}`,html:block.html})),this.progressiveRevision++);const tail=session.tail;(tail?.kind!==this.streamingTail?.kind||tail?.text!==this.streamingTail?.text)&&(this.streamingTail=tail),this.headingTree=session.headings,this.codeHeader.setBlocks(session.records)}progressiveStats(){return this.progressiveSession?.stats}maybeLoadKatex(){this.math&&this.markdownVariant.katexState.startLoad(this.handleKatexResolved)}reportMathFailure(){this.mathFailureReported||(this.mathFailureReported=!0,this.emit("lr-render-error",{error:markdownMathPeerError(this.markdownVariant.tag)}))}getCachedHighlight(key){return getCachedHighlight(this.highlightCache,key)}setCachedHighlight(key,html){return setCachedHighlight(this.highlightCache,key,html,HIGHLIGHT_CACHE_MAX)}async highlightPending(pendingKeys){const work=pendingKeys.filter(({key})=>this.inFlightHighlightKeys.get(key)!==this.highlightToken);if(work.length===0)return;const token=this.highlightToken;for(const{key}of work)this.inFlightHighlightKeys.set(key,token);const languages=this.languages,isCurrent=()=>token===this.highlightToken&&this.isConnected,tokenizeOne=async pending=>{const html=await this.tokenizePendingHighlight(pending,languages,isCurrent);!isCurrent()||html===void 0||(html===null||!this.setCachedHighlight(pending.key,html))&&addFailedHighlightKey(this.failedHighlightKeys,pending.key)};try{await processPendingHighlights(work,tokenizeOne)}catch{for(const{key}of work)addFailedHighlightKey(this.failedHighlightKeys,key);devWarnOnce(HIGHLIGHT_FAILURE_WARNING_KEY,HIGHLIGHT_FAILURE_WARNING)}finally{for(const{key}of work)this.inFlightHighlightKeys.get(key)===token&&this.inFlightHighlightKeys.delete(key)}this.isConnected&&(this.progressiveSession?(this.progressiveSession.invalidateHighlights(work.map(({key})=>key)),this.streaming?this.scheduleStreamingRender():this.renderMarkdown()):this.renderMarkdown())}parseMarkdown(marked,pendingKeys,headingTreeOut){const source=this.content??"";return parseMarkdownDocument(this.markdownParseOptions(marked,normalizeMarkdownLeadingTabs(source,finiteInteger(this.tabSize,4,1,32)),pendingKeys,headingTreeOut,void 0,this.codeBlocks,source))}markdownParseOptions(marked,content,pendingKeys,headingTreeOut,slugger,codeBlocksOut=[],rawContent=content){const variant=this.markdownVariant;return{marked,slugger,content,pendingKeys,headingTreeOut,codeBlocksOut,rawContent,markedConfigurations:[variant.sharedParser.get(marked)?.defaults,this.marked?.defaults],gfm:!this.withoutGfm,linkTarget:this.linkTarget,headingOffset:finiteInteger(this.headingOffset,0,0,6),escapeHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="escape",trustedHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="trusted",codeBlockHeaderOption:this.codeBlockHeader,codeFrameNonce:this.codeBlockHeader?this.codeHeader.nonce:void 0,tabSize:finiteInteger(this.tabSize,4,1,32),highlightCodeOption:!this.withoutSyntaxHighlighting&&!this.streaming,getCachedHighlight:key=>this.getCachedHighlight(key),failedHighlightKeys:this.failedHighlightKeys,headingAnchorsOption:this.headingAnchors,mathOption:this.math,cachedKatex:this.math?variant.katexState.getIfLoaded():null}}getHeadingTree(){return[...this.headingTree]}contentRoot(){return this.renderRoot.querySelector('[part="content"]')}async applyAnchor(anchor){const root=this.contentRoot();if(!root)return!1;if(anchor.kind==="fragment")return applyMarkdownFragmentAnchor(root,anchor,this.headingTree);if(anchor.kind==="text-quote"){const index=this.markdownTextIndex(root),found=applyMarkdownTextQuoteAnchor(root,anchor,this.effectiveLocale,index);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.repaintHighlights(),found}return!1}computeSelectionAnchor(range){const root=this.contentRoot();if(!root)return null;const anchor=buildQuoteAnchor(range,this.markdownTextIndex(root).scope);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.scheduleAfterUpdate(()=>this.repaintHighlights()),anchor}ensureHighlightHandle(){return this.highlightHandle??=acquireHighlightHandle(this,this.ownerDocument),this.highlightHandle}markdownTextIndex(root){const locale=this.effectiveLocale,cached=this.textQuoteIndexCache;if(cached?.root===root&&cached.locale===locale&&!cached.mappingDirty)return cached.index;if(cached?.mappingDirty){const handle=this.ensureHighlightHandle();for(const tone of["accent","success","warning","danger","neutral"])handle.setRanges(tone,[]);handle.setActive(null)}const markers=this.progressiveSession?this.renderedBlocks.length*2+8:0,scope=scopeFromElement(root,{maxTraversalNodes:TEXT_QUOTE_LIMITS.maxTraversalNodes+markers});if(this.markdownTextScopeBuilds++,cached?.root===root&&cached.locale===locale&&cached.index.rebindScope(scope))return cached.mappingDirty=!1,cached.index;const index=createTextQuoteIndex(scope,locale);return this.textQuoteIndexCache={root,locale,index,mappingDirty:!1},index}markdownTextScopeBuildCount(){return this.markdownTextScopeBuilds}markdownTextQuoteScanCount(){return this.textQuoteIndexCache?.index.scanCount??0}repaintHighlights(){this.resolvedHighlightRanges=[];const root=this.contentRoot();if(!root)return;if(this.highlights.length===0){this.highlightHandle?.release(),this.highlightHandle=void 0;return}if(this.streaming&&this.progressiveSession&&!supportsCustomHighlights(this.ownerDocument)){this.highlightHandle?.release(),this.highlightHandle=void 0;return}const index=this.markdownTextIndex(root);this.resolvedHighlightRanges=repaintMarkdownHighlights({locale:this.effectiveLocale,root,handle:this.ensureHighlightHandle(),highlights:this.highlights,activeHighlightId:this.activeHighlightId,index}),!supportsCustomHighlights(this.ownerDocument)&&this.textQuoteIndexCache&&(this.textQuoteIndexCache.mappingDirty=!0)}render(){const progressiveRendering=!!(this.progressiveSession&&(this.streaming||this.progressiveAdopted));return renderMarkdownContent({content:this.content??"",sanitized:normalizeMarkdownHtmlMode(this.htmlMode)==="sanitize",renderedHtml:this.renderedHtml,fallbackSegments:!progressiveRendering&&this.renderedHtml===null?this.fallbackCode.segments(this.content??""):null,progressive:progressiveRendering?{blocks:this.renderedBlocks,tail:this.streamingTail}:null,hostAriaLabel:this.getAttribute("aria-label"),isDarkTheme:this.isDarkTheme,onClick:this.onContentClick,liveRegion:this.renderAnchorLiveRegion(),maxHeight:this.maxHeight})}}__decorate([state()],MarkdownRuntimeBase.prototype,"renderedHtml",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"renderedBlocks",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"streamingTail",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"progressiveRevision",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"isDarkTheme",void 0);export{MarkdownRuntimeBase,createMarkdownVariantContext};
@@ -3,9 +3,7 @@ import type{LyraClipboardWriteSuccess,LyraClipboardWriteFailure}from'../../../in
3
3
  * before this type moved into the pair's shared module -- see `markdown-shared.ts`'s class doc. */
4
4
  export type MarkdownHeadingItem=SharedMarkdownHeadingItem;
5
5
  /** Peer-neutral public alias matching the full variant's `getMarked()` signature. */
6
- export type Marked=LyraMarkedParser;export type{MarkdownStreamingRenderMode};export type{MarkdownStreamingRender}from'./markdown-shared.js';export interface LyraMarkdownCoreEventMap extends LyraAnchorTargetEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-link-activate':CustomEvent<{href:string;}>;
7
- /** @deprecated Use lr-link-activate. */
8
- 'lr-link-click':CustomEvent<{href:string;}>;'lr-content-settled':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;}
6
+ export type Marked=LyraMarkedParser;export type{MarkdownStreamingRenderMode};export type{MarkdownStreamingRender}from'./markdown-shared.js';export interface LyraMarkdownCoreEventMap extends LyraAnchorTargetEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-link-activate':CustomEvent<{href:string;}>;'lr-content-settled':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;}
9
7
  /**
10
8
  * `<lr-markdown-core>` — a build-lean variant of `<lr-markdown>` for a consumer whose
11
9
  * `languages` map already covers every language it will ever render. Every other capability (GFM
@@ -106,7 +104,6 @@ export type Marked=LyraMarkedParser;export type{MarkdownStreamingRenderMode};exp
106
104
  * `lr-render-error`.
107
105
  *
108
106
  * @customElement lr-markdown-core
109
- * @event lr-link-click - Deprecated compatibility alias of `lr-link-activate`, emitted afterward with the same detail.
110
107
  * @event lr-link-activate - Fired (and the click prevented) when a rendered
111
108
  * link's `href` starts with `internal-link-prefix`. `detail: { href: string }`.
112
109
  * Ordinary external links navigate normally
@@ -4,9 +4,7 @@ import type{LyraClipboardWriteSuccess,LyraClipboardWriteFailure}from'../../../in
4
4
  export type MarkdownHeadingItem=SharedMarkdownHeadingItem;
5
5
  /** Peer-neutral public alias matching the upstream static `getMarked()` signature without
6
6
  * importing the optional `marked` peer into the runtime graph. */
7
- export type Marked=LyraMarkedParser;export type{MarkdownStreamingRenderMode};export type{MarkdownStreamingRender}from'./markdown-shared.js';export interface LyraMarkdownEventMap extends LyraAnchorTargetEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-link-activate':CustomEvent<{href:string;}>;
8
- /** @deprecated Use lr-link-activate. */
9
- 'lr-link-click':CustomEvent<{href:string;}>;'lr-content-settled':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;}
7
+ export type Marked=LyraMarkedParser;export type{MarkdownStreamingRenderMode};export type{MarkdownStreamingRender}from'./markdown-shared.js';export interface LyraMarkdownEventMap extends LyraAnchorTargetEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-link-activate':CustomEvent<{href:string;}>;'lr-content-settled':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;}
10
8
  /**
11
9
  * `<lr-markdown>` — sanitized Markdown-to-HTML rendering (GFM tables,
12
10
  * fenced code blocks, links, blockquotes) built on the optional peer
@@ -110,7 +108,6 @@ export type Marked=LyraMarkedParser;export type{MarkdownStreamingRenderMode};exp
110
108
  * anything that updates after first connect.
111
109
  *
112
110
  * @customElement lr-markdown
113
- * @event lr-link-click - Deprecated compatibility alias of `lr-link-activate`, emitted afterward with the same detail.
114
111
  * @event lr-link-activate - Fired (and the click prevented) when a rendered
115
112
  * link's `href` starts with `internal-link-prefix`. `detail: { href: string }`.
116
113
  * Ordinary external links navigate normally
@@ -1,6 +1,4 @@
1
- import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import'../../utility/copy-button/copy-button.class.js';import'../message-feedback/message-feedback.class.js';import type{LyraClipboardWriteFailure,LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';import type{MessageFeedbackSubmitDetail,MessageFeedbackValue}from'../message-feedback/message-feedback.class.js';export type MessageActionControl='copy'|'regenerate'|'edit'|'feedback';export interface LyraMessageActionsEventMap{'lr-regenerate':CustomEvent<null>;'lr-edit':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-error':CustomEvent<null>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;'lr-feedback-change':CustomEvent<{rating:MessageFeedbackValue;}>;'lr-feedback-submit-request':CustomEvent<LyraEventDetailSnapshot<MessageFeedbackSubmitDetail>>;
2
- /** @deprecated Use `lr-feedback-submit-request`. */
3
- 'lr-feedback-submit':CustomEvent<LyraEventDetailSnapshot<MessageFeedbackSubmitDetail>>;}
1
+ import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import'../../utility/copy-button/copy-button.class.js';import'../message-feedback/message-feedback.class.js';import type{LyraClipboardWriteFailure,LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';import type{MessageFeedbackSubmitDetail,MessageFeedbackValue}from'../message-feedback/message-feedback.class.js';export type MessageActionControl='copy'|'regenerate'|'edit'|'feedback';export interface LyraMessageActionsEventMap{'lr-regenerate':CustomEvent<null>;'lr-edit':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-error':CustomEvent<null>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;'lr-feedback-change':CustomEvent<{rating:MessageFeedbackValue;}>;'lr-feedback-submit-request':CustomEvent<LyraEventDetailSnapshot<MessageFeedbackSubmitDetail>>;}
4
2
  /**
5
3
  * `<lr-message-actions>` — the per-message action toolbar for `<lr-chat-message>`'s `actions`
6
4
  * slot: opt-in built-ins (copy / regenerate / edit / feedback) that emit intent events, plus a
@@ -60,7 +58,6 @@ import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';impo
60
58
  * @event lr-feedback-change - Bubbles unchanged from the embedded, thumbs-only
61
59
  * `lr-message-feedback`. `detail: { rating }`. A colliding event from a slotted custom child is
62
60
  * contained at the slot boundary and remains observable directly on that child.
63
- * @event lr-feedback-submit - Deprecated cancelable compatibility alias of `lr-feedback-submit-request`.
64
61
  * @event lr-feedback-submit-request - The built-in feedback control's terminal cancelable persistence
65
62
  * request, including thumbs-only choices. Its frozen detail includes a nonblank `submissionId`;
66
63
  * when prevented, pass that exact ID to `finalizePendingSubmit()` or
@@ -9,7 +9,7 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
9
9
  <path d="M12 20h9"></path>
10
10
  <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
11
11
  </svg>
12
- `}class LyraMessageActions extends LyraElement{constructor(){super(...arguments),this.controls=[],this.copyText="",this.feedbackRating=null,this.revealOnInteraction=!1,this.accessibleLabel=null,this.activeStopIndex=0,this.revealed=!1,this.hoverTarget=null,this.slottedOverlay=new SlottedOverlayController(this,()=>this.renderRoot?.querySelector('[part="base"] > slot:not([name])')),this.slottedOverlayWasOpen=!1,this.stopSyncGeneration=0,this.managedStops=[],this.directActions=new WeakMap,this.nextDirectActionId=0,this.onHoverTargetEnter=()=>{this.setRevealed(!0)},this.onHoverTargetLeave=()=>{!this.matches(":focus-within")&&!this.slottedOverlay.open&&this.setRevealed(!1)},this.onFocusIn=event=>{this.setRevealed(!0);const stops=this.logicalActions(),path=event.composedPath(),index=stops.findIndex(({action})=>action.matchesEventPath(path));if(index>=0){this.setActiveStop(stops,index,stops[index]);const base=this.renderRoot.querySelector('[part="base"]'),repair=base?captureComposedFocusRepair(this,base):null,stop=stops[index];this.focusedStop=stop&&repair?{index,owner:stop.owner,id:stop.action.id,source:stop.source,repair}:void 0}else this.focusedStop=void 0},this.onFocusOut=event=>{!this.hoverTarget?.matches(":hover")&&!this.slottedOverlay.open&&this.setRevealed(!1);const destination=event.relatedTarget;destination&&destination.nodeType===1&&!composedContains(this,destination)&&(this.focusedStop=void 0)},this.onStopMutations=records=>{this.reconcileStopsAfterChildren()},this.onSlotChange=()=>{const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()},this.onToolbarActionsChange=event=>{event.stopPropagation(),this.reconcileStopsAfterChildren()},this.containSlottedFeedbackEvent=event=>{event.stopPropagation()},this.onToolbarKeyDown=e=>{const stops=this.logicalActions();if(stops.length===0)return;const path=e.composedPath(),originIndex=stops.findIndex(({action})=>action.matchesEventPath(path));if(originIndex<0&&path[0]!==e.currentTarget)return;const currentIndex=originIndex>=0?originIndex:this.activeStopIndex,forwardKey=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backwardKey=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";let target;if(e.key===forwardKey)target=(currentIndex+1)%stops.length;else if(e.key===backwardKey)target=(currentIndex-1+stops.length)%stops.length;else if(e.key==="Home")target=0;else if(e.key==="End")target=stops.length-1;else return;e.preventDefault(),this.setActiveStop(stops,target),stops[target]?.action.focus()},this.onRegenerateClick=()=>{this.emit("lr-regenerate",null)},this.onEditClick=()=>{this.emit("lr-edit",null)}}static{this.defaultStrings={...super.defaultStrings,editMessage:LYRA_DEFAULT_editMessage,fieldRequired:LYRA_DEFAULT_fieldRequired,messageActionsLabel:LYRA_DEFAULT_messageActionsLabel,regenerateResponse:LYRA_DEFAULT_regenerateResponse}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["controls"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-feedback-submit","lr-feedback-submit-request"])}get effectiveControls(){const seen=new Set,controls=[];for(const value of this.controls){if(typeof value!="string"||!MESSAGE_ACTION_CONTROLS.includes(value)||seen.has(value))continue;const control=value;seen.add(control),controls.push(control)}return controls}get feedbackPending(){return this.currentBuiltInFeedback()?.pending===!0}finalizePendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.finalizePendingSubmit(submissionId):!1}revertPendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.revertPendingSubmit(submissionId):!1}currentBuiltInFeedback(){const base=this.renderRoot.querySelector('[part="base"]'),feedback=base?.querySelector('lr-message-feedback[part~="feedback"]');return feedback&&feedback.parentElement===base&&feedback.getRootNode()===this.renderRoot&&feedback.isConnected?feedback:void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.revealOnInteraction&&this.bindHoverTarget(),this.hasUpdated&&this.reconcileStopsAfterChildren()}disconnectedCallback(){this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops(),this.focusedStop=void 0,this.unbindHoverTarget(),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops()}willUpdate(changed){super.willUpdate(changed),changed.has("revealOnInteraction")&&(this.revealOnInteraction?this.bindHoverTarget():this.unbindHoverTarget());const overlayOpen=this.slottedOverlay.open;overlayOpen!==this.slottedOverlayWasOpen&&(this.slottedOverlayWasOpen=overlayOpen,overlayOpen?this.setRevealed(!0):!this.hoverTarget?.matches(":hover")&&!this.matches(":focus-within")&&this.setRevealed(!1))}firstUpdated(changed){super.firstUpdated(changed),this.setActiveStop(this.logicalActions(),0),this.reconcileStopsAfterChildren()}updated(changed){if(super.updated(changed),changed.has("controls")){const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()}}setRevealed(revealed){this.revealed!==revealed&&(this.revealed=revealed,this.toggleAttribute("data-revealed",revealed))}bindHoverTarget(){this.unbindHoverTarget();const target=this.closest("lr-chat-message")??this.parentElement;target&&(this.hoverTarget=target,target.addEventListener("pointerenter",this.onHoverTargetEnter),target.addEventListener("pointerleave",this.onHoverTargetLeave))}unbindHoverTarget(){this.hoverTarget?.removeEventListener("pointerenter",this.onHoverTargetEnter),this.hoverTarget?.removeEventListener("pointerleave",this.onHoverTargetLeave),this.hoverTarget=null,this.setRevealed(!1)}actionRoots(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return[];const direct=[...base.children].filter(element=>element.localName!=="slot"),slot=base.querySelector("slot");return[...direct,...slot?.assignedElements({flatten:!0})??[]]}sameAction(left,right){return left.owner===right.owner&&left.source===right.source&&left.action.id===right.action.id}isAvailable(action){try{return action.disabled!==!0}catch{return!1}}directActionFor(element){let action=this.directActions.get(element);if(action)return action;const target=element,id=`direct-${++this.nextDirectActionId}`;let leasedTarget,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const leased=leasedTarget;leased&&leased.getAttribute("tabindex")===lastManagedTabIndex&&(leasedAuthoredTabIndex===null?leased.removeAttribute("tabindex"):leased.setAttribute("tabindex",leasedAuthoredTabIndex)),leasedTarget=void 0,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return action={id,get disabled(){return!isComposedFocusAvailable(element)},focus(options){target.focus(options)},setTabIndex(tabIndex){if(leasedTarget!==target&&(releaseTabIndex(),leasedTarget=target,leasedAuthoredTabIndex=target.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&target.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}target.tabIndex=tabIndex,lastManagedTabIndex=target.getAttribute("tabindex")},releaseTabIndex,hasAuthoredTabIndex(){return leasedTarget!==target?target.hasAttribute("tabindex"):lastManagedTabIndex!==null&&target.getAttribute("tabindex")===lastManagedTabIndex?leasedAuthoredTabIndex!==null:target.hasAttribute("tabindex")},matchesEventPath(path){return path.includes(element)}},this.directActions.set(element,action),action}logicalActions(){const actions=[],addProvider=(owner,provider)=>{const getToolbarActions=dataCallable(provider,"getToolbarActions");if(!getToolbarActions)return;let provided;try{provided=Reflect.apply(getToolbarActions,provider,[])}catch{return}let isArray=!1;try{isArray=Array.isArray(provided)}catch{return}if(!isArray)return;const length=getOwnDataDescriptor(provided,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const seen=new Set,inspected=Math.min(length.value,MAX_TOOLBAR_ACTIONS);for(let index=0;index<inspected;index+=1){const candidate=getOwnDataDescriptor(provided,String(index));if(candidate===MISSING_OWN_DATA_DESCRIPTOR||candidate===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const projected=projectToolbarAction(candidate.value);!projected||seen.has(projected.action.id)||(seen.add(projected.action.id),this.isAvailable(projected.action)&&actions.push({owner,...projected}))}},visit=element=>{if(isLyraToolbarActionProvider(element)){addProvider(element,element);return}const knownAction=this.directActions.get(element);if(isSemanticActionElement(element)||(knownAction?.hasAuthoredTabIndex()??element.hasAttribute("tabindex"))){const action=this.directActionFor(element);this.isAvailable(action)&&actions.push({owner:element,action,source:action});return}for(const child of element.children)visit(child)};for(const root of this.actionRoots())visit(root);return actions}setActiveStop(stops,index,preferred){this.stopObserver?.disconnect();for(const previous of this.managedStops)stops.some(stop=>this.sameAction(stop,previous))||this.releaseManagedStop(previous);const preferredIndex=preferred?stops.findIndex(stop=>this.sameAction(stop,preferred)):-1;this.activeStopIndex=stops.length===0?0:preferredIndex>=0?preferredIndex:Math.min(Math.max(0,index),stops.length-1),stops.forEach(({action},stopIndex)=>{try{action.setTabIndex(stopIndex===this.activeStopIndex?0:-1)}catch{}}),this.managedStops=stops,this.observeStopChanges()}releaseManagedStop(stop){try{stop.action.releaseTabIndex?.()}catch{}this.directActions.get(stop.owner)===stop.action&&this.directActions.delete(stop.owner)}releaseManagedStops(){for(const stop of this.managedStops)this.releaseManagedStop(stop);this.managedStops=[]}observeStopChanges(){this.stopObserver?.disconnect();const Observer=this.ownerDocument.defaultView?.MutationObserver,base=this.renderRoot.querySelector('[part="base"]');if(!Observer||!base||!this.isConnected){this.stopObserver=void 0;return}const observer=new Observer(this.onStopMutations),roots=new Set([base,...this.actionRoots()]),options={attributes:!0,attributeOldValue:!0,attributeFilter:["aria-disabled","aria-hidden","contenteditable","controls","disabled","hidden","href","inert","open","role","tabindex","type"],childList:!0,subtree:!0};for(const root of roots)observer.observe(root,options);this.stopObserver=observer}async reconcileStopsAfterChildren(){const generation=++this.stopSyncGeneration,pending=this.actionRoots().map(root=>root.updateComplete).filter(value=>value!==void 0&&typeof value.then=="function");if(await Promise.all(pending),await Promise.resolve(),generation!==this.stopSyncGeneration||!this.isConnected)return;const stops=this.logicalActions(),focused=this.focusedStop,retainedIndex=focused?stops.findIndex(stop=>stop.owner===focused.owner&&stop.source===focused.source&&stop.action.id===focused.id):-1,targetIndex=retainedIndex>=0?retainedIndex:Math.min(focused?Math.max(0,focused.index):this.activeStopIndex,Math.max(0,stops.length-1));if(this.setActiveStop(stops,targetIndex),focused&&retainedIndex<0){const base=this.renderRoot.querySelector('[part="base"]');base&&applyComposedFocusRepair(focused.repair,base)&&stops[targetIndex]?.action.focus(),this.focusedStop===focused&&(this.focusedStop=void 0)}}renderControl(type){switch(type){case"copy":return this.copyText?html`<lr-copy-button
12
+ `}class LyraMessageActions extends LyraElement{constructor(){super(...arguments),this.controls=[],this.copyText="",this.feedbackRating=null,this.revealOnInteraction=!1,this.accessibleLabel=null,this.activeStopIndex=0,this.revealed=!1,this.hoverTarget=null,this.slottedOverlay=new SlottedOverlayController(this,()=>this.renderRoot?.querySelector('[part="base"] > slot:not([name])')),this.slottedOverlayWasOpen=!1,this.stopSyncGeneration=0,this.managedStops=[],this.directActions=new WeakMap,this.nextDirectActionId=0,this.onHoverTargetEnter=()=>{this.setRevealed(!0)},this.onHoverTargetLeave=()=>{!this.matches(":focus-within")&&!this.slottedOverlay.open&&this.setRevealed(!1)},this.onFocusIn=event=>{this.setRevealed(!0);const stops=this.logicalActions(),path=event.composedPath(),index=stops.findIndex(({action})=>action.matchesEventPath(path));if(index>=0){this.setActiveStop(stops,index,stops[index]);const base=this.renderRoot.querySelector('[part="base"]'),repair=base?captureComposedFocusRepair(this,base):null,stop=stops[index];this.focusedStop=stop&&repair?{index,owner:stop.owner,id:stop.action.id,source:stop.source,repair}:void 0}else this.focusedStop=void 0},this.onFocusOut=event=>{!this.hoverTarget?.matches(":hover")&&!this.slottedOverlay.open&&this.setRevealed(!1);const destination=event.relatedTarget;destination&&destination.nodeType===1&&!composedContains(this,destination)&&(this.focusedStop=void 0)},this.onStopMutations=records=>{this.reconcileStopsAfterChildren()},this.onSlotChange=()=>{const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()},this.onToolbarActionsChange=event=>{event.stopPropagation(),this.reconcileStopsAfterChildren()},this.containSlottedFeedbackEvent=event=>{event.stopPropagation()},this.onToolbarKeyDown=e=>{const stops=this.logicalActions();if(stops.length===0)return;const path=e.composedPath(),originIndex=stops.findIndex(({action})=>action.matchesEventPath(path));if(originIndex<0&&path[0]!==e.currentTarget)return;const currentIndex=originIndex>=0?originIndex:this.activeStopIndex,forwardKey=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backwardKey=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";let target;if(e.key===forwardKey)target=(currentIndex+1)%stops.length;else if(e.key===backwardKey)target=(currentIndex-1+stops.length)%stops.length;else if(e.key==="Home")target=0;else if(e.key==="End")target=stops.length-1;else return;e.preventDefault(),this.setActiveStop(stops,target),stops[target]?.action.focus()},this.onRegenerateClick=()=>{this.emit("lr-regenerate",null)},this.onEditClick=()=>{this.emit("lr-edit",null)}}static{this.defaultStrings={...super.defaultStrings,editMessage:LYRA_DEFAULT_editMessage,fieldRequired:LYRA_DEFAULT_fieldRequired,messageActionsLabel:LYRA_DEFAULT_messageActionsLabel,regenerateResponse:LYRA_DEFAULT_regenerateResponse}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["controls"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-feedback-submit-request"])}get effectiveControls(){const seen=new Set,controls=[];for(const value of this.controls){if(typeof value!="string"||!MESSAGE_ACTION_CONTROLS.includes(value)||seen.has(value))continue;const control=value;seen.add(control),controls.push(control)}return controls}get feedbackPending(){return this.currentBuiltInFeedback()?.pending===!0}finalizePendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.finalizePendingSubmit(submissionId):!1}revertPendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.revertPendingSubmit(submissionId):!1}currentBuiltInFeedback(){const base=this.renderRoot.querySelector('[part="base"]'),feedback=base?.querySelector('lr-message-feedback[part~="feedback"]');return feedback&&feedback.parentElement===base&&feedback.getRootNode()===this.renderRoot&&feedback.isConnected?feedback:void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.revealOnInteraction&&this.bindHoverTarget(),this.hasUpdated&&this.reconcileStopsAfterChildren()}disconnectedCallback(){this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops(),this.focusedStop=void 0,this.unbindHoverTarget(),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops()}willUpdate(changed){super.willUpdate(changed),changed.has("revealOnInteraction")&&(this.revealOnInteraction?this.bindHoverTarget():this.unbindHoverTarget());const overlayOpen=this.slottedOverlay.open;overlayOpen!==this.slottedOverlayWasOpen&&(this.slottedOverlayWasOpen=overlayOpen,overlayOpen?this.setRevealed(!0):!this.hoverTarget?.matches(":hover")&&!this.matches(":focus-within")&&this.setRevealed(!1))}firstUpdated(changed){super.firstUpdated(changed),this.setActiveStop(this.logicalActions(),0),this.reconcileStopsAfterChildren()}updated(changed){if(super.updated(changed),changed.has("controls")){const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()}}setRevealed(revealed){this.revealed!==revealed&&(this.revealed=revealed,this.toggleAttribute("data-revealed",revealed))}bindHoverTarget(){this.unbindHoverTarget();const target=this.closest("lr-chat-message")??this.parentElement;target&&(this.hoverTarget=target,target.addEventListener("pointerenter",this.onHoverTargetEnter),target.addEventListener("pointerleave",this.onHoverTargetLeave))}unbindHoverTarget(){this.hoverTarget?.removeEventListener("pointerenter",this.onHoverTargetEnter),this.hoverTarget?.removeEventListener("pointerleave",this.onHoverTargetLeave),this.hoverTarget=null,this.setRevealed(!1)}actionRoots(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return[];const direct=[...base.children].filter(element=>element.localName!=="slot"),slot=base.querySelector("slot");return[...direct,...slot?.assignedElements({flatten:!0})??[]]}sameAction(left,right){return left.owner===right.owner&&left.source===right.source&&left.action.id===right.action.id}isAvailable(action){try{return action.disabled!==!0}catch{return!1}}directActionFor(element){let action=this.directActions.get(element);if(action)return action;const target=element,id=`direct-${++this.nextDirectActionId}`;let leasedTarget,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const leased=leasedTarget;leased&&leased.getAttribute("tabindex")===lastManagedTabIndex&&(leasedAuthoredTabIndex===null?leased.removeAttribute("tabindex"):leased.setAttribute("tabindex",leasedAuthoredTabIndex)),leasedTarget=void 0,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return action={id,get disabled(){return!isComposedFocusAvailable(element)},focus(options){target.focus(options)},setTabIndex(tabIndex){if(leasedTarget!==target&&(releaseTabIndex(),leasedTarget=target,leasedAuthoredTabIndex=target.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&target.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}target.tabIndex=tabIndex,lastManagedTabIndex=target.getAttribute("tabindex")},releaseTabIndex,hasAuthoredTabIndex(){return leasedTarget!==target?target.hasAttribute("tabindex"):lastManagedTabIndex!==null&&target.getAttribute("tabindex")===lastManagedTabIndex?leasedAuthoredTabIndex!==null:target.hasAttribute("tabindex")},matchesEventPath(path){return path.includes(element)}},this.directActions.set(element,action),action}logicalActions(){const actions=[],addProvider=(owner,provider)=>{const getToolbarActions=dataCallable(provider,"getToolbarActions");if(!getToolbarActions)return;let provided;try{provided=Reflect.apply(getToolbarActions,provider,[])}catch{return}let isArray=!1;try{isArray=Array.isArray(provided)}catch{return}if(!isArray)return;const length=getOwnDataDescriptor(provided,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const seen=new Set,inspected=Math.min(length.value,MAX_TOOLBAR_ACTIONS);for(let index=0;index<inspected;index+=1){const candidate=getOwnDataDescriptor(provided,String(index));if(candidate===MISSING_OWN_DATA_DESCRIPTOR||candidate===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const projected=projectToolbarAction(candidate.value);!projected||seen.has(projected.action.id)||(seen.add(projected.action.id),this.isAvailable(projected.action)&&actions.push({owner,...projected}))}},visit=element=>{if(isLyraToolbarActionProvider(element)){addProvider(element,element);return}const knownAction=this.directActions.get(element);if(isSemanticActionElement(element)||(knownAction?.hasAuthoredTabIndex()??element.hasAttribute("tabindex"))){const action=this.directActionFor(element);this.isAvailable(action)&&actions.push({owner:element,action,source:action});return}for(const child of element.children)visit(child)};for(const root of this.actionRoots())visit(root);return actions}setActiveStop(stops,index,preferred){this.stopObserver?.disconnect();for(const previous of this.managedStops)stops.some(stop=>this.sameAction(stop,previous))||this.releaseManagedStop(previous);const preferredIndex=preferred?stops.findIndex(stop=>this.sameAction(stop,preferred)):-1;this.activeStopIndex=stops.length===0?0:preferredIndex>=0?preferredIndex:Math.min(Math.max(0,index),stops.length-1),stops.forEach(({action},stopIndex)=>{try{action.setTabIndex(stopIndex===this.activeStopIndex?0:-1)}catch{}}),this.managedStops=stops,this.observeStopChanges()}releaseManagedStop(stop){try{stop.action.releaseTabIndex?.()}catch{}this.directActions.get(stop.owner)===stop.action&&this.directActions.delete(stop.owner)}releaseManagedStops(){for(const stop of this.managedStops)this.releaseManagedStop(stop);this.managedStops=[]}observeStopChanges(){this.stopObserver?.disconnect();const Observer=this.ownerDocument.defaultView?.MutationObserver,base=this.renderRoot.querySelector('[part="base"]');if(!Observer||!base||!this.isConnected){this.stopObserver=void 0;return}const observer=new Observer(this.onStopMutations),roots=new Set([base,...this.actionRoots()]),options={attributes:!0,attributeOldValue:!0,attributeFilter:["aria-disabled","aria-hidden","contenteditable","controls","disabled","hidden","href","inert","open","role","tabindex","type"],childList:!0,subtree:!0};for(const root of roots)observer.observe(root,options);this.stopObserver=observer}async reconcileStopsAfterChildren(){const generation=++this.stopSyncGeneration,pending=this.actionRoots().map(root=>root.updateComplete).filter(value=>value!==void 0&&typeof value.then=="function");if(await Promise.all(pending),await Promise.resolve(),generation!==this.stopSyncGeneration||!this.isConnected)return;const stops=this.logicalActions(),focused=this.focusedStop,retainedIndex=focused?stops.findIndex(stop=>stop.owner===focused.owner&&stop.source===focused.source&&stop.action.id===focused.id):-1,targetIndex=retainedIndex>=0?retainedIndex:Math.min(focused?Math.max(0,focused.index):this.activeStopIndex,Math.max(0,stops.length-1));if(this.setActiveStop(stops,targetIndex),focused&&retainedIndex<0){const base=this.renderRoot.querySelector('[part="base"]');base&&applyComposedFocusRepair(focused.repair,base)&&stops[targetIndex]?.action.focus(),this.focusedStop===focused&&(this.focusedStop=void 0)}}renderControl(type){switch(type){case"copy":return this.copyText?html`<lr-copy-button
13
13
  part="copy-button"
14
14
  .value=${this.copyText}
15
15
  ></lr-copy-button>`:nothing;case"regenerate":return html`<lr-icon-button
@@ -2,9 +2,7 @@ import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';impo
2
2
  /** Native `<textarea wrap>` values accepted by the optional comment field. */
3
3
  export type MessageFeedbackWrap=LyraTextWrap;export interface MessageFeedbackSubmitDetail{rating:MessageFeedbackValue;reasonIds:string[];comment:string;
4
4
  /** Opaque, nonblank correlation identity for this one feedback persistence transaction. */
5
- readonly submissionId:string;}export interface LyraMessageFeedbackEventMap{
6
- /** @deprecated Use `lr-feedback-submit-request`. */
7
- 'lr-feedback-submit':LyraMessageFeedbackEventMap['lr-feedback-submit-request'];'lr-feedback-change':CustomEvent<{rating:MessageFeedbackValue;}>;'lr-feedback-submit-request':CustomEvent<LyraEventDetailSnapshot<MessageFeedbackSubmitDetail>>;'lr-toolbar-actions-change':Event;blur:CustomEvent<null>;focus:CustomEvent<null>;}
5
+ readonly submissionId:string;}export interface LyraMessageFeedbackEventMap{'lr-feedback-change':CustomEvent<{rating:MessageFeedbackValue;}>;'lr-feedback-submit-request':CustomEvent<LyraEventDetailSnapshot<MessageFeedbackSubmitDetail>>;'lr-toolbar-actions-change':Event;blur:CustomEvent<null>;focus:CustomEvent<null>;}
8
6
  /**
9
7
  * `<lr-message-feedback>` — thumbs up/down for one assistant message, with an optional inline
10
8
  * detail step (categorical reason chips + a free-text comment) that opens as a disclosure directly
@@ -27,7 +25,6 @@ readonly submissionId:string;}export interface LyraMessageFeedbackEventMap{
27
25
  * @customElement lr-message-feedback
28
26
  * @event lr-feedback-change - `detail: { rating }`. Fires whenever thumb interaction changes the
29
27
  * provisional rating, including clearing it to `null`.
30
- * @event lr-feedback-submit - Deprecated cancelable compatibility alias of `lr-feedback-submit-request`.
31
28
  * @event lr-feedback-submit-request - Frozen `detail: { rating, reasonIds, comment, submissionId }`, fired
32
29
  * immediately for a thumbs-only terminal choice or by the detail panel's submit button.
33
30
  * `submissionId` is a nonblank, never-reused transaction identity. Cancelable:
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/dev-mode-attribute-warning.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{composedContains}from"../../../internal/overlay-stack.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{autocorrectConverter,declaredDefaultConverter,normalizeAutocorrect,omittedEmptyStringConverter,trueDefaultSpellcheckConverter}from"../../../internal/converters.js";import{styles}from"./message-feedback.styles.js";import{LYRA_DEFAULT_feedbackCommentLabel,LYRA_DEFAULT_feedbackCommentPlaceholder,LYRA_DEFAULT_feedbackNegative,LYRA_DEFAULT_feedbackPositive,LYRA_DEFAULT_feedbackReasonsLabel,LYRA_DEFAULT_feedbackSubmit,LYRA_DEFAULT_feedbackSubmitted}from"../../../internal/default-strings.generated.js";function thumbIcon(direction,filled){return svg`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{composedContains}from"../../../internal/overlay-stack.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{autocorrectConverter,declaredDefaultConverter,normalizeAutocorrect,omittedEmptyStringConverter,trueDefaultSpellcheckConverter}from"../../../internal/converters.js";import{styles}from"./message-feedback.styles.js";import{LYRA_DEFAULT_feedbackCommentLabel,LYRA_DEFAULT_feedbackCommentPlaceholder,LYRA_DEFAULT_feedbackNegative,LYRA_DEFAULT_feedbackPositive,LYRA_DEFAULT_feedbackReasonsLabel,LYRA_DEFAULT_feedbackSubmit,LYRA_DEFAULT_feedbackSubmitted}from"../../../internal/default-strings.generated.js";function thumbIcon(direction,filled){return svg`
2
2
  <svg
3
3
  width="1em"
4
4
  height="1em"
@@ -11,7 +11,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
11
11
  aria-hidden="true"
12
12
  focusable="false"
13
13
  ><path d=${direction==="up"?"M7 11v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1h3Z":"M17 13V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v8h4Z"}></path><path d=${direction==="up"?"M7 11l3.5-7A2 2 0 0 1 12 3a1 1 0 0 1 1 1v6h4.5a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 16.3 21H9a2 2 0 0 1-2-2v-8Z":"M17 13l-3.5 7A2 2 0 0 1 12 21a1 1 0 0 1-1-1v-6H6.5a2 2 0 0 1-2-2.3l1.2-7A2 2 0 0 1 7.7 3H15a2 2 0 0 1 2 2v8Z"}></path></svg>
14
- `}const MAX_PROJECTED_FEEDBACK_REASONS=1e4,EMPTY_FEEDBACK_DETAIL_PROJECTION=Object.freeze({reasons:Object.freeze([]),commentable:!1});function isObjectValue(value){return value!==null&&(typeof value=="object"||typeof value=="function")}function isArrayValue(value){try{return Array.isArray(value)}catch{return!1}}function projectFeedbackDetail(detail){if(!isObjectValue(detail))return EMPTY_FEEDBACK_DETAIL_PROJECTION;const reasonsDescriptor=getOwnDataDescriptor(detail,"reasons"),commentableDescriptor=getOwnDataDescriptor(detail,"commentable"),commentable=commentableDescriptor!==MISSING_OWN_DATA_DESCRIPTOR&&commentableDescriptor!==UNSAFE_OWN_DATA_DESCRIPTOR&&commentableDescriptor.value===!0,reasonsValue=reasonsDescriptor!==MISSING_OWN_DATA_DESCRIPTOR&&reasonsDescriptor!==UNSAFE_OWN_DATA_DESCRIPTOR?reasonsDescriptor.value:void 0;if(!isArrayValue(reasonsValue))return commentable?Object.freeze({reasons:Object.freeze([]),commentable}):EMPTY_FEEDBACK_DETAIL_PROJECTION;const lengthDescriptor=getOwnDataDescriptor(reasonsValue,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return commentable?Object.freeze({reasons:Object.freeze([]),commentable}):EMPTY_FEEDBACK_DETAIL_PROJECTION;const reasons=[],seen=new Set,length=Math.min(lengthDescriptor.value,MAX_PROJECTED_FEEDBACK_REASONS);for(let index=0;index<length;index+=1){const rowDescriptor=getOwnDataDescriptor(reasonsValue,String(index));if(rowDescriptor===MISSING_OWN_DATA_DESCRIPTOR||rowDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!isObjectValue(rowDescriptor.value))continue;const row=rowDescriptor.value,idDescriptor=getOwnDataDescriptor(row,"id"),labelDescriptor=getOwnDataDescriptor(row,"label");if(idDescriptor===MISSING_OWN_DATA_DESCRIPTOR||idDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||labelDescriptor===MISSING_OWN_DATA_DESCRIPTOR||labelDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof idDescriptor.value!="string"||typeof labelDescriptor.value!="string")continue;const id=idDescriptor.value,label=labelDescriptor.value;id.trim().length===0||seen.has(id)||(seen.add(id),reasons.push(Object.freeze({id,label})))}return Object.freeze({reasons:Object.freeze(reasons),commentable})}class LyraMessageFeedback extends LyraElement{constructor(){super(...arguments),this.rating=null,this.detailFor="down",this.disabled=!1,this.pending=!1,this.spellcheck=!0,this.autocapitalize="",this.autocorrectValue=!0,this.wrap="soft",this.panelOpen=!1,this.selectedReasonIds=[],this.commentDraft="",this.detailProjectionSource=Symbol("unprojected-feedback-detail"),this.detailProjection=EMPTY_FEEDBACK_DETAIL_PROJECTION,this.submissionSequence=0,this.submissionCount=0,this.legacyNoArgumentSettlementInvalidated=!1,this.lifecycleGeneration=0,this.focusGeneration=0,this.settingPending=!1,this.panelId=nextId("message-feedback-panel"),this.upToolbarAction=this.createToolbarAction("up"),this.downToolbarAction=this.createToolbarAction("down"),this.onPanelKeyDown=e=>{e.key==="Escape"&&(e.stopPropagation(),this.closePanel())},this.stopChipAliasEvent=event=>{event.stopPropagation()},this.onCommentInput=e=>{this.commentDraft=e.target.value},this.onCommentFocus=()=>{this.emit("focus",null)},this.onCommentBlur=()=>{this.emit("blur",null)},this.submissionRequestDispatching=!1,this.onSubmit=()=>{if(this.disabled||this.pending||!this.rating||!this.panelOpen)return;const validReasonIds=new Set(this.detailReasons.map(reason=>reason.id));this.requestSubmission({rating:this.rating,reasonIds:this.selectedReasonIds.filter(id=>validReasonIds.has(id)),comment:this.detailCommentable?this.commentDraft.trim():""},this.rating,!0)}}static{this.defaultStrings={...super.defaultStrings,feedbackCommentLabel:LYRA_DEFAULT_feedbackCommentLabel,feedbackCommentPlaceholder:LYRA_DEFAULT_feedbackCommentPlaceholder,feedbackNegative:LYRA_DEFAULT_feedbackNegative,feedbackPositive:LYRA_DEFAULT_feedbackPositive,feedbackReasonsLabel:LYRA_DEFAULT_feedbackReasonsLabel,feedbackSubmit:LYRA_DEFAULT_feedbackSubmit,feedbackSubmitted:LYRA_DEFAULT_feedbackSubmitted}}emitFeedbackSubmitRequest(detail){const request=this.emit("lr-feedback-submit-request",Object.freeze(detail),{cancelable:!0});return this.emit("lr-feedback-submit",Object.freeze(detail),{cancelable:!0}).defaultPrevented&&(warnDeprecatedUsage(this,"event","lr-feedback-submit","lr-feedback-submit-request"),request.preventDefault()),request}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["detail"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-feedback-submit","lr-feedback-submit-request"])}get autocorrect(){return this.autocorrectValue}set autocorrect(next){const previous=this.autocorrectValue;this.autocorrectValue=normalizeAutocorrect(next),this.requestUpdate("autocorrect",previous)}createToolbarAction(direction){const host=this,button=()=>direction==="up"?host.upButtonEl:host.downButtonEl;let leasedButton,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const target=leasedButton;target&&target.getAttribute("tabindex")===lastManagedTabIndex&&(authoredTabIndex===null?target.removeAttribute("tabindex"):target.setAttribute("tabindex",authoredTabIndex)),leasedButton=void 0,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return{id:direction,get disabled(){return!button()||button().disabled},focus(options){button()?.focus(options)},setTabIndex(tabIndex){const target=button();if(!target){releaseTabIndex();return}if(leasedButton!==target&&(releaseTabIndex(),leasedButton=target,authoredTabIndex=target.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&target.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}target.tabIndex=tabIndex,lastManagedTabIndex=target.getAttribute("tabindex")},releaseTabIndex,matchesEventPath(path){const target=button();return target!==void 0&&path.includes(target)}}}getToolbarActions(){return[this.upToolbarAction,this.downToolbarAction]}focus(options){(this.rating==="down"?this.downButtonEl:this.upButtonEl)?.focus(options)}blur(){this.upButtonEl?.blur(),this.downButtonEl?.blur()}click(){this.disabled||this.pending||(this.rating==="down"?this.downButtonEl:this.upButtonEl)?.click()}get detailReasons(){return this.currentDetailProjection.reasons}get detailCommentable(){return this.currentDetailProjection.commentable}get currentDetailProjection(){const detail=this.detail;return detail!==this.detailProjectionSource&&(this.detailProjectionSource=detail,this.detailProjection=projectFeedbackDetail(detail)),this.detailProjection}get hasDetailContent(){return this.detailReasons.length>0||this.detailCommentable}detailApplies(direction){return this.detailFor==="both"||this.detailFor===direction}requestUpdate(name,oldValue,options){const currentValue=name==="rating"?this.rating:name==="detail"?this.detail:name==="detailFor"?this.detailFor:name==="pending"?this.pending:void 0,changed=oldValue!==currentValue,internalRatingWrite=name==="rating"&&this.pendingInternalRating?.rating===this.rating;changed&&(name==="rating"||name==="detail"||name==="detailFor"||name==="pending")&&!(name==="rating"&&internalRatingWrite)&&(this.focusGeneration=(this.focusGeneration??0)+1,this.pendingSubmission&&(name!=="pending"||!this.settingPending&&this.pending===!1)&&this.invalidatePendingSubmission()),super.requestUpdate(name,oldValue,options)}disconnectedCallback(){this.lifecycleGeneration+=1,this.invalidatePendingSubmission(),this.upToolbarAction.releaseTabIndex?.(),this.downToolbarAction.releaseTabIndex?.(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.lifecycleGeneration+=1,this.invalidatePendingSubmission(),this.upToolbarAction.releaseTabIndex?.(),this.downToolbarAction.releaseTabIndex?.()}willUpdate(changed){if(super.willUpdate(changed),changed.has("rating")){const internal=this.pendingInternalRating?.rating===this.rating;this.pendingInternalRating=void 0,internal||(this.invalidatePendingSubmission(),this.setPending(!1),this.panelOpen=!1,this.selectedReasonIds=[],this.commentDraft="")}if(changed.has("detail")){const validIds=new Set(this.detailReasons.map(reason=>reason.id));this.selectedReasonIds=this.selectedReasonIds.filter(id=>validIds.has(id)),this.detailCommentable||(this.commentDraft="")}this.panelOpen&&(!this.rating||!this.detailApplies(this.rating)||!this.hasDetailContent)&&(this.invalidatePendingSubmission(),this.setPending(!1),this.panelOpen=!1,changed.has("detailFor")&&(this.selectedReasonIds=[],this.commentDraft=""))}updated(changed){super.updated(changed),(changed.has("disabled")||changed.has("pending"))&&this.emit("lr-toolbar-actions-change")}setRatingFromInteraction(rating){this.pendingInternalRating={rating},this.rating=rating}activateThumb(next){if(this.disabled||this.pending)return;const previousRating=this.rating;if(this.rating===next){if(this.panelOpen){this.setRatingFromInteraction(null),this.panelOpen=!1,this.selectedReasonIds=[],this.commentDraft="",this.emit("lr-feedback-change",{rating:null}),this.requestSubmission({rating:null,reasonIds:[],comment:""},previousRating,!0);return}if(this.detailApplies(next)&&this.hasDetailContent){this.panelOpen=!0;return}this.setRatingFromInteraction(null),this.emit("lr-feedback-change",{rating:null}),this.requestSubmission({rating:null,reasonIds:[],comment:""},previousRating,!1);return}this.selectedReasonIds=[],this.commentDraft="",this.setRatingFromInteraction(next),this.panelOpen=this.detailApplies(next)&&this.hasDetailContent,this.emit("lr-feedback-change",{rating:next}),this.panelOpen||this.requestSubmission({rating:next,reasonIds:[],comment:""},previousRating,!1)}focusActiveThumb(){(this.rating==="down"?this.downButtonEl:this.upButtonEl)?.focus()}closePanel(){this.panelOpen&&(this.panelOpen=!1,this.focusActiveThumb())}toggleReason(id){this.disabled||this.pending||(this.selectedReasonIds=this.selectedReasonIds.includes(id)?this.selectedReasonIds.filter(r=>r!==id):[...this.selectedReasonIds,id])}setPending(pending){this.settingPending=!0,this.pending=pending,this.settingPending=!1}invalidatePendingSubmission(){const transaction=this.pendingSubmission;transaction&&(this.pendingSubmission=void 0,this.dispatchingSubmission===transaction&&(this.dispatchingSubmission=void 0),this.legacyNoArgumentSettlementInvalidated=!0,this.focusGeneration+=1,this.setPending(!1))}isCurrentPendingSubmission(transaction){return this.pendingSubmission===transaction&&this.pending&&this.isConnected&&transaction.lifecycleGeneration===this.lifecycleGeneration&&transaction.rating===this.rating&&transaction.detail===this.detail&&transaction.detailFor===this.detailFor?!0:(this.pendingSubmission===transaction&&this.invalidatePendingSubmission(),!1)}canSettleWithoutSubmissionId(transaction){return!this.legacyNoArgumentSettlementInvalidated&&this.submissionCount===1&&transaction.sequence===1}scheduleSettlementFocus(transaction,destination){const focusGeneration=++this.focusGeneration,lifecycleGeneration=transaction.lifecycleGeneration;this.ownsSettlementFocus()&&this.updateComplete.then(()=>{focusGeneration!==this.focusGeneration||lifecycleGeneration!==this.lifecycleGeneration||!this.isConnected||this.pending||this.pendingSubmission||!this.ownsSettlementFocus()||(destination==="submit"&&this.panelOpen?this.submitButtonEl?.focus():this.focusActiveThumb())})}ownsSettlementFocus(){const doc=this.ownerDocument,active=deepActiveElementIn(doc);return active===null||active===doc.body||active===doc.documentElement||composedContains(this,active)}settlePendingSubmission(settlement,submissionId){const transaction=this.pendingSubmission;if(!transaction||!this.isCurrentPendingSubmission(transaction))return!1;if(submissionId===void 0){if(!this.canSettleWithoutSubmissionId(transaction))return!1}else if(submissionId!==transaction.submissionId)return!1;return transaction.settlement?!1:this.dispatchingSubmission===transaction?(transaction.settlement=settlement,!0):(this.commitSettlement(transaction,settlement),!0)}commitSettlement(transaction,settlement){if(this.isCurrentPendingSubmission(transaction)){if(this.pendingSubmission=void 0,this.dispatchingSubmission===transaction&&(this.dispatchingSubmission=void 0),this.setPending(!1),settlement==="finalize"){this.panelOpen=!1,this.liveRegion?.announce(this.localize("feedbackSubmitted"),{force:!0}),this.scheduleSettlementFocus(transaction,"thumb");return}this.setRatingFromInteraction(transaction.previousRating),this.panelOpen=transaction.panelWasOpen,this.scheduleSettlementFocus(transaction,transaction.panelWasOpen?"submit":"thumb")}}finalizePendingSubmit(submissionId){return this.settlePendingSubmission("finalize",submissionId)}revertPendingSubmit(submissionId){return this.settlePendingSubmission("revert",submissionId)}requestSubmission(detail,previousRating,panelWasOpen){if(!this.submissionRequestDispatching){this.submissionRequestDispatching=!0;try{this.focusGeneration+=1;const sequence=++this.submissionSequence;this.submissionCount+=1;const transaction={submissionId:nextId("message-feedback-submission"),sequence,lifecycleGeneration:this.lifecycleGeneration,rating:this.rating,detail:this.detail,detailFor:this.detailFor,previousRating,panelWasOpen};this.pendingSubmission=transaction,this.setPending(!0),this.dispatchingSubmission=transaction;const event=this.emitFeedbackSubmitRequest({...detail,submissionId:transaction.submissionId});if(this.dispatchingSubmission===transaction&&(this.dispatchingSubmission=void 0),!this.isCurrentPendingSubmission(transaction))return;if(transaction.settlement){this.commitSettlement(transaction,transaction.settlement);return}event.defaultPrevented||this.commitSettlement(transaction,"finalize")}finally{this.submissionRequestDispatching=!1}}}renderThumb(direction){const pressed=this.rating===direction,canExpand=this.detailApplies(direction)&&this.hasDetailContent;return html`
14
+ `}const MAX_PROJECTED_FEEDBACK_REASONS=1e4,EMPTY_FEEDBACK_DETAIL_PROJECTION=Object.freeze({reasons:Object.freeze([]),commentable:!1});function isObjectValue(value){return value!==null&&(typeof value=="object"||typeof value=="function")}function isArrayValue(value){try{return Array.isArray(value)}catch{return!1}}function projectFeedbackDetail(detail){if(!isObjectValue(detail))return EMPTY_FEEDBACK_DETAIL_PROJECTION;const reasonsDescriptor=getOwnDataDescriptor(detail,"reasons"),commentableDescriptor=getOwnDataDescriptor(detail,"commentable"),commentable=commentableDescriptor!==MISSING_OWN_DATA_DESCRIPTOR&&commentableDescriptor!==UNSAFE_OWN_DATA_DESCRIPTOR&&commentableDescriptor.value===!0,reasonsValue=reasonsDescriptor!==MISSING_OWN_DATA_DESCRIPTOR&&reasonsDescriptor!==UNSAFE_OWN_DATA_DESCRIPTOR?reasonsDescriptor.value:void 0;if(!isArrayValue(reasonsValue))return commentable?Object.freeze({reasons:Object.freeze([]),commentable}):EMPTY_FEEDBACK_DETAIL_PROJECTION;const lengthDescriptor=getOwnDataDescriptor(reasonsValue,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return commentable?Object.freeze({reasons:Object.freeze([]),commentable}):EMPTY_FEEDBACK_DETAIL_PROJECTION;const reasons=[],seen=new Set,length=Math.min(lengthDescriptor.value,MAX_PROJECTED_FEEDBACK_REASONS);for(let index=0;index<length;index+=1){const rowDescriptor=getOwnDataDescriptor(reasonsValue,String(index));if(rowDescriptor===MISSING_OWN_DATA_DESCRIPTOR||rowDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!isObjectValue(rowDescriptor.value))continue;const row=rowDescriptor.value,idDescriptor=getOwnDataDescriptor(row,"id"),labelDescriptor=getOwnDataDescriptor(row,"label");if(idDescriptor===MISSING_OWN_DATA_DESCRIPTOR||idDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||labelDescriptor===MISSING_OWN_DATA_DESCRIPTOR||labelDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof idDescriptor.value!="string"||typeof labelDescriptor.value!="string")continue;const id=idDescriptor.value,label=labelDescriptor.value;id.trim().length===0||seen.has(id)||(seen.add(id),reasons.push(Object.freeze({id,label})))}return Object.freeze({reasons:Object.freeze(reasons),commentable})}class LyraMessageFeedback extends LyraElement{constructor(){super(...arguments),this.rating=null,this.detailFor="down",this.disabled=!1,this.pending=!1,this.spellcheck=!0,this.autocapitalize="",this.autocorrectValue=!0,this.wrap="soft",this.panelOpen=!1,this.selectedReasonIds=[],this.commentDraft="",this.detailProjectionSource=Symbol("unprojected-feedback-detail"),this.detailProjection=EMPTY_FEEDBACK_DETAIL_PROJECTION,this.submissionSequence=0,this.submissionCount=0,this.legacyNoArgumentSettlementInvalidated=!1,this.lifecycleGeneration=0,this.focusGeneration=0,this.settingPending=!1,this.panelId=nextId("message-feedback-panel"),this.upToolbarAction=this.createToolbarAction("up"),this.downToolbarAction=this.createToolbarAction("down"),this.onPanelKeyDown=e=>{e.key==="Escape"&&(e.stopPropagation(),this.closePanel())},this.stopChipAliasEvent=event=>{event.stopPropagation()},this.onCommentInput=e=>{this.commentDraft=e.target.value},this.onCommentFocus=()=>{this.emit("focus",null)},this.onCommentBlur=()=>{this.emit("blur",null)},this.submissionRequestDispatching=!1,this.onSubmit=()=>{if(this.disabled||this.pending||!this.rating||!this.panelOpen)return;const validReasonIds=new Set(this.detailReasons.map(reason=>reason.id));this.requestSubmission({rating:this.rating,reasonIds:this.selectedReasonIds.filter(id=>validReasonIds.has(id)),comment:this.detailCommentable?this.commentDraft.trim():""},this.rating,!0)}}static{this.defaultStrings={...super.defaultStrings,feedbackCommentLabel:LYRA_DEFAULT_feedbackCommentLabel,feedbackCommentPlaceholder:LYRA_DEFAULT_feedbackCommentPlaceholder,feedbackNegative:LYRA_DEFAULT_feedbackNegative,feedbackPositive:LYRA_DEFAULT_feedbackPositive,feedbackReasonsLabel:LYRA_DEFAULT_feedbackReasonsLabel,feedbackSubmit:LYRA_DEFAULT_feedbackSubmit,feedbackSubmitted:LYRA_DEFAULT_feedbackSubmitted}}emitFeedbackSubmitRequest(detail){return this.emit("lr-feedback-submit-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["detail"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-feedback-submit-request"])}get autocorrect(){return this.autocorrectValue}set autocorrect(next){const previous=this.autocorrectValue;this.autocorrectValue=normalizeAutocorrect(next),this.requestUpdate("autocorrect",previous)}createToolbarAction(direction){const host=this,button=()=>direction==="up"?host.upButtonEl:host.downButtonEl;let leasedButton,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const target=leasedButton;target&&target.getAttribute("tabindex")===lastManagedTabIndex&&(authoredTabIndex===null?target.removeAttribute("tabindex"):target.setAttribute("tabindex",authoredTabIndex)),leasedButton=void 0,authoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return{id:direction,get disabled(){return!button()||button().disabled},focus(options){button()?.focus(options)},setTabIndex(tabIndex){const target=button();if(!target){releaseTabIndex();return}if(leasedButton!==target&&(releaseTabIndex(),leasedButton=target,authoredTabIndex=target.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&target.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}target.tabIndex=tabIndex,lastManagedTabIndex=target.getAttribute("tabindex")},releaseTabIndex,matchesEventPath(path){const target=button();return target!==void 0&&path.includes(target)}}}getToolbarActions(){return[this.upToolbarAction,this.downToolbarAction]}focus(options){(this.rating==="down"?this.downButtonEl:this.upButtonEl)?.focus(options)}blur(){this.upButtonEl?.blur(),this.downButtonEl?.blur()}click(){this.disabled||this.pending||(this.rating==="down"?this.downButtonEl:this.upButtonEl)?.click()}get detailReasons(){return this.currentDetailProjection.reasons}get detailCommentable(){return this.currentDetailProjection.commentable}get currentDetailProjection(){const detail=this.detail;return detail!==this.detailProjectionSource&&(this.detailProjectionSource=detail,this.detailProjection=projectFeedbackDetail(detail)),this.detailProjection}get hasDetailContent(){return this.detailReasons.length>0||this.detailCommentable}detailApplies(direction){return this.detailFor==="both"||this.detailFor===direction}requestUpdate(name,oldValue,options){const currentValue=name==="rating"?this.rating:name==="detail"?this.detail:name==="detailFor"?this.detailFor:name==="pending"?this.pending:void 0,changed=oldValue!==currentValue,internalRatingWrite=name==="rating"&&this.pendingInternalRating?.rating===this.rating;changed&&(name==="rating"||name==="detail"||name==="detailFor"||name==="pending")&&!(name==="rating"&&internalRatingWrite)&&(this.focusGeneration=(this.focusGeneration??0)+1,this.pendingSubmission&&(name!=="pending"||!this.settingPending&&this.pending===!1)&&this.invalidatePendingSubmission()),super.requestUpdate(name,oldValue,options)}disconnectedCallback(){this.lifecycleGeneration+=1,this.invalidatePendingSubmission(),this.upToolbarAction.releaseTabIndex?.(),this.downToolbarAction.releaseTabIndex?.(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.lifecycleGeneration+=1,this.invalidatePendingSubmission(),this.upToolbarAction.releaseTabIndex?.(),this.downToolbarAction.releaseTabIndex?.()}willUpdate(changed){if(super.willUpdate(changed),changed.has("rating")){const internal=this.pendingInternalRating?.rating===this.rating;this.pendingInternalRating=void 0,internal||(this.invalidatePendingSubmission(),this.setPending(!1),this.panelOpen=!1,this.selectedReasonIds=[],this.commentDraft="")}if(changed.has("detail")){const validIds=new Set(this.detailReasons.map(reason=>reason.id));this.selectedReasonIds=this.selectedReasonIds.filter(id=>validIds.has(id)),this.detailCommentable||(this.commentDraft="")}this.panelOpen&&(!this.rating||!this.detailApplies(this.rating)||!this.hasDetailContent)&&(this.invalidatePendingSubmission(),this.setPending(!1),this.panelOpen=!1,changed.has("detailFor")&&(this.selectedReasonIds=[],this.commentDraft=""))}updated(changed){super.updated(changed),(changed.has("disabled")||changed.has("pending"))&&this.emit("lr-toolbar-actions-change")}setRatingFromInteraction(rating){this.pendingInternalRating={rating},this.rating=rating}activateThumb(next){if(this.disabled||this.pending)return;const previousRating=this.rating;if(this.rating===next){if(this.panelOpen){this.setRatingFromInteraction(null),this.panelOpen=!1,this.selectedReasonIds=[],this.commentDraft="",this.emit("lr-feedback-change",{rating:null}),this.requestSubmission({rating:null,reasonIds:[],comment:""},previousRating,!0);return}if(this.detailApplies(next)&&this.hasDetailContent){this.panelOpen=!0;return}this.setRatingFromInteraction(null),this.emit("lr-feedback-change",{rating:null}),this.requestSubmission({rating:null,reasonIds:[],comment:""},previousRating,!1);return}this.selectedReasonIds=[],this.commentDraft="",this.setRatingFromInteraction(next),this.panelOpen=this.detailApplies(next)&&this.hasDetailContent,this.emit("lr-feedback-change",{rating:next}),this.panelOpen||this.requestSubmission({rating:next,reasonIds:[],comment:""},previousRating,!1)}focusActiveThumb(){(this.rating==="down"?this.downButtonEl:this.upButtonEl)?.focus()}closePanel(){this.panelOpen&&(this.panelOpen=!1,this.focusActiveThumb())}toggleReason(id){this.disabled||this.pending||(this.selectedReasonIds=this.selectedReasonIds.includes(id)?this.selectedReasonIds.filter(r=>r!==id):[...this.selectedReasonIds,id])}setPending(pending){this.settingPending=!0,this.pending=pending,this.settingPending=!1}invalidatePendingSubmission(){const transaction=this.pendingSubmission;transaction&&(this.pendingSubmission=void 0,this.dispatchingSubmission===transaction&&(this.dispatchingSubmission=void 0),this.legacyNoArgumentSettlementInvalidated=!0,this.focusGeneration+=1,this.setPending(!1))}isCurrentPendingSubmission(transaction){return this.pendingSubmission===transaction&&this.pending&&this.isConnected&&transaction.lifecycleGeneration===this.lifecycleGeneration&&transaction.rating===this.rating&&transaction.detail===this.detail&&transaction.detailFor===this.detailFor?!0:(this.pendingSubmission===transaction&&this.invalidatePendingSubmission(),!1)}canSettleWithoutSubmissionId(transaction){return!this.legacyNoArgumentSettlementInvalidated&&this.submissionCount===1&&transaction.sequence===1}scheduleSettlementFocus(transaction,destination){const focusGeneration=++this.focusGeneration,lifecycleGeneration=transaction.lifecycleGeneration;this.ownsSettlementFocus()&&this.updateComplete.then(()=>{focusGeneration!==this.focusGeneration||lifecycleGeneration!==this.lifecycleGeneration||!this.isConnected||this.pending||this.pendingSubmission||!this.ownsSettlementFocus()||(destination==="submit"&&this.panelOpen?this.submitButtonEl?.focus():this.focusActiveThumb())})}ownsSettlementFocus(){const doc=this.ownerDocument,active=deepActiveElementIn(doc);return active===null||active===doc.body||active===doc.documentElement||composedContains(this,active)}settlePendingSubmission(settlement,submissionId){const transaction=this.pendingSubmission;if(!transaction||!this.isCurrentPendingSubmission(transaction))return!1;if(submissionId===void 0){if(!this.canSettleWithoutSubmissionId(transaction))return!1}else if(submissionId!==transaction.submissionId)return!1;return transaction.settlement?!1:this.dispatchingSubmission===transaction?(transaction.settlement=settlement,!0):(this.commitSettlement(transaction,settlement),!0)}commitSettlement(transaction,settlement){if(this.isCurrentPendingSubmission(transaction)){if(this.pendingSubmission=void 0,this.dispatchingSubmission===transaction&&(this.dispatchingSubmission=void 0),this.setPending(!1),settlement==="finalize"){this.panelOpen=!1,this.liveRegion?.announce(this.localize("feedbackSubmitted"),{force:!0}),this.scheduleSettlementFocus(transaction,"thumb");return}this.setRatingFromInteraction(transaction.previousRating),this.panelOpen=transaction.panelWasOpen,this.scheduleSettlementFocus(transaction,transaction.panelWasOpen?"submit":"thumb")}}finalizePendingSubmit(submissionId){return this.settlePendingSubmission("finalize",submissionId)}revertPendingSubmit(submissionId){return this.settlePendingSubmission("revert",submissionId)}requestSubmission(detail,previousRating,panelWasOpen){if(!this.submissionRequestDispatching){this.submissionRequestDispatching=!0;try{this.focusGeneration+=1;const sequence=++this.submissionSequence;this.submissionCount+=1;const transaction={submissionId:nextId("message-feedback-submission"),sequence,lifecycleGeneration:this.lifecycleGeneration,rating:this.rating,detail:this.detail,detailFor:this.detailFor,previousRating,panelWasOpen};this.pendingSubmission=transaction,this.setPending(!0),this.dispatchingSubmission=transaction;const event=this.emitFeedbackSubmitRequest({...detail,submissionId:transaction.submissionId});if(this.dispatchingSubmission===transaction&&(this.dispatchingSubmission=void 0),!this.isCurrentPendingSubmission(transaction))return;if(transaction.settlement){this.commitSettlement(transaction,transaction.settlement);return}event.defaultPrevented||this.commitSettlement(transaction,"finalize")}finally{this.submissionRequestDispatching=!1}}}renderThumb(direction){const pressed=this.rating===direction,canExpand=this.detailApplies(direction)&&this.hasDetailContent;return html`
15
15
  <button
16
16
  part=${direction==="up"?"up-button":"down-button"}
17
17
  type="button"
@@ -64,6 +64,7 @@ export type MessagePartsToolDisplay='chip'|'block';export interface LyraMessageP
64
64
  * so that nested code direction cannot be overridden with `::part()` from outside.
65
65
  *
66
66
  * @customElement lr-message-parts
67
+ * @attr {string | null} aria-label - Accessible name for the internal message-part group.
67
68
  * @event lr-citation-select - A citation part was activated. `detail: { citation }`.
68
69
  * @event lr-part-resume - Requests host-managed resume of an interrupted, resumable part. `detail: { part }`.
69
70
  * @event lr-part-retry - Retry was requested for a retryable error part. `detail: { part }`.
@@ -73,7 +74,6 @@ export type MessagePartsToolDisplay='chip'|'block';export interface LyraMessageP
73
74
  * @event lr-render-error - Passthrough from rendered Markdown, tool-result, or widget content, or
74
75
  * tool-call block (`callId` included).
75
76
  * @event lr-link-activate - Passthrough from rendered Markdown.
76
- * @event lr-link-click - Deprecated compatibility alias of `lr-link-activate`.
77
77
  * @event lr-highlight-activate - Passthrough from rendered Markdown.
78
78
  * @event lr-text-select - Passthrough from rendered Markdown.
79
79
  * @event lr-anchor-result - Passthrough from rendered Markdown.
@@ -146,10 +146,7 @@ codeBlockHeader:boolean;
146
146
  * even once an earlier citation rolls out of the rendered window. Opt in for a message that can
147
147
  * grow an unusually large number of parts (e.g. a long agentic run with many interleaved
148
148
  * tool-call/tool-result parts), where unbounded live DOM can visibly stall the main thread. */
149
- maxRenderedParts:number;
150
- /** Accessible name override for the internal message-part group.
151
- * @deprecated Use the host's native `aria-label` attribute. */
152
- get accessibleLabel():string|null;set accessibleLabel(value:string|null);private _accessibleLabel;private knownErrorIds;
149
+ maxRenderedParts:number;private knownErrorIds;
153
150
  /** First tool-call's projected `redactedFields` per invocation id; only non-empty entries. */
154
151
  private redactionByInvocation;private redactionMemo;private errorAnnouncementSink?;private suppressNextErrorAnnouncement;connectedCallback():void;disconnectedCallback():void;private get effectiveParts();
155
152
  /** `maxRenderedParts`, normalized to a finite non-negative integer (falling back to the
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/dev-mode-attribute-warning.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{isToolCallStatus}from"../../agent-tools/tool-status.js";import{projectedRedactionFields,redactToolDetail,TOO_MANY_REDACTION_PATHS}from"../../agent-tools/tool-redaction.js";import{literalSetConverter}from"../../../internal/converters.js";import{finiteCount}from"../../../internal/numbers.js";import{LyraElement}from"../../../internal/lyra-element.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{isNonBlankIdentity,isRecord}from"../../retrieval/retrieval-identity.js";import{styles}from"./message-parts.styles.js";import{LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_messagePartError,LYRA_DEFAULT_messagePartRetry,LYRA_DEFAULT_messagePartsLabel,LYRA_DEFAULT_retry,LYRA_DEFAULT_streamInterrupted,LYRA_DEFAULT_streamResume,LYRA_DEFAULT_thinkingPanelLabel}from"../../../internal/default-strings.generated.js";const MESSAGE_PARTS_CONTENT_MODES=Object.freeze(["plain","markdown"]),MESSAGE_PARTS_TOOL_DISPLAY=literalSetConverter(["chip","block"],"chip"),EMPTY_REDACTED_FIELDS=Object.freeze([]),TOOL_BLOCK_EXPORTPARTS="header:tool-block-header, body:tool-block-body, args:tool-block-args, result:tool-block-result, error:tool-block-error";function resolveBlockStatus(invocation,result){const status=isToolCallStatus(invocation.status)?invocation.status:"pending";return status==="denied"||status==="incomplete"?status:status==="error"||result&&"error"in result?"error":result&&result.state==="streaming"?"running":result?"success":status}function invocationDuration(invocation){if(invocation.startedAt==null||invocation.endedAt==null)return;const diff=invocation.endedAt-invocation.startedAt;return Number.isFinite(diff)?diff:void 0}function invocationDisplayName(invocation){return typeof invocation.displayName=="string"?invocation.displayName:void 0}function normalizeMessagePartsContentMode(value){return typeof value=="string"&&MESSAGE_PARTS_CONTENT_MODES.includes(value)?value:"markdown"}class LyraMessageParts extends LyraElement{constructor(){super(...arguments),this.parts=[],this.disabled=!1,this.contentModeValue="markdown",this.toolDisplayValue="chip",this.withoutReasoning=!1,this.streamingRender="plain",this.codeBlockHeader=!1,this.maxRenderedParts=0,this._accessibleLabel=null,this.knownErrorIds=new Set,this.redactionByInvocation=new Map,this.redactionMemo=new WeakMap,this.suppressNextErrorAnnouncement=!0,this.resumeDispatching=!1}static{this.defaultStrings={...super.defaultStrings,envListValueHidden:LYRA_DEFAULT_envListValueHidden,messagePartError:LYRA_DEFAULT_messagePartError,messagePartRetry:LYRA_DEFAULT_messagePartRetry,messagePartsLabel:LYRA_DEFAULT_messagePartsLabel,retry:LYRA_DEFAULT_retry,streamInterrupted:LYRA_DEFAULT_streamInterrupted,streamResume:LYRA_DEFAULT_streamResume,thinkingPanelLabel:LYRA_DEFAULT_thinkingPanelLabel}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["parts"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-citation-select","lr-part-retry","lr-part-resume"])}get contentMode(){return this.contentModeValue}set contentMode(value){const previous=this.contentModeValue,normalized=normalizeMessagePartsContentMode(value);this.contentModeValue=normalized,typeof value=="string"&&value!==normalized&&this.getAttribute("content-mode")!==normalized&&this.setAttribute("content-mode",normalized),this.requestUpdate("contentMode",previous,{reflect:!0,hasChanged:()=>!0})}get toolDisplay(){return this.toolDisplayValue}set toolDisplay(value){const normalized=MESSAGE_PARTS_TOOL_DISPLAY.normalizeReflected(this,"tool-display",value),previous=this.toolDisplayValue;previous!==normalized&&(this.toolDisplayValue=normalized,this.requestUpdate("toolDisplay",previous))}get accessibleLabel(){return this._accessibleLabel}set accessibleLabel(value){value!==null&&!this.hasAttribute("aria-label")&&warnDeprecatedUsage(this,"property","accessibleLabel","ariaLabel");const previous=this._accessibleLabel;this._accessibleLabel=value,this.requestUpdate("accessibleLabel",previous)}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.hasUpdated&&(this.suppressNextErrorAnnouncement=!0,this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}get effectiveParts(){const seen=new Set;return this.parts.filter(part=>{const id=part?.id;return!isNonBlankIdentity(id)||seen.has(id)||part.type==="tool-call"&&!isRecord(part.invocation)||part.type==="citation"&&!isRecord(part.citation)||part.type==="attachment"&&!isRecord(part.document)?!1:(seen.add(id),!0)})}get effectiveMaxRenderedParts(){return finiteCount(this.maxRenderedParts,0)}get renderedParts(){const parts=this.effectiveParts,max=this.effectiveMaxRenderedParts;return max>0&&parts.length>max?parts.slice(-max):parts}willUpdate(changed){if(super.willUpdate(changed),!changed.has("parts")&&this.hasUpdated||(this.redactionByInvocation=this.projectRedactions(),!changed.has("parts")))return;const current=this.effectiveParts.filter(part=>part.type==="error");if(this.hasUpdated&&!this.suppressNextErrorAnnouncement)for(const part of current)this.knownErrorIds.has(part.id)||this.errorAnnouncementSink?.announce(part.message||this.localize("messagePartError"));this.knownErrorIds=new Set(current.map(part=>part.id))}projectRedactions(){const map=new Map,seen=new Set;for(const part of this.effectiveParts){if(part.type!=="tool-call")continue;const id=part.invocation.id;if(typeof id!="string"||seen.has(id))continue;seen.add(id);const paths=projectedRedactionFields(part.invocation.redactedFields)??TOO_MANY_REDACTION_PATHS;paths.length>0&&map.set(id,paths)}return map}redacted(part,invocationId,source){if(typeof invocationId!="string")return;const paths=this.redactionByInvocation.get(invocationId);if(!paths)return;const detail=redactToolDetail(source,paths,this.localize("envListValueHidden"),this.redactionMemo.get(part));return this.redactionMemo.set(part,detail),detail}updated(_changed){super.updated(_changed),this.suppressNextErrorAnnouncement=!1}selectCitation(event,part){event.stopPropagation(),this.emit("lr-citation-select",{citation:part.citation})}partNames(part){const parts=["part"];switch(part.type){case"text":parts.push("text");break;case"reasoning":parts.push("reasoning");break;case"tool-call":parts.push("tool-call");break;case"tool-result":parts.push("tool-result");break;case"citation":parts.push("citation");break;case"attachment":parts.push("attachment");break;case"data":parts.push("data");break;case"audio":parts.push("audio");break;case"error":parts.push("error");break}return part.state==="streaming"&&parts.push("part-streaming"),part.state==="interrupted"&&parts.push("part-interrupted"),parts.join(" ")}renderToolBlock(part,paired){const invocation=part.invocation,result=paired?paired.result:invocation.result,error=paired&&"error"in paired?paired.error:invocation.error,redactedFields=this.redactionByInvocation.get(invocation.id)??EMPTY_REDACTED_FIELDS;return html`<lr-tool-call-block
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{isToolCallStatus}from"../../agent-tools/tool-status.js";import{projectedRedactionFields,redactToolDetail,TOO_MANY_REDACTION_PATHS}from"../../agent-tools/tool-redaction.js";import{literalSetConverter}from"../../../internal/converters.js";import{finiteCount}from"../../../internal/numbers.js";import{LyraElement}from"../../../internal/lyra-element.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{isNonBlankIdentity,isRecord}from"../../retrieval/retrieval-identity.js";import{styles}from"./message-parts.styles.js";import{LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_messagePartError,LYRA_DEFAULT_messagePartRetry,LYRA_DEFAULT_messagePartsLabel,LYRA_DEFAULT_retry,LYRA_DEFAULT_streamInterrupted,LYRA_DEFAULT_streamResume,LYRA_DEFAULT_thinkingPanelLabel}from"../../../internal/default-strings.generated.js";const MESSAGE_PARTS_CONTENT_MODES=Object.freeze(["plain","markdown"]),MESSAGE_PARTS_TOOL_DISPLAY=literalSetConverter(["chip","block"],"chip"),EMPTY_REDACTED_FIELDS=Object.freeze([]),TOOL_BLOCK_EXPORTPARTS="header:tool-block-header, body:tool-block-body, args:tool-block-args, result:tool-block-result, error:tool-block-error";function resolveBlockStatus(invocation,result){const status=isToolCallStatus(invocation.status)?invocation.status:"pending";return status==="denied"||status==="incomplete"?status:status==="error"||result&&"error"in result?"error":result&&result.state==="streaming"?"running":result?"success":status}function invocationDuration(invocation){if(invocation.startedAt==null||invocation.endedAt==null)return;const diff=invocation.endedAt-invocation.startedAt;return Number.isFinite(diff)?diff:void 0}function invocationDisplayName(invocation){return typeof invocation.displayName=="string"?invocation.displayName:void 0}function normalizeMessagePartsContentMode(value){return typeof value=="string"&&MESSAGE_PARTS_CONTENT_MODES.includes(value)?value:"markdown"}class LyraMessageParts extends LyraElement{constructor(){super(...arguments),this.parts=[],this.disabled=!1,this.contentModeValue="markdown",this.toolDisplayValue="chip",this.withoutReasoning=!1,this.streamingRender="plain",this.codeBlockHeader=!1,this.maxRenderedParts=0,this.knownErrorIds=new Set,this.redactionByInvocation=new Map,this.redactionMemo=new WeakMap,this.suppressNextErrorAnnouncement=!0,this.resumeDispatching=!1}static{this.defaultStrings={...super.defaultStrings,envListValueHidden:LYRA_DEFAULT_envListValueHidden,messagePartError:LYRA_DEFAULT_messagePartError,messagePartRetry:LYRA_DEFAULT_messagePartRetry,messagePartsLabel:LYRA_DEFAULT_messagePartsLabel,retry:LYRA_DEFAULT_retry,streamInterrupted:LYRA_DEFAULT_streamInterrupted,streamResume:LYRA_DEFAULT_streamResume,thinkingPanelLabel:LYRA_DEFAULT_thinkingPanelLabel}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["parts"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-citation-select","lr-part-retry","lr-part-resume"])}get contentMode(){return this.contentModeValue}set contentMode(value){const previous=this.contentModeValue,normalized=normalizeMessagePartsContentMode(value);this.contentModeValue=normalized,typeof value=="string"&&value!==normalized&&this.getAttribute("content-mode")!==normalized&&this.setAttribute("content-mode",normalized),this.requestUpdate("contentMode",previous,{reflect:!0,hasChanged:()=>!0})}get toolDisplay(){return this.toolDisplayValue}set toolDisplay(value){const normalized=MESSAGE_PARTS_TOOL_DISPLAY.normalizeReflected(this,"tool-display",value),previous=this.toolDisplayValue;previous!==normalized&&(this.toolDisplayValue=normalized,this.requestUpdate("toolDisplay",previous))}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.hasUpdated&&(this.suppressNextErrorAnnouncement=!0,this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}get effectiveParts(){const seen=new Set;return this.parts.filter(part=>{const id=part?.id;return!isNonBlankIdentity(id)||seen.has(id)||part.type==="tool-call"&&!isRecord(part.invocation)||part.type==="citation"&&!isRecord(part.citation)||part.type==="attachment"&&!isRecord(part.document)?!1:(seen.add(id),!0)})}get effectiveMaxRenderedParts(){return finiteCount(this.maxRenderedParts,0)}get renderedParts(){const parts=this.effectiveParts,max=this.effectiveMaxRenderedParts;return max>0&&parts.length>max?parts.slice(-max):parts}willUpdate(changed){if(super.willUpdate(changed),!changed.has("parts")&&this.hasUpdated||(this.redactionByInvocation=this.projectRedactions(),!changed.has("parts")))return;const current=this.effectiveParts.filter(part=>part.type==="error");if(this.hasUpdated&&!this.suppressNextErrorAnnouncement)for(const part of current)this.knownErrorIds.has(part.id)||this.errorAnnouncementSink?.announce(part.message||this.localize("messagePartError"));this.knownErrorIds=new Set(current.map(part=>part.id))}projectRedactions(){const map=new Map,seen=new Set;for(const part of this.effectiveParts){if(part.type!=="tool-call")continue;const id=part.invocation.id;if(typeof id!="string"||seen.has(id))continue;seen.add(id);const paths=projectedRedactionFields(part.invocation.redactedFields)??TOO_MANY_REDACTION_PATHS;paths.length>0&&map.set(id,paths)}return map}redacted(part,invocationId,source){if(typeof invocationId!="string")return;const paths=this.redactionByInvocation.get(invocationId);if(!paths)return;const detail=redactToolDetail(source,paths,this.localize("envListValueHidden"),this.redactionMemo.get(part));return this.redactionMemo.set(part,detail),detail}updated(_changed){super.updated(_changed),this.suppressNextErrorAnnouncement=!1}selectCitation(event,part){event.stopPropagation(),this.emit("lr-citation-select",{citation:part.citation})}partNames(part){const parts=["part"];switch(part.type){case"text":parts.push("text");break;case"reasoning":parts.push("reasoning");break;case"tool-call":parts.push("tool-call");break;case"tool-result":parts.push("tool-result");break;case"citation":parts.push("citation");break;case"attachment":parts.push("attachment");break;case"data":parts.push("data");break;case"audio":parts.push("audio");break;case"error":parts.push("error");break}return part.state==="streaming"&&parts.push("part-streaming"),part.state==="interrupted"&&parts.push("part-interrupted"),parts.join(" ")}renderToolBlock(part,paired){const invocation=part.invocation,result=paired?paired.result:invocation.result,error=paired&&"error"in paired?paired.error:invocation.error,redactedFields=this.redactionByInvocation.get(invocation.id)??EMPTY_REDACTED_FIELDS;return html`<lr-tool-call-block
2
2
  .name=${invocation.name}
3
3
  .displayName=${invocationDisplayName(invocation)}
4
4
  .callId=${invocation.id}
@@ -59,6 +59,6 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
59
59
  >${this.localize("retry")}</lr-button
60
60
  >`:nothing}`}}requestResume(part){const current=this.renderedParts.find(candidate=>candidate.id===part.id);if(!(this.resumeDispatching||this.disabled||current!==part||part.state!=="interrupted"||part.interruption?.resumable!==!0)){this.resumeDispatching=!0;try{this.emit("lr-part-resume",{part})}finally{this.resumeDispatching=!1}}}renderInterruption(part){return part.state!=="interrupted"?nothing:html`<div part="interruption"><span>${this.localize("streamInterrupted")}</span>${part.interruption?.reason?html`<span>${part.interruption.reason}</span>`:nothing}${part.interruption?.resumable===!0?html`<button part="resume" type="button" ?disabled=${this.disabled}
61
61
  @click=${()=>this.requestResume(part)}>${this.localize("streamResume")}</button>`:nothing}</div>`}renderOne(part,citationRank,custom,pairing){return part.type==="reasoning"&&this.withoutReasoning?nothing:pairing?.folded.has(part.id)?nothing:html`<div part=${this.partNames(part)} data-type=${part.type} data-state=${part.state??"complete"}
62
- >${custom.has(part.id)?custom.get(part.id):html`${this.renderBuiltin(part,citationRank,pairing)}${this.renderInterruption(part)}`}</div>`}render(){const label=this.getAttribute("aria-label")??this.accessibleLabel??this.localize("messagePartsLabel"),allParts=this.effectiveParts,citationRanks=new Map;let citationRank=0;for(const part of allParts)part.type==="citation"&&citationRanks.set(part.id,++citationRank);const parts=this.renderedParts,custom=new Map;this.renderPart&&parts.forEach((part,index)=>{if(part.type==="reasoning"&&this.withoutReasoning)return;const rendered=this.renderPart?.(part,index);rendered!==void 0&&custom.set(part.id,rendered)});const pairing=this.toolDisplay==="block"?this.pairTools(parts,custom):void 0;return html`<div part="base" role="group" aria-label=${label}>
62
+ >${custom.has(part.id)?custom.get(part.id):html`${this.renderBuiltin(part,citationRank,pairing)}${this.renderInterruption(part)}`}</div>`}render(){const label=this.getAttribute("aria-label")??this.localize("messagePartsLabel"),allParts=this.effectiveParts,citationRanks=new Map;let citationRank=0;for(const part of allParts)part.type==="citation"&&citationRanks.set(part.id,++citationRank);const parts=this.renderedParts,custom=new Map;this.renderPart&&parts.forEach((part,index)=>{if(part.type==="reasoning"&&this.withoutReasoning)return;const rendered=this.renderPart?.(part,index);rendered!==void 0&&custom.set(part.id,rendered)});const pairing=this.toolDisplay==="block"?this.pairTools(parts,custom):void 0;return html`<div part="base" role="group" aria-label=${label}>
63
63
  ${repeat(parts,part=>part.id,part=>this.renderOne(part,citationRanks.get(part.id)??0,custom,pairing))}
64
- </div>`}}__decorate([property({attribute:!1})],LyraMessageParts.prototype,"parts",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraMessageParts.prototype,"disabled",void 0),__decorate([property({reflect:!0,attribute:"content-mode"})],LyraMessageParts.prototype,"contentMode",null),__decorate([property({reflect:!0,attribute:"tool-display",converter:MESSAGE_PARTS_TOOL_DISPLAY})],LyraMessageParts.prototype,"toolDisplay",null),__decorate([property({type:Boolean,attribute:"without-reasoning",reflect:!0})],LyraMessageParts.prototype,"withoutReasoning",void 0),__decorate([property({attribute:!1})],LyraMessageParts.prototype,"renderPart",void 0),__decorate([property({attribute:"streaming-render"})],LyraMessageParts.prototype,"streamingRender",void 0),__decorate([property({type:Boolean,attribute:"code-block-header"})],LyraMessageParts.prototype,"codeBlockHeader",void 0),__decorate([property({type:Number,attribute:"max-rendered-parts"})],LyraMessageParts.prototype,"maxRenderedParts",void 0),__decorate([property({attribute:"aria-label"})],LyraMessageParts.prototype,"accessibleLabel",null);export{LyraMessageParts};
64
+ </div>`}}__decorate([property({attribute:!1})],LyraMessageParts.prototype,"parts",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraMessageParts.prototype,"disabled",void 0),__decorate([property({reflect:!0,attribute:"content-mode"})],LyraMessageParts.prototype,"contentMode",null),__decorate([property({reflect:!0,attribute:"tool-display",converter:MESSAGE_PARTS_TOOL_DISPLAY})],LyraMessageParts.prototype,"toolDisplay",null),__decorate([property({type:Boolean,attribute:"without-reasoning",reflect:!0})],LyraMessageParts.prototype,"withoutReasoning",void 0),__decorate([property({attribute:!1})],LyraMessageParts.prototype,"renderPart",void 0),__decorate([property({attribute:"streaming-render"})],LyraMessageParts.prototype,"streamingRender",void 0),__decorate([property({type:Boolean,attribute:"code-block-header"})],LyraMessageParts.prototype,"codeBlockHeader",void 0),__decorate([property({type:Number,attribute:"max-rendered-parts"})],LyraMessageParts.prototype,"maxRenderedParts",void 0);export{LyraMessageParts};
@@ -2,7 +2,7 @@ import type{LyraClipboardWriteSuccess,LyraClipboardWriteFailure}from'../../../in
2
2
  /** Runs {@link APPEND_MONOTONIC_MARKDOWN_PATTERNS}/{@link BOUNDARY_SENSITIVE_MARKDOWN_PATTERNS}
3
3
  * against `text`, used whenever `contentMode` is left unset (auto-detect). Exported so the
4
4
  * heuristic is directly testable without going through either variant's render cycle. */
5
- export declare function looksLikeMarkdown(text:string):boolean;export type StreamingTextContentMode='auto'|'plain'|'markdown';export interface LyraStreamingTextEventMap{'lr-content-settled':CustomEvent<null>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;}
5
+ export declare function looksLikeMarkdown(text:string):boolean;export type StreamingTextContentMode='auto'|'plain'|'markdown';export interface LyraStreamingTextEventMap{'lr-content-settled':CustomEvent<null>;'lr-link-activate':CustomEvent<{href:string;}>;'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;}
6
6
  /**
7
7
  * Shared runtime for `<lr-streaming-text>`/`<lr-streaming-text-core>` -- token coalescing,
8
8
  * `contentMode` auto-detection, and the blinking cursor -- factored out so neither variant
@@ -25,6 +25,8 @@ export interface LyraStreamingTextCoreEventMap extends StreamingTextRuntimeEvent
25
25
  * @customElement lr-streaming-text-core
26
26
  * @event lr-content-settled - Fired after newly-coalesced content actually reaches the rendered
27
27
  * DOM (plain-text mode only -- see `<lr-streaming-text>`'s class doc). `detail: null`.
28
+ * @event lr-link-activate - Passthrough from composed Markdown when a rendered link matches
29
+ * `internal-link-prefix`; navigation is prevented and `detail: { href }` carries the raw URL.
28
30
  * @csspart base - The root container.
29
31
  * @csspart cursor - The blinking (or, under reduced motion, static) cursor bar. Only rendered while `streaming` is `true`.
30
32
  * @csspart content - Forwarded from the composed `<lr-markdown-core>` in Markdown mode -- the
@@ -16,7 +16,6 @@ import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/dec
16
16
  .math=${this.math}
17
17
  .maxHeight=${this.maxHeight}
18
18
  @lr-render-error=${this.stopOwnedEvent}
19
- @lr-link-click=${this.stopOwnedEvent}
20
19
  @lr-highlight-activate=${this.stopOwnedEvent}
21
20
  @lr-text-select=${this.stopOwnedEvent}
22
21
  @lr-anchor-result=${this.stopOwnedEvent}
@@ -92,6 +92,8 @@ import{type TemplateResult}from'lit';import{StreamingTextRuntimeBase}from'./stre
92
92
  * @customElement lr-streaming-text
93
93
  * @event lr-content-settled - Fired after newly-coalesced content actually reaches the rendered
94
94
  * DOM (plain-text mode only -- see the class doc). `detail: null`.
95
+ * @event lr-link-activate - Passthrough from composed Markdown when a rendered link matches
96
+ * `internal-link-prefix`; navigation is prevented and `detail: { href }` carries the raw URL.
95
97
  * @csspart base - The root container.
96
98
  * @csspart cursor - The blinking (or, under reduced motion, static) cursor bar. Only rendered while `streaming` is `true`.
97
99
  * @csspart content - Forwarded from the composed `<lr-markdown>` in Markdown mode -- the wrapper
@@ -16,7 +16,6 @@ import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/dec
16
16
  .math=${this.math}
17
17
  .maxHeight=${this.maxHeight}
18
18
  @lr-render-error=${this.stopOwnedEvent}
19
- @lr-link-click=${this.stopOwnedEvent}
20
19
  @lr-highlight-activate=${this.stopOwnedEvent}
21
20
  @lr-text-select=${this.stopOwnedEvent}
22
21
  @lr-anchor-result=${this.stopOwnedEvent}
@@ -1,19 +1,14 @@
1
- import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraDeprecatedAliases}from'../../../internal/deprecated-aliases.js';import type{LyraConversationItem}from'../conversation-item/conversation-item.class.js';import{type LyraSize}from'../../../internal/variants.js';import{type LyraTimestamp}from'../timestamp.js';export interface LyraChatThread{id:string;
1
+ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraConversationItem}from'../conversation-item/conversation-item.class.js';import{type LyraSize}from'../../../internal/variants.js';import{type LyraTimestamp}from'../timestamp.js';export interface LyraChatThread{id:string;
2
2
  /** Required display/search text. Runtime records without a string title are omitted. */
3
3
  title:string;excerpt?:string;timestamp?:LyraTimestamp;pinned?:boolean;archived?:boolean;}export type ThreadRowAction='pin'|'archive'|'delete';export type ThreadListGrouping='date'|'custom'|'none';
4
4
  /** Payload shared by the `lr-group-toggle-request`/`lr-group-toggle` pair. */
5
5
  export interface ThreadGroupToggleDetail{groupId:string;
6
6
  /** Whether the group is shown in the resulting (on `lr-group-toggle-request`, the proposed)
7
7
  * state. Always present on events this component dispatches. */
8
- expanded?:boolean;
9
- /** The inverse of `expanded`.
10
- * @deprecated Read `expanded` instead; removal not before 23.0.0. */
11
- collapsed:boolean;}export interface LyraThreadListEventMap{'lr-select':CustomEvent<{conversationId:string;}>;'lr-thread-pin':CustomEvent<{conversationId:string;pinned:boolean;}>;'lr-thread-archive':CustomEvent<{conversationId:string;archived:boolean;}>;'lr-thread-delete':CustomEvent<{conversationId:string;}>;'lr-thread-rename':CustomEvent<{conversationId:string;label:string;}>;'lr-filter-change':CustomEvent<{text:string;matchCount:number;}>;'lr-query-change':CustomEvent<{text:string;}>;'lr-group-toggle-request':CustomEvent<ThreadGroupToggleDetail>;'lr-group-toggle':CustomEvent<ThreadGroupToggleDetail>;
8
+ expanded?:boolean;}export interface LyraThreadListEventMap{'lr-select':CustomEvent<{conversationId:string;}>;'lr-thread-pin':CustomEvent<{conversationId:string;pinned:boolean;}>;'lr-thread-archive':CustomEvent<{conversationId:string;archived:boolean;}>;'lr-thread-delete':CustomEvent<{conversationId:string;}>;'lr-thread-rename':CustomEvent<{conversationId:string;label:string;}>;'lr-filter-change':CustomEvent<{text:string;matchCount:number;}>;'lr-query-change':CustomEvent<{text:string;}>;'lr-group-toggle-request':CustomEvent<ThreadGroupToggleDetail>;'lr-group-toggle':CustomEvent<ThreadGroupToggleDetail>;
12
9
  /** The built-in `[part='retry-button']` was activated, only rendered while `error` is set.
13
10
  * Cancelable: the default action clears `error`; `preventDefault()` leaves it set instead. */
14
- 'lr-retry-request':CustomEvent<null>;
15
- /** @deprecated Use `lr-retry-request`; removal not before 24.0.0. */
16
- 'lr-retry':CustomEvent<null>;blur:CustomEvent<null>;focus:CustomEvent<null>;}export type ThreadBucketKey='pinned'|'today'|'yesterday'|'previous7'|'previous30'|`month:${string}`|'archived';export interface ThreadGroupContext{id:string;threads:readonly LyraChatThread[];bucket?:ThreadBucketKey;date?:Date;}
11
+ 'lr-retry-request':CustomEvent<null>;blur:CustomEvent<null>;focus:CustomEvent<null>;}export type ThreadBucketKey='pinned'|'today'|'yesterday'|'previous7'|'previous30'|`month:${string}`|'archived';export interface ThreadGroupContext{id:string;threads:readonly LyraChatThread[];bucket?:ThreadBucketKey;date?:Date;}
17
12
  /**
18
13
  * `<lr-thread-list>` — the conversation sidebar: a grouped, searchable list of chat sessions with
19
14
  * pin/archive/delete/rename affordances. *Data mode* (non-empty `threads`, or empty `threads` with
@@ -70,14 +65,13 @@ collapsed:boolean;}export interface LyraThreadListEventMap{'lr-select':CustomEve
70
65
  * correlated `lr-rename` request (data mode only).
71
66
  * @event lr-filter-change - `detail: { text, matchCount }` -- data-mode query plus owned results.
72
67
  * @event lr-query-change - `detail: { text }` -- slotted-mode query request; the host owns results.
73
- * @event lr-group-toggle-request - `detail: { groupId, expanded, collapsed }` (`expanded` is the
74
- * canonical key, the deprecated `collapsed` its inverse) -- cancelable proposal before a
68
+ * @event lr-group-toggle-request - `detail: { groupId, expanded }` is a cancelable proposal before a
75
69
  * custom/date group's collapse state changes. Calling `preventDefault()` skips the built-in
76
70
  * `collapsedGroupIds` write below and suppresses the following `lr-group-toggle`, leaving the
77
71
  * group's collapse state fully controlled -- the host must then reassign `collapsedGroupIds`
78
72
  * itself, mirroring `<lr-chat-message>`'s and `<lr-code-block>`'s own
79
73
  * `lr-toggle-request`/`lr-toggle` pairs.
80
- * @event lr-group-toggle - `detail: { groupId, expanded, collapsed }` -- a custom/date group's collapse-state
74
+ * @event lr-group-toggle - `detail: { groupId, expanded }` -- a custom/date group's collapse-state
81
75
  * change was accepted and, unless `lr-group-toggle-request` was prevented, already applied to
82
76
  * `collapsedGroupIds`. A host that already listens here and reassigns `collapsedGroupIds` itself
83
77
  * keeps working unchanged: this component's own write, when it happens, always precedes that
@@ -88,7 +82,6 @@ collapsed:boolean;}export interface LyraThreadListEventMap{'lr-select':CustomEve
88
82
  * @event focus - `searchable`: re-dispatched from the internal search `<input>`'s own `focus`,
89
83
  * for the same reason as `blur`.
90
84
  * @event lr-retry-request - Cancelable retry proposal before the default retry action. `detail: null`.
91
- * @event lr-retry - Deprecated veto alias of `lr-retry-request`; removal not before 24.0.0.
92
85
  * The built-in `[part='retry-button']` was activated, only rendered while
93
86
  * `error` is set. Cancelable: the default action clears `error`; `preventDefault()` leaves it
94
87
  * set instead.
@@ -191,7 +184,7 @@ collapsed:boolean;}export interface LyraThreadListEventMap{'lr-select':CustomEve
191
184
  * @status stable
192
185
  * @since 4.0.0
193
186
  */
194
- export declare class LyraThreadList extends LyraElement<LyraThreadListEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly ownedCollectionProperties:readonly string[];protected static readonly identityCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[];protected static deprecatedAliases:LyraDeprecatedAliases;
187
+ export declare class LyraThreadList extends LyraElement<LyraThreadListEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly ownedCollectionProperties:readonly string[];protected static readonly identityCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[];
195
188
  /** At least one valid thread ⇒ data mode (the default slot is ignored). No valid threads and no
196
189
  * slotted content ⇒ data mode with zero rows (the built-in empty state). No valid threads with
197
190
  * slotted content ⇒ slotted mode. Thread ids must be nonempty and unique; invalid/later
@@ -281,10 +274,6 @@ formatDate?:(date:Date)=>string;
281
274
  withArchived:boolean;
282
275
  /** Forwarded to each data-mode row: turns off its inline rename. */
283
276
  withoutRename:boolean;
284
- /** Compatibility density alias: true selects `size="s"`, false selects `size="m"`. The shared
285
- * size applies to the built-in search field and data-mode rows; slotted rows retain their own size.
286
- * @deprecated Use `size="s"`; removal not before 24.0.0. */
287
- compact:boolean;
288
277
  /** Data mode only: pins the current date/custom group's header to the top of the scroll viewport
289
278
  * while its rows are in view, pushing it off as the next group's header arrives. Group headers
290
279
  * are ordinary virtualized rows, so this renders a `aria-hidden` copy of the header into