@aceshooting/lyra-ui 9.1.0 → 10.0.1

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 (622) hide show
  1. package/CHANGELOG.md +843 -0
  2. package/README.md +7 -0
  3. package/custom-elements.json +1 -1
  4. package/dist/cli/migrate-wa.mjs +52 -0
  5. package/dist/cli/migration-contract.json +1 -1
  6. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +2 -2
  7. package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +0 -16
  8. package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
  9. package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.styles.js +9 -7
  10. package/dist/components/agent-tools/agent-run/agent-run.class.js +2 -2
  11. package/dist/components/agent-tools/agent-run/agent-run.styles.js +0 -13
  12. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +1 -1
  13. package/dist/components/agent-tools/agent-trace/agent-trace.styles.js +7 -4
  14. package/dist/components/agent-tools/approval-queue/approval-queue.styles.js +7 -5
  15. package/dist/components/agent-tools/artifact-panel/artifact-panel.styles.js +0 -3
  16. package/dist/components/agent-tools/browser-frame/browser-frame.class.js +1 -1
  17. package/dist/components/agent-tools/browser-frame/browser-frame.styles.js +3 -5
  18. package/dist/components/agent-tools/commit-card/commit-card.class.js +1 -1
  19. package/dist/components/agent-tools/commit-card/commit-card.styles.js +0 -10
  20. package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +11 -6
  21. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
  22. package/dist/components/agent-tools/confirm-bar/confirm-bar.styles.js +0 -46
  23. package/dist/components/agent-tools/context-inspector/context-inspector.class.js +1 -1
  24. package/dist/components/agent-tools/eval-dataset/eval-dataset.styles.js +0 -7
  25. package/dist/components/agent-tools/eval-result/eval-result.class.js +1 -1
  26. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +2 -2
  27. package/dist/components/agent-tools/policy-summary/policy-summary.class.js +1 -1
  28. package/dist/components/agent-tools/prompt-studio/prompt-studio.styles.js +0 -15
  29. package/dist/components/agent-tools/result-card/result-card.styles.js +0 -7
  30. package/dist/components/agent-tools/result-card/result-field.styles.js +0 -5
  31. package/dist/components/agent-tools/schema-viewer/schema-viewer.styles.js +2 -5
  32. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +1 -1
  33. package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +0 -15
  34. package/dist/components/agent-tools/stack-trace/stack-trace.styles.js +0 -20
  35. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
  36. package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +1 -4
  37. package/dist/components/agent-tools/task-list/task-list.class.js +2 -2
  38. package/dist/components/agent-tools/task-list/task-list.styles.js +0 -15
  39. package/dist/components/agent-tools/terminal/terminal.class.d.ts +11 -6
  40. package/dist/components/agent-tools/terminal/terminal.class.js +4 -4
  41. package/dist/components/agent-tools/terminal/terminal.styles.js +0 -46
  42. package/dist/components/agent-tools/test-results/test-results.class.js +2 -2
  43. package/dist/components/agent-tools/test-results/test-results.styles.js +0 -5
  44. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
  45. package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +0 -41
  46. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.styles.js +0 -41
  47. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +2 -2
  48. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.styles.js +0 -30
  49. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +6 -6
  50. package/dist/components/agent-tools/tool-param-form/tool-param-form.styles.js +0 -5
  51. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +2 -2
  52. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.styles.js +0 -20
  53. package/dist/components/agent-tools/tool-result-view/tool-result-view.styles.js +0 -4
  54. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.styles.js +0 -21
  55. package/dist/components/agent-tools/trace-tree/trace-tree.class.js +2 -2
  56. package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +7 -31
  57. package/dist/components/charts/chart/bar-chart.class.js +1 -1
  58. package/dist/components/charts/chart/box-plot.styles.js +0 -20
  59. package/dist/components/charts/chart/bubble-chart.class.js +1 -1
  60. package/dist/components/charts/chart/chart-colors.d.ts +1 -1
  61. package/dist/components/charts/chart/chart-colors.js +1 -1
  62. package/dist/components/charts/chart/chart-core-loader.d.ts +1 -0
  63. package/dist/components/charts/chart/chart-core-loader.js +1 -1
  64. package/dist/components/charts/chart/chart-feature-loader.d.ts +35 -0
  65. package/dist/components/charts/chart/chart-feature-loader.js +1 -1
  66. package/dist/components/charts/chart/chart.class.d.ts +93 -0
  67. package/dist/components/charts/chart/chart.class.js +3 -3
  68. package/dist/components/charts/chart/chart.styles.js +0 -27
  69. package/dist/components/charts/chart/doughnut-chart.class.js +1 -1
  70. package/dist/components/charts/chart/histogram.class.js +1 -1
  71. package/dist/components/charts/chart/line-chart.class.js +1 -1
  72. package/dist/components/charts/chart/lite-chart.class.d.ts +20 -1
  73. package/dist/components/charts/chart/lite-chart.class.js +4 -4
  74. package/dist/components/charts/chart/lite-chart.styles.js +0 -27
  75. package/dist/components/charts/chart/pie-chart.class.js +1 -1
  76. package/dist/components/charts/chart/polar-area-chart.class.js +1 -1
  77. package/dist/components/charts/chart/radar-chart.class.js +1 -1
  78. package/dist/components/charts/chart/scatter-chart.class.js +1 -1
  79. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +20 -0
  80. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +3 -1
  81. package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +3 -0
  82. package/dist/components/conversation/audio-visualizer/audio-visualizer.styles.js +0 -7
  83. package/dist/components/conversation/branch-picker/branch-picker.styles.js +0 -3
  84. package/dist/components/conversation/chat-composer/chat-composer.styles.js +0 -51
  85. package/dist/components/conversation/chat-message/chat-message.class.js +2 -2
  86. package/dist/components/conversation/chat-message/chat-message.styles.js +13 -35
  87. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  88. package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +0 -33
  89. package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
  90. package/dist/components/conversation/checkpoint/checkpoint.styles.js +0 -3
  91. package/dist/components/conversation/code-block/code-block-shared.d.ts +5 -2
  92. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  93. package/dist/components/conversation/code-block/code-block.styles.js +4 -95
  94. package/dist/components/conversation/code-block/code-loader.d.ts +11 -0
  95. package/dist/components/conversation/code-block/code-loader.js +1 -1
  96. package/dist/components/conversation/code-block/shiki-types.d.ts +12 -0
  97. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  98. package/dist/components/conversation/conversation-item/conversation-item.styles.js +8 -54
  99. package/dist/components/conversation/generation-metrics/generation-metrics.class.js +2 -2
  100. package/dist/components/conversation/generation-metrics/generation-metrics.styles.js +0 -17
  101. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  102. package/dist/components/conversation/markdown/markdown.styles.js +0 -41
  103. package/dist/components/conversation/message-actions/message-actions.styles.js +0 -3
  104. package/dist/components/conversation/message-feedback/message-feedback.styles.js +0 -35
  105. package/dist/components/conversation/message-parts/message-parts.class.d.ts +1 -1
  106. package/dist/components/conversation/message-parts/message-parts.styles.js +0 -5
  107. package/dist/components/conversation/model-select/model-select.class.js +3 -3
  108. package/dist/components/conversation/model-select/model-select.styles.js +12 -47
  109. package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +0 -6
  110. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -0
  111. package/dist/components/conversation/prompt-input/prompt-input.styles.js +0 -10
  112. package/dist/components/conversation/push-to-talk/push-to-talk.styles.js +0 -8
  113. package/dist/components/conversation/realtime-session/realtime-session.styles.js +1 -1
  114. package/dist/components/conversation/selection-toolbar/selection-toolbar.styles.js +1 -11
  115. package/dist/components/conversation/stream-status/stream-status.styles.js +0 -16
  116. package/dist/components/conversation/streaming-text/streaming-text.styles.js +0 -15
  117. package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +0 -5
  118. package/dist/components/conversation/thread-list/thread-list.styles.js +5 -19
  119. package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +16 -4
  120. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  121. package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +0 -1
  122. package/dist/components/conversation/typing-indicator/typing-indicator.styles.js +0 -23
  123. package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
  124. package/dist/components/conversation/usage-badge/usage-badge.styles.js +0 -3
  125. package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -3
  126. package/dist/components/conversation/voice-picker/voice-picker.styles.js +9 -29
  127. package/dist/components/conversation/widget-renderer/resolve.d.ts +2 -0
  128. package/dist/components/conversation/widget-renderer/resolve.js +1 -1
  129. package/dist/components/data/calendar/calendar.class.d.ts +15 -2
  130. package/dist/components/data/calendar/calendar.class.js +2 -2
  131. package/dist/components/data/calendar/calendar.styles.js +2 -28
  132. package/dist/components/data/condition-builder/condition-builder.class.d.ts +10 -6
  133. package/dist/components/data/condition-builder/condition-builder.class.js +2 -2
  134. package/dist/components/data/condition-builder/condition-builder.styles.js +0 -6
  135. package/dist/components/data/context-meter/context-meter.styles.js +0 -24
  136. package/dist/components/data/data-grid/data-grid.class.js +3 -3
  137. package/dist/components/data/data-grid/data-grid.styles.js +0 -22
  138. package/dist/components/data/document-library/document-library.class.js +2 -2
  139. package/dist/components/data/document-library/document-library.styles.js +0 -4
  140. package/dist/components/data/env-list/env-list.class.js +1 -1
  141. package/dist/components/data/env-list/env-list.styles.js +7 -4
  142. package/dist/components/data/file-tree/file-tree.class.d.ts +12 -0
  143. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  144. package/dist/components/data/flow-canvas/flow-canvas.styles.js +12 -19
  145. package/dist/components/data/flow-controls/flow-controls.class.js +2 -2
  146. package/dist/components/data/flow-controls/flow-controls.styles.js +3 -36
  147. package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
  148. package/dist/components/data/flow-minimap/flow-minimap.styles.js +0 -9
  149. package/dist/components/data/flow-node/flow-node.styles.js +0 -23
  150. package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
  151. package/dist/components/data/flow-run-status/flow-run-status.styles.js +0 -7
  152. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +0 -7
  153. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
  154. package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +0 -10
  155. package/dist/components/data/heatmap/heatmap-scale.d.ts +20 -0
  156. package/dist/components/data/heatmap/heatmap-scale.js +1 -1
  157. package/dist/components/data/heatmap/heatmap.class.d.ts +85 -2
  158. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  159. package/dist/components/data/heatmap/heatmap.styles.js +0 -54
  160. package/dist/components/data/pagination/pagination.class.js +1 -1
  161. package/dist/components/data/pagination/pagination.styles.js +23 -46
  162. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +34 -1
  163. package/dist/components/data/sequence-strip/sequence-strip.class.js +5 -2
  164. package/dist/components/data/sequence-strip/sequence-strip.styles.js +14 -20
  165. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  166. package/dist/components/data/stat/stat.styles.js +0 -67
  167. package/dist/components/data/table/table.class.d.ts +42 -3
  168. package/dist/components/data/table/table.class.js +4 -4
  169. package/dist/components/data/table/table.styles.js +20 -91
  170. package/dist/components/data/timeline/timeline-item.styles.js +0 -30
  171. package/dist/components/data/timeline/timeline.class.d.ts +89 -1
  172. package/dist/components/data/timeline/timeline.class.js +2 -2
  173. package/dist/components/data/timeline/timeline.styles.js +111 -31
  174. package/dist/components/data/tree/tree-item.styles.js +1 -28
  175. package/dist/components/data/tree/tree.class.js +2 -2
  176. package/dist/components/data/tree/tree.styles.js +0 -6
  177. package/dist/components/data/word-cloud/word-cloud.styles.js +0 -5
  178. package/dist/components/forms/button/button.class.js +1 -1
  179. package/dist/components/forms/button/button.styles.js +1 -106
  180. package/dist/components/forms/checkbox/checkbox.class.d.ts +3 -0
  181. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  182. package/dist/components/forms/checkbox/checkbox.styles.js +0 -39
  183. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +21 -2
  184. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  185. package/dist/components/forms/checkbox-group/checkbox-group.styles.js +0 -18
  186. package/dist/components/forms/code-editor/code-editor.styles.js +0 -30
  187. package/dist/components/forms/color-picker/color-picker.class.js +2 -2
  188. package/dist/components/forms/color-picker/color-picker.styles.js +0 -69
  189. package/dist/components/forms/combobox/combobox.class.js +2 -2
  190. package/dist/components/forms/combobox/combobox.styles.js +22 -111
  191. package/dist/components/forms/combobox/option.styles.js +7 -1
  192. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  193. package/dist/components/forms/date-picker/date-input.styles.js +12 -67
  194. package/dist/components/forms/date-picker/date-picker.class.d.ts +1 -0
  195. package/dist/components/forms/date-picker/date-picker.class.js +22 -20
  196. package/dist/components/forms/date-picker/date-picker.styles.js +36 -29
  197. package/dist/components/forms/emoji-picker/emoji-data-loader.d.ts +6 -3
  198. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  199. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +8 -1
  200. package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
  201. package/dist/components/forms/emoji-picker/emoji-picker.styles.js +3 -41
  202. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  203. package/dist/components/forms/icon-button/icon-button.styles.js +0 -16
  204. package/dist/components/forms/input/input.styles.js +0 -54
  205. package/dist/components/forms/input/number-input.styles.d.ts +4 -5
  206. package/dist/components/forms/input/number-input.styles.js +0 -11
  207. package/dist/components/forms/input/time-input-shared.d.ts +11 -0
  208. package/dist/components/forms/input/time-input-shared.js +1 -1
  209. package/dist/components/forms/input/time-input.class.d.ts +11 -2
  210. package/dist/components/forms/input/time-input.class.js +1 -1
  211. package/dist/components/forms/input/time-input.styles.js +0 -6
  212. package/dist/components/forms/locale-picker/locale-picker.class.js +2 -2
  213. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -26
  214. package/dist/components/forms/otp-input/otp-input.class.js +3 -3
  215. package/dist/components/forms/otp-input/otp-input.styles.js +0 -16
  216. package/dist/components/forms/phone-input/phone-input.class.d.ts +9 -1
  217. package/dist/components/forms/phone-input/phone-input.class.js +2 -2
  218. package/dist/components/forms/phone-input/phone-input.styles.js +0 -37
  219. package/dist/components/forms/radio/radio-button.styles.js +1 -30
  220. package/dist/components/forms/radio/radio-group.styles.js +0 -4
  221. package/dist/components/forms/radio/radio.styles.js +0 -44
  222. package/dist/components/forms/rubric-form/rubric-form.styles.js +0 -5
  223. package/dist/components/forms/select/select.class.js +1 -1
  224. package/dist/components/forms/select/select.styles.js +14 -114
  225. package/dist/components/forms/slider/slider.styles.js +0 -55
  226. package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +0 -11
  227. package/dist/components/forms/swatch-picker/swatch-picker.class.js +2 -2
  228. package/dist/components/forms/swatch-picker/swatch-picker.styles.js +0 -77
  229. package/dist/components/forms/switch/switch.class.d.ts +3 -0
  230. package/dist/components/forms/switch/switch.class.js +1 -1
  231. package/dist/components/forms/switch/switch.styles.js +3 -38
  232. package/dist/components/forms/textarea/textarea.styles.js +0 -28
  233. package/dist/components/forms/time-range/time-range.styles.js +12 -84
  234. package/dist/components/forms/token-input/token-input.class.d.ts +23 -9
  235. package/dist/components/forms/token-input/token-input.class.js +1 -1
  236. package/dist/components/forms/token-input/token-input.styles.js +1 -54
  237. package/dist/components/layout/app-rail/app-rail-item.class.js +2 -2
  238. package/dist/components/layout/app-rail/app-rail-item.styles.js +0 -13
  239. package/dist/components/layout/app-rail/app-rail.class.d.ts +5 -0
  240. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  241. package/dist/components/layout/app-rail/app-rail.styles.js +0 -46
  242. package/dist/components/layout/button-group/button-group.styles.js +0 -6
  243. package/dist/components/layout/card/card.class.d.ts +12 -0
  244. package/dist/components/layout/card/card.styles.js +5 -13
  245. package/dist/components/layout/carousel/carousel.styles.js +0 -1
  246. package/dist/components/layout/command-palette/command-palette.class.d.ts +8 -0
  247. package/dist/components/layout/command-palette/command-palette.class.js +3 -1
  248. package/dist/components/layout/command-palette/command-palette.styles.js +1 -13
  249. package/dist/components/layout/control-group/control-group.styles.js +0 -7
  250. package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
  251. package/dist/components/layout/dashboard-grid/dashboard-grid.styles.js +6 -25
  252. package/dist/components/layout/details/accordion.class.d.ts +13 -0
  253. package/dist/components/layout/details/accordion.class.js +1 -1
  254. package/dist/components/layout/details/details.class.js +1 -1
  255. package/dist/components/layout/details/details.styles.js +0 -12
  256. package/dist/components/layout/dock-panel/dock-panel.styles.js +0 -45
  257. package/dist/components/layout/drilldown-panel/drilldown-panel.class.d.ts +2 -0
  258. package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +2 -2
  259. package/dist/components/layout/drilldown-panel/drilldown-panel.styles.js +0 -4
  260. package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
  261. package/dist/components/layout/filter-bar/filter-bar.styles.js +0 -9
  262. package/dist/components/layout/menu/menu-item.class.d.ts +5 -0
  263. package/dist/components/layout/menu/menu-item.class.js +1 -1
  264. package/dist/components/layout/menu/menu-item.styles.js +0 -49
  265. package/dist/components/layout/menu/menu-label.styles.js +0 -2
  266. package/dist/components/layout/menu/menu.styles.js +0 -18
  267. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  268. package/dist/components/layout/multi-split/multi-split.styles.js +8 -51
  269. package/dist/components/layout/page/page.class.d.ts +4 -0
  270. package/dist/components/layout/page/page.class.js +1 -1
  271. package/dist/components/layout/reorder-list/reorder-item.styles.js +0 -4
  272. package/dist/components/layout/responsive-panel/responsive-panel.styles.js +0 -27
  273. package/dist/components/layout/scroller/scroller.styles.js +0 -20
  274. package/dist/components/layout/segmented/segmented.class.d.ts +7 -1
  275. package/dist/components/layout/segmented/segmented.class.js +1 -1
  276. package/dist/components/layout/segmented/segmented.styles.js +69 -37
  277. package/dist/components/layout/split-panel/split-panel.styles.js +1 -7
  278. package/dist/components/layout/stepper/stepper.class.d.ts +8 -1
  279. package/dist/components/layout/stepper/stepper.class.js +1 -1
  280. package/dist/components/layout/stepper/stepper.styles.js +140 -41
  281. package/dist/components/layout/tab-group/tab-group.class.d.ts +4 -1
  282. package/dist/components/layout/tab-group/tab-group.styles.js +9 -75
  283. package/dist/components/layout/tab-group/tab.styles.js +0 -2
  284. package/dist/components/layout/virtual-list/virtual-list.class.d.ts +4 -4
  285. package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
  286. package/dist/components/layout/virtual-list/virtual-list.styles.js +0 -68
  287. package/dist/components/layout/widget/widget.class.d.ts +5 -1
  288. package/dist/components/layout/widget/widget.class.js +1 -1
  289. package/dist/components/layout/widget/widget.styles.js +97 -40
  290. package/dist/components/media/animated-image/animated-image.class.d.ts +3 -0
  291. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  292. package/dist/components/media/animated-image/animated-image.styles.js +0 -28
  293. package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +1 -1
  294. package/dist/components/media/attachment-chip/attachment-chip.class.js +2 -2
  295. package/dist/components/media/attachment-chip/attachment-chip.styles.js +0 -31
  296. package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +1 -1
  297. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +4 -4
  298. package/dist/components/media/attachment-trigger/attachment-trigger.styles.js +0 -40
  299. package/dist/components/media/av-player/av-player.class.d.ts +5 -6
  300. package/dist/components/media/av-player/av-player.class.js +1 -1
  301. package/dist/components/media/av-player/av-player.styles.js +0 -45
  302. package/dist/components/media/avatar/avatar.styles.js +3 -16
  303. package/dist/components/media/file-icon/file-icon.class.d.ts +1 -2
  304. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  305. package/dist/components/media/file-input/file-input.class.d.ts +12 -0
  306. package/dist/components/media/file-input/file-input.class.js +1 -1
  307. package/dist/components/media/file-input/file-input.styles.js +3 -24
  308. package/dist/components/media/flag/flag.class.d.ts +20 -0
  309. package/dist/components/media/flag/flag.class.js +4 -2
  310. package/dist/components/media/flag/flag.styles.js +7 -1
  311. package/dist/components/media/flag/language-map.d.ts +10 -0
  312. package/dist/components/media/flag/language-map.js +1 -1
  313. package/dist/components/media/image-comparer/image-comparer.styles.js +4 -33
  314. package/dist/components/media/image-viewer/image-viewer.class.js +0 -2
  315. package/dist/components/media/image-viewer/image-viewer.styles.js +7 -27
  316. package/dist/components/media/lightbox/lightbox.class.js +0 -2
  317. package/dist/components/media/lightbox/lightbox.styles.js +2 -21
  318. package/dist/components/media/map/map-loader.d.ts +19 -1
  319. package/dist/components/media/map/map-loader.js +1 -1
  320. package/dist/components/media/map/map.class.d.ts +141 -1
  321. package/dist/components/media/map/map.class.js +15 -3
  322. package/dist/components/media/map/map.styles.js +20 -17
  323. package/dist/components/media/media-card/media-card.class.d.ts +14 -3
  324. package/dist/components/media/media-card/media-card.class.js +1 -1
  325. package/dist/components/media/media-card/media-card.styles.js +2 -28
  326. package/dist/components/media/pan-zoom/pan-zoom.styles.js +0 -3
  327. package/dist/components/media/qr-code/qr-code.class.d.ts +3 -2
  328. package/dist/components/media/qr-code/qr-code.class.js +2 -2
  329. package/dist/components/media/qr-code/qr-code.styles.js +0 -3
  330. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +2 -0
  331. package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -1
  332. package/dist/components/media/sequence-playback/sequence-playback.styles.js +0 -19
  333. package/dist/components/media/video/video.class.d.ts +23 -2
  334. package/dist/components/media/video/video.class.js +3 -3
  335. package/dist/components/media/video/video.styles.js +4 -2
  336. package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +3 -2
  337. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
  338. package/dist/components/media/zoomable-frame/zoomable-frame.styles.js +0 -5
  339. package/dist/components/overlays/alert/alert.styles.js +4 -2
  340. package/dist/components/overlays/badge/badge.styles.js +4 -48
  341. package/dist/components/overlays/badge/tag.styles.js +0 -14
  342. package/dist/components/overlays/callout/callout.styles.js +2 -13
  343. package/dist/components/overlays/chip/chip-group.styles.js +0 -18
  344. package/dist/components/overlays/chip/chip.styles.js +6 -69
  345. package/dist/components/overlays/dialog/confirm.d.ts +1 -4
  346. package/dist/components/overlays/dialog/confirm.js +1 -1
  347. package/dist/components/overlays/dialog/dialog.class.d.ts +12 -9
  348. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  349. package/dist/components/overlays/dialog/dialog.styles.js +0 -43
  350. package/dist/components/overlays/drawer/drawer.class.d.ts +2 -2
  351. package/dist/components/overlays/drawer/drawer.styles.js +0 -9
  352. package/dist/components/overlays/empty/empty.styles.js +0 -12
  353. package/dist/components/overlays/kbd/kbd.class.js +1 -1
  354. package/dist/components/overlays/kbd/kbd.styles.js +0 -8
  355. package/dist/components/overlays/overlay/dropdown.class.d.ts +1 -6
  356. package/dist/components/overlays/overlay/dropdown.class.js +2 -2
  357. package/dist/components/overlays/overlay/overlay.styles.js +0 -28
  358. package/dist/components/overlays/overlay/popover.class.d.ts +9 -1
  359. package/dist/components/overlays/overlay/popover.class.js +2 -2
  360. package/dist/components/overlays/overlay/tooltip.class.d.ts +10 -0
  361. package/dist/components/overlays/overlay/tooltip.class.js +2 -2
  362. package/dist/components/overlays/popup/popup.class.d.ts +1 -0
  363. package/dist/components/overlays/popup/popup.class.js +2 -2
  364. package/dist/components/overlays/popup/popup.styles.js +0 -15
  365. package/dist/components/overlays/progress/progress-ring.class.d.ts +9 -1
  366. package/dist/components/overlays/progress/progress-ring.class.js +3 -3
  367. package/dist/components/overlays/progress/progress.styles.js +0 -21
  368. package/dist/components/overlays/rating/rating.styles.js +0 -25
  369. package/dist/components/overlays/skeleton/skeleton.styles.js +0 -4
  370. package/dist/components/overlays/spinner/spinner.styles.js +2 -5
  371. package/dist/components/overlays/toast/toast-item.styles.js +3 -45
  372. package/dist/components/retrieval/chunk-inspector/chunk-inspector.styles.js +0 -35
  373. package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +2 -2
  374. package/dist/components/retrieval/citation-badge/citation-badge.class.js +3 -3
  375. package/dist/components/retrieval/citation-badge/citation-badge.styles.js +0 -20
  376. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +1 -1
  377. package/dist/components/retrieval/claim-evidence/claim-evidence.styles.js +0 -8
  378. package/dist/components/retrieval/community-card/community-card.class.d.ts +1 -0
  379. package/dist/components/retrieval/community-card/community-card.styles.js +0 -6
  380. package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +8 -12
  381. package/dist/components/retrieval/entity-card/entity-card.class.d.ts +4 -3
  382. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  383. package/dist/components/retrieval/entity-card/entity-card.styles.js +0 -12
  384. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +10 -4
  385. package/dist/components/retrieval/entity-chip/entity-chip.class.js +3 -3
  386. package/dist/components/retrieval/entity-chip/entity-chip.styles.js +6 -9
  387. package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +19 -5
  388. package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +1 -1
  389. package/dist/components/retrieval/graph/graph.class.d.ts +5 -0
  390. package/dist/components/retrieval/graph/graph.class.js +1 -1
  391. package/dist/components/retrieval/graph/graph.styles.js +0 -30
  392. package/dist/components/retrieval/graph-legend/graph-legend.styles.js +0 -3
  393. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +2 -2
  394. package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +0 -25
  395. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +2 -0
  396. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +0 -7
  397. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +20 -6
  398. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +2 -2
  399. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +6 -11
  400. package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
  401. package/dist/components/retrieval/mind-map/mind-map.class.d.ts +5 -3
  402. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  403. package/dist/components/retrieval/mind-map/mind-map.styles.js +0 -2
  404. package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +3 -2
  405. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  406. package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +0 -30
  407. package/dist/components/retrieval/node-palette/node-palette.styles.js +0 -11
  408. package/dist/components/retrieval/path-strip/path-strip.styles.js +0 -10
  409. package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +12 -3
  410. package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
  411. package/dist/components/retrieval/provenance-panel/provenance-panel.styles.js +0 -2
  412. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +3 -2
  413. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +2 -2
  414. package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +0 -28
  415. package/dist/components/retrieval/retrieval-search/retrieval-search.styles.js +0 -4
  416. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
  417. package/dist/components/retrieval/retrieval-trace/retrieval-trace.styles.js +0 -2
  418. package/dist/components/retrieval/source-card/source-card.styles.js +0 -13
  419. package/dist/components/retrieval/source-list/source-list.styles.js +0 -7
  420. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  421. package/dist/components/retrieval/source-picker/source-picker.styles.js +0 -7
  422. package/dist/components/utility/copy-button/copy-button.styles.js +0 -10
  423. package/dist/components/utility/diff-view/diff-view.styles.js +0 -14
  424. package/dist/components/utility/export-button/export-button.styles.js +0 -22
  425. package/dist/components/utility/icon/icon.styles.js +0 -6
  426. package/dist/components/utility/json-viewer/json-viewer.styles.js +2 -48
  427. package/dist/components/utility/known-date/known-date.class.d.ts +7 -3
  428. package/dist/components/utility/known-date/known-date.styles.js +10 -51
  429. package/dist/components/utility/live-region/live-region.styles.js +0 -4
  430. package/dist/components/utility/mention-popover/mention-popover.styles.js +0 -25
  431. package/dist/components/utility/poll-status/poll-status.styles.js +0 -4
  432. package/dist/components/utility/random-content/random-content.class.d.ts +22 -0
  433. package/dist/components/utility/random-content/random-content.class.js +3 -2
  434. package/dist/components/utility/random-content/random-content.styles.js +6 -13
  435. package/dist/components/utility/tour/tour.class.d.ts +4 -2
  436. package/dist/components/utility/tour/tour.class.js +3 -3
  437. package/dist/components/utility/tour/tour.styles.js +0 -13
  438. package/dist/components/utility/visually-hidden/visually-hidden.styles.js +0 -5
  439. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  440. package/dist/components/viewers/archive-viewer/archive-viewer.styles.d.ts +2 -2
  441. package/dist/components/viewers/archive-viewer/archive-viewer.styles.js +0 -10
  442. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  443. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  444. package/dist/components/viewers/csv-viewer/csv-viewer.styles.js +0 -19
  445. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
  446. package/dist/components/viewers/dataset-viewer/dataset-viewer.styles.js +0 -15
  447. package/dist/components/viewers/document-compare/document-compare.class.js +1 -1
  448. package/dist/components/viewers/document-compare/document-compare.styles.js +0 -3
  449. package/dist/components/viewers/document-preview/document-preview.styles.js +0 -25
  450. package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +2 -1
  451. package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
  452. package/dist/components/viewers/document-viewer/document-viewer.styles.js +0 -5
  453. package/dist/components/viewers/docx-viewer/docx-viewer.styles.js +0 -17
  454. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  455. package/dist/components/viewers/ebook-viewer/ebook-viewer.styles.js +0 -4
  456. package/dist/components/viewers/email-viewer/email-viewer.styles.js +0 -7
  457. package/dist/components/viewers/geojson-view/geojson-view.styles.js +0 -5
  458. package/dist/components/viewers/highlight-layer/highlight-layer.styles.js +0 -3
  459. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
  460. package/dist/components/viewers/notebook-viewer/notebook-viewer.styles.js +0 -38
  461. package/dist/components/viewers/page-rail/page-rail.class.js +1 -1
  462. package/dist/components/viewers/page-rail/page-rail.styles.js +0 -13
  463. package/dist/components/viewers/pdf-viewer/pdf-loader.d.ts +13 -2
  464. package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
  465. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +32 -2
  466. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
  467. package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -27
  468. package/dist/components/viewers/pptx-viewer/pptx-viewer.styles.js +0 -3
  469. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  470. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.styles.js +0 -14
  471. package/dist/components/viewers/svg-viewer/svg-viewer.styles.js +0 -7
  472. package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +2 -24
  473. package/dist/custom-elements-jsx.d.ts +56 -37
  474. package/dist/events.d.ts +43 -33
  475. package/dist/internal/agent-status-variants.d.ts +18 -0
  476. package/dist/internal/agent-status-variants.js +1 -0
  477. package/dist/internal/announcer.d.ts +8 -3
  478. package/dist/internal/announcer.js +1 -1
  479. package/dist/internal/autoloader-manifest.js +1 -1
  480. package/dist/internal/canvas-color.d.ts +16 -0
  481. package/dist/internal/canvas-color.js +1 -1
  482. package/dist/internal/catalog-picker.d.ts +0 -1
  483. package/dist/internal/catalog-picker.js +1 -1
  484. package/dist/internal/default-strings.generated.d.ts +1 -0
  485. package/dist/internal/default-strings.generated.js +1 -1
  486. package/dist/internal/dev-mode-attribute-warning.d.ts +30 -0
  487. package/dist/internal/dev-mode-attribute-warning.js +1 -0
  488. package/dist/internal/localization-runtime.js +1 -1
  489. package/dist/internal/localization-types.d.ts +1 -1
  490. package/dist/internal/localization.js +1 -1
  491. package/dist/internal/lyra-element.d.ts +13 -0
  492. package/dist/internal/lyra-element.js +1 -1
  493. package/dist/internal/media-controller.js +1 -1
  494. package/dist/internal/package-metadata.d.ts +1 -1
  495. package/dist/internal/package-metadata.js +1 -1
  496. package/dist/internal/scroll-overflow.d.ts +35 -13
  497. package/dist/internal/scroll-overflow.js +1 -1
  498. package/dist/internal/sizes.styles.js +0 -2
  499. package/dist/internal/specialist-tokens.styles.js +6 -11
  500. package/dist/internal/text-highlights.d.ts +4 -1
  501. package/dist/internal/text-highlights.js +1 -1
  502. package/dist/internal/tokens/palette.styles.js +0 -15
  503. package/dist/internal/tokens.styles.js +19 -113
  504. package/dist/lyra.d.ts +8 -5
  505. package/dist/styles/reservations.css +82 -0
  506. package/dist/svelte.d.ts +56 -37
  507. package/dist/translations/ar.js +1 -1
  508. package/dist/translations/de.js +1 -1
  509. package/dist/translations/es.js +1 -1
  510. package/dist/translations/fa.js +1 -1
  511. package/dist/translations/fr.js +1 -1
  512. package/dist/translations/he.js +1 -1
  513. package/dist/translations/ja.js +1 -1
  514. package/dist/translations/pt-BR.js +1 -1
  515. package/dist/translations/ru.js +1 -1
  516. package/dist/translations/zh-CN.js +1 -1
  517. package/dist/vue.d.ts +56 -37
  518. package/llms/components/lr-accordion-item.md +12 -3
  519. package/llms/components/lr-accordion.md +11 -2
  520. package/llms/components/lr-agent-eval-dashboard.md +1 -1
  521. package/llms/components/lr-agent-trace.md +3 -1
  522. package/llms/components/lr-agent-workspace.md +20 -0
  523. package/llms/components/lr-artifact-panel.md +10 -4
  524. package/llms/components/lr-attachment-chip.md +7 -4
  525. package/llms/components/lr-attachment-trigger.md +9 -6
  526. package/llms/components/lr-av-player.md +3 -1
  527. package/llms/components/lr-avatar.md +6 -6
  528. package/llms/components/lr-bar-chart.md +4 -3
  529. package/llms/components/lr-box-plot.md +1 -1
  530. package/llms/components/lr-browser-frame.md +7 -3
  531. package/llms/components/lr-bubble-chart.md +4 -3
  532. package/llms/components/lr-calendar.md +9 -2
  533. package/llms/components/lr-card.md +24 -0
  534. package/llms/components/lr-chart.md +32 -8
  535. package/llms/components/lr-chat-viewport.md +7 -2
  536. package/llms/components/lr-checkbox-group.md +13 -5
  537. package/llms/components/lr-checkbox.md +5 -2
  538. package/llms/components/lr-checkpoint.md +6 -2
  539. package/llms/components/lr-combobox.md +5 -2
  540. package/llms/components/lr-command-palette.md +4 -1
  541. package/llms/components/lr-confirm-bar.md +7 -3
  542. package/llms/components/lr-context-meter.md +12 -11
  543. package/llms/components/lr-conversation-item.md +7 -4
  544. package/llms/components/lr-details.md +11 -2
  545. package/llms/components/lr-dialog.md +15 -10
  546. package/llms/components/lr-dock-panel.md +7 -10
  547. package/llms/components/lr-document-preview.md +6 -1
  548. package/llms/components/lr-document-viewer.md +3 -2
  549. package/llms/components/lr-doughnut-chart.md +4 -3
  550. package/llms/components/lr-drawer.md +3 -3
  551. package/llms/components/lr-entity-card.md +3 -3
  552. package/llms/components/lr-entity-chip.md +1 -1
  553. package/llms/components/lr-entity-dossier.md +4 -1
  554. package/llms/components/lr-file-input.md +2 -2
  555. package/llms/components/lr-flag.md +20 -5
  556. package/llms/components/lr-heatmap.md +29 -1
  557. package/llms/components/lr-histogram.md +3 -1
  558. package/llms/components/lr-icon.md +1 -1
  559. package/llms/components/lr-json-schema-viewer.md +2 -1
  560. package/llms/components/lr-knowledge-graph-explorer.md +8 -3
  561. package/llms/components/lr-known-date.md +4 -2
  562. package/llms/components/lr-line-chart.md +4 -3
  563. package/llms/components/lr-lite-chart.md +16 -6
  564. package/llms/components/lr-map.md +72 -8
  565. package/llms/components/lr-markdown-core.md +3 -2
  566. package/llms/components/lr-media-card.md +28 -12
  567. package/llms/components/lr-message-parts.md +2 -1
  568. package/llms/components/lr-model-select.md +9 -10
  569. package/llms/components/lr-model-settings-panel.md +9 -9
  570. package/llms/components/lr-neighbor-list.md +1 -1
  571. package/llms/components/lr-notebook-viewer.md +6 -3
  572. package/llms/components/lr-option.md +5 -2
  573. package/llms/components/lr-pdf-viewer.md +62 -2
  574. package/llms/components/lr-pie-chart.md +4 -3
  575. package/llms/components/lr-polar-area-chart.md +4 -3
  576. package/llms/components/lr-popover.md +5 -0
  577. package/llms/components/lr-progress-ring.md +8 -1
  578. package/llms/components/lr-prompt-studio.md +1 -1
  579. package/llms/components/lr-provenance-panel.md +4 -2
  580. package/llms/components/lr-qr-code.md +1 -1
  581. package/llms/components/lr-radar-chart.md +4 -3
  582. package/llms/components/lr-rag-eval-dashboard.md +2 -2
  583. package/llms/components/lr-random-content.md +13 -0
  584. package/llms/components/lr-reorder-item.md +6 -1
  585. package/llms/components/lr-reorder-list.md +6 -1
  586. package/llms/components/lr-responsive-panel.md +11 -7
  587. package/llms/components/lr-scatter-chart.md +4 -3
  588. package/llms/components/lr-sequence-strip.md +16 -2
  589. package/llms/components/lr-slider.md +12 -5
  590. package/llms/components/lr-sparkline.md +1 -1
  591. package/llms/components/lr-suggestion-chips.md +7 -2
  592. package/llms/components/lr-swatch-picker.md +5 -5
  593. package/llms/components/lr-switch.md +5 -2
  594. package/llms/components/lr-table.md +30 -4
  595. package/llms/components/lr-terminal.md +3 -1
  596. package/llms/components/lr-thread-list.md +8 -8
  597. package/llms/components/lr-time-input.md +6 -1
  598. package/llms/components/lr-timeline-item.md +24 -0
  599. package/llms/components/lr-timeline.md +25 -1
  600. package/llms/components/lr-token-input.md +7 -2
  601. package/llms/components/lr-tool-approval-dialog.md +7 -8
  602. package/llms/components/lr-tool-call-chip.md +5 -1
  603. package/llms/components/lr-tool-param-form.md +14 -12
  604. package/llms/components/lr-tool-result-dialog.md +11 -9
  605. package/llms/components/lr-tool-result-view.md +7 -6
  606. package/llms/components/lr-tool-select-dialog.md +18 -16
  607. package/llms/components/lr-trace-tree.md +3 -1
  608. package/llms/components/lr-usage-badge.md +4 -1
  609. package/llms/components/lr-video-playlist.md +1 -1
  610. package/llms/components/lr-virtual-list.md +22 -14
  611. package/llms/components/lr-voice-picker.md +8 -5
  612. package/llms/components/lr-widget-renderer.md +3 -3
  613. package/llms/components/lr-widget.md +1 -1
  614. package/llms/components/lr-word-cloud.md +6 -2
  615. package/llms/index.md +1 -1
  616. package/llms/peers.md +13 -3
  617. package/llms/shared.md +83 -2
  618. package/llms-full.txt +1159 -288
  619. package/package.json +19 -7
  620. package/vscode-css-data.json +37 -2
  621. package/vscode-html-data.json +402 -45
  622. package/web-types.json +300 -56
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{resolveCssLength}from"../../../internal/css-length.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{chevronIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{finiteCount,finiteDuration,finiteInteger,finiteRange}from"../../../internal/numbers.js";import{sizes}from"../../../internal/sizes.styles.js";import{srOnly}from"../../../internal/a11y.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{aggregateValues,columnId,columnValue,filterRows,pathValue,rowsAsDelimited,searchRows,sortRows}from"./data-grid-processing.js";import{styles}from"./data-grid.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copied,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_dataGridColumnMenu,LYRA_DEFAULT_dataGridPinEnd,LYRA_DEFAULT_dataGridPinStart,LYRA_DEFAULT_dataGridRowsPerPage,LYRA_DEFAULT_dataGridTreeLimitReached,LYRA_DEFAULT_dataGridUnpin,LYRA_DEFAULT_expand,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_paginationFirstPage,LYRA_DEFAULT_paginationJumpToPage,LYRA_DEFAULT_paginationLabel,LYRA_DEFAULT_paginationLastPage,LYRA_DEFAULT_previous,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_tableFilterLabel}from"../../../internal/default-strings.generated.js";export*from"./data-grid-types.js";const selectableConverter={fromAttribute(value){return value===null?"none":value===""||value==="multiple"?"multiple":value==="single"||value==="none"?value:"none"},toAttribute(value){return value==="none"?null:value===""||value==="multiple"?"":value}};function snapshotColumns(value,occurrenceId){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const column of value)try{if(column===null||typeof column!="object"||Array.isArray(column))continue;const hasId=Object.prototype.hasOwnProperty.call(column,"id"),hasField=Object.prototype.hasOwnProperty.call(column,"field"),authoredId=hasId?column.id:void 0,authoredField=hasField?column.field:void 0;if(hasId&&authoredId!==void 0&&(typeof authoredId!="string"||authoredId.trim()==="")||!hasId&&hasField&&authoredField!==void 0&&(typeof authoredField!="string"||authoredField.trim()===""))continue;const identity=typeof authoredId=="string"?authoredId:typeof authoredField=="string"?authoredField:occurrenceId(column);if(seen.has(identity))continue;seen.add(identity);const snapshot={...column,...authoredId===void 0&&authoredField===void 0?{id:identity}:{}};output.push(Object.freeze(snapshot))}catch{}return Object.freeze(output)}const INTERACTIVE_SELECTOR='button, a[href], input, select, textarea, summary, [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="radio"]',VIRTUALIZATION_THRESHOLD=80,VIRTUAL_OVERSCAN=5,DATA_GRID_TREE_NODE_LIMIT=1e4,DATA_GRID_TREE_DEPTH_LIMIT=64,DATA_GRID_DRAG_TYPE="application/x-lyra-data-grid-column";function frozenArray(values){return Object.freeze([...values])}function serializableFilterValue(value){try{const serialized=JSON.stringify({value},(_key,nested)=>typeof nested=="bigint"?nested.toString():typeof nested=="number"&&!Number.isFinite(nested)?null:nested!==null&&typeof nested=="object"&&Object.prototype.toString.call(nested)==="[object Set]"?[...nested]:nested);if(!serialized)return null;const snapshot=JSON.parse(serialized).value??null,stack=[snapshot],visited=new Set;for(;stack.length>0;){const current=stack.pop();if(!(current===null||typeof current!="object"||visited.has(current))){visited.add(current);for(const nested of Object.values(current))stack.push(nested);Object.freeze(current)}}return snapshot}catch{return null}}function isKey(value){return typeof value=="string"&&value.trim()!==""||typeof value=="number"&&Number.isFinite(value)}function snapshotKeys(value){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const key of value)!isKey(key)||seen.has(key)||(seen.add(key),output.push(key));return frozenArray(output)}function keysEqual(left,right){return typeof left==typeof right&&left===right}function arrayHasKey(keys,key){return keys.some(candidate=>keysEqual(candidate,key))}function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.closest=="function"}function valueControl(value){return!isElementValue(value)||typeof value.value!="string"?null:value}function checkableControl(value){return!isElementValue(value)||typeof value.checked!="boolean"?null:value}function dateText(value){try{const timestamp=Date.prototype.getTime.call(value);return Number.isFinite(timestamp)?Date.prototype.toISOString.call(value):""}catch{return}}function humanizeIdentifier(value,locale){const intlLocale=resolveIntlLocale(locale);return value.replaceAll(/[._-]+/gu," ").replaceAll(/([a-z\d])([A-Z])/gu,"$1 $2").replace(/^./u,first=>first.toLocaleUpperCase(intlLocale))}function safeText(value){if(value==null)return"";if(typeof value=="object"){const serializedDate=dateText(value);if(serializedDate!==void 0)return serializedDate}if(Array.isArray(value))return value.map(safeText).join(", ");if(typeof value=="object")try{return JSON.stringify(value,(_key,nested)=>typeof nested=="bigint"?nested.toString():nested)??""}catch{return""}return String(value)}function normalizePinSide(side){return side==="start"?"left":side==="end"?"right":side}function normalizedGroupBy(value){return typeof value!="string"?(value??[]).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT):value.split(/[\s,]+/u).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT)}class LyraDataGrid extends LyraElement{constructor(){super(...arguments),this.appearance="outlined",this.childRows=null,this._columnOrder=Object.freeze([]),this.columnOccurrenceIds=new WeakMap,this.nextColumnOccurrenceId=1,this.rowOccurrenceIds=new WeakMap,this.nextRowOccurrenceId=1,this._columns=Object.freeze([]),this._data=Object.freeze([]),this.dataSource=null,this._expandedRowKeys=Object.freeze([]),this.filterDebounce=250,this.filterFromLeafRows=!1,this._filters=Object.freeze([]),this._groupBy=null,this.label=null,this.loading=!1,this.maxMultiSort=0,this.page=0,this.pageSize=20,this._pageSizeOptions=Object.freeze([10,20,50,100]),this.paginate=!1,this.pinnable=!1,this.reorderable=!1,this.resizable=!1,this.rowClass=null,this.rowDetail=null,this.rowKey=null,this.searchFn=null,this.searchTerm="",this.selectable="none",this.selectableRows=null,this._selectedRowKeys=Object.freeze([]),this.server=!1,this.size="m",this._sort=Object.freeze([]),this.sortDescFirst=!1,this.striped=!1,this.total=-1,this.withColumnMenu=!1,this.withColumnsMenu=!1,this.withoutSortRemoval=!1,this.withSearch=!1,this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map,this.activeFilterColumn=null,this.columnsMenuOpen=!1,this.activeColumnMenu=null,this.liveText="",this.bodyScrollTop=0,this.viewportHeight=0,this.focusedRow=-1,this.focusedColumn=0,this.dragGhost="",this.requestGeneration=0,this.ownsLoadingState=!1,this.columnDragSequence=0,this.lastSelectedIndex=-1,this.isMounting=!0,this.relayEditorFocus=event=>{relayNativeEvent(this,event)},this.relayEditorBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copied:LYRA_DEFAULT_copied,copyFailed:LYRA_DEFAULT_copyFailed,dataGridColumnMenu:LYRA_DEFAULT_dataGridColumnMenu,dataGridPinEnd:LYRA_DEFAULT_dataGridPinEnd,dataGridPinStart:LYRA_DEFAULT_dataGridPinStart,dataGridRowsPerPage:LYRA_DEFAULT_dataGridRowsPerPage,dataGridTreeLimitReached:LYRA_DEFAULT_dataGridTreeLimitReached,dataGridUnpin:LYRA_DEFAULT_dataGridUnpin,expand:LYRA_DEFAULT_expand,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,paginationFirstPage:LYRA_DEFAULT_paginationFirstPage,paginationJumpToPage:LYRA_DEFAULT_paginationJumpToPage,paginationLabel:LYRA_DEFAULT_paginationLabel,paginationLastPage:LYRA_DEFAULT_paginationLastPage,previous:LYRA_DEFAULT_previous,resizeColumn:LYRA_DEFAULT_resizeColumn,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel}}static{this.immutableEventDetails=Object.freeze(["request","lr-column-move","lr-data-error"])}static{this.identityEventDetailProperties=Object.freeze({request:Object.freeze(["signal"]),"lr-data-error":Object.freeze(["error","request"])})}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}get columnOrder(){return this._columnOrder}set columnOrder(value){const previous=this._columnOrder,seen=new Set;this._columnOrder=frozenArray(Array.isArray(value)?value.filter(id=>typeof id!="string"||id.trim()===""||seen.has(id)?!1:(seen.add(id),!0)):[]),this.requestUpdate("columnOrder",previous)}get columns(){return this._columns}set columns(value){const previous=this._columns;this._columns=snapshotColumns(value,column=>{const current=this.columnOccurrenceIds.get(column);if(current)return current;const identity=`column-occurrence-${this.nextColumnOccurrenceId}`;return this.nextColumnOccurrenceId+=1,this.columnOccurrenceIds.set(column,identity),identity}),this.requestUpdate("columns",previous)}get data(){return this._data}set data(value){const previous=this._data;this._data=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("data",previous)}get expandedRowKeys(){return this._expandedRowKeys}set expandedRowKeys(value){const previous=this._expandedRowKeys;this._expandedRowKeys=snapshotKeys(value),this.requestUpdate("expandedRowKeys",previous),this.requestUpdate("expandedKeys",previous)}get expandedKeys(){return this.expandedRowKeys}set expandedKeys(value){this.expandedRowKeys=value}get filteredCount(){return this.processedClientRows.length}get filters(){return this._filters}set filters(value){const previous=this._filters,next=[];if(Array.isArray(value))for(const filter of value)try{if(!filter||typeof filter.id!="string")continue;const filterValue=filter.value instanceof Set||Array.isArray(filter.value)?frozenArray(filter.value):filter.value;next.push(Object.freeze({id:filter.id,value:filterValue}))}catch{}this._filters=Object.freeze(next),this.requestUpdate("filters",previous)}get groupBy(){return this._groupBy}set groupBy(value){const previous=this._groupBy;this._groupBy=typeof value=="string"?value:Array.isArray(value)?frozenArray(value.filter(item=>typeof item=="string")):null,this.requestUpdate("groupBy",previous)}get pageCount(){const size=this.safePageSize;if(size===0)return 0;if(!this.usesServerData&&normalizedGroupBy(this.groupBy).length>0){const groups=this.topLevelGroupBuckets(this.processedClientRows).length;return groups<=0?0:Math.ceil(groups/size)}const count=this.safeTotal>=0?this.safeTotal:this.filteredCount;return count<=0?0:Math.ceil(count/size)}get pageSizeOptions(){return this._pageSizeOptions}set pageSizeOptions(value){const previous=this._pageSizeOptions;this._pageSizeOptions=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("pageSizeOptions",previous)}get selectedRowKeys(){return this._selectedRowKeys}set selectedRowKeys(value){const previous=this._selectedRowKeys;this._selectedRowKeys=snapshotKeys(value),this.requestUpdate("selectedRowKeys",previous),this.requestUpdate("selectedKeys",previous)}get selectedKeys(){return this.selectedRowKeys}set selectedKeys(value){this.selectedRowKeys=value}get selectedRows(){return frozenArray(this.allSourceRows.filter((row,index)=>arrayHasKey(this.selectedKeys,this.keyForRow(row,index))))}set selectedRows(next){const source=this.allSourceRows,sourceSet=new Set(source),sourceIndexes=this.sourceIndexMap(source),candidates=Array.isArray(next)?next:[],seen=new Set,rows=candidates.filter(row=>!sourceSet.has(row)||seen.has(row)?!1:(seen.add(row),!0)),limited=this.selectionMode==="single"?rows.slice(0,1):rows;this.selectedKeys=limited.map(row=>this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??0))}get sort(){return this._sort}set sort(value){const previous=this._sort,next=[];if(Array.isArray(value))for(const item of value)try{if(!item||typeof item.id!="string")continue;next.push(Object.freeze({id:item.id,desc:!!item.desc}))}catch{}this._sort=Object.freeze(next),this.requestUpdate("sort",previous)}connectedCallback(){super.connectedCallback(),this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.dataSource&&this.scheduleServerRequest(!1)}disconnectedCallback(){this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1,this.cancelRequestTimer(),this.resizeSession?.moved&&this.restoreResizeSession(this.resizeSession,!1),this.resizeSession=void 0,this.activeFilterColumn=null,this.activeColumnMenu=null,this.columnsMenuOpen=!1,this.dragGhost="",this.columnDragSession=void 0,this.sink?.release(),this.sink=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&changed.has("loading")&&this.loading&&this.announce(this.localize("loading"));const sourceReplaced=changed.has("dataSource")&&changed.get("dataSource")!==void 0,serverDisabled=changed.has("server")&&!this.usesServerData;if((sourceReplaced||serverDisabled)&&(this.requestController||this.requestTimer!==void 0)&&(this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.cancelRequestTimer(),this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1),this.resizeSession&&(changed.has("resizable")||changed.has("columns"))&&!this.columnCanResize(this.resizeSession.columnId)){const session=this.resizeSession;this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0)}if(this.columnDragSession&&(changed.has("reorderable")||changed.has("columns"))&&!this.columnCanMove(this.columnDragSession.sourceId)&&(this.columnDragSession=void 0,this.dragGhost=""),changed.has("columns")&&this.handleColumnsChange(),!this.usesServerData&&(changed.has("data")||changed.has("rowKey")||changed.has("childRows")||changed.has("server")||changed.has("dataSource"))){const validKeys=this.allSourceRows.map((row,index)=>this.keyForRow(row,index)),validKeySet=new Set(validKeys),selectedKeys=this.selectedKeys.filter(key=>validKeySet.has(key));(selectedKeys.length!==this.selectedKeys.length||selectedKeys.some((key,index)=>!keysEqual(key,this.selectedKeys[index])))&&(this.selectedKeys=selectedKeys),this.lastSelectedIndex=-1}if(this.paginate&&(changed.has("data")||changed.has("filters")||changed.has("searchTerm")||changed.has("groupBy")||changed.has("pageSize")||changed.has("total")||changed.has("server")||changed.has("dataSource"))){const lastPage=Math.max(0,this.pageCount-1);this.page=finiteInteger(this.page,0,0,lastPage)}(changed.has("data")||changed.has("columns")||changed.has("filters")||changed.has("searchTerm")||changed.has("sort")||changed.has("expandedKeys")||changed.has("groupBy")||changed.has("page")||changed.has("pageSize")||changed.has("paginate")||changed.has("childRows"))&&(this.focusedRow=finiteInteger(this.focusedRow,-1,-1,Math.max(-1,this.displayItems.length-1)),this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1)))}updated(changed){if(super.updated(changed),changed.has("dataSource")&&this.dataSource&&this.scheduleServerRequest(!1),(changed.has("sort")||changed.has("filters")||changed.has("searchTerm")||changed.has("page")||changed.has("pageSize")||changed.has("server"))&&(this.server||this.dataSource)){const delayed=changed.has("filters")||changed.has("searchTerm");this.scheduleServerRequest(delayed)}this.isMounting=!1}announce(text){this.sink?.announce(text),this.liveText=text}get usesServerData(){return this.server||this.dataSource!==null}get safePage(){return finiteInteger(this.page,0,0,Math.max(0,this.pageCount-1))}get safePageSize(){return finiteCount(this.pageSize)}get safeTotal(){return this.total===-1?-1:finiteCount(this.total)}sourceProjection(){const result=[],visited=new Set,seenRowKeys=new Set,stack=[];for(let index=this.data.length-1;index>=0;index-=1)stack.push({row:this.data[index],depth:0});let truncated=!1;for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(!trackIdentity||trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const rowKey=this.rowIdentity(current.row);if(rowKey===void 0||seenRowKeys.has(rowKey))continue;seenRowKeys.add(rowKey),result.push(current.row);const children=this.childrenFor(current.row);if(children.length!==0){if(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT){truncated=!0;continue}for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}}return stack.length>0&&(truncated=!0),{rows:Object.freeze(result),truncated}}get allSourceRows(){return this.sourceProjection().rows}get canonicalRootRows(){const canonical=new Set(this.allSourceRows);return this.data.filter(row=>canonical.has(row))}sourceIndexMap(rows=this.allSourceRows){const indexes=new Map;return rows.forEach((row,index)=>{indexes.has(row)||indexes.set(row,index)}),indexes}sourceIndexFor(row,indexes){const direct=indexes.get(row);if(direct!==void 0)return direct;const identity=this.rowIdentity(row);if(identity!==void 0){for(const[candidate,index]of indexes)if(Object.is(this.rowIdentity(candidate),identity))return index}}canonicalMembers(rows){const byIdentity=new Map;for(const row of this.allSourceRows){const identity=this.rowIdentity(row);identity!==void 0&&!byIdentity.has(identity)&&byIdentity.set(identity,row)}const output=[],seen=new Set;for(const candidate of rows){const identity=this.rowIdentity(candidate);if(identity===void 0||seen.has(identity))continue;const canonical=byIdentity.get(identity);canonical&&(seen.add(identity),output.push(canonical))}return output}get orderedColumns(){const entries=this.columns.map((column,naturalIndex)=>({column,id:columnId(column,naturalIndex),naturalIndex}));if(this.columnOrder.length===0)return entries;const rank=new Map(this.columnOrder.map((id,index)=>[id,index]));return entries.sort((left,right)=>{const leftRank=rank.get(left.id),rightRank=rank.get(right.id);return leftRank===void 0&&rightRank===void 0?left.naturalIndex-right.naturalIndex:leftRank===void 0?1:rightRank===void 0?-1:leftRank-rightRank})}get visibleColumns(){const entries=this.orderedColumns.filter(({column,id})=>this.columnVisibility.get(id)??column.hidden!==!0),rank=(side,id)=>this.orderedColumns.filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).findIndex(entry=>entry.id===id);return entries.sort((left,right)=>{const leftPin=normalizePinSide(this.getColumnPin(left.id)),rightPin=normalizePinSide(this.getColumnPin(right.id));return leftPin===rightPin?0:leftPin==="left"?-1:rightPin==="left"||leftPin==="right"?1:rightPin==="right"?-1:rank("left",left.id)-rank("right",right.id)})}get processedClientRows(){const rows=this.canonicalRootRows;if(this.usesServerData)return[...rows];if(this.childRows){const included=rows.filter(row=>this.rowMatches(row)||this.filterFromLeafRows&&this.hasMatchingDescendant(row));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}const filtered=filterRows(rows,this.columns,this.filters,this.effectiveLocale),searched=searchRows(filtered,this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);return sortRows(searched,this.columns,this.sort,this.effectiveLocale)}childrenFor(row){try{const children=typeof this.childRows=="function"?this.childRows(row):this.childRows?pathValue(row,this.childRows):void 0;return Array.isArray(children)?children.slice(0,DATA_GRID_TREE_NODE_LIMIT):[]}catch{return[]}}rowIdentity(row){if(!((typeof row!="object"||row===null)&&typeof row!="function"))try{if(this.rowKey){const candidate=pathValue(row,this.rowKey);return isKey(candidate)?candidate:void 0}const object=row,current=this.rowOccurrenceIds.get(object);if(current)return current;const identity=`row-occurrence-${this.nextRowOccurrenceId}`;return this.nextRowOccurrenceId+=1,this.rowOccurrenceIds.set(object,identity),identity}catch{return}}keyForRow(row,_index){return this.rowIdentity(row)}renderedColumnElements(columnId2,role){const prefix=role?`[role="${role}"]`:"",ownerCss=this.ownerDocument.defaultView?.CSS,escape=ownerCss?.escape;if(typeof escape=="function")try{const matches=[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id="${escape.call(ownerCss,columnId2)}"]`)];if(matches.length>0)return matches}catch{}return[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id]`)].filter(element=>element.getAttribute("data-column-id")===columnId2)}computedToken(name,privateDefault){if(!this.isConnected)return"";const owner=this.ownerDocument.defaultView;if(!owner||typeof owner.getComputedStyle!="function")return"";try{const style=owner.getComputedStyle(this);return style.getPropertyValue(name).trim()||(privateDefault?style.getPropertyValue(privateDefault).trim():"")}catch{return""}}autoSizeColumn(columnId2){const cells=this.renderedColumnElements(columnId2);if(cells.length===0)return;let width=0;for(const cell of cells)width=Math.max(width,cell.scrollWidth);const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column);this.setColumnWidth(columnId2,finiteRange(width,minimum,minimum,maximum),!1)}autoSizeColumns(){for(const{id}of this.visibleColumns)this.autoSizeColumn(id)}collapseAllRows(){this.expandedKeys=[]}collapseRow(key){this.expandedKeys=this.expandedKeys.filter(candidate=>!keysEqual(candidate,key))}copySelectedRows(options={}){const rowsToCopy=this.selectedRows.length>0?this.selectedRows:this.getProcessedRows(),format=options.format??"tsv",text=this.delimitedRows(rowsToCopy,{...options,delimiter:options.delimiter??(format==="csv"?",":" ")});return this.copyAndReport(text),rowsToCopy.length}expandAllRows(){const keys=[];this.allSourceRows.forEach((row,index)=>{(this.childrenFor(row).length>0||this.rowDetail)&&keys.push(this.keyForRow(row,index))});for(const group of this.groupItems(this.processedClientRows))keys.push(group.key);this.expandedKeys=keys}expandRow(key){arrayHasKey(this.expandedKeys,key)||(this.expandedKeys=[...this.expandedKeys,key])}exportDataAsCsv(options={}){const text=this.getDataAsCsv(options),ownerDocument=this.ownerDocument,owner=ownerDocument.defaultView;if(!owner||typeof owner.URL.createObjectURL!="function")return;const url=owner.URL.createObjectURL(new owner.Blob([text],{type:"text/csv;charset=utf-8"}));try{const anchor=ownerDocument.createElement("a");anchor.href=url,anchor.download=options.fileName||"data.csv",anchor.hidden=!0,ownerDocument.body?.append(anchor),anchor.click(),anchor.remove()}finally{owner.URL.revokeObjectURL(url)}}focus(options={}){const selector=this.focusedRow<0?`[role="columnheader"][data-column-position="${this.focusedColumn}"]`:`[role="gridcell"][data-row-position="${this.focusedRow}"][data-column-position="${this.focusedColumn}"]`;this.renderRoot.querySelector(selector)?.focus(options)}getColumnFacets(columnId2){const uniqueValues=new Map;if(this.usesServerData)return Object.freeze({uniqueValues});const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return Object.freeze({uniqueValues});const otherFilters=this.filters.filter(filter=>filter.id!==columnId2),rows=searchRows(filterRows(this.canonicalRootRows,this.columns,otherFilters,this.effectiveLocale),this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);let minimum=Number.POSITIVE_INFINITY,maximum=Number.NEGATIVE_INFINITY;for(const row of rows){const value=columnValue(entry.column,row);uniqueValues.set(value,(uniqueValues.get(value)??0)+1);const number=typeof value=="number"?value:Number(value);Number.isFinite(number)&&(minimum=Math.min(minimum,number),maximum=Math.max(maximum,number))}return Number.isFinite(minimum)&&Number.isFinite(maximum)?Object.freeze({uniqueValues,minMax:Object.freeze([minimum,maximum])}):Object.freeze({uniqueValues})}getColumnPin(columnId2){return this.columnPinning.has(columnId2)?this.columnPinning.get(columnId2)??!1:this.orderedColumns.find(({id})=>id===columnId2)?.column.pinned??!1}getDataAsCsv(options={}){return this.delimitedRows(this.getProcessedRows(),options)}getProcessedRows(){return frozenArray(this.processedClientRows)}getVisibleRows(){const rows=this.processedClientRows;if(!this.paginate||this.usesServerData)return frozenArray(rows);const size=this.safePageSize;if(size===0)return[];const start=this.safePage*size;return normalizedGroupBy(this.groupBy).length>0?frozenArray(this.topLevelGroupBuckets(rows).slice(start,start+size).flatMap(bucket=>bucket.rows)):frozenArray(rows.slice(start,start+size))}getState(){return Object.freeze({order:frozenArray(this.columnOrder),widths:Object.freeze(Object.fromEntries(this.columnWidths)),visibility:Object.freeze(Object.fromEntries(this.columnVisibility)),pinning:Object.freeze(Object.fromEntries(this.columnPinning)),sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,selectedRowKeys:frozenArray(this.selectedRowKeys),expandedRowKeys:frozenArray(this.expandedRowKeys),selectedKeys:frozenArray(this.selectedRowKeys),expandedKeys:frozenArray(this.expandedRowKeys),page:this.safePage,pageSize:this.safePageSize})}handleColumnsChange(){const valid=new Set(this.columns.map((column,index)=>columnId(column,index))),natural=[...valid],order=this.columnOrder.filter(id=>valid.has(id));for(const id of natural)order.includes(id)||order.push(id);this.columnOrder.length>0&&order.join("\0")!==this.columnOrder.join("\0")&&(this.columnOrder=order);const widths=[...this.columnWidths].filter(([id])=>valid.has(id)),visibility=[...this.columnVisibility].filter(([id])=>valid.has(id)),pinning=[...this.columnPinning].filter(([id])=>valid.has(id));widths.length!==this.columnWidths.size&&(this.columnWidths=new Map(widths)),visibility.length!==this.columnVisibility.size&&(this.columnVisibility=new Map(visibility)),pinning.length!==this.columnPinning.size&&(this.columnPinning=new Map(pinning))}handlePageChange(){this.applyPageChange(this.safePage)}applyPageChange(value){let requested;typeof value=="number"?requested=value:requested=Number(valueControl(value?.currentTarget)?.value??this.safePage);const last=Math.max(0,this.pageCount-1),next=finiteInteger(requested,this.safePage,0,last);this.page=next,this.emit("lr-page-change",Object.freeze({page:next,pageSize:this.safePageSize}))}handleSearchTermChange(){this.applySearchTermChange(this.searchTerm)}applySearchTermChange(value){const next=typeof value=="string"?value:valueControl(value?.currentTarget)?.value??this.searchTerm;this.searchTerm=next,this.page!==0&&(this.page=0)}pinColumn(columnId2,side){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnPinning);next.set(columnId2,side),this.columnPinning=next}async reload(){const owner=this.ownerDocument.defaultView;!this.isConnected||!owner||!this.usesServerData||(this.cancelRequestTimer(),await this.loadServerData(owner))}resetColumns(){this.columnOrder=[],this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map}resetState(){this.resetColumns(),this.sort=[],this.filters=[],this.searchTerm="",this.expandedKeys=[]}scrollToIndex(index,options={}){const rows=this.getVisibleRows();if(rows.length===0)return;const requestedIndex=finiteInteger(index,0,0,rows.length-1),requestedRow=rows[requestedIndex],sourceIndexes=this.sourceIndexMap(),sourceIndex=this.sourceIndexFor(requestedRow,sourceIndexes),requestedKey=this.keyForRow(requestedRow,sourceIndex??requestedIndex),target=this.displayItems.findIndex(item=>item.kind==="row"&&(item.row===requestedRow||keysEqual(item.key,requestedKey)));if(target<0)return;const rendered=this.renderRoot?.querySelector(`[part~="row"][data-visible-index="${target}"]`);if(rendered){rendered.scrollIntoView({block:options.align??"nearest"});return}const body=this.bodyElement;if(!body)return;const rowHeight=this.resolvedRowHeight;let top=target*rowHeight;options.align==="center"?top-=(body.clientHeight-rowHeight)/2:options.align==="end"&&(top-=body.clientHeight-rowHeight),body.scrollTo({top:Math.max(0,top)})}setState(state2){const known=new Set(this.columns.map((column,index)=>columnId(column,index)));state2.order&&(this.columnOrder=state2.order.filter(id=>known.has(id))),state2.widths&&(this.columnWidths=this.validColumnMap(state2.widths,known,width=>finiteRange(width,0,0))),state2.visibility&&(this.columnVisibility=this.validColumnMap(state2.visibility,known,Boolean)),state2.pinning&&(this.columnPinning=this.validColumnMap(state2.pinning,known,side=>side==="left"||side==="right"||side==="start"||side==="end"?side:!1)),state2.sort&&(this.sort=state2.sort.filter(item=>known.has(item.id)).map(item=>({id:item.id,desc:!!item.desc}))),state2.filters&&(this.filters=state2.filters.filter(item=>known.has(item.id)).map(item=>({...item}))),state2.search!==void 0&&(this.searchTerm=state2.search);const selectedRowKeys=state2.selectedRowKeys??state2.selectedKeys,expandedRowKeys=state2.expandedRowKeys??state2.expandedKeys;selectedRowKeys&&(this.selectedRowKeys=selectedRowKeys),expandedRowKeys&&(this.expandedRowKeys=expandedRowKeys),state2.page!==void 0&&(this.page=finiteCount(state2.page)),state2.pageSize!==void 0&&(this.pageSize=finiteCount(state2.pageSize))}sizeColumnsToFit(){const body=this.bodyElement;if(!body||this.visibleColumns.length===0)return;const selectionWidth=this.selectionEnabled?resolveCssLength(this.computedToken("--lr-icon-button-size"),{host:this})??0:0,available=Math.max(0,body.clientWidth-selectionWidth),flexible=this.visibleColumns.filter(({column})=>column.flex!==0);if(flexible.length===0)return;const totalFlex=flexible.reduce((sum,{column})=>sum+finiteRange(column.flex??1,1,0),0)||flexible.length,next=new Map(this.columnWidths);for(const{column,id}of flexible){const share=available*(finiteRange(column.flex??1,1,0)/totalFlex),{minimum,maximum}=this.columnBounds(column);next.set(id,finiteRange(share,minimum,minimum,maximum))}this.columnWidths=next}toggleColumn(columnId2,visible){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnVisibility);next.set(columnId2,visible),this.columnVisibility=next,this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1))}validColumnMap(record,known,convert){const result=new Map;for(const[id,value]of Object.entries(record))known.has(id)&&result.set(id,convert(value));return result}delimitedRows(rows,options){const active=this.visibleColumns.map(({column,id})=>({...column,id,value:row=>{const raw=columnValue(column,row),formatted=column.formatter?.(raw,row);return typeof formatted=="string"?formatted:raw},hidden:!1}));return rowsAsDelimited(rows,active,options)}async copyAndReport(text){const owner=this.isConnected?this.ownerDocument.defaultView:null,outcome=await this.writeClipboard(text,owner);if(!(!owner||!this.isConnected||this.ownerDocument.defaultView!==owner)){if(outcome.ok){this.isMounting||this.announce(this.localize("copied")),this.emit("lr-copy",outcome);return}this.isMounting||this.announce(this.localize("copyFailed")),this.emit("lr-error"),this.emit("lr-copy-error",outcome)}}async writeClipboard(text,owner){const ownerDocument=this.ownerDocument,outcome=await writeClipboardText(owner,text);if(outcome.ok||!owner||ownerDocument.defaultView!==owner||!ownerDocument.body)return outcome;const textarea=ownerDocument.createElement("textarea");textarea.value=text,textarea.style.position="fixed",textarea.style.opacity="0",ownerDocument.body.append(textarea);try{if(textarea.select(),ownerDocument.execCommand?.("copy"))return Object.freeze({ok:!0,text})}finally{textarea.remove()}return outcome}setColumnWidth(columnIdValue,width,emit,finished=!0){const entry=this.orderedColumns.find(({id})=>id===columnIdValue);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column),safeWidth=finiteRange(width,minimum,minimum,maximum),next=new Map(this.columnWidths);next.set(columnIdValue,safeWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:columnIdValue,width:safeWidth,finished}))}cancelRequestTimer(){const timer=this.requestTimer;this.requestTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}scheduleServerRequest(delayed){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner||!this.usesServerData)return;this.cancelRequestTimer();const delay=delayed?finiteDuration(this.filterDebounce,250):0;let handle=0;handle=owner.setTimeout(()=>{this.requestTimer?.owner!==owner||this.requestTimer.handle!==handle||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.requestTimer=void 0,this.loadServerData(owner))},delay),this.requestTimer={owner,handle}}async loadServerData(owner){if(!this.isConnected||this.ownerDocument.defaultView!==owner||!this.usesServerData)return;this.requestController?.abort();const AbortControllerCtor=owner.AbortController;this.requestController=typeof AbortControllerCtor=="function"?new AbortControllerCtor:void 0;const generation=++this.requestGeneration,request=Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,page:this.safePage,pageSize:this.safePageSize,signal:this.requestController?.signal}),requestDetail=()=>Object.freeze({...request,sort:frozenArray(request.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(request.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)})))});if(this.emit("request",requestDetail()),!!this.dataSource){this.ownsLoadingState=!0,this.loading=!0;try{const response=await this.dataSource(request);if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.data=Array.isArray(response.rows)?response.rows:[],this.total=finiteCount(response.total),this.loading=!1,this.ownsLoadingState=!1}catch(error){if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.loading=!1,this.ownsLoadingState=!1,this.emit("lr-data-error",Object.freeze({error,request:requestDetail()}))}}}get selectionMode(){return this.selectable===""||this.selectable==="multiple"?"multiple":this.selectable}get selectionEnabled(){return this.selectionMode!=="none"}rowIsSelectable(row){return this.selectionEnabled&&(this.selectableRows?.(row)??!0)}rowMatches(row){return filterRows([row],this.columns,this.filters,this.effectiveLocale).length>0&&searchRows([row],this.columns,this.searchTerm,this.effectiveLocale,this.searchFn).length>0}processedChildrenFor(row){const children=this.canonicalMembers(this.childrenFor(row));if(children.length===0||this.usesServerData)return children;const included=children.filter(child=>this.rowMatches(child)?!0:this.filterFromLeafRows&&this.hasMatchingDescendant(child));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}hasMatchingDescendant(row){const stack=this.canonicalMembers(this.childrenFor(row)).map(child=>({row:child,depth:1})),visited=new Set;let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(!(trackIdentity&&visited.has(current.row))){if(trackIdentity&&visited.add(current.row),inspected+=1,this.rowMatches(current.row))return!0;if(!(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))for(const child of this.canonicalMembers(this.childrenFor(current.row)))stack.push({row:child,depth:current.depth+1})}}return!1}get pageRows(){return this.getVisibleRows()}get currentPageSelectableRows(){const result=[],sourceIndex=new Map(this.allSourceRows.map((row,index)=>[row,index])),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row),inspected+=1;const index=this.sourceIndexFor(current.row,sourceIndex);if(index===void 0)continue;const key=this.keyForRow(current.row,index);if(this.rowIsSelectable(current.row)&&result.push({row:current.row,key}),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let childIndex=children.length-1;childIndex>=0;childIndex-=1){const child=children[childIndex];stack.push({row:child,depth:current.depth+1})}}return result}groupKey(parent,id,value){return`group:${parent}:${id}:${typeof value}:${safeText(value)}`}topLevelGroupBuckets(rows){const field=normalizedGroupBy(this.groupBy)[0];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return[];const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}return[...buckets].map(([value,bucketRows])=>({value,rows:bucketRows}))}groupItems(rows){const fields=normalizedGroupBy(this.groupBy);if(fields.length===0||this.usesServerData)return[];const result=[],visit=(groupRows,depth,parent)=>{const field=fields[depth];if(!field)return;const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return;const buckets=new Map;for(const row of groupRows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),depth+1<fields.length&&visit(bucket,depth+1,key)}};return visit(rows,0,"root"),result}get displayItems(){const groups=normalizedGroupBy(this.groupBy);if(groups.length>0&&!this.usesServerData)return this.groupedDisplayItems(this.pageRows,groups,0,"root",this.sourceIndexMap());const result=[],sourceRows=this.allSourceRows,indexes=this.sourceIndexMap(sourceRows),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const sourceIndex=this.sourceIndexFor(current.row,indexes);if(sourceIndex===void 0)continue;const safeIndex=sourceIndex,key=this.keyForRow(current.row,safeIndex);if(result.push({kind:"row",row:current.row,key,depth:current.depth,sourceIndex:safeIndex}),!arrayHasKey(this.expandedKeys,key)||current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.processedChildrenFor(current.row);for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}return result}groupedDisplayItems(rows,fields,depth,parent,sourceIndexes){const field=fields[depth];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return rows.map((row,index)=>({kind:"row",row,key:this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??index),depth,sourceIndex:this.sourceIndexFor(row,sourceIndexes)??index}));const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}const result=[];for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);if(result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),!!arrayHasKey(this.expandedKeys,key))if(depth+1<fields.length)result.push(...this.groupedDisplayItems(bucket,fields,depth+1,key,sourceIndexes));else for(const row of bucket){const sourceIndex=this.sourceIndexFor(row,sourceIndexes);result.push({kind:"row",row,key:this.keyForRow(row,sourceIndex??result.length),depth:depth+1,sourceIndex:sourceIndex??result.length})}}return result}get resolvedRowHeight(){const raw=this.computedToken("--row-height","--_lr-data-grid-row-height");return finiteRange(resolveCssLength(raw,{host:this})??56,56,1)}get virtualWindow(){const items=this.displayItems,expandedDetails=!!(this.rowDetail&&items.some(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)));if(items.length<VIRTUALIZATION_THRESHOLD||expandedDetails||this.computedToken("--max-height","--_lr-data-grid-max-height")==="none")return{items,start:0,end:items.length};const height=this.resolvedRowHeight,visibleCount=Math.max(1,Math.ceil((this.viewportHeight||height*10)/height)),start=Math.min(Math.max(0,items.length-visibleCount),Math.max(0,Math.floor(this.bodyScrollTop/height)-VIRTUAL_OVERSCAN)),end=Math.min(items.length,start+visibleCount+VIRTUAL_OVERSCAN*2);return{items:items.slice(start,end),start,end}}get gridTemplate(){const columns=this.visibleColumns.map(({column,id})=>{const bounds=this.columnBounds(column),width=this.columnWidths.get(id)??column.width;if(width!==void 0&&Number.isFinite(width)&&width>0)return`${finiteRange(width,bounds.minimum,bounds.minimum,bounds.maximum)}px`;const minimum=bounds.minimum>0?`${bounds.minimum}px`:Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?"0px":"var(--lr-size-7rem)",maximum=Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?`${bounds.maximum}px`:`${finiteRange(column.flex??1,1,0)}fr`;return`minmax(${minimum}, ${maximum})`});return this.selectionEnabled&&columns.unshift("var(--lr-icon-button-size)"),columns.length>0?columns.join(" "):"minmax(var(--lr-size-7rem), 1fr)"}columnStyle(column,id){const side=normalizePinSide(this.getColumnPin(id)),pinOffset=side?this.pinOffset(id,side):0;return{...side?{"--pin-offset":`${pinOffset}px`}:{},...Number.isFinite(column.width)&&(column.width??0)>0&&!this.columnWidths.has(id)?{"--column-authored-width":`${column.width}px`}:{}}}estimatedColumnWidth(column,id){const{minimum,maximum}=this.columnBounds(column),explicit=this.columnWidths.get(id)??column.width;if(explicit!==void 0)return finiteRange(explicit,Math.max(112,minimum),minimum,maximum);const raw=this.computedToken("--lr-size-7rem");return finiteRange(resolveCssLength(raw,{host:this})??112,Math.max(112,minimum),minimum,maximum)}columnBounds(column){const minimum=finiteRange(column.minWidth??0,0,0),authoredMaximum=finiteRange(column.maxWidth??Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0);return Object.freeze({minimum,maximum:Math.max(minimum,authoredMaximum)})}pinOffset(id,side){const entries=this.visibleColumns,index=entries.findIndex(entry=>entry.id===id);return index<0?0:(side==="left"?entries.slice(0,index):entries.slice(index+1)).filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).reduce((sum,entry)=>sum+this.estimatedColumnWidth(entry.column,entry.id),0)}columnLabel(column,id){return column.label??humanizeIdentifier(column.field??id,this.effectiveLocale)}columnIsSortable(column){return column.sortable!==!1&&!!(column.field||column.value)}sortFor(id){const index=this.sort.findIndex(item=>item.id===id);return{state:index>=0?this.sort[index]:void 0,index}}activateSort(id,additive){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnIsSortable(entry.column))return;const existing=this.sortFor(id).state,descendingFirst=entry.column.sortDescFirst??this.sortDescFirst;let replacement;existing?existing.desc===descendingFirst?replacement={id,desc:!descendingFirst}:this.withoutSortRemoval&&(replacement={id,desc:descendingFirst}):replacement={id,desc:descendingFirst};let next=additive?this.sort.filter(item=>item.id!==id):[];replacement&&next.push(replacement);const limit=finiteCount(this.maxMultiSort);limit>0&&next.length>limit&&(next=next.slice(next.length-limit)),this.sort=next,this.page=0,this.emit("lr-sort-change",Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item})))}))}onHeaderClick(event,id){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget||this.activateSort(id,event.shiftKey)}onFilterInput(event,id){const control=valueControl(event.currentTarget);if(!control)return;const value=control.value,next=this.filters.filter(filter=>filter.id!==id);value&&next.push({id,value}),this.filters=next,this.page=0,this.emit("lr-filter-change",Object.freeze({filters:frozenArray(next.map(filter=>Object.freeze({...filter})))}))}onBodyScroll(event){const target=event.currentTarget;!isElementValue(target)||typeof target.scrollTop!="number"||typeof target.clientHeight!="number"||(this.bodyScrollTop=target.scrollTop,this.viewportHeight=target.clientHeight)}onCellClick(event,item,column,columnIdValue,index){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget&&isElementValue(event.currentTarget)&&event.currentTarget.contains(interactive)||this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index}))}emitCellContextMenu(originalEvent,item,column,columnIdValue,index){const detail=Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index,originalEvent});this.emit("lr-cell-contextmenu",detail,{cancelable:!0}).defaultPrevented&&originalEvent.preventDefault()}descendantRows(row){const result=[],visited=new Set,stack=this.canonicalMembers(this.childrenFor(row)).reverse().map(child=>({row:child,depth:1}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row)||(trackIdentity&&visited.add(current.row),result.push(current.row),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let index=children.length-1;index>=0;index-=1){const child=children[index];stack.push({row:child,depth:current.depth+1})}}return result}setRowSelected(item,selected,event){if(!this.rowIsSelectable(item.row))return;const selectableItems=this.displayItems.filter(candidate=>candidate.kind==="row"&&this.rowIsSelectable(candidate.row)),position=selectableItems.findIndex(candidate=>keysEqual(candidate.key,item.key));let affected=[item];if(event?.shiftKey&&this.selectionMode==="multiple"&&this.lastSelectedIndex>=0){const from=Math.min(this.lastSelectedIndex,position),to=Math.max(this.lastSelectedIndex,position);affected=selectableItems.slice(from,to+1)}const descendants=this.selectionMode==="multiple"?affected.flatMap(candidate=>this.descendantRows(candidate.row)).filter(row=>this.rowIsSelectable(row)):[],sourceIndexes=this.sourceIndexMap(),keys=[...affected.map(candidate=>candidate.key),...descendants.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)})];let next=this.selectionMode==="single"?[]:[...this.selectedKeys];for(const key of keys)next=next.filter(candidate=>!keysEqual(candidate,key)),selected&&next.push(key);this.selectedKeys=next,this.lastSelectedIndex=position,this.emitSelection()}selectCurrentPage(selected){const pageKeys=this.currentPageSelectableRows.map(item=>item.key);let next=this.selectedKeys.filter(key=>!pageKeys.some(pageKey=>keysEqual(pageKey,key)));selected&&(next=[...next,...pageKeys]),this.selectedKeys=next,this.emitSelection()}emitSelection(){const selectedRowKeys=frozenArray(this.selectedRowKeys),selectedRows=frozenArray(this.selectedRows);this.emit("lr-row-select",Object.freeze({selectedRowKeys,selectedKeys:selectedRowKeys,selectedRows}))}rowSelectionState(item){const own=arrayHasKey(this.selectedKeys,item.key),descendants=this.descendantRows(item.row).filter(row=>this.rowIsSelectable(row));if(descendants.length===0)return{checked:own,indeterminate:!1};const sourceIndexes=this.sourceIndexMap(),selected=descendants.filter((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return arrayHasKey(this.selectedKeys,this.keyForRow(row,sourceIndex??index))}).length,checked=own&&selected===descendants.length;return{checked,indeterminate:!checked&&(own||selected>0)}}toggleRowExpanded(item,emitUserEvent){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key),emitUserEvent&&this.emit(expanded?"lr-row-collapse":"lr-row-expand",Object.freeze({rowKey:item.key,key:item.key,row:item.row}))}toggleGroupExpanded(item){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key);const detail=Object.freeze({key:item.key,columnId:item.columnId,value:item.value,rows:frozenArray(item.rows)});this.emit(expanded?"lr-group-collapse":"lr-group-expand",detail)}moveColumn(id,delta,emitUserEvent){const order=this.orderedColumns.map(entry=>entry.id),from=order.indexOf(id);if(from<0)return;const to=finiteInteger(from+delta,from,0,order.length-1);from!==to&&(order.splice(from,1),order.splice(to,0,id),this.columnOrder=order,emitUserEvent&&this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:id,finished:!0})))}columnCanMove(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.reorderable||entry.column.movable))}columnCanResize(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.resizable||entry.column.resizable))}onDragStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanMove(id)||!event.dataTransfer){event.preventDefault();return}const token=`${++this.columnDragSequence}:${id}`;this.columnDragSession=Object.freeze({sourceId:id,token}),event.dataTransfer.setData(DATA_GRID_DRAG_TYPE,token),event.dataTransfer.setData("text/plain",id),event.dataTransfer.effectAllowed="move",this.dragGhost=this.columnLabel(entry.column,id)}onDrop(event,targetId){event.preventDefault();const session=this.columnDragSession,token=event.dataTransfer?.getData(DATA_GRID_DRAG_TYPE),sourceId=session?.sourceId;if(this.columnDragSession=void 0,this.dragGhost="",!session||token!==session.token||!sourceId||sourceId===targetId||!this.columnCanMove(sourceId)||!this.columnCanMove(targetId))return;const order=this.orderedColumns.map(entry=>entry.id),source=order.indexOf(sourceId),target=order.indexOf(targetId);source<0||target<0||(order.splice(source,1),order.splice(target,0,sourceId),this.columnOrder=order,this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:sourceId,finished:!0})))}onResizeStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const header=this.renderedColumnElements(id,"columnheader")[0];this.resizeSession={columnId:id,startClientX:event.clientX,startWidth:header?.getBoundingClientRect().width??this.estimatedColumnWidth(entry.column,id),initialStateWidth:this.columnWidths.get(id),pointerId:event.pointerId,moved:!1,direction:this.effectiveDirection};try{event.currentTarget.setPointerCapture?.(event.pointerId)}catch{}event.preventDefault()}onResizeMove(event){const session=this.resizeSession;if(!session||event.pointerId!==session.pointerId)return;if(!this.columnCanResize(session.columnId)){this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0);return}const direction=session.direction==="rtl"?-1:1;this.setColumnWidth(session.columnId,session.startWidth+(event.clientX-session.startClientX)*direction,!0,!1),session.moved=!0}takeResizeSession(event){const session=this.resizeSession;if(!(!session||event.pointerId!==session.pointerId)){this.resizeSession=void 0;try{event.currentTarget.releasePointerCapture?.(event.pointerId)}catch{}return session}}restoreResizeSession(session,emit){const next=new Map(this.columnWidths);session.initialStateWidth===void 0?next.delete(session.columnId):next.set(session.columnId,session.initialStateWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width:session.startWidth,finished:!1}))}onResizeEnd(event){const session=this.takeResizeSession(event);if(!session)return;if(!this.columnCanResize(session.columnId)){session.moved&&this.restoreResizeSession(session,!0);return}const width=this.columnWidths.get(session.columnId)??session.startWidth;this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width,finished:!0}))}onResizeCancel(event){const session=this.takeResizeSession(event);!session||!session.moved||this.restoreResizeSession(session,!0)}onResizeKey(event,id){if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const logical=(event.key==="ArrowRight"?1:-1)*(this.effectiveDirection==="rtl"?-1:1),current=this.columnWidths.get(id)??this.estimatedColumnWidth(entry.column,id);this.setColumnWidth(id,current+logical*10,!0,!0),event.preventDefault()}onPageSizeChange(event){const control=valueControl(event.currentTarget);control&&(this.pageSize=finiteCount(Number(control.value)),this.page=0,this.emit("lr-page-change",Object.freeze({page:0,pageSize:this.safePageSize})))}focusCell(row,column){const rowLimit=Math.max(-1,this.displayItems.length-1),columnLimit=Math.max(0,this.visibleColumns.length-1);this.focusedRow=finiteInteger(row,this.focusedRow,-1,rowLimit),this.focusedColumn=finiteInteger(column,this.focusedColumn,0,columnLimit);let pendingScrollTop;if(this.focusedRow>=0){const selector=`[role="gridcell"][data-row-position="${this.focusedRow}"]`;if(!this.renderRoot.querySelector(selector)){const top=this.focusedRow*this.resolvedRowHeight;pendingScrollTop=top,this.bodyScrollTop=top,this.bodyElement&&(this.bodyElement.scrollTop=top)}}this.updateComplete.then(()=>{pendingScrollTop!==void 0&&this.bodyElement&&(this.bodyElement.scrollTop=pendingScrollTop),this.focus()})}onGridKeyDown(event,rowPosition,columnPosition,item,column,columnIdValue){const target=event.target;if(isElementValue(target)&&target!==event.currentTarget&&target.closest(INTERACTIVE_SELECTOR))return;const rtlMultiplier=this.effectiveDirection==="rtl"?-1:1;if(event.ctrlKey&&event.key.toLowerCase()==="a"&&this.selectionMode==="multiple"){this.selectCurrentPage(!0),event.preventDefault();return}if(event.ctrlKey&&event.key.toLowerCase()==="c"){this.copySelectedRows(),event.preventDefault();return}if(event.shiftKey&&event.key==="F10"&&item&&column&&columnIdValue){this.emitCellContextMenu(event,item,column,columnIdValue,rowPosition);return}const headerEntry=columnIdValue?this.orderedColumns.find(entry=>entry.id===columnIdValue):void 0;if(rowPosition<0&&columnIdValue&&headerEntry&&(this.reorderable||headerEntry.column.movable)&&event.shiftKey&&!event.altKey&&(event.key==="ArrowLeft"||event.key==="ArrowRight")){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.moveColumn(columnIdValue,delta,!0),event.preventDefault();return}if(!(rowPosition<0&&columnIdValue&&headerEntry&&(this.resizable||headerEntry.column.resizable)&&event.altKey&&(this.onResizeKey(event,columnIdValue),event.defaultPrevented))){if(event.key==="ArrowLeft"||event.key==="ArrowRight"){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.focusCell(rowPosition,columnPosition+delta),event.preventDefault()}else if(event.key==="ArrowUp")this.focusCell(rowPosition-1,columnPosition),event.preventDefault();else if(event.key==="ArrowDown")this.focusCell(rowPosition+1,columnPosition),event.preventDefault();else if(event.key==="Home")this.focusCell(event.ctrlKey?-1:rowPosition,0),event.preventDefault();else if(event.key==="End")this.focusCell(event.ctrlKey?this.displayItems.length-1:rowPosition,this.visibleColumns.length-1),event.preventDefault();else if(event.key==="PageUp"||event.key==="PageDown"){const delta=event.key==="PageDown"?this.safePageSize||10:-(this.safePageSize||10);this.focusCell(rowPosition+delta,columnPosition),event.preventDefault()}else if(event.key==="Enter")rowPosition<0&&columnIdValue?this.activateSort(columnIdValue,event.shiftKey):item&&column&&columnIdValue&&this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index:rowPosition})),event.preventDefault();else if(event.key===" "&&item){const selected=!arrayHasKey(this.selectedKeys,item.key);this.setRowSelected(item,selected,event),event.preventDefault()}}}setGroupSelected(group,selected){const eligible=group.rows.filter(row=>this.rowIsSelectable(row)),sourceIndexes=this.sourceIndexMap(),groupKeys=eligible.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)});let next=this.selectedKeys.filter(key=>!groupKeys.some(groupKey=>keysEqual(groupKey,key)));selected&&(next=[...next,...groupKeys]),this.selectedKeys=next,this.emitSelection()}userPinColumn(id,side){this.pinColumn(id,side),this.emit("lr-column-pin",Object.freeze({columnId:id,side}))}userToggleColumn(id,visible){this.toggleColumn(id,visible),this.emit("lr-column-visibility-change",Object.freeze({columnId:id,visible}))}renderToolbar(){return!this.withSearch&&!this.withColumnsMenu?nothing:html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{resolveCssLength}from"../../../internal/css-length.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{chevronIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{finiteCount,finiteDuration,finiteInteger,finiteRange}from"../../../internal/numbers.js";import{sizes}from"../../../internal/sizes.styles.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{aggregateValues,columnId,columnValue,filterRows,pathValue,rowsAsDelimited,searchRows,sortRows}from"./data-grid-processing.js";import{styles}from"./data-grid.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copied,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_dataGridColumnMenu,LYRA_DEFAULT_dataGridPinEnd,LYRA_DEFAULT_dataGridPinStart,LYRA_DEFAULT_dataGridRowsPerPage,LYRA_DEFAULT_dataGridTreeLimitReached,LYRA_DEFAULT_dataGridUnpin,LYRA_DEFAULT_expand,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_paginationFirstPage,LYRA_DEFAULT_paginationJumpToPage,LYRA_DEFAULT_paginationLabel,LYRA_DEFAULT_paginationLastPage,LYRA_DEFAULT_previous,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_tableFilterLabel}from"../../../internal/default-strings.generated.js";export*from"./data-grid-types.js";const selectableConverter={fromAttribute(value){return value===null?"none":value===""||value==="multiple"?"multiple":value==="single"||value==="none"?value:"none"},toAttribute(value){return value==="none"?null:value===""||value==="multiple"?"":value}};function snapshotColumns(value,occurrenceId){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const column of value)try{if(column===null||typeof column!="object"||Array.isArray(column))continue;const hasId=Object.prototype.hasOwnProperty.call(column,"id"),hasField=Object.prototype.hasOwnProperty.call(column,"field"),authoredId=hasId?column.id:void 0,authoredField=hasField?column.field:void 0;if(hasId&&authoredId!==void 0&&(typeof authoredId!="string"||authoredId.trim()==="")||!hasId&&hasField&&authoredField!==void 0&&(typeof authoredField!="string"||authoredField.trim()===""))continue;const identity=typeof authoredId=="string"?authoredId:typeof authoredField=="string"?authoredField:occurrenceId(column);if(seen.has(identity))continue;seen.add(identity);const snapshot={...column,...authoredId===void 0&&authoredField===void 0?{id:identity}:{}};output.push(Object.freeze(snapshot))}catch{}return Object.freeze(output)}const INTERACTIVE_SELECTOR='button, a[href], input, select, textarea, summary, [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="radio"]',VIRTUALIZATION_THRESHOLD=80,VIRTUAL_OVERSCAN=5,DATA_GRID_TREE_NODE_LIMIT=1e4,DATA_GRID_TREE_DEPTH_LIMIT=64,DATA_GRID_DRAG_TYPE="application/x-lyra-data-grid-column";function frozenArray(values){return Object.freeze([...values])}function serializableFilterValue(value){try{const serialized=JSON.stringify({value},(_key,nested)=>typeof nested=="bigint"?nested.toString():typeof nested=="number"&&!Number.isFinite(nested)?null:nested!==null&&typeof nested=="object"&&Object.prototype.toString.call(nested)==="[object Set]"?[...nested]:nested);if(!serialized)return null;const snapshot=JSON.parse(serialized).value??null,stack=[snapshot],visited=new Set;for(;stack.length>0;){const current=stack.pop();if(!(current===null||typeof current!="object"||visited.has(current))){visited.add(current);for(const nested of Object.values(current))stack.push(nested);Object.freeze(current)}}return snapshot}catch{return null}}function isKey(value){return typeof value=="string"&&value.trim()!==""||typeof value=="number"&&Number.isFinite(value)}function snapshotKeys(value){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const key of value)!isKey(key)||seen.has(key)||(seen.add(key),output.push(key));return frozenArray(output)}function keysEqual(left,right){return typeof left==typeof right&&left===right}function arrayHasKey(keys,key){return keys.some(candidate=>keysEqual(candidate,key))}function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.closest=="function"}function valueControl(value){return!isElementValue(value)||typeof value.value!="string"?null:value}function checkableControl(value){return!isElementValue(value)||typeof value.checked!="boolean"?null:value}function dateText(value){try{const timestamp=Date.prototype.getTime.call(value);return Number.isFinite(timestamp)?Date.prototype.toISOString.call(value):""}catch{return}}function humanizeIdentifier(value,locale){const intlLocale=resolveIntlLocale(locale);return value.replaceAll(/[._-]+/gu," ").replaceAll(/([a-z\d])([A-Z])/gu,"$1 $2").replace(/^./u,first=>first.toLocaleUpperCase(intlLocale))}function safeText(value){if(value==null)return"";if(typeof value=="object"){const serializedDate=dateText(value);if(serializedDate!==void 0)return serializedDate}if(Array.isArray(value))return value.map(safeText).join(", ");if(typeof value=="object")try{return JSON.stringify(value,(_key,nested)=>typeof nested=="bigint"?nested.toString():nested)??""}catch{return""}return String(value)}function normalizePinSide(side){return side==="start"?"left":side==="end"?"right":side}function normalizedGroupBy(value){return typeof value!="string"?(value??[]).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT):value.split(/[\s,]+/u).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT)}class LyraDataGrid extends LyraElement{constructor(){super(...arguments),this.appearance="outlined",this.childRows=null,this._columnOrder=Object.freeze([]),this.columnOccurrenceIds=new WeakMap,this.nextColumnOccurrenceId=1,this.rowOccurrenceIds=new WeakMap,this.nextRowOccurrenceId=1,this._columns=Object.freeze([]),this._data=Object.freeze([]),this.dataSource=null,this._expandedRowKeys=Object.freeze([]),this.filterDebounce=250,this.filterFromLeafRows=!1,this._filters=Object.freeze([]),this._groupBy=null,this.label=null,this.loading=!1,this.maxMultiSort=0,this.page=0,this.pageSize=20,this._pageSizeOptions=Object.freeze([10,20,50,100]),this.paginate=!1,this.pinnable=!1,this.reorderable=!1,this.resizable=!1,this.rowClass=null,this.rowDetail=null,this.rowKey=null,this.searchFn=null,this.searchTerm="",this.selectable="none",this.selectableRows=null,this._selectedRowKeys=Object.freeze([]),this.server=!1,this.size="m",this._sort=Object.freeze([]),this.sortDescFirst=!1,this.striped=!1,this.total=-1,this.withColumnMenu=!1,this.withColumnsMenu=!1,this.withoutSortRemoval=!1,this.withSearch=!1,this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map,this.activeFilterColumn=null,this.columnsMenuOpen=!1,this.activeColumnMenu=null,this.liveText="",this.bodyScrollTop=0,this.viewportHeight=0,this.focusedRow=-1,this.focusedColumn=0,this.dragGhost="",this.requestGeneration=0,this.ownsLoadingState=!1,this.columnDragSequence=0,this.lastSelectedIndex=-1,this.isMounting=!0,this.relayEditorFocus=event=>{relayNativeEvent(this,event)},this.relayEditorBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copied:LYRA_DEFAULT_copied,copyFailed:LYRA_DEFAULT_copyFailed,dataGridColumnMenu:LYRA_DEFAULT_dataGridColumnMenu,dataGridPinEnd:LYRA_DEFAULT_dataGridPinEnd,dataGridPinStart:LYRA_DEFAULT_dataGridPinStart,dataGridRowsPerPage:LYRA_DEFAULT_dataGridRowsPerPage,dataGridTreeLimitReached:LYRA_DEFAULT_dataGridTreeLimitReached,dataGridUnpin:LYRA_DEFAULT_dataGridUnpin,expand:LYRA_DEFAULT_expand,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,paginationFirstPage:LYRA_DEFAULT_paginationFirstPage,paginationJumpToPage:LYRA_DEFAULT_paginationJumpToPage,paginationLabel:LYRA_DEFAULT_paginationLabel,paginationLastPage:LYRA_DEFAULT_paginationLastPage,previous:LYRA_DEFAULT_previous,resizeColumn:LYRA_DEFAULT_resizeColumn,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel}}static{this.immutableEventDetails=Object.freeze(["request","lr-column-move","lr-data-error"])}static{this.identityEventDetailProperties=Object.freeze({request:Object.freeze(["signal"]),"lr-data-error":Object.freeze(["error","request"])})}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}get columnOrder(){return this._columnOrder}set columnOrder(value){const previous=this._columnOrder,seen=new Set;this._columnOrder=frozenArray(Array.isArray(value)?value.filter(id=>typeof id!="string"||id.trim()===""||seen.has(id)?!1:(seen.add(id),!0)):[]),this.requestUpdate("columnOrder",previous)}get columns(){return this._columns}set columns(value){const previous=this._columns;this._columns=snapshotColumns(value,column=>{const current=this.columnOccurrenceIds.get(column);if(current)return current;const identity=`column-occurrence-${this.nextColumnOccurrenceId}`;return this.nextColumnOccurrenceId+=1,this.columnOccurrenceIds.set(column,identity),identity}),this.requestUpdate("columns",previous)}get data(){return this._data}set data(value){const previous=this._data;this._data=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("data",previous)}get expandedRowKeys(){return this._expandedRowKeys}set expandedRowKeys(value){const previous=this._expandedRowKeys;this._expandedRowKeys=snapshotKeys(value),this.requestUpdate("expandedRowKeys",previous),this.requestUpdate("expandedKeys",previous)}get expandedKeys(){return this.expandedRowKeys}set expandedKeys(value){this.expandedRowKeys=value}get filteredCount(){return this.processedClientRows.length}get filters(){return this._filters}set filters(value){const previous=this._filters,next=[];if(Array.isArray(value))for(const filter of value)try{if(!filter||typeof filter.id!="string")continue;const filterValue=filter.value instanceof Set||Array.isArray(filter.value)?frozenArray(filter.value):filter.value;next.push(Object.freeze({id:filter.id,value:filterValue}))}catch{}this._filters=Object.freeze(next),this.requestUpdate("filters",previous)}get groupBy(){return this._groupBy}set groupBy(value){const previous=this._groupBy;this._groupBy=typeof value=="string"?value:Array.isArray(value)?frozenArray(value.filter(item=>typeof item=="string")):null,this.requestUpdate("groupBy",previous)}get pageCount(){const size=this.safePageSize;if(size===0)return 0;if(!this.usesServerData&&normalizedGroupBy(this.groupBy).length>0){const groups=this.topLevelGroupBuckets(this.processedClientRows).length;return groups<=0?0:Math.ceil(groups/size)}const count=this.safeTotal>=0?this.safeTotal:this.filteredCount;return count<=0?0:Math.ceil(count/size)}get pageSizeOptions(){return this._pageSizeOptions}set pageSizeOptions(value){const previous=this._pageSizeOptions;this._pageSizeOptions=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("pageSizeOptions",previous)}get selectedRowKeys(){return this._selectedRowKeys}set selectedRowKeys(value){const previous=this._selectedRowKeys;this._selectedRowKeys=snapshotKeys(value),this.requestUpdate("selectedRowKeys",previous),this.requestUpdate("selectedKeys",previous)}get selectedKeys(){return this.selectedRowKeys}set selectedKeys(value){this.selectedRowKeys=value}get selectedRows(){return frozenArray(this.allSourceRows.filter((row,index)=>arrayHasKey(this.selectedKeys,this.keyForRow(row,index))))}set selectedRows(next){const source=this.allSourceRows,sourceSet=new Set(source),sourceIndexes=this.sourceIndexMap(source),candidates=Array.isArray(next)?next:[],seen=new Set,rows=candidates.filter(row=>!sourceSet.has(row)||seen.has(row)?!1:(seen.add(row),!0)),limited=this.selectionMode==="single"?rows.slice(0,1):rows;this.selectedKeys=limited.map(row=>this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??0))}get sort(){return this._sort}set sort(value){const previous=this._sort,next=[];if(Array.isArray(value))for(const item of value)try{if(!item||typeof item.id!="string")continue;next.push(Object.freeze({id:item.id,desc:!!item.desc}))}catch{}this._sort=Object.freeze(next),this.requestUpdate("sort",previous)}connectedCallback(){super.connectedCallback(),this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.dataSource&&this.scheduleServerRequest(!1)}disconnectedCallback(){this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1,this.cancelRequestTimer(),this.resizeSession?.moved&&this.restoreResizeSession(this.resizeSession,!1),this.resizeSession=void 0,this.activeFilterColumn=null,this.activeColumnMenu=null,this.columnsMenuOpen=!1,this.dragGhost="",this.columnDragSession=void 0,this.sink?.release(),this.sink=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&changed.has("loading")&&this.loading&&this.announce(this.localize("loading"));const sourceReplaced=changed.has("dataSource")&&changed.get("dataSource")!==void 0,serverDisabled=changed.has("server")&&!this.usesServerData;if((sourceReplaced||serverDisabled)&&(this.requestController||this.requestTimer!==void 0)&&(this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.cancelRequestTimer(),this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1),this.resizeSession&&(changed.has("resizable")||changed.has("columns"))&&!this.columnCanResize(this.resizeSession.columnId)){const session=this.resizeSession;this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0)}if(this.columnDragSession&&(changed.has("reorderable")||changed.has("columns"))&&!this.columnCanMove(this.columnDragSession.sourceId)&&(this.columnDragSession=void 0,this.dragGhost=""),changed.has("columns")&&this.handleColumnsChange(),!this.usesServerData&&(changed.has("data")||changed.has("rowKey")||changed.has("childRows")||changed.has("server")||changed.has("dataSource"))){const validKeys=this.allSourceRows.map((row,index)=>this.keyForRow(row,index)),validKeySet=new Set(validKeys),selectedKeys=this.selectedKeys.filter(key=>validKeySet.has(key));(selectedKeys.length!==this.selectedKeys.length||selectedKeys.some((key,index)=>!keysEqual(key,this.selectedKeys[index])))&&(this.selectedKeys=selectedKeys),this.lastSelectedIndex=-1}if(this.paginate&&(changed.has("data")||changed.has("filters")||changed.has("searchTerm")||changed.has("groupBy")||changed.has("pageSize")||changed.has("total")||changed.has("server")||changed.has("dataSource"))){const lastPage=Math.max(0,this.pageCount-1);this.page=finiteInteger(this.page,0,0,lastPage)}(changed.has("data")||changed.has("columns")||changed.has("filters")||changed.has("searchTerm")||changed.has("sort")||changed.has("expandedKeys")||changed.has("groupBy")||changed.has("page")||changed.has("pageSize")||changed.has("paginate")||changed.has("childRows"))&&(this.focusedRow=finiteInteger(this.focusedRow,-1,-1,Math.max(-1,this.displayItems.length-1)),this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1)))}updated(changed){if(super.updated(changed),changed.has("dataSource")&&this.dataSource&&this.scheduleServerRequest(!1),(changed.has("sort")||changed.has("filters")||changed.has("searchTerm")||changed.has("page")||changed.has("pageSize")||changed.has("server"))&&(this.server||this.dataSource)){const delayed=changed.has("filters")||changed.has("searchTerm");this.scheduleServerRequest(delayed)}this.isMounting=!1}announce(text){this.sink?.announce(text),this.liveText=text}get usesServerData(){return this.server||this.dataSource!==null}get safePage(){return finiteInteger(this.page,0,0,Math.max(0,this.pageCount-1))}get safePageSize(){return finiteCount(this.pageSize)}get safeTotal(){return this.total===-1?-1:finiteCount(this.total)}sourceProjection(){const result=[],visited=new Set,seenRowKeys=new Set,stack=[];for(let index=this.data.length-1;index>=0;index-=1)stack.push({row:this.data[index],depth:0});let truncated=!1;for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(!trackIdentity||trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const rowKey=this.rowIdentity(current.row);if(rowKey===void 0||seenRowKeys.has(rowKey))continue;seenRowKeys.add(rowKey),result.push(current.row);const children=this.childrenFor(current.row);if(children.length!==0){if(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT){truncated=!0;continue}for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}}return stack.length>0&&(truncated=!0),{rows:Object.freeze(result),truncated}}get allSourceRows(){return this.sourceProjection().rows}get canonicalRootRows(){const canonical=new Set(this.allSourceRows);return this.data.filter(row=>canonical.has(row))}sourceIndexMap(rows=this.allSourceRows){const indexes=new Map;return rows.forEach((row,index)=>{indexes.has(row)||indexes.set(row,index)}),indexes}sourceIndexFor(row,indexes){const direct=indexes.get(row);if(direct!==void 0)return direct;const identity=this.rowIdentity(row);if(identity!==void 0){for(const[candidate,index]of indexes)if(Object.is(this.rowIdentity(candidate),identity))return index}}canonicalMembers(rows){const byIdentity=new Map;for(const row of this.allSourceRows){const identity=this.rowIdentity(row);identity!==void 0&&!byIdentity.has(identity)&&byIdentity.set(identity,row)}const output=[],seen=new Set;for(const candidate of rows){const identity=this.rowIdentity(candidate);if(identity===void 0||seen.has(identity))continue;const canonical=byIdentity.get(identity);canonical&&(seen.add(identity),output.push(canonical))}return output}get orderedColumns(){const entries=this.columns.map((column,naturalIndex)=>({column,id:columnId(column,naturalIndex),naturalIndex}));if(this.columnOrder.length===0)return entries;const rank=new Map(this.columnOrder.map((id,index)=>[id,index]));return entries.sort((left,right)=>{const leftRank=rank.get(left.id),rightRank=rank.get(right.id);return leftRank===void 0&&rightRank===void 0?left.naturalIndex-right.naturalIndex:leftRank===void 0?1:rightRank===void 0?-1:leftRank-rightRank})}get visibleColumns(){const entries=this.orderedColumns.filter(({column,id})=>this.columnVisibility.get(id)??column.hidden!==!0),rank=(side,id)=>this.orderedColumns.filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).findIndex(entry=>entry.id===id);return entries.sort((left,right)=>{const leftPin=normalizePinSide(this.getColumnPin(left.id)),rightPin=normalizePinSide(this.getColumnPin(right.id));return leftPin===rightPin?0:leftPin==="left"?-1:rightPin==="left"||leftPin==="right"?1:rightPin==="right"?-1:rank("left",left.id)-rank("right",right.id)})}get processedClientRows(){const rows=this.canonicalRootRows;if(this.usesServerData)return[...rows];if(this.childRows){const included=rows.filter(row=>this.rowMatches(row)||this.filterFromLeafRows&&this.hasMatchingDescendant(row));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}const filtered=filterRows(rows,this.columns,this.filters,this.effectiveLocale),searched=searchRows(filtered,this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);return sortRows(searched,this.columns,this.sort,this.effectiveLocale)}childrenFor(row){try{const children=typeof this.childRows=="function"?this.childRows(row):this.childRows?pathValue(row,this.childRows):void 0;return Array.isArray(children)?children.slice(0,DATA_GRID_TREE_NODE_LIMIT):[]}catch{return[]}}rowIdentity(row){if(!((typeof row!="object"||row===null)&&typeof row!="function"))try{if(this.rowKey){const candidate=pathValue(row,this.rowKey);return isKey(candidate)?candidate:void 0}const object=row,current=this.rowOccurrenceIds.get(object);if(current)return current;const identity=`row-occurrence-${this.nextRowOccurrenceId}`;return this.nextRowOccurrenceId+=1,this.rowOccurrenceIds.set(object,identity),identity}catch{return}}keyForRow(row,_index){return this.rowIdentity(row)}renderedColumnElements(columnId2,role){const prefix=role?`[role="${role}"]`:"",ownerCss=this.ownerDocument.defaultView?.CSS,escape=ownerCss?.escape;if(typeof escape=="function")try{const matches=[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id="${escape.call(ownerCss,columnId2)}"]`)];if(matches.length>0)return matches}catch{}return[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id]`)].filter(element=>element.getAttribute("data-column-id")===columnId2)}computedToken(name,privateDefault){if(!this.isConnected)return"";const owner=this.ownerDocument.defaultView;if(!owner||typeof owner.getComputedStyle!="function")return"";try{const style=owner.getComputedStyle(this);return style.getPropertyValue(name).trim()||(privateDefault?style.getPropertyValue(privateDefault).trim():"")}catch{return""}}autoSizeColumn(columnId2){const cells=this.renderedColumnElements(columnId2);if(cells.length===0)return;let width=0;for(const cell of cells)width=Math.max(width,cell.scrollWidth);const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column);this.setColumnWidth(columnId2,finiteRange(width,minimum,minimum,maximum),!1)}autoSizeColumns(){for(const{id}of this.visibleColumns)this.autoSizeColumn(id)}collapseAllRows(){this.expandedKeys=[]}collapseRow(key){this.expandedKeys=this.expandedKeys.filter(candidate=>!keysEqual(candidate,key))}copySelectedRows(options={}){const rowsToCopy=this.selectedRows.length>0?this.selectedRows:this.getProcessedRows(),format=options.format??"tsv",text=this.delimitedRows(rowsToCopy,{...options,delimiter:options.delimiter??(format==="csv"?",":" ")});return this.copyAndReport(text),rowsToCopy.length}expandAllRows(){const keys=[];this.allSourceRows.forEach((row,index)=>{(this.childrenFor(row).length>0||this.rowDetail)&&keys.push(this.keyForRow(row,index))});for(const group of this.groupItems(this.processedClientRows))keys.push(group.key);this.expandedKeys=keys}expandRow(key){arrayHasKey(this.expandedKeys,key)||(this.expandedKeys=[...this.expandedKeys,key])}exportDataAsCsv(options={}){const text=this.getDataAsCsv(options),ownerDocument=this.ownerDocument,owner=ownerDocument.defaultView;if(!owner||typeof owner.URL.createObjectURL!="function")return;const url=owner.URL.createObjectURL(new owner.Blob([text],{type:"text/csv;charset=utf-8"}));try{const anchor=ownerDocument.createElement("a");anchor.href=url,anchor.download=options.fileName||"data.csv",anchor.hidden=!0,ownerDocument.body?.append(anchor),anchor.click(),anchor.remove()}finally{owner.URL.revokeObjectURL(url)}}focus(options={}){const selector=this.focusedRow<0?`[role="columnheader"][data-column-position="${this.focusedColumn}"]`:`[role="gridcell"][data-row-position="${this.focusedRow}"][data-column-position="${this.focusedColumn}"]`;this.renderRoot.querySelector(selector)?.focus(options)}getColumnFacets(columnId2){const uniqueValues=new Map;if(this.usesServerData)return Object.freeze({uniqueValues});const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return Object.freeze({uniqueValues});const otherFilters=this.filters.filter(filter=>filter.id!==columnId2),rows=searchRows(filterRows(this.canonicalRootRows,this.columns,otherFilters,this.effectiveLocale),this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);let minimum=Number.POSITIVE_INFINITY,maximum=Number.NEGATIVE_INFINITY;for(const row of rows){const value=columnValue(entry.column,row);uniqueValues.set(value,(uniqueValues.get(value)??0)+1);const number=typeof value=="number"?value:Number(value);Number.isFinite(number)&&(minimum=Math.min(minimum,number),maximum=Math.max(maximum,number))}return Number.isFinite(minimum)&&Number.isFinite(maximum)?Object.freeze({uniqueValues,minMax:Object.freeze([minimum,maximum])}):Object.freeze({uniqueValues})}getColumnPin(columnId2){return this.columnPinning.has(columnId2)?this.columnPinning.get(columnId2)??!1:this.orderedColumns.find(({id})=>id===columnId2)?.column.pinned??!1}getDataAsCsv(options={}){return this.delimitedRows(this.getProcessedRows(),options)}getProcessedRows(){return frozenArray(this.processedClientRows)}getVisibleRows(){const rows=this.processedClientRows;if(!this.paginate||this.usesServerData)return frozenArray(rows);const size=this.safePageSize;if(size===0)return[];const start=this.safePage*size;return normalizedGroupBy(this.groupBy).length>0?frozenArray(this.topLevelGroupBuckets(rows).slice(start,start+size).flatMap(bucket=>bucket.rows)):frozenArray(rows.slice(start,start+size))}getState(){return Object.freeze({order:frozenArray(this.columnOrder),widths:Object.freeze(Object.fromEntries(this.columnWidths)),visibility:Object.freeze(Object.fromEntries(this.columnVisibility)),pinning:Object.freeze(Object.fromEntries(this.columnPinning)),sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,selectedRowKeys:frozenArray(this.selectedRowKeys),expandedRowKeys:frozenArray(this.expandedRowKeys),selectedKeys:frozenArray(this.selectedRowKeys),expandedKeys:frozenArray(this.expandedRowKeys),page:this.safePage,pageSize:this.safePageSize})}handleColumnsChange(){const valid=new Set(this.columns.map((column,index)=>columnId(column,index))),natural=[...valid],order=this.columnOrder.filter(id=>valid.has(id));for(const id of natural)order.includes(id)||order.push(id);this.columnOrder.length>0&&order.join("\0")!==this.columnOrder.join("\0")&&(this.columnOrder=order);const widths=[...this.columnWidths].filter(([id])=>valid.has(id)),visibility=[...this.columnVisibility].filter(([id])=>valid.has(id)),pinning=[...this.columnPinning].filter(([id])=>valid.has(id));widths.length!==this.columnWidths.size&&(this.columnWidths=new Map(widths)),visibility.length!==this.columnVisibility.size&&(this.columnVisibility=new Map(visibility)),pinning.length!==this.columnPinning.size&&(this.columnPinning=new Map(pinning))}handlePageChange(){this.applyPageChange(this.safePage)}applyPageChange(value){let requested;typeof value=="number"?requested=value:requested=Number(valueControl(value?.currentTarget)?.value??this.safePage);const last=Math.max(0,this.pageCount-1),next=finiteInteger(requested,this.safePage,0,last);this.page=next,this.emit("lr-page-change",Object.freeze({page:next,pageSize:this.safePageSize}))}handleSearchTermChange(){this.applySearchTermChange(this.searchTerm)}applySearchTermChange(value){const next=typeof value=="string"?value:valueControl(value?.currentTarget)?.value??this.searchTerm;this.searchTerm=next,this.page!==0&&(this.page=0)}pinColumn(columnId2,side){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnPinning);next.set(columnId2,side),this.columnPinning=next}async reload(){const owner=this.ownerDocument.defaultView;!this.isConnected||!owner||!this.usesServerData||(this.cancelRequestTimer(),await this.loadServerData(owner))}resetColumns(){this.columnOrder=[],this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map}resetState(){this.resetColumns(),this.sort=[],this.filters=[],this.searchTerm="",this.expandedKeys=[]}scrollToIndex(index,options={}){const rows=this.getVisibleRows();if(rows.length===0)return;const requestedIndex=finiteInteger(index,0,0,rows.length-1),requestedRow=rows[requestedIndex],sourceIndexes=this.sourceIndexMap(),sourceIndex=this.sourceIndexFor(requestedRow,sourceIndexes),requestedKey=this.keyForRow(requestedRow,sourceIndex??requestedIndex),target=this.displayItems.findIndex(item=>item.kind==="row"&&(item.row===requestedRow||keysEqual(item.key,requestedKey)));if(target<0)return;const rendered=this.renderRoot?.querySelector(`[part~="row"][data-visible-index="${target}"]`);if(rendered){rendered.scrollIntoView({block:options.align??"nearest"});return}const body=this.bodyElement;if(!body)return;const rowHeight=this.resolvedRowHeight;let top=target*rowHeight;options.align==="center"?top-=(body.clientHeight-rowHeight)/2:options.align==="end"&&(top-=body.clientHeight-rowHeight),body.scrollTo({top:Math.max(0,top)})}setState(state2){const known=new Set(this.columns.map((column,index)=>columnId(column,index)));state2.order&&(this.columnOrder=state2.order.filter(id=>known.has(id))),state2.widths&&(this.columnWidths=this.validColumnMap(state2.widths,known,width=>finiteRange(width,0,0))),state2.visibility&&(this.columnVisibility=this.validColumnMap(state2.visibility,known,Boolean)),state2.pinning&&(this.columnPinning=this.validColumnMap(state2.pinning,known,side=>side==="left"||side==="right"||side==="start"||side==="end"?side:!1)),state2.sort&&(this.sort=state2.sort.filter(item=>known.has(item.id)).map(item=>({id:item.id,desc:!!item.desc}))),state2.filters&&(this.filters=state2.filters.filter(item=>known.has(item.id)).map(item=>({...item}))),state2.search!==void 0&&(this.searchTerm=state2.search);const selectedRowKeys=state2.selectedRowKeys??state2.selectedKeys,expandedRowKeys=state2.expandedRowKeys??state2.expandedKeys;selectedRowKeys&&(this.selectedRowKeys=selectedRowKeys),expandedRowKeys&&(this.expandedRowKeys=expandedRowKeys),state2.page!==void 0&&(this.page=finiteCount(state2.page)),state2.pageSize!==void 0&&(this.pageSize=finiteCount(state2.pageSize))}sizeColumnsToFit(){const body=this.bodyElement;if(!body||this.visibleColumns.length===0)return;const selectionWidth=this.selectionEnabled?resolveCssLength(this.computedToken("--lr-icon-button-size"),{host:this})??0:0,available=Math.max(0,body.clientWidth-selectionWidth),flexible=this.visibleColumns.filter(({column})=>column.flex!==0);if(flexible.length===0)return;const totalFlex=flexible.reduce((sum,{column})=>sum+finiteRange(column.flex??1,1,0),0)||flexible.length,next=new Map(this.columnWidths);for(const{column,id}of flexible){const share=available*(finiteRange(column.flex??1,1,0)/totalFlex),{minimum,maximum}=this.columnBounds(column);next.set(id,finiteRange(share,minimum,minimum,maximum))}this.columnWidths=next}toggleColumn(columnId2,visible){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnVisibility);next.set(columnId2,visible),this.columnVisibility=next,this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1))}validColumnMap(record,known,convert){const result=new Map;for(const[id,value]of Object.entries(record))known.has(id)&&result.set(id,convert(value));return result}delimitedRows(rows,options){const active=this.visibleColumns.map(({column,id})=>({...column,id,value:row=>{const raw=columnValue(column,row),formatted=column.formatter?.(raw,row);return typeof formatted=="string"?formatted:raw},hidden:!1}));return rowsAsDelimited(rows,active,options)}async copyAndReport(text){const owner=this.isConnected?this.ownerDocument.defaultView:null,outcome=await this.writeClipboard(text,owner);if(!(!owner||!this.isConnected||this.ownerDocument.defaultView!==owner)){if(outcome.ok){this.isMounting||this.announce(this.localize("copied")),this.emit("lr-copy",outcome);return}this.isMounting||this.announce(this.localize("copyFailed")),this.emit("lr-error"),this.emit("lr-copy-error",outcome)}}async writeClipboard(text,owner){const ownerDocument=this.ownerDocument,outcome=await writeClipboardText(owner,text);if(outcome.ok||!owner||ownerDocument.defaultView!==owner||!ownerDocument.body)return outcome;const textarea=ownerDocument.createElement("textarea");textarea.value=text,textarea.style.position="fixed",textarea.style.opacity="0",ownerDocument.body.append(textarea);try{if(textarea.select(),ownerDocument.execCommand?.("copy"))return Object.freeze({ok:!0,text})}finally{textarea.remove()}return outcome}setColumnWidth(columnIdValue,width,emit,finished=!0){const entry=this.orderedColumns.find(({id})=>id===columnIdValue);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column),safeWidth=finiteRange(width,minimum,minimum,maximum),next=new Map(this.columnWidths);next.set(columnIdValue,safeWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:columnIdValue,width:safeWidth,finished}))}cancelRequestTimer(){const timer=this.requestTimer;this.requestTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}scheduleServerRequest(delayed){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner||!this.usesServerData)return;this.cancelRequestTimer();const delay=delayed?finiteDuration(this.filterDebounce,250):0;let handle=0;handle=owner.setTimeout(()=>{this.requestTimer?.owner!==owner||this.requestTimer.handle!==handle||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.requestTimer=void 0,this.loadServerData(owner))},delay),this.requestTimer={owner,handle}}async loadServerData(owner){if(!this.isConnected||this.ownerDocument.defaultView!==owner||!this.usesServerData)return;this.requestController?.abort();const AbortControllerCtor=owner.AbortController;this.requestController=typeof AbortControllerCtor=="function"?new AbortControllerCtor:void 0;const generation=++this.requestGeneration,request=Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,page:this.safePage,pageSize:this.safePageSize,signal:this.requestController?.signal}),requestDetail=()=>Object.freeze({...request,sort:frozenArray(request.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(request.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)})))});if(this.emit("request",requestDetail()),!!this.dataSource){this.ownsLoadingState=!0,this.loading=!0;try{const response=await this.dataSource(request);if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.data=Array.isArray(response.rows)?response.rows:[],this.total=finiteCount(response.total),this.loading=!1,this.ownsLoadingState=!1}catch(error){if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.loading=!1,this.ownsLoadingState=!1,this.emit("lr-data-error",Object.freeze({error,request:requestDetail()}))}}}get selectionMode(){return this.selectable===""||this.selectable==="multiple"?"multiple":this.selectable}get selectionEnabled(){return this.selectionMode!=="none"}rowIsSelectable(row){return this.selectionEnabled&&(this.selectableRows?.(row)??!0)}rowMatches(row){return filterRows([row],this.columns,this.filters,this.effectiveLocale).length>0&&searchRows([row],this.columns,this.searchTerm,this.effectiveLocale,this.searchFn).length>0}processedChildrenFor(row){const children=this.canonicalMembers(this.childrenFor(row));if(children.length===0||this.usesServerData)return children;const included=children.filter(child=>this.rowMatches(child)?!0:this.filterFromLeafRows&&this.hasMatchingDescendant(child));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}hasMatchingDescendant(row){const stack=this.canonicalMembers(this.childrenFor(row)).map(child=>({row:child,depth:1})),visited=new Set;let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(!(trackIdentity&&visited.has(current.row))){if(trackIdentity&&visited.add(current.row),inspected+=1,this.rowMatches(current.row))return!0;if(!(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))for(const child of this.canonicalMembers(this.childrenFor(current.row)))stack.push({row:child,depth:current.depth+1})}}return!1}get pageRows(){return this.getVisibleRows()}get currentPageSelectableRows(){const result=[],sourceIndex=new Map(this.allSourceRows.map((row,index)=>[row,index])),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row),inspected+=1;const index=this.sourceIndexFor(current.row,sourceIndex);if(index===void 0)continue;const key=this.keyForRow(current.row,index);if(this.rowIsSelectable(current.row)&&result.push({row:current.row,key}),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let childIndex=children.length-1;childIndex>=0;childIndex-=1){const child=children[childIndex];stack.push({row:child,depth:current.depth+1})}}return result}groupKey(parent,id,value){return`group:${parent}:${id}:${typeof value}:${safeText(value)}`}topLevelGroupBuckets(rows){const field=normalizedGroupBy(this.groupBy)[0];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return[];const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}return[...buckets].map(([value,bucketRows])=>({value,rows:bucketRows}))}groupItems(rows){const fields=normalizedGroupBy(this.groupBy);if(fields.length===0||this.usesServerData)return[];const result=[],visit=(groupRows,depth,parent)=>{const field=fields[depth];if(!field)return;const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return;const buckets=new Map;for(const row of groupRows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),depth+1<fields.length&&visit(bucket,depth+1,key)}};return visit(rows,0,"root"),result}get displayItems(){const groups=normalizedGroupBy(this.groupBy);if(groups.length>0&&!this.usesServerData)return this.groupedDisplayItems(this.pageRows,groups,0,"root",this.sourceIndexMap());const result=[],sourceRows=this.allSourceRows,indexes=this.sourceIndexMap(sourceRows),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const sourceIndex=this.sourceIndexFor(current.row,indexes);if(sourceIndex===void 0)continue;const safeIndex=sourceIndex,key=this.keyForRow(current.row,safeIndex);if(result.push({kind:"row",row:current.row,key,depth:current.depth,sourceIndex:safeIndex}),!arrayHasKey(this.expandedKeys,key)||current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.processedChildrenFor(current.row);for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}return result}groupedDisplayItems(rows,fields,depth,parent,sourceIndexes){const field=fields[depth];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return rows.map((row,index)=>({kind:"row",row,key:this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??index),depth,sourceIndex:this.sourceIndexFor(row,sourceIndexes)??index}));const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}const result=[];for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);if(result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),!!arrayHasKey(this.expandedKeys,key))if(depth+1<fields.length)result.push(...this.groupedDisplayItems(bucket,fields,depth+1,key,sourceIndexes));else for(const row of bucket){const sourceIndex=this.sourceIndexFor(row,sourceIndexes);result.push({kind:"row",row,key:this.keyForRow(row,sourceIndex??result.length),depth:depth+1,sourceIndex:sourceIndex??result.length})}}return result}get resolvedRowHeight(){const raw=this.computedToken("--row-height","--_lr-data-grid-row-height");return finiteRange(resolveCssLength(raw,{host:this})??56,56,1)}get virtualWindow(){const items=this.displayItems,expandedDetails=!!(this.rowDetail&&items.some(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)));if(items.length<VIRTUALIZATION_THRESHOLD||expandedDetails||this.computedToken("--max-height","--_lr-data-grid-max-height")==="none")return{items,start:0,end:items.length};const height=this.resolvedRowHeight,visibleCount=Math.max(1,Math.ceil((this.viewportHeight||height*10)/height)),start=Math.min(Math.max(0,items.length-visibleCount),Math.max(0,Math.floor(this.bodyScrollTop/height)-VIRTUAL_OVERSCAN)),end=Math.min(items.length,start+visibleCount+VIRTUAL_OVERSCAN*2);return{items:items.slice(start,end),start,end}}get gridTemplate(){const columns=this.visibleColumns.map(({column,id})=>{const bounds=this.columnBounds(column),width=this.columnWidths.get(id)??column.width;if(width!==void 0&&Number.isFinite(width)&&width>0)return`${finiteRange(width,bounds.minimum,bounds.minimum,bounds.maximum)}px`;const minimum=bounds.minimum>0?`${bounds.minimum}px`:Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?"0px":"var(--lr-size-7rem)",maximum=Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?`${bounds.maximum}px`:`${finiteRange(column.flex??1,1,0)}fr`;return`minmax(${minimum}, ${maximum})`});return this.selectionEnabled&&columns.unshift("var(--lr-icon-button-size)"),columns.length>0?columns.join(" "):"minmax(var(--lr-size-7rem), 1fr)"}columnStyle(column,id){const side=normalizePinSide(this.getColumnPin(id)),pinOffset=side?this.pinOffset(id,side):0;return{...side?{"--pin-offset":`${pinOffset}px`}:{},...Number.isFinite(column.width)&&(column.width??0)>0&&!this.columnWidths.has(id)?{"--column-authored-width":`${column.width}px`}:{}}}estimatedColumnWidth(column,id){const{minimum,maximum}=this.columnBounds(column),explicit=this.columnWidths.get(id)??column.width;if(explicit!==void 0)return finiteRange(explicit,Math.max(112,minimum),minimum,maximum);const raw=this.computedToken("--lr-size-7rem");return finiteRange(resolveCssLength(raw,{host:this})??112,Math.max(112,minimum),minimum,maximum)}columnBounds(column){const minimum=finiteRange(column.minWidth??0,0,0),authoredMaximum=finiteRange(column.maxWidth??Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0);return Object.freeze({minimum,maximum:Math.max(minimum,authoredMaximum)})}pinOffset(id,side){const entries=this.visibleColumns,index=entries.findIndex(entry=>entry.id===id);return index<0?0:(side==="left"?entries.slice(0,index):entries.slice(index+1)).filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).reduce((sum,entry)=>sum+this.estimatedColumnWidth(entry.column,entry.id),0)}columnLabel(column,id){return column.label??humanizeIdentifier(column.field??id,this.effectiveLocale)}columnIsSortable(column){return column.sortable!==!1&&!!(column.field||column.value)}sortFor(id){const index=this.sort.findIndex(item=>item.id===id);return{state:index>=0?this.sort[index]:void 0,index}}activateSort(id,additive){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnIsSortable(entry.column))return;const existing=this.sortFor(id).state,descendingFirst=entry.column.sortDescFirst??this.sortDescFirst;let replacement;existing?existing.desc===descendingFirst?replacement={id,desc:!descendingFirst}:this.withoutSortRemoval&&(replacement={id,desc:descendingFirst}):replacement={id,desc:descendingFirst};let next=additive?this.sort.filter(item=>item.id!==id):[];replacement&&next.push(replacement);const limit=finiteCount(this.maxMultiSort);limit>0&&next.length>limit&&(next=next.slice(next.length-limit)),this.sort=next,this.page=0,this.emit("lr-sort-change",Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item})))}))}onHeaderClick(event,id){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget||this.activateSort(id,event.shiftKey)}onFilterInput(event,id){const control=valueControl(event.currentTarget);if(!control)return;const value=control.value,next=this.filters.filter(filter=>filter.id!==id);value&&next.push({id,value}),this.filters=next,this.page=0,this.emit("lr-filter-change",Object.freeze({filters:frozenArray(next.map(filter=>Object.freeze({...filter})))}))}onBodyScroll(event){const target=event.currentTarget;!isElementValue(target)||typeof target.scrollTop!="number"||typeof target.clientHeight!="number"||(this.bodyScrollTop=target.scrollTop,this.viewportHeight=target.clientHeight)}onCellClick(event,item,column,columnIdValue,index){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget&&isElementValue(event.currentTarget)&&event.currentTarget.contains(interactive)||this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index}))}emitCellContextMenu(originalEvent,item,column,columnIdValue,index){const detail=Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index,originalEvent});this.emit("lr-cell-contextmenu",detail,{cancelable:!0}).defaultPrevented&&originalEvent.preventDefault()}descendantRows(row){const result=[],visited=new Set,stack=this.canonicalMembers(this.childrenFor(row)).reverse().map(child=>({row:child,depth:1}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&&current.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row)||(trackIdentity&&visited.add(current.row),result.push(current.row),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let index=children.length-1;index>=0;index-=1){const child=children[index];stack.push({row:child,depth:current.depth+1})}}return result}setRowSelected(item,selected,event){if(!this.rowIsSelectable(item.row))return;const selectableItems=this.displayItems.filter(candidate=>candidate.kind==="row"&&this.rowIsSelectable(candidate.row)),position=selectableItems.findIndex(candidate=>keysEqual(candidate.key,item.key));let affected=[item];if(event?.shiftKey&&this.selectionMode==="multiple"&&this.lastSelectedIndex>=0){const from=Math.min(this.lastSelectedIndex,position),to=Math.max(this.lastSelectedIndex,position);affected=selectableItems.slice(from,to+1)}const descendants=this.selectionMode==="multiple"?affected.flatMap(candidate=>this.descendantRows(candidate.row)).filter(row=>this.rowIsSelectable(row)):[],sourceIndexes=this.sourceIndexMap(),keys=[...affected.map(candidate=>candidate.key),...descendants.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)})];let next=this.selectionMode==="single"?[]:[...this.selectedKeys];for(const key of keys)next=next.filter(candidate=>!keysEqual(candidate,key)),selected&&next.push(key);this.selectedKeys=next,this.lastSelectedIndex=position,this.emitSelection()}selectCurrentPage(selected){const pageKeys=this.currentPageSelectableRows.map(item=>item.key);let next=this.selectedKeys.filter(key=>!pageKeys.some(pageKey=>keysEqual(pageKey,key)));selected&&(next=[...next,...pageKeys]),this.selectedKeys=next,this.emitSelection()}emitSelection(){const selectedRowKeys=frozenArray(this.selectedRowKeys),selectedRows=frozenArray(this.selectedRows);this.emit("lr-row-select",Object.freeze({selectedRowKeys,selectedKeys:selectedRowKeys,selectedRows}))}rowSelectionState(item){const own=arrayHasKey(this.selectedKeys,item.key),descendants=this.descendantRows(item.row).filter(row=>this.rowIsSelectable(row));if(descendants.length===0)return{checked:own,indeterminate:!1};const sourceIndexes=this.sourceIndexMap(),selected=descendants.filter((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return arrayHasKey(this.selectedKeys,this.keyForRow(row,sourceIndex??index))}).length,checked=own&&selected===descendants.length;return{checked,indeterminate:!checked&&(own||selected>0)}}toggleRowExpanded(item,emitUserEvent){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key),emitUserEvent&&this.emit(expanded?"lr-row-collapse":"lr-row-expand",Object.freeze({rowKey:item.key,key:item.key,row:item.row}))}toggleGroupExpanded(item){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key);const detail=Object.freeze({key:item.key,columnId:item.columnId,value:item.value,rows:frozenArray(item.rows)});this.emit(expanded?"lr-group-collapse":"lr-group-expand",detail)}moveColumn(id,delta,emitUserEvent){const order=this.orderedColumns.map(entry=>entry.id),from=order.indexOf(id);if(from<0)return;const to=finiteInteger(from+delta,from,0,order.length-1);from!==to&&(order.splice(from,1),order.splice(to,0,id),this.columnOrder=order,emitUserEvent&&this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:id,finished:!0})))}columnCanMove(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.reorderable||entry.column.movable))}columnCanResize(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.resizable||entry.column.resizable))}onDragStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanMove(id)||!event.dataTransfer){event.preventDefault();return}const token=`${++this.columnDragSequence}:${id}`;this.columnDragSession=Object.freeze({sourceId:id,token}),event.dataTransfer.setData(DATA_GRID_DRAG_TYPE,token),event.dataTransfer.setData("text/plain",id),event.dataTransfer.effectAllowed="move",this.dragGhost=this.columnLabel(entry.column,id)}onDrop(event,targetId){event.preventDefault();const session=this.columnDragSession,token=event.dataTransfer?.getData(DATA_GRID_DRAG_TYPE),sourceId=session?.sourceId;if(this.columnDragSession=void 0,this.dragGhost="",!session||token!==session.token||!sourceId||sourceId===targetId||!this.columnCanMove(sourceId)||!this.columnCanMove(targetId))return;const order=this.orderedColumns.map(entry=>entry.id),source=order.indexOf(sourceId),target=order.indexOf(targetId);source<0||target<0||(order.splice(source,1),order.splice(target,0,sourceId),this.columnOrder=order,this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:sourceId,finished:!0})))}onResizeStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const header=this.renderedColumnElements(id,"columnheader")[0];this.resizeSession={columnId:id,startClientX:event.clientX,startWidth:header?.getBoundingClientRect().width??this.estimatedColumnWidth(entry.column,id),initialStateWidth:this.columnWidths.get(id),pointerId:event.pointerId,moved:!1,direction:this.effectiveDirection};try{event.currentTarget.setPointerCapture?.(event.pointerId)}catch{}event.preventDefault()}onResizeMove(event){const session=this.resizeSession;if(!session||event.pointerId!==session.pointerId)return;if(!this.columnCanResize(session.columnId)){this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0);return}const direction=session.direction==="rtl"?-1:1;this.setColumnWidth(session.columnId,session.startWidth+(event.clientX-session.startClientX)*direction,!0,!1),session.moved=!0}takeResizeSession(event){const session=this.resizeSession;if(!(!session||event.pointerId!==session.pointerId)){this.resizeSession=void 0;try{event.currentTarget.releasePointerCapture?.(event.pointerId)}catch{}return session}}restoreResizeSession(session,emit){const next=new Map(this.columnWidths);session.initialStateWidth===void 0?next.delete(session.columnId):next.set(session.columnId,session.initialStateWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width:session.startWidth,finished:!1}))}onResizeEnd(event){const session=this.takeResizeSession(event);if(!session)return;if(!this.columnCanResize(session.columnId)){session.moved&&this.restoreResizeSession(session,!0);return}const width=this.columnWidths.get(session.columnId)??session.startWidth;this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width,finished:!0}))}onResizeCancel(event){const session=this.takeResizeSession(event);!session||!session.moved||this.restoreResizeSession(session,!0)}onResizeKey(event,id){if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const logical=(event.key==="ArrowRight"?1:-1)*(this.effectiveDirection==="rtl"?-1:1),current=this.columnWidths.get(id)??this.estimatedColumnWidth(entry.column,id);this.setColumnWidth(id,current+logical*10,!0,!0),event.preventDefault()}onPageSizeChange(event){const control=valueControl(event.currentTarget);control&&(this.pageSize=finiteCount(Number(control.value)),this.page=0,this.emit("lr-page-change",Object.freeze({page:0,pageSize:this.safePageSize})))}focusCell(row,column){const rowLimit=Math.max(-1,this.displayItems.length-1),columnLimit=Math.max(0,this.visibleColumns.length-1);this.focusedRow=finiteInteger(row,this.focusedRow,-1,rowLimit),this.focusedColumn=finiteInteger(column,this.focusedColumn,0,columnLimit);let pendingScrollTop;if(this.focusedRow>=0){const selector=`[role="gridcell"][data-row-position="${this.focusedRow}"]`;if(!this.renderRoot.querySelector(selector)){const top=this.focusedRow*this.resolvedRowHeight;pendingScrollTop=top,this.bodyScrollTop=top,this.bodyElement&&(this.bodyElement.scrollTop=top)}}this.updateComplete.then(()=>{pendingScrollTop!==void 0&&this.bodyElement&&(this.bodyElement.scrollTop=pendingScrollTop),this.focus()})}onGridKeyDown(event,rowPosition,columnPosition,item,column,columnIdValue){const target=event.target;if(isElementValue(target)&&target!==event.currentTarget&&target.closest(INTERACTIVE_SELECTOR))return;const rtlMultiplier=this.effectiveDirection==="rtl"?-1:1;if(event.ctrlKey&&event.key.toLowerCase()==="a"&&this.selectionMode==="multiple"){this.selectCurrentPage(!0),event.preventDefault();return}if(event.ctrlKey&&event.key.toLowerCase()==="c"){this.copySelectedRows(),event.preventDefault();return}if(event.shiftKey&&event.key==="F10"&&item&&column&&columnIdValue){this.emitCellContextMenu(event,item,column,columnIdValue,rowPosition);return}const headerEntry=columnIdValue?this.orderedColumns.find(entry=>entry.id===columnIdValue):void 0;if(rowPosition<0&&columnIdValue&&headerEntry&&(this.reorderable||headerEntry.column.movable)&&event.shiftKey&&!event.altKey&&(event.key==="ArrowLeft"||event.key==="ArrowRight")){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.moveColumn(columnIdValue,delta,!0),event.preventDefault();return}if(!(rowPosition<0&&columnIdValue&&headerEntry&&(this.resizable||headerEntry.column.resizable)&&event.altKey&&(this.onResizeKey(event,columnIdValue),event.defaultPrevented))){if(event.key==="ArrowLeft"||event.key==="ArrowRight"){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.focusCell(rowPosition,columnPosition+delta),event.preventDefault()}else if(event.key==="ArrowUp")this.focusCell(rowPosition-1,columnPosition),event.preventDefault();else if(event.key==="ArrowDown")this.focusCell(rowPosition+1,columnPosition),event.preventDefault();else if(event.key==="Home")this.focusCell(event.ctrlKey?-1:rowPosition,0),event.preventDefault();else if(event.key==="End")this.focusCell(event.ctrlKey?this.displayItems.length-1:rowPosition,this.visibleColumns.length-1),event.preventDefault();else if(event.key==="PageUp"||event.key==="PageDown"){const delta=event.key==="PageDown"?this.safePageSize||10:-(this.safePageSize||10);this.focusCell(rowPosition+delta,columnPosition),event.preventDefault()}else if(event.key==="Enter")rowPosition<0&&columnIdValue?this.activateSort(columnIdValue,event.shiftKey):item&&column&&columnIdValue&&this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index:rowPosition})),event.preventDefault();else if(event.key===" "&&item){const selected=!arrayHasKey(this.selectedKeys,item.key);this.setRowSelected(item,selected,event),event.preventDefault()}}}setGroupSelected(group,selected){const eligible=group.rows.filter(row=>this.rowIsSelectable(row)),sourceIndexes=this.sourceIndexMap(),groupKeys=eligible.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)});let next=this.selectedKeys.filter(key=>!groupKeys.some(groupKey=>keysEqual(groupKey,key)));selected&&(next=[...next,...groupKeys]),this.selectedKeys=next,this.emitSelection()}userPinColumn(id,side){this.pinColumn(id,side),this.emit("lr-column-pin",Object.freeze({columnId:id,side}))}userToggleColumn(id,visible){this.toggleColumn(id,visible),this.emit("lr-column-visibility-change",Object.freeze({columnId:id,visible}))}renderToolbar(){return!this.withSearch&&!this.withColumnsMenu?nothing:html`
2
2
  <div part="toolbar">
3
3
  ${this.withSearch?html`
4
4
  <input
@@ -128,7 +128,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
128
128
  part="header-cell"
129
129
  role="columnheader"
130
130
  aria-colindex=${position+1+selectionOffset}
131
- aria-sort=${sorting.state?direction:nothing}
131
+ aria-sort=${sortable?sorting.state?direction:"none":nothing}
132
132
  tabindex=${this.focusedRow<0&&this.focusedColumn===position?"0":"-1"}
133
133
  data-focus-cell
134
134
  data-column-id=${id}
@@ -457,7 +457,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
457
457
  >
458
458
  </button>
459
459
  </nav>
460
- `}render(){const accessibleName=this.getAttribute("aria-label")||this.label||void 0,detailCount=this.rowDetail?this.displayItems.filter(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)).length:0,rowCount=Math.max(1,this.displayItems.length+detailCount)+1,columnCount=Math.max(1,this.visibleColumns.length+(this.selectionEnabled?1:0)),role=this.childRows||normalizedGroupBy(this.groupBy).length>0?"treegrid":"grid",treeProjection=this.sourceProjection();return html`
460
+ `}render(){const accessibleName=hostAriaLabel(this)??(this.label||void 0),detailCount=this.rowDetail?this.displayItems.filter(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)).length:0,rowCount=Math.max(1,this.displayItems.length+detailCount)+1,columnCount=Math.max(1,this.visibleColumns.length+(this.selectionEnabled?1:0)),role=this.childRows||normalizedGroupBy(this.groupBy).length>0?"treegrid":"grid",treeProjection=this.sourceProjection();return html`
461
461
  <div part="data-grid">
462
462
  ${this.renderToolbar()}
463
463
  <div
@@ -29,15 +29,6 @@ import{css}from"lit";const styles=css`
29
29
  color: var(--text-color, var(--_lr-data-grid-text-color));
30
30
  }
31
31
 
32
- /* Wires the size density ladder into the values above. The "m" tier is the :host block's own
33
- default, so it is intentionally absent here -- these rules only override the non-default
34
- tiers, leaving "m" byte-for-byte what it always rendered.
35
-
36
- Deliberately NOT sourced from the shared sizes stylesheet's --lr-form-control-height /
37
- --lr-form-control-padding-* -- that ladder is tuned for single-line form controls and its "m"
38
- tier (2.5rem) sits BELOW this component's own "m" row-height (3.5rem), so borrowing it verbatim
39
- would make "l" (3rem) render shorter than the default row, inverting the ladder. Each tier
40
- below instead scales this component's own row-height/cell-padding baseline directly. */
41
32
  :host([size="xs"]) {
42
33
  --_lr-data-grid-cell-padding: var(--lr-space-xs);
43
34
  --_lr-data-grid-header-row-height: var(--lr-size-2rem);
@@ -114,8 +105,6 @@ import{css}from"lit";const styles=css`
114
105
  color: var(--lr-color-text-quiet);
115
106
  }
116
107
 
117
- /* Search decorations belong to WebKit's native chrome. Reset them unconditionally in both
118
- entry points so the component owns the control palette on Safari as well as Chromium. */
119
108
  [part="search"]::-webkit-search-cancel-button,
120
109
  [part="search"]::-webkit-search-decoration,
121
110
  [part="filter-panel"] input[type="search"]::-webkit-search-cancel-button,
@@ -310,9 +299,6 @@ import{css}from"lit";const styles=css`
310
299
  );
311
300
  }
312
301
 
313
- /* MUST stay after the selected-row rule above: both are (0,2,0), so source order alone decides,
314
- and the selected row is the one a user is most likely to hover next -- put this before and the
315
- single most common hover in a selectable grid would be the one hover with no feedback. */
316
302
  [part~="row"]:hover {
317
303
  background: var(
318
304
  --row-hover-background,
@@ -320,9 +306,6 @@ import{css}from"lit";const styles=css`
320
306
  );
321
307
  }
322
308
 
323
- /* MUST stay after the selected-row rule above: both are (0,2,0), so source order alone decides,
324
- and the selected row is the one a user presses to DEselect -- put this first and the single
325
- most common press in a selectable grid would be the one press with no feedback. */
326
309
  [part~="row"]:active {
327
310
  background: color-mix(
328
311
  in srgb,
@@ -595,16 +578,11 @@ import{css}from"lit";const styles=css`
595
578
  line-height: var(--lr-line-height-none);
596
579
  }
597
580
 
598
- /* The two chevrons of an edge button overlap slightly so they read as one doubled glyph rather
599
- than two separate arrows -- matches lr-pagination's identical first/last treatment. */
600
581
  [part="first-icon"] svg + svg,
601
582
  [part="last-icon"] svg + svg {
602
583
  margin-inline-start: var(--lr-size-neg-4px);
603
584
  }
604
585
 
605
- /* chevronIcon() points right by default, so 'next'/'last' render unrotated and
606
- 'first'/'previous' rotate to point left -- then both pairs flip under RTL, exactly like
607
- lr-pagination's first/previous/next/last icons. */
608
586
  [part="first-icon"],
609
587
  [part="previous-icon"] {
610
588
  transform: rotate(180deg);
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getDateTimeFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{styles}from"./document-library.styles.js";import{LYRA_DEFAULT_documentLibraryClearSelection,LYRA_DEFAULT_documentLibraryEmptyHeading,LYRA_DEFAULT_documentLibraryFilterByTag,LYRA_DEFAULT_documentLibraryFreshnessAging,LYRA_DEFAULT_documentLibraryFreshnessColumn,LYRA_DEFAULT_documentLibraryFreshnessFresh,LYRA_DEFAULT_documentLibraryFreshnessStale,LYRA_DEFAULT_documentLibraryLabel,LYRA_DEFAULT_documentLibraryNameColumn,LYRA_DEFAULT_documentLibraryNoMatchesHeading,LYRA_DEFAULT_documentLibraryOwnerColumn,LYRA_DEFAULT_documentLibrarySearchPlaceholder,LYRA_DEFAULT_documentLibrarySelectAll,LYRA_DEFAULT_documentLibrarySelectColumn,LYRA_DEFAULT_documentLibrarySelectDocument,LYRA_DEFAULT_documentLibrarySelectedCount,LYRA_DEFAULT_documentLibraryTagsColumn,LYRA_DEFAULT_documentLibraryTypeColumn,LYRA_DEFAULT_documentLibraryUpdatedColumn,LYRA_DEFAULT_documentLibraryVersionColumn}from"../../../internal/default-strings.generated.js";const FRESHNESS_RANK={fresh:0,aging:1,stale:2},MAX_LIBRARY_COLLECTION_ENTRIES=1e4,FRESHNESS_TONE={fresh:"success",aging:"warning",stale:"danger"};class LyraDocumentLibrary extends LyraElement{constructor(){super(...arguments),this._documents=Object.freeze([]),this._selectedDocumentIds=Object.freeze([]),this._tagFilter=Object.freeze([]),this.sortKey="name",this.sortDir="asc",this.searchTerm="",this.loading=!1,this.isMounting=!0,this.defaultFilter=(document,query)=>{const locale=this.effectiveLocale;return[document.name,document.owner??"",...document.tags??[]].some(value=>value.toLocaleLowerCase(locale).includes(query))},this.compareDocuments=(a,b)=>{const locale=this.effectiveLocale,dir=this.sortDir==="asc"?1:-1;let result=0;switch(this.sortKey){case"name":result=a.name.localeCompare(b.name,locale,{numeric:!0});break;case"version":result=(a.version??"").localeCompare(b.version??"",locale,{numeric:!0});break;case"owner":result=(a.owner??"").localeCompare(b.owner??"",locale,{numeric:!0});break;case"freshness":result=(a.freshness?FRESHNESS_RANK[a.freshness]:3)-(b.freshness?FRESHNESS_RANK[b.freshness]:3);break;case"updatedAt":result=(this.normalizeDate(a.updatedAt)?.getTime()??0)-(this.normalizeDate(b.updatedAt)?.getTime()??0);break}return result*dir},this.onSearchInput=event=>{event.stopPropagation(),this.searchTerm=event.detail.value,this.emitFilterChange()},this.onTagFilterChange=event=>{event.stopPropagation();const combobox=event.target;this.tagFilter=Array.isArray(combobox.value)?combobox.value:[],this.emitFilterChange()},this.onTableSortRequest=event=>{if(event.stopPropagation(),!this.isSortKey(event.detail.sortKey)){event.preventDefault();return}const detail=Object.freeze({phase:"request",sortKey:event.detail.sortKey,sortDir:event.detail.sortDir});this.emit("lr-sort-request",detail,{cancelable:!0}).defaultPrevented&&event.preventDefault()},this.onTableSortCommit=event=>{event.stopPropagation(),this.isSortKey(event.detail.sortKey)&&(this.sortKey=event.detail.sortKey,this.sortDir=event.detail.sortDir,this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:this.sortKey,sortDir:this.sortDir})))},this.stopOwnedEvent=event=>{event.stopPropagation()},this.onTableSelectionChange=event=>{event.stopPropagation();const table=event.currentTarget;table.selectedRowKeys=new Set(this.selectedDocumentIds)},this.clearSelection=()=>{this.setSelected([])}}static{this.defaultStrings={...super.defaultStrings,documentLibraryClearSelection:LYRA_DEFAULT_documentLibraryClearSelection,documentLibraryEmptyHeading:LYRA_DEFAULT_documentLibraryEmptyHeading,documentLibraryFilterByTag:LYRA_DEFAULT_documentLibraryFilterByTag,documentLibraryFreshnessAging:LYRA_DEFAULT_documentLibraryFreshnessAging,documentLibraryFreshnessColumn:LYRA_DEFAULT_documentLibraryFreshnessColumn,documentLibraryFreshnessFresh:LYRA_DEFAULT_documentLibraryFreshnessFresh,documentLibraryFreshnessStale:LYRA_DEFAULT_documentLibraryFreshnessStale,documentLibraryLabel:LYRA_DEFAULT_documentLibraryLabel,documentLibraryNameColumn:LYRA_DEFAULT_documentLibraryNameColumn,documentLibraryNoMatchesHeading:LYRA_DEFAULT_documentLibraryNoMatchesHeading,documentLibraryOwnerColumn:LYRA_DEFAULT_documentLibraryOwnerColumn,documentLibrarySearchPlaceholder:LYRA_DEFAULT_documentLibrarySearchPlaceholder,documentLibrarySelectAll:LYRA_DEFAULT_documentLibrarySelectAll,documentLibrarySelectColumn:LYRA_DEFAULT_documentLibrarySelectColumn,documentLibrarySelectDocument:LYRA_DEFAULT_documentLibrarySelectDocument,documentLibrarySelectedCount:LYRA_DEFAULT_documentLibrarySelectedCount,documentLibraryTagsColumn:LYRA_DEFAULT_documentLibraryTagsColumn,documentLibraryTypeColumn:LYRA_DEFAULT_documentLibraryTypeColumn,documentLibraryUpdatedColumn:LYRA_DEFAULT_documentLibraryUpdatedColumn,documentLibraryVersionColumn:LYRA_DEFAULT_documentLibraryVersionColumn}}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-filter-change","lr-selection-change"])}get documents(){return this.snapshotDocuments(this._documents)}set documents(value){const previous=this._documents;this._documents=this.snapshotDocuments(Array.isArray(value)?value:[]),this.requestUpdate("documents",previous)}get selectedDocumentIds(){return this._selectedDocumentIds}set selectedDocumentIds(value){const previous=this._selectedDocumentIds;this._selectedDocumentIds=this.snapshotIds(Array.isArray(value)?value:[]),this.requestUpdate("selectedDocumentIds",previous)}get tagFilter(){return this._tagFilter}set tagFilter(value){const previous=this._tagFilter;this._tagFilter=this.snapshotIds(Array.isArray(value)?value:[]),this.requestUpdate("tagFilter",previous)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink()}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}snapshotDocuments(documents){const snapshot=[],seen=new Set;for(const document of documents.slice(0,MAX_LIBRARY_COLLECTION_ENTRIES))try{const id=document?.id;if(typeof id!="string"||id.trim().length===0||seen.has(id))continue;const updatedAt=document.updatedAt instanceof Date?new Date(document.updatedAt.getTime()):document.updatedAt,tags=document.tags===void 0?void 0:Object.freeze(document.tags.slice(0,MAX_LIBRARY_COLLECTION_ENTRIES)),retained=Object.freeze({...document,id,updatedAt,tags});seen.add(id),snapshot.push(retained)}catch{}return Object.freeze(snapshot)}snapshotIds(ids){const snapshot=[],seen=new Set;try{for(const id of ids)if(!seen.has(id)&&(seen.add(id),snapshot.push(id),snapshot.length>=MAX_LIBRARY_COLLECTION_ENTRIES))break}catch{}return Object.freeze(snapshot)}willUpdate(changed){if(super.willUpdate(changed),(changed.has("documents")||changed.has("selectedDocumentIds"))&&this.selectedDocumentIds.length>0){const existing=new Set(this._documents.map(doc=>doc.id)),normalized=this.snapshotIds(this.selectedDocumentIds.filter(id=>existing.has(id)));(normalized.length!==this.selectedDocumentIds.length||normalized.some((id,index)=>id!==this.selectedDocumentIds[index]))&&(this.selectedDocumentIds=normalized)}if((changed.has("documents")||changed.has("tagFilter"))&&this.tagFilter.length>0){const availableTags=new Set(this._documents.flatMap(document=>document.tags??[])),normalized=this.snapshotIds(this.tagFilter.filter(tag=>availableTags.has(tag)));(normalized.length!==this.tagFilter.length||normalized.some((tag,index)=>tag!==this.tagFilter[index]))&&(this.tagFilter=normalized)}}updated(changed){super.updated(changed),!this.isMounting&&changed.has("selectedDocumentIds")&&this.announcementSink?.announce(this.selectionCountText()),this.isMounting=!1}selectionCountText(){return this.localize("documentLibrarySelectedCount",void 0,{count:getNumberFormat(this.effectiveLocale).format(this.selectedDocumentIds.length)})}normalizeDate(value){if(value===void 0)return;const date=value instanceof Date?value:new Date(value);return Number.isNaN(date.getTime())?void 0:date}matchesTagFilter(document){if(this.tagFilter.length===0)return!0;const tags=new Set(document.tags??[]);return this.tagFilter.every(tag=>tags.has(tag))}get visibleDocuments(){const query=this.searchTerm.trim().toLocaleLowerCase(this.effectiveLocale),matchFn=this.filter??this.defaultFilter;return[...this._documents.filter(document=>(query===""||matchFn(document,query))&&this.matchesTagFilter(document))].sort(this.compareDocuments)}get allTags(){const tags=new Set;for(const document of this._documents)for(const tag of document.tags??[])tags.add(tag);return[...tags].sort((a,b)=>a.localeCompare(b,this.effectiveLocale))}emitFilterChange(){const tags=Object.freeze([...this.tagFilter]);this.emit("lr-filter-change",Object.freeze({searchTerm:this.searchTerm,tags,matchCount:this.visibleDocuments.length}))}isSortKey(value){return value==="name"||value==="version"||value==="owner"||value==="freshness"||value==="updatedAt"}openDocument(document){this.emit("lr-open",Object.freeze({documentId:document.id}))}setSelected(ids){this.selectedDocumentIds=[...ids];const eventIds=Object.freeze([...this.selectedDocumentIds]);this.emit("lr-selection-change",Object.freeze({documentIds:eventIds}))}toggleSelection(document,checked){const next=new Set(this.selectedDocumentIds);checked?next.add(document.id):next.delete(document.id),this.setSelected(next)}toggleSelectAll(checked,visible){const next=new Set(this.selectedDocumentIds);for(const document of visible)checked?next.add(document.id):next.delete(document.id);this.setSelected(next)}freshnessLabel(freshness){switch(freshness){case"fresh":return this.localize("documentLibraryFreshnessFresh");case"aging":return this.localize("documentLibraryFreshnessAging");case"stale":return this.localize("documentLibraryFreshnessStale")}}renderSelectAllCheckbox(visible){const allSelected=visible.length>0&&visible.every(document=>this.selectedDocumentIds.includes(document.id)),someSelected=!allSelected&&visible.some(document=>this.selectedDocumentIds.includes(document.id));return html`<lr-checkbox
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{getDateTimeFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{styles}from"./document-library.styles.js";import{LYRA_DEFAULT_documentLibraryClearSelection,LYRA_DEFAULT_documentLibraryEmptyHeading,LYRA_DEFAULT_documentLibraryFilterByTag,LYRA_DEFAULT_documentLibraryFreshnessAging,LYRA_DEFAULT_documentLibraryFreshnessColumn,LYRA_DEFAULT_documentLibraryFreshnessFresh,LYRA_DEFAULT_documentLibraryFreshnessStale,LYRA_DEFAULT_documentLibraryLabel,LYRA_DEFAULT_documentLibraryNameColumn,LYRA_DEFAULT_documentLibraryNoMatchesHeading,LYRA_DEFAULT_documentLibraryOwnerColumn,LYRA_DEFAULT_documentLibrarySearchPlaceholder,LYRA_DEFAULT_documentLibrarySelectAll,LYRA_DEFAULT_documentLibrarySelectColumn,LYRA_DEFAULT_documentLibrarySelectDocument,LYRA_DEFAULT_documentLibrarySelectedCount,LYRA_DEFAULT_documentLibraryTagsColumn,LYRA_DEFAULT_documentLibraryTypeColumn,LYRA_DEFAULT_documentLibraryUpdatedColumn,LYRA_DEFAULT_documentLibraryVersionColumn}from"../../../internal/default-strings.generated.js";const FRESHNESS_RANK={fresh:0,aging:1,stale:2},MAX_LIBRARY_COLLECTION_ENTRIES=1e4,FRESHNESS_TONE={fresh:"success",aging:"warning",stale:"danger"};class LyraDocumentLibrary extends LyraElement{constructor(){super(...arguments),this._documents=Object.freeze([]),this._selectedDocumentIds=Object.freeze([]),this._tagFilter=Object.freeze([]),this.sortKey="name",this.sortDir="asc",this.searchTerm="",this.loading=!1,this.isMounting=!0,this.defaultFilter=(document,query)=>{const locale=this.effectiveLocale;return[document.name,document.owner??"",...document.tags??[]].some(value=>value.toLocaleLowerCase(locale).includes(query))},this.compareDocuments=(a,b)=>{const locale=this.effectiveLocale,dir=this.sortDir==="asc"?1:-1;let result=0;switch(this.sortKey){case"name":result=a.name.localeCompare(b.name,locale,{numeric:!0});break;case"version":result=(a.version??"").localeCompare(b.version??"",locale,{numeric:!0});break;case"owner":result=(a.owner??"").localeCompare(b.owner??"",locale,{numeric:!0});break;case"freshness":result=(a.freshness?FRESHNESS_RANK[a.freshness]:3)-(b.freshness?FRESHNESS_RANK[b.freshness]:3);break;case"updatedAt":result=(this.normalizeDate(a.updatedAt)?.getTime()??0)-(this.normalizeDate(b.updatedAt)?.getTime()??0);break}return result*dir},this.onSearchInput=event=>{event.stopPropagation(),this.searchTerm=event.detail.value,this.emitFilterChange()},this.onTagFilterChange=event=>{event.stopPropagation();const combobox=event.target;this.tagFilter=Array.isArray(combobox.value)?combobox.value:[],this.emitFilterChange()},this.onTableSortRequest=event=>{if(event.stopPropagation(),!this.isSortKey(event.detail.sortKey)){event.preventDefault();return}const detail=Object.freeze({phase:"request",sortKey:event.detail.sortKey,sortDir:event.detail.sortDir});this.emit("lr-sort-request",detail,{cancelable:!0}).defaultPrevented&&event.preventDefault()},this.onTableSortCommit=event=>{event.stopPropagation(),this.isSortKey(event.detail.sortKey)&&(this.sortKey=event.detail.sortKey,this.sortDir=event.detail.sortDir,this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:this.sortKey,sortDir:this.sortDir})))},this.stopOwnedEvent=event=>{event.stopPropagation()},this.onTableSelectionChange=event=>{event.stopPropagation();const table=event.currentTarget;table.selectedRowKeys=new Set(this.selectedDocumentIds)},this.clearSelection=()=>{this.setSelected([])}}static{this.defaultStrings={...super.defaultStrings,documentLibraryClearSelection:LYRA_DEFAULT_documentLibraryClearSelection,documentLibraryEmptyHeading:LYRA_DEFAULT_documentLibraryEmptyHeading,documentLibraryFilterByTag:LYRA_DEFAULT_documentLibraryFilterByTag,documentLibraryFreshnessAging:LYRA_DEFAULT_documentLibraryFreshnessAging,documentLibraryFreshnessColumn:LYRA_DEFAULT_documentLibraryFreshnessColumn,documentLibraryFreshnessFresh:LYRA_DEFAULT_documentLibraryFreshnessFresh,documentLibraryFreshnessStale:LYRA_DEFAULT_documentLibraryFreshnessStale,documentLibraryLabel:LYRA_DEFAULT_documentLibraryLabel,documentLibraryNameColumn:LYRA_DEFAULT_documentLibraryNameColumn,documentLibraryNoMatchesHeading:LYRA_DEFAULT_documentLibraryNoMatchesHeading,documentLibraryOwnerColumn:LYRA_DEFAULT_documentLibraryOwnerColumn,documentLibrarySearchPlaceholder:LYRA_DEFAULT_documentLibrarySearchPlaceholder,documentLibrarySelectAll:LYRA_DEFAULT_documentLibrarySelectAll,documentLibrarySelectColumn:LYRA_DEFAULT_documentLibrarySelectColumn,documentLibrarySelectDocument:LYRA_DEFAULT_documentLibrarySelectDocument,documentLibrarySelectedCount:LYRA_DEFAULT_documentLibrarySelectedCount,documentLibraryTagsColumn:LYRA_DEFAULT_documentLibraryTagsColumn,documentLibraryTypeColumn:LYRA_DEFAULT_documentLibraryTypeColumn,documentLibraryUpdatedColumn:LYRA_DEFAULT_documentLibraryUpdatedColumn,documentLibraryVersionColumn:LYRA_DEFAULT_documentLibraryVersionColumn}}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-filter-change","lr-selection-change"])}get documents(){return this.snapshotDocuments(this._documents)}set documents(value){const previous=this._documents;this._documents=this.snapshotDocuments(Array.isArray(value)?value:[]),this.requestUpdate("documents",previous)}get selectedDocumentIds(){return this._selectedDocumentIds}set selectedDocumentIds(value){const previous=this._selectedDocumentIds;this._selectedDocumentIds=this.snapshotIds(Array.isArray(value)?value:[]),this.requestUpdate("selectedDocumentIds",previous)}get tagFilter(){return this._tagFilter}set tagFilter(value){const previous=this._tagFilter;this._tagFilter=this.snapshotIds(Array.isArray(value)?value:[]),this.requestUpdate("tagFilter",previous)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink()}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}snapshotDocuments(documents){const snapshot=[],seen=new Set;for(const document of documents.slice(0,MAX_LIBRARY_COLLECTION_ENTRIES))try{const id=document?.id;if(typeof id!="string"||id.trim().length===0||seen.has(id))continue;const updatedAt=document.updatedAt instanceof Date?new Date(document.updatedAt.getTime()):document.updatedAt,tags=document.tags===void 0?void 0:Object.freeze(document.tags.slice(0,MAX_LIBRARY_COLLECTION_ENTRIES)),retained=Object.freeze({...document,id,updatedAt,tags});seen.add(id),snapshot.push(retained)}catch{}return Object.freeze(snapshot)}snapshotIds(ids){const snapshot=[],seen=new Set;try{for(const id of ids)if(!seen.has(id)&&(seen.add(id),snapshot.push(id),snapshot.length>=MAX_LIBRARY_COLLECTION_ENTRIES))break}catch{}return Object.freeze(snapshot)}willUpdate(changed){if(super.willUpdate(changed),(changed.has("documents")||changed.has("selectedDocumentIds"))&&this.selectedDocumentIds.length>0){const existing=new Set(this._documents.map(doc=>doc.id)),normalized=this.snapshotIds(this.selectedDocumentIds.filter(id=>existing.has(id)));(normalized.length!==this.selectedDocumentIds.length||normalized.some((id,index)=>id!==this.selectedDocumentIds[index]))&&(this.selectedDocumentIds=normalized)}if((changed.has("documents")||changed.has("tagFilter"))&&this.tagFilter.length>0){const availableTags=new Set(this._documents.flatMap(document=>document.tags??[])),normalized=this.snapshotIds(this.tagFilter.filter(tag=>availableTags.has(tag)));(normalized.length!==this.tagFilter.length||normalized.some((tag,index)=>tag!==this.tagFilter[index]))&&(this.tagFilter=normalized)}}updated(changed){super.updated(changed),!this.isMounting&&changed.has("selectedDocumentIds")&&this.announcementSink?.announce(this.selectionCountText()),this.isMounting=!1}selectionCountText(){return this.localize("documentLibrarySelectedCount",void 0,{count:getNumberFormat(this.effectiveLocale).format(this.selectedDocumentIds.length)})}normalizeDate(value){if(value===void 0)return;const date=value instanceof Date?value:new Date(value);return Number.isNaN(date.getTime())?void 0:date}matchesTagFilter(document){if(this.tagFilter.length===0)return!0;const tags=new Set(document.tags??[]);return this.tagFilter.every(tag=>tags.has(tag))}get visibleDocuments(){const query=this.searchTerm.trim().toLocaleLowerCase(this.effectiveLocale),matchFn=this.filter??this.defaultFilter;return[...this._documents.filter(document=>(query===""||matchFn(document,query))&&this.matchesTagFilter(document))].sort(this.compareDocuments)}get allTags(){const tags=new Set;for(const document of this._documents)for(const tag of document.tags??[])tags.add(tag);return[...tags].sort((a,b)=>a.localeCompare(b,this.effectiveLocale))}emitFilterChange(){const tags=Object.freeze([...this.tagFilter]);this.emit("lr-filter-change",Object.freeze({searchTerm:this.searchTerm,tags,matchCount:this.visibleDocuments.length}))}isSortKey(value){return value==="name"||value==="version"||value==="owner"||value==="freshness"||value==="updatedAt"}openDocument(document){this.emit("lr-open",Object.freeze({documentId:document.id}))}setSelected(ids){this.selectedDocumentIds=[...ids];const eventIds=Object.freeze([...this.selectedDocumentIds]);this.emit("lr-selection-change",Object.freeze({documentIds:eventIds}))}toggleSelection(document,checked){const next=new Set(this.selectedDocumentIds);checked?next.add(document.id):next.delete(document.id),this.setSelected(next)}toggleSelectAll(checked,visible){const next=new Set(this.selectedDocumentIds);for(const document of visible)checked?next.add(document.id):next.delete(document.id);this.setSelected(next)}freshnessLabel(freshness){switch(freshness){case"fresh":return this.localize("documentLibraryFreshnessFresh");case"aging":return this.localize("documentLibraryFreshnessAging");case"stale":return this.localize("documentLibraryFreshnessStale")}}renderSelectAllCheckbox(visible){const allSelected=visible.length>0&&visible.every(document=>this.selectedDocumentIds.includes(document.id)),someSelected=!allSelected&&visible.some(document=>this.selectedDocumentIds.includes(document.id));return html`<lr-checkbox
2
2
  .checked=${allSelected}
3
3
  .indeterminate=${someSelected}
4
4
  aria-label=${this.localize("documentLibrarySelectAll")}
@@ -27,7 +27,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
27
27
  mime-type=${document.mimeType??""}
28
28
  name=${document.name}
29
29
  decorative
30
- ></lr-file-icon>`},{key:"name",label:this.localize("documentLibraryNameColumn"),sortable:!0,cell:document=>this.renderNameCell(document)},{key:"version",label:this.localize("documentLibraryVersionColumn"),sortable:!0,priority:"medium",cell:document=>document.version??""},{key:"owner",label:this.localize("documentLibraryOwnerColumn"),sortable:!0,priority:"medium",cell:document=>document.owner??""},{key:"tags",label:this.localize("documentLibraryTagsColumn"),priority:"low",cell:document=>this.renderTagsCell(document)},{key:"freshness",label:this.localize("documentLibraryFreshnessColumn"),sortable:!0,priority:"low",cell:document=>this.renderFreshnessCell(document)},{key:"updatedAt",label:this.localize("documentLibraryUpdatedColumn"),sortable:!0,priority:"low",cell:document=>this.renderUpdatedCell(document)}]}render(){const label=this.getAttribute("aria-label")?.trim()||(this.label==null?this.localize("documentLibraryLabel"):this.label),visible=this.visibleDocuments,tags=this.allTags,emptyHeading=this._documents.length===0?this.localize("documentLibraryEmptyHeading"):this.localize("documentLibraryNoMatchesHeading");return html`
30
+ ></lr-file-icon>`},{key:"name",label:this.localize("documentLibraryNameColumn"),sortable:!0,cell:document=>this.renderNameCell(document)},{key:"version",label:this.localize("documentLibraryVersionColumn"),sortable:!0,priority:"medium",cell:document=>document.version??""},{key:"owner",label:this.localize("documentLibraryOwnerColumn"),sortable:!0,priority:"medium",cell:document=>document.owner??""},{key:"tags",label:this.localize("documentLibraryTagsColumn"),priority:"low",cell:document=>this.renderTagsCell(document)},{key:"freshness",label:this.localize("documentLibraryFreshnessColumn"),sortable:!0,priority:"low",cell:document=>this.renderFreshnessCell(document)},{key:"updatedAt",label:this.localize("documentLibraryUpdatedColumn"),sortable:!0,priority:"low",cell:document=>this.renderUpdatedCell(document)}]}render(){const label=hostAriaLabel(this)?.trim()??(this.label==null?this.localize("documentLibraryLabel"):this.label),visible=this.visibleDocuments,tags=this.allTags,emptyHeading=this._documents.length===0?this.localize("documentLibraryEmptyHeading"):this.localize("documentLibraryNoMatchesHeading");return html`
31
31
  <div part="base" role="region" aria-label=${label}>
32
32
  <div part="toolbar">
33
33
  <lr-input
@@ -49,10 +49,6 @@ import{css}from"lit";const styles=css`
49
49
  [part='clear-selection']:hover {
50
50
  text-decoration: underline;
51
51
  }
52
- /* Pressed deepens the link colour on top of the hovered underline: an underline alone cannot get
53
- "more underlined", so the press would otherwise be indistinguishable from the hover it starts
54
- from. The mix follows --lr-color-mix-partner (the text colour), so it darkens a light theme and
55
- lightens a dark one instead of always doing one of the two. */
56
52
  [part='clear-selection']:active {
57
53
  color: color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active));
58
54
  text-decoration: underline;
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{styles}from"./env-list.styles.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_envListCopy,LYRA_DEFAULT_envListHide,LYRA_DEFAULT_envListLabel,LYRA_DEFAULT_envListReveal,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_noData}from"../../../internal/default-strings.generated.js";const MASK="\u2022".repeat(8),MAX_ENV_ENTRIES=1e4;class LyraEnvList extends LyraElement{constructor(){super(...arguments),this._entries=[],this.revealable=!0,this.copyable=!0,this.revealed=new Map}static{this.defaultStrings={...super.defaultStrings,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed,envListCopy:LYRA_DEFAULT_envListCopy,envListHide:LYRA_DEFAULT_envListHide,envListLabel:LYRA_DEFAULT_envListLabel,envListReveal:LYRA_DEFAULT_envListReveal,envListValueHidden:LYRA_DEFAULT_envListValueHidden,noData:LYRA_DEFAULT_noData}}static{this.styles=[LyraElement.styles,styles,srOnly]}get entries(){return this._entries}set entries(value){const previous=this._entries,next=[],seen=new Set;if(Array.isArray(value))for(const candidate of value.slice(0,MAX_ENV_ENTRIES))try{if(!candidate||typeof candidate.name!="string"||typeof candidate.value!="string")continue;const name=candidate.name;if(name.trim().length===0||seen.has(name))continue;next.push(Object.freeze({name,value:candidate.value,...candidate.secret===void 0?{}:{secret:!!candidate.secret}})),seen.add(name)}catch{}this._entries=Object.freeze(next),this.requestUpdate("entries",previous)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink()}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}willUpdate(changed){if(super.willUpdate(changed),changed.has("revealable")&&!this.revealable&&this.revealed.size>0&&(this.revealed=new Map),changed.has("entries")){const previous=changed.get("entries")??[],next=new Map;this.entries.forEach((entry,index)=>{if(previous[index]?.name!==entry.name)return;const wasRevealed=this.revealed.get(entry.name);wasRevealed!==void 0&&next.set(entry.name,wasRevealed)}),this.revealed=next}}toggleReveal(envName){const isRevealed=!(this.revealed.get(envName)??!1),next=new Map(this.revealed);next.set(envName,isRevealed),this.revealed=next,this.emit("lr-reveal-change",Object.freeze({envName,revealed:isRevealed}))}async copy(entry){const text=entry.value,owner=this.isConnected?this.ownerDocument.defaultView:null,outcome=await writeClipboardText(owner,text);if(!(!this.isConnected||this.ownerDocument.defaultView!==owner)){if(outcome.ok){this.announcementSink?.announce(this.localize("copied")),this.emit("lr-copy",outcome);return}this.announcementSink?.announce(this.localize("copyFailed")),this.emit("lr-error"),this.emit("lr-copy-error",outcome)}}get accessibleLabel(){return this.getAttribute("aria-label")?.trim()||(this.label==null?this.localize("envListLabel"):this.label)}render(){return this.entries.length===0?html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{styles}from"./env-list.styles.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_envListCopy,LYRA_DEFAULT_envListHide,LYRA_DEFAULT_envListLabel,LYRA_DEFAULT_envListReveal,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_noData}from"../../../internal/default-strings.generated.js";const MASK="\u2022".repeat(8),MAX_ENV_ENTRIES=1e4;class LyraEnvList extends LyraElement{constructor(){super(...arguments),this._entries=[],this.revealable=!0,this.copyable=!0,this.revealed=new Map}static{this.defaultStrings={...super.defaultStrings,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed,envListCopy:LYRA_DEFAULT_envListCopy,envListHide:LYRA_DEFAULT_envListHide,envListLabel:LYRA_DEFAULT_envListLabel,envListReveal:LYRA_DEFAULT_envListReveal,envListValueHidden:LYRA_DEFAULT_envListValueHidden,noData:LYRA_DEFAULT_noData}}static{this.styles=[LyraElement.styles,styles,srOnly]}get entries(){return this._entries}set entries(value){const previous=this._entries,next=[],seen=new Set;if(Array.isArray(value))for(const candidate of value.slice(0,MAX_ENV_ENTRIES))try{if(!candidate||typeof candidate.name!="string"||typeof candidate.value!="string")continue;const name=candidate.name;if(name.trim().length===0||seen.has(name))continue;next.push(Object.freeze({name,value:candidate.value,...candidate.secret===void 0?{}:{secret:!!candidate.secret}})),seen.add(name)}catch{}this._entries=Object.freeze(next),this.requestUpdate("entries",previous)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink()}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}willUpdate(changed){if(super.willUpdate(changed),changed.has("revealable")&&!this.revealable&&this.revealed.size>0&&(this.revealed=new Map),changed.has("entries")){const previous=changed.get("entries")??[],next=new Map;this.entries.forEach((entry,index)=>{if(previous[index]?.name!==entry.name)return;const wasRevealed=this.revealed.get(entry.name);wasRevealed!==void 0&&next.set(entry.name,wasRevealed)}),this.revealed=next}}toggleReveal(envName){const isRevealed=!(this.revealed.get(envName)??!1),next=new Map(this.revealed);next.set(envName,isRevealed),this.revealed=next,this.emit("lr-reveal-change",Object.freeze({envName,revealed:isRevealed}))}async copy(entry){const text=entry.value,owner=this.isConnected?this.ownerDocument.defaultView:null,outcome=await writeClipboardText(owner,text);if(!(!this.isConnected||this.ownerDocument.defaultView!==owner)){if(outcome.ok){this.announcementSink?.announce(this.localize("copied")),this.emit("lr-copy",outcome);return}this.announcementSink?.announce(this.localize("copyFailed")),this.emit("lr-error"),this.emit("lr-copy-error",outcome)}}get accessibleLabel(){return hostAriaLabel(this)?.trim()??(this.label==null?this.localize("envListLabel"):this.label)}render(){return this.entries.length===0?html`
2
2
  <div part="base" data-empty role="group" aria-label=${this.accessibleLabel}>
3
3
  <lr-empty heading=${this.localize("noData")}></lr-empty>
4
4
  </div>
@@ -68,10 +68,13 @@ import{css}from"lit";const styles=css`
68
68
  background: var(--lr-env-list-reveal-active-bg, var(--lr-color-brand-quiet));
69
69
  border-color: var(--lr-env-list-reveal-active-border, var(--lr-color-brand));
70
70
  }
71
- /* MUST stay after the [aria-pressed='true'] rule above: both are (0,2,0), so source order alone
72
- decides, and a revealed button's toggled-on fill is the same brand-quiet the hover uses -- put
73
- this first and pressing the one button whose state you are about to flip would show nothing at
74
- all. Only the fill is claimed, so the toggled border colour still reads while pressed. */
71
+ [part='reveal-button']:where([aria-pressed='true']):hover {
72
+ background: color-mix(
73
+ in oklab,
74
+ var(--lr-env-list-reveal-active-bg, var(--lr-color-brand-quiet)),
75
+ var(--lr-color-mix-partner) var(--lr-color-mix-hover)
76
+ );
77
+ }
75
78
  [part='reveal-button']:active,
76
79
  [part='copy-button']:active {
77
80
  background: color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active));
@@ -29,6 +29,18 @@ export interface LyraFileTreeEventMap {
29
29
  * `<lr-file-tree>` — a file-explorer preset over `<lr-tree>` + `<lr-file-icon>`: path-keyed
30
30
  * nodes with git-status/diff-count badges, lazy directory loading, and select/open events.
31
31
  *
32
+ * **The composed `<lr-tree>`'s `reorderable`/`lr-reorder` capability is deliberately not
33
+ * forwarded.** The tree it renders is not a model this component owns: `treeItems` is derived
34
+ * from `nodes` on every render and keyed by filesystem path, so sibling order is whatever the
35
+ * host's own listing produced (name, type, git status), not an authored sequence a user can
36
+ * rearrange. `<lr-tree>`'s reorder is also strictly sibling-scoped — it never crosses a subtree
37
+ * boundary, precisely so a reorder can never become a reparent — which is the one file operation
38
+ * ("move this file into that directory") that would change a path and therefore mean something
39
+ * here. Forwarding it would have to invent a second, path-shaped event alongside
40
+ * `lr-file-select`/`lr-file-open`/`lr-load-children`, permanently, for a gesture whose result the
41
+ * host would have to discard. A consumer that genuinely needs orderable rows composes `<lr-tree>`
42
+ * directly, where the capability already lives.
43
+ *
32
44
  * @customElement lr-file-tree
33
45
  * @event lr-file-select - `detail: { filePath, node }` — a row was activated.
34
46
  * @event lr-file-open - `detail: { filePath, node }` — Enter/click on an already-selected file row
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./file-tree.styles.js";import{LyraTreeItem}from"../tree/tree-item.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_fileTreeDiffSummary,LYRA_DEFAULT_fileTreeLabel,LYRA_DEFAULT_gitStatusAdded,LYRA_DEFAULT_gitStatusConflicted,LYRA_DEFAULT_gitStatusDeleted,LYRA_DEFAULT_gitStatusIgnored,LYRA_DEFAULT_gitStatusModified,LYRA_DEFAULT_gitStatusRenamed,LYRA_DEFAULT_gitStatusUntracked,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const MAX_FILE_TREE_NODES=1e4,MAX_FILE_TREE_DEPTH=64,GIT_STATUSES=new Set(["added","modified","deleted","renamed","untracked","conflicted","ignored"]);function boundedArrayShape(value){try{if(!Array.isArray(value))return{isArray:!1,length:0};const descriptor=Object.getOwnPropertyDescriptor(value,"length"),length=descriptor&&"value"in descriptor?descriptor.value:0;return{isArray:!0,length:typeof length=="number"&&Number.isSafeInteger(length)&&length>=0?Math.min(length,MAX_FILE_TREE_NODES):0}}catch{return{isArray:!1,length:0}}}function normalizeFileTreeNodes(value){const rootShape=boundedArrayShape(value),roots=rootShape.isArray?value:[],drafts=[],rootDrafts=[],seenObjects=new WeakSet,seenPaths=new Set,stack=[{input:roots,output:rootDrafts,depth:0,index:0,length:rootShape.length}];let inspected=0;for(;stack.length>0&&drafts.length<MAX_FILE_TREE_NODES&&inspected<MAX_FILE_TREE_NODES;){const frame=stack[stack.length-1];if(frame.index>=frame.length){stack.pop();continue}const sourceIndex=frame.index++;inspected+=1;let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(frame.input,String(sourceIndex))}catch{continue}if(!descriptor||!("value"in descriptor))continue;const candidate=descriptor.value;if(!(typeof candidate!="object"||candidate===null||seenObjects.has(candidate))){seenObjects.add(candidate);try{const record=candidate,path=record.path;if(typeof path!="string"||path.trim().length===0||seenPaths.has(path))continue;seenPaths.add(path);const name=record.name,kind=record.kind,mimeType=record.mimeType,gitStatus=record.gitStatus,additions=record.additions,deletions=record.deletions,hasChildren=record.hasChildren,rawChildren=record.children,fields={path,...typeof name=="string"?{name}:{},...kind==="file"||kind==="directory"?{kind}:{},...typeof mimeType=="string"?{mimeType}:{},...typeof gitStatus=="string"&&GIT_STATUSES.has(gitStatus)?{gitStatus}:{},...additions===void 0?{}:{additions:finiteCount(typeof additions=="number"?additions:0)},...deletions===void 0?{}:{deletions:finiteCount(typeof deletions=="number"?deletions:0)},...hasChildren===void 0?{}:{hasChildren:!!hasChildren}},childShape=boundedArrayShape(rawChildren),childrenProvided=childShape.isArray,draft={fields,children:[],childrenProvided};frame.output.push(draft),drafts.push(draft),childrenProvided&&frame.depth<MAX_FILE_TREE_DEPTH&&stack.push({input:rawChildren,output:draft.children,depth:frame.depth+1,index:0,length:childShape.length})}catch{}}}for(let index=drafts.length-1;index>=0;index--){const draft=drafts[index];draft.normalized=Object.freeze({...draft.fields,...draft.childrenProvided?{children:Object.freeze(draft.children.map(child=>child.normalized))}:{}})}return Object.freeze(rootDrafts.map(draft=>draft.normalized))}const GIT_STATUS_LETTER={added:"A",modified:"M",deleted:"D",renamed:"R",untracked:"U",conflicted:"C",ignored:"!"},GIT_STATUS_TONE={added:"success",untracked:"success",modified:"brand",renamed:"brand",deleted:"danger",conflicted:"danger",ignored:"neutral"},GIT_STATUS_KEY={added:"gitStatusAdded",modified:"gitStatusModified",deleted:"gitStatusDeleted",renamed:"gitStatusRenamed",untracked:"gitStatusUntracked",conflicted:"gitStatusConflicted",ignored:"gitStatusIgnored"};function baseName(path){const segments=path.split("/").filter(Boolean);return segments[segments.length-1]??path}function isDirectory(node){return node.kind==="directory"||node.children!==void 0||node.hasChildren===!0}function isLazyUnloaded(node){return isDirectory(node)&&node.hasChildren===!0&&node.children===void 0}class LyraFileTree extends LyraElement{constructor(){super(...arguments),this._nodes=[],this.selectedPath=null,this.nodesByPath=new Map,this.parentPathByPath=new Map,this.onNodeSelect=e=>{e.stopPropagation();const{nodeId}=e.detail,node=this.nodesByPath.get(nodeId);if(!node)return;const wasSelected=this.selectedPath===nodeId;this.selectedPath=nodeId,this.emit("lr-file-select",Object.freeze({filePath:nodeId,node})),!isDirectory(node)&&wasSelected&&this.emit("lr-file-open",Object.freeze({filePath:nodeId,node}))},this.onNodeToggle=e=>{e.stopPropagation();const{nodeId,expanded}=e.detail;if(!expanded)return;const node=this.nodesByPath.get(nodeId);node&&isLazyUnloaded(node)&&this.emit("lr-load-children",Object.freeze({filePath:nodeId}))}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,fileTreeDiffSummary:LYRA_DEFAULT_fileTreeDiffSummary,fileTreeLabel:LYRA_DEFAULT_fileTreeLabel,gitStatusAdded:LYRA_DEFAULT_gitStatusAdded,gitStatusConflicted:LYRA_DEFAULT_gitStatusConflicted,gitStatusDeleted:LYRA_DEFAULT_gitStatusDeleted,gitStatusIgnored:LYRA_DEFAULT_gitStatusIgnored,gitStatusModified:LYRA_DEFAULT_gitStatusModified,gitStatusRenamed:LYRA_DEFAULT_gitStatusRenamed,gitStatusUntracked:LYRA_DEFAULT_gitStatusUntracked,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get nodes(){return this._nodes}set nodes(value){const previous=this._nodes;this._nodes=normalizeFileTreeNodes(value),this.requestUpdate("nodes",previous)}willUpdate(changed){if(super.willUpdate(changed),changed.has("nodes")){this.nodesByPath=new Map,this.parentPathByPath=new Map;const stack=[...this.nodes].reverse().map(node=>({node,parentPath:void 0}));for(;stack.length>0;){const{node,parentPath}=stack.pop();if(this.nodesByPath.set(node.path,node),parentPath!==void 0&&this.parentPathByPath.set(node.path,parentPath),node.children)for(let index=node.children.length-1;index>=0;index--)stack.push({node:node.children[index],parentPath:node.path})}}}toTreeItem(node){const badges=[];node.gitStatus&&badges.push({text:GIT_STATUS_LETTER[node.gitStatus],tone:GIT_STATUS_TONE[node.gitStatus],label:this.localize(GIT_STATUS_KEY[node.gitStatus])});const description=node.additions!==void 0||node.deletions!==void 0?this.localize("fileTreeDiffSummary",void 0,{additions:getNumberFormat(this.effectiveLocale).format(node.additions??0),deletions:getNumberFormat(this.effectiveLocale).format(node.deletions??0)}):void 0;let children;return isLazyUnloaded(node)?children=[{id:`${node.path} loading`,label:this.localize("loading"),disabled:!0}]:node.children&&(children=node.children.map(c=>this.toTreeItem(c))),{id:node.path,label:node.name??baseName(node.path),selected:this.selectedPath===node.path,children,badges:badges.length>0?badges:void 0,description,icon:isDirectory(node)?void 0:html`<lr-file-icon
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./file-tree.styles.js";import{LyraTreeItem}from"../tree/tree-item.class.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_fileTreeDiffSummary,LYRA_DEFAULT_fileTreeLabel,LYRA_DEFAULT_gitStatusAdded,LYRA_DEFAULT_gitStatusConflicted,LYRA_DEFAULT_gitStatusDeleted,LYRA_DEFAULT_gitStatusIgnored,LYRA_DEFAULT_gitStatusModified,LYRA_DEFAULT_gitStatusRenamed,LYRA_DEFAULT_gitStatusUntracked,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const MAX_FILE_TREE_NODES=1e4,MAX_FILE_TREE_DEPTH=64,GIT_STATUSES=new Set(["added","modified","deleted","renamed","untracked","conflicted","ignored"]);function boundedArrayShape(value){try{if(!Array.isArray(value))return{isArray:!1,length:0};const descriptor=Object.getOwnPropertyDescriptor(value,"length"),length=descriptor&&"value"in descriptor?descriptor.value:0;return{isArray:!0,length:typeof length=="number"&&Number.isSafeInteger(length)&&length>=0?Math.min(length,MAX_FILE_TREE_NODES):0}}catch{return{isArray:!1,length:0}}}function normalizeFileTreeNodes(value){const rootShape=boundedArrayShape(value),roots=rootShape.isArray?value:[],drafts=[],rootDrafts=[],seenObjects=new WeakSet,seenPaths=new Set,stack=[{input:roots,output:rootDrafts,depth:0,index:0,length:rootShape.length}];let inspected=0;for(;stack.length>0&&drafts.length<MAX_FILE_TREE_NODES&&inspected<MAX_FILE_TREE_NODES;){const frame=stack[stack.length-1];if(frame.index>=frame.length){stack.pop();continue}const sourceIndex=frame.index++;inspected+=1;let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(frame.input,String(sourceIndex))}catch{continue}if(!descriptor||!("value"in descriptor))continue;const candidate=descriptor.value;if(!(typeof candidate!="object"||candidate===null||seenObjects.has(candidate))){seenObjects.add(candidate);try{const record=candidate,path=record.path;if(typeof path!="string"||path.trim().length===0||seenPaths.has(path))continue;seenPaths.add(path);const name=record.name,kind=record.kind,mimeType=record.mimeType,gitStatus=record.gitStatus,additions=record.additions,deletions=record.deletions,hasChildren=record.hasChildren,rawChildren=record.children,fields={path,...typeof name=="string"?{name}:{},...kind==="file"||kind==="directory"?{kind}:{},...typeof mimeType=="string"?{mimeType}:{},...typeof gitStatus=="string"&&GIT_STATUSES.has(gitStatus)?{gitStatus}:{},...additions===void 0?{}:{additions:finiteCount(typeof additions=="number"?additions:0)},...deletions===void 0?{}:{deletions:finiteCount(typeof deletions=="number"?deletions:0)},...hasChildren===void 0?{}:{hasChildren:!!hasChildren}},childShape=boundedArrayShape(rawChildren),childrenProvided=childShape.isArray,draft={fields,children:[],childrenProvided};frame.output.push(draft),drafts.push(draft),childrenProvided&&frame.depth<MAX_FILE_TREE_DEPTH&&stack.push({input:rawChildren,output:draft.children,depth:frame.depth+1,index:0,length:childShape.length})}catch{}}}for(let index=drafts.length-1;index>=0;index--){const draft=drafts[index];draft.normalized=Object.freeze({...draft.fields,...draft.childrenProvided?{children:Object.freeze(draft.children.map(child=>child.normalized))}:{}})}return Object.freeze(rootDrafts.map(draft=>draft.normalized))}const GIT_STATUS_LETTER={added:"A",modified:"M",deleted:"D",renamed:"R",untracked:"U",conflicted:"C",ignored:"!"},GIT_STATUS_TONE={added:"success",untracked:"success",modified:"brand",renamed:"brand",deleted:"danger",conflicted:"danger",ignored:"neutral"},GIT_STATUS_KEY={added:"gitStatusAdded",modified:"gitStatusModified",deleted:"gitStatusDeleted",renamed:"gitStatusRenamed",untracked:"gitStatusUntracked",conflicted:"gitStatusConflicted",ignored:"gitStatusIgnored"};function baseName(path){const segments=path.split("/").filter(Boolean);return segments[segments.length-1]??path}function isDirectory(node){return node.kind==="directory"||node.children!==void 0||node.hasChildren===!0}function isLazyUnloaded(node){return isDirectory(node)&&node.hasChildren===!0&&node.children===void 0}class LyraFileTree extends LyraElement{constructor(){super(...arguments),this._nodes=[],this.selectedPath=null,this.nodesByPath=new Map,this.parentPathByPath=new Map,this.onNodeSelect=e=>{e.stopPropagation();const{nodeId}=e.detail,node=this.nodesByPath.get(nodeId);if(!node)return;const wasSelected=this.selectedPath===nodeId;this.selectedPath=nodeId,this.emit("lr-file-select",Object.freeze({filePath:nodeId,node})),!isDirectory(node)&&wasSelected&&this.emit("lr-file-open",Object.freeze({filePath:nodeId,node}))},this.onNodeToggle=e=>{e.stopPropagation();const{nodeId,expanded}=e.detail;if(!expanded)return;const node=this.nodesByPath.get(nodeId);node&&isLazyUnloaded(node)&&this.emit("lr-load-children",Object.freeze({filePath:nodeId}))}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,fileTreeDiffSummary:LYRA_DEFAULT_fileTreeDiffSummary,fileTreeLabel:LYRA_DEFAULT_fileTreeLabel,gitStatusAdded:LYRA_DEFAULT_gitStatusAdded,gitStatusConflicted:LYRA_DEFAULT_gitStatusConflicted,gitStatusDeleted:LYRA_DEFAULT_gitStatusDeleted,gitStatusIgnored:LYRA_DEFAULT_gitStatusIgnored,gitStatusModified:LYRA_DEFAULT_gitStatusModified,gitStatusRenamed:LYRA_DEFAULT_gitStatusRenamed,gitStatusUntracked:LYRA_DEFAULT_gitStatusUntracked,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get nodes(){return this._nodes}set nodes(value){const previous=this._nodes;this._nodes=normalizeFileTreeNodes(value),this.requestUpdate("nodes",previous)}willUpdate(changed){if(super.willUpdate(changed),changed.has("nodes")){this.nodesByPath=new Map,this.parentPathByPath=new Map;const stack=[...this.nodes].reverse().map(node=>({node,parentPath:void 0}));for(;stack.length>0;){const{node,parentPath}=stack.pop();if(this.nodesByPath.set(node.path,node),parentPath!==void 0&&this.parentPathByPath.set(node.path,parentPath),node.children)for(let index=node.children.length-1;index>=0;index--)stack.push({node:node.children[index],parentPath:node.path})}}}toTreeItem(node){const badges=[];node.gitStatus&&badges.push({text:GIT_STATUS_LETTER[node.gitStatus],tone:GIT_STATUS_TONE[node.gitStatus],label:this.localize(GIT_STATUS_KEY[node.gitStatus])});const description=node.additions!==void 0||node.deletions!==void 0?this.localize("fileTreeDiffSummary",void 0,{additions:getNumberFormat(this.effectiveLocale).format(node.additions??0),deletions:getNumberFormat(this.effectiveLocale).format(node.deletions??0)}):void 0;let children;return isLazyUnloaded(node)?children=[{id:`${node.path} loading`,label:this.localize("loading"),disabled:!0}]:node.children&&(children=node.children.map(c=>this.toTreeItem(c))),{id:node.path,label:node.name??baseName(node.path),selected:this.selectedPath===node.path,children,badges:badges.length>0?badges:void 0,description,icon:isDirectory(node)?void 0:html`<lr-file-icon
2
2
  mime-type=${node.mimeType??""}
3
3
  name=${node.name??baseName(node.path)}
4
4
  decorative