@aceshooting/lyra-ui 27.0.0 → 28.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 (397) hide show
  1. package/CHANGELOG.md +67 -63
  2. package/README.md +7 -3
  3. package/dist/cli/css-declarations.mjs +1 -0
  4. package/dist/cli/lyra-rename-ledger.mjs +1 -1
  5. package/dist/cli/migrate-wa.mjs +9 -4
  6. package/dist/cli/migration-contract.json +1 -1
  7. package/dist/cli/migration-renames.mjs +2 -2
  8. package/dist/cli/migration-theme-scopes.mjs +3 -0
  9. package/dist/cli/theme-scope-vocabulary.generated.mjs +1 -0
  10. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
  11. package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
  12. package/dist/components/agent-tools/agent-question/agent-question.class.js +1 -1
  13. package/dist/components/agent-tools/agent-run/agent-run.class.js +1 -1
  14. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +1 -1
  15. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -1
  16. package/dist/components/agent-tools/artifact-panel/artifact-panel.class.js +1 -1
  17. package/dist/components/agent-tools/background-runs/background-runs.class.js +1 -1
  18. package/dist/components/agent-tools/browser-frame/browser-frame.class.js +1 -1
  19. package/dist/components/agent-tools/budget-meter/budget-meter.class.js +1 -1
  20. package/dist/components/agent-tools/change-review/change-review.class.js +1 -1
  21. package/dist/components/agent-tools/commit-card/commit-card.class.js +1 -1
  22. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  23. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +1 -1
  24. package/dist/components/agent-tools/connector-manager/connector-manager.class.js +1 -1
  25. package/dist/components/agent-tools/context-inspector/context-inspector.class.js +1 -1
  26. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  27. package/dist/components/agent-tools/eval-result/eval-result.class.js +1 -1
  28. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -1
  29. package/dist/components/agent-tools/mcp-app/mcp-app.class.js +1 -1
  30. package/dist/components/agent-tools/permission-grant/permission-grant.class.js +1 -1
  31. package/dist/components/agent-tools/permission-rules/permission-rules.class.js +1 -1
  32. package/dist/components/agent-tools/policy-summary/policy-summary.class.js +1 -1
  33. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +1 -1
  34. package/dist/components/agent-tools/result-card/result-field.class.js +1 -1
  35. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.js +1 -1
  36. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +1 -1
  37. package/dist/components/agent-tools/stack-trace/stack-trace.class.js +1 -1
  38. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
  39. package/dist/components/agent-tools/task-list/task-list.class.js +2 -2
  40. package/dist/components/agent-tools/terminal/terminal.class.js +1 -1
  41. package/dist/components/agent-tools/test-results/test-results.class.js +1 -1
  42. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
  43. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
  44. package/dist/components/agent-tools/tool-call-block/tool-call-block.class.js +1 -1
  45. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +1 -1
  46. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +1 -1
  47. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +1 -1
  48. package/dist/components/agent-tools/tool-result-view/tool-result-view.class.js +1 -1
  49. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
  50. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -1
  51. package/dist/components/agent-tools/trace-tree/trace-tree.class.js +2 -2
  52. package/dist/components/charts/chart/box-plot.class.d.ts +4 -2
  53. package/dist/components/charts/chart/box-plot.class.js +6 -5
  54. package/dist/components/charts/chart/chart-token-cache.js +2 -2
  55. package/dist/components/charts/chart/chart.class.d.ts +6 -4
  56. package/dist/components/charts/chart/chart.class.js +8 -7
  57. package/dist/components/charts/chart/histogram.class.js +1 -1
  58. package/dist/components/charts/chart/lite-chart.class.js +1 -1
  59. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +1 -1
  60. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.js +1 -1
  61. package/dist/components/conversation/branch-picker/branch-picker.class.js +1 -1
  62. package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
  63. package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
  64. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  65. package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
  66. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  67. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  68. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  69. package/dist/components/conversation/conversation-item/conversation-item.class.js +1 -1
  70. package/dist/components/conversation/generation-metrics/generation-metrics.class.js +1 -1
  71. package/dist/components/conversation/handoff-divider/handoff-divider.class.js +1 -1
  72. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  73. package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
  74. package/dist/components/conversation/markdown/markdown.class.js +1 -1
  75. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  76. package/dist/components/conversation/message-feedback/message-feedback.class.js +1 -1
  77. package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
  78. package/dist/components/conversation/model-select/model-select.class.js +1 -1
  79. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +1 -1
  80. package/dist/components/conversation/prompt-input/prompt-input.class.js +1 -1
  81. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +1 -1
  82. package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
  83. package/dist/components/conversation/realtime-session/realtime-session.class.js +1 -1
  84. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  85. package/dist/components/conversation/stream-status/stream-status.class.js +1 -1
  86. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +1 -1
  87. package/dist/components/conversation/thread-list/thread-list.class.js +1 -1
  88. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  89. package/dist/components/conversation/typing-indicator/typing-indicator.class.js +1 -1
  90. package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
  91. package/dist/components/conversation/voice-picker/voice-picker.class.js +1 -1
  92. package/dist/components/data/calendar/calendar.class.js +1 -1
  93. package/dist/components/data/condition-builder/condition-builder.class.js +1 -1
  94. package/dist/components/data/context-meter/context-meter.class.js +1 -1
  95. package/dist/components/data/data-grid/data-grid.class.d.ts +2 -2
  96. package/dist/components/data/data-grid/data-grid.class.js +3 -3
  97. package/dist/components/data/document-library/document-library.class.js +1 -1
  98. package/dist/components/data/env-list/env-list.class.js +1 -1
  99. package/dist/components/data/file-tree/file-tree.class.d.ts +2 -2
  100. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  101. package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
  102. package/dist/components/data/flow-controls/flow-controls.class.js +1 -1
  103. package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
  104. package/dist/components/data/flow-node/flow-node.class.js +1 -1
  105. package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
  106. package/dist/components/data/funnel/funnel.class.js +1 -1
  107. package/dist/components/data/gauge/gauge.class.js +1 -1
  108. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
  109. package/dist/components/data/heatmap/heatmap.class.d.ts +2 -1
  110. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  111. package/dist/components/data/heatmap/heatmap.styles.js +1 -1
  112. package/dist/components/data/pagination/pagination.class.d.ts +2 -0
  113. package/dist/components/data/pagination/pagination.class.js +1 -1
  114. package/dist/components/data/pagination/pagination.styles.js +1 -1
  115. package/dist/components/data/sequence-strip/sequence-strip.class.js +1 -1
  116. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  117. package/dist/components/data/stat/stat.class.js +1 -1
  118. package/dist/components/data/table/table.class.d.ts +23 -2
  119. package/dist/components/data/table/table.class.js +5 -3
  120. package/dist/components/data/table/table.styles.js +1 -1
  121. package/dist/components/data/timeline/timeline.class.js +1 -1
  122. package/dist/components/data/tree/tree.class.js +1 -1
  123. package/dist/components/data/word-cloud/word-cloud.class.js +1 -1
  124. package/dist/components/forms/button/button.class.js +1 -1
  125. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  126. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  127. package/dist/components/forms/code-editor/code-editor.class.js +1 -1
  128. package/dist/components/forms/color-picker/color-picker.class.d.ts +8 -4
  129. package/dist/components/forms/color-picker/color-picker.class.js +2 -2
  130. package/dist/components/forms/combobox/combobox.class.js +1 -1
  131. package/dist/components/forms/country-picker/country-picker.class.js +1 -1
  132. package/dist/components/forms/currency-picker/currency-picker.class.js +1 -1
  133. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  134. package/dist/components/forms/date-picker/date-picker.class.js +1 -1
  135. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  136. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +7 -4
  137. package/dist/components/forms/emoji-picker/emoji-picker.class.js +5 -5
  138. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -0
  139. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  140. package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
  141. package/dist/components/forms/input/input-shared.js +1 -1
  142. package/dist/components/forms/input/input.class.js +1 -1
  143. package/dist/components/forms/input/native-time-input.class.js +1 -1
  144. package/dist/components/forms/input/number-input.class.js +1 -1
  145. package/dist/components/forms/input/time-input.class.js +1 -1
  146. package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
  147. package/dist/components/forms/otp-input/otp-input.class.js +1 -1
  148. package/dist/components/forms/phone-input/phone-input.class.js +1 -1
  149. package/dist/components/forms/radio/radio-group.class.js +1 -1
  150. package/dist/components/forms/radio/radio.class.js +1 -1
  151. package/dist/components/forms/rubric-form/rubric-form.class.js +4 -4
  152. package/dist/components/forms/select/select.class.js +1 -1
  153. package/dist/components/forms/signature-pad/signature-pad.class.js +1 -1
  154. package/dist/components/forms/slider/slider.class.js +1 -1
  155. package/dist/components/forms/switch/switch.class.js +1 -1
  156. package/dist/components/forms/textarea/textarea.class.js +1 -1
  157. package/dist/components/forms/time-range/time-range.class.js +1 -1
  158. package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -1
  159. package/dist/components/forms/token-input/token-input.class.js +1 -1
  160. package/dist/components/forms/unit-picker/unit-picker.class.js +1 -1
  161. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  162. package/dist/components/layout/app-rail/app-rail.class.d.ts +70 -7
  163. package/dist/components/layout/app-rail/app-rail.class.js +16 -4
  164. package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
  165. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  166. package/dist/components/layout/breadcrumb/breadcrumb.class.js +1 -1
  167. package/dist/components/layout/card/card.class.js +1 -1
  168. package/dist/components/layout/carousel/carousel.class.js +1 -1
  169. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  170. package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
  171. package/dist/components/layout/details/accordion-item.class.js +1 -1
  172. package/dist/components/layout/details/details.class.js +1 -1
  173. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  174. package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +1 -1
  175. package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
  176. package/dist/components/layout/menu/menu.class.js +1 -1
  177. package/dist/components/layout/menubar/menubar.class.js +1 -1
  178. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  179. package/dist/components/layout/navigation-menu/navigation-menu.class.js +1 -1
  180. package/dist/components/layout/page/page.class.js +1 -1
  181. package/dist/components/layout/reorder-list/reorder-item.class.js +1 -1
  182. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  183. package/dist/components/layout/responsive-panel/responsive-panel.class.js +1 -1
  184. package/dist/components/layout/scroller/scroller.class.js +1 -1
  185. package/dist/components/layout/segmented/segmented.class.d.ts +7 -4
  186. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  187. package/dist/components/layout/split-panel/split-panel.class.js +1 -1
  188. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  189. package/dist/components/layout/tab-group/tab.class.js +1 -1
  190. package/dist/components/layout/virtual-list/virtual-list.styles.js +1 -1
  191. package/dist/components/layout/widget/widget.class.js +1 -1
  192. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  193. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  194. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +2 -2
  195. package/dist/components/media/av-player/av-player.class.js +1 -1
  196. package/dist/components/media/avatar-group/avatar-group.class.js +1 -1
  197. package/dist/components/media/drop-zone/drop-zone.class.js +1 -1
  198. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  199. package/dist/components/media/file-input/file-input.class.js +1 -1
  200. package/dist/components/media/flag/flag.class.js +1 -1
  201. package/dist/components/media/image-comparer/image-comparer.class.js +1 -1
  202. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -1
  203. package/dist/components/media/image-viewer/image-viewer.class.js +4 -2
  204. package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
  205. package/dist/components/media/lightbox/lightbox.class.js +1 -1
  206. package/dist/components/media/map/map.class.js +1 -1
  207. package/dist/components/media/media-card/media-card.class.js +1 -1
  208. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  209. package/dist/components/media/qr-code/qr-code.class.d.ts +2 -2
  210. package/dist/components/media/qr-code/qr-code.class.js +1 -1
  211. package/dist/components/media/sequence-playback/sequence-playback.class.js +1 -1
  212. package/dist/components/media/video/video.class.js +1 -1
  213. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  214. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +1 -1
  215. package/dist/components/overlays/alert/alert.class.js +1 -1
  216. package/dist/components/overlays/badge/tag.class.js +1 -1
  217. package/dist/components/overlays/callout/callout.class.js +1 -1
  218. package/dist/components/overlays/chip/chip-group.class.js +1 -1
  219. package/dist/components/overlays/chip/chip.class.js +1 -1
  220. package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
  221. package/dist/components/overlays/dialog/confirm.js +1 -1
  222. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  223. package/dist/components/overlays/kbd/kbd.class.js +1 -1
  224. package/dist/components/overlays/overlay/popover.class.js +1 -1
  225. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  226. package/dist/components/overlays/progress/progress-bar.class.js +1 -1
  227. package/dist/components/overlays/progress/progress-ring.class.js +1 -1
  228. package/dist/components/overlays/rating/rating.class.js +1 -1
  229. package/dist/components/overlays/skeleton/skeleton.class.js +1 -1
  230. package/dist/components/overlays/spinner/spinner.class.js +1 -1
  231. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  232. package/dist/components/overlays/toast/toast.class.js +1 -1
  233. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.js +1 -1
  234. package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
  235. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +1 -1
  236. package/dist/components/retrieval/community-card/community-card.class.js +1 -1
  237. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +1 -1
  238. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  239. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  240. package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +1 -1
  241. package/dist/components/retrieval/graph/graph.class.js +1 -1
  242. package/dist/components/retrieval/graph-legend/graph-legend.class.js +1 -1
  243. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +2 -2
  244. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +1 -1
  245. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +1 -1
  246. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +1 -1
  247. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +1 -1
  248. package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
  249. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  250. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  251. package/dist/components/retrieval/node-palette/node-palette.class.js +1 -1
  252. package/dist/components/retrieval/path-strip/path-strip.class.js +1 -1
  253. package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
  254. package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
  255. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +1 -1
  256. package/dist/components/retrieval/research-progress/research-progress.class.js +1 -1
  257. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +1 -1
  258. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
  259. package/dist/components/retrieval/retrieval-search/retrieval-search.class.js +1 -1
  260. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
  261. package/dist/components/retrieval/source-card/source-card.class.js +1 -1
  262. package/dist/components/retrieval/source-list/source-list.class.js +1 -1
  263. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  264. package/dist/components/utility/copy-button/copy-button.class.js +1 -1
  265. package/dist/components/utility/diff-view/diff-view.class.js +1 -1
  266. package/dist/components/utility/export-button/export-button.class.js +1 -1
  267. package/dist/components/utility/icon/icon.class.js +1 -1
  268. package/dist/components/utility/json-viewer/json-viewer.class.js +1 -1
  269. package/dist/components/utility/known-date/known-date.class.js +1 -1
  270. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  271. package/dist/components/utility/poll-status/poll-status.class.js +1 -1
  272. package/dist/components/utility/random-content/random-content.class.js +1 -1
  273. package/dist/components/utility/tour/tour.class.js +1 -1
  274. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  275. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  276. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  277. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  278. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +2 -2
  279. package/dist/components/viewers/document-compare/document-compare.class.js +1 -1
  280. package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
  281. package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
  282. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
  283. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  284. package/dist/components/viewers/email-viewer/email-viewer.class.js +1 -1
  285. package/dist/components/viewers/geojson-view/geojson-view.class.js +1 -1
  286. package/dist/components/viewers/geojson-view/geojson-viewer.class.js +1 -1
  287. package/dist/components/viewers/highlight-layer/highlight-layer.class.js +1 -1
  288. package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
  289. package/dist/components/viewers/include/include.class.js +1 -1
  290. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
  291. package/dist/components/viewers/page-rail/page-rail.class.d.ts +1 -1
  292. package/dist/components/viewers/page-rail/page-rail.class.js +3 -3
  293. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
  294. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  295. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
  296. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  297. package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
  298. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  299. package/dist/events.d.ts +6 -1
  300. package/dist/framework-types.d.ts +1 -1
  301. package/dist/internal/accessibility-visibility.js +1 -1
  302. package/dist/internal/collection-snapshot.js +1 -1
  303. package/dist/internal/default-strings/agent-tools.generated.js +1 -0
  304. package/dist/internal/default-strings/charts.generated.js +1 -0
  305. package/dist/internal/default-strings/conversation.generated.js +1 -0
  306. package/dist/internal/default-strings/data.generated.js +1 -0
  307. package/dist/internal/default-strings/forms.generated.js +1 -0
  308. package/dist/internal/default-strings/layout.generated.js +1 -0
  309. package/dist/internal/default-strings/media.generated.js +1 -0
  310. package/dist/internal/default-strings/overlays.generated.js +1 -0
  311. package/dist/internal/default-strings/retrieval.generated.js +1 -0
  312. package/dist/internal/default-strings/shared.generated.js +1 -0
  313. package/dist/internal/default-strings/utility.generated.js +1 -0
  314. package/dist/internal/default-strings/viewers.generated.js +5 -0
  315. package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
  316. package/dist/internal/dev-mode-attribute-warning.production.js +1 -1
  317. package/dist/internal/document-tokens.d.ts +11 -0
  318. package/dist/internal/document-tokens.generated.js +15 -0
  319. package/dist/internal/document-tokens.js +3 -0
  320. package/dist/internal/form-associated.d.ts +1 -1
  321. package/dist/internal/form-associated.js +1 -1
  322. package/dist/internal/glass-surface.styles.js +1 -1
  323. package/dist/internal/host-tokens.styles.js +1 -0
  324. package/dist/internal/image-zoom.js +1 -0
  325. package/dist/internal/intl-cache.js +1 -1
  326. package/dist/internal/localization-types.d.ts +1 -1
  327. package/dist/internal/localization.js +2 -2
  328. package/dist/internal/lyra-element.d.ts +4 -2
  329. package/dist/internal/lyra-element.js +2 -2
  330. package/dist/internal/nonmodal-overlay-manager.js +1 -1
  331. package/dist/internal/opaque-content-border.styles.js +1 -1
  332. package/dist/internal/open-overlay-ancestors.js +1 -0
  333. package/dist/internal/open-overlay-raise.styles.js +1 -0
  334. package/dist/internal/optional-peer-failure.js +1 -0
  335. package/dist/internal/package-metadata.js +1 -1
  336. package/dist/internal/prefix.js +1 -1
  337. package/dist/internal/specialist-host-tokens.styles.js +1 -0
  338. package/dist/internal/specialist-tokens.generated.js +2 -0
  339. package/dist/internal/step-value.js +1 -1
  340. package/dist/internal/theme-observation.js +1 -1
  341. package/dist/internal/theme-scopes.d.ts +11 -0
  342. package/dist/internal/theme-scopes.js +1 -0
  343. package/dist/looks/shadcn.css +1 -1
  344. package/dist/lyra.d.ts +1 -1
  345. package/dist/lyra.js +1 -1
  346. package/dist/styles/design-tokens.css +1 -1
  347. package/dist/styles/tokens-root.css +1 -1
  348. package/dist/surfaces/glass.css +1 -1
  349. package/dist/testing/happy-dom-shims.d.ts +22 -1
  350. package/dist/testing/happy-dom-shims.js +1 -1
  351. package/dist/testing/index.d.ts +1 -1
  352. package/dist/testing/index.js +1 -1
  353. package/dist/testing/interaction-drivers.d.ts +66 -7
  354. package/dist/testing/interaction-drivers.js +1 -1
  355. package/dist/testing/jsdom-shims.d.ts +70 -0
  356. package/dist/testing/jsdom-shims.js +1 -0
  357. package/dist/theme/look-inputs.d.ts +1 -1
  358. package/dist/theme/look-inputs.js +37 -41
  359. package/dist/theme/theme.d.ts +13 -0
  360. package/dist/theme/theme.js +1 -1
  361. package/dist/theme.css +1 -1
  362. package/dist/utilities/index.d.ts +1 -1
  363. package/dist/utilities/index.js +1 -1
  364. package/dist/utilities/scoped-registry.d.ts +3 -0
  365. package/dist/utilities/scoped-registry.js +1 -1
  366. package/dist/utilities/theme-scopes.d.ts +1 -0
  367. package/dist/utilities/theme-scopes.js +1 -0
  368. package/dist/utilities/tokens.d.ts +1 -0
  369. package/dist/utilities/tokens.js +1 -0
  370. package/llms/components/lr-app-rail.md +51 -4
  371. package/llms/components/lr-box-plot.md +5 -0
  372. package/llms/components/lr-chart.md +6 -0
  373. package/llms/components/lr-emoji-picker.md +13 -8
  374. package/llms/components/lr-heatmap.md +10 -2
  375. package/llms/components/lr-icon-button.md +13 -1
  376. package/llms/components/lr-image-viewer.md +8 -0
  377. package/llms/components/lr-pagination.md +4 -2
  378. package/llms/components/lr-segmented.md +7 -3
  379. package/llms/components/lr-table.md +14 -12
  380. package/llms/components/lr-thread-list.md +4 -3
  381. package/llms/migration.md +9 -0
  382. package/llms/peers.md +1 -1
  383. package/llms/shared/events-and-types.md +41 -0
  384. package/llms/shared/frameworks-and-ssr.md +16 -0
  385. package/llms/shared/imports-and-registration.md +4 -3
  386. package/llms/shared/native-styles-and-utilities.md +38 -3
  387. package/llms/shared/styles-and-tokens.md +242 -102
  388. package/llms/shared/testing-and-utilities.md +104 -7
  389. package/llms/shared.md +445 -115
  390. package/llms/tokens.md +31 -49
  391. package/locales.json +138 -138
  392. package/package.json +16 -8
  393. package/registrations.json +1 -1
  394. package/dist/internal/default-strings.generated.js +0 -5
  395. package/dist/internal/specialist-tokens.styles.js +0 -1
  396. package/dist/internal/tokens/palette.styles.js +0 -1
  397. package/dist/internal/tokens.styles.js +0 -1
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{guard}from"lit/directives/guard.js";import{LyraElement}from"../../../internal/lyra-element.js";import{literalSetConverter}from"../../../internal/converters.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{formatShortDuration,safeDurationMs}from"../../../internal/duration.js";import{tag}from"../../../internal/prefix.js";import{observeScrollOverflow,SCROLL_OVERFLOW_ATTRIBUTE}from"../../../internal/scroll-overflow.js";import{TOOL_CALL_STATUSES,TOOL_STATUS_LABEL_KEY,toolStatusIcon}from"../tool-status.js";import{projectedRedactionFields,redactToolDetail,TOO_MANY_REDACTION_PATHS}from"../tool-redaction.js";import{styles}from"./tool-call-block.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall,LYRA_DEFAULT_toolCallBlockArgumentsLabel,LYRA_DEFAULT_toolCallBlockErrorLabel,LYRA_DEFAULT_toolCallBlockHeaderDenied,LYRA_DEFAULT_toolCallBlockHeaderError,LYRA_DEFAULT_toolCallBlockHeaderIncomplete,LYRA_DEFAULT_toolCallBlockHeaderPending,LYRA_DEFAULT_toolCallBlockHeaderRunning,LYRA_DEFAULT_toolCallBlockHeaderSuccess,LYRA_DEFAULT_toolCallBlockResultLabel}from"../../../internal/default-strings.generated.js";const TOOL_CALL_BLOCK_STATUS=literalSetConverter(TOOL_CALL_STATUSES,"pending"),HEADER_KEY={pending:"toolCallBlockHeaderPending",running:"toolCallBlockHeaderRunning",success:"toolCallBlockHeaderSuccess",error:"toolCallBlockHeaderError",denied:"toolCallBlockHeaderDenied",incomplete:"toolCallBlockHeaderIncomplete"};function argsPresent(args){if(args==null)return!1;if(typeof args!="object")return!0;try{const prototype=Object.getPrototypeOf(args);return prototype!==Object.prototype&&prototype!==null?!0:Object.keys(args).length>0}catch{return!0}}class LyraToolCallBlock extends LyraElement{constructor(){super(...arguments),this.name="",this.callId="",this.statusValue="pending",this.expanded=!1,this.redactedFields=[],this.bodyId=nextId("tool-call-block-body"),this.labelId=nextId("tool-call-block-label"),this.argsLabelId=nextId("tool-call-block-args-label"),this.resultLabelId=nextId("tool-call-block-result-label"),this.errorLabelId=nextId("tool-call-block-error-label"),this.projectedPaths=[],this.restoreFocusToHeader=!1,this.resultOverflow=observeScrollOverflow(this,()=>this.renderRoot?.querySelector('[part="result"]'),()=>this.syncResultScrollStop()),this.onHeaderClick=()=>{this.expanded=!this.expanded,this.emit("lr-toggle",{expanded:this.expanded,callId:this.callId})},this.onRenderError=event=>{event.stopPropagation(),this.emit("lr-render-error",{toolName:event.detail.toolName,error:event.detail.error,callId:this.callId})}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,envListValueHidden:LYRA_DEFAULT_envListValueHidden,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusIncomplete:LYRA_DEFAULT_statusIncomplete,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall,toolCallBlockArgumentsLabel:LYRA_DEFAULT_toolCallBlockArgumentsLabel,toolCallBlockErrorLabel:LYRA_DEFAULT_toolCallBlockErrorLabel,toolCallBlockHeaderDenied:LYRA_DEFAULT_toolCallBlockHeaderDenied,toolCallBlockHeaderError:LYRA_DEFAULT_toolCallBlockHeaderError,toolCallBlockHeaderIncomplete:LYRA_DEFAULT_toolCallBlockHeaderIncomplete,toolCallBlockHeaderPending:LYRA_DEFAULT_toolCallBlockHeaderPending,toolCallBlockHeaderRunning:LYRA_DEFAULT_toolCallBlockHeaderRunning,toolCallBlockHeaderSuccess:LYRA_DEFAULT_toolCallBlockHeaderSuccess,toolCallBlockResultLabel:LYRA_DEFAULT_toolCallBlockResultLabel}}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["redactedFields"])}get status(){return this.statusValue}set status(next){const normalized=TOOL_CALL_BLOCK_STATUS.normalizeReflected(this,"status",next),old=this.statusValue;old!==normalized&&(this.statusValue=normalized,this.requestUpdate("status",old))}willUpdate(changed){super.willUpdate(changed),(!this.hasUpdated||changed.has("redactedFields"))&&(this.projectedPaths=projectedRedactionFields(this.redactedFields)??TOO_MANY_REDACTION_PATHS),this.hasUpdated&&changed.get("expanded")===!0&&!this.expanded&&(this.restoreFocusToHeader=!!this.renderRoot?.querySelector('[part="body"]')?.contains(shadowFocusTarget(this)))}updated(changed){super.updated(changed);const view=this.renderRoot.querySelector(tag("tool-result-view"));view&&this.resultOverflow.observeExtra([view]),this.syncResultScrollStop(),this.restoreFocusToHeader&&(this.restoreFocusToHeader=!1,this.renderRoot.querySelector('[part="header"]')?.focus())}syncResultScrollStop(){const result=this.renderRoot?.querySelector('[part="result"]');result&&(result.hasAttribute(SCROLL_OVERFLOW_ATTRIBUTE)?result.setAttribute("tabindex","0"):result.removeAttribute("tabindex"))}detail(){const detail=redactToolDetail({args:this.args,result:this.result,error:this.errorText},this.projectedPaths,this.localize("envListValueHidden"),this.detailMemo?.detail);return detail!==this.detailMemo?.detail&&(this.detailMemo={detail,hasArgs:argsPresent(this.args)}),this.detailMemo}get safeDurationMs(){return safeDurationMs(this.durationMs)}durationText(){const ms=this.safeDurationMs;return ms==null?null:formatShortDuration(this.localize.bind(this),this.effectiveLocale,ms)}emptyText(){return this.status==="pending"?this.localize("statusPending"):this.status==="running"?this.localize("statusRunning"):this.localize("noData")}bodyTemplate(){const memo=this.detail(),{detail,hasArgs}=memo,empty=!hasArgs&&!(typeof detail.sourceError=="string"&&detail.sourceError!=="")&&detail.sourceResult===void 0,labels=[this.localize("toolCallBlockArgumentsLabel"),this.localize("toolCallBlockErrorLabel"),this.localize("toolCallBlockResultLabel"),empty?this.emptyText():""];return html`${guard([memo,this.name,this.onRenderError,...labels],()=>this.sectionsTemplate(memo,labels))}`}sectionsTemplate({detail,hasArgs},[argsLabel,errorLabel,resultLabel,emptyText]){const hasError=typeof detail.sourceError=="string"&&detail.sourceError!=="",hasResult=detail.sourceResult!==void 0;return!hasArgs&&!hasError&&!hasResult?html`<p part="empty">${emptyText}</p>`:html`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{guard}from"lit/directives/guard.js";import{LyraElement}from"../../../internal/lyra-element.js";import{literalSetConverter}from"../../../internal/converters.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{formatShortDuration,safeDurationMs}from"../../../internal/duration.js";import{tag}from"../../../internal/prefix.js";import{observeScrollOverflow,SCROLL_OVERFLOW_ATTRIBUTE}from"../../../internal/scroll-overflow.js";import{TOOL_CALL_STATUSES,TOOL_STATUS_LABEL_KEY,toolStatusIcon}from"../tool-status.js";import{projectedRedactionFields,redactToolDetail,TOO_MANY_REDACTION_PATHS}from"../tool-redaction.js";import{styles}from"./tool-call-block.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_toolCall,LYRA_DEFAULT_toolCallBlockArgumentsLabel,LYRA_DEFAULT_toolCallBlockErrorLabel,LYRA_DEFAULT_toolCallBlockHeaderDenied,LYRA_DEFAULT_toolCallBlockHeaderError,LYRA_DEFAULT_toolCallBlockHeaderIncomplete,LYRA_DEFAULT_toolCallBlockHeaderPending,LYRA_DEFAULT_toolCallBlockHeaderRunning,LYRA_DEFAULT_toolCallBlockHeaderSuccess,LYRA_DEFAULT_toolCallBlockResultLabel}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess}from"../../../internal/default-strings/shared.generated.js";const TOOL_CALL_BLOCK_STATUS=literalSetConverter(TOOL_CALL_STATUSES,"pending"),HEADER_KEY={pending:"toolCallBlockHeaderPending",running:"toolCallBlockHeaderRunning",success:"toolCallBlockHeaderSuccess",error:"toolCallBlockHeaderError",denied:"toolCallBlockHeaderDenied",incomplete:"toolCallBlockHeaderIncomplete"};function argsPresent(args){if(args==null)return!1;if(typeof args!="object")return!0;try{const prototype=Object.getPrototypeOf(args);return prototype!==Object.prototype&&prototype!==null?!0:Object.keys(args).length>0}catch{return!0}}class LyraToolCallBlock extends LyraElement{constructor(){super(...arguments),this.name="",this.callId="",this.statusValue="pending",this.expanded=!1,this.redactedFields=[],this.bodyId=nextId("tool-call-block-body"),this.labelId=nextId("tool-call-block-label"),this.argsLabelId=nextId("tool-call-block-args-label"),this.resultLabelId=nextId("tool-call-block-result-label"),this.errorLabelId=nextId("tool-call-block-error-label"),this.projectedPaths=[],this.restoreFocusToHeader=!1,this.resultOverflow=observeScrollOverflow(this,()=>this.renderRoot?.querySelector('[part="result"]'),()=>this.syncResultScrollStop()),this.onHeaderClick=()=>{this.expanded=!this.expanded,this.emit("lr-toggle",{expanded:this.expanded,callId:this.callId})},this.onRenderError=event=>{event.stopPropagation(),this.emit("lr-render-error",{toolName:event.detail.toolName,error:event.detail.error,callId:this.callId})}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,envListValueHidden:LYRA_DEFAULT_envListValueHidden,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusIncomplete:LYRA_DEFAULT_statusIncomplete,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall,toolCallBlockArgumentsLabel:LYRA_DEFAULT_toolCallBlockArgumentsLabel,toolCallBlockErrorLabel:LYRA_DEFAULT_toolCallBlockErrorLabel,toolCallBlockHeaderDenied:LYRA_DEFAULT_toolCallBlockHeaderDenied,toolCallBlockHeaderError:LYRA_DEFAULT_toolCallBlockHeaderError,toolCallBlockHeaderIncomplete:LYRA_DEFAULT_toolCallBlockHeaderIncomplete,toolCallBlockHeaderPending:LYRA_DEFAULT_toolCallBlockHeaderPending,toolCallBlockHeaderRunning:LYRA_DEFAULT_toolCallBlockHeaderRunning,toolCallBlockHeaderSuccess:LYRA_DEFAULT_toolCallBlockHeaderSuccess,toolCallBlockResultLabel:LYRA_DEFAULT_toolCallBlockResultLabel}}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["redactedFields"])}get status(){return this.statusValue}set status(next){const normalized=TOOL_CALL_BLOCK_STATUS.normalizeReflected(this,"status",next),old=this.statusValue;old!==normalized&&(this.statusValue=normalized,this.requestUpdate("status",old))}willUpdate(changed){super.willUpdate(changed),(!this.hasUpdated||changed.has("redactedFields"))&&(this.projectedPaths=projectedRedactionFields(this.redactedFields)??TOO_MANY_REDACTION_PATHS),this.hasUpdated&&changed.get("expanded")===!0&&!this.expanded&&(this.restoreFocusToHeader=!!this.renderRoot?.querySelector('[part="body"]')?.contains(shadowFocusTarget(this)))}updated(changed){super.updated(changed);const view=this.renderRoot.querySelector(tag("tool-result-view"));view&&this.resultOverflow.observeExtra([view]),this.syncResultScrollStop(),this.restoreFocusToHeader&&(this.restoreFocusToHeader=!1,this.renderRoot.querySelector('[part="header"]')?.focus())}syncResultScrollStop(){const result=this.renderRoot?.querySelector('[part="result"]');result&&(result.hasAttribute(SCROLL_OVERFLOW_ATTRIBUTE)?result.setAttribute("tabindex","0"):result.removeAttribute("tabindex"))}detail(){const detail=redactToolDetail({args:this.args,result:this.result,error:this.errorText},this.projectedPaths,this.localize("envListValueHidden"),this.detailMemo?.detail);return detail!==this.detailMemo?.detail&&(this.detailMemo={detail,hasArgs:argsPresent(this.args)}),this.detailMemo}get safeDurationMs(){return safeDurationMs(this.durationMs)}durationText(){const ms=this.safeDurationMs;return ms==null?null:formatShortDuration(this.localize.bind(this),this.effectiveLocale,ms)}emptyText(){return this.status==="pending"?this.localize("statusPending"):this.status==="running"?this.localize("statusRunning"):this.localize("noData")}bodyTemplate(){const memo=this.detail(),{detail,hasArgs}=memo,empty=!hasArgs&&!(typeof detail.sourceError=="string"&&detail.sourceError!=="")&&detail.sourceResult===void 0,labels=[this.localize("toolCallBlockArgumentsLabel"),this.localize("toolCallBlockErrorLabel"),this.localize("toolCallBlockResultLabel"),empty?this.emptyText():""];return html`${guard([memo,this.name,this.onRenderError,...labels],()=>this.sectionsTemplate(memo,labels))}`}sectionsTemplate({detail,hasArgs},[argsLabel,errorLabel,resultLabel,emptyText]){const hasError=typeof detail.sourceError=="string"&&detail.sourceError!=="",hasResult=detail.sourceResult!==void 0;return!hasArgs&&!hasError&&!hasResult?html`<p part="empty">${emptyText}</p>`:html`
2
2
  ${hasArgs?html`<div part="args" role="group" aria-labelledby=${this.argsLabelId}>
3
3
  <div part="args-label" id=${this.argsLabelId}>${argsLabel}</div>
4
4
  <lr-json-viewer .data=${detail.args}></lr-json-viewer>
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{deferredPlace as place}from"../../../internal/anchored-overlay-runtime.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{nextId}from"../../../internal/a11y.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{formatShortDuration,safeDurationMs}from"../../../internal/duration.js";import{TOOL_CALL_STATUSES,TOOL_STATUS_LABEL_KEY,toolStatusIcon}from"../tool-status.js";import{literalSetConverter}from"../../../internal/converters.js";import{styles}from"./tool-call-chip.styles.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings.generated.js";const STATUS_ICON=toolStatusIcon,TOOL_CALL_CHIP_STATUS=literalSetConverter(TOOL_CALL_STATUSES,"pending");class LyraToolCallChip extends LyraElement{constructor(){super(...arguments),this.name="",this.category="",this.statusValue="pending",this.summary="",this.icon="",this.callId="",this.hasDetailSlot=!1,this.tooltipOpen=!1,this.tooltipId=nextId("tool-call-chip-tooltip"),this.hovering=!1,this.focused=!1,this.focusDescribed=!1,this.onDetailSlotChange=e=>{this.hasDetailSlot=this.hasPreviewNodes(e.target.assignedNodes({flatten:!0})),this.hasDetailSlot||this.hideTooltip()},this.onMouseEnter=()=>{this.hovering=!0,this.showTooltip()},this.onMouseLeave=()=>{this.hovering=!1,!this.focused&&this.hideTooltip()},this.onFocus=event=>{this.focusDescribed=!0,isKeyboardFocusEvent(event)&&(this.focused=!0,this.showTooltip())},this.onBlur=()=>{this.focused=!1,this.focusDescribed=!1,!this.hovering&&this.hideTooltip()},this.onClick=()=>{this.emit("lr-tool-call-chip-select",{name:this.name,callId:this.callId})}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusIncomplete:LYRA_DEFAULT_statusIncomplete,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}get status(){return this.statusValue}set status(next){const old=this.statusValue;this.statusValue=TOOL_CALL_CHIP_STATUS.normalizeReflected(this,"status",next),this.requestUpdate("status",old)}hasPreviewNodes(nodes){return nodes.some(node=>{if(node.nodeType===3)return!!node.textContent?.trim();if(node.nodeType!==1)return!1;const slotName=node.getAttribute("slot");return slotName===null||slotName===""})}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasDetailSlot=this.hasPreviewNodes(Array.from(this.childNodes)))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription()}syncExternalDescription(){const target=this.isConnected?this.baseEl??null:null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}updated(changed){if(super.updated(changed),this.syncExternalDescription(),changed.has("tooltipOpen")&&(this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOverlay?.deactivate({restoreFocus:!1}),this.tooltipOverlay=void 0,this.tooltipOpen)){const anchor=this.renderRoot.querySelector('[part="base"]'),tooltip=this.renderRoot.querySelector('[part="tooltip"]');anchor&&tooltip&&(this.cleanupPositioner=place(anchor,tooltip,{placement:"top-start",strategy:resolveEffectivePositioningStrategy(this,void 0,"fixed")}),this.tooltipOverlay=activateNonmodalOverlay({host:this,panel:()=>tooltip,onEscape:()=>this.hideTooltip(),restoreFocusTo:null}))}}disconnectedCallback(){super.disconnectedCallback(),this.releaseExternalDescription(),this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOverlay?.deactivate({restoreFocus:!1}),this.tooltipOverlay=void 0,this.tooltipOpen=!1,this.hovering=!1,this.focused=!1,this.focusDescribed=!1}showTooltip(){!this.hasDetailSlot||this.tooltipOpen||(this.tooltipOpen=!0)}hideTooltip(){this.tooltipOpen&&(this.tooltipOpen=!1)}focus(options){this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}click(){this.baseEl?.click()}get safeDurationMs(){return safeDurationMs(this.durationMs)}get shownName(){return this.displayName||this.name||this.localize("toolCall")}get accessibleLabel(){const parts=[this.shownName];this.summary&&parts.push(this.summary),parts.push(this.localize(TOOL_STATUS_LABEL_KEY[this.status]));const durationMs=this.safeDurationMs;return durationMs!=null&&parts.push(this.localizedDuration(durationMs)),parts.join(this.localize("accessibleLabelSeparator"))}localizedDuration(ms){return formatShortDuration(this.localize.bind(this),this.effectiveLocale,ms)}render(){const hasCategory=(this.category??"").length>0,hasSummary=(this.summary??"").length>0,durationMs=this.safeDurationMs,hasDuration=durationMs!=null,status=this.status;return html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{deferredPlace as place}from"../../../internal/anchored-overlay-runtime.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{nextId}from"../../../internal/a11y.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{formatShortDuration,safeDurationMs}from"../../../internal/duration.js";import{TOOL_CALL_STATUSES,TOOL_STATUS_LABEL_KEY,toolStatusIcon}from"../tool-status.js";import{literalSetConverter}from"../../../internal/converters.js";import{styles}from"./tool-call-chip.styles.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess}from"../../../internal/default-strings/shared.generated.js";const STATUS_ICON=toolStatusIcon,TOOL_CALL_CHIP_STATUS=literalSetConverter(TOOL_CALL_STATUSES,"pending");class LyraToolCallChip extends LyraElement{constructor(){super(...arguments),this.name="",this.category="",this.statusValue="pending",this.summary="",this.icon="",this.callId="",this.hasDetailSlot=!1,this.tooltipOpen=!1,this.tooltipId=nextId("tool-call-chip-tooltip"),this.hovering=!1,this.focused=!1,this.focusDescribed=!1,this.onDetailSlotChange=e=>{this.hasDetailSlot=this.hasPreviewNodes(e.target.assignedNodes({flatten:!0})),this.hasDetailSlot||this.hideTooltip()},this.onMouseEnter=()=>{this.hovering=!0,this.showTooltip()},this.onMouseLeave=()=>{this.hovering=!1,!this.focused&&this.hideTooltip()},this.onFocus=event=>{this.focusDescribed=!0,isKeyboardFocusEvent(event)&&(this.focused=!0,this.showTooltip())},this.onBlur=()=>{this.focused=!1,this.focusDescribed=!1,!this.hovering&&this.hideTooltip()},this.onClick=()=>{this.emit("lr-tool-call-chip-select",{name:this.name,callId:this.callId})}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusIncomplete:LYRA_DEFAULT_statusIncomplete,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}get status(){return this.statusValue}set status(next){const old=this.statusValue;this.statusValue=TOOL_CALL_CHIP_STATUS.normalizeReflected(this,"status",next),this.requestUpdate("status",old)}hasPreviewNodes(nodes){return nodes.some(node=>{if(node.nodeType===3)return!!node.textContent?.trim();if(node.nodeType!==1)return!1;const slotName=node.getAttribute("slot");return slotName===null||slotName===""})}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasDetailSlot=this.hasPreviewNodes(Array.from(this.childNodes)))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription()}syncExternalDescription(){const target=this.isConnected?this.baseEl??null:null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}updated(changed){if(super.updated(changed),this.syncExternalDescription(),changed.has("tooltipOpen")&&(this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOverlay?.deactivate({restoreFocus:!1}),this.tooltipOverlay=void 0,this.tooltipOpen)){const anchor=this.renderRoot.querySelector('[part="base"]'),tooltip=this.renderRoot.querySelector('[part="tooltip"]');anchor&&tooltip&&(this.cleanupPositioner=place(anchor,tooltip,{placement:"top-start",strategy:resolveEffectivePositioningStrategy(this,void 0,"fixed")}),this.tooltipOverlay=activateNonmodalOverlay({host:this,panel:()=>tooltip,onEscape:()=>this.hideTooltip(),restoreFocusTo:null}))}}disconnectedCallback(){super.disconnectedCallback(),this.releaseExternalDescription(),this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.tooltipOverlay?.deactivate({restoreFocus:!1}),this.tooltipOverlay=void 0,this.tooltipOpen=!1,this.hovering=!1,this.focused=!1,this.focusDescribed=!1}showTooltip(){!this.hasDetailSlot||this.tooltipOpen||(this.tooltipOpen=!0)}hideTooltip(){this.tooltipOpen&&(this.tooltipOpen=!1)}focus(options){this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}click(){this.baseEl?.click()}get safeDurationMs(){return safeDurationMs(this.durationMs)}get shownName(){return this.displayName||this.name||this.localize("toolCall")}get accessibleLabel(){const parts=[this.shownName];this.summary&&parts.push(this.summary),parts.push(this.localize(TOOL_STATUS_LABEL_KEY[this.status]));const durationMs=this.safeDurationMs;return durationMs!=null&&parts.push(this.localizedDuration(durationMs)),parts.join(this.localize("accessibleLabelSeparator"))}localizedDuration(ms){return formatShortDuration(this.localize.bind(this),this.effectiveLocale,ms)}render(){const hasCategory=(this.category??"").length>0,hasSummary=(this.summary??"").length>0,durationMs=this.safeDurationMs,hasDuration=durationMs!=null,status=this.status;return html`
2
2
  <button
3
3
  part="base"
4
4
  type="button"
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{emitValueEvents}from"../../../internal/value-events.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{nextId}from"../../../internal/a11y.js";import{resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{styles}from"./tool-param-form.styles.js";import{EMPTY_SCHEMA,MAX_ENUM_OPTIONS,MAX_SCHEMA_FIELDS,snapshotFormValue,snapshotSchema}from"./tool-param-snapshot.js";import{toolParamChoices,toolParamConstraintFailure,validToolParamConstraints}from"./tool-param-constraints.js";import"../../forms/select/select.class.js";import"../../forms/combobox/option.class.js";import"../../forms/input/number-input.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_fieldMustBeBoolean,LYRA_DEFAULT_fieldMustBeInteger,LYRA_DEFAULT_fieldMustBeNumber,LYRA_DEFAULT_fieldMustBeOneOf,LYRA_DEFAULT_fieldMustBeString,LYRA_DEFAULT_fieldMustEqual,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noData,LYRA_DEFAULT_schemaMustBeObject,LYRA_DEFAULT_schemaPropertiesMustBeFlat,LYRA_DEFAULT_toolParamBooleanFalse,LYRA_DEFAULT_toolParamBooleanTrue,LYRA_DEFAULT_toolParamBooleanUnset,LYRA_DEFAULT_toolParamFormat,LYRA_DEFAULT_toolParamInvalidConstraint,LYRA_DEFAULT_toolParamInvalidSelection,LYRA_DEFAULT_toolParamMaxItems,LYRA_DEFAULT_toolParamMaxLength,LYRA_DEFAULT_toolParamMaximum,LYRA_DEFAULT_toolParamMinItems,LYRA_DEFAULT_toolParamMinLength,LYRA_DEFAULT_toolParamMinimum,LYRA_DEFAULT_toolParamMissingProperty,LYRA_DEFAULT_toolParamSchemaLimit,LYRA_DEFAULT_unsupportedFieldType,LYRA_DEFAULT_valueMustBeSerializable}from"../../../internal/default-strings.generated.js";installFormControlLabelSupport();const MAX_LISTED_CHOICES=10;function sameErrors(left,right){const keys=Object.keys(left);return keys.length===Object.keys(right).length&&keys.every(key=>left[key]===right[key])}class LyraToolParamForm extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldMustBeBoolean:LYRA_DEFAULT_fieldMustBeBoolean,fieldMustBeInteger:LYRA_DEFAULT_fieldMustBeInteger,fieldMustBeNumber:LYRA_DEFAULT_fieldMustBeNumber,fieldMustBeOneOf:LYRA_DEFAULT_fieldMustBeOneOf,fieldMustBeString:LYRA_DEFAULT_fieldMustBeString,fieldMustEqual:LYRA_DEFAULT_fieldMustEqual,fieldRequired:LYRA_DEFAULT_fieldRequired,noData:LYRA_DEFAULT_noData,schemaMustBeObject:LYRA_DEFAULT_schemaMustBeObject,schemaPropertiesMustBeFlat:LYRA_DEFAULT_schemaPropertiesMustBeFlat,toolParamBooleanFalse:LYRA_DEFAULT_toolParamBooleanFalse,toolParamBooleanTrue:LYRA_DEFAULT_toolParamBooleanTrue,toolParamBooleanUnset:LYRA_DEFAULT_toolParamBooleanUnset,toolParamFormat:LYRA_DEFAULT_toolParamFormat,toolParamInvalidConstraint:LYRA_DEFAULT_toolParamInvalidConstraint,toolParamInvalidSelection:LYRA_DEFAULT_toolParamInvalidSelection,toolParamMaxItems:LYRA_DEFAULT_toolParamMaxItems,toolParamMaxLength:LYRA_DEFAULT_toolParamMaxLength,toolParamMaximum:LYRA_DEFAULT_toolParamMaximum,toolParamMinItems:LYRA_DEFAULT_toolParamMinItems,toolParamMinLength:LYRA_DEFAULT_toolParamMinLength,toolParamMinimum:LYRA_DEFAULT_toolParamMinimum,toolParamMissingProperty:LYRA_DEFAULT_toolParamMissingProperty,toolParamSchemaLimit:LYRA_DEFAULT_toolParamSchemaLimit,unsupportedFieldType:LYRA_DEFAULT_unsupportedFieldType,valueMustBeSerializable:LYRA_DEFAULT_valueMustBeSerializable}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-validity-change","lr-input","lr-change"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},schema:{attribute:!1,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}constructor(){super(),this._errors=Object.create(null),this._formError="",this.showFormError=!1,this.touchedFields=new Set,this.baseId=nextId("tool-param-form"),this._fieldsetDisabled=!1,this._name="",this._schema=EMPTY_SCHEMA,this.schemaInputShapeError="",this.schemaInputExceededLimits=!1,this._value=Object.freeze({}),this.lastSchemaInput=EMPTY_SCHEMA,this.lastValueInput=this._value,this.valueInputInvalid=!1,this.valueInputTruncated=!1,this.defaultValueSnapshot=Object.freeze({}),this.defaultValueCaptured=!1,this._effectiveValue=Object.freeze({}),this._validityFlags={},this._disabled=!1,this.hasInteracted=!1,this.visibleErrorSnapshot=new Map,this.suppressNextErrorAnnouncement=!0,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.syncValidityCustomStates())},this.onValueCommit=event=>{event.stopPropagation(),this.effectiveDisabled||emitValueEvents(this,"change",{value:this.effectiveValue},detail=>this.emit("lr-change",detail))},this.stopNestedControlEvent=e=>{e.stopPropagation()},this.onFieldFocus=event=>{relayNativeEvent(this,event)},this.onFieldBlur=event=>{relayNativeEvent(this,event)},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,this.syncFormState()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}[VALIDITY_ANCHOR](){const field=this.firstInvalidField();if(field){const input=field.querySelector("input.control");if(input)return input;for(const child of field.children){const anchor=resolveValidityAnchor(child);if(anchor)return anchor}}return this.firstMissingPropertyError()}firstInvalidField(){if(!this.renderRoot)return;const fields=Array.from(this.renderRoot.querySelectorAll('[part="field"]'));for(const key of Object.keys(this._errors)){const field=fields.find(candidate=>candidate.dataset.key===key);if(field)return field}}get missingRequiredKeys(){const properties=this.schemaProperties;return this.requiredKeys.filter(key=>!Object.prototype.hasOwnProperty.call(properties,key)&&!!this._errors[key])}firstMissingPropertyError(){if(!this.renderRoot)return;const errors=Array.from(this.renderRoot.querySelectorAll('[part="error"][data-missing-property]'));for(const key of Object.keys(this._errors)){const error=errors.find(candidate=>candidate.dataset.key===key);if(error)return error}}focusFirstControl(options){if(!this.renderRoot)return;const controls=this.renderRoot.querySelectorAll(`input.control, ${tag("select")}, ${tag("number-input")}`);for(const control of controls)if(!(control.disabled||control.getAttribute("aria-disabled")==="true")){control.focus(options);return}}click(){this.effectiveDisabled||this.focusFirstControl()}focus(options){this.effectiveDisabled||this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.isConnected?this.shadowRoot:null);active&&typeof active.blur=="function"&&active.blur()}connectedCallback(){this.defaultValueCaptured||(this.defaultValueSnapshot=this._value,this.defaultValueCaptured=!0),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()),this.syncFormState()}disconnectedCallback(){super.disconnectedCallback(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}get effectiveValue(){return this._effectiveValue}get schemaProperties(){return this._schema.properties}get requiredKeys(){return this._schema.required??Object.freeze([])}resolveEffectiveValue(){const props=this.schemaProperties,out={...this.value};for(const[key,prop]of Object.entries(props)){const fallback=prop.const!==void 0?prop.const:prop.default;!Object.prototype.hasOwnProperty.call(this.value,key)&&fallback!==void 0&&Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:fallback})}return snapshotFormValue(out).value}get schema(){return this._schema}set schema(next){if(next===this._schema||next===this.lastSchemaInput)return;this.lastSchemaInput=next;const old=this._schema,snapshot=snapshotSchema(next);this._schema=snapshot.schema,this.schemaInputShapeError=snapshot.shapeError,this.schemaInputExceededLimits=snapshot.exceededLimits,this.syncFormState(),this.requestUpdate("schema",old)}get value(){return this._value}set value(next){next===this._value||next===this.lastValueInput||(this.lastValueInput=next,this.applyValue(next))}applyValue(next){const old=this._value,snapshot=snapshotFormValue(next);this._value=snapshot.value,this.valueInputInvalid=snapshot.invalid,this.valueInputTruncated=snapshot.truncated,this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.applyValidity(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&(this.validityController.customValidityMessage||this._formError)&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}get formError(){return this._formError}selectionMessage(prop){const choices=prop.type==="string"?toolParamChoices(prop):void 0;return!choices||choices.length===0||choices.length>MAX_LISTED_CHOICES?this.localize("toolParamInvalidSelection"):this.localize("fieldMustBeOneOf",void 0,{values:getListFormat(this.effectiveLocale,{style:"long",type:"disjunction"}).format(choices.map(choice=>choice.label))})}computeValidation(effective){const props=this.schemaProperties,required=new Set(this.requiredKeys),out=Object.create(null),flags={},addError=(key,message)=>{Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:message})};for(const[key,prop]of Object.entries(props)){const type=prop?.type;if(type!=="string"&&type!=="number"&&type!=="integer"&&type!=="boolean"&&type!=="array"){addError(key,this.localize("unsupportedFieldType",void 0,{type:String(type)})),flags.customError=!0;continue}if(!validToolParamConstraints(prop)){addError(key,this.localize("toolParamInvalidConstraint")),flags.customError=!0;continue}if(!(Object.prototype.hasOwnProperty.call(effective,key)&&effective[key]!==void 0)){required.has(key)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);continue}const v=effective[key];if(type==="string"&&typeof v!="string"){addError(key,this.localize("fieldMustBeString")),flags.typeMismatch=!0;continue}if(type==="number"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeNumber")),flags.typeMismatch=!0;continue}if(type==="integer"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeInteger")),flags.typeMismatch=!0;continue}if(type==="integer"&&!Number.isInteger(v)){addError(key,this.localize("fieldMustBeInteger")),flags.stepMismatch=!0;continue}if(type==="boolean"&&typeof v!="boolean"){addError(key,this.localize("fieldMustBeBoolean")),flags.typeMismatch=!0;continue}const constraint=toolParamConstraintFailure(prop,v);if(constraint){const number=getNumberFormat(this.effectiveLocale),message=constraint==="minLength"?this.localize("toolParamMinLength",void 0,{count:number.format(prop.minLength)}):constraint==="maxLength"?this.localize("toolParamMaxLength",void 0,{count:number.format(prop.maxLength)}):constraint==="minimum"?this.localize("toolParamMinimum",void 0,{value:number.format(prop.minimum)}):constraint==="maximum"?this.localize("toolParamMaximum",void 0,{value:number.format(prop.maximum)}):constraint==="minItems"?this.localize("toolParamMinItems",void 0,{count:number.format(prop.minItems)}):constraint==="maxItems"?this.localize("toolParamMaxItems",void 0,{count:number.format(prop.maxItems)}):constraint==="format"?this.localize("toolParamFormat",void 0,{format:prop.format}):this.selectionMessage(prop);addError(key,message),flags.customError=!0;continue}prop.const!==void 0&&v!==prop.const&&(addError(key,this.localize("fieldMustEqual",void 0,{value:JSON.stringify(prop.const)})),flags.customError=!0)}for(const key of required)Object.prototype.hasOwnProperty.call(props,key)||(!Object.prototype.hasOwnProperty.call(effective,key)||effective[key]===void 0)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);return{errors:out,flags}}checkValidity(){return this.validityController.checkValidity(()=>this.syncFormState())}reportValidity(){this.validityController.syncConstraints(),this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this._formError&&(this.showFormError=!0),this.requestUpdate();const valid=this.internals.reportValidity();return!valid&&!this.firstInvalidField()&&this.missingRequiredKeys.length>0&&this.updateComplete.then(()=>{const error=this.firstMissingPropertyError();this.validityController.refreshAnchor(),error?.focus()}),valid}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.applyValue(this.defaultValueSnapshot),this.touchedFields=new Set,this.showFormError=!1}formStateRestoreCallback(state2,_mode){let restored={};if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=parsed)}catch{}this.applyValue(restored)}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.applyValidity(),this.requestUpdate())}schemaShapeError(){return this.schemaInputShapeError==="object"?this.localize("schemaMustBeObject"):this.schemaInputShapeError==="properties"?this.localize("schemaPropertiesMustBeFlat"):this.schemaInputExceededLimits?this.localize("toolParamSchemaLimit",void 0,{fields:getNumberFormat(this.effectiveLocale).format(MAX_SCHEMA_FIELDS),options:getNumberFormat(this.effectiveLocale).format(MAX_ENUM_OPTIONS)}):""}serializeEffectiveValue(effective){const serialized=JSON.stringify(effective,(_key,value)=>{if(typeof value=="number"&&!Number.isFinite(value))throw new TypeError("Non-finite numbers are not JSON values.");return value});if(typeof serialized!="string")throw new TypeError("Value did not serialize to JSON.");return serialized}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncInternals(formValue){this.internals.setFormValue(formValue,formValue),this.applyValidity()}applyValidity(){if(this.validityController){if(this.barredFromValidation||Object.keys(this._validityFlags).length===0)this.validityController.setValidity({});else{const firstMessage=Object.values(this._errors)[0]??this._formError;this.validityController.setValidity(this._validityFlags,firstMessage)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}}syncValidityCustomStates(){syncValidityStates(this.internals,{required:this.requiredKeys.length>0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}syncFormState(){let effective=Object.freeze({}),errors={},flags={},formError="",formValue=null;try{if(formError=this.schemaShapeError(),this.valueInputInvalid||this.valueInputTruncated)throw new TypeError("The value could not be retained within the public snapshot boundary.");effective=this.resolveEffectiveValue();const validation=this.computeValidation(effective);errors=validation.errors,flags=validation.flags,formValue=this.serializeEffectiveValue(effective)}catch{formError=this.localize("valueMustBeSerializable"),formValue=null}formError&&(flags.customError=!0,formValue=null),this._effectiveValue=effective,sameErrors(this._errors,errors)||(this._errors=errors),this._formError=formError,this._validityFlags=flags,this.syncInternals(formValue)}updated(changed){if(super.updated(changed),this.publishValiditySnapshot(),changed.has("value")||changed.has("schema")||changed.has("_errors")||changed.has("_formError")){const nestedUpdates=Array.from(this.firstInvalidField()?.children??[]).filter(element=>typeof element[VALIDITY_ANCHOR]=="function").map(element=>element.updateComplete).filter(update=>update!==void 0);nestedUpdates.length>0&&Promise.all(nestedUpdates).then(()=>this.validityController.refreshAnchor())}const currentErrors=this.visibleErrors();if(!this.suppressNextErrorAnnouncement){const freshMessages=[];for(const[key,text]of currentErrors)this.visibleErrorSnapshot.get(key)!==text&&!freshMessages.includes(text)&&freshMessages.push(text);freshMessages.length>0&&this.errorAnnouncementSink?.announce(freshMessages.join(" "))}this.visibleErrorSnapshot=currentErrors,this.suppressNextErrorAnnouncement=!1}visibleErrors(){const visible=new Map;for(const key of Object.keys(this.schemaProperties)){const message=this.touchedFields.has(key)?this._errors[key]:void 0;message&&visible.set(key,message)}for(const key of this.missingRequiredKeys)this.touchedFields.has(key)&&visible.set(key,this.localize("toolParamMissingProperty",void 0,{key}));return this.showFormError&&this._formError&&visible.set("form",this._formError),visible}setFieldValue(key,val,committed=!1){if(this.effectiveDisabled)return;this.hasInteracted=!0,this.applyValue({...this.value,[key]:val});const detail={value:this.effectiveValue};emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),committed&&emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2))}markTouched(key){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(key)&&(this.touchedFields=new Set(this.touchedFields).add(key))}onTextInput(key,e){e.stopPropagation(),this.setFieldValue(key,e.target.value)}onNumberInput(key,e){e.stopPropagation();const n=e.target.valueAsNumber;this.setFieldValue(key,Number.isNaN(n)?void 0:n)}onSelectChange(key,e){e.stopPropagation(),this.setFieldValue(key,e.target.value,!0)}onBooleanSelectChange(key,e){e.stopPropagation();const value=e.target.value;if(value===""){if(this.effectiveDisabled)return;if(this.hasInteracted=!0,this.schemaProperties[key]?.default!==void 0)this.applyValue({...this.value,[key]:void 0});else{const next={...this.value};Reflect.deleteProperty(next,key),this.applyValue(next)}const detail={value:this.effectiveValue};emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2));return}this.setFieldValue(key,value==="true",!0)}renderControl(key,prop,fieldId,label,required,describedBy,errorMessage,effective){const choices=toolParamChoices(prop);if((prop.type==="string"||prop.type==="array")&&choices&&choices.length>0)return html`<lr-select
1
+ import{__decorate}from"tslib";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{emitValueEvents}from"../../../internal/value-events.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{nextId}from"../../../internal/a11y.js";import{resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{styles}from"./tool-param-form.styles.js";import{EMPTY_SCHEMA,MAX_ENUM_OPTIONS,MAX_SCHEMA_FIELDS,snapshotFormValue,snapshotSchema}from"./tool-param-snapshot.js";import{toolParamChoices,toolParamConstraintFailure,validToolParamConstraints}from"./tool-param-constraints.js";import"../../forms/select/select.class.js";import"../../forms/combobox/option.class.js";import"../../forms/input/number-input.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_fieldMustBeBoolean,LYRA_DEFAULT_fieldMustBeInteger,LYRA_DEFAULT_fieldMustBeNumber,LYRA_DEFAULT_fieldMustBeOneOf,LYRA_DEFAULT_fieldMustBeString,LYRA_DEFAULT_fieldMustEqual,LYRA_DEFAULT_schemaMustBeObject,LYRA_DEFAULT_schemaPropertiesMustBeFlat,LYRA_DEFAULT_toolParamBooleanFalse,LYRA_DEFAULT_toolParamBooleanTrue,LYRA_DEFAULT_toolParamBooleanUnset,LYRA_DEFAULT_toolParamFormat,LYRA_DEFAULT_toolParamInvalidConstraint,LYRA_DEFAULT_toolParamInvalidSelection,LYRA_DEFAULT_toolParamMaxItems,LYRA_DEFAULT_toolParamMaxLength,LYRA_DEFAULT_toolParamMaximum,LYRA_DEFAULT_toolParamMinItems,LYRA_DEFAULT_toolParamMinLength,LYRA_DEFAULT_toolParamMinimum,LYRA_DEFAULT_toolParamMissingProperty,LYRA_DEFAULT_toolParamSchemaLimit,LYRA_DEFAULT_valueMustBeSerializable}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noData,LYRA_DEFAULT_unsupportedFieldType}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();const MAX_LISTED_CHOICES=10;function sameErrors(left,right){const keys=Object.keys(left);return keys.length===Object.keys(right).length&&keys.every(key=>left[key]===right[key])}class LyraToolParamForm extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldMustBeBoolean:LYRA_DEFAULT_fieldMustBeBoolean,fieldMustBeInteger:LYRA_DEFAULT_fieldMustBeInteger,fieldMustBeNumber:LYRA_DEFAULT_fieldMustBeNumber,fieldMustBeOneOf:LYRA_DEFAULT_fieldMustBeOneOf,fieldMustBeString:LYRA_DEFAULT_fieldMustBeString,fieldMustEqual:LYRA_DEFAULT_fieldMustEqual,fieldRequired:LYRA_DEFAULT_fieldRequired,noData:LYRA_DEFAULT_noData,schemaMustBeObject:LYRA_DEFAULT_schemaMustBeObject,schemaPropertiesMustBeFlat:LYRA_DEFAULT_schemaPropertiesMustBeFlat,toolParamBooleanFalse:LYRA_DEFAULT_toolParamBooleanFalse,toolParamBooleanTrue:LYRA_DEFAULT_toolParamBooleanTrue,toolParamBooleanUnset:LYRA_DEFAULT_toolParamBooleanUnset,toolParamFormat:LYRA_DEFAULT_toolParamFormat,toolParamInvalidConstraint:LYRA_DEFAULT_toolParamInvalidConstraint,toolParamInvalidSelection:LYRA_DEFAULT_toolParamInvalidSelection,toolParamMaxItems:LYRA_DEFAULT_toolParamMaxItems,toolParamMaxLength:LYRA_DEFAULT_toolParamMaxLength,toolParamMaximum:LYRA_DEFAULT_toolParamMaximum,toolParamMinItems:LYRA_DEFAULT_toolParamMinItems,toolParamMinLength:LYRA_DEFAULT_toolParamMinLength,toolParamMinimum:LYRA_DEFAULT_toolParamMinimum,toolParamMissingProperty:LYRA_DEFAULT_toolParamMissingProperty,toolParamSchemaLimit:LYRA_DEFAULT_toolParamSchemaLimit,unsupportedFieldType:LYRA_DEFAULT_unsupportedFieldType,valueMustBeSerializable:LYRA_DEFAULT_valueMustBeSerializable}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-validity-change","lr-input","lr-change"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},schema:{attribute:!1,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}constructor(){super(),this._errors=Object.create(null),this._formError="",this.showFormError=!1,this.touchedFields=new Set,this.baseId=nextId("tool-param-form"),this._fieldsetDisabled=!1,this._name="",this._schema=EMPTY_SCHEMA,this.schemaInputShapeError="",this.schemaInputExceededLimits=!1,this._value=Object.freeze({}),this.lastSchemaInput=EMPTY_SCHEMA,this.lastValueInput=this._value,this.valueInputInvalid=!1,this.valueInputTruncated=!1,this.defaultValueSnapshot=Object.freeze({}),this.defaultValueCaptured=!1,this._effectiveValue=Object.freeze({}),this._validityFlags={},this._disabled=!1,this.hasInteracted=!1,this.visibleErrorSnapshot=new Map,this.suppressNextErrorAnnouncement=!0,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.syncValidityCustomStates())},this.onValueCommit=event=>{event.stopPropagation(),this.effectiveDisabled||emitValueEvents(this,"change",{value:this.effectiveValue},detail=>this.emit("lr-change",detail))},this.stopNestedControlEvent=e=>{e.stopPropagation()},this.onFieldFocus=event=>{relayNativeEvent(this,event)},this.onFieldBlur=event=>{relayNativeEvent(this,event)},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,this.syncFormState()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}[VALIDITY_ANCHOR](){const field=this.firstInvalidField();if(field){const input=field.querySelector("input.control");if(input)return input;for(const child of field.children){const anchor=resolveValidityAnchor(child);if(anchor)return anchor}}return this.firstMissingPropertyError()}firstInvalidField(){if(!this.renderRoot)return;const fields=Array.from(this.renderRoot.querySelectorAll('[part="field"]'));for(const key of Object.keys(this._errors)){const field=fields.find(candidate=>candidate.dataset.key===key);if(field)return field}}get missingRequiredKeys(){const properties=this.schemaProperties;return this.requiredKeys.filter(key=>!Object.prototype.hasOwnProperty.call(properties,key)&&!!this._errors[key])}firstMissingPropertyError(){if(!this.renderRoot)return;const errors=Array.from(this.renderRoot.querySelectorAll('[part="error"][data-missing-property]'));for(const key of Object.keys(this._errors)){const error=errors.find(candidate=>candidate.dataset.key===key);if(error)return error}}focusFirstControl(options){if(!this.renderRoot)return;const controls=this.renderRoot.querySelectorAll(`input.control, ${tag("select")}, ${tag("number-input")}`);for(const control of controls)if(!(control.disabled||control.getAttribute("aria-disabled")==="true")){control.focus(options);return}}click(){this.effectiveDisabled||this.focusFirstControl()}focus(options){this.effectiveDisabled||this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.isConnected?this.shadowRoot:null);active&&typeof active.blur=="function"&&active.blur()}connectedCallback(){this.defaultValueCaptured||(this.defaultValueSnapshot=this._value,this.defaultValueCaptured=!0),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()),this.syncFormState()}disconnectedCallback(){super.disconnectedCallback(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}get effectiveValue(){return this._effectiveValue}get schemaProperties(){return this._schema.properties}get requiredKeys(){return this._schema.required??Object.freeze([])}resolveEffectiveValue(){const props=this.schemaProperties,out={...this.value};for(const[key,prop]of Object.entries(props)){const fallback=prop.const!==void 0?prop.const:prop.default;!Object.prototype.hasOwnProperty.call(this.value,key)&&fallback!==void 0&&Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:fallback})}return snapshotFormValue(out).value}get schema(){return this._schema}set schema(next){if(next===this._schema||next===this.lastSchemaInput)return;this.lastSchemaInput=next;const old=this._schema,snapshot=snapshotSchema(next);this._schema=snapshot.schema,this.schemaInputShapeError=snapshot.shapeError,this.schemaInputExceededLimits=snapshot.exceededLimits,this.syncFormState(),this.requestUpdate("schema",old)}get value(){return this._value}set value(next){next===this._value||next===this.lastValueInput||(this.lastValueInput=next,this.applyValue(next))}applyValue(next){const old=this._value,snapshot=snapshotFormValue(next);this._value=snapshot.value,this.valueInputInvalid=snapshot.invalid,this.valueInputTruncated=snapshot.truncated,this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.applyValidity(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&(this.validityController.customValidityMessage||this._formError)&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}get formError(){return this._formError}selectionMessage(prop){const choices=prop.type==="string"?toolParamChoices(prop):void 0;return!choices||choices.length===0||choices.length>MAX_LISTED_CHOICES?this.localize("toolParamInvalidSelection"):this.localize("fieldMustBeOneOf",void 0,{values:getListFormat(this.effectiveLocale,{style:"long",type:"disjunction"}).format(choices.map(choice=>choice.label))})}computeValidation(effective){const props=this.schemaProperties,required=new Set(this.requiredKeys),out=Object.create(null),flags={},addError=(key,message)=>{Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:message})};for(const[key,prop]of Object.entries(props)){const type=prop?.type;if(type!=="string"&&type!=="number"&&type!=="integer"&&type!=="boolean"&&type!=="array"){addError(key,this.localize("unsupportedFieldType",void 0,{type:String(type)})),flags.customError=!0;continue}if(!validToolParamConstraints(prop)){addError(key,this.localize("toolParamInvalidConstraint")),flags.customError=!0;continue}if(!(Object.prototype.hasOwnProperty.call(effective,key)&&effective[key]!==void 0)){required.has(key)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);continue}const v=effective[key];if(type==="string"&&typeof v!="string"){addError(key,this.localize("fieldMustBeString")),flags.typeMismatch=!0;continue}if(type==="number"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeNumber")),flags.typeMismatch=!0;continue}if(type==="integer"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeInteger")),flags.typeMismatch=!0;continue}if(type==="integer"&&!Number.isInteger(v)){addError(key,this.localize("fieldMustBeInteger")),flags.stepMismatch=!0;continue}if(type==="boolean"&&typeof v!="boolean"){addError(key,this.localize("fieldMustBeBoolean")),flags.typeMismatch=!0;continue}const constraint=toolParamConstraintFailure(prop,v);if(constraint){const number=getNumberFormat(this.effectiveLocale),message=constraint==="minLength"?this.localize("toolParamMinLength",void 0,{count:number.format(prop.minLength)}):constraint==="maxLength"?this.localize("toolParamMaxLength",void 0,{count:number.format(prop.maxLength)}):constraint==="minimum"?this.localize("toolParamMinimum",void 0,{value:number.format(prop.minimum)}):constraint==="maximum"?this.localize("toolParamMaximum",void 0,{value:number.format(prop.maximum)}):constraint==="minItems"?this.localize("toolParamMinItems",void 0,{count:number.format(prop.minItems)}):constraint==="maxItems"?this.localize("toolParamMaxItems",void 0,{count:number.format(prop.maxItems)}):constraint==="format"?this.localize("toolParamFormat",void 0,{format:prop.format}):this.selectionMessage(prop);addError(key,message),flags.customError=!0;continue}prop.const!==void 0&&v!==prop.const&&(addError(key,this.localize("fieldMustEqual",void 0,{value:JSON.stringify(prop.const)})),flags.customError=!0)}for(const key of required)Object.prototype.hasOwnProperty.call(props,key)||(!Object.prototype.hasOwnProperty.call(effective,key)||effective[key]===void 0)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);return{errors:out,flags}}checkValidity(){return this.validityController.checkValidity(()=>this.syncFormState())}reportValidity(){this.validityController.syncConstraints(),this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this._formError&&(this.showFormError=!0),this.requestUpdate();const valid=this.internals.reportValidity();return!valid&&!this.firstInvalidField()&&this.missingRequiredKeys.length>0&&this.updateComplete.then(()=>{const error=this.firstMissingPropertyError();this.validityController.refreshAnchor(),error?.focus()}),valid}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.applyValue(this.defaultValueSnapshot),this.touchedFields=new Set,this.showFormError=!1}formStateRestoreCallback(state2,_mode){let restored={};if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=parsed)}catch{}this.applyValue(restored)}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.applyValidity(),this.requestUpdate())}schemaShapeError(){return this.schemaInputShapeError==="object"?this.localize("schemaMustBeObject"):this.schemaInputShapeError==="properties"?this.localize("schemaPropertiesMustBeFlat"):this.schemaInputExceededLimits?this.localize("toolParamSchemaLimit",void 0,{fields:getNumberFormat(this.effectiveLocale).format(MAX_SCHEMA_FIELDS),options:getNumberFormat(this.effectiveLocale).format(MAX_ENUM_OPTIONS)}):""}serializeEffectiveValue(effective){const serialized=JSON.stringify(effective,(_key,value)=>{if(typeof value=="number"&&!Number.isFinite(value))throw new TypeError("Non-finite numbers are not JSON values.");return value});if(typeof serialized!="string")throw new TypeError("Value did not serialize to JSON.");return serialized}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncInternals(formValue){this.internals.setFormValue(formValue,formValue),this.applyValidity()}applyValidity(){if(this.validityController){if(this.barredFromValidation||Object.keys(this._validityFlags).length===0)this.validityController.setValidity({});else{const firstMessage=Object.values(this._errors)[0]??this._formError;this.validityController.setValidity(this._validityFlags,firstMessage)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}}syncValidityCustomStates(){syncValidityStates(this.internals,{required:this.requiredKeys.length>0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}syncFormState(){let effective=Object.freeze({}),errors={},flags={},formError="",formValue=null;try{if(formError=this.schemaShapeError(),this.valueInputInvalid||this.valueInputTruncated)throw new TypeError("The value could not be retained within the public snapshot boundary.");effective=this.resolveEffectiveValue();const validation=this.computeValidation(effective);errors=validation.errors,flags=validation.flags,formValue=this.serializeEffectiveValue(effective)}catch{formError=this.localize("valueMustBeSerializable"),formValue=null}formError&&(flags.customError=!0,formValue=null),this._effectiveValue=effective,sameErrors(this._errors,errors)||(this._errors=errors),this._formError=formError,this._validityFlags=flags,this.syncInternals(formValue)}updated(changed){if(super.updated(changed),this.publishValiditySnapshot(),changed.has("value")||changed.has("schema")||changed.has("_errors")||changed.has("_formError")){const nestedUpdates=Array.from(this.firstInvalidField()?.children??[]).filter(element=>typeof element[VALIDITY_ANCHOR]=="function").map(element=>element.updateComplete).filter(update=>update!==void 0);nestedUpdates.length>0&&Promise.all(nestedUpdates).then(()=>this.validityController.refreshAnchor())}const currentErrors=this.visibleErrors();if(!this.suppressNextErrorAnnouncement){const freshMessages=[];for(const[key,text]of currentErrors)this.visibleErrorSnapshot.get(key)!==text&&!freshMessages.includes(text)&&freshMessages.push(text);freshMessages.length>0&&this.errorAnnouncementSink?.announce(freshMessages.join(" "))}this.visibleErrorSnapshot=currentErrors,this.suppressNextErrorAnnouncement=!1}visibleErrors(){const visible=new Map;for(const key of Object.keys(this.schemaProperties)){const message=this.touchedFields.has(key)?this._errors[key]:void 0;message&&visible.set(key,message)}for(const key of this.missingRequiredKeys)this.touchedFields.has(key)&&visible.set(key,this.localize("toolParamMissingProperty",void 0,{key}));return this.showFormError&&this._formError&&visible.set("form",this._formError),visible}setFieldValue(key,val,committed=!1){if(this.effectiveDisabled)return;this.hasInteracted=!0,this.applyValue({...this.value,[key]:val});const detail={value:this.effectiveValue};emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),committed&&emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2))}markTouched(key){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(key)&&(this.touchedFields=new Set(this.touchedFields).add(key))}onTextInput(key,e){e.stopPropagation(),this.setFieldValue(key,e.target.value)}onNumberInput(key,e){e.stopPropagation();const n=e.target.valueAsNumber;this.setFieldValue(key,Number.isNaN(n)?void 0:n)}onSelectChange(key,e){e.stopPropagation(),this.setFieldValue(key,e.target.value,!0)}onBooleanSelectChange(key,e){e.stopPropagation();const value=e.target.value;if(value===""){if(this.effectiveDisabled)return;if(this.hasInteracted=!0,this.schemaProperties[key]?.default!==void 0)this.applyValue({...this.value,[key]:void 0});else{const next={...this.value};Reflect.deleteProperty(next,key),this.applyValue(next)}const detail={value:this.effectiveValue};emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2));return}this.setFieldValue(key,value==="true",!0)}renderControl(key,prop,fieldId,label,required,describedBy,errorMessage,effective){const choices=toolParamChoices(prop);if((prop.type==="string"||prop.type==="array")&&choices&&choices.length>0)return html`<lr-select
2
2
  id=${fieldId}
3
3
  .label=${label}
4
4
  .hint=${prop.description??""}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,svg,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId}from"../../../internal/a11y.js";import{closeIcon,expandIcon}from"../../../internal/icons.js";import{formatShortDuration,safeDurationMs}from"../../../internal/duration.js";import{TOOL_CALL_STATUSES,TOOL_STATUS_LABEL_KEY,toolGlyph,toolStatusIcon}from"../tool-status.js";import{literalSetConverter}from"../../../internal/converters.js";import{styles}from"./tool-result-dialog.styles.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_maximize,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings.generated.js";function shrinkIcon(){return toolGlyph(svg`
1
+ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,svg,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId}from"../../../internal/a11y.js";import{closeIcon,expandIcon}from"../../../internal/icons.js";import{formatShortDuration,safeDurationMs}from"../../../internal/duration.js";import{TOOL_CALL_STATUSES,TOOL_STATUS_LABEL_KEY,toolGlyph,toolStatusIcon}from"../tool-status.js";import{literalSetConverter}from"../../../internal/converters.js";import{styles}from"./tool-result-dialog.styles.js";import{LYRA_DEFAULT_maximize,LYRA_DEFAULT_toolCall}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess}from"../../../internal/default-strings/shared.generated.js";function shrinkIcon(){return toolGlyph(svg`
2
2
  <polyline points="4 14 10 14 10 20"></polyline>
3
3
  <polyline points="20 10 14 10 14 4"></polyline>
4
4
  <line x1="14" y1="10" x2="21" y2="3"></line>
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{findToolRenderer,getDefaultToolRendererRegistry,loadToolRenderer}from"./registry.js";import{styles}from"./tool-result-view.styles.js";import"../../overlays/skeleton/skeleton.class.js";import"../../utility/json-viewer/json-viewer.class.js";import"../../utility/copy-button/copy-button.class.js";import{LYRA_DEFAULT_loading,LYRA_DEFAULT_viewerSearchActiveMatch,LYRA_DEFAULT_viewerSearchMatchCount,LYRA_DEFAULT_viewerSearchNoMatches}from"../../../internal/default-strings.generated.js";const FALLBACK_STATE={kind:"fallback"};class LyraToolResultView extends LyraElement{constructor(){super(...arguments),this.toolName="",this._fallback="json",this.copyable=!1,this.status="success",this.renderState=FALLBACK_STATE,this.generation=0}static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading,viewerSearchActiveMatch:LYRA_DEFAULT_viewerSearchActiveMatch,viewerSearchMatchCount:LYRA_DEFAULT_viewerSearchMatchCount,viewerSearchNoMatches:LYRA_DEFAULT_viewerSearchNoMatches}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["registry"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.properties={fallback:{reflect:!0,noAccessor:!0}}}get fallback(){return this._fallback}set fallback(next){const old=this._fallback;this._fallback=next==="text"?"text":"json",this.requestUpdate("fallback",old)}willUpdate(changed){super.willUpdate(changed),(!this.hasUpdated||changed.has("toolName")||changed.has("result")||changed.has("args")||changed.has("registry"))&&this.resolve()}async resolve(){const generation=++this.generation;this.renderAttempt=void 0;const registry=this.registry??getDefaultToolRendererRegistry();let def;try{def=findToolRenderer(this.toolName,this.result,registry)}catch(error){this.fail(error);return}if(!def){this.fail(new Error(`<lr-tool-result-view>: no renderer registered for tool "${this.toolName}"`));return}if(def.load){if(this.resolvedLazy?.def===def){this.renderWith(this.resolvedLazy.resolved);return}this.renderState={kind:"loading"};let resolved;try{resolved=await loadToolRenderer(def)}catch(error){if(generation!==this.generation)return;this.fail(error);return}if(generation!==this.generation)return;this.resolvedLazy={def,resolved},this.renderWith(resolved);return}this.renderWith(def)}renderWith(def){const generation=this.generation,attempt=Symbol();this.renderAttempt=attempt,this.status="success";const context={reportStatus:status=>{generation!==this.generation||this.renderAttempt!==attempt||(this.status=status)}};try{const template=def.render(this.result,this.args,context);if(generation!==this.generation||this.renderAttempt!==attempt)return;this.renderState={kind:"rendered",template}}catch(error){if(generation!==this.generation||this.renderAttempt!==attempt)return;this.renderAttempt=void 0,this.fail(error)}}fail(error){this.emit("lr-render-error",{toolName:this.toolName,error}),this.status="success",this.renderState=FALLBACK_STATE}render(){const state2=this.renderState;return html`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{findToolRenderer,getDefaultToolRendererRegistry,loadToolRenderer}from"./registry.js";import{styles}from"./tool-result-view.styles.js";import"../../overlays/skeleton/skeleton.class.js";import"../../utility/json-viewer/json-viewer.class.js";import"../../utility/copy-button/copy-button.class.js";import{LYRA_DEFAULT_loading,LYRA_DEFAULT_viewerSearchActiveMatch,LYRA_DEFAULT_viewerSearchMatchCount,LYRA_DEFAULT_viewerSearchNoMatches}from"../../../internal/default-strings/shared.generated.js";const FALLBACK_STATE={kind:"fallback"};class LyraToolResultView extends LyraElement{constructor(){super(...arguments),this.toolName="",this._fallback="json",this.copyable=!1,this.status="success",this.renderState=FALLBACK_STATE,this.generation=0}static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading,viewerSearchActiveMatch:LYRA_DEFAULT_viewerSearchActiveMatch,viewerSearchMatchCount:LYRA_DEFAULT_viewerSearchMatchCount,viewerSearchNoMatches:LYRA_DEFAULT_viewerSearchNoMatches}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["registry"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.properties={fallback:{reflect:!0,noAccessor:!0}}}get fallback(){return this._fallback}set fallback(next){const old=this._fallback;this._fallback=next==="text"?"text":"json",this.requestUpdate("fallback",old)}willUpdate(changed){super.willUpdate(changed),(!this.hasUpdated||changed.has("toolName")||changed.has("result")||changed.has("args")||changed.has("registry"))&&this.resolve()}async resolve(){const generation=++this.generation;this.renderAttempt=void 0;const registry=this.registry??getDefaultToolRendererRegistry();let def;try{def=findToolRenderer(this.toolName,this.result,registry)}catch(error){this.fail(error);return}if(!def){this.fail(new Error(`<lr-tool-result-view>: no renderer registered for tool "${this.toolName}"`));return}if(def.load){if(this.resolvedLazy?.def===def){this.renderWith(this.resolvedLazy.resolved);return}this.renderState={kind:"loading"};let resolved;try{resolved=await loadToolRenderer(def)}catch(error){if(generation!==this.generation)return;this.fail(error);return}if(generation!==this.generation)return;this.resolvedLazy={def,resolved},this.renderWith(resolved);return}this.renderWith(def)}renderWith(def){const generation=this.generation,attempt=Symbol();this.renderAttempt=attempt,this.status="success";const context={reportStatus:status=>{generation!==this.generation||this.renderAttempt!==attempt||(this.status=status)}};try{const template=def.render(this.result,this.args,context);if(generation!==this.generation||this.renderAttempt!==attempt)return;this.renderState={kind:"rendered",template}}catch(error){if(generation!==this.generation||this.renderAttempt!==attempt)return;this.renderAttempt=void 0,this.fail(error)}}fail(error){this.emit("lr-render-error",{toolName:this.toolName,error}),this.status="success",this.renderState=FALLBACK_STATE}render(){const state2=this.renderState;return html`
2
2
  <div part="base" aria-busy=${state2.kind==="loading"?"true":"false"}>
3
3
  ${state2.kind==="loading"?html`
4
4
  <span class="sr-only">${this.localize("loading")}</span>
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{live}from"lit/directives/live.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR,getOwnDataDescriptor}from"../../../internal/data-descriptors.js";import{styles}from"./tool-select-dialog.styles.js";import"../../forms/checkbox/checkbox.class.js";import"../../forms/switch/switch.class.js";import{trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{closeIcon}from"../../../internal/icons.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_noMatchesQuery,LYRA_DEFAULT_otherCategory,LYRA_DEFAULT_searchToolsPlaceholder,LYRA_DEFAULT_selectTools,LYRA_DEFAULT_toolCount,LYRA_DEFAULT_toolSelectCustomizeHint,LYRA_DEFAULT_toolSelectLimit,LYRA_DEFAULT_toolSelectNoneAvailable,LYRA_DEFAULT_toolSelectSummary,LYRA_DEFAULT_useDefaultTools}from"../../../internal/default-strings.generated.js";const UNCATEGORIZED=null,MAX_RENDERED_TOOLS=200,MAX_NORMALIZED_TOOL_ENTRIES=1e4,FUNCTION_TO_STRING=Function.prototype.toString,OBJECT_CONSTRUCTOR_SOURCE=FUNCTION_TO_STRING.call(Object);function isRuntimeArray(value){try{return Array.isArray(value)}catch{return!1}}function ownDataArrayValues(value,limit){if(!isRuntimeArray(value))return[];const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return[];const values=[];for(let index=0;index<Math.min(length.value,limit);index+=1){const entry=getOwnDataDescriptor(value,String(index));entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR||values.push(entry.value)}return values}function isPlainToolRecord(value){if(value===null||typeof value!="object")return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype&&FUNCTION_TO_STRING.call(constructor.value)===OBJECT_CONSTRUCTOR_SOURCE}catch{return!1}}function requiredToolString(record,key){const value=getOwnDataDescriptor(record,key);if(!(value===MISSING_OWN_DATA_DESCRIPTOR||value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"||value.value.trim().length===0))return value.value}function optionalToolString(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"?null:value.value}function optionalToolBoolean(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="boolean"?null:value.value}function canonicalTool(value){if(!isPlainToolRecord(value))return;const id=requiredToolString(value,"id"),name=requiredToolString(value,"name"),description=optionalToolString(value,"description"),category=optionalToolString(value,"category"),icon=optionalToolString(value,"icon"),disabled=optionalToolBoolean(value,"disabled"),disabledReason=optionalToolString(value,"disabledReason");if(!(id===void 0||name===void 0||description===null||category===null||icon===null||disabled===null||disabledReason===null))return Object.freeze({id,name,...description===void 0?{}:{description},...category===void 0?{}:{category},...icon===void 0?{}:{icon},...disabled===void 0?{}:{disabled},...disabledReason===void 0?{}:{disabledReason}})}function projectCanonicalTools(input){const tools=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES)){const tool=canonicalTool(entry);!tool||seen.has(tool.id)||(seen.add(tool.id),tools.push(tool))}return Object.freeze(tools)}function projectCanonicalSelectedToolIds(input){const ids=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES))typeof entry!="string"||entry.trim().length===0||seen.has(entry)||(seen.add(entry),ids.push(entry));return Object.freeze(ids)}function defaultFilter(tool,query,locale){const intlLocale=resolveIntlLocale(locale);return tool.name.toLocaleLowerCase(intlLocale).includes(query)||(tool.description??"").toLocaleLowerCase(intlLocale).includes(query)}class LyraToolSelectDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.lightDismiss=!1,this.tools=[],this.selectedToolIds=[],this.useDefaults=!1,this.accessibleLabel=null,this.autocomplete="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.inputMode="",this.enterKeyHint="",this.filter=null,this.query="",this.hasFooterSlot=!1,this.renderedToolLimit=MAX_RENDERED_TOOLS,this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{!this.open||!this.overlay?.isTopmost()||this.close("escape")},onUnexpectedClose:()=>{this.open&&(this.nativeModal.hide(),this.close("api"))}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal),this.titleId=nextId("tool-select-dialog-title"),this.categoryIds=new Map,this.onFooterSlotChange=()=>{this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.changeRequestPending=!1,this.onSearchInput=e=>{this.query=e.target.value,this.renderedToolLimit=MAX_RENDERED_TOOLS,e.stopPropagation()},this.onSearchFocus=event=>{relayNativeEvent(this,event)},this.onSearchBlur=event=>{relayNativeEvent(this,event)},this.onClearSearch=()=>{this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS,this.renderRoot.querySelector('[part="search-input"]')?.focus()},this.stopNestedControlEvent=event=>{event.stopPropagation()},this.onDefaultsToggleRequest=e=>{e.stopPropagation();const next={selectedToolIds:this.canonicalSelectedToolIds,useDefaults:e.detail.checked};if(!this.requestChange(next)){e.preventDefault();return}this.useDefaults=next.useDefaults,this.emit("lr-change",next)},this.onLoadMore=()=>{this.renderedToolLimit+=MAX_RENDERED_TOOLS,this.updateComplete.then(()=>{if(!this.isConnected||!this.open)return;(this.shadowRoot?.querySelector('[part="load-more"]')??this.shadowRoot?.querySelector('[part="body"]'))?.focus()})}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,fieldRequired:LYRA_DEFAULT_fieldRequired,loadMore:LYRA_DEFAULT_loadMore,noMatchesQuery:LYRA_DEFAULT_noMatchesQuery,otherCategory:LYRA_DEFAULT_otherCategory,searchToolsPlaceholder:LYRA_DEFAULT_searchToolsPlaceholder,selectTools:LYRA_DEFAULT_selectTools,toolCount:LYRA_DEFAULT_toolCount,toolSelectCustomizeHint:LYRA_DEFAULT_toolSelectCustomizeHint,toolSelectLimit:LYRA_DEFAULT_toolSelectLimit,toolSelectNoneAvailable:LYRA_DEFAULT_toolSelectNoneAvailable,toolSelectSummary:LYRA_DEFAULT_toolSelectSummary,useDefaultTools:LYRA_DEFAULT_useDefaultTools}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["tools","selectedToolIds"])}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-change-request","lr-change"])}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("tools")&&(this.canonicalToolsCache=void 0,this.renderedToolLimit=MAX_RENDERED_TOOLS),changed.has("selectedToolIds")&&(this.canonicalSelectedToolIdsCache=void 0,this.canonicalSelectedToolIdsSource=void 0),changed.has("open"))if(this.open)this.renderedWindow=void 0,this.modalSurface.open(()=>this.activateOverlay());else{const hadOverlay=this.overlay!==void 0;this.modalSurface.close(hadOverlay,()=>{this.overlay?.deactivate(),this.overlay=void 0},()=>!this.open),this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS}}updated(changed){super.updated(changed),this.open&&this.enterTopLayer(),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.modalSurface.prepare(),this.requestUpdate(),this.activateOverlay(),this.overlay?.focusInitial(),this.updateComplete.then(()=>{!this.open||!this.isConnected||(this.enterTopLayer(),this.overlay?.focusInitial())}))}enterTopLayer(){this.modalSurface.show()}disconnectedCallback(){super.disconnectedCallback(),this.modalSurface.disconnect(),this.overlay?.suspend()}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>{this.lightDismiss&&this.close("backdrop")},lockScroll:!0,suspendWhenUnrendered:!0})}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",{reason}))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}requestChange(next){if(this.changeRequestPending)return!1;const selected=this.selectedToolIds,defaults=this.useDefaults,tools=this.tools;this.changeRequestPending=!0;try{return!this.emit("lr-change-request",{selectedToolIds:[...next.selectedToolIds],useDefaults:next.useDefaults},{cancelable:!0}).defaultPrevented&&this.selectedToolIds===selected&&this.useDefaults===defaults&&this.tools===tools}finally{this.changeRequestPending=!1}}onToolToggleRequest(tool,e){if(e.stopPropagation(),tool.disabled||this.useDefaults){e.preventDefault();return}const selected=this.canonicalSelectedToolIds,index=selected.indexOf(tool.id),next={selectedToolIds:e.detail.checked?index>=0?selected:[...selected.slice(0,MAX_NORMALIZED_TOOL_ENTRIES-1),tool.id]:index<0?selected:[...selected.slice(0,index),...selected.slice(index+1)],useDefaults:this.useDefaults};if(!this.requestChange(next)){e.preventDefault();return}this.selectedToolIds=next.selectedToolIds,this.canonicalSelectedToolIdsCache=next.selectedToolIds,this.canonicalSelectedToolIdsSource=this.selectedToolIds,this.emit("lr-change",next)}categoryId(category){let id=this.categoryIds.get(category);return id||(id=nextId("tool-select-dialog-category"),this.categoryIds.set(category,id)),id}get canonicalTools(){return this.canonicalToolsCache||(this.canonicalToolsCache=projectCanonicalTools(this.tools)),this.canonicalToolsCache}get canonicalSelectedToolIds(){const source=this.selectedToolIds;return(this.canonicalSelectedToolIdsCache===void 0||this.canonicalSelectedToolIdsSource!==source)&&(this.canonicalSelectedToolIdsCache=projectCanonicalSelectedToolIds(source),this.canonicalSelectedToolIdsSource=source),this.canonicalSelectedToolIdsCache}get projection(){const order=[],byCategory=new Map;for(const tool of this.canonicalTools){const category=tool.category?.trim()||UNCATEGORIZED;let bucket=byCategory.get(category);bucket||(bucket=[],byCategory.set(category,bucket),category!==UNCATEGORIZED&&order.push(category)),bucket.push(tool)}byCategory.has(UNCATEGORIZED)&&order.push(UNCATEGORIZED);const q=this.query.trim().toLocaleLowerCase(this.effectiveLocale),filter=typeof this.filter=="function"?this.filter:null,matches=q?tool=>{if(!filter)return defaultFilter(tool,q,this.effectiveLocale);try{return!!filter(tool,q)}catch{return!1}}:()=>!0,matchingGroups=order.map(category=>({category,tools:byCategory.get(category).filter(matches)})).filter(group=>group.tools.length>0),totalMatches=matchingGroups.reduce((total,group)=>total+group.tools.length,0),selectedIds=new Set(this.canonicalSelectedToolIds),chosenIds=new Set,previous=this.renderedWindow,kept=previous&&previous.tools===this.canonicalTools&&previous.query===q?previous.ids:null;if(kept)for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;kept.has(tool.id)&&chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;selectedIds.has(tool.id)&&chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}this.renderedWindow={tools:this.canonicalTools,query:q,ids:chosenIds};const groups=matchingGroups.map(group=>({category:group.category,tools:group.tools.filter(tool=>chosenIds.has(tool.id))})).filter(group=>group.tools.length>0),renderedCount=chosenIds.size;return{groups,renderedCount,totalMatches,truncated:renderedCount<totalMatches}}renderTool(tool,selectedIds){const rowDisabled=!!tool.disabled||this.useDefaults;return html`
1
+ import{__decorate}from"tslib";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{live}from"lit/directives/live.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR,getOwnDataDescriptor}from"../../../internal/data-descriptors.js";import{styles}from"./tool-select-dialog.styles.js";import"../../forms/checkbox/checkbox.class.js";import"../../forms/switch/switch.class.js";import{trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{closeIcon}from"../../../internal/icons.js";import{LYRA_DEFAULT_noMatchesQuery,LYRA_DEFAULT_otherCategory,LYRA_DEFAULT_searchToolsPlaceholder,LYRA_DEFAULT_selectTools,LYRA_DEFAULT_toolCount,LYRA_DEFAULT_toolSelectCustomizeHint,LYRA_DEFAULT_toolSelectLimit,LYRA_DEFAULT_toolSelectNoneAvailable,LYRA_DEFAULT_toolSelectSummary,LYRA_DEFAULT_useDefaultTools}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loadMore}from"../../../internal/default-strings/shared.generated.js";const UNCATEGORIZED=null,MAX_RENDERED_TOOLS=200,MAX_NORMALIZED_TOOL_ENTRIES=1e4,FUNCTION_TO_STRING=Function.prototype.toString,OBJECT_CONSTRUCTOR_SOURCE=FUNCTION_TO_STRING.call(Object);function isRuntimeArray(value){try{return Array.isArray(value)}catch{return!1}}function ownDataArrayValues(value,limit){if(!isRuntimeArray(value))return[];const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return[];const values=[];for(let index=0;index<Math.min(length.value,limit);index+=1){const entry=getOwnDataDescriptor(value,String(index));entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR||values.push(entry.value)}return values}function isPlainToolRecord(value){if(value===null||typeof value!="object")return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype&&FUNCTION_TO_STRING.call(constructor.value)===OBJECT_CONSTRUCTOR_SOURCE}catch{return!1}}function requiredToolString(record,key){const value=getOwnDataDescriptor(record,key);if(!(value===MISSING_OWN_DATA_DESCRIPTOR||value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"||value.value.trim().length===0))return value.value}function optionalToolString(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"?null:value.value}function optionalToolBoolean(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="boolean"?null:value.value}function canonicalTool(value){if(!isPlainToolRecord(value))return;const id=requiredToolString(value,"id"),name=requiredToolString(value,"name"),description=optionalToolString(value,"description"),category=optionalToolString(value,"category"),icon=optionalToolString(value,"icon"),disabled=optionalToolBoolean(value,"disabled"),disabledReason=optionalToolString(value,"disabledReason");if(!(id===void 0||name===void 0||description===null||category===null||icon===null||disabled===null||disabledReason===null))return Object.freeze({id,name,...description===void 0?{}:{description},...category===void 0?{}:{category},...icon===void 0?{}:{icon},...disabled===void 0?{}:{disabled},...disabledReason===void 0?{}:{disabledReason}})}function projectCanonicalTools(input){const tools=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES)){const tool=canonicalTool(entry);!tool||seen.has(tool.id)||(seen.add(tool.id),tools.push(tool))}return Object.freeze(tools)}function projectCanonicalSelectedToolIds(input){const ids=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES))typeof entry!="string"||entry.trim().length===0||seen.has(entry)||(seen.add(entry),ids.push(entry));return Object.freeze(ids)}function defaultFilter(tool,query,locale){const intlLocale=resolveIntlLocale(locale);return tool.name.toLocaleLowerCase(intlLocale).includes(query)||(tool.description??"").toLocaleLowerCase(intlLocale).includes(query)}class LyraToolSelectDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.lightDismiss=!1,this.tools=[],this.selectedToolIds=[],this.useDefaults=!1,this.accessibleLabel=null,this.autocomplete="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.inputMode="",this.enterKeyHint="",this.filter=null,this.query="",this.hasFooterSlot=!1,this.renderedToolLimit=MAX_RENDERED_TOOLS,this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{!this.open||!this.overlay?.isTopmost()||this.close("escape")},onUnexpectedClose:()=>{this.open&&(this.nativeModal.hide(),this.close("api"))}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal),this.titleId=nextId("tool-select-dialog-title"),this.categoryIds=new Map,this.onFooterSlotChange=()=>{this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.changeRequestPending=!1,this.onSearchInput=e=>{this.query=e.target.value,this.renderedToolLimit=MAX_RENDERED_TOOLS,e.stopPropagation()},this.onSearchFocus=event=>{relayNativeEvent(this,event)},this.onSearchBlur=event=>{relayNativeEvent(this,event)},this.onClearSearch=()=>{this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS,this.renderRoot.querySelector('[part="search-input"]')?.focus()},this.stopNestedControlEvent=event=>{event.stopPropagation()},this.onDefaultsToggleRequest=e=>{e.stopPropagation();const next={selectedToolIds:this.canonicalSelectedToolIds,useDefaults:e.detail.checked};if(!this.requestChange(next)){e.preventDefault();return}this.useDefaults=next.useDefaults,this.emit("lr-change",next)},this.onLoadMore=()=>{this.renderedToolLimit+=MAX_RENDERED_TOOLS,this.updateComplete.then(()=>{if(!this.isConnected||!this.open)return;(this.shadowRoot?.querySelector('[part="load-more"]')??this.shadowRoot?.querySelector('[part="body"]'))?.focus()})}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,fieldRequired:LYRA_DEFAULT_fieldRequired,loadMore:LYRA_DEFAULT_loadMore,noMatchesQuery:LYRA_DEFAULT_noMatchesQuery,otherCategory:LYRA_DEFAULT_otherCategory,searchToolsPlaceholder:LYRA_DEFAULT_searchToolsPlaceholder,selectTools:LYRA_DEFAULT_selectTools,toolCount:LYRA_DEFAULT_toolCount,toolSelectCustomizeHint:LYRA_DEFAULT_toolSelectCustomizeHint,toolSelectLimit:LYRA_DEFAULT_toolSelectLimit,toolSelectNoneAvailable:LYRA_DEFAULT_toolSelectNoneAvailable,toolSelectSummary:LYRA_DEFAULT_toolSelectSummary,useDefaultTools:LYRA_DEFAULT_useDefaultTools}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["tools","selectedToolIds"])}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-change-request","lr-change"])}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("tools")&&(this.canonicalToolsCache=void 0,this.renderedToolLimit=MAX_RENDERED_TOOLS),changed.has("selectedToolIds")&&(this.canonicalSelectedToolIdsCache=void 0,this.canonicalSelectedToolIdsSource=void 0),changed.has("open"))if(this.open)this.renderedWindow=void 0,this.modalSurface.open(()=>this.activateOverlay());else{const hadOverlay=this.overlay!==void 0;this.modalSurface.close(hadOverlay,()=>{this.overlay?.deactivate(),this.overlay=void 0},()=>!this.open),this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS}}updated(changed){super.updated(changed),this.open&&this.enterTopLayer(),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.modalSurface.prepare(),this.requestUpdate(),this.activateOverlay(),this.overlay?.focusInitial(),this.updateComplete.then(()=>{!this.open||!this.isConnected||(this.enterTopLayer(),this.overlay?.focusInitial())}))}enterTopLayer(){this.modalSurface.show()}disconnectedCallback(){super.disconnectedCallback(),this.modalSurface.disconnect(),this.overlay?.suspend()}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>{this.lightDismiss&&this.close("backdrop")},lockScroll:!0,suspendWhenUnrendered:!0})}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",{reason}))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}requestChange(next){if(this.changeRequestPending)return!1;const selected=this.selectedToolIds,defaults=this.useDefaults,tools=this.tools;this.changeRequestPending=!0;try{return!this.emit("lr-change-request",{selectedToolIds:[...next.selectedToolIds],useDefaults:next.useDefaults},{cancelable:!0}).defaultPrevented&&this.selectedToolIds===selected&&this.useDefaults===defaults&&this.tools===tools}finally{this.changeRequestPending=!1}}onToolToggleRequest(tool,e){if(e.stopPropagation(),tool.disabled||this.useDefaults){e.preventDefault();return}const selected=this.canonicalSelectedToolIds,index=selected.indexOf(tool.id),next={selectedToolIds:e.detail.checked?index>=0?selected:[...selected.slice(0,MAX_NORMALIZED_TOOL_ENTRIES-1),tool.id]:index<0?selected:[...selected.slice(0,index),...selected.slice(index+1)],useDefaults:this.useDefaults};if(!this.requestChange(next)){e.preventDefault();return}this.selectedToolIds=next.selectedToolIds,this.canonicalSelectedToolIdsCache=next.selectedToolIds,this.canonicalSelectedToolIdsSource=this.selectedToolIds,this.emit("lr-change",next)}categoryId(category){let id=this.categoryIds.get(category);return id||(id=nextId("tool-select-dialog-category"),this.categoryIds.set(category,id)),id}get canonicalTools(){return this.canonicalToolsCache||(this.canonicalToolsCache=projectCanonicalTools(this.tools)),this.canonicalToolsCache}get canonicalSelectedToolIds(){const source=this.selectedToolIds;return(this.canonicalSelectedToolIdsCache===void 0||this.canonicalSelectedToolIdsSource!==source)&&(this.canonicalSelectedToolIdsCache=projectCanonicalSelectedToolIds(source),this.canonicalSelectedToolIdsSource=source),this.canonicalSelectedToolIdsCache}get projection(){const order=[],byCategory=new Map;for(const tool of this.canonicalTools){const category=tool.category?.trim()||UNCATEGORIZED;let bucket=byCategory.get(category);bucket||(bucket=[],byCategory.set(category,bucket),category!==UNCATEGORIZED&&order.push(category)),bucket.push(tool)}byCategory.has(UNCATEGORIZED)&&order.push(UNCATEGORIZED);const q=this.query.trim().toLocaleLowerCase(this.effectiveLocale),filter=typeof this.filter=="function"?this.filter:null,matches=q?tool=>{if(!filter)return defaultFilter(tool,q,this.effectiveLocale);try{return!!filter(tool,q)}catch{return!1}}:()=>!0,matchingGroups=order.map(category=>({category,tools:byCategory.get(category).filter(matches)})).filter(group=>group.tools.length>0),totalMatches=matchingGroups.reduce((total,group)=>total+group.tools.length,0),selectedIds=new Set(this.canonicalSelectedToolIds),chosenIds=new Set,previous=this.renderedWindow,kept=previous&&previous.tools===this.canonicalTools&&previous.query===q?previous.ids:null;if(kept)for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;kept.has(tool.id)&&chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;selectedIds.has(tool.id)&&chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}this.renderedWindow={tools:this.canonicalTools,query:q,ids:chosenIds};const groups=matchingGroups.map(group=>({category:group.category,tools:group.tools.filter(tool=>chosenIds.has(tool.id))})).filter(group=>group.tools.length>0),renderedCount=chosenIds.size;return{groups,renderedCount,totalMatches,truncated:renderedCount<totalMatches}}renderTool(tool,selectedIds){const rowDisabled=!!tool.disabled||this.useDefaults;return html`
2
2
  <li part="tool-row" ?data-disabled=${rowDisabled}>
3
3
  <lr-checkbox
4
4
  part="tool-checkbox"
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{formatTimeOfDay,getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{eyeOffIcon}from"../../../internal/icons.js";import{srOnly}from"../../../internal/a11y.js";import{styles}from"./tool-timeline.styles.js";import{overallSemanticLabel}from"../semantic-owner.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{TOOL_CALL_STATUSES}from"../tool-status.js";import{EMPTY_REDACTION_PATHS,projectedRedactionFields,redactToolDetail}from"../tool-redaction.js";import{LYRA_DEFAULT_confirmApproved,LYRA_DEFAULT_confirmDenied,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_noData,LYRA_DEFAULT_retry,LYRA_DEFAULT_toolTimelineDetailsFor,LYRA_DEFAULT_toolTimelineLimit}from"../../../internal/default-strings.generated.js";let resultViewRegistration,approvalDialogRegistration;const MAX_RENDERED_ENTRIES=500,TOOL_STATUSES=new Set(TOOL_CALL_STATUSES);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectToolTimelineEntry(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),nameDescriptor=descriptorValue(value,"name"),displayNameDescriptor=descriptorValue(value,"displayName"),argsDescriptor=descriptorValue(value,"args"),statusDescriptor=descriptorValue(value,"status"),resultDescriptor=descriptorValue(value,"result"),errorDescriptor=descriptorValue(value,"error"),sourceKeyDescriptor=descriptorValue(value,"sourceKey"),iconDescriptor=descriptorValue(value,"icon"),startedAtDescriptor=descriptorValue(value,"startedAt"),endedAtDescriptor=descriptorValue(value,"endedAt"),retryCountDescriptor=descriptorValue(value,"retryCount"),redactedFieldsDescriptor=descriptorValue(value,"redactedFields"),needsApprovalDescriptor=descriptorValue(value,"needsApproval"),approvedDescriptor=descriptorValue(value,"approved");if([idDescriptor,nameDescriptor,displayNameDescriptor,argsDescriptor,statusDescriptor,resultDescriptor,errorDescriptor,sourceKeyDescriptor,iconDescriptor,startedAtDescriptor,endedAtDescriptor,retryCountDescriptor,redactedFieldsDescriptor,needsApprovalDescriptor,approvedDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const valueOf=descriptor=>{if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return descriptor.value},id=valueOf(idDescriptor);if(typeof id!="string"||id.trim().length===0)return;const redactedFieldsValue=valueOf(redactedFieldsDescriptor),redactedFields=redactedFieldsValue===void 0?EMPTY_REDACTION_PATHS:projectedRedactionFields(redactedFieldsValue);if(redactedFields===void 0)return;const name=valueOf(nameDescriptor),displayName=valueOf(displayNameDescriptor),status=valueOf(statusDescriptor),result=valueOf(resultDescriptor),error=valueOf(errorDescriptor),sourceKey=valueOf(sourceKeyDescriptor),icon=valueOf(iconDescriptor),startedAt=valueOf(startedAtDescriptor),endedAt=valueOf(endedAtDescriptor),retryCount=valueOf(retryCountDescriptor),needsApproval=valueOf(needsApprovalDescriptor),approved=valueOf(approvedDescriptor);return Object.freeze({source:value,id,name:typeof name=="string"?name:"",...typeof displayName=="string"?{displayName}:{},args:valueOf(argsDescriptor),status:TOOL_STATUSES.has(status)?status:"pending",...result===void 0?{}:{result},...typeof error=="string"?{error}:{},...typeof sourceKey=="string"?{sourceKey}:{},...typeof icon=="string"?{icon}:{},...typeof startedAt=="number"?{startedAt}:{},...typeof endedAt=="number"?{endedAt}:{},...typeof retryCount=="number"?{retryCount}:{},redactedFields,...typeof needsApproval=="boolean"?{needsApproval}:{},...typeof approved=="boolean"?{approved}:{}})}catch{return}}function entrySourceKey(entry){return entry.sourceKey?.trim()?entry.sourceKey:void 0}function entryIdentity(entry){return JSON.stringify([entrySourceKey(entry)??null,entry.id])}function entryCorrelation(entry){const sourceKey=entrySourceKey(entry);return sourceKey===void 0?{invocationId:entry.id}:{invocationId:entry.id,sourceKey}}class LyraToolTimeline extends LyraElement{constructor(){super(...arguments),this.entries=[],this.approvalReadonly=!1,this.approvalPending=null,this.openedEntryIds=new Set,this.projectedEntriesCache=[],this.sortedEntriesCache=[],this.projectionTruncated=!1,this.redactionCache=new WeakMap,this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.decisionDispatching=!1,this.onDialogApprove=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!0,args:event.detail.args}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="approve",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogDeny=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!1}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="deny",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogClose=event=>{event.stopPropagation(),this.approvalPending=null,this.reviewingEntryKey=void 0}}static{this.defaultStrings={...super.defaultStrings,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmDenied:LYRA_DEFAULT_confirmDenied,envListValueHidden:LYRA_DEFAULT_envListValueHidden,noData:LYRA_DEFAULT_noData,retry:LYRA_DEFAULT_retry,toolTimelineDetailsFor:LYRA_DEFAULT_toolTimelineDetailsFor,toolTimelineLimit:LYRA_DEFAULT_toolTimelineLimit}}emitToolApprovalDecideRequest(detail){return this.emit("lr-tool-approval-decide-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entries"])}static{this.identityCollectionProperties=Object.freeze(["entries"])}static{this.styles=[LyraElement.styles,styles,srOnly]}connectedCallback(){super.connectedCallback(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.projectionTruncated}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}get pendingApproval(){return this.approvalPending}willUpdate(changed){if(super.willUpdate(changed),this.openedEntryIds.size>0&&(resultViewRegistration??=import("../tool-result-view/tool-result-view.js").catch(()=>resultViewRegistration=void 0)),!changed.has("entries"))return;this.rebuildProjection();const projected=this.projectedEntriesCache;projected.some(entry=>entry.needsApproval)&&(approvalDialogRegistration??=import("../tool-approval-dialog/tool-approval-dialog.js").catch(()=>approvalDialogRegistration=void 0));const identities=new Set(projected.map(entryIdentity));if(this.reviewingEntryKey!==void 0){const still=projected.find(entry=>entryIdentity(entry)===this.reviewingEntryKey);(!still||!(still.needsApproval&&still.approved===void 0))&&(this.reviewingEntryKey=void 0,this.approvalPending=null)}const opened=new Set([...this.openedEntryIds].filter(key=>identities.has(key)));opened.size!==this.openedEntryIds.size&&(this.openedEntryIds=opened)}updated(changed){super.updated(changed),this.limitAnnouncementInitialized&&this.projectionTruncated&&!this.previouslyTruncated&&this.announcements.announcePolite(this.localize("toolTimelineLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(MAX_RENDERED_ENTRIES)})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.projectionTruncated}rebuildProjection(){const entries=Array.isArray(this.entries)?this.entries:[],projected=[],projectedIndex=new Map,reservedKeys=new Set(this.openedEntryIds);this.reviewingEntryKey!==void 0&&reservedKeys.add(this.reviewingEntryKey);const displacedReserved=new Map,seen=new Set;for(const sourceEntry of entries){const entry=projectToolTimelineEntry(sourceEntry);if(!entry)continue;const key=entryIdentity(entry);seen.has(key)||(seen.add(key),projected.length<MAX_RENDERED_ENTRIES?(projectedIndex.set(key,projected.length),projected.push(entry)):reservedKeys.has(key)&&displacedReserved.set(key,entry))}for(const[key,entry]of displacedReserved){if(projectedIndex.has(key))continue;let replacement=projected.length-1;for(;replacement>=0&&reservedKeys.has(entryIdentity(projected[replacement]));)replacement--;if(replacement<0)break;projectedIndex.delete(entryIdentity(projected[replacement])),projected[replacement]=entry,projectedIndex.set(key,replacement)}this.projectedEntriesCache=projected,this.projectionTruncated=seen.size>projected.length,this.sortedEntriesCache=projected.map((entry,index)=>({entry,index})).sort((a,b)=>{const ak=Number.isFinite(a.entry.startedAt)?a.entry.startedAt:Number.POSITIVE_INFINITY,bk=Number.isFinite(b.entry.startedAt)?b.entry.startedAt:Number.POSITIVE_INFINITY;return ak!==bk?ak-bk:a.index-b.index}).map(({entry})=>entry)}get sortedEntries(){return this.sortedEntriesCache}get reviewingEntry(){return this.reviewingEntryKey===void 0?void 0:this.projectedEntriesCache.find(entry=>entryIdentity(entry)===this.reviewingEntryKey)}durationFor(entry){if(entry.startedAt==null||entry.endedAt==null)return;const diff=entry.endedAt-entry.startedAt;return Number.isFinite(diff)?diff:void 0}normalizedDate(ms){if(ms==null||!Number.isFinite(ms))return;const date=new Date(ms);return Number.isNaN(date.getTime())?void 0:date}onChipSelect(entry,event){if(event.stopPropagation(),entry.needsApproval&&entry.approved===void 0){this.reviewingEntryKey=entryIdentity(entry);return}this.emit("lr-tool-activate",entryCorrelation(entry))}entryStillNeedsApproval(key){const entries=Array.isArray(this.entries)?this.entries:[];for(const sourceEntry of entries){const projected=projectToolTimelineEntry(sourceEntry);if(projected!==void 0&&entryIdentity(projected)===key)return projected.needsApproval===!0&&projected.approved===void 0}return!1}finalizePendingApproval(){this.approvalPending!==null&&(this.approvalPending=null,this.reviewingEntryKey=void 0)}revertPendingApproval(){this.approvalPending!==null&&(this.approvalPending=null)}onDetailsToggle(entry,event){event.stopPropagation();const key=entryIdentity(entry),next=new Set(this.openedEntryIds);event.detail.expanded?next.add(key):next.delete(key),this.openedEntryIds=next}stopOwnedEvent(event){event.stopPropagation()}onRenderError(entry,event){event.stopPropagation(),this.emit("lr-tool-render-error",{...entryCorrelation(entry),...event.detail})}redactedEntry(entry,placeholder){const redacted=redactToolDetail({args:entry.args,result:entry.result,error:entry.error},entry.redactedFields,placeholder,this.redactionCache.get(entry));return this.redactionCache.set(entry,redacted),redacted}openedDetailsTemplate(entry,placeholder){const redacted=this.redactedEntry(entry,placeholder);return html`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{formatTimeOfDay,getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{eyeOffIcon}from"../../../internal/icons.js";import{srOnly}from"../../../internal/a11y.js";import{styles}from"./tool-timeline.styles.js";import{overallSemanticLabel}from"../semantic-owner.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{TOOL_CALL_STATUSES}from"../tool-status.js";import{EMPTY_REDACTION_PATHS,projectedRedactionFields,redactToolDetail}from"../tool-redaction.js";import{LYRA_DEFAULT_confirmApproved,LYRA_DEFAULT_confirmDenied,LYRA_DEFAULT_toolTimelineDetailsFor,LYRA_DEFAULT_toolTimelineLimit}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_noData,LYRA_DEFAULT_retry}from"../../../internal/default-strings/shared.generated.js";let resultViewRegistration,approvalDialogRegistration;const MAX_RENDERED_ENTRIES=500,TOOL_STATUSES=new Set(TOOL_CALL_STATUSES);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectToolTimelineEntry(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),nameDescriptor=descriptorValue(value,"name"),displayNameDescriptor=descriptorValue(value,"displayName"),argsDescriptor=descriptorValue(value,"args"),statusDescriptor=descriptorValue(value,"status"),resultDescriptor=descriptorValue(value,"result"),errorDescriptor=descriptorValue(value,"error"),sourceKeyDescriptor=descriptorValue(value,"sourceKey"),iconDescriptor=descriptorValue(value,"icon"),startedAtDescriptor=descriptorValue(value,"startedAt"),endedAtDescriptor=descriptorValue(value,"endedAt"),retryCountDescriptor=descriptorValue(value,"retryCount"),redactedFieldsDescriptor=descriptorValue(value,"redactedFields"),needsApprovalDescriptor=descriptorValue(value,"needsApproval"),approvedDescriptor=descriptorValue(value,"approved");if([idDescriptor,nameDescriptor,displayNameDescriptor,argsDescriptor,statusDescriptor,resultDescriptor,errorDescriptor,sourceKeyDescriptor,iconDescriptor,startedAtDescriptor,endedAtDescriptor,retryCountDescriptor,redactedFieldsDescriptor,needsApprovalDescriptor,approvedDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const valueOf=descriptor=>{if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return descriptor.value},id=valueOf(idDescriptor);if(typeof id!="string"||id.trim().length===0)return;const redactedFieldsValue=valueOf(redactedFieldsDescriptor),redactedFields=redactedFieldsValue===void 0?EMPTY_REDACTION_PATHS:projectedRedactionFields(redactedFieldsValue);if(redactedFields===void 0)return;const name=valueOf(nameDescriptor),displayName=valueOf(displayNameDescriptor),status=valueOf(statusDescriptor),result=valueOf(resultDescriptor),error=valueOf(errorDescriptor),sourceKey=valueOf(sourceKeyDescriptor),icon=valueOf(iconDescriptor),startedAt=valueOf(startedAtDescriptor),endedAt=valueOf(endedAtDescriptor),retryCount=valueOf(retryCountDescriptor),needsApproval=valueOf(needsApprovalDescriptor),approved=valueOf(approvedDescriptor);return Object.freeze({source:value,id,name:typeof name=="string"?name:"",...typeof displayName=="string"?{displayName}:{},args:valueOf(argsDescriptor),status:TOOL_STATUSES.has(status)?status:"pending",...result===void 0?{}:{result},...typeof error=="string"?{error}:{},...typeof sourceKey=="string"?{sourceKey}:{},...typeof icon=="string"?{icon}:{},...typeof startedAt=="number"?{startedAt}:{},...typeof endedAt=="number"?{endedAt}:{},...typeof retryCount=="number"?{retryCount}:{},redactedFields,...typeof needsApproval=="boolean"?{needsApproval}:{},...typeof approved=="boolean"?{approved}:{}})}catch{return}}function entrySourceKey(entry){return entry.sourceKey?.trim()?entry.sourceKey:void 0}function entryIdentity(entry){return JSON.stringify([entrySourceKey(entry)??null,entry.id])}function entryCorrelation(entry){const sourceKey=entrySourceKey(entry);return sourceKey===void 0?{invocationId:entry.id}:{invocationId:entry.id,sourceKey}}class LyraToolTimeline extends LyraElement{constructor(){super(...arguments),this.entries=[],this.approvalReadonly=!1,this.approvalPending=null,this.openedEntryIds=new Set,this.projectedEntriesCache=[],this.sortedEntriesCache=[],this.projectionTruncated=!1,this.redactionCache=new WeakMap,this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.decisionDispatching=!1,this.onDialogApprove=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!0,args:event.detail.args}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="approve",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogDeny=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!1}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="deny",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogClose=event=>{event.stopPropagation(),this.approvalPending=null,this.reviewingEntryKey=void 0}}static{this.defaultStrings={...super.defaultStrings,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmDenied:LYRA_DEFAULT_confirmDenied,envListValueHidden:LYRA_DEFAULT_envListValueHidden,noData:LYRA_DEFAULT_noData,retry:LYRA_DEFAULT_retry,toolTimelineDetailsFor:LYRA_DEFAULT_toolTimelineDetailsFor,toolTimelineLimit:LYRA_DEFAULT_toolTimelineLimit}}emitToolApprovalDecideRequest(detail){return this.emit("lr-tool-approval-decide-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entries"])}static{this.identityCollectionProperties=Object.freeze(["entries"])}static{this.styles=[LyraElement.styles,styles,srOnly]}connectedCallback(){super.connectedCallback(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.projectionTruncated}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}get pendingApproval(){return this.approvalPending}willUpdate(changed){if(super.willUpdate(changed),this.openedEntryIds.size>0&&(resultViewRegistration??=import("../tool-result-view/tool-result-view.js").catch(()=>resultViewRegistration=void 0)),!changed.has("entries"))return;this.rebuildProjection();const projected=this.projectedEntriesCache;projected.some(entry=>entry.needsApproval)&&(approvalDialogRegistration??=import("../tool-approval-dialog/tool-approval-dialog.js").catch(()=>approvalDialogRegistration=void 0));const identities=new Set(projected.map(entryIdentity));if(this.reviewingEntryKey!==void 0){const still=projected.find(entry=>entryIdentity(entry)===this.reviewingEntryKey);(!still||!(still.needsApproval&&still.approved===void 0))&&(this.reviewingEntryKey=void 0,this.approvalPending=null)}const opened=new Set([...this.openedEntryIds].filter(key=>identities.has(key)));opened.size!==this.openedEntryIds.size&&(this.openedEntryIds=opened)}updated(changed){super.updated(changed),this.limitAnnouncementInitialized&&this.projectionTruncated&&!this.previouslyTruncated&&this.announcements.announcePolite(this.localize("toolTimelineLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(MAX_RENDERED_ENTRIES)})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.projectionTruncated}rebuildProjection(){const entries=Array.isArray(this.entries)?this.entries:[],projected=[],projectedIndex=new Map,reservedKeys=new Set(this.openedEntryIds);this.reviewingEntryKey!==void 0&&reservedKeys.add(this.reviewingEntryKey);const displacedReserved=new Map,seen=new Set;for(const sourceEntry of entries){const entry=projectToolTimelineEntry(sourceEntry);if(!entry)continue;const key=entryIdentity(entry);seen.has(key)||(seen.add(key),projected.length<MAX_RENDERED_ENTRIES?(projectedIndex.set(key,projected.length),projected.push(entry)):reservedKeys.has(key)&&displacedReserved.set(key,entry))}for(const[key,entry]of displacedReserved){if(projectedIndex.has(key))continue;let replacement=projected.length-1;for(;replacement>=0&&reservedKeys.has(entryIdentity(projected[replacement]));)replacement--;if(replacement<0)break;projectedIndex.delete(entryIdentity(projected[replacement])),projected[replacement]=entry,projectedIndex.set(key,replacement)}this.projectedEntriesCache=projected,this.projectionTruncated=seen.size>projected.length,this.sortedEntriesCache=projected.map((entry,index)=>({entry,index})).sort((a,b)=>{const ak=Number.isFinite(a.entry.startedAt)?a.entry.startedAt:Number.POSITIVE_INFINITY,bk=Number.isFinite(b.entry.startedAt)?b.entry.startedAt:Number.POSITIVE_INFINITY;return ak!==bk?ak-bk:a.index-b.index}).map(({entry})=>entry)}get sortedEntries(){return this.sortedEntriesCache}get reviewingEntry(){return this.reviewingEntryKey===void 0?void 0:this.projectedEntriesCache.find(entry=>entryIdentity(entry)===this.reviewingEntryKey)}durationFor(entry){if(entry.startedAt==null||entry.endedAt==null)return;const diff=entry.endedAt-entry.startedAt;return Number.isFinite(diff)?diff:void 0}normalizedDate(ms){if(ms==null||!Number.isFinite(ms))return;const date=new Date(ms);return Number.isNaN(date.getTime())?void 0:date}onChipSelect(entry,event){if(event.stopPropagation(),entry.needsApproval&&entry.approved===void 0){this.reviewingEntryKey=entryIdentity(entry);return}this.emit("lr-tool-activate",entryCorrelation(entry))}entryStillNeedsApproval(key){const entries=Array.isArray(this.entries)?this.entries:[];for(const sourceEntry of entries){const projected=projectToolTimelineEntry(sourceEntry);if(projected!==void 0&&entryIdentity(projected)===key)return projected.needsApproval===!0&&projected.approved===void 0}return!1}finalizePendingApproval(){this.approvalPending!==null&&(this.approvalPending=null,this.reviewingEntryKey=void 0)}revertPendingApproval(){this.approvalPending!==null&&(this.approvalPending=null)}onDetailsToggle(entry,event){event.stopPropagation();const key=entryIdentity(entry),next=new Set(this.openedEntryIds);event.detail.expanded?next.add(key):next.delete(key),this.openedEntryIds=next}stopOwnedEvent(event){event.stopPropagation()}onRenderError(entry,event){event.stopPropagation(),this.emit("lr-tool-render-error",{...entryCorrelation(entry),...event.detail})}redactedEntry(entry,placeholder){const redacted=redactToolDetail({args:entry.args,result:entry.result,error:entry.error},entry.redactedFields,placeholder,this.redactionCache.get(entry));return this.redactionCache.set(entry,redacted),redacted}openedDetailsTemplate(entry,placeholder){const redacted=this.redactedEntry(entry,placeholder);return html`
2
2
  <lr-tool-result-view
3
3
  part="entry-result"
4
4
  tool-name=${entry.name}
@@ -1,8 +1,8 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,svg,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatShortDuration}from"../../../internal/duration.js";import{isRtl}from"../../../internal/rtl.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteCount,finiteNumber}from"../../../internal/numbers.js";import{chevronIcon}from"../../../internal/icons.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{styles}from"./trace-tree.styles.js";import{MAX_RENDERED_LYRA_SPANS,normalizeLyraSpans}from"./span.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_cost,LYRA_DEFAULT_details,LYRA_DEFAULT_duration,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_spanKindAgent,LYRA_DEFAULT_spanKindEmbedding,LYRA_DEFAULT_spanKindLlm,LYRA_DEFAULT_spanKindOther,LYRA_DEFAULT_spanKindRetriever,LYRA_DEFAULT_spanKindTool,LYRA_DEFAULT_spanProjectionLimit,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_statusUnknown,LYRA_DEFAULT_tokensIn,LYRA_DEFAULT_tokensOut,LYRA_DEFAULT_traceTree,LYRA_DEFAULT_traceTreeMetricLabel,LYRA_DEFAULT_traceTreeSpanStatus}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function glyph(paths){return svg`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,svg,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatShortDuration}from"../../../internal/duration.js";import{isRtl}from"../../../internal/rtl.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteCount,finiteNumber}from"../../../internal/numbers.js";import{chevronIcon}from"../../../internal/icons.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{styles}from"./trace-tree.styles.js";import{MAX_RENDERED_LYRA_SPANS,normalizeLyraSpans}from"./span.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_cost,LYRA_DEFAULT_duration,LYRA_DEFAULT_spanKindAgent,LYRA_DEFAULT_spanKindEmbedding,LYRA_DEFAULT_spanKindLlm,LYRA_DEFAULT_spanKindOther,LYRA_DEFAULT_spanKindRetriever,LYRA_DEFAULT_spanKindTool,LYRA_DEFAULT_spanProjectionLimit,LYRA_DEFAULT_traceTree,LYRA_DEFAULT_traceTreeMetricLabel,LYRA_DEFAULT_traceTreeSpanStatus}from"../../../internal/default-strings/agent-tools.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_statusDenied,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusIncomplete,LYRA_DEFAULT_statusPending,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess,LYRA_DEFAULT_statusUnknown,LYRA_DEFAULT_tokensIn,LYRA_DEFAULT_tokensOut}from"../../../internal/default-strings/shared.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function glyph(paths){return svg`
2
2
  <svg width="1em" height="1em" viewBox=${ICON_VIEW_BOX} fill="none" stroke="currentColor"
3
3
  stroke-width=${ICON_STROKE_WIDTH} stroke-linecap="round" stroke-linejoin="round"
4
4
  aria-hidden="true" focusable="false">${paths}</svg>
5
- `}function agentIcon(){return glyph(svg`<rect x="5" y="8" width="14" height="10" rx="2"></rect><circle cx="9.5" cy="13" r="1"></circle><circle cx="14.5" cy="13" r="1"></circle><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle>`)}function llmIcon(){return glyph(svg`<path d="M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6z"></path><path d="M18.5 15l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7z"></path>`)}function toolIcon(){return glyph(svg`<path d="M14.7 6.3a4 4 0 0 1-5.4 5.4L4 17l3 3 5.3-5.3a4 4 0 0 1 5.4-5.4l-2.3 2.3-2-2z"></path>`)}function retrieverIcon(){return glyph(svg`<circle cx="10.5" cy="10.5" r="6.5"></circle><line x1="15.5" y1="15.5" x2="20" y2="20"></line>`)}function embeddingIcon(){return glyph(svg`<circle cx="6" cy="6" r="1.6"></circle><circle cx="18" cy="6" r="1.6"></circle><circle cx="6" cy="18" r="1.6"></circle><circle cx="18" cy="18" r="1.6"></circle><circle cx="12" cy="12" r="1.6"></circle><line x1="7.3" y1="7.3" x2="10.8" y2="10.8"></line><line x1="16.7" y1="7.3" x2="13.2" y2="10.8"></line><line x1="7.3" y1="16.7" x2="10.8" y2="13.2"></line><line x1="16.7" y1="16.7" x2="13.2" y2="13.2"></line>`)}function otherIcon(){return glyph(svg`<circle cx="12" cy="12" r="8"></circle>`)}const KIND_ICON={agent:agentIcon,llm:llmIcon,tool:toolIcon,retriever:retrieverIcon,embedding:embeddingIcon,other:otherIcon},KIND_LABEL_KEY={agent:"spanKindAgent",llm:"spanKindLlm",tool:"spanKindTool",retriever:"spanKindRetriever",embedding:"spanKindEmbedding",other:"spanKindOther"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied",incomplete:"statusIncomplete",unknown:"statusUnknown"};class LyraTraceTree extends LyraElement{constructor(){super(...arguments),this.spans=[],this.hiddenKinds=[],this.activeSpanId=null,this.withTokens=!1,this.withCost=!1,this.withoutBars=!1,this.collapsedIds=new Set,this.focusedId=null,this.previousStatuses=new Map,this.pendingAnnouncements=[],this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.renderedProjectionTruncated=!1,this.onKeyDown=e=>{const rows=this.buildRows();if(rows.length===0)return;const currentIndex=rows.findIndex(r=>r.span.id===this.focusedId),current=currentIndex>=0?rows[currentIndex]:rows[0];if(!current)return;const rtl=isRtl(this),expandKey=rtl?"ArrowLeft":"ArrowRight",collapseKey=rtl?"ArrowRight":"ArrowLeft";switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(rows[Math.min(rows.length-1,currentIndex+1)]);break;case"ArrowUp":e.preventDefault(),this.focusRow(rows[Math.max(0,currentIndex-1)]);break;case"Home":e.preventDefault(),this.focusRow(rows[0]);break;case"End":e.preventDefault(),this.focusRow(rows[rows.length-1]);break;case expandKey:if(e.preventDefault(),!current.hasChildren)break;if(this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else{const child=rows[currentIndex+1];child&&child.depth>current.depth&&this.focusRow(child)}break;case collapseKey:if(e.preventDefault(),current.hasChildren&&!this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else for(let i=currentIndex-1;i>=0;i--){const row=rows[i];if(row&&row.depth<current.depth){this.focusRow(row);break}}break;case"Enter":case" ":e.preventDefault(),this.selectRow(current.span.id);break;default:return}}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,cost:LYRA_DEFAULT_cost,details:LYRA_DEFAULT_details,duration:LYRA_DEFAULT_duration,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,spanKindAgent:LYRA_DEFAULT_spanKindAgent,spanKindEmbedding:LYRA_DEFAULT_spanKindEmbedding,spanKindLlm:LYRA_DEFAULT_spanKindLlm,spanKindOther:LYRA_DEFAULT_spanKindOther,spanKindRetriever:LYRA_DEFAULT_spanKindRetriever,spanKindTool:LYRA_DEFAULT_spanKindTool,spanProjectionLimit:LYRA_DEFAULT_spanProjectionLimit,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusIncomplete:LYRA_DEFAULT_statusIncomplete,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,statusUnknown:LYRA_DEFAULT_statusUnknown,tokensIn:LYRA_DEFAULT_tokensIn,tokensOut:LYRA_DEFAULT_tokensOut,traceTree:LYRA_DEFAULT_traceTree,traceTreeMetricLabel:LYRA_DEFAULT_traceTreeMetricLabel,traceTreeSpanStatus:LYRA_DEFAULT_traceTreeSpanStatus}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["spans","hiddenKinds"])}static{this.identityCollectionProperties=Object.freeze(["spans"])}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.renderedProjectionTruncated}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}hierarchy(){const key=this.hierarchyKey;return(!key||key[0]!==this.spans||key[1]!==this.activeSpanId||key[2]!==this.hiddenKinds)&&(this.hierarchyKey=[this.spans,this.activeSpanId,this.hiddenKinds],this.hierarchyCache=this.buildHierarchy()),this.hierarchyCache}buildHierarchy(){const projection=normalizeLyraSpans(this.spans,this.activeSpanId),{truncated,extentEndMs}=projection;let{spans,byId}=projection;if(this.hiddenKinds.length>0){const hidden=new Set(this.hiddenKinds);spans=spans.filter(span=>!hidden.has(span.kind)),byId=new Map(spans.map(span=>[span.id,span]))}const childrenOf=new Map,parentOf=new Map,roots=[],hasCyclicParentChain=span=>{const visited=new Set([span.id]);let parentId=span.parentId;for(;parentId!=null;){if(visited.has(parentId))return!0;visited.add(parentId),parentId=byId.get(parentId)?.parentId}return!1};for(const span of spans){const parent=span.parentId!=null&&!hasCyclicParentChain(span)?byId.get(span.parentId):void 0;if(parent&&parent.id!==span.id){const list=childrenOf.get(parent.id)??[];list.push(span),childrenOf.set(parent.id,list),parentOf.set(span.id,parent.id)}else roots.push(span)}const byStart=(a,b)=>a.startMs-b.startMs;roots.sort(byStart);for(const list of childrenOf.values())list.sort(byStart);return{spans,byId,childrenOf,parentOf,roots,truncated,extentEndMs}}buildRows(hierarchy=this.hierarchy()){const rows=[],stack=[...hierarchy.roots].reverse().map((span,reverseIndex)=>({span,depth:0,posInSet:hierarchy.roots.length-reverseIndex,setSize:hierarchy.roots.length})),visited=new Set;for(;stack.length>0&&rows.length<MAX_RENDERED_LYRA_SPANS;){const current=stack.pop();if(!current||visited.has(current.span.id))continue;visited.add(current.span.id);const children=hierarchy.childrenOf.get(current.span.id)??[];if(rows.push({...current,hasChildren:children.length>0}),!(children.length===0||this.collapsedIds.has(current.span.id)))for(let index=children.length-1;index>=0;index--){const child=children[index];child&&stack.push({span:child,depth:current.depth+1,posInSet:index+1,setSize:children.length})}}return rows}traceExtent(hierarchy=this.hierarchy()){return finiteNumber(hierarchy.extentEndMs,0)||1}formatDuration(ms){return ms==null?"":formatShortDuration(this.localize.bind(this),this.effectiveLocale,ms)}formatNumber(n){return getNumberFormat(this.effectiveLocale).format(finiteCount(n))}validTokenMetric(value){return typeof value=="number"&&Number.isFinite(value)&&value>=0}toggleSpan(id){const collapsed=this.collapsedIds.has(id);collapsed||this.renderedRowById(id)?.focus();const next=new Set(this.collapsedIds);collapsed?next.delete(id):next.add(id),this.collapsedIds=next,this.focusedId=id,this.emit("lr-span-toggle",{spanId:id,expanded:collapsed})}async expandAll(){this.collapsedIds=new Set,await this.updateComplete}collapseAll(){const next=new Set,hierarchy=this.hierarchy(),{byId,parentOf}=hierarchy,hasChild=new Set(hierarchy.childrenOf.keys());for(const id of hasChild)next.add(id);if(this.collapsedIds=next,this.focusedId!=null){const before=this.focusedId;let current=byId.get(before);for(;current&&parentOf.has(current.id);)current=byId.get(parentOf.get(current.id));this.focusedId=current?.id??null,current&&current.id!==before&&shadowFocusTarget(this)&&this.renderedRowById(current.id)?.focus()}}focusRow(row){row&&(this.focusedId=row.span.id,this.updateComplete.then(()=>{this.renderedRowById(row.span.id)?.focus()}))}selectRow(id){this.focusedId=id,this.emit("lr-span-select",{spanId:id})}willUpdate(changed){if(super.willUpdate(changed),changed.has("spans")||changed.has("hiddenKinds")||changed.has("activeSpanId")||changed.has("collapsedIds")){const hierarchy=this.hierarchy(),ids=new Set(hierarchy.byId.keys());let pruned=null;for(const id of this.collapsedIds)ids.has(id)||(pruned??=new Set(this.collapsedIds),pruned.delete(id));if(pruned&&(this.collapsedIds=pruned),(changed.has("spans")||changed.has("activeSpanId"))&&this.activeSpanId&&hierarchy.byId.has(this.activeSpanId)){const revealed=new Set(this.collapsedIds);let currentId=this.activeSpanId,changedCollapse=!1;for(;hierarchy.parentOf.has(currentId);)currentId=hierarchy.parentOf.get(currentId),revealed.delete(currentId)&&(changedCollapse=!0);changedCollapse&&(this.collapsedIds=revealed)}const rows=this.buildRows(hierarchy),visibleIds=new Set(rows.map(row=>row.span.id));if((this.focusedId==null||!ids.has(this.focusedId))&&(this.focusedId=this.activeSpanId&&visibleIds.has(this.activeSpanId)?this.activeSpanId:rows[0]?.span.id??null),changed.has("spans")){for(const row of rows){const{span}=row,prev=this.previousStatuses.get(span.id);prev!==void 0&&prev!==span.status&&this.pendingAnnouncements.push(this.localize("traceTreeSpanStatus",void 0,{name:span.name,status:this.localize(STATUS_LABEL_KEY[span.status])}))}this.previousStatuses=new Map(hierarchy.spans.map(span=>[span.id,span.status]))}const visibleAncestor=id=>{let current=id?hierarchy.byId.get(id):void 0;for(;current;){if(visibleIds.has(current.id))return current.id;current=hierarchy.parentOf.has(current.id)?hierarchy.byId.get(hierarchy.parentOf.get(current.id)):void 0}return null};this.focusedId=visibleAncestor(changed.has("activeSpanId")?this.activeSpanId:null)??visibleAncestor(this.focusedId)??visibleAncestor(this.activeSpanId)??rows[0]?.span.id??null}}renderedRowById(id){const ownerCss=this.ownerDocument.defaultView?.CSS;return typeof ownerCss?.escape=="function"?this.renderRoot.querySelector(`[data-id="${ownerCss.escape(id)}"]`):Array.from(this.renderRoot.querySelectorAll("[data-id]")).find(element=>element.dataset.id===id)??null}updated(changed){if(super.updated(changed),changed.has("activeSpanId")&&this.activeSpanId){const row=this.renderedRowById(this.activeSpanId);if(row){const reducedMotion=!row.ownerDocument.defaultView||prefersReducedMotion(this);row.scrollIntoView({block:"nearest",behavior:reducedMotion?"auto":"smooth"})}}if(this.pendingAnnouncements.length>0){const texts=this.pendingAnnouncements;this.pendingAnnouncements=[];for(const text of texts)this.liveRegion?.announce(text)}this.limitAnnouncementInitialized&&this.renderedProjectionTruncated&&!this.previouslyTruncated&&this.announcements.announcePolite(this.localize("spanProjectionLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(MAX_RENDERED_LYRA_SPANS)})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.renderedProjectionTruncated}renderHeader(){return html`
5
+ `}function agentIcon(){return glyph(svg`<rect x="5" y="8" width="14" height="10" rx="2"></rect><circle cx="9.5" cy="13" r="1"></circle><circle cx="14.5" cy="13" r="1"></circle><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle>`)}function llmIcon(){return glyph(svg`<path d="M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6z"></path><path d="M18.5 15l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7z"></path>`)}function toolIcon(){return glyph(svg`<path d="M14.7 6.3a4 4 0 0 1-5.4 5.4L4 17l3 3 5.3-5.3a4 4 0 0 1 5.4-5.4l-2.3 2.3-2-2z"></path>`)}function retrieverIcon(){return glyph(svg`<circle cx="10.5" cy="10.5" r="6.5"></circle><line x1="15.5" y1="15.5" x2="20" y2="20"></line>`)}function embeddingIcon(){return glyph(svg`<circle cx="6" cy="6" r="1.6"></circle><circle cx="18" cy="6" r="1.6"></circle><circle cx="6" cy="18" r="1.6"></circle><circle cx="18" cy="18" r="1.6"></circle><circle cx="12" cy="12" r="1.6"></circle><line x1="7.3" y1="7.3" x2="10.8" y2="10.8"></line><line x1="16.7" y1="7.3" x2="13.2" y2="10.8"></line><line x1="7.3" y1="16.7" x2="10.8" y2="13.2"></line><line x1="16.7" y1="16.7" x2="13.2" y2="13.2"></line>`)}function otherIcon(){return glyph(svg`<circle cx="12" cy="12" r="8"></circle>`)}const KIND_ICON={agent:agentIcon,llm:llmIcon,tool:toolIcon,retriever:retrieverIcon,embedding:embeddingIcon,other:otherIcon},KIND_LABEL_KEY={agent:"spanKindAgent",llm:"spanKindLlm",tool:"spanKindTool",retriever:"spanKindRetriever",embedding:"spanKindEmbedding",other:"spanKindOther"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied",incomplete:"statusIncomplete",unknown:"statusUnknown"};class LyraTraceTree extends LyraElement{constructor(){super(...arguments),this.spans=[],this.hiddenKinds=[],this.activeSpanId=null,this.withTokens=!1,this.withCost=!1,this.withoutBars=!1,this.collapsedIds=new Set,this.focusedId=null,this.previousStatuses=new Map,this.pendingAnnouncements=[],this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.renderedProjectionTruncated=!1,this.onKeyDown=e=>{const rows=this.buildRows();if(rows.length===0)return;const currentIndex=rows.findIndex(r=>r.span.id===this.focusedId),current=currentIndex>=0?rows[currentIndex]:rows[0];if(!current)return;const rtl=isRtl(this),expandKey=rtl?"ArrowLeft":"ArrowRight",collapseKey=rtl?"ArrowRight":"ArrowLeft";switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(rows[Math.min(rows.length-1,currentIndex+1)]);break;case"ArrowUp":e.preventDefault(),this.focusRow(rows[Math.max(0,currentIndex-1)]);break;case"Home":e.preventDefault(),this.focusRow(rows[0]);break;case"End":e.preventDefault(),this.focusRow(rows[rows.length-1]);break;case expandKey:if(e.preventDefault(),!current.hasChildren)break;if(this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else{const child=rows[currentIndex+1];child&&child.depth>current.depth&&this.focusRow(child)}break;case collapseKey:if(e.preventDefault(),current.hasChildren&&!this.collapsedIds.has(current.span.id))this.toggleSpan(current.span.id);else for(let i=currentIndex-1;i>=0;i--){const row=rows[i];if(row&&row.depth<current.depth){this.focusRow(row);break}}break;case"Enter":case" ":e.preventDefault(),this.selectRow(current.span.id);break;default:return}}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,cost:LYRA_DEFAULT_cost,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,duration:LYRA_DEFAULT_duration,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,spanKindAgent:LYRA_DEFAULT_spanKindAgent,spanKindEmbedding:LYRA_DEFAULT_spanKindEmbedding,spanKindLlm:LYRA_DEFAULT_spanKindLlm,spanKindOther:LYRA_DEFAULT_spanKindOther,spanKindRetriever:LYRA_DEFAULT_spanKindRetriever,spanKindTool:LYRA_DEFAULT_spanKindTool,spanProjectionLimit:LYRA_DEFAULT_spanProjectionLimit,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusIncomplete:LYRA_DEFAULT_statusIncomplete,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,statusUnknown:LYRA_DEFAULT_statusUnknown,tokensIn:LYRA_DEFAULT_tokensIn,tokensOut:LYRA_DEFAULT_tokensOut,traceTree:LYRA_DEFAULT_traceTree,traceTreeMetricLabel:LYRA_DEFAULT_traceTreeMetricLabel,traceTreeSpanStatus:LYRA_DEFAULT_traceTreeSpanStatus}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["spans","hiddenKinds"])}static{this.identityCollectionProperties=Object.freeze(["spans"])}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.renderedProjectionTruncated}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}hierarchy(){const key=this.hierarchyKey;return(!key||key[0]!==this.spans||key[1]!==this.activeSpanId||key[2]!==this.hiddenKinds)&&(this.hierarchyKey=[this.spans,this.activeSpanId,this.hiddenKinds],this.hierarchyCache=this.buildHierarchy()),this.hierarchyCache}buildHierarchy(){const projection=normalizeLyraSpans(this.spans,this.activeSpanId),{truncated,extentEndMs}=projection;let{spans,byId}=projection;if(this.hiddenKinds.length>0){const hidden=new Set(this.hiddenKinds);spans=spans.filter(span=>!hidden.has(span.kind)),byId=new Map(spans.map(span=>[span.id,span]))}const childrenOf=new Map,parentOf=new Map,roots=[],hasCyclicParentChain=span=>{const visited=new Set([span.id]);let parentId=span.parentId;for(;parentId!=null;){if(visited.has(parentId))return!0;visited.add(parentId),parentId=byId.get(parentId)?.parentId}return!1};for(const span of spans){const parent=span.parentId!=null&&!hasCyclicParentChain(span)?byId.get(span.parentId):void 0;if(parent&&parent.id!==span.id){const list=childrenOf.get(parent.id)??[];list.push(span),childrenOf.set(parent.id,list),parentOf.set(span.id,parent.id)}else roots.push(span)}const byStart=(a,b)=>a.startMs-b.startMs;roots.sort(byStart);for(const list of childrenOf.values())list.sort(byStart);return{spans,byId,childrenOf,parentOf,roots,truncated,extentEndMs}}buildRows(hierarchy=this.hierarchy()){const rows=[],stack=[...hierarchy.roots].reverse().map((span,reverseIndex)=>({span,depth:0,posInSet:hierarchy.roots.length-reverseIndex,setSize:hierarchy.roots.length})),visited=new Set;for(;stack.length>0&&rows.length<MAX_RENDERED_LYRA_SPANS;){const current=stack.pop();if(!current||visited.has(current.span.id))continue;visited.add(current.span.id);const children=hierarchy.childrenOf.get(current.span.id)??[];if(rows.push({...current,hasChildren:children.length>0}),!(children.length===0||this.collapsedIds.has(current.span.id)))for(let index=children.length-1;index>=0;index--){const child=children[index];child&&stack.push({span:child,depth:current.depth+1,posInSet:index+1,setSize:children.length})}}return rows}traceExtent(hierarchy=this.hierarchy()){return finiteNumber(hierarchy.extentEndMs,0)||1}formatDuration(ms){return ms==null?"":formatShortDuration(this.localize.bind(this),this.effectiveLocale,ms)}formatNumber(n){return getNumberFormat(this.effectiveLocale).format(finiteCount(n))}validTokenMetric(value){return typeof value=="number"&&Number.isFinite(value)&&value>=0}toggleSpan(id){const collapsed=this.collapsedIds.has(id);collapsed||this.renderedRowById(id)?.focus();const next=new Set(this.collapsedIds);collapsed?next.delete(id):next.add(id),this.collapsedIds=next,this.focusedId=id,this.emit("lr-span-toggle",{spanId:id,expanded:collapsed})}async expandAll(){this.collapsedIds=new Set,await this.updateComplete}collapseAll(){const next=new Set,hierarchy=this.hierarchy(),{byId,parentOf}=hierarchy,hasChild=new Set(hierarchy.childrenOf.keys());for(const id of hasChild)next.add(id);if(this.collapsedIds=next,this.focusedId!=null){const before=this.focusedId;let current=byId.get(before);for(;current&&parentOf.has(current.id);)current=byId.get(parentOf.get(current.id));this.focusedId=current?.id??null,current&&current.id!==before&&shadowFocusTarget(this)&&this.renderedRowById(current.id)?.focus()}}focusRow(row){row&&(this.focusedId=row.span.id,this.updateComplete.then(()=>{this.renderedRowById(row.span.id)?.focus()}))}selectRow(id){this.focusedId=id,this.emit("lr-span-select",{spanId:id})}willUpdate(changed){if(super.willUpdate(changed),changed.has("spans")||changed.has("hiddenKinds")||changed.has("activeSpanId")||changed.has("collapsedIds")){const hierarchy=this.hierarchy(),ids=new Set(hierarchy.byId.keys());let pruned=null;for(const id of this.collapsedIds)ids.has(id)||(pruned??=new Set(this.collapsedIds),pruned.delete(id));if(pruned&&(this.collapsedIds=pruned),(changed.has("spans")||changed.has("activeSpanId"))&&this.activeSpanId&&hierarchy.byId.has(this.activeSpanId)){const revealed=new Set(this.collapsedIds);let currentId=this.activeSpanId,changedCollapse=!1;for(;hierarchy.parentOf.has(currentId);)currentId=hierarchy.parentOf.get(currentId),revealed.delete(currentId)&&(changedCollapse=!0);changedCollapse&&(this.collapsedIds=revealed)}const rows=this.buildRows(hierarchy),visibleIds=new Set(rows.map(row=>row.span.id));if((this.focusedId==null||!ids.has(this.focusedId))&&(this.focusedId=this.activeSpanId&&visibleIds.has(this.activeSpanId)?this.activeSpanId:rows[0]?.span.id??null),changed.has("spans")){for(const row of rows){const{span}=row,prev=this.previousStatuses.get(span.id);prev!==void 0&&prev!==span.status&&this.pendingAnnouncements.push(this.localize("traceTreeSpanStatus",void 0,{name:span.name,status:this.localize(STATUS_LABEL_KEY[span.status])}))}this.previousStatuses=new Map(hierarchy.spans.map(span=>[span.id,span.status]))}const visibleAncestor=id=>{let current=id?hierarchy.byId.get(id):void 0;for(;current;){if(visibleIds.has(current.id))return current.id;current=hierarchy.parentOf.has(current.id)?hierarchy.byId.get(hierarchy.parentOf.get(current.id)):void 0}return null};this.focusedId=visibleAncestor(changed.has("activeSpanId")?this.activeSpanId:null)??visibleAncestor(this.focusedId)??visibleAncestor(this.activeSpanId)??rows[0]?.span.id??null}}renderedRowById(id){const ownerCss=this.ownerDocument.defaultView?.CSS;return typeof ownerCss?.escape=="function"?this.renderRoot.querySelector(`[data-id="${ownerCss.escape(id)}"]`):Array.from(this.renderRoot.querySelectorAll("[data-id]")).find(element=>element.dataset.id===id)??null}updated(changed){if(super.updated(changed),changed.has("activeSpanId")&&this.activeSpanId){const row=this.renderedRowById(this.activeSpanId);if(row){const reducedMotion=!row.ownerDocument.defaultView||prefersReducedMotion(this);row.scrollIntoView({block:"nearest",behavior:reducedMotion?"auto":"smooth"})}}if(this.pendingAnnouncements.length>0){const texts=this.pendingAnnouncements;this.pendingAnnouncements=[];for(const text of texts)this.liveRegion?.announce(text)}this.limitAnnouncementInitialized&&this.renderedProjectionTruncated&&!this.previouslyTruncated&&this.announcements.announcePolite(this.localize("spanProjectionLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(MAX_RENDERED_LYRA_SPANS)})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.renderedProjectionTruncated}renderHeader(){return html`
6
6
  <div part="header">
7
7
  <span class="col-toggle" aria-hidden="true"></span>
8
8
  <span class="col-icon" aria-hidden="true"></span>
@@ -62,7 +62,9 @@ export interface LyraBoxPlotPointDetail{datasetIndex:number;index:number;label:s
62
62
  * @cssprop [--lr-box-plot-fill-color-8=var(--lr-color-chart-8)] - Eighth series box-fill and
63
63
  * legend-swatch color.
64
64
  * @csspart error - Static visible error shown instead of the canvas when the optional box-plot
65
- * peer fails to load; its transition is announced through a shared light-DOM alert.
65
+ * peer fails to load or the canvas context is unavailable. Canvas failure keeps the data table
66
+ * visible and retries on data updates or `refreshTheme()`; its transition is announced through
67
+ * a shared light-DOM alert.
66
68
  * @csspart data-truncation - Explanation shown when the generated accessible alternative samples
67
69
  * more than 1,000 records.
68
70
  * @event lr-legend-visibility-change-request - Cancelable proposed DOM legend visibility change.
@@ -147,7 +149,7 @@ dataTableToggle:boolean;private dataTableExpandedOverride;private readonly dataT
147
149
  valueFormatter?:LyraChartValueFormatter;
148
150
  /** Unified context-object formatter shared with the other chart surfaces. The tooltip lists all
149
151
  * five statistics, each formatted with its own `statistic`. */
150
- formatter?:LyraChartFormatter;private loading;private loadFailed;private visible;private keyboardDatumIndex;private keyboardDatumAnnouncement;private intersectionObserver?;private intersectionGeneration;private readonly reducedMotionWatch;private canvasEl?;private chart?;private stopAnnotationRegistrationWatch?;private chartJsModule?;private loadGeneration;private descriptionId;private lastDrawnDirection?;private lastDrawnLocale?;private readonly announcements;private lastDataTruncationAnnouncement;private isMounting;connectedCallback():void;private onBoxPlotPluginLoaded;disconnectedCallback():void;adoptedCallback():void;private armReducedMotionWatcher;private disarmReducedMotionWatcher;private get ownerWindow();private effectiveHiddenDatasetIndexes;private applyDatasetVisibility;protected updated(changed:PropertyValues):void;private themeColors;private seriesColor;private seriesBorderColor;private seriesFillColor;private forcedColorFill;private styleColor;private styleNumber;private readonly tooltipIsolationPlugin;private buildConfig;private draw;private drawIfVisible;private rebuildAfterAnnotationRegistration;
152
+ formatter?:LyraChartFormatter;private loading;private loadFailed;private canvasUnavailable;private visible;private keyboardDatumIndex;private keyboardDatumAnnouncement;private intersectionObserver?;private intersectionGeneration;private readonly reducedMotionWatch;private canvasEl?;private chart?;private stopAnnotationRegistrationWatch?;private chartJsModule?;private loadGeneration;private descriptionId;private lastDrawnDirection?;private lastDrawnLocale?;private readonly announcements;private lastDataTruncationAnnouncement;private isMounting;connectedCallback():void;private onBoxPlotPluginLoaded;disconnectedCallback():void;adoptedCallback():void;private armReducedMotionWatcher;private disarmReducedMotionWatcher;private get ownerWindow();private effectiveHiddenDatasetIndexes;private applyDatasetVisibility;protected updated(changed:PropertyValues):void;private themeColors;private seriesColor;private seriesBorderColor;private seriesFillColor;private forcedColorFill;private styleColor;private styleNumber;private readonly tooltipIsolationPlugin;private buildConfig;private draw;private setCanvasUnavailable;private drawIfVisible;private rebuildAfterAnnotationRegistration;
151
153
  /** Re-reads canvas theme custom properties after an out-of-band ancestor theme change. */
152
154
  refreshTheme():void;private seriesDisplayLabel;private formatValue;
153
155
  /** Returns a spreadsheet-safe CSV snapshot or the current canvas PNG data URL. */