@aceshooting/lyra-ui 9.1.1 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (585) hide show
  1. package/CHANGELOG.md +785 -0
  2. package/custom-elements.json +1 -1
  3. package/design-tokens.json +13 -0
  4. package/dist/cli/migrate-wa.mjs +216 -1
  5. package/dist/cli/migration-contract.json +1 -1
  6. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
  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 +7 -5
  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.styles.js +7 -4
  13. package/dist/components/agent-tools/approval-queue/approval-queue.styles.js +7 -5
  14. package/dist/components/agent-tools/artifact-panel/artifact-panel.styles.js +0 -3
  15. package/dist/components/agent-tools/browser-frame/browser-frame.styles.js +3 -5
  16. package/dist/components/agent-tools/commit-card/commit-card.styles.js +0 -10
  17. package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +11 -6
  18. package/dist/components/agent-tools/confirm-bar/confirm-bar.styles.js +0 -46
  19. package/dist/components/agent-tools/eval-dataset/eval-dataset.styles.js +0 -7
  20. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +2 -2
  21. package/dist/components/agent-tools/prompt-studio/prompt-studio.styles.js +0 -15
  22. package/dist/components/agent-tools/result-card/result-card.styles.js +0 -7
  23. package/dist/components/agent-tools/result-card/result-field.styles.js +0 -5
  24. package/dist/components/agent-tools/schema-viewer/schema-viewer.styles.js +0 -3
  25. package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +0 -15
  26. package/dist/components/agent-tools/stack-trace/stack-trace.styles.js +0 -20
  27. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
  28. package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +0 -3
  29. package/dist/components/agent-tools/task-list/task-list.styles.js +0 -15
  30. package/dist/components/agent-tools/terminal/terminal.class.d.ts +11 -6
  31. package/dist/components/agent-tools/terminal/terminal.class.js +4 -4
  32. package/dist/components/agent-tools/terminal/terminal.styles.js +0 -46
  33. package/dist/components/agent-tools/test-results/test-results.class.js +2 -2
  34. package/dist/components/agent-tools/test-results/test-results.styles.js +0 -5
  35. package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +0 -41
  36. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.styles.js +0 -41
  37. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.styles.js +0 -30
  38. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +6 -6
  39. package/dist/components/agent-tools/tool-param-form/tool-param-form.styles.js +0 -5
  40. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.styles.js +0 -20
  41. package/dist/components/agent-tools/tool-result-view/tool-result-view.styles.js +0 -4
  42. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.styles.js +0 -21
  43. package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +7 -31
  44. package/dist/components/charts/chart/box-plot.class.d.ts +27 -0
  45. package/dist/components/charts/chart/box-plot.class.js +14 -4
  46. package/dist/components/charts/chart/box-plot.styles.js +28 -20
  47. package/dist/components/charts/chart/chart-colors.d.ts +1 -1
  48. package/dist/components/charts/chart/chart-colors.js +1 -1
  49. package/dist/components/charts/chart/chart-core-loader.d.ts +1 -0
  50. package/dist/components/charts/chart/chart-core-loader.js +1 -1
  51. package/dist/components/charts/chart/chart-feature-loader.d.ts +35 -0
  52. package/dist/components/charts/chart/chart-feature-loader.js +1 -1
  53. package/dist/components/charts/chart/chart.class.d.ts +120 -0
  54. package/dist/components/charts/chart/chart.class.js +16 -6
  55. package/dist/components/charts/chart/chart.styles.js +28 -27
  56. package/dist/components/charts/chart/lite-chart.class.d.ts +20 -1
  57. package/dist/components/charts/chart/lite-chart.class.js +4 -4
  58. package/dist/components/charts/chart/lite-chart.styles.js +0 -27
  59. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +20 -0
  60. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +3 -1
  61. package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +3 -0
  62. package/dist/components/conversation/audio-visualizer/audio-visualizer.styles.js +0 -7
  63. package/dist/components/conversation/branch-picker/branch-picker.styles.js +0 -3
  64. package/dist/components/conversation/chat-composer/chat-composer.styles.js +0 -51
  65. package/dist/components/conversation/chat-message/chat-message.styles.js +7 -35
  66. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  67. package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +0 -33
  68. package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
  69. package/dist/components/conversation/checkpoint/checkpoint.styles.js +0 -3
  70. package/dist/components/conversation/code-block/code-block-shared.d.ts +5 -2
  71. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  72. package/dist/components/conversation/code-block/code-block.styles.js +4 -95
  73. package/dist/components/conversation/code-block/code-loader.d.ts +11 -0
  74. package/dist/components/conversation/code-block/code-loader.js +1 -1
  75. package/dist/components/conversation/code-block/shiki-types.d.ts +12 -0
  76. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  77. package/dist/components/conversation/conversation-item/conversation-item.styles.js +8 -54
  78. package/dist/components/conversation/generation-metrics/generation-metrics.class.js +2 -2
  79. package/dist/components/conversation/generation-metrics/generation-metrics.styles.js +0 -17
  80. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  81. package/dist/components/conversation/markdown/markdown.styles.js +0 -41
  82. package/dist/components/conversation/message-actions/message-actions.styles.js +0 -3
  83. package/dist/components/conversation/message-feedback/message-feedback.styles.js +0 -35
  84. package/dist/components/conversation/message-parts/message-parts.class.d.ts +1 -1
  85. package/dist/components/conversation/message-parts/message-parts.styles.js +0 -5
  86. package/dist/components/conversation/model-select/model-select.class.js +3 -3
  87. package/dist/components/conversation/model-select/model-select.styles.js +12 -47
  88. package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +0 -6
  89. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -0
  90. package/dist/components/conversation/prompt-input/prompt-input.styles.js +0 -10
  91. package/dist/components/conversation/push-to-talk/push-to-talk.styles.js +0 -8
  92. package/dist/components/conversation/selection-toolbar/selection-toolbar.styles.js +1 -11
  93. package/dist/components/conversation/stream-status/stream-status.styles.js +0 -16
  94. package/dist/components/conversation/streaming-text/streaming-text.styles.js +0 -15
  95. package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +0 -5
  96. package/dist/components/conversation/thread-list/thread-list.styles.js +0 -23
  97. package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +16 -4
  98. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  99. package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +0 -1
  100. package/dist/components/conversation/typing-indicator/typing-indicator.styles.js +0 -23
  101. package/dist/components/conversation/usage-badge/usage-badge.styles.js +0 -3
  102. package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -3
  103. package/dist/components/conversation/voice-picker/voice-picker.styles.js +9 -29
  104. package/dist/components/conversation/widget-renderer/resolve.d.ts +2 -0
  105. package/dist/components/conversation/widget-renderer/resolve.js +1 -1
  106. package/dist/components/data/calendar/calendar.class.d.ts +15 -2
  107. package/dist/components/data/calendar/calendar.class.js +2 -2
  108. package/dist/components/data/calendar/calendar.styles.js +2 -28
  109. package/dist/components/data/condition-builder/condition-builder.class.d.ts +10 -6
  110. package/dist/components/data/condition-builder/condition-builder.class.js +2 -2
  111. package/dist/components/data/condition-builder/condition-builder.styles.js +0 -6
  112. package/dist/components/data/context-meter/context-meter.styles.js +0 -24
  113. package/dist/components/data/data-grid/data-grid.class.js +3 -3
  114. package/dist/components/data/data-grid/data-grid.styles.js +0 -22
  115. package/dist/components/data/document-library/document-library.class.js +2 -2
  116. package/dist/components/data/document-library/document-library.styles.js +0 -4
  117. package/dist/components/data/env-list/env-list.class.js +1 -1
  118. package/dist/components/data/env-list/env-list.styles.js +7 -4
  119. package/dist/components/data/file-tree/file-tree.class.d.ts +12 -0
  120. package/dist/components/data/flow-canvas/flow-canvas.styles.js +12 -19
  121. package/dist/components/data/flow-controls/flow-controls.class.js +2 -2
  122. package/dist/components/data/flow-controls/flow-controls.styles.js +3 -36
  123. package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
  124. package/dist/components/data/flow-minimap/flow-minimap.styles.js +0 -9
  125. package/dist/components/data/flow-node/flow-node.styles.js +0 -23
  126. package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
  127. package/dist/components/data/flow-run-status/flow-run-status.styles.js +0 -7
  128. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +0 -7
  129. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
  130. package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +0 -10
  131. package/dist/components/data/heatmap/heatmap-scale.d.ts +20 -0
  132. package/dist/components/data/heatmap/heatmap-scale.js +1 -1
  133. package/dist/components/data/heatmap/heatmap.class.d.ts +117 -1
  134. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  135. package/dist/components/data/heatmap/heatmap.styles.js +0 -54
  136. package/dist/components/data/pagination/pagination.styles.js +23 -46
  137. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +34 -1
  138. package/dist/components/data/sequence-strip/sequence-strip.class.js +5 -2
  139. package/dist/components/data/sequence-strip/sequence-strip.styles.js +14 -20
  140. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  141. package/dist/components/data/stat/stat.styles.js +0 -67
  142. package/dist/components/data/table/table.class.d.ts +42 -3
  143. package/dist/components/data/table/table.class.js +4 -4
  144. package/dist/components/data/table/table.styles.js +20 -91
  145. package/dist/components/data/timeline/timeline-item.styles.js +0 -30
  146. package/dist/components/data/timeline/timeline.class.d.ts +89 -1
  147. package/dist/components/data/timeline/timeline.class.js +2 -2
  148. package/dist/components/data/timeline/timeline.styles.js +111 -31
  149. package/dist/components/data/tree/tree-item.styles.js +1 -28
  150. package/dist/components/data/tree/tree.class.js +2 -2
  151. package/dist/components/data/tree/tree.styles.js +0 -6
  152. package/dist/components/data/word-cloud/word-cloud.styles.js +0 -5
  153. package/dist/components/forms/button/button.class.js +1 -1
  154. package/dist/components/forms/button/button.styles.js +0 -105
  155. package/dist/components/forms/checkbox/checkbox.class.d.ts +3 -0
  156. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  157. package/dist/components/forms/checkbox/checkbox.styles.js +0 -39
  158. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +21 -2
  159. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  160. package/dist/components/forms/checkbox-group/checkbox-group.styles.js +0 -18
  161. package/dist/components/forms/code-editor/code-editor.styles.js +0 -30
  162. package/dist/components/forms/color-picker/color-picker.class.js +2 -2
  163. package/dist/components/forms/color-picker/color-picker.styles.js +0 -69
  164. package/dist/components/forms/combobox/combobox.class.d.ts +71 -3
  165. package/dist/components/forms/combobox/combobox.class.js +5 -3
  166. package/dist/components/forms/combobox/combobox.styles.js +31 -111
  167. package/dist/components/forms/combobox/option.styles.js +7 -1
  168. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  169. package/dist/components/forms/date-picker/date-input.styles.js +12 -67
  170. package/dist/components/forms/date-picker/date-picker.class.d.ts +47 -0
  171. package/dist/components/forms/date-picker/date-picker.class.js +36 -22
  172. package/dist/components/forms/date-picker/date-picker.styles.js +82 -29
  173. package/dist/components/forms/emoji-picker/emoji-data-loader.d.ts +6 -3
  174. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  175. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +8 -1
  176. package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
  177. package/dist/components/forms/emoji-picker/emoji-picker.styles.js +3 -41
  178. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  179. package/dist/components/forms/icon-button/icon-button.styles.js +0 -16
  180. package/dist/components/forms/input/input.styles.js +0 -54
  181. package/dist/components/forms/input/number-input.styles.d.ts +4 -5
  182. package/dist/components/forms/input/number-input.styles.js +0 -11
  183. package/dist/components/forms/input/time-input-shared.d.ts +11 -0
  184. package/dist/components/forms/input/time-input-shared.js +1 -1
  185. package/dist/components/forms/input/time-input.class.d.ts +11 -2
  186. package/dist/components/forms/input/time-input.class.js +1 -1
  187. package/dist/components/forms/input/time-input.styles.js +0 -6
  188. package/dist/components/forms/locale-picker/locale-picker.class.js +2 -2
  189. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -26
  190. package/dist/components/forms/otp-input/otp-input.class.js +3 -3
  191. package/dist/components/forms/otp-input/otp-input.styles.js +0 -16
  192. package/dist/components/forms/phone-input/phone-input.class.d.ts +9 -1
  193. package/dist/components/forms/phone-input/phone-input.class.js +2 -2
  194. package/dist/components/forms/phone-input/phone-input.styles.js +0 -37
  195. package/dist/components/forms/radio/radio-button.styles.js +1 -30
  196. package/dist/components/forms/radio/radio-group.styles.js +0 -4
  197. package/dist/components/forms/radio/radio.styles.js +0 -44
  198. package/dist/components/forms/rubric-form/rubric-form.styles.js +0 -5
  199. package/dist/components/forms/select/select.class.js +1 -1
  200. package/dist/components/forms/select/select.styles.js +14 -114
  201. package/dist/components/forms/slider/slider.styles.js +0 -55
  202. package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +0 -11
  203. package/dist/components/forms/swatch-picker/swatch-picker.class.js +2 -2
  204. package/dist/components/forms/swatch-picker/swatch-picker.styles.js +0 -77
  205. package/dist/components/forms/switch/switch.class.d.ts +3 -0
  206. package/dist/components/forms/switch/switch.class.js +1 -1
  207. package/dist/components/forms/switch/switch.styles.js +0 -37
  208. package/dist/components/forms/textarea/textarea.styles.js +0 -28
  209. package/dist/components/forms/time-range/time-range.styles.js +12 -84
  210. package/dist/components/forms/token-input/token-input.class.d.ts +23 -9
  211. package/dist/components/forms/token-input/token-input.class.js +1 -1
  212. package/dist/components/forms/token-input/token-input.styles.js +1 -54
  213. package/dist/components/layout/app-rail/app-rail-item.class.js +2 -2
  214. package/dist/components/layout/app-rail/app-rail-item.styles.js +0 -13
  215. package/dist/components/layout/app-rail/app-rail.class.d.ts +5 -0
  216. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  217. package/dist/components/layout/app-rail/app-rail.styles.js +0 -46
  218. package/dist/components/layout/button-group/button-group.styles.js +0 -6
  219. package/dist/components/layout/card/card.class.d.ts +12 -0
  220. package/dist/components/layout/card/card.styles.js +3 -11
  221. package/dist/components/layout/carousel/carousel.styles.js +0 -1
  222. package/dist/components/layout/command-palette/command-palette.class.d.ts +8 -0
  223. package/dist/components/layout/command-palette/command-palette.class.js +3 -1
  224. package/dist/components/layout/command-palette/command-palette.styles.js +1 -13
  225. package/dist/components/layout/control-group/control-group.styles.js +0 -7
  226. package/dist/components/layout/dashboard-grid/dashboard-grid.styles.js +6 -25
  227. package/dist/components/layout/details/accordion.class.d.ts +13 -0
  228. package/dist/components/layout/details/accordion.class.js +1 -1
  229. package/dist/components/layout/details/details.class.js +1 -1
  230. package/dist/components/layout/details/details.styles.js +0 -12
  231. package/dist/components/layout/dock-panel/dock-panel.styles.js +0 -45
  232. package/dist/components/layout/drilldown-panel/drilldown-panel.class.d.ts +2 -0
  233. package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +2 -2
  234. package/dist/components/layout/drilldown-panel/drilldown-panel.styles.js +0 -4
  235. package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
  236. package/dist/components/layout/filter-bar/filter-bar.styles.js +0 -9
  237. package/dist/components/layout/menu/menu-item.class.d.ts +5 -0
  238. package/dist/components/layout/menu/menu-item.class.js +1 -1
  239. package/dist/components/layout/menu/menu-item.styles.js +0 -49
  240. package/dist/components/layout/menu/menu-label.styles.js +0 -2
  241. package/dist/components/layout/menu/menu.styles.js +0 -18
  242. package/dist/components/layout/multi-split/multi-split.styles.js +0 -63
  243. package/dist/components/layout/page/page.class.d.ts +4 -0
  244. package/dist/components/layout/page/page.class.js +1 -1
  245. package/dist/components/layout/reorder-list/reorder-item.styles.js +0 -4
  246. package/dist/components/layout/responsive-panel/responsive-panel.styles.js +0 -27
  247. package/dist/components/layout/scroller/scroller.styles.js +0 -20
  248. package/dist/components/layout/segmented/segmented.class.d.ts +7 -1
  249. package/dist/components/layout/segmented/segmented.class.js +1 -1
  250. package/dist/components/layout/segmented/segmented.styles.js +69 -37
  251. package/dist/components/layout/split-panel/split-panel.styles.js +1 -7
  252. package/dist/components/layout/stepper/stepper.class.d.ts +8 -1
  253. package/dist/components/layout/stepper/stepper.class.js +1 -1
  254. package/dist/components/layout/stepper/stepper.styles.js +140 -41
  255. package/dist/components/layout/tab-group/tab-group.class.d.ts +4 -1
  256. package/dist/components/layout/tab-group/tab-group.styles.js +9 -75
  257. package/dist/components/layout/tab-group/tab.styles.js +0 -2
  258. package/dist/components/layout/virtual-list/virtual-list.class.d.ts +4 -4
  259. package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
  260. package/dist/components/layout/virtual-list/virtual-list.styles.js +0 -68
  261. package/dist/components/layout/widget/widget.class.d.ts +5 -1
  262. package/dist/components/layout/widget/widget.class.js +1 -1
  263. package/dist/components/layout/widget/widget.styles.js +97 -40
  264. package/dist/components/media/animated-image/animated-image.class.d.ts +3 -0
  265. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  266. package/dist/components/media/animated-image/animated-image.styles.js +0 -28
  267. package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +1 -1
  268. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  269. package/dist/components/media/attachment-chip/attachment-chip.styles.js +0 -31
  270. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
  271. package/dist/components/media/attachment-trigger/attachment-trigger.styles.js +0 -40
  272. package/dist/components/media/av-player/av-player.class.d.ts +5 -6
  273. package/dist/components/media/av-player/av-player.class.js +1 -1
  274. package/dist/components/media/av-player/av-player.styles.js +0 -45
  275. package/dist/components/media/avatar/avatar.styles.js +3 -16
  276. package/dist/components/media/file-icon/file-icon.class.d.ts +1 -2
  277. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  278. package/dist/components/media/file-input/file-input.class.d.ts +12 -0
  279. package/dist/components/media/file-input/file-input.styles.js +3 -24
  280. package/dist/components/media/flag/flag.class.d.ts +23 -1
  281. package/dist/components/media/flag/flag.class.js +4 -2
  282. package/dist/components/media/flag/flag.styles.js +7 -1
  283. package/dist/components/media/flag/language-map.d.ts +10 -0
  284. package/dist/components/media/flag/language-map.js +1 -1
  285. package/dist/components/media/image-comparer/image-comparer.styles.js +4 -33
  286. package/dist/components/media/image-viewer/image-viewer.class.js +0 -2
  287. package/dist/components/media/image-viewer/image-viewer.styles.js +7 -27
  288. package/dist/components/media/lightbox/lightbox.class.js +0 -2
  289. package/dist/components/media/lightbox/lightbox.styles.js +0 -21
  290. package/dist/components/media/map/map-loader.d.ts +19 -1
  291. package/dist/components/media/map/map-loader.js +1 -1
  292. package/dist/components/media/map/map.class.d.ts +178 -1
  293. package/dist/components/media/map/map.class.js +15 -3
  294. package/dist/components/media/map/map.styles.js +20 -17
  295. package/dist/components/media/media-card/media-card.class.d.ts +14 -3
  296. package/dist/components/media/media-card/media-card.class.js +1 -1
  297. package/dist/components/media/media-card/media-card.styles.js +2 -28
  298. package/dist/components/media/pan-zoom/pan-zoom.styles.js +0 -3
  299. package/dist/components/media/qr-code/qr-code.class.d.ts +3 -2
  300. package/dist/components/media/qr-code/qr-code.class.js +2 -2
  301. package/dist/components/media/qr-code/qr-code.styles.js +0 -3
  302. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +2 -0
  303. package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -1
  304. package/dist/components/media/sequence-playback/sequence-playback.styles.js +0 -19
  305. package/dist/components/media/video/video.class.d.ts +23 -2
  306. package/dist/components/media/video/video.class.js +3 -3
  307. package/dist/components/media/video/video.styles.js +4 -2
  308. package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +3 -2
  309. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
  310. package/dist/components/media/zoomable-frame/zoomable-frame.styles.js +0 -5
  311. package/dist/components/overlays/alert/alert.styles.js +4 -2
  312. package/dist/components/overlays/badge/badge.styles.js +4 -48
  313. package/dist/components/overlays/badge/tag.styles.js +0 -14
  314. package/dist/components/overlays/callout/callout.styles.js +0 -11
  315. package/dist/components/overlays/chip/chip-group.styles.js +0 -18
  316. package/dist/components/overlays/chip/chip.styles.js +6 -69
  317. package/dist/components/overlays/dialog/confirm.d.ts +1 -4
  318. package/dist/components/overlays/dialog/confirm.js +1 -1
  319. package/dist/components/overlays/dialog/dialog.class.d.ts +32 -9
  320. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  321. package/dist/components/overlays/dialog/dialog.styles.js +0 -43
  322. package/dist/components/overlays/drawer/drawer.class.d.ts +2 -2
  323. package/dist/components/overlays/drawer/drawer.styles.js +0 -9
  324. package/dist/components/overlays/empty/empty.styles.js +0 -12
  325. package/dist/components/overlays/kbd/kbd.styles.js +0 -8
  326. package/dist/components/overlays/overlay/dropdown.class.d.ts +1 -6
  327. package/dist/components/overlays/overlay/dropdown.class.js +2 -2
  328. package/dist/components/overlays/overlay/overlay.styles.js +0 -28
  329. package/dist/components/overlays/overlay/popover.class.d.ts +28 -4
  330. package/dist/components/overlays/overlay/popover.class.js +2 -2
  331. package/dist/components/overlays/overlay/tooltip.class.d.ts +10 -0
  332. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  333. package/dist/components/overlays/popup/popup.class.d.ts +1 -0
  334. package/dist/components/overlays/popup/popup.class.js +1 -1
  335. package/dist/components/overlays/popup/popup.styles.js +0 -15
  336. package/dist/components/overlays/progress/progress-ring.class.d.ts +9 -1
  337. package/dist/components/overlays/progress/progress-ring.class.js +3 -3
  338. package/dist/components/overlays/progress/progress.styles.js +0 -21
  339. package/dist/components/overlays/rating/rating.styles.js +0 -25
  340. package/dist/components/overlays/skeleton/skeleton.styles.js +0 -4
  341. package/dist/components/overlays/spinner/spinner.styles.js +0 -3
  342. package/dist/components/overlays/toast/toast-item.styles.js +3 -45
  343. package/dist/components/retrieval/chunk-inspector/chunk-inspector.styles.js +0 -35
  344. package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +2 -2
  345. package/dist/components/retrieval/citation-badge/citation-badge.class.js +3 -3
  346. package/dist/components/retrieval/citation-badge/citation-badge.styles.js +0 -20
  347. package/dist/components/retrieval/claim-evidence/claim-evidence.styles.js +0 -8
  348. package/dist/components/retrieval/community-card/community-card.class.d.ts +1 -0
  349. package/dist/components/retrieval/community-card/community-card.styles.js +0 -6
  350. package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +8 -12
  351. package/dist/components/retrieval/entity-card/entity-card.class.d.ts +4 -3
  352. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  353. package/dist/components/retrieval/entity-card/entity-card.styles.js +0 -12
  354. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +10 -4
  355. package/dist/components/retrieval/entity-chip/entity-chip.class.js +3 -3
  356. package/dist/components/retrieval/entity-chip/entity-chip.styles.js +6 -9
  357. package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +19 -5
  358. package/dist/components/retrieval/graph/graph.class.d.ts +5 -0
  359. package/dist/components/retrieval/graph/graph.class.js +1 -1
  360. package/dist/components/retrieval/graph/graph.styles.js +0 -30
  361. package/dist/components/retrieval/graph-legend/graph-legend.styles.js +0 -3
  362. package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +0 -25
  363. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +2 -0
  364. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +0 -7
  365. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +20 -6
  366. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +2 -2
  367. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +0 -16
  368. package/dist/components/retrieval/mind-map/mind-map.class.d.ts +5 -3
  369. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  370. package/dist/components/retrieval/mind-map/mind-map.styles.js +0 -2
  371. package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +3 -2
  372. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  373. package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +0 -30
  374. package/dist/components/retrieval/node-palette/node-palette.styles.js +0 -11
  375. package/dist/components/retrieval/path-strip/path-strip.styles.js +0 -10
  376. package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +12 -3
  377. package/dist/components/retrieval/provenance-panel/provenance-panel.styles.js +0 -2
  378. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +3 -2
  379. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +2 -2
  380. package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +0 -28
  381. package/dist/components/retrieval/retrieval-search/retrieval-search.styles.js +0 -4
  382. package/dist/components/retrieval/retrieval-trace/retrieval-trace.styles.js +0 -2
  383. package/dist/components/retrieval/source-card/source-card.styles.js +0 -13
  384. package/dist/components/retrieval/source-list/source-list.styles.js +0 -7
  385. package/dist/components/retrieval/source-picker/source-picker.styles.js +0 -7
  386. package/dist/components/utility/copy-button/copy-button.styles.js +0 -10
  387. package/dist/components/utility/diff-view/diff-view.styles.js +0 -14
  388. package/dist/components/utility/export-button/export-button.styles.js +0 -22
  389. package/dist/components/utility/icon/icon.styles.js +0 -6
  390. package/dist/components/utility/json-viewer/json-viewer.styles.js +2 -48
  391. package/dist/components/utility/known-date/known-date.class.d.ts +7 -3
  392. package/dist/components/utility/known-date/known-date.styles.js +10 -51
  393. package/dist/components/utility/live-region/live-region.styles.js +0 -4
  394. package/dist/components/utility/mention-popover/mention-popover.styles.js +0 -25
  395. package/dist/components/utility/poll-status/poll-status.styles.js +0 -4
  396. package/dist/components/utility/random-content/random-content.class.d.ts +22 -0
  397. package/dist/components/utility/random-content/random-content.class.js +3 -2
  398. package/dist/components/utility/random-content/random-content.styles.js +6 -13
  399. package/dist/components/utility/tour/tour.class.d.ts +4 -2
  400. package/dist/components/utility/tour/tour.class.js +3 -3
  401. package/dist/components/utility/tour/tour.styles.js +0 -13
  402. package/dist/components/utility/visually-hidden/visually-hidden.styles.js +0 -5
  403. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  404. package/dist/components/viewers/archive-viewer/archive-viewer.styles.d.ts +2 -2
  405. package/dist/components/viewers/archive-viewer/archive-viewer.styles.js +0 -10
  406. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  407. package/dist/components/viewers/csv-viewer/csv-viewer.styles.js +0 -19
  408. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
  409. package/dist/components/viewers/dataset-viewer/dataset-viewer.styles.js +0 -15
  410. package/dist/components/viewers/document-compare/document-compare.styles.js +0 -3
  411. package/dist/components/viewers/document-preview/document-preview.styles.js +0 -25
  412. package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +2 -1
  413. package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
  414. package/dist/components/viewers/document-viewer/document-viewer.styles.js +0 -5
  415. package/dist/components/viewers/docx-viewer/docx-viewer.styles.js +0 -17
  416. package/dist/components/viewers/ebook-viewer/ebook-viewer.styles.js +0 -4
  417. package/dist/components/viewers/email-viewer/email-viewer.styles.js +0 -7
  418. package/dist/components/viewers/geojson-view/geojson-view.styles.js +0 -5
  419. package/dist/components/viewers/highlight-layer/highlight-layer.styles.js +0 -3
  420. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
  421. package/dist/components/viewers/notebook-viewer/notebook-viewer.styles.js +0 -38
  422. package/dist/components/viewers/page-rail/page-rail.class.js +1 -1
  423. package/dist/components/viewers/page-rail/page-rail.styles.js +0 -13
  424. package/dist/components/viewers/pdf-viewer/pdf-loader.d.ts +13 -2
  425. package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
  426. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +32 -2
  427. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
  428. package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -27
  429. package/dist/components/viewers/pptx-viewer/pptx-viewer.styles.js +0 -3
  430. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  431. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.styles.js +0 -14
  432. package/dist/components/viewers/svg-viewer/svg-viewer.styles.js +0 -7
  433. package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +2 -24
  434. package/dist/custom-elements-jsx.d.ts +72 -40
  435. package/dist/events.d.ts +43 -33
  436. package/dist/internal/agent-status-variants.d.ts +18 -0
  437. package/dist/internal/agent-status-variants.js +1 -0
  438. package/dist/internal/announcer.d.ts +8 -3
  439. package/dist/internal/announcer.js +1 -1
  440. package/dist/internal/autoloader-manifest.js +1 -1
  441. package/dist/internal/canvas-color.d.ts +16 -0
  442. package/dist/internal/canvas-color.js +1 -1
  443. package/dist/internal/catalog-picker.d.ts +0 -1
  444. package/dist/internal/catalog-picker.js +1 -1
  445. package/dist/internal/default-strings.generated.d.ts +1 -0
  446. package/dist/internal/default-strings.generated.js +1 -1
  447. package/dist/internal/dev-mode-attribute-warning.d.ts +27 -4
  448. package/dist/internal/dev-mode-attribute-warning.js +1 -1
  449. package/dist/internal/localization-runtime.js +1 -1
  450. package/dist/internal/localization-types.d.ts +1 -1
  451. package/dist/internal/localization.js +1 -1
  452. package/dist/internal/lyra-element.d.ts +13 -0
  453. package/dist/internal/lyra-element.js +1 -1
  454. package/dist/internal/media-controller.js +1 -1
  455. package/dist/internal/package-metadata.d.ts +1 -1
  456. package/dist/internal/package-metadata.js +1 -1
  457. package/dist/internal/scroll-overflow.d.ts +35 -13
  458. package/dist/internal/scroll-overflow.js +1 -1
  459. package/dist/internal/sizes.styles.js +0 -2
  460. package/dist/internal/specialist-tokens.styles.js +6 -11
  461. package/dist/internal/text-highlights.d.ts +4 -1
  462. package/dist/internal/text-highlights.js +1 -1
  463. package/dist/internal/tokens/palette.styles.js +0 -15
  464. package/dist/internal/tokens.styles.js +20 -113
  465. package/dist/lyra.d.ts +9 -6
  466. package/dist/styles/reservations.css +82 -0
  467. package/dist/svelte.d.ts +72 -40
  468. package/dist/translations/ar.js +1 -1
  469. package/dist/translations/de.js +1 -1
  470. package/dist/translations/es.js +1 -1
  471. package/dist/translations/fa.js +1 -1
  472. package/dist/translations/fr.js +1 -1
  473. package/dist/translations/he.js +1 -1
  474. package/dist/translations/ja.js +1 -1
  475. package/dist/translations/pt-BR.js +1 -1
  476. package/dist/translations/ru.js +1 -1
  477. package/dist/translations/zh-CN.js +1 -1
  478. package/dist/vue.d.ts +72 -40
  479. package/llms/components/lr-accordion-item.md +12 -3
  480. package/llms/components/lr-accordion.md +11 -2
  481. package/llms/components/lr-agent-eval-dashboard.md +1 -1
  482. package/llms/components/lr-agent-trace.md +3 -1
  483. package/llms/components/lr-agent-workspace.md +20 -0
  484. package/llms/components/lr-artifact-panel.md +10 -4
  485. package/llms/components/lr-attachment-chip.md +7 -4
  486. package/llms/components/lr-attachment-trigger.md +7 -4
  487. package/llms/components/lr-av-player.md +3 -1
  488. package/llms/components/lr-avatar.md +6 -6
  489. package/llms/components/lr-bar-chart.md +8 -6
  490. package/llms/components/lr-box-plot.md +15 -4
  491. package/llms/components/lr-browser-frame.md +7 -3
  492. package/llms/components/lr-bubble-chart.md +8 -6
  493. package/llms/components/lr-calendar.md +9 -2
  494. package/llms/components/lr-card.md +24 -0
  495. package/llms/components/lr-chart.md +45 -11
  496. package/llms/components/lr-chat-viewport.md +7 -2
  497. package/llms/components/lr-checkbox-group.md +13 -5
  498. package/llms/components/lr-checkbox.md +5 -2
  499. package/llms/components/lr-checkpoint.md +6 -2
  500. package/llms/components/lr-combobox.md +47 -8
  501. package/llms/components/lr-command-palette.md +4 -1
  502. package/llms/components/lr-confirm-bar.md +7 -3
  503. package/llms/components/lr-context-meter.md +12 -11
  504. package/llms/components/lr-conversation-item.md +7 -4
  505. package/llms/components/lr-date-input.md +22 -2
  506. package/llms/components/lr-date-picker.md +23 -3
  507. package/llms/components/lr-details.md +11 -2
  508. package/llms/components/lr-dialog.md +16 -10
  509. package/llms/components/lr-dock-panel.md +7 -10
  510. package/llms/components/lr-document-preview.md +6 -1
  511. package/llms/components/lr-document-viewer.md +3 -2
  512. package/llms/components/lr-doughnut-chart.md +8 -6
  513. package/llms/components/lr-drawer.md +3 -3
  514. package/llms/components/lr-entity-card.md +3 -3
  515. package/llms/components/lr-entity-chip.md +1 -1
  516. package/llms/components/lr-entity-dossier.md +4 -1
  517. package/llms/components/lr-file-input.md +2 -2
  518. package/llms/components/lr-flag.md +30 -8
  519. package/llms/components/lr-heatmap.md +46 -0
  520. package/llms/components/lr-histogram.md +7 -4
  521. package/llms/components/lr-icon.md +1 -1
  522. package/llms/components/lr-json-schema-viewer.md +2 -1
  523. package/llms/components/lr-knowledge-graph-explorer.md +8 -3
  524. package/llms/components/lr-known-date.md +4 -2
  525. package/llms/components/lr-line-chart.md +8 -6
  526. package/llms/components/lr-lite-chart.md +16 -6
  527. package/llms/components/lr-map.md +91 -10
  528. package/llms/components/lr-markdown-core.md +3 -2
  529. package/llms/components/lr-media-card.md +28 -12
  530. package/llms/components/lr-message-parts.md +2 -1
  531. package/llms/components/lr-model-select.md +9 -10
  532. package/llms/components/lr-model-settings-panel.md +9 -9
  533. package/llms/components/lr-neighbor-list.md +1 -1
  534. package/llms/components/lr-notebook-viewer.md +6 -3
  535. package/llms/components/lr-option.md +46 -7
  536. package/llms/components/lr-pdf-viewer.md +62 -2
  537. package/llms/components/lr-pie-chart.md +8 -6
  538. package/llms/components/lr-polar-area-chart.md +8 -6
  539. package/llms/components/lr-popover.md +25 -1
  540. package/llms/components/lr-progress-ring.md +8 -1
  541. package/llms/components/lr-prompt-studio.md +1 -1
  542. package/llms/components/lr-provenance-panel.md +4 -2
  543. package/llms/components/lr-qr-code.md +1 -1
  544. package/llms/components/lr-radar-chart.md +8 -6
  545. package/llms/components/lr-rag-eval-dashboard.md +2 -2
  546. package/llms/components/lr-random-content.md +13 -0
  547. package/llms/components/lr-reorder-item.md +6 -1
  548. package/llms/components/lr-reorder-list.md +6 -1
  549. package/llms/components/lr-responsive-panel.md +11 -7
  550. package/llms/components/lr-scatter-chart.md +8 -6
  551. package/llms/components/lr-sequence-strip.md +16 -2
  552. package/llms/components/lr-slider.md +12 -5
  553. package/llms/components/lr-sparkline.md +1 -1
  554. package/llms/components/lr-suggestion-chips.md +7 -2
  555. package/llms/components/lr-swatch-picker.md +5 -5
  556. package/llms/components/lr-switch.md +5 -2
  557. package/llms/components/lr-table.md +30 -4
  558. package/llms/components/lr-terminal.md +3 -1
  559. package/llms/components/lr-thread-list.md +8 -8
  560. package/llms/components/lr-time-input.md +6 -1
  561. package/llms/components/lr-timeline-item.md +24 -0
  562. package/llms/components/lr-timeline.md +25 -1
  563. package/llms/components/lr-token-input.md +7 -2
  564. package/llms/components/lr-tool-approval-dialog.md +7 -8
  565. package/llms/components/lr-tool-call-chip.md +5 -1
  566. package/llms/components/lr-tool-param-form.md +14 -12
  567. package/llms/components/lr-tool-result-dialog.md +11 -9
  568. package/llms/components/lr-tool-result-view.md +7 -6
  569. package/llms/components/lr-tool-select-dialog.md +18 -16
  570. package/llms/components/lr-trace-tree.md +3 -1
  571. package/llms/components/lr-usage-badge.md +4 -1
  572. package/llms/components/lr-video-playlist.md +1 -1
  573. package/llms/components/lr-virtual-list.md +22 -14
  574. package/llms/components/lr-voice-picker.md +8 -5
  575. package/llms/components/lr-widget-renderer.md +3 -3
  576. package/llms/components/lr-widget.md +1 -1
  577. package/llms/components/lr-word-cloud.md +6 -2
  578. package/llms/peers.md +12 -2
  579. package/llms/shared.md +70 -2
  580. package/llms/tokens.md +15 -1
  581. package/llms-full.txt +1335 -306
  582. package/package.json +17 -5
  583. package/vscode-css-data.json +93 -2
  584. package/vscode-html-data.json +513 -59
  585. package/web-types.json +457 -72
@@ -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{closeIcon}from"../../../internal/icons.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{styles}from"./graph-query-builder.styles.js";import{getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_graphQueryBuilderLabel,LYRA_DEFAULT_graphQueryDeleteWithContext,LYRA_DEFAULT_graphQueryDirectionLabel,LYRA_DEFAULT_graphQueryEndLabel,LYRA_DEFAULT_graphQueryHopRangeInvalid,LYRA_DEFAULT_graphQueryLoadWithContext,LYRA_DEFAULT_graphQueryMaxHopsLabel,LYRA_DEFAULT_graphQueryMinHopsLabel,LYRA_DEFAULT_graphQueryNodeTypeLabel,LYRA_DEFAULT_graphQueryRelationshipTypeLabel,LYRA_DEFAULT_graphQueryRun,LYRA_DEFAULT_graphQuerySaveButton,LYRA_DEFAULT_graphQuerySaveNameLabel,LYRA_DEFAULT_graphQuerySavedQueriesLabel,LYRA_DEFAULT_graphQueryStartLabel,LYRA_DEFAULT_neighborDirectionBoth,LYRA_DEFAULT_neighborDirectionIn,LYRA_DEFAULT_neighborDirectionOut,LYRA_DEFAULT_noData,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const MAX_TYPES=500,MAX_SAVED_QUERIES=200,MAX_TEXT=256,EMPTY_STRINGS=Object.freeze([]),EMPTY_VALUE=Object.freeze({startId:"",endId:"",relationshipTypes:EMPTY_STRINGS,nodeTypes:EMPTY_STRINGS,direction:"both",minHops:1,maxHops:1}),EMPTY_OPTIONS=Object.freeze([]),EMPTY_SAVED=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return typeof value=="string"?value.slice(0,MAX_TEXT):""}function stringArray(value){return Array.isArray(value)?Object.freeze([...new Set(value.slice(0,MAX_TYPES).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)).filter(Boolean))]):EMPTY_STRINGS}function normalizeGraphQuery(value){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,direction=ownValue(record,"direction");return Object.freeze({startId:boundedString(ownValue(record,"startId")),endId:boundedString(ownValue(record,"endId")),relationshipTypes:stringArray(ownValue(record,"relationshipTypes")),nodeTypes:stringArray(ownValue(record,"nodeTypes")),direction:direction==="out"||direction==="in"||direction==="both"?direction:"both",minHops:finiteInteger(typeof ownValue(record,"minHops")=="number"?ownValue(record,"minHops"):EMPTY_VALUE.minHops,EMPTY_VALUE.minHops,1,20),maxHops:finiteInteger(typeof ownValue(record,"maxHops")=="number"?ownValue(record,"maxHops"):EMPTY_VALUE.maxHops,EMPTY_VALUE.maxHops,1,20)})}function normalizeTypeOptions(value){if(!Array.isArray(value))return EMPTY_OPTIONS;const values=new Set,result=[];for(const candidate of value.slice(0,MAX_TYPES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const optionValue=boundedString(ownValue(candidate,"value"));if(optionValue.trim().length===0||values.has(optionValue))continue;values.add(optionValue);const label=boundedString(ownValue(candidate,"label"));result.push(Object.freeze({value:optionValue,...label?{label}:{}}))}return Object.freeze(result)}function normalizeSavedQueries(value){if(!Array.isArray(value))return EMPTY_SAVED;const ids=new Set,result=[];for(const candidate of value.slice(0,MAX_SAVED_QUERIES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));id.trim().length===0||ids.has(id)||(ids.add(id),result.push(Object.freeze({id,name:boundedString(ownValue(candidate,"name")),query:normalizeGraphQuery(ownValue(candidate,"query"))})))}return Object.freeze(result)}class LyraGraphQueryBuilder extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,graphQueryBuilderLabel:LYRA_DEFAULT_graphQueryBuilderLabel,graphQueryDeleteWithContext:LYRA_DEFAULT_graphQueryDeleteWithContext,graphQueryDirectionLabel:LYRA_DEFAULT_graphQueryDirectionLabel,graphQueryEndLabel:LYRA_DEFAULT_graphQueryEndLabel,graphQueryHopRangeInvalid:LYRA_DEFAULT_graphQueryHopRangeInvalid,graphQueryLoadWithContext:LYRA_DEFAULT_graphQueryLoadWithContext,graphQueryMaxHopsLabel:LYRA_DEFAULT_graphQueryMaxHopsLabel,graphQueryMinHopsLabel:LYRA_DEFAULT_graphQueryMinHopsLabel,graphQueryNodeTypeLabel:LYRA_DEFAULT_graphQueryNodeTypeLabel,graphQueryRelationshipTypeLabel:LYRA_DEFAULT_graphQueryRelationshipTypeLabel,graphQueryRun:LYRA_DEFAULT_graphQueryRun,graphQuerySaveButton:LYRA_DEFAULT_graphQuerySaveButton,graphQuerySaveNameLabel:LYRA_DEFAULT_graphQuerySaveNameLabel,graphQuerySavedQueriesLabel:LYRA_DEFAULT_graphQuerySavedQueriesLabel,graphQueryStartLabel:LYRA_DEFAULT_graphQueryStartLabel,neighborDirectionBoth:LYRA_DEFAULT_neighborDirectionBoth,neighborDirectionIn:LYRA_DEFAULT_neighborDirectionIn,neighborDirectionOut:LYRA_DEFAULT_neighborDirectionOut,noData:LYRA_DEFAULT_noData,select:LYRA_DEFAULT_select}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-before-query-run","lr-query-run","lr-before-query-save","lr-query-save","lr-before-query-load","lr-query-load"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get relationshipTypeOptions(){return this._relationshipTypeOptions}set relationshipTypeOptions(value){const previous=this._relationshipTypeOptions;this._relationshipTypeOptions=normalizeTypeOptions(value),this.requestUpdate("relationshipTypeOptions",previous)}get nodeTypeOptions(){return this._nodeTypeOptions}set nodeTypeOptions(value){const previous=this._nodeTypeOptions;this._nodeTypeOptions=normalizeTypeOptions(value),this.requestUpdate("nodeTypeOptions",previous)}get savedQueries(){return this._savedQueries}set savedQueries(value){const previous=this._savedQueries;this._savedQueries=normalizeSavedQueries(value),this.requestUpdate("savedQueries",previous)}constructor(){super(),this._relationshipTypeOptions=EMPTY_OPTIONS,this._nodeTypeOptions=EMPTY_OPTIONS,this._savedQueries=EMPTY_SAVED,this.hopLimit=6,this.label="",this.hint="",this.errorText="",this._errors={},this.touchedFields=new Set,this.saveName="",this.hasHintSlot=!1,this.hasErrorSlot=!1,this.labelId=nextId("graph-query-builder-label"),this.hintId=nextId("graph-query-builder-hint"),this.errorId=nextId("graph-query-builder-error"),this._fieldsetDisabled=!1,this._name="",this._value=EMPTY_VALUE,this.defaultValue=normalizeGraphQuery(EMPTY_VALUE),this.defaultValueCaptured=!1,this._disabled=!1,this.hasInteracted=!1,this.removalFocusGeneration=0,this.onChromeSlotChange=event=>{const slot=event.currentTarget,hasContent=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType===Node.TEXT_NODE?!!node.textContent?.trim():!0);slot.name==="hint"?this.hasHintSlot=hasContent:slot.name==="error"&&(this.hasErrorSlot=hasContent)},this.internals=this.safeAttachInternals(),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.syncFormState()}disconnectedCallback(){this.removalFocusGeneration++,this.pendingRemovalFocus=void 0,super.disconnectedCallback()}safeAttachInternals(){if(typeof globalThis.ElementInternals>"u")return this.inertInternals();try{return this.attachInternals()}catch{return this.inertInternals()}}inertInternals(){return{form:null,labels:[],validity:{},validationMessage:"",willValidate:!1,setFormValue:()=>{},setValidity:()=>{},checkValidity:()=>!0,reportValidity:()=>!0,states:new Set}}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}get value(){return this._value}set value(next){const old=this._value;this._value=normalizeGraphQuery(next),this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.validityController&&this.syncFormState(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&this.validity.customError&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}[VALIDITY_ANCHOR](){const firstInvalidPart=Object.keys(this._errors)[0];if(!(!firstInvalidPart||!this.renderRoot))return this.renderRoot.querySelector(`[part="${firstInvalidPart}"]`)??void 0}computeValidation(){const errors={},flags={};return this._value.startId.trim()||(errors["start-input"]=this.localize("fieldRequired"),flags.valueMissing=!0),this._value.minHops>this._value.maxHops&&(errors["max-hops"]=this.localize("graphQueryHopRangeInvalid"),flags.rangeUnderflow=!0),{errors,flags}}syncFormState(){const{errors,flags}=this.computeValidation();this._errors=errors;let formValue=null;try{formValue=JSON.stringify(this._value)}catch{formValue=null}if(this.internals.setFormValue(formValue,formValue),this.barredFromValidation||Object.keys(flags).length===0)this.validityController.setValidity({});else{const message=Object.values(errors)[0]??"";this.validityController.setValidity(flags,message)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncValidityCustomStates(){syncValidityStates(this.internals,{required:!0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}checkValidity(){return this.syncFormState(),this.internals.checkValidity()}reportValidity(){return this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot()}formResetCallback(){this.hasInteracted=!1,this.captureDefaultValue(),this.value=this.defaultValue,this.touchedFields=new Set,this.saveName=""}captureDefaultValue(){this.defaultValueCaptured||(this.defaultValue=normalizeGraphQuery(this._value),this.defaultValueCaptured=!0)}formStateRestoreCallback(state2,_mode){let restored=EMPTY_VALUE;if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=normalizeGraphQuery(parsed))}catch{}this.value=restored}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.syncFormState(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focusFirstControl(options){if(!this.renderRoot||this.liveDisabled)return;(this.renderRoot.querySelector('[part="start-input"]')||this.renderRoot.querySelector('[part="end-input"]')||this.renderRoot.querySelector('[part="min-hops"]')||this.renderRoot.querySelector('[part="max-hops"]')||this.renderRoot.querySelector('[part="direction"]')||this.renderRoot.querySelector('[part="save-name-input"]'))?.focus(options)}focus(options){this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.shadowRoot);active&&typeof active.blur=="function"&&active.blur()}click(){this.focusFirstControl()}setValue(next){this.effectiveDisabled||(this.hasInteracted=!0,this.value=next,this.emit("lr-input",Object.freeze({value:this._value})))}addRelationshipType(type){!type||this._value.relationshipTypes.includes(type)||this.setValue({...this._value,relationshipTypes:[...this._value.relationshipTypes,type]})}removeRelationshipType(type){this.captureChipRemovalFocus("relationship",type,this._value.relationshipTypes),this.setValue({...this._value,relationshipTypes:this._value.relationshipTypes.filter(t=>t!==type)})}addNodeType(type){!type||this._value.nodeTypes.includes(type)||this.setValue({...this._value,nodeTypes:[...this._value.nodeTypes,type]})}removeNodeType(type){this.captureChipRemovalFocus("node-type",type,this._value.nodeTypes),this.setValue({...this._value,nodeTypes:this._value.nodeTypes.filter(t=>t!==type)})}captureChipRemovalFocus(group,value,selected){const active=this.shadowRoot?.activeElement,expectedPart=group==="relationship"?"relationship-chips":"node-type-chips";if(active?.localName!=="lr-chip"||active.getAttribute("value")!==value||active.closest("lr-chip-group")?.getAttribute("part")!==expectedPart)return;const index=selected.indexOf(value),survivors=selected.filter(candidate=>candidate!==value),targetValue=survivors[Math.min(Math.max(index,0),survivors.length-1)];this.pendingRemovalFocus={kind:"chip",group,targetValue},this.removalFocusGeneration++}markTouched(part){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(part)&&(this.touchedFields=new Set(this.touchedFields).add(part))}runQuery(){if(this.effectiveDisabled||!this.reportValidity())return;const detail=()=>Object.freeze({query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-run",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-run",detail())}saveQuery(){if(this.effectiveDisabled)return;const name=this.saveName.trim();if(!name)return;const detail=()=>Object.freeze({name,query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-save",detail(),{cancelable:!0}).defaultPrevented||(this.saveName="",this.emit("lr-query-save",detail()))}loadQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id,query:normalizeGraphQuery(item.query)});this.emit("lr-before-query-load",detail(),{cancelable:!0}).defaultPrevented||(this.setValue({...EMPTY_VALUE,...item.query}),this.emit("lr-query-load",detail()))}deleteQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id});this.emit("lr-before-query-delete",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-delete",detail())}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.captureDefaultValue(),!changed.has("savedQueries"))return;const active=this.shadowRoot?.activeElement;if(active?.getAttribute("part")!=="saved-delete-button")return;const focusedId=active.closest("[data-query-id]")?.dataset.queryId;if(!focusedId||this.savedQueries.some(item=>item.id===focusedId))return;const index=(changed.get("savedQueries")??[]).findIndex(item=>item.id===focusedId),target=this.savedQueries[Math.min(Math.max(index,0),this.savedQueries.length-1)];this.pendingRemovalFocus={kind:"saved",targetId:target?.id},this.removalFocusGeneration++}updated(changed){super.updated(changed),this.publishValiditySnapshot();const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const generation=this.removalFocusGeneration;this.scheduleAfterUpdate(()=>{if(!(generation!==this.removalFocusGeneration||!this.isConnected)){if(pending.kind==="chip"){if(pending.targetValue){const part=pending.group==="relationship"?"relationship-chips":"node-type-chips",chip=[...this.shadowRoot?.querySelectorAll(`[part="${part}"] lr-chip`)??[]].find(candidate=>candidate.getAttribute("value")===pending.targetValue);if(chip){chip.focus();return}}const pickerPart=pending.group==="relationship"?"relationship-picker":"node-type-picker";this.shadowRoot?.querySelector(`[part="${pickerPart}"]`)?.focus();return}if(pending.targetId){const action=[...this.shadowRoot?.querySelectorAll("[data-query-id]")??[]].find(candidate=>candidate.dataset.queryId===pending.targetId)?.querySelector('[part="saved-delete-button"]');if(action){action.focus();return}}this.shadowRoot?.querySelector('[part="save-name-input"]')?.focus()}},"graph-query-removal-focus")}hopOptions(){const limit=finiteInteger(this.hopLimit,6,1,20),options=new Set(Array.from({length:limit},(_,i)=>i+1));return options.add(this._value.minHops),options.add(this._value.maxHops),[...options].sort((a,b)=>a-b)}labelForType(options,value){return options.find(o=>o.value===value)?.label??value}renderTypeFilter(kind,options,selected,add,remove,disabled){const pickerPart=kind==="relationship"?"relationship-picker":"node-type-picker",chipsPart=kind==="relationship"?"relationship-chips":"node-type-chips",pickerLabel=kind==="relationship"?this.localize("graphQueryRelationshipTypeLabel"):this.localize("graphQueryNodeTypeLabel"),available=options.filter(o=>!selected.includes(o.value));return html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{styles}from"./graph-query-builder.styles.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_graphQueryBuilderLabel,LYRA_DEFAULT_graphQueryDeleteWithContext,LYRA_DEFAULT_graphQueryDirectionLabel,LYRA_DEFAULT_graphQueryEndLabel,LYRA_DEFAULT_graphQueryHopRangeInvalid,LYRA_DEFAULT_graphQueryLoadWithContext,LYRA_DEFAULT_graphQueryMaxHopsLabel,LYRA_DEFAULT_graphQueryMinHopsLabel,LYRA_DEFAULT_graphQueryNodeTypeLabel,LYRA_DEFAULT_graphQueryRelationshipTypeLabel,LYRA_DEFAULT_graphQueryRun,LYRA_DEFAULT_graphQuerySaveButton,LYRA_DEFAULT_graphQuerySaveNameLabel,LYRA_DEFAULT_graphQuerySavedQueriesLabel,LYRA_DEFAULT_graphQueryStartLabel,LYRA_DEFAULT_neighborDirectionBoth,LYRA_DEFAULT_neighborDirectionIn,LYRA_DEFAULT_neighborDirectionOut,LYRA_DEFAULT_noData,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const MAX_TYPES=500,MAX_SAVED_QUERIES=200,MAX_TEXT=256,EMPTY_STRINGS=Object.freeze([]),EMPTY_VALUE=Object.freeze({startId:"",endId:"",relationshipTypes:EMPTY_STRINGS,nodeTypes:EMPTY_STRINGS,direction:"both",minHops:1,maxHops:1}),EMPTY_OPTIONS=Object.freeze([]),EMPTY_SAVED=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return typeof value=="string"?value.slice(0,MAX_TEXT):""}function stringArray(value){return Array.isArray(value)?Object.freeze([...new Set(value.slice(0,MAX_TYPES).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)).filter(Boolean))]):EMPTY_STRINGS}function normalizeGraphQuery(value){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,direction=ownValue(record,"direction");return Object.freeze({startId:boundedString(ownValue(record,"startId")),endId:boundedString(ownValue(record,"endId")),relationshipTypes:stringArray(ownValue(record,"relationshipTypes")),nodeTypes:stringArray(ownValue(record,"nodeTypes")),direction:direction==="out"||direction==="in"||direction==="both"?direction:"both",minHops:finiteInteger(typeof ownValue(record,"minHops")=="number"?ownValue(record,"minHops"):EMPTY_VALUE.minHops,EMPTY_VALUE.minHops,1,20),maxHops:finiteInteger(typeof ownValue(record,"maxHops")=="number"?ownValue(record,"maxHops"):EMPTY_VALUE.maxHops,EMPTY_VALUE.maxHops,1,20)})}function normalizeTypeOptions(value){if(!Array.isArray(value))return EMPTY_OPTIONS;const values=new Set,result=[];for(const candidate of value.slice(0,MAX_TYPES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const optionValue=boundedString(ownValue(candidate,"value"));if(optionValue.trim().length===0||values.has(optionValue))continue;values.add(optionValue);const label=boundedString(ownValue(candidate,"label"));result.push(Object.freeze({value:optionValue,...label?{label}:{}}))}return Object.freeze(result)}function normalizeSavedQueries(value){if(!Array.isArray(value))return EMPTY_SAVED;const ids=new Set,result=[];for(const candidate of value.slice(0,MAX_SAVED_QUERIES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));id.trim().length===0||ids.has(id)||(ids.add(id),result.push(Object.freeze({id,name:boundedString(ownValue(candidate,"name")),query:normalizeGraphQuery(ownValue(candidate,"query"))})))}return Object.freeze(result)}class LyraGraphQueryBuilder extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,graphQueryBuilderLabel:LYRA_DEFAULT_graphQueryBuilderLabel,graphQueryDeleteWithContext:LYRA_DEFAULT_graphQueryDeleteWithContext,graphQueryDirectionLabel:LYRA_DEFAULT_graphQueryDirectionLabel,graphQueryEndLabel:LYRA_DEFAULT_graphQueryEndLabel,graphQueryHopRangeInvalid:LYRA_DEFAULT_graphQueryHopRangeInvalid,graphQueryLoadWithContext:LYRA_DEFAULT_graphQueryLoadWithContext,graphQueryMaxHopsLabel:LYRA_DEFAULT_graphQueryMaxHopsLabel,graphQueryMinHopsLabel:LYRA_DEFAULT_graphQueryMinHopsLabel,graphQueryNodeTypeLabel:LYRA_DEFAULT_graphQueryNodeTypeLabel,graphQueryRelationshipTypeLabel:LYRA_DEFAULT_graphQueryRelationshipTypeLabel,graphQueryRun:LYRA_DEFAULT_graphQueryRun,graphQuerySaveButton:LYRA_DEFAULT_graphQuerySaveButton,graphQuerySaveNameLabel:LYRA_DEFAULT_graphQuerySaveNameLabel,graphQuerySavedQueriesLabel:LYRA_DEFAULT_graphQuerySavedQueriesLabel,graphQueryStartLabel:LYRA_DEFAULT_graphQueryStartLabel,neighborDirectionBoth:LYRA_DEFAULT_neighborDirectionBoth,neighborDirectionIn:LYRA_DEFAULT_neighborDirectionIn,neighborDirectionOut:LYRA_DEFAULT_neighborDirectionOut,noData:LYRA_DEFAULT_noData,select:LYRA_DEFAULT_select}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-before-query-run","lr-query-run","lr-before-query-save","lr-query-save","lr-before-query-load","lr-query-load"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get relationshipTypeOptions(){return this._relationshipTypeOptions}set relationshipTypeOptions(value){const previous=this._relationshipTypeOptions;this._relationshipTypeOptions=normalizeTypeOptions(value),this.requestUpdate("relationshipTypeOptions",previous)}get nodeTypeOptions(){return this._nodeTypeOptions}set nodeTypeOptions(value){const previous=this._nodeTypeOptions;this._nodeTypeOptions=normalizeTypeOptions(value),this.requestUpdate("nodeTypeOptions",previous)}get savedQueries(){return this._savedQueries}set savedQueries(value){const previous=this._savedQueries;this._savedQueries=normalizeSavedQueries(value),this.requestUpdate("savedQueries",previous)}constructor(){super(),this._relationshipTypeOptions=EMPTY_OPTIONS,this._nodeTypeOptions=EMPTY_OPTIONS,this._savedQueries=EMPTY_SAVED,this.hopLimit=6,this.label="",this.hint="",this.errorText="",this._errors={},this.touchedFields=new Set,this.saveName="",this.hasHintSlot=!1,this.hasErrorSlot=!1,this.labelId=nextId("graph-query-builder-label"),this.hintId=nextId("graph-query-builder-hint"),this.errorId=nextId("graph-query-builder-error"),this._fieldsetDisabled=!1,this._name="",this._value=EMPTY_VALUE,this.defaultValue=normalizeGraphQuery(EMPTY_VALUE),this.defaultValueCaptured=!1,this._disabled=!1,this.hasInteracted=!1,this.removalFocusGeneration=0,this.onChromeSlotChange=event=>{const slot=event.currentTarget,hasContent=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType===Node.TEXT_NODE?!!node.textContent?.trim():!0);slot.name==="hint"?this.hasHintSlot=hasContent:slot.name==="error"&&(this.hasErrorSlot=hasContent)},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.syncFormState()}disconnectedCallback(){this.removalFocusGeneration++,this.pendingRemovalFocus=void 0,super.disconnectedCallback()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}get value(){return this._value}set value(next){const old=this._value;this._value=normalizeGraphQuery(next),this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.validityController&&this.syncFormState(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&this.validity.customError&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}[VALIDITY_ANCHOR](){const firstInvalidPart=Object.keys(this._errors)[0];if(!(!firstInvalidPart||!this.renderRoot))return this.renderRoot.querySelector(`[part="${firstInvalidPart}"]`)??void 0}computeValidation(){const errors={},flags={};return this._value.startId.trim()||(errors["start-input"]=this.localize("fieldRequired"),flags.valueMissing=!0),this._value.minHops>this._value.maxHops&&(errors["max-hops"]=this.localize("graphQueryHopRangeInvalid"),flags.rangeUnderflow=!0),{errors,flags}}syncFormState(){const{errors,flags}=this.computeValidation();this._errors=errors;let formValue=null;try{formValue=JSON.stringify(this._value)}catch{formValue=null}if(this.internals.setFormValue(formValue,formValue),this.barredFromValidation||Object.keys(flags).length===0)this.validityController.setValidity({});else{const message=Object.values(errors)[0]??"";this.validityController.setValidity(flags,message)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncValidityCustomStates(){syncValidityStates(this.internals,{required:!0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}checkValidity(){return this.syncFormState(),this.internals.checkValidity()}reportValidity(){return this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot()}formResetCallback(){this.hasInteracted=!1,this.captureDefaultValue(),this.value=this.defaultValue,this.touchedFields=new Set,this.saveName=""}captureDefaultValue(){this.defaultValueCaptured||(this.defaultValue=normalizeGraphQuery(this._value),this.defaultValueCaptured=!0)}formStateRestoreCallback(state2,_mode){let restored=EMPTY_VALUE;if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=normalizeGraphQuery(parsed))}catch{}this.value=restored}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.syncFormState(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focusFirstControl(options){if(!this.renderRoot||this.liveDisabled)return;(this.renderRoot.querySelector('[part="start-input"]')||this.renderRoot.querySelector('[part="end-input"]')||this.renderRoot.querySelector('[part="min-hops"]')||this.renderRoot.querySelector('[part="max-hops"]')||this.renderRoot.querySelector('[part="direction"]')||this.renderRoot.querySelector('[part="save-name-input"]'))?.focus(options)}focus(options){this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.shadowRoot);active&&typeof active.blur=="function"&&active.blur()}click(){this.focusFirstControl()}setValue(next){this.effectiveDisabled||(this.hasInteracted=!0,this.value=next,this.emit("lr-input",Object.freeze({value:this._value})))}addRelationshipType(type){!type||this._value.relationshipTypes.includes(type)||this.setValue({...this._value,relationshipTypes:[...this._value.relationshipTypes,type]})}removeRelationshipType(type){this.captureChipRemovalFocus("relationship",type,this._value.relationshipTypes),this.setValue({...this._value,relationshipTypes:this._value.relationshipTypes.filter(t=>t!==type)})}addNodeType(type){!type||this._value.nodeTypes.includes(type)||this.setValue({...this._value,nodeTypes:[...this._value.nodeTypes,type]})}removeNodeType(type){this.captureChipRemovalFocus("node-type",type,this._value.nodeTypes),this.setValue({...this._value,nodeTypes:this._value.nodeTypes.filter(t=>t!==type)})}captureChipRemovalFocus(group,value,selected){const active=this.shadowRoot?.activeElement,expectedPart=group==="relationship"?"relationship-chips":"node-type-chips";if(active?.localName!=="lr-chip"||active.getAttribute("value")!==value||active.closest("lr-chip-group")?.getAttribute("part")!==expectedPart)return;const index=selected.indexOf(value),survivors=selected.filter(candidate=>candidate!==value),targetValue=survivors[Math.min(Math.max(index,0),survivors.length-1)];this.pendingRemovalFocus={kind:"chip",group,targetValue},this.removalFocusGeneration++}markTouched(part){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(part)&&(this.touchedFields=new Set(this.touchedFields).add(part))}runQuery(){if(this.effectiveDisabled||!this.reportValidity())return;const detail=()=>Object.freeze({query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-run",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-run",detail())}saveQuery(){if(this.effectiveDisabled)return;const name=this.saveName.trim();if(!name)return;const detail=()=>Object.freeze({name,query:normalizeGraphQuery(this._value)});this.emit("lr-before-query-save",detail(),{cancelable:!0}).defaultPrevented||(this.saveName="",this.emit("lr-query-save",detail()))}loadQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id,query:normalizeGraphQuery(item.query)});this.emit("lr-before-query-load",detail(),{cancelable:!0}).defaultPrevented||(this.setValue({...EMPTY_VALUE,...item.query}),this.emit("lr-query-load",detail()))}deleteQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id});this.emit("lr-before-query-delete",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-delete",detail())}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.captureDefaultValue(),!changed.has("savedQueries"))return;const active=this.shadowRoot?.activeElement;if(active?.getAttribute("part")!=="saved-delete-button")return;const focusedId=active.closest("[data-query-id]")?.dataset.queryId;if(!focusedId||this.savedQueries.some(item=>item.id===focusedId))return;const index=(changed.get("savedQueries")??[]).findIndex(item=>item.id===focusedId),target=this.savedQueries[Math.min(Math.max(index,0),this.savedQueries.length-1)];this.pendingRemovalFocus={kind:"saved",targetId:target?.id},this.removalFocusGeneration++}updated(changed){super.updated(changed),this.publishValiditySnapshot();const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const generation=this.removalFocusGeneration;this.scheduleAfterUpdate(()=>{if(!(generation!==this.removalFocusGeneration||!this.isConnected)){if(pending.kind==="chip"){if(pending.targetValue){const part=pending.group==="relationship"?"relationship-chips":"node-type-chips",chip=[...this.shadowRoot?.querySelectorAll(`[part="${part}"] lr-chip`)??[]].find(candidate=>candidate.getAttribute("value")===pending.targetValue);if(chip){chip.focus();return}}const pickerPart=pending.group==="relationship"?"relationship-picker":"node-type-picker";this.shadowRoot?.querySelector(`[part="${pickerPart}"]`)?.focus();return}if(pending.targetId){const action=[...this.shadowRoot?.querySelectorAll("[data-query-id]")??[]].find(candidate=>candidate.dataset.queryId===pending.targetId)?.querySelector('[part="saved-delete-button"]');if(action){action.focus();return}}this.shadowRoot?.querySelector('[part="save-name-input"]')?.focus()}},"graph-query-removal-focus")}hopOptions(){const limit=finiteInteger(this.hopLimit,6,1,20),options=new Set(Array.from({length:limit},(_,i)=>i+1));return options.add(this._value.minHops),options.add(this._value.maxHops),[...options].sort((a,b)=>a-b)}labelForType(options,value){return options.find(o=>o.value===value)?.label??value}renderTypeFilter(kind,options,selected,add,remove,disabled){const pickerPart=kind==="relationship"?"relationship-picker":"node-type-picker",chipsPart=kind==="relationship"?"relationship-chips":"node-type-chips",pickerLabel=kind==="relationship"?this.localize("graphQueryRelationshipTypeLabel"):this.localize("graphQueryNodeTypeLabel"),available=options.filter(o=>!selected.includes(o.value));return html`
2
2
  <div part="filter-group" data-kind=${kind}>
3
3
  <lr-select
4
4
  part=${pickerPart}
@@ -87,10 +87,6 @@ import{css}from"lit";const styles=css`
87
87
  border-color: var(--lr-graph-query-builder-save-border-color, var(--lr-color-border));
88
88
  color: var(--lr-graph-query-builder-save-color, var(--lr-color-text));
89
89
  }
90
- /* Mixing the resting fill toward --lr-color-mix-partner (which follows the text colour) rather
91
- than multiplying every channel with filter: brightness(): a filter lightens a dark brand and
92
- darkens a light one only by accident, does nothing at all to a pure white or pure black one,
93
- and -- because it applies to the whole subtree -- shifted this button's label with it. */
94
90
  [part='run-button']:hover {
95
91
  background: var(
96
92
  --lr-graph-query-builder-run-hover-bg,
@@ -188,9 +184,6 @@ import{css}from"lit";const styles=css`
188
184
  [part='saved-load-button']:hover {
189
185
  text-decoration: underline;
190
186
  }
191
- /* The row this button fills has the surface fill, so that -- not the button's own transparent
192
- background -- is the base the pressed tint mixes from; an underline alone cannot get "more
193
- underlined", and loading a saved query replaces the whole form, which is worth acknowledging. */
194
187
  [part='saved-load-button']:active {
195
188
  background: var(
196
189
  --lr-graph-query-builder-saved-load-active-bg,
@@ -221,9 +214,6 @@ import{css}from"lit";const styles=css`
221
214
  [part='saved-delete-button']:hover {
222
215
  color: var(--lr-graph-query-builder-saved-delete-hover-color, var(--lr-color-danger));
223
216
  }
224
- /* Pressed adds the quiet danger fill behind the already-red glyph rather than only deepening the
225
- glyph itself: a colour step on an icon this small is easy to miss, and this is the destructive
226
- control in the row. */
227
217
  [part='saved-delete-button']:active {
228
218
  color: var(
229
219
  --lr-graph-query-builder-saved-delete-active-color,
@@ -32,3 +32,23 @@ export declare function sqrtStep(count: number, max: number, steps: number): num
32
32
  * scale case (the `'sqrt'` scale already has its own discrete `sqrtStep()`).
33
33
  */
34
34
  export declare function linearBucket(value: number, lo: number, hi: number, steps: number): number;
35
+ /**
36
+ * Normalizes `value` to `[0, 1]` around an anchored `midpoint` rather than the plain `lo`-`hi`
37
+ * span, so a diverging ramp's neutral color lands exactly on `midpoint` instead of wherever the
38
+ * data's own midpoint happens to fall.
39
+ *
40
+ * The two halves are scaled independently: `lo`->0, `midpoint`->0.5, `hi`->1. That deliberately
41
+ * does NOT preserve a single units-per-pixel ratio across the whole range — with data running
42
+ * -4.93 to +28.8 around a zero midpoint, an equal color distance means "equally far from
43
+ * neutral in its own direction", which is the entire point of a diverging ramp. A caller wanting
44
+ * a symmetric ramp passes a symmetric `domain` (e.g. `[-28.8, 28.8]`).
45
+ *
46
+ * Falls back to `finiteRatio`'s plain normalization when `midpoint` sits outside `[lo, hi]` or
47
+ * any input is non-finite, so a mis-set midpoint degrades to today's behavior rather than
48
+ * producing a a division by zero.
49
+ */
50
+ export declare function midpointRatio(value: number, lo: number, hi: number, midpoint: number): number;
51
+ /** `linearAlpha`'s midpoint-anchored twin, keeping the same 0.1-1.0 floor. */
52
+ export declare function midpointAlpha(value: number, lo: number, hi: number, midpoint: number): number;
53
+ /** `linearBucket`'s midpoint-anchored twin. */
54
+ export declare function midpointBucket(value: number, lo: number, hi: number, midpoint: number, steps: number): number;
@@ -1 +1 @@
1
- import{finiteRatio}from"../../../internal/numbers.js";function linearAlpha(value,lo,hi){return .1+.9*finiteRatio(value,lo,hi)}function minMax(values){if(values.length===0)return null;let lo=values[0],hi=values[0];for(let i=1;i<values.length;i++){const v=values[i];v<lo&&(lo=v),v>hi&&(hi=v)}return[lo,hi]}function sqrtStep(count,max,steps){if(count<0)return-1;if(max<=0)return 0;const ratio=Math.sqrt(count)/Math.sqrt(max);return Math.min(steps-1,Math.floor(ratio*steps))}function linearBucket(value,lo,hi,steps){const t=finiteRatio(value,lo,hi);return Math.min(steps-1,Math.floor(t*steps))}export{linearAlpha,linearBucket,minMax,sqrtStep};
1
+ import{finiteRatio}from"../../../internal/numbers.js";function linearAlpha(value,lo,hi){return .1+.9*finiteRatio(value,lo,hi)}function minMax(values){if(values.length===0)return null;let lo=values[0],hi=values[0];for(let i=1;i<values.length;i++){const v=values[i];v<lo&&(lo=v),v>hi&&(hi=v)}return[lo,hi]}function sqrtStep(count,max,steps){if(count<0)return-1;if(max<=0)return 0;const ratio=Math.sqrt(count)/Math.sqrt(max);return Math.min(steps-1,Math.floor(ratio*steps))}function linearBucket(value,lo,hi,steps){const t=finiteRatio(value,lo,hi);return Math.min(steps-1,Math.floor(t*steps))}function midpointRatio(value,lo,hi,midpoint){return!Number.isFinite(value)||!Number.isFinite(midpoint)?finiteRatio(value,lo,hi):!Number.isFinite(lo)||!Number.isFinite(hi)?finiteRatio(value,lo,hi):!(midpoint>lo)||!(midpoint<hi)?finiteRatio(value,lo,hi):value<=lo?0:value>=hi?1:value<=midpoint?.5*((value-lo)/(midpoint-lo)):.5+.5*((value-midpoint)/(hi-midpoint))}function midpointAlpha(value,lo,hi,midpoint){return .1+.9*midpointRatio(value,lo,hi,midpoint)}function midpointBucket(value,lo,hi,midpoint,steps){const t=midpointRatio(value,lo,hi,midpoint);return Math.min(steps-1,Math.floor(t*steps))}export{linearAlpha,linearBucket,midpointAlpha,midpointBucket,midpointRatio,minMax,sqrtStep};
@@ -294,6 +294,69 @@ export declare class LyraHeatmap extends LyraElement<LyraHeatmapEventMap> {
294
294
  /** All mode-specific input. Reassign this property after changing caller-owned collections. */
295
295
  data: HeatmapData;
296
296
  private get effectiveMode();
297
+ /**
298
+ * Width, in CSS px, of the matrix row-label gutter, or `'auto'` to measure the widest label and
299
+ * size the gutter to fit (never below the built-in 60px, never above 40% of the host's width, so
300
+ * one long label cannot squeeze out the cells it exists to describe).
301
+ *
302
+ * Unset keeps the built-in 60px. That default is deliberate: auto-sizing every existing heatmap
303
+ * would silently reflow charts whose labels already fit, which is a bigger change than the
304
+ * clipping it fixes. Opt in per chart, or pin an exact figure.
305
+ *
306
+ * Independently of this, a row label too wide for the resolved gutter is now truncated with an
307
+ * ellipsis instead of being clipped mid-glyph by whatever is painted beside it -- clipping read
308
+ * as a rendering fault, truncation reads as "there is more here". `cellText` still carries the
309
+ * full label to the tooltip and the keyboard announcement either way.
310
+ *
311
+ * Calendar mode is unaffected; it has its own fixed weekday gutter.
312
+ */
313
+ rowLabelWidth?: number | 'auto';
314
+ /**
315
+ * Height, in CSS px, of the matrix column-label band, or `"auto"` to measure the labels and size
316
+ * the band to fit them (never below the built-in 20px, and bounded above by a sanity ceiling so a
317
+ * pathological label cannot produce an absurd canvas). Under a non-zero
318
+ * `colLabelRotation` the measurement projects each label's width through the rotation, which is
319
+ * what makes a rotated axis usable without hand-tuning a magic number.
320
+ *
321
+ * Unset keeps the built-in 20px, for the same reason `rowLabelWidth` does: auto-sizing every
322
+ * existing heatmap would silently reflow charts whose labels already fit.
323
+ */
324
+ colLabelHeight?: number | 'auto';
325
+ /**
326
+ * Rotation, in degrees, applied to matrix column labels. Unset (or `0`) paints them horizontally
327
+ * exactly as before. In a dense matrix the per-column width is far narrower than a typical label,
328
+ * so horizontal labels collide with their neighbours; `45` or `90` is the standard remedy.
329
+ *
330
+ * Each label is rotated about an anchor at its own column's centre, with the label's *end* at the
331
+ * anchor, so it leans up and back over the columns to its left and the last column's label cannot
332
+ * overflow the canvas. Values outside `[0, 90]` clamp into it and non-finite values normalize to
333
+ * `0`; a rotation is not a coordinate a caller can usefully be surprised by.
334
+ *
335
+ * Pair with `colLabelHeight="auto"` to have the band size itself to the rotated extent.
336
+ *
337
+ * Not mirrored under `dir="rtl"`: both grid modes deliberately retain physical LTR geometry (see
338
+ * the class doc), and leaning one axis' labels the other way while the grid itself stays physical
339
+ * would be incoherent.
340
+ */
341
+ colLabelRotation?: number;
342
+ /** Column band resolved during the last draw, mirroring `resolvedRowLabelWidth`. */
343
+ private resolvedColLabelHeight;
344
+ /** Normalized rotation in degrees: finite, clamped to `[0, 90]`. */
345
+ private get effectiveColLabelRotation();
346
+ /** Gutter resolved during the last draw, so hit-testing between draws agrees with what was
347
+ * painted. Only ever differs from the default while `rowLabelWidth="auto"`. */
348
+ private resolvedRowLabelWidth;
349
+ private get matrixPadLeft();
350
+ private get matrixPadTop();
351
+ /** Tallest rotated column label plus inset, floored at the built-in band and capped so labels can
352
+ * never crowd out the matrix. The column mirror of `measureRowLabelWidth()`. */
353
+ private measureColLabelHeight;
354
+ /** Widest row label plus insets, floored at the built-in gutter and capped so labels can never
355
+ * crowd out the matrix itself. Measured against the same font the labels are drawn with. */
356
+ private measureRowLabelWidth;
357
+ /** Trims `label` to fit `maxWidth`, ending in an ellipsis. Returns `''` when not even one
358
+ * character plus the ellipsis fits, which is honest: a single clipped glyph reads as data. */
359
+ private ellipsize;
297
360
  private get matrixRowLabels();
298
361
  private get matrixColLabels();
299
362
  private get matrixValues();
@@ -322,12 +385,48 @@ export declare class LyraHeatmap extends LyraElement<LyraHeatmapEventMap> {
322
385
  * rest of a skewed dataset.
323
386
  */
324
387
  scale: HeatmapScale;
388
+ /**
389
+ * Pins the color ramp's input domain to `[min, max]` instead of deriving it from the data's own
390
+ * extremes. Unset (the default) keeps today's behavior exactly: the ramp spans the data's own
391
+ * min-max, so two heatmaps of comparable data each normalize to their own extremes and cannot be
392
+ * read against each other. Setting it also opts the component into **signed data** (see
393
+ * `signedDomain`), because declaring a domain is what disambiguates a negative value from the
394
+ * no-data sentinel. A reversed or degenerate pair falls back to the derived range.
395
+ */
396
+ domain?: [number, number];
397
+ /**
398
+ * Anchors a diverging ramp's neutral color on this value rather than at the middle of the
399
+ * domain, scaling the two halves independently (`lo`->0, `midpoint`->0.5, `hi`->1). Unset (the
400
+ * default) leaves the plain min-max normalization untouched. Like `domain`, setting it opts into
401
+ * signed data. A midpoint outside the resolved domain degrades to plain normalization rather
402
+ * than distorting the ramp.
403
+ */
404
+ midpoint?: number;
405
+ /**
406
+ * Whether the consumer has declared signed data, by pinning `domain` or anchoring `midpoint`.
407
+ *
408
+ * This gates the negative-value contract. By default a negative value is no-data, matching the
409
+ * long-documented `-1` sentinel -- a matrix of counts has no meaningful negative and consumers
410
+ * rely on that. A consumer who supplies a domain or midpoint has explicitly said the data is
411
+ * signed, at which point silently dropping the whole negative half (32.7% of cells in the report
412
+ * that prompted this) is the defect, not the feature. In signed mode only a non-finite value is
413
+ * no-data; an absent matrix cell reads as `NaN`, so it stays no-data in both modes.
414
+ */
415
+ private get signedDomain();
416
+ /** Ramp position in `[0, 1]` for `value`, midpoint-anchored when `midpoint` is set. Every fill
417
+ * path goes through this pair so the diverging anchor can never apply to some cells and not
418
+ * others. */
419
+ private rampAlpha;
420
+ /** `rampAlpha`'s discrete twin, for a `colorSteps` ramp. */
421
+ private rampBucket;
422
+ /** Whether `value` paints as no-data, honoring the signed-domain contract above. */
423
+ private isNoData;
325
424
  /**
326
425
  * When set, `cellSize` is derived from the host's measured `clientWidth`
327
426
  * on every draw (including ResizeObserver-triggered redraws) instead of
328
427
  * the fixed `cell-size` attribute, so the grid actually fills the
329
428
  * available width. Without this, canvas dimensions are computed purely
330
- * from `PAD_LEFT + cols * cellSize` (matrix mode) or
429
+ * from `matrixPadLeft + cols * cellSize` (matrix mode) or
331
430
  * `CAL_PAD_LEFT + weekCount * cellSize` (calendar mode), so a
332
431
  * resize-triggered redraw is a geometric no-op. Originally matrix-mode
333
432
  * only; now applies to calendar mode too.
@@ -531,6 +630,23 @@ export declare class LyraHeatmap extends LyraElement<LyraHeatmapEventMap> {
531
630
  private cachedCalendarCellsByPos;
532
631
  private cachedCalendarCellsByDate;
533
632
  private cachedAnnotations;
633
+ /**
634
+ * Dev-mode-only: warns when `legendStops` describes colors the cells are not actually painted
635
+ * from.
636
+ *
637
+ * `colorSteps` supplies the cell ramp and `legendStops` supplies the key, deliberately without
638
+ * feeding back into each other -- that independence is what lets a `cellColor` consumer describe
639
+ * a ramp the grid no longer uses. The cost is that a consumer building a diverging ramp supplies
640
+ * both by hand and nothing checks they agree, so a legend can confidently label colors that never
641
+ * appear. A wrong legend is worse than no legend, because the reader trusts it, and the mismatch
642
+ * is invisible both in review and at runtime.
643
+ *
644
+ * Warning rather than deriving one from the other: deriving would silently change what an
645
+ * existing `colorSteps`-only consumer sees, and would also break the deliberate `cellColor`
646
+ * escape hatch. This keeps every current behavior and only makes the disagreement audible.
647
+ * Compares only the stops that carry a color -- a caption-only stop describes no color at all.
648
+ */
649
+ private warnOnLegendRampMismatch;
534
650
  private cachedLegendStops;
535
651
  private cachedColorSteps;
536
652
  private cachedCalendarAnnotationDates;
@@ -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{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{finiteInteger,finiteRange}from"../../../internal/numbers.js";import{getScratchCtx}from"../../../internal/canvas.js";import{resolveCssLength}from"../../../internal/css-length.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{activeElementIn}from"../../../internal/active-element.js";import{linearAlpha,linearBucket,minMax,sqrtStep}from"./heatmap-scale.js";import{styles}from"./heatmap.styles.js";import{buildCalendarGrid,parseIsoDate,quartileBucket}from"./calendar-grid.js";import{getDateTimeFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_heatmapCalendarCellLabel,LYRA_DEFAULT_heatmapCalendarLabel,LYRA_DEFAULT_heatmapDecorationLimit,LYRA_DEFAULT_heatmapDefaultColLabel,LYRA_DEFAULT_heatmapDefaultRowLabel,LYRA_DEFAULT_heatmapMatrixCellLabel,LYRA_DEFAULT_heatmapMatrixLabel,LYRA_DEFAULT_heatmapNoDataValue,LYRA_DEFAULT_heatmapProjectionLimit,LYRA_DEFAULT_heatmapSelectedCellLabel,LYRA_DEFAULT_heatmapValueLabel}from"../../../internal/default-strings.generated.js";const PAD_LEFT=60,PAD_TOP=20,FALLBACK_NO_DATA_FILL="rgba(128,128,128,0.25)",RAMP_STEPS=7,FALLBACK_SCALE_LO="#cde2fb",FALLBACK_SCALE_HI="#0969da",FALLBACK_LABEL_FONT="10px system-ui, sans-serif",CAL_PAD_LEFT=28,CAL_LABEL_H=16,CAL_CELL=11,CAL_GAP=2,DEFAULT_MATRIX_CELL_SIZE=22,DEFAULT_ACCESSIBLE_TARGET_SIZE_PX=40,DEFAULT_BUCKET_COUNT=5,FIT_MIN_CELL=4,MAX_BUCKET_COUNT=256,MAX_HEATMAP_CELLS=1e4,MAX_HEATMAP_DECORATIONS=256,MAX_ACCESSIBLE_HEATMAP_CELLS=400,RING_LINE_WIDTH=2,FALLBACK_FOCUS_RING_COLOR="#0969da",FALLBACK_ANNOTATION_COLOR="#cf222e",FALLBACK_SELECTED_COLOR="#1a7f37",ARROW_KEYS=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),MS_PER_DAY=864e5;function isoDateAtOffset(firstWeekStart,dayOffset){return new Date(firstWeekStart.getTime()+dayOffset*MS_PER_DAY).toISOString().slice(0,10)}const HEX_RE=/^([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,RGB_RE=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/i;function hexToRgb(hex){const clean=hex.trim().replace("#","");if(!HEX_RE.test(clean))return null;const hasAlpha=clean.length===4||clean.length===8,full=clean.length<=4?clean.split("").map(c=>c+c).join(""):clean,num=Number.parseInt(full,16);return hasAlpha?[num>>>24&255,num>>>16&255,num>>>8&255,(num&255)/255]:[num>>16&255,num>>8&255,num&255,1]}function parseRgbString(value){const match=RGB_RE.exec(value);if(!match)return null;const a=match[4]===void 0?1:Number(match[4]);return[Number(match[1]),Number(match[2]),Number(match[3]),a]}function resolveViaPixelReadback(ctx){try{ctx.clearRect(0,0,1,1),ctx.fillRect(0,0,1,1);const[r=0,g=0,b=0,a=0]=ctx.getImageData(0,0,1,1).data;return[r,g,b,a/255]}catch{return null}}function formatRgb([r,g,b,a]){const alpha=Math.min(1,Math.max(0,a));return alpha>=1?`rgb(${r}, ${g}, ${b})`:`rgba(${r}, ${g}, ${b}, ${Math.round(alpha*1e3)/1e3})`}const warnedInvalidColors=new Set;function warnInvalidColor(color){warnedInvalidColors.has(color)||(warnedInvalidColors.add(color),console.warn(`<lr-heatmap> could not parse "${color}" (set via --lr-heatmap-scale-lo/-hi) as a CSS color; falling back to the default ramp endpoint.`))}let warnedNoCanvasContext=!1;function warnNoCanvasContext(){warnedNoCanvasContext||(warnedNoCanvasContext=!0,console.warn("<lr-heatmap>: no 2D canvas context is available in this environment; color resolution for non-hex/non-rgb values (e.g. oklch(), color(srgb ...), named colors) will fall back to the given default instead of resolving the requested color."))}function normalizeBucketCount(bucketCount){return finiteInteger(bucketCount,DEFAULT_BUCKET_COUNT,2,MAX_BUCKET_COUNT)}const optionalCellSizeConverter={fromAttribute(value){if(value===null||value.trim()==="")return;const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0},toAttribute(value){return value==null?null:String(value)}},DEFAULT_MATRIX_DATA=Object.freeze({kind:"matrix",rowLabels:Object.freeze([]),colLabels:Object.freeze([]),values:Object.freeze([])});function normalizeCellSizeClamp(value){if(!(value==null||!Number.isFinite(value)))return finiteRange(value,FIT_MIN_CELL,FIT_MIN_CELL)}const bucketCountConverter={fromAttribute(value){return value===null?DEFAULT_BUCKET_COUNT:normalizeBucketCount(Number(value))},toAttribute(value){return String(normalizeBucketCount(value))}};function resolveRgb(color,fallbackHex,ownerDocument){const fallback=hexToRgb(fallbackHex)??[0,0,0,1],direct=hexToRgb(color);if(direct)return direct;const ctx=getScratchCtx(ownerDocument);if(!ctx)return warnNoCanvasContext(),fallback;const sentinel="rgb(1, 2, 3)";ctx.fillStyle=sentinel;const sentinelNormalized=ctx.fillStyle;if(ctx.fillStyle=color,ctx.fillStyle===sentinelNormalized&&color.trim()!==sentinel)return warnInvalidColor(color),fallback;const normalized=ctx.fillStyle;return hexToRgb(normalized)??parseRgbString(normalized)??resolveViaPixelReadback(ctx)??fallback}function mixRgb(from,to,t){const clamped=Math.min(1,Math.max(0,t)),r=Math.round(from[0]+(to[0]-from[0])*clamped),g=Math.round(from[1]+(to[1]-from[1])*clamped),b=Math.round(from[2]+(to[2]-from[2])*clamped),a=from[3]+(to[3]-from[3])*clamped;return formatRgb([r,g,b,a])}class LyraHeatmap extends LyraElement{static{this.defaultStrings={...super.defaultStrings,heatmapCalendarCellLabel:LYRA_DEFAULT_heatmapCalendarCellLabel,heatmapCalendarLabel:LYRA_DEFAULT_heatmapCalendarLabel,heatmapDecorationLimit:LYRA_DEFAULT_heatmapDecorationLimit,heatmapDefaultColLabel:LYRA_DEFAULT_heatmapDefaultColLabel,heatmapDefaultRowLabel:LYRA_DEFAULT_heatmapDefaultRowLabel,heatmapMatrixCellLabel:LYRA_DEFAULT_heatmapMatrixCellLabel,heatmapMatrixLabel:LYRA_DEFAULT_heatmapMatrixLabel,heatmapNoDataValue:LYRA_DEFAULT_heatmapNoDataValue,heatmapProjectionLimit:LYRA_DEFAULT_heatmapProjectionLimit,heatmapSelectedCellLabel:LYRA_DEFAULT_heatmapSelectedCellLabel,heatmapValueLabel:LYRA_DEFAULT_heatmapValueLabel}}static{this.ownedCollectionProperties=Object.freeze(["data","annotations","legendStops","colorSteps"])}static{this.identityCollectionObjectProperties=Object.freeze(["data"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"role"])]}get effectiveMode(){return this.data.kind}get matrixRowLabels(){return this.cachedMatrixData.rowLabels}get matrixColLabels(){return this.cachedMatrixData.colLabels}get matrixValues(){return this.cachedMatrixData.values}get calendarDays(){return this.data.kind==="calendar"?this.data.days:[]}get calendarData(){return this.data.kind==="calendar"?this.data:void 0}get cellSize(){return this._cellSize??(this.effectiveMode==="calendar"?CAL_CELL:DEFAULT_MATRIX_CELL_SIZE)}set cellSize(value){const oldValue=this._cellSize;this._cellSize=value==null?void 0:finiteRange(value,this.effectiveMode==="calendar"?CAL_CELL:DEFAULT_MATRIX_CELL_SIZE,1),this.requestUpdate("cellSize",oldValue)}get maxCellSize(){return this._maxCellSize}set maxCellSize(value){const oldValue=this._maxCellSize;this._maxCellSize=normalizeCellSizeClamp(value),this.requestUpdate("maxCellSize",oldValue)}get minCellSize(){return this._minCellSize}set minCellSize(value){const oldValue=this._minCellSize;this._minCellSize=normalizeCellSizeClamp(value),this.requestUpdate("minCellSize",oldValue)}get normalizedFirstDayOfWeek(){return(finiteInteger(this.calendarData?.firstDayOfWeek??0,0)%7+7)%7}get bucketCount(){return this._bucketCount}set bucketCount(value){const oldValue=this._bucketCount;this._bucketCount=normalizeBucketCount(value),this.requestUpdate("bucketCount",oldValue)}get calendarWeekdayLabelText(){return this.calendarData?.weekdayLabelText}get calendarMonthLabelText(){return this.calendarData?.monthLabelText}get calendarColumnX(){return this.calendarData?.columnX}get calendarRowY(){return this.calendarData?.rowY}constructor(){super(),this.data=DEFAULT_MATRIX_DATA,this.scale="linear",this.fitToWidth=!1,this._bucketCount=DEFAULT_BUCKET_COUNT,this.annotations=[],this.selectedCell=null,this.accessibleCells=!1,this.cachedValueRange=null,this.cachedMatrixData={rowLabels:[],colLabels:[],values:[],truncated:!1},this.cachedCalendarGrid=buildCalendarGrid(this.calendarDays),this.cachedCalendarSortedValues=[],this.cachedCalendarCellsByPos=new Map,this.cachedCalendarCellsByDate=new Map,this.cachedAnnotations=[],this.cachedLegendStops=[],this.cachedColorSteps=[],this.cachedCalendarAnnotationDates=new Set,this.cachedMatrixAnnotationPositions=new Set,this.decorationProjectionTruncated=!1,this.cachedCalendarDateByPos=[],this.cachedAccessiblePositions=[],this.cachedAccessiblePositionsByKey=new Map,this.cachedAccessiblePositionIndexByKey=new Map,this.cachedRamp=null,this.canvasHasContent=!1,this.canvasVisible=!0,this.drawDirty=!1,this.hoverCell=null,this.focusedCell=null,this.liveText="",this.accessibleTargetSizePx=DEFAULT_ACCESSIBLE_TARGET_SIZE_PX,this.restoringAccessibleFocus=!1,this.accessibleFocusGeneration=0,this.authorRole=null,this.authorAriaLabel=null,this.generatedAriaLabel="",this.syncingGeneratedSemantics=!1,this.onDprChange=()=>{this.watchDpr(),this.requestDraw()},this.scheduleDraw=()=>{if(this.drawFrameRequest)return;const owner=this.ownerDocument.defaultView;if(!owner||!this.isConnected)return;const request={owner,handle:0};request.handle=owner.requestAnimationFrame(()=>{this.drawFrameRequest===request&&(this.drawFrameRequest=void 0,this.isConnected&&this.ownerDocument.defaultView===owner&&this.requestDraw())}),this.drawFrameRequest=request},this.onPointerMove=e=>{const next=this.hitTest(e.offsetX,e.offsetY);this.samePos(this.hoverCell,next)||(this.hoverCell=next)},this.onPointerLeave=()=>{this.hoverCell=null},this.onCanvasClick=e=>{const pos=this.hitTest(e.offsetX,e.offsetY);pos&&(this.focusedCell=pos,this.announce(pos),this.emitCellClick(pos))},this.onKeyDown=e=>{this.effectiveMode==="calendar"?this.onCalendarKeyDown(e):this.onMatrixKeyDown(e)},this.canvasColorCache=new Map,this.onAccessibleCellFocus=e=>{if(this.restoringAccessibleFocus)return;const key=e.currentTarget.dataset.cellKey,pos=key?this.accessibleCellAtKey(key):null;pos&&(this.focusedCell=pos,this.announce(pos))},this.onAccessibleCellClick=e=>{const key=e.currentTarget.dataset.cellKey,pos=key?this.accessibleCellAtKey(key):null;pos&&(this.focusedCell=pos,this.announce(pos),this.emitCellClick(pos))},this.onAccessibleCellKeyDown=e=>{if(!ARROW_KEYS.has(e.key))return;const key=e.currentTarget.dataset.cellKey,pos=key?this.accessibleCellAtKey(key):null;pos&&(e.preventDefault(),this.focusedCell=pos,this.onKeyDown(e),this.focusAccessibleCell(this.focusedCell))},new ThemeWatcher(this,()=>this.refreshTheme())}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),!(oldValue===value||this.syncingGeneratedSemantics)&&(name==="role"&&(this.authorRole=value),name==="aria-label"&&(this.authorAriaLabel=value))}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink(),this.refreshAccessibleTargetSize();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;if(owner&&ResizeObserverCtor){let observer;observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleDraw()}),this.resizeObserver=observer,observer.observe(this)}const IntersectionObserverCtor=owner?.IntersectionObserver;if(this.canvasVisible=!0,owner&&IntersectionObserverCtor){let observer;observer=new IntersectionObserverCtor(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==owner||this.intersectionObserver!==observer)return;const entry=entries.find(candidate=>candidate.target===this);!entry||entry.isIntersecting===this.canvasVisible||(this.canvasVisible=entry.isIntersecting,this.canvasVisible&&this.drawDirty&&this.scheduleDraw())}),this.intersectionObserver=observer,observer.observe(this)}this.cachedRamp=null,this.canvasColorCache.clear(),this.watchDpr()}disconnectedCallback(){super.disconnectedCallback(),this.accessibleFocusGeneration++,this.pendingAccessibleFocus=void 0,this.pendingAccessibleFocusOrigin=void 0,this.restoringAccessibleFocus=!1,this.releaseAnnouncementSink(),this.hoverCell=null,this.focusedCell=null,this.liveText="",this.canvasHasContent=!1,this.drawDirty=!0,this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.canvasVisible=!0,this.clearDprWatcher(),this.cancelDrawFrame()}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}))}watchDpr(){this.clearDprWatcher();const owner=this.ownerDocument.defaultView;if(!owner||typeof owner.matchMedia!="function")return;const query2=owner.matchMedia(`(resolution: ${owner.devicePixelRatio}dppx)`),listener=()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.dprQuery!==query2||this.onDprChange()};this.dprQuery=query2,this.dprChangeListener=listener,query2.addEventListener("change",listener)}clearDprWatcher(){this.dprQuery&&this.dprChangeListener&&this.dprQuery.removeEventListener("change",this.dprChangeListener),this.dprQuery=void 0,this.dprChangeListener=void 0}willUpdate(changed){super.willUpdate(changed),(changed.has("data")||!this.hasUpdated)&&this.rebuildCanonicalMatrixData(),(changed.has("annotations")||changed.has("legendStops")||changed.has("colorSteps")||!this.hasUpdated)&&this.rebuildBoundedDecorations();const accessibleModeChanged=changed.has("accessibleCells")&&this.hasUpdated,collectionChanged=changed.has("data")||changed.has("cellInteractive"),activeRenderedControl=collectionChanged||accessibleModeChanged?activeElementIn(this.shadowRoot):null,activeAccessibleCell=activeRenderedControl?.matches('[part="cell"]')?activeRenderedControl:null,renderedAccessibleCells=activeAccessibleCell?.matches('[part="cell"]')?[...this.shadowRoot?.querySelectorAll('[part="cell"]')??[]]:[],accessibleFocusSnapshot=activeAccessibleCell?.matches('[part="cell"]')?{identity:activeAccessibleCell.dataset.cellIdentity,index:renderedAccessibleCells.indexOf(activeAccessibleCell)}:void 0;if(collectionChanged&&(this.focusedCell=null,this.hoverCell=null,this.liveText=""),changed.has("data")||changed.has("locale")||!this.hasUpdated){this.cachedCalendarGrid=buildCalendarGrid(this.calendarDays,this.normalizedFirstDayOfWeek,this.calendarMonthLabelText,this.effectiveLocale),this.cachedCalendarSortedValues=this.cachedCalendarGrid.cells.map(cell=>cell.value).filter(value=>Number.isFinite(value)&&value>=0).sort((a,b)=>a-b),this.cachedCalendarCellsByPos=new Map(this.cachedCalendarGrid.cells.map(cell=>[`${cell.week}:${cell.weekday}`,cell])),this.cachedCalendarCellsByDate=new Map(this.cachedCalendarGrid.cells.map(cell=>[cell.date,cell]));const{firstWeekStart,weekCount}=this.cachedCalendarGrid;this.cachedCalendarDateByPos=Array.from({length:weekCount*7},(_,index)=>isoDateAtOffset(firstWeekStart,index))}if(changed.has("colorSteps")||!this.hasUpdated){const colorSteps=this.cachedColorSteps.map(sanitizeCssColor);colorSteps.length>=2&&colorSteps.every(color=>color!==void 0)?this.style.setProperty("--lr-heatmap-color-steps-gradient",`linear-gradient(to right, ${colorSteps.join(", ")})`):this.style.removeProperty("--lr-heatmap-color-steps-gradient")}if((changed.has("data")||!this.hasUpdated)&&(this.cachedValueRange=this.computeValueRange()),(collectionChanged||!this.hasUpdated)&&this.rebuildAccessiblePositions(),accessibleFocusSnapshot){const positions=this.accessibleCellPositions(),target=(accessibleFocusSnapshot.identity==null?void 0:positions.find(pos=>this.accessibleCellIdentity(pos)===accessibleFocusSnapshot.identity))??positions[Math.min(Math.max(accessibleFocusSnapshot.index,0),positions.length-1)]??null;this.focusedCell=target,this.liveText=target?this.resolveCellText(target):"",this.pendingAccessibleFocus=target??"base",this.pendingAccessibleFocusOrigin=activeAccessibleCell??void 0,this.restoringAccessibleFocus=!0,this.accessibleFocusGeneration++}if(accessibleModeChanged){const previouslyAccessible=changed.get("accessibleCells")===!0;if(previouslyAccessible&&!this.accessibleCells&&activeAccessibleCell){const key=activeAccessibleCell.dataset.cellKey,target=key?this.accessibleCellAtKey(key):null;target&&(this.focusedCell=target,this.liveText=this.resolveCellText(target)),this.pendingAccessibleFocus="canvas",this.pendingAccessibleFocusOrigin=activeAccessibleCell,this.restoringAccessibleFocus=!0,this.accessibleFocusGeneration++}else if(!previouslyAccessible&&this.accessibleCells&&activeRenderedControl?.matches('[part="canvas"]')){const positions=this.accessibleCellPositions(),target=this.focusedCell?positions.find(pos=>this.samePos(pos,this.focusedCell))??positions[0]??null:positions[0]??null;this.focusedCell=target,this.liveText=target?this.resolveCellText(target):"",this.pendingAccessibleFocus=target??"base",this.pendingAccessibleFocusOrigin=activeRenderedControl,this.restoringAccessibleFocus=!0,this.accessibleFocusGeneration++}}const bounds=this.cachedValueRange,range=bounds?`${this.formatNumericValue(bounds[0])}\u2013${this.formatNumericValue(bounds[1])}`:this.localize("heatmapNoDataValue"),valueLabel=this.localizedValueLabel();let label;if(this.effectiveMode==="calendar")label=this.localize("heatmapCalendarLabel",void 0,{days:this.formatCount(this.cachedCalendarGrid.cells.length),label:valueLabel,range});else{const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;label=this.localize("heatmapMatrixLabel",void 0,{rows:this.formatCount(rows),cols:this.formatCount(cols),label:valueLabel,range})}const selectedText=this.selectedCellDescription(),generatedAriaLabel=[label,selectedText,this.projectionDescription()].filter(Boolean).join(" ");this.generatedAriaLabel=generatedAriaLabel,this.syncingGeneratedSemantics=!0;try{this.authorRole===null&&this.setAttribute("role","group"),this.authorAriaLabel===null&&this.setAttribute("aria-label",generatedAriaLabel)}finally{this.syncingGeneratedSemantics=!1}}rebuildBoundedDecorations(){this.cachedAnnotations=this.annotations.slice(0,MAX_HEATMAP_DECORATIONS).map(entry=>({...entry})),this.cachedLegendStops=(this.legendStops??[]).slice(0,MAX_HEATMAP_DECORATIONS).map(entry=>({...entry})),this.cachedColorSteps=(this.colorSteps??[]).slice(0,MAX_HEATMAP_DECORATIONS),this.cachedCalendarAnnotationDates=new Set(this.cachedAnnotations.flatMap(annotation=>annotation.date==null?[]:[annotation.date])),this.cachedMatrixAnnotationPositions=new Set(this.cachedAnnotations.flatMap(annotation=>annotation.row==null||annotation.col==null?[]:[`${annotation.row}:${annotation.col}`])),this.decorationProjectionTruncated=this.annotations.length>MAX_HEATMAP_DECORATIONS||(this.legendStops?.length??0)>MAX_HEATMAP_DECORATIONS||(this.colorSteps?.length??0)>MAX_HEATMAP_DECORATIONS}get projectionTruncated(){return this.decorationProjectionTruncated||(this.effectiveMode==="calendar"?this.cachedCalendarGrid.truncated:this.cachedMatrixData.truncated)}get cellProjectionTruncated(){return this.effectiveMode==="calendar"?this.cachedCalendarGrid.truncated:this.cachedMatrixData.truncated}projectedCellCount(){return this.effectiveMode==="calendar"?this.cachedCalendarGrid.weekCount*7:this.matrixRowLabels.length*this.matrixColLabels.length}projectionDescription(){const messages=[];return this.cellProjectionTruncated&&messages.push(this.localize("heatmapProjectionLimit",void 0,{count:this.formatCount(this.projectedCellCount())})),this.decorationProjectionTruncated&&messages.push(this.localize("heatmapDecorationLimit",void 0,{count:this.formatCount(MAX_HEATMAP_DECORATIONS)})),messages.join(" ")}rebuildCanonicalMatrixData(){if(this.data.kind!=="matrix"){this.cachedMatrixData={rowLabels:[],colLabels:[],values:[],truncated:!1};return}const colCount=Math.min(this.data.colLabels.length,MAX_HEATMAP_CELLS),rowLimit=colCount===0?Math.min(this.data.rowLabels.length,MAX_HEATMAP_CELLS):Math.floor(MAX_HEATMAP_CELLS/colCount),rowCount=Math.min(this.data.rowLabels.length,rowLimit),rowLabels=this.data.rowLabels.slice(0,rowCount).map(String),colLabels=this.data.colLabels.slice(0,colCount).map(String),source=this.data,values=Array.from({length:rowCount},(_,row)=>Array.from({length:colCount},(_2,col)=>source.values[row]?.[col]??-1));this.cachedMatrixData={rowLabels,colLabels,values,truncated:rowCount!==this.data.rowLabels.length||colCount!==this.data.colLabels.length||this.data.values.some((row,index)=>index>=rowCount||row.length>colCount)}}selectedCellDescription(){if(!this.selectedCell)return"";if(this.effectiveMode==="calendar"){if(this.selectedCell.date==null)return"";const match=this.cachedCalendarCellsByDate.get(this.selectedCell.date);return match?this.localize("heatmapSelectedCellLabel",void 0,{cell:this.calendarCellText({week:match.week,weekday:match.weekday,date:match.date})}):""}const{row,col}=this.selectedCell;return row==null||col==null||row<0||row>=this.matrixRowLabels.length||col<0||col>=this.matrixColLabels.length?"":this.localize("heatmapSelectedCellLabel",void 0,{cell:this.matrixCellText({row,col})})}computeValueRange(){const source=this.effectiveMode==="calendar"?this.cachedCalendarGrid.cells.map(cell=>cell.value):this.matrixValues.flat();return minMax(source.filter(v=>Number.isFinite(v)&&v>=0))}localizedValueLabel(){return this.valueLabel===void 0?this.localize("heatmapValueLabel"):this.valueLabel}formatNumericValue(value){return getNumberFormat(this.effectiveLocale||void 0).format(value)}updated(changed){if(super.updated(changed),["data","cellSize","maxCellSize","minCellSize","valueLabel","scale","fitToWidth","bucketCount","annotations","focusedCell","colorSteps","cellColor","selectedCell","legendStops","accessibleCells","accessibleTargetSizePx","locale"].some(name=>changed.has(name))){if(changed.has("focusedCell")&&[...changed.keys()].every(key=>key==="focusedCell"||key==="liveText")&&this.repaintFocusRing(changed.get("focusedCell")))return;this.requestDraw()}const pending=this.pendingAccessibleFocus;if(pending===void 0)return;this.pendingAccessibleFocus=void 0;const origin=this.pendingAccessibleFocusOrigin;this.pendingAccessibleFocusOrigin=void 0;const generation=this.accessibleFocusGeneration;this.scheduleAfterUpdate(()=>{try{if(generation!==this.accessibleFocusGeneration||!this.isConnected)return;if(origin){const internalActive=activeElementIn(this.shadowRoot),documentActive=activeElementIn(this.ownerDocument),focusStayedAtOrigin=internalActive===origin,originWasRemovedWithoutReplacement=internalActive===null&&(documentActive===null||documentActive===this||documentActive===this.ownerDocument.body);if(!focusStayedAtOrigin&&!originWasRemovedWithoutReplacement)return}if(pending==="base"){this.shadowRoot?.querySelector('[part="base"]')?.focus();return}if(pending==="canvas"){this.shadowRoot?.querySelector('[part="canvas"]')?.focus();return}const identity=this.accessibleCellIdentity(pending);[...this.shadowRoot?.querySelectorAll('[part="cell"]')??[]].find(candidate=>candidate.dataset.cellIdentity===identity)?.focus()}finally{this.restoringAccessibleFocus=!1}},"heatmap-accessible-focus")}refreshTheme(){this.cachedRamp=null,this.refreshAccessibleTargetSize()||this.requestDraw()}refreshAccessibleTargetSize(){const raw=this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue("--lr-icon-button-size").trim()??"",resolved=resolveCssLength(raw,{host:this}),next=resolved!==void 0&&Number.isFinite(resolved)&&resolved>0?resolved:DEFAULT_ACCESSIBLE_TARGET_SIZE_PX;return next===this.accessibleTargetSizePx?!1:(this.accessibleTargetSizePx=next,!0)}scaleEndpoints(cs){const lo=cs.getPropertyValue("--lr-heatmap-scale-lo").trim()||cs.getPropertyValue("--_lr-heatmap-scale-lo").trim()||FALLBACK_SCALE_LO,hi=cs.getPropertyValue("--lr-heatmap-scale-hi").trim()||cs.getPropertyValue("--_lr-heatmap-scale-hi").trim()||FALLBACK_SCALE_HI;return[lo,hi]}labelColor(cs){return cs.getPropertyValue("--lr-color-text-quiet").trim()||"#6b7280"}labelFont(cs){return cs.getPropertyValue("--lr-heatmap-label-font").trim()||cs.getPropertyValue("--_lr-heatmap-label-font").trim()||FALLBACK_LABEL_FONT}noDataFill(cs){return cs.getPropertyValue("--lr-heatmap-no-data-fill").trim()||cs.getPropertyValue("--_lr-heatmap-no-data-fill").trim()||FALLBACK_NO_DATA_FILL}focusRingColor(cs){return cs.getPropertyValue("--lr-heatmap-focus-ring-color").trim()||cs.getPropertyValue("--_lr-heatmap-focus-ring-color").trim()||FALLBACK_FOCUS_RING_COLOR}annotationColor(cs){return cs.getPropertyValue("--lr-heatmap-annotation-color").trim()||cs.getPropertyValue("--_lr-heatmap-annotation-color").trim()||FALLBACK_ANNOTATION_COLOR}selectedColor(cs){return cs.getPropertyValue("--lr-heatmap-selected-color").trim()||cs.getPropertyValue("--_lr-heatmap-selected-color").trim()||FALLBACK_SELECTED_COLOR}strokeCellState(ctx,x,y,size,state2,color){const inset=Math.min(state2==="annotation"?.5:state2==="selected"?3.5:6.5,Math.max(.5,(size-RING_LINE_WIDTH-1)/2)),extent=Math.max(1,size-inset*2);ctx.lineWidth=RING_LINE_WIDTH,ctx.strokeStyle=color,ctx.setLineDash?.(state2==="annotation"?[]:state2==="selected"?[4,2]:[1,2]),ctx.strokeRect(x+inset,y+inset,extent,extent),ctx.setLineDash?.([])}isSelectedPos(pos){return this.selectedCell?"week"in pos?this.selectedCell.date==null?!1:this.calendarCellAt(pos).date===this.selectedCell.date:this.selectedCell.row===pos.row&&this.selectedCell.col===pos.col:!1}draw(){if(!this.canvasVisible){this.drawDirty=!0;return}this.drawDirty=!1,this.canvasHasContent=!1,this.effectiveMode==="calendar"?this.drawCalendar():this.drawMatrix()}requestDraw(){this.drawDirty=!0,this.canvasVisible&&this.draw()}repaintFocusRing(previous){if(!this.canvasHasContent||!this.canvas)return!1;const current=this.focusedCell;if(this.effectiveMode==="calendar"){if(previous&&!("week"in previous)||current&&!("week"in current))return!1;this.repaintCalendarFocusCell(previous&&"week"in previous?previous:null),current&&(!previous||!this.samePos(previous,current))&&this.repaintCalendarFocusCell(current)}else{if(previous&&!("row"in previous)||current&&!("row"in current))return!1;this.repaintMatrixFocusCell(previous&&"row"in previous?previous:null),current&&(!previous||!this.samePos(previous,current))&&this.repaintMatrixFocusCell(current)}return!0}cancelDrawFrame(){const request=this.drawFrameRequest;request&&request.owner.cancelAnimationFrame(request.handle),this.drawFrameRequest=void 0}resolveColorStep(color,fallback){const safe=sanitizeCssColor(color);if(!safe)return fallback;const scope=this.ownerDocument.createElement("span"),probe=this.ownerDocument.createElement("span");scope.hidden=!0,scope.style.color=fallback,probe.style.color=safe,scope.append(probe),this.renderRoot.append(scope);try{return this.ownerDocument.defaultView?.getComputedStyle(probe).color.trim()||fallback}finally{scope.remove()}}colorRamp(bucketCount,cs){const steps=this.cachedColorSteps;if(steps&&steps.length>=2){const key2=`steps ${steps.join(" ")}`;if(this.cachedRamp?.key===key2)return this.cachedRamp;const resolved=steps.map((color,index)=>this.resolveColorStep(color,index===steps.length-1?FALLBACK_SCALE_HI:FALLBACK_SCALE_LO)),colors2=resolved.map(color=>formatRgb(resolveRgb(color,FALLBACK_SCALE_LO,this.ownerDocument))),loRgb2=resolveRgb(resolved[0],FALLBACK_SCALE_LO,this.ownerDocument),hiRgb2=resolveRgb(resolved[resolved.length-1],FALLBACK_SCALE_HI,this.ownerDocument);return this.cachedRamp={key:key2,colors:colors2,loRgb:loRgb2,hiRgb:hiRgb2},this.cachedRamp}const[scaleLo,scaleHi]=this.scaleEndpoints(cs),normalizedBucketCount=normalizeBucketCount(bucketCount),key=`${scaleLo}\0${scaleHi}\0${normalizedBucketCount}`;if(this.cachedRamp?.key===key)return this.cachedRamp;const loRgb=resolveRgb(scaleLo,FALLBACK_SCALE_LO,this.ownerDocument),hiRgb=resolveRgb(scaleHi,FALLBACK_SCALE_HI,this.ownerDocument),colors=Array.from({length:normalizedBucketCount},(_,i)=>mixRgb(loRgb,hiRgb,i/(normalizedBucketCount-1)));return this.cachedRamp={key,colors,loRgb,hiRgb},this.cachedRamp}calendarCellSize(){const{weekCount}=this.cachedCalendarGrid;let size;if(this.fitToWidth&&weekCount>0){const hostWidth=this.clientWidth||CAL_PAD_LEFT+weekCount*(this.cellSize+CAL_GAP);size=this.clampFitCellSize((hostWidth-CAL_PAD_LEFT)/weekCount-CAL_GAP)}else size=this.cellSize;return this.accessibleCells?Math.max(size,this.accessibleTargetSizePx):size}clampFitCellSize(size){const floored=finiteRange(size,FIT_MIN_CELL,Math.max(FIT_MIN_CELL,this.minCellSize??FIT_MIN_CELL));return this.maxCellSize==null?floored:Math.min(floored,this.maxCellSize)}columnXFor(week){return this.calendarColumnPositions()[week]??CAL_PAD_LEFT}rowYFor(weekday){return this.calendarRowPositions()[weekday]??CAL_LABEL_H}calendarColumnPositions(){const cellSize=this.calendarCellSize(),weekCount=this.cachedCalendarGrid.weekCount,callback=this.calendarColumnX,cached=this.cachedColumnGeometry;if(cached!==void 0&&cached.callback===callback&&cached.cellSize===cellSize&&cached.weekCount===weekCount)return cached.positions;const positions=[];for(let index=0;index<=weekCount;index++){const fallback=index===0?CAL_PAD_LEFT:positions[index-1]+cellSize+CAL_GAP;let candidate=fallback;if(callback)try{const supplied=callback(index);Number.isFinite(supplied)&&supplied>=0&&(index===0||supplied>=positions[index-1]+cellSize)&&(candidate=supplied)}catch{candidate=fallback}positions.push(candidate)}return this.cachedColumnGeometry={callback,cellSize,weekCount,positions},positions}calendarRowPositions(){const cellSize=this.calendarCellSize(),callback=this.calendarRowY,cached=this.cachedRowGeometry;if(cached!==void 0&&cached.callback===callback&&cached.cellSize===cellSize)return cached.positions;const positions=[];for(let index=0;index<=7;index++){const fallback=index===0?CAL_LABEL_H:positions[index-1]+cellSize+CAL_GAP;let candidate=fallback;if(callback)try{const supplied=callback(index);Number.isFinite(supplied)&&supplied>=0&&(index===0||supplied>=positions[index-1]+cellSize)&&(candidate=supplied)}catch{candidate=fallback}positions.push(candidate)}return this.cachedRowGeometry={callback,cellSize,positions},positions}weekAtX(x,weekCount){const positions=this.calendarColumnPositions(),cellSize=this.calendarCellSize();for(let week=0;week<weekCount;week++){const start=positions[week];if(x>=start&&x<start+cellSize)return week}return null}weekdayAtY(y){const positions=this.calendarRowPositions(),cellSize=this.calendarCellSize();for(let weekday=0;weekday<7;weekday++){const start=positions[weekday];if(y>=start&&y<start+cellSize)return weekday}return null}weekdayLabels(firstWeekStart){const formatter=getDateTimeFormat(this.effectiveLocale||void 0,{weekday:"short",timeZone:"UTC"}),labels=["","","","","","",""];for(const weekday of[1,3,5]){const row=(weekday-this.normalizedFirstDayOfWeek+7)%7;labels[row]=this.calendarWeekdayLabelText?.(weekday)??formatter.format(new Date(firstWeekStart.getTime()+row*MS_PER_DAY))}return labels}drawCalendar(){if(!this.canvas)return;const{weekCount,firstWeekStart,monthLabels}=this.cachedCalendarGrid,cellSize=this.calendarCellSize(),w=this.columnXFor(Math.max(1,weekCount)),h=this.rowYFor(7),dpr=this.ownerDocument.defaultView?.devicePixelRatio||1;this.canvas.width=w*dpr,this.canvas.height=h*dpr,this.canvas.style.width=`${w}px`,this.canvas.style.height=`${h}px`;const ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.scale(dpr,dpr),ctx.clearRect(0,0,w,h);const cs=this.ownerDocument.defaultView?.getComputedStyle(this);if(!cs)return;const buckets=normalizeBucketCount(this.bucketCount),ramp=this.colorRamp(buckets,cs).colors,noDataFill=this.noDataFill(cs);this.canvasColorCache.clear();const bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1;for(let week=0;week<weekCount;week++)for(let weekday=0;weekday<7;weekday++){const value=this.cachedCalendarCellsByPos.get(`${week}:${weekday}`)?.value??-1,x=this.columnXFor(week),y=this.rowYFor(weekday),override=this.cellColor?.(this.calendarPos(week,weekday),value);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(value<0||!Number.isFinite(value))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(value,hi,ramp.length);ctx.fillStyle=step<0?noDataFill:ramp[step]}else if(this.cachedColorSteps.length>=2){const step=linearBucket(value,lo,hi,ramp.length);ctx.fillStyle=ramp[step]}else ctx.fillStyle=ramp[quartileBucket(value,this.cachedCalendarSortedValues,buckets)];ctx.fillRect(x,y,cellSize,cellSize)}if(this.cachedAnnotations.length)for(const ann of this.cachedAnnotations){if(ann.date==null)continue;const match=this.cachedCalendarCellsByDate.get(ann.date);if(!match)continue;const x=this.columnXFor(match.week),y=this.rowYFor(match.weekday);this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs))}if(this.selectedCell?.date!=null){const match=this.cachedCalendarCellsByDate.get(this.selectedCell.date);if(match){const x=this.columnXFor(match.week),y=this.rowYFor(match.weekday);this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs))}}if(this.focusedCell&&"week"in this.focusedCell){const{week,weekday}=this.focusedCell;if(week<weekCount&&weekday<7){const x=this.columnXFor(week),y=this.rowYFor(weekday);this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}}ctx.fillStyle=this.labelColor(cs),ctx.font=this.labelFont(cs);for(const m of monthLabels)ctx.fillText(m.label,this.columnXFor(m.week),CAL_LABEL_H-4);this.weekdayLabels(firstWeekStart).forEach((label,weekday)=>{label&&ctx.fillText(label,2,this.rowYFor(weekday)+cellSize-1)}),this.canvasHasContent=!0}matrixCellSize(cols){let size;if(this.fitToWidth&&cols>0){const hostWidth=this.clientWidth||PAD_LEFT+cols*this.cellSize;size=this.clampFitCellSize((hostWidth-PAD_LEFT)/cols)}else size=this.cellSize;return this.accessibleCells?Math.max(size,this.accessibleTargetSizePx):size}paintMatrixCell(ctx,row,col,cellSize,cs,rampData,noDataFill){const value=this.matrixValues[row]?.[col]??-1,bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1,override=this.cellColor?.({row,col},value);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(value<0||!Number.isFinite(value))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(value,hi,rampData.colors.length);ctx.fillStyle=step<0?noDataFill:rampData.colors[step]}else this.cachedColorSteps.length>=2?ctx.fillStyle=rampData.colors[linearBucket(value,lo,hi,rampData.colors.length)]:ctx.fillStyle=mixRgb(rampData.loRgb,rampData.hiRgb,linearAlpha(value,lo,hi));ctx.fillRect(PAD_LEFT+col*cellSize,PAD_TOP+row*cellSize,cellSize-1,cellSize-1)}paintMatrixFocusOverlays(ctx,row,col,cellSize,cs){const x=PAD_LEFT+col*cellSize,y=PAD_TOP+row*cellSize;this.cachedMatrixAnnotationPositions.has(`${row}:${col}`)&&this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs)),this.selectedCell?.row===row&&this.selectedCell.col===col&&this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs)),this.focusedCell&&"row"in this.focusedCell&&this.focusedCell.row===row&&this.focusedCell.col===col&&this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}repaintMatrixFocusCell(pos){if(!pos||!this.canvas)return;const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(pos.row<0||pos.row>=rows||pos.col<0||pos.col>=cols)return;const cellSize=this.matrixCellSize(cols),x=PAD_LEFT+pos.col*cellSize,y=PAD_TOP+pos.row*cellSize,ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.clearRect(x-RING_LINE_WIDTH-1,y-RING_LINE_WIDTH-1,cellSize+2*(RING_LINE_WIDTH+1),cellSize+2*(RING_LINE_WIDTH+1));const cs=this.ownerDocument.defaultView?.getComputedStyle(this);cs&&(this.paintMatrixCell(ctx,pos.row,pos.col,cellSize,cs,this.colorRamp(RAMP_STEPS,cs),this.noDataFill(cs)),this.paintMatrixFocusOverlays(ctx,pos.row,pos.col,cellSize,cs))}paintCalendarCell(ctx,week,weekday,cellSize,cs,ramp,noDataFill){const value=this.cachedCalendarCellsByPos.get(`${week}:${weekday}`)?.value??-1,bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1,override=this.cellColor?.(this.calendarPos(week,weekday),value);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(value<0||!Number.isFinite(value))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(value,hi,ramp.length);ctx.fillStyle=step<0?noDataFill:ramp[step]}else this.cachedColorSteps.length>=2?ctx.fillStyle=ramp[linearBucket(value,lo,hi,ramp.length)]:ctx.fillStyle=ramp[quartileBucket(value,this.cachedCalendarSortedValues,ramp.length)];ctx.fillRect(this.columnXFor(week),this.rowYFor(weekday),cellSize,cellSize)}paintCalendarFocusOverlays(ctx,week,weekday,cellSize,cs){const date=this.calendarDateAt(week,weekday),x=this.columnXFor(week),y=this.rowYFor(weekday),matches=candidate=>candidate?.date===date;this.cachedCalendarAnnotationDates.has(date)&&this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs)),matches(this.selectedCell??void 0)&&this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs)),this.focusedCell&&"week"in this.focusedCell&&this.focusedCell.week===week&&this.focusedCell.weekday===weekday&&this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}repaintCalendarFocusCell(pos){if(!pos||!this.canvas)return;const{weekCount,firstWeekStart}=this.cachedCalendarGrid;if(pos.week<0||pos.week>=weekCount||pos.weekday<0||pos.weekday>=7)return;const cellSize=this.calendarCellSize(),x=this.columnXFor(pos.week),y=this.rowYFor(pos.weekday),ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.clearRect(x-RING_LINE_WIDTH-1,y-RING_LINE_WIDTH-1,cellSize+2*(RING_LINE_WIDTH+1),cellSize+2*(RING_LINE_WIDTH+1));const cs=this.ownerDocument.defaultView?.getComputedStyle(this);if(!cs)return;const ramp=this.colorRamp(normalizeBucketCount(this.bucketCount),cs).colors;this.paintCalendarCell(ctx,pos.week,pos.weekday,cellSize,cs,ramp,this.noDataFill(cs)),this.paintCalendarFocusOverlays(ctx,pos.week,pos.weekday,cellSize,cs),ctx.fillStyle=this.labelColor(cs),ctx.font=this.labelFont(cs);for(const month of this.cachedCalendarGrid.monthLabels)ctx.fillText(month.label,this.columnXFor(month.week),CAL_LABEL_H-4);this.weekdayLabels(firstWeekStart).forEach((label,weekday)=>{label&&ctx.fillText(label,2,this.rowYFor(weekday)+cellSize-1)})}drawMatrix(){if(!this.canvas)return;const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length,cellSize=this.matrixCellSize(cols),w=PAD_LEFT+cols*cellSize,h=PAD_TOP+rows*cellSize,dpr=this.ownerDocument.defaultView?.devicePixelRatio||1;this.canvas.width=w*dpr,this.canvas.height=h*dpr,this.canvas.style.width=`${w}px`,this.canvas.style.height=`${h}px`;const ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.scale(dpr,dpr),ctx.clearRect(0,0,w,h);const cs=this.ownerDocument.defaultView?.getComputedStyle(this);if(!cs)return;const bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1,rampData=this.colorRamp(RAMP_STEPS,cs),ramp=rampData.colors,{loRgb,hiRgb}=rampData,noDataFill=this.noDataFill(cs);this.canvasColorCache.clear();for(let r=0;r<rows;r++)for(let c=0;c<cols;c++){const v=this.matrixValues[r]?.[c]??-1,x=PAD_LEFT+c*cellSize,y=PAD_TOP+r*cellSize,override=this.cellColor?.({row:r,col:c},v);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(v<0||!Number.isFinite(v))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(v,hi,ramp.length);ctx.fillStyle=step<0?noDataFill:ramp[step]}else if(this.cachedColorSteps.length>=2){const step=linearBucket(v,lo,hi,ramp.length);ctx.fillStyle=ramp[step]}else{const t=linearAlpha(v,lo,hi);ctx.fillStyle=mixRgb(loRgb,hiRgb,t)}ctx.fillRect(x,y,cellSize-1,cellSize-1)}if(this.cachedAnnotations.length)for(const ann of this.cachedAnnotations){if(ann.row==null||ann.col==null||ann.row<0||ann.row>=rows||ann.col<0||ann.col>=cols)continue;const x=PAD_LEFT+ann.col*cellSize,y=PAD_TOP+ann.row*cellSize;this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs))}if(this.selectedCell?.row!=null&&this.selectedCell.col!=null){const{row,col}=this.selectedCell;if(row>=0&&row<rows&&col>=0&&col<cols){const x=PAD_LEFT+col*cellSize,y=PAD_TOP+row*cellSize;this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs))}}if(this.focusedCell&&"row"in this.focusedCell){const{row,col}=this.focusedCell;if(row<rows&&col<cols){const x=PAD_LEFT+col*cellSize,y=PAD_TOP+row*cellSize;this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}}ctx.fillStyle=this.labelColor(cs),ctx.font=this.labelFont(cs),this.matrixRowLabels.forEach((label,r)=>{ctx.fillText(label,4,PAD_TOP+r*cellSize+cellSize/2+3)}),this.matrixColLabels.forEach((label,c)=>{ctx.fillText(label,PAD_LEFT+c*cellSize+2,PAD_TOP-6)}),this.canvasHasContent=!0}hitTest(x,y){return this.effectiveMode==="calendar"?this.hitTestCalendar(x,y):this.hitTestMatrix(x,y)}hitTestMatrix(x,y){const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(rows===0||cols===0)return null;const cellSize=this.matrixCellSize(cols),col=Math.floor((x-PAD_LEFT)/cellSize),row=Math.floor((y-PAD_TOP)/cellSize);if(row<0||row>=rows||col<0||col>=cols)return null;const pos={row,col};return this.isCellInteractive(pos)?pos:null}firstInteractiveMatrixCell(rows,cols){for(let r=0;r<rows;r++)for(let c=0;c<cols;c++)if(this.isCellInteractive({row:r,col:c}))return{row:r,col:c};return null}nextInteractiveMatrixCell(row,col,dRow,dCol,rows,cols){let r=row,c=col;for(;;){const nr=Math.min(rows-1,Math.max(0,r+dRow)),nc=Math.min(cols-1,Math.max(0,c+dCol));if(nr===r&&nc===c)return{row,col};if(r=nr,c=nc,this.isCellInteractive({row:r,col:c}))return{row:r,col:c}}}firstInteractiveCalendarCell(weekCount){for(let week=0;week<weekCount;week++)for(let weekday=0;weekday<7;weekday++){const pos=this.calendarPos(week,weekday);if(this.isCellInteractive(pos))return pos}return null}nextInteractiveCalendarCell(week,weekday,dWeek,dWeekday,weekCount){let w=week,d=weekday;for(;;){const nw=Math.min(weekCount-1,Math.max(0,w+dWeek)),nd=Math.min(6,Math.max(0,d+dWeekday));if(nw===w&&nd===d)return this.calendarPos(week,weekday);w=nw,d=nd;const pos=this.calendarPos(w,d);if(this.isCellInteractive(pos))return pos}}hitTestCalendar(x,y){const{weekCount}=this.cachedCalendarGrid;if(weekCount===0)return null;const week=this.weekAtX(x,weekCount),weekday=this.weekdayAtY(y);if(week===null||weekday===null)return null;const pos=this.calendarPos(week,weekday);return this.isCellInteractive(pos)?pos:null}calendarCellAt(pos){const match=this.cachedCalendarCellsByPos.get(`${pos.week}:${pos.weekday}`);return match?{date:match.date,value:match.value}:{date:this.calendarDateAt(pos.week,pos.weekday),value:-1}}calendarDateAt(week,weekday){const index=week*7+weekday;return this.cachedCalendarDateByPos[index]??isoDateAtOffset(this.cachedCalendarGrid.firstWeekStart,index)}calendarPos(week,weekday){return{week,weekday,date:this.calendarDateAt(week,weekday)}}cellRect(pos){if("week"in pos){const cellSize2=this.calendarCellSize();return{x:this.columnXFor(pos.week),y:this.rowYFor(pos.weekday),w:cellSize2,h:cellSize2}}const cellSize=this.matrixCellSize(this.matrixColLabels.length);return{x:PAD_LEFT+pos.col*cellSize,y:PAD_TOP+pos.row*cellSize,w:cellSize-1,h:cellSize-1}}defaultCellText(pos){return"week"in pos?this.calendarCellText(pos):this.matrixCellText(pos)}matrixCellText(pos){const rowLabel=this.matrixRowLabels[pos.row]??this.localize("heatmapDefaultRowLabel",void 0,{n:this.formatCount(pos.row+1)}),colLabel=this.matrixColLabels[pos.col]??this.localize("heatmapDefaultColLabel",void 0,{n:this.formatCount(pos.col+1)}),v=this.matrixValues[pos.row]?.[pos.col],valueText=v==null||v<0||!Number.isFinite(v)?this.localize("heatmapNoDataValue"):this.formatNumericValue(v);return this.localize("heatmapMatrixCellLabel",void 0,{row:rowLabel,col:colLabel,value:valueText})}calendarCellText(pos){const{date,value}=this.calendarCellAt(pos),label=parseIsoDate(date).toLocaleString(this.effectiveLocale||void 0,{month:"short",day:"numeric",timeZone:"UTC"}),valueText=value<0||!Number.isFinite(value)?this.localize("heatmapNoDataValue"):this.formatNumericValue(value);return this.localize("heatmapCalendarCellLabel",void 0,{date:label,value:valueText})}valueAt(pos){return"week"in pos?this.calendarCellAt(pos).value:this.matrixValues[pos.row]?.[pos.col]??-1}resolveCellText(pos){return this.cellText?this.cellText(pos,this.valueAt(pos)):this.defaultCellText(pos)}isCellInteractive(pos){return this.cellInteractive?.(pos,this.valueAt(pos))??!0}announce(pos){const text=this.resolveCellText(pos),announcement=this.isSelectedPos(pos)?this.localize("heatmapSelectedCellLabel",void 0,{cell:text}):text;this.liveText=announcement,this.announcementSink?.announce(announcement)}emitCellClick(pos){if(this.isCellInteractive(pos))if("week"in pos){const{date,value}=this.calendarCellAt(pos);this.emit("lr-cell-click",{date,value})}else{const value=this.matrixValues[pos.row]?.[pos.col]??-1;this.emit("lr-cell-click",{row:pos.row,col:pos.col,value})}}tooltipStyle(pos){const rect=this.cellRect(pos);return{left:`${rect.x+rect.w/2}px`,top:`${rect.y}px`}}samePos(a,b){return a===b?!0:!a||!b?!1:"week"in a&&"week"in b?a.week===b.week&&a.weekday===b.weekday:"row"in a&&"row"in b?a.row===b.row&&a.col===b.col:!1}onMatrixKeyDown(e){const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(rows===0||cols===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedCell&&this.emitCellClick(this.focusedCell);return}if(!ARROW_KEYS.has(e.key))return;if(e.preventDefault(),!this.focusedCell||!("row"in this.focusedCell)){const next2=this.firstInteractiveMatrixCell(rows,cols);if(!next2)return;this.focusedCell=next2,this.announce(next2);return}const{row,col}=this.focusedCell;let dRow=0,dCol=0;e.key==="ArrowUp"?dRow=-1:e.key==="ArrowDown"?dRow=1:e.key==="ArrowLeft"?dCol=-1:e.key==="ArrowRight"&&(dCol=1);const next=this.nextInteractiveMatrixCell(row,col,dRow,dCol,rows,cols);this.focusedCell=next,this.announce(next)}onCalendarKeyDown(e){const{weekCount}=this.cachedCalendarGrid;if(weekCount===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedCell&&this.emitCellClick(this.focusedCell);return}if(!ARROW_KEYS.has(e.key))return;if(e.preventDefault(),!this.focusedCell||!("week"in this.focusedCell)){const next2=this.firstInteractiveCalendarCell(weekCount);if(!next2)return;this.focusedCell=next2,this.announce(next2);return}const{week,weekday}=this.focusedCell;let dWeek=0,dWeekday=0;e.key==="ArrowUp"?dWeekday=-1:e.key==="ArrowDown"?dWeekday=1:e.key==="ArrowLeft"?dWeek=-1:e.key==="ArrowRight"&&(dWeek=1);const next=this.nextInteractiveCalendarCell(week,weekday,dWeek,dWeekday,weekCount);this.focusedCell=next,this.announce(next)}resolveCanvasColor(value,cs){const cached=this.canvasColorCache.get(value);if(cached!==void 0)return cached;const fallback=this.noDataFill(cs);let candidate=value;if(value.includes("var(")){if(this.colorProbe||(this.colorProbe=this.ownerDocument.createElement("span"),this.colorProbe.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none;",this.shadowRoot.appendChild(this.colorProbe)),this.colorProbe.style.color="",this.colorProbe.style.color=value,!this.colorProbe.style.color)return this.canvasColorCache.set(value,fallback),fallback;candidate=this.ownerDocument.defaultView?.getComputedStyle(this.colorProbe).color||fallback}const ctx=getScratchCtx(this.ownerDocument);if(!ctx)return fallback;ctx.fillStyle="rgb(1, 2, 3)";const firstSentinel=ctx.fillStyle;ctx.fillStyle=candidate;let resolved=ctx.fillStyle;if(resolved===firstSentinel){ctx.fillStyle="rgb(4, 5, 6)";const secondSentinel=ctx.fillStyle;ctx.fillStyle=candidate,resolved=ctx.fillStyle,resolved===secondSentinel&&(resolved=fallback)}return this.canvasColorCache.set(value,resolved),resolved}rebuildAccessiblePositions(){const positions=[];if(this.effectiveMode==="calendar"){const{weekCount}=this.cachedCalendarGrid;for(let week=0;week<weekCount;week++)for(let weekday=0;weekday<7;weekday++){const pos=this.calendarPos(week,weekday);this.isCellInteractive(pos)&&positions.push(pos)}}else for(let row=0;row<this.matrixRowLabels.length;row++)for(let col=0;col<this.matrixColLabels.length;col++){const pos={row,col};this.isCellInteractive(pos)&&positions.push(pos)}this.cachedAccessiblePositions=positions,this.cachedAccessiblePositionsByKey=new Map(positions.map(position=>[this.accessibleCellKey(position),position])),this.cachedAccessiblePositionIndexByKey=new Map(positions.map((position,index)=>[this.accessibleCellKey(position),index]))}accessibleCellPositions(){return this.cachedAccessiblePositions}accessibleCellKey(pos){return"week"in pos?`calendar-${pos.week}-${pos.weekday}`:`matrix-${pos.row}-${pos.col}`}accessibleCellIdentity(pos){return"week"in pos?pos.date:this.accessibleCellKey(pos)}accessibleCellAtKey(key){return this.cachedAccessiblePositionsByKey.get(key)??null}focusAccessibleCell(pos){pos&&this.updateComplete.then(()=>{[...this.shadowRoot?.querySelectorAll('[part="cell"]')??[]].find(candidate=>candidate.dataset.cellKey===this.accessibleCellKey(pos))?.focus()})}renderAccessibleCells(){if(!this.accessibleCells)return html``;const positions=this.accessibleCellPositions(),tabStop=this.focusedCell??positions[0]??null,focusIndex=tabStop?this.cachedAccessiblePositionIndexByKey.get(this.accessibleCellKey(tabStop))??0:0,start=Math.max(0,Math.min(Math.max(0,positions.length-MAX_ACCESSIBLE_HEATMAP_CELLS),focusIndex-Math.floor(MAX_ACCESSIBLE_HEATMAP_CELLS/2))),renderedPositions=positions.slice(start,start+MAX_ACCESSIBLE_HEATMAP_CELLS),renderedRows=new Map;for(const pos of renderedPositions){const rowIndex="week"in pos?pos.weekday+1:pos.row+1,row=renderedRows.get(rowIndex);row?row.push(pos):renderedRows.set(rowIndex,[pos])}const rowCount=this.effectiveMode==="calendar"?7:this.matrixRowLabels.length,colCount=this.effectiveMode==="calendar"?this.cachedCalendarGrid.weekCount:this.matrixColLabels.length;return html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{srOnly}from"../../../internal/a11y.js";import{finiteInteger,finiteNumber,finiteRange}from"../../../internal/numbers.js";import{getScratchCtx}from"../../../internal/canvas.js";import{resolveCssLength}from"../../../internal/css-length.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{activeElementIn}from"../../../internal/active-element.js";import{linearAlpha,linearBucket,midpointAlpha,midpointBucket,minMax,sqrtStep}from"./heatmap-scale.js";import{styles}from"./heatmap.styles.js";import{buildCalendarGrid,parseIsoDate,quartileBucket}from"./calendar-grid.js";import{getDateTimeFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_heatmapCalendarCellLabel,LYRA_DEFAULT_heatmapCalendarLabel,LYRA_DEFAULT_heatmapDecorationLimit,LYRA_DEFAULT_heatmapDefaultColLabel,LYRA_DEFAULT_heatmapDefaultRowLabel,LYRA_DEFAULT_heatmapMatrixCellLabel,LYRA_DEFAULT_heatmapMatrixLabel,LYRA_DEFAULT_heatmapNoDataValue,LYRA_DEFAULT_heatmapProjectionLimit,LYRA_DEFAULT_heatmapSelectedCellLabel,LYRA_DEFAULT_heatmapValueLabel}from"../../../internal/default-strings.generated.js";const PAD_LEFT=60,PAD_TOP=20,ROW_LABEL_INSET=4,MAX_ROW_LABEL_FRACTION=.4,MAX_COL_LABEL_HEIGHT=240,COL_LABEL_INSET=6,labelExtentConverter={fromAttribute:value=>{if(value===null)return;const trimmed=value.trim();if(trimmed.toLowerCase()==="auto")return"auto";const parsed=Number.parseFloat(trimmed);return Number.isFinite(parsed)&&parsed>=0?parsed:void 0},toAttribute:value=>value===void 0?null:String(value)},FALLBACK_NO_DATA_FILL="rgba(128,128,128,0.25)",RAMP_STEPS=7,FALLBACK_SCALE_LO="#cde2fb",FALLBACK_SCALE_HI="#0969da",FALLBACK_LABEL_FONT="10px system-ui, sans-serif",CAL_PAD_LEFT=28,CAL_LABEL_H=16,CAL_CELL=11,CAL_GAP=2,DEFAULT_MATRIX_CELL_SIZE=22,DEFAULT_ACCESSIBLE_TARGET_SIZE_PX=40,DEFAULT_BUCKET_COUNT=5,FIT_MIN_CELL=4,MAX_BUCKET_COUNT=256,MAX_HEATMAP_CELLS=1e4,MAX_HEATMAP_DECORATIONS=256,MAX_ACCESSIBLE_HEATMAP_CELLS=400,RING_LINE_WIDTH=2,FALLBACK_FOCUS_RING_COLOR="#0969da",FALLBACK_ANNOTATION_COLOR="#cf222e",FALLBACK_SELECTED_COLOR="#1a7f37",ARROW_KEYS=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),MS_PER_DAY=864e5;function isoDateAtOffset(firstWeekStart,dayOffset){return new Date(firstWeekStart.getTime()+dayOffset*MS_PER_DAY).toISOString().slice(0,10)}const HEX_RE=/^([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,RGB_RE=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/i;function hexToRgb(hex){const clean=hex.trim().replace("#","");if(!HEX_RE.test(clean))return null;const hasAlpha=clean.length===4||clean.length===8,full=clean.length<=4?clean.split("").map(c=>c+c).join(""):clean,num=Number.parseInt(full,16);return hasAlpha?[num>>>24&255,num>>>16&255,num>>>8&255,(num&255)/255]:[num>>16&255,num>>8&255,num&255,1]}function parseRgbString(value){const match=RGB_RE.exec(value);if(!match)return null;const a=match[4]===void 0?1:Number(match[4]);return[Number(match[1]),Number(match[2]),Number(match[3]),a]}function resolveViaPixelReadback(ctx){try{ctx.clearRect(0,0,1,1),ctx.fillRect(0,0,1,1);const[r=0,g=0,b=0,a=0]=ctx.getImageData(0,0,1,1).data;return[r,g,b,a/255]}catch{return null}}function formatRgb([r,g,b,a]){const alpha=Math.min(1,Math.max(0,a));return alpha>=1?`rgb(${r}, ${g}, ${b})`:`rgba(${r}, ${g}, ${b}, ${Math.round(alpha*1e3)/1e3})`}const warnedInvalidColors=new Set;function warnInvalidColor(color){warnedInvalidColors.has(color)||(warnedInvalidColors.add(color),console.warn(`<lr-heatmap> could not parse "${color}" (set via --lr-heatmap-scale-lo/-hi) as a CSS color; falling back to the default ramp endpoint.`))}let warnedNoCanvasContext=!1;function warnNoCanvasContext(){warnedNoCanvasContext||(warnedNoCanvasContext=!0,console.warn("<lr-heatmap>: no 2D canvas context is available in this environment; color resolution for non-hex/non-rgb values (e.g. oklch(), color(srgb ...), named colors) will fall back to the given default instead of resolving the requested color."))}function normalizeBucketCount(bucketCount){return finiteInteger(bucketCount,DEFAULT_BUCKET_COUNT,2,MAX_BUCKET_COUNT)}const optionalCellSizeConverter={fromAttribute(value){if(value===null||value.trim()==="")return;const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0},toAttribute(value){return value==null?null:String(value)}},DEFAULT_MATRIX_DATA=Object.freeze({kind:"matrix",rowLabels:Object.freeze([]),colLabels:Object.freeze([]),values:Object.freeze([])});function normalizeCellSizeClamp(value){if(!(value==null||!Number.isFinite(value)))return finiteRange(value,FIT_MIN_CELL,FIT_MIN_CELL)}const bucketCountConverter={fromAttribute(value){return value===null?DEFAULT_BUCKET_COUNT:normalizeBucketCount(Number(value))},toAttribute(value){return String(normalizeBucketCount(value))}};function resolveRgb(color,fallbackHex,ownerDocument){const fallback=hexToRgb(fallbackHex)??[0,0,0,1],direct=hexToRgb(color);if(direct)return direct;const ctx=getScratchCtx(ownerDocument);if(!ctx)return warnNoCanvasContext(),fallback;const sentinel="rgb(1, 2, 3)";ctx.fillStyle=sentinel;const sentinelNormalized=ctx.fillStyle;if(ctx.fillStyle=color,ctx.fillStyle===sentinelNormalized&&color.trim()!==sentinel)return warnInvalidColor(color),fallback;const normalized=ctx.fillStyle;return hexToRgb(normalized)??parseRgbString(normalized)??resolveViaPixelReadback(ctx)??fallback}function mixRgb(from,to,t){const clamped=Math.min(1,Math.max(0,t)),r=Math.round(from[0]+(to[0]-from[0])*clamped),g=Math.round(from[1]+(to[1]-from[1])*clamped),b=Math.round(from[2]+(to[2]-from[2])*clamped),a=from[3]+(to[3]-from[3])*clamped;return formatRgb([r,g,b,a])}class LyraHeatmap extends LyraElement{static{this.defaultStrings={...super.defaultStrings,heatmapCalendarCellLabel:LYRA_DEFAULT_heatmapCalendarCellLabel,heatmapCalendarLabel:LYRA_DEFAULT_heatmapCalendarLabel,heatmapDecorationLimit:LYRA_DEFAULT_heatmapDecorationLimit,heatmapDefaultColLabel:LYRA_DEFAULT_heatmapDefaultColLabel,heatmapDefaultRowLabel:LYRA_DEFAULT_heatmapDefaultRowLabel,heatmapMatrixCellLabel:LYRA_DEFAULT_heatmapMatrixCellLabel,heatmapMatrixLabel:LYRA_DEFAULT_heatmapMatrixLabel,heatmapNoDataValue:LYRA_DEFAULT_heatmapNoDataValue,heatmapProjectionLimit:LYRA_DEFAULT_heatmapProjectionLimit,heatmapSelectedCellLabel:LYRA_DEFAULT_heatmapSelectedCellLabel,heatmapValueLabel:LYRA_DEFAULT_heatmapValueLabel}}static{this.ownedCollectionProperties=Object.freeze(["data","annotations","legendStops","colorSteps"])}static{this.identityCollectionObjectProperties=Object.freeze(["data"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"role"])]}get effectiveMode(){return this.data.kind}get effectiveColLabelRotation(){if(typeof this.colLabelRotation!="number")return 0;const degrees=finiteNumber(this.colLabelRotation,0);return Math.min(90,Math.max(0,degrees))}get matrixPadLeft(){if(this.rowLabelWidth==="auto")return this.resolvedRowLabelWidth;if(typeof this.rowLabelWidth!="number")return PAD_LEFT;const resolved=finiteNumber(this.rowLabelWidth,PAD_LEFT);return resolved>=0?resolved:PAD_LEFT}get matrixPadTop(){if(this.colLabelHeight==="auto")return this.resolvedColLabelHeight;if(typeof this.colLabelHeight!="number")return PAD_TOP;const resolved=finiteNumber(this.colLabelHeight,PAD_TOP);return resolved>=0?resolved:PAD_TOP}measureColLabelHeight(cs){const labels=this.matrixColLabels;if(labels.length===0)return PAD_TOP;const ctx=getScratchCtx(this.ownerDocument);if(!ctx)return PAD_TOP;ctx.font=this.labelFont(cs);let widest=0;for(const label of labels)widest=Math.max(widest,ctx.measureText(label).width);const radians=this.effectiveColLabelRotation*Math.PI/180,projected=widest*Math.sin(radians);return Math.max(PAD_TOP,Math.min(Math.ceil(projected)+COL_LABEL_INSET,MAX_COL_LABEL_HEIGHT))}measureRowLabelWidth(cs){const labels=this.matrixRowLabels;if(labels.length===0)return PAD_LEFT;const ctx=getScratchCtx(this.ownerDocument);if(!ctx)return PAD_LEFT;ctx.font=this.labelFont(cs);let widest=0;for(const label of labels)widest=Math.max(widest,ctx.measureText(label).width);const hostWidth=this.clientWidth||0,cap=hostWidth>0?hostWidth*MAX_ROW_LABEL_FRACTION:Number.POSITIVE_INFINITY;return Math.min(Math.max(PAD_LEFT,Math.ceil(widest)+ROW_LABEL_INSET*2),cap)}ellipsize(ctx,label,maxWidth){if(maxWidth<=0)return"";if(ctx.measureText(label).width<=maxWidth)return label;const characters=[...label];let kept=characters.length-1;for(;kept>0;){const candidate=`${characters.slice(0,kept).join("")}\u2026`;if(ctx.measureText(candidate).width<=maxWidth)return candidate;kept-=1}return ctx.measureText("\u2026").width<=maxWidth?"\u2026":""}get matrixRowLabels(){return this.cachedMatrixData.rowLabels}get matrixColLabels(){return this.cachedMatrixData.colLabels}get matrixValues(){return this.cachedMatrixData.values}get calendarDays(){return this.data.kind==="calendar"?this.data.days:[]}get calendarData(){return this.data.kind==="calendar"?this.data:void 0}get cellSize(){return this._cellSize??(this.effectiveMode==="calendar"?CAL_CELL:DEFAULT_MATRIX_CELL_SIZE)}set cellSize(value){const oldValue=this._cellSize;this._cellSize=value==null?void 0:finiteRange(value,this.effectiveMode==="calendar"?CAL_CELL:DEFAULT_MATRIX_CELL_SIZE,1),this.requestUpdate("cellSize",oldValue)}get signedDomain(){return this.domain!==void 0||this.midpoint!==void 0}rampAlpha(value,lo,hi){const anchor=this.midpoint;return anchor===void 0?linearAlpha(value,lo,hi):midpointAlpha(value,lo,hi,anchor)}rampBucket(value,lo,hi,steps){const anchor=this.midpoint;return anchor===void 0?linearBucket(value,lo,hi,steps):midpointBucket(value,lo,hi,anchor,steps)}isNoData(value){return Number.isFinite(value)?value<0&&!this.signedDomain:!0}get maxCellSize(){return this._maxCellSize}set maxCellSize(value){const oldValue=this._maxCellSize;this._maxCellSize=normalizeCellSizeClamp(value),this.requestUpdate("maxCellSize",oldValue)}get minCellSize(){return this._minCellSize}set minCellSize(value){const oldValue=this._minCellSize;this._minCellSize=normalizeCellSizeClamp(value),this.requestUpdate("minCellSize",oldValue)}get normalizedFirstDayOfWeek(){return(finiteInteger(this.calendarData?.firstDayOfWeek??0,0)%7+7)%7}get bucketCount(){return this._bucketCount}set bucketCount(value){const oldValue=this._bucketCount;this._bucketCount=normalizeBucketCount(value),this.requestUpdate("bucketCount",oldValue)}get calendarWeekdayLabelText(){return this.calendarData?.weekdayLabelText}get calendarMonthLabelText(){return this.calendarData?.monthLabelText}get calendarColumnX(){return this.calendarData?.columnX}get calendarRowY(){return this.calendarData?.rowY}constructor(){super(),this.data=DEFAULT_MATRIX_DATA,this.resolvedColLabelHeight=PAD_TOP,this.resolvedRowLabelWidth=PAD_LEFT,this.scale="linear",this.fitToWidth=!1,this._bucketCount=DEFAULT_BUCKET_COUNT,this.annotations=[],this.selectedCell=null,this.accessibleCells=!1,this.cachedValueRange=null,this.cachedMatrixData={rowLabels:[],colLabels:[],values:[],truncated:!1},this.cachedCalendarGrid=buildCalendarGrid(this.calendarDays),this.cachedCalendarSortedValues=[],this.cachedCalendarCellsByPos=new Map,this.cachedCalendarCellsByDate=new Map,this.cachedAnnotations=[],this.cachedLegendStops=[],this.cachedColorSteps=[],this.cachedCalendarAnnotationDates=new Set,this.cachedMatrixAnnotationPositions=new Set,this.decorationProjectionTruncated=!1,this.cachedCalendarDateByPos=[],this.cachedAccessiblePositions=[],this.cachedAccessiblePositionsByKey=new Map,this.cachedAccessiblePositionIndexByKey=new Map,this.cachedRamp=null,this.canvasHasContent=!1,this.canvasVisible=!0,this.drawDirty=!1,this.hoverCell=null,this.focusedCell=null,this.liveText="",this.accessibleTargetSizePx=DEFAULT_ACCESSIBLE_TARGET_SIZE_PX,this.restoringAccessibleFocus=!1,this.accessibleFocusGeneration=0,this.authorRole=null,this.authorAriaLabel=null,this.generatedAriaLabel="",this.syncingGeneratedSemantics=!1,this.onDprChange=()=>{this.watchDpr(),this.requestDraw()},this.scheduleDraw=()=>{if(this.drawFrameRequest)return;const owner=this.ownerDocument.defaultView;if(!owner||!this.isConnected)return;const request={owner,handle:0};request.handle=owner.requestAnimationFrame(()=>{this.drawFrameRequest===request&&(this.drawFrameRequest=void 0,this.isConnected&&this.ownerDocument.defaultView===owner&&this.requestDraw())}),this.drawFrameRequest=request},this.onPointerMove=e=>{const next=this.hitTest(e.offsetX,e.offsetY);this.samePos(this.hoverCell,next)||(this.hoverCell=next)},this.onPointerLeave=()=>{this.hoverCell=null},this.onCanvasClick=e=>{const pos=this.hitTest(e.offsetX,e.offsetY);pos&&(this.focusedCell=pos,this.announce(pos),this.emitCellClick(pos))},this.onKeyDown=e=>{this.effectiveMode==="calendar"?this.onCalendarKeyDown(e):this.onMatrixKeyDown(e)},this.canvasColorCache=new Map,this.onAccessibleCellFocus=e=>{if(this.restoringAccessibleFocus)return;const key=e.currentTarget.dataset.cellKey,pos=key?this.accessibleCellAtKey(key):null;pos&&(this.focusedCell=pos,this.announce(pos))},this.onAccessibleCellClick=e=>{const key=e.currentTarget.dataset.cellKey,pos=key?this.accessibleCellAtKey(key):null;pos&&(this.focusedCell=pos,this.announce(pos),this.emitCellClick(pos))},this.onAccessibleCellKeyDown=e=>{if(!ARROW_KEYS.has(e.key))return;const key=e.currentTarget.dataset.cellKey,pos=key?this.accessibleCellAtKey(key):null;pos&&(e.preventDefault(),this.focusedCell=pos,this.onKeyDown(e),this.focusAccessibleCell(this.focusedCell))},new ThemeWatcher(this,()=>this.refreshTheme())}warnOnLegendRampMismatch(){const rampColors=this.cachedColorSteps.map(color=>sanitizeCssColor(color)??color);if(rampColors.length===0)return;const legendColors=this.cachedLegendStops.filter(stop=>!!stop.color).map(stop=>sanitizeCssColor(stop.color??"")??stop.color??"");legendColors.length===0||legendColors.length===rampColors.length&&legendColors.every((color,index)=>color===rampColors[index])||devWarnOnce("lyra-heatmap-legend-ramp-mismatch",`<${this.localName}>: legendStops describes ${legendColors.length} colour(s) that do not match the ${rampColors.length} colorSteps the cells are painted from, so the legend may misdescribe the ramp. Supply legendStops built from the same array as colorSteps, or omit it to keep the built-in gradient key.`)}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),!(oldValue===value||this.syncingGeneratedSemantics)&&(name==="role"&&(this.authorRole=value),name==="aria-label"&&(this.authorAriaLabel=value))}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink(),this.refreshAccessibleTargetSize();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;if(owner&&ResizeObserverCtor){let observer;observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleDraw()}),this.resizeObserver=observer,observer.observe(this)}const IntersectionObserverCtor=owner?.IntersectionObserver;if(this.canvasVisible=!0,owner&&IntersectionObserverCtor){let observer;observer=new IntersectionObserverCtor(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==owner||this.intersectionObserver!==observer)return;const entry=entries.find(candidate=>candidate.target===this);!entry||entry.isIntersecting===this.canvasVisible||(this.canvasVisible=entry.isIntersecting,this.canvasVisible&&this.drawDirty&&this.scheduleDraw())}),this.intersectionObserver=observer,observer.observe(this)}this.cachedRamp=null,this.canvasColorCache.clear(),this.watchDpr()}disconnectedCallback(){super.disconnectedCallback(),this.accessibleFocusGeneration++,this.pendingAccessibleFocus=void 0,this.pendingAccessibleFocusOrigin=void 0,this.restoringAccessibleFocus=!1,this.releaseAnnouncementSink(),this.hoverCell=null,this.focusedCell=null,this.liveText="",this.canvasHasContent=!1,this.drawDirty=!0,this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.canvasVisible=!0,this.clearDprWatcher(),this.cancelDrawFrame()}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}))}watchDpr(){this.clearDprWatcher();const owner=this.ownerDocument.defaultView;if(!owner||typeof owner.matchMedia!="function")return;const query2=owner.matchMedia(`(resolution: ${owner.devicePixelRatio}dppx)`),listener=()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.dprQuery!==query2||this.onDprChange()};this.dprQuery=query2,this.dprChangeListener=listener,query2.addEventListener("change",listener)}clearDprWatcher(){this.dprQuery&&this.dprChangeListener&&this.dprQuery.removeEventListener("change",this.dprChangeListener),this.dprQuery=void 0,this.dprChangeListener=void 0}willUpdate(changed){super.willUpdate(changed),(changed.has("data")||!this.hasUpdated)&&this.rebuildCanonicalMatrixData(),(changed.has("annotations")||changed.has("legendStops")||changed.has("colorSteps")||!this.hasUpdated)&&this.rebuildBoundedDecorations();const accessibleModeChanged=changed.has("accessibleCells")&&this.hasUpdated,collectionChanged=changed.has("data")||changed.has("cellInteractive"),activeRenderedControl=collectionChanged||accessibleModeChanged?activeElementIn(this.shadowRoot):null,activeAccessibleCell=activeRenderedControl?.matches('[part="cell"]')?activeRenderedControl:null,renderedAccessibleCells=activeAccessibleCell?.matches('[part="cell"]')?[...this.shadowRoot?.querySelectorAll('[part="cell"]')??[]]:[],accessibleFocusSnapshot=activeAccessibleCell?.matches('[part="cell"]')?{identity:activeAccessibleCell.dataset.cellIdentity,index:renderedAccessibleCells.indexOf(activeAccessibleCell)}:void 0;if(collectionChanged&&(this.focusedCell=null,this.hoverCell=null,this.liveText=""),changed.has("data")||changed.has("locale")||!this.hasUpdated){this.cachedCalendarGrid=buildCalendarGrid(this.calendarDays,this.normalizedFirstDayOfWeek,this.calendarMonthLabelText,this.effectiveLocale),this.cachedCalendarSortedValues=this.cachedCalendarGrid.cells.map(cell=>cell.value).filter(value=>!this.isNoData(value)).sort((a,b)=>a-b),this.cachedCalendarCellsByPos=new Map(this.cachedCalendarGrid.cells.map(cell=>[`${cell.week}:${cell.weekday}`,cell])),this.cachedCalendarCellsByDate=new Map(this.cachedCalendarGrid.cells.map(cell=>[cell.date,cell]));const{firstWeekStart,weekCount}=this.cachedCalendarGrid;this.cachedCalendarDateByPos=Array.from({length:weekCount*7},(_,index)=>isoDateAtOffset(firstWeekStart,index))}if(changed.has("colorSteps")||!this.hasUpdated){const colorSteps=this.cachedColorSteps.map(sanitizeCssColor);colorSteps.length>=2&&colorSteps.every(color=>color!==void 0)?this.style.setProperty("--lr-heatmap-color-steps-gradient",`linear-gradient(to right, ${colorSteps.join(", ")})`):this.style.removeProperty("--lr-heatmap-color-steps-gradient")}if((changed.has("data")||!this.hasUpdated)&&(this.cachedValueRange=this.computeValueRange()),(collectionChanged||!this.hasUpdated)&&this.rebuildAccessiblePositions(),accessibleFocusSnapshot){const positions=this.accessibleCellPositions(),target=(accessibleFocusSnapshot.identity==null?void 0:positions.find(pos=>this.accessibleCellIdentity(pos)===accessibleFocusSnapshot.identity))??positions[Math.min(Math.max(accessibleFocusSnapshot.index,0),positions.length-1)]??null;this.focusedCell=target,this.liveText=target?this.resolveCellText(target):"",this.pendingAccessibleFocus=target??"base",this.pendingAccessibleFocusOrigin=activeAccessibleCell??void 0,this.restoringAccessibleFocus=!0,this.accessibleFocusGeneration++}if(accessibleModeChanged){const previouslyAccessible=changed.get("accessibleCells")===!0;if(previouslyAccessible&&!this.accessibleCells&&activeAccessibleCell){const key=activeAccessibleCell.dataset.cellKey,target=key?this.accessibleCellAtKey(key):null;target&&(this.focusedCell=target,this.liveText=this.resolveCellText(target)),this.pendingAccessibleFocus="canvas",this.pendingAccessibleFocusOrigin=activeAccessibleCell,this.restoringAccessibleFocus=!0,this.accessibleFocusGeneration++}else if(!previouslyAccessible&&this.accessibleCells&&activeRenderedControl?.matches('[part="canvas"]')){const positions=this.accessibleCellPositions(),target=this.focusedCell?positions.find(pos=>this.samePos(pos,this.focusedCell))??positions[0]??null:positions[0]??null;this.focusedCell=target,this.liveText=target?this.resolveCellText(target):"",this.pendingAccessibleFocus=target??"base",this.pendingAccessibleFocusOrigin=activeRenderedControl,this.restoringAccessibleFocus=!0,this.accessibleFocusGeneration++}}const bounds=this.cachedValueRange,range=bounds?`${this.formatNumericValue(bounds[0])}\u2013${this.formatNumericValue(bounds[1])}`:this.localize("heatmapNoDataValue"),valueLabel=this.localizedValueLabel();let label;if(this.effectiveMode==="calendar")label=this.localize("heatmapCalendarLabel",void 0,{days:this.formatCount(this.cachedCalendarGrid.cells.length),label:valueLabel,range});else{const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;label=this.localize("heatmapMatrixLabel",void 0,{rows:this.formatCount(rows),cols:this.formatCount(cols),label:valueLabel,range})}const selectedText=this.selectedCellDescription(),generatedAriaLabel=[label,selectedText,this.projectionDescription()].filter(Boolean).join(" ");this.generatedAriaLabel=generatedAriaLabel,this.syncingGeneratedSemantics=!0;try{this.authorRole===null&&this.setAttribute("role","group"),this.authorAriaLabel===null&&this.setAttribute("aria-label",generatedAriaLabel)}finally{this.syncingGeneratedSemantics=!1}}rebuildBoundedDecorations(){this.cachedAnnotations=this.annotations.slice(0,MAX_HEATMAP_DECORATIONS).map(entry=>({...entry})),this.cachedLegendStops=(this.legendStops??[]).slice(0,MAX_HEATMAP_DECORATIONS).map(entry=>({...entry})),this.cachedColorSteps=(this.colorSteps??[]).slice(0,MAX_HEATMAP_DECORATIONS),this.warnOnLegendRampMismatch(),this.cachedCalendarAnnotationDates=new Set(this.cachedAnnotations.flatMap(annotation=>annotation.date==null?[]:[annotation.date])),this.cachedMatrixAnnotationPositions=new Set(this.cachedAnnotations.flatMap(annotation=>annotation.row==null||annotation.col==null?[]:[`${annotation.row}:${annotation.col}`])),this.decorationProjectionTruncated=this.annotations.length>MAX_HEATMAP_DECORATIONS||(this.legendStops?.length??0)>MAX_HEATMAP_DECORATIONS||(this.colorSteps?.length??0)>MAX_HEATMAP_DECORATIONS}get projectionTruncated(){return this.decorationProjectionTruncated||(this.effectiveMode==="calendar"?this.cachedCalendarGrid.truncated:this.cachedMatrixData.truncated)}get cellProjectionTruncated(){return this.effectiveMode==="calendar"?this.cachedCalendarGrid.truncated:this.cachedMatrixData.truncated}projectedCellCount(){return this.effectiveMode==="calendar"?this.cachedCalendarGrid.weekCount*7:this.matrixRowLabels.length*this.matrixColLabels.length}projectionDescription(){const messages=[];return this.cellProjectionTruncated&&messages.push(this.localize("heatmapProjectionLimit",void 0,{count:this.formatCount(this.projectedCellCount())})),this.decorationProjectionTruncated&&messages.push(this.localize("heatmapDecorationLimit",void 0,{count:this.formatCount(MAX_HEATMAP_DECORATIONS)})),messages.join(" ")}rebuildCanonicalMatrixData(){if(this.data.kind!=="matrix"){this.cachedMatrixData={rowLabels:[],colLabels:[],values:[],truncated:!1};return}const colCount=Math.min(this.data.colLabels.length,MAX_HEATMAP_CELLS),rowLimit=colCount===0?Math.min(this.data.rowLabels.length,MAX_HEATMAP_CELLS):Math.floor(MAX_HEATMAP_CELLS/colCount),rowCount=Math.min(this.data.rowLabels.length,rowLimit),rowLabels=this.data.rowLabels.slice(0,rowCount).map(String),colLabels=this.data.colLabels.slice(0,colCount).map(String),source=this.data,values=Array.from({length:rowCount},(_,row)=>Array.from({length:colCount},(_2,col)=>source.values[row]?.[col]??(this.signedDomain?Number.NaN:-1)));this.cachedMatrixData={rowLabels,colLabels,values,truncated:rowCount!==this.data.rowLabels.length||colCount!==this.data.colLabels.length||this.data.values.some((row,index)=>index>=rowCount||row.length>colCount)}}selectedCellDescription(){if(!this.selectedCell)return"";if(this.effectiveMode==="calendar"){if(this.selectedCell.date==null)return"";const match=this.cachedCalendarCellsByDate.get(this.selectedCell.date);return match?this.localize("heatmapSelectedCellLabel",void 0,{cell:this.calendarCellText({week:match.week,weekday:match.weekday,date:match.date})}):""}const{row,col}=this.selectedCell;return row==null||col==null||row<0||row>=this.matrixRowLabels.length||col<0||col>=this.matrixColLabels.length?"":this.localize("heatmapSelectedCellLabel",void 0,{cell:this.matrixCellText({row,col})})}computeValueRange(){const pinned=this.domain;if(pinned){const[lo,hi]=pinned;if(Number.isFinite(lo)&&Number.isFinite(hi)&&lo!==hi)return lo<hi?[lo,hi]:[hi,lo]}const source=this.effectiveMode==="calendar"?this.cachedCalendarGrid.cells.map(cell=>cell.value):this.matrixValues.flat();return minMax(source.filter(v=>!this.isNoData(v)))}localizedValueLabel(){return this.valueLabel===void 0?this.localize("heatmapValueLabel"):this.valueLabel}formatNumericValue(value){return getNumberFormat(this.effectiveLocale||void 0).format(value)}updated(changed){if(super.updated(changed),["data","cellSize","maxCellSize","minCellSize","valueLabel","scale","fitToWidth","bucketCount","annotations","focusedCell","colorSteps","cellColor","selectedCell","legendStops","accessibleCells","accessibleTargetSizePx","locale"].some(name=>changed.has(name))){if(changed.has("focusedCell")&&[...changed.keys()].every(key=>key==="focusedCell"||key==="liveText")&&this.repaintFocusRing(changed.get("focusedCell")))return;this.requestDraw()}const pending=this.pendingAccessibleFocus;if(pending===void 0)return;this.pendingAccessibleFocus=void 0;const origin=this.pendingAccessibleFocusOrigin;this.pendingAccessibleFocusOrigin=void 0;const generation=this.accessibleFocusGeneration;this.scheduleAfterUpdate(()=>{try{if(generation!==this.accessibleFocusGeneration||!this.isConnected)return;if(origin){const internalActive=activeElementIn(this.shadowRoot),documentActive=activeElementIn(this.ownerDocument),focusStayedAtOrigin=internalActive===origin,originWasRemovedWithoutReplacement=internalActive===null&&(documentActive===null||documentActive===this||documentActive===this.ownerDocument.body);if(!focusStayedAtOrigin&&!originWasRemovedWithoutReplacement)return}if(pending==="base"){this.shadowRoot?.querySelector('[part="base"]')?.focus();return}if(pending==="canvas"){this.shadowRoot?.querySelector('[part="canvas"]')?.focus();return}const identity=this.accessibleCellIdentity(pending);[...this.shadowRoot?.querySelectorAll('[part="cell"]')??[]].find(candidate=>candidate.dataset.cellIdentity===identity)?.focus()}finally{this.restoringAccessibleFocus=!1}},"heatmap-accessible-focus")}refreshTheme(){this.cachedRamp=null,this.refreshAccessibleTargetSize()||this.requestDraw()}refreshAccessibleTargetSize(){const raw=this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue("--lr-icon-button-size").trim()??"",resolved=resolveCssLength(raw,{host:this}),next=resolved!==void 0&&Number.isFinite(resolved)&&resolved>0?resolved:DEFAULT_ACCESSIBLE_TARGET_SIZE_PX;return next===this.accessibleTargetSizePx?!1:(this.accessibleTargetSizePx=next,!0)}scaleEndpoints(cs){const lo=cs.getPropertyValue("--lr-heatmap-scale-lo").trim()||cs.getPropertyValue("--_lr-heatmap-scale-lo").trim()||FALLBACK_SCALE_LO,hi=cs.getPropertyValue("--lr-heatmap-scale-hi").trim()||cs.getPropertyValue("--_lr-heatmap-scale-hi").trim()||FALLBACK_SCALE_HI;return[lo,hi]}labelColor(cs){return cs.getPropertyValue("--lr-color-text-quiet").trim()||"#6b7280"}labelFont(cs){return cs.getPropertyValue("--lr-heatmap-label-font").trim()||cs.getPropertyValue("--_lr-heatmap-label-font").trim()||FALLBACK_LABEL_FONT}noDataFill(cs){return cs.getPropertyValue("--lr-heatmap-no-data-fill").trim()||cs.getPropertyValue("--_lr-heatmap-no-data-fill").trim()||FALLBACK_NO_DATA_FILL}focusRingColor(cs){return cs.getPropertyValue("--lr-heatmap-focus-ring-color").trim()||cs.getPropertyValue("--_lr-heatmap-focus-ring-color").trim()||FALLBACK_FOCUS_RING_COLOR}annotationColor(cs){return cs.getPropertyValue("--lr-heatmap-annotation-color").trim()||cs.getPropertyValue("--_lr-heatmap-annotation-color").trim()||FALLBACK_ANNOTATION_COLOR}selectedColor(cs){return cs.getPropertyValue("--lr-heatmap-selected-color").trim()||cs.getPropertyValue("--_lr-heatmap-selected-color").trim()||FALLBACK_SELECTED_COLOR}strokeCellState(ctx,x,y,size,state2,color){const inset=Math.min(state2==="annotation"?.5:state2==="selected"?3.5:6.5,Math.max(.5,(size-RING_LINE_WIDTH-1)/2)),extent=Math.max(1,size-inset*2);ctx.lineWidth=RING_LINE_WIDTH,ctx.strokeStyle=color,ctx.setLineDash?.(state2==="annotation"?[]:state2==="selected"?[4,2]:[1,2]),ctx.strokeRect(x+inset,y+inset,extent,extent),ctx.setLineDash?.([])}isSelectedPos(pos){return this.selectedCell?"week"in pos?this.selectedCell.date==null?!1:this.calendarCellAt(pos).date===this.selectedCell.date:this.selectedCell.row===pos.row&&this.selectedCell.col===pos.col:!1}draw(){if(!this.canvasVisible){this.drawDirty=!0;return}this.drawDirty=!1,this.canvasHasContent=!1,this.effectiveMode==="calendar"?this.drawCalendar():this.drawMatrix()}requestDraw(){this.drawDirty=!0,this.canvasVisible&&this.draw()}repaintFocusRing(previous){if(!this.canvasHasContent||!this.canvas)return!1;const current=this.focusedCell;if(this.effectiveMode==="calendar"){if(previous&&!("week"in previous)||current&&!("week"in current))return!1;this.repaintCalendarFocusCell(previous&&"week"in previous?previous:null),current&&(!previous||!this.samePos(previous,current))&&this.repaintCalendarFocusCell(current)}else{if(previous&&!("row"in previous)||current&&!("row"in current))return!1;this.repaintMatrixFocusCell(previous&&"row"in previous?previous:null),current&&(!previous||!this.samePos(previous,current))&&this.repaintMatrixFocusCell(current)}return!0}cancelDrawFrame(){const request=this.drawFrameRequest;request&&request.owner.cancelAnimationFrame(request.handle),this.drawFrameRequest=void 0}resolveColorStep(color,fallback){const safe=sanitizeCssColor(color);if(!safe)return fallback;const scope=this.ownerDocument.createElement("span"),probe=this.ownerDocument.createElement("span");scope.hidden=!0,scope.style.color=fallback,probe.style.color=safe,scope.append(probe),this.renderRoot.append(scope);try{return this.ownerDocument.defaultView?.getComputedStyle(probe).color.trim()||fallback}finally{scope.remove()}}colorRamp(bucketCount,cs){const steps=this.cachedColorSteps;if(steps&&steps.length>=2){const key2=`steps ${steps.join(" ")}`;if(this.cachedRamp?.key===key2)return this.cachedRamp;const resolved=steps.map((color,index)=>this.resolveColorStep(color,index===steps.length-1?FALLBACK_SCALE_HI:FALLBACK_SCALE_LO)),colors2=resolved.map(color=>formatRgb(resolveRgb(color,FALLBACK_SCALE_LO,this.ownerDocument))),loRgb2=resolveRgb(resolved[0],FALLBACK_SCALE_LO,this.ownerDocument),hiRgb2=resolveRgb(resolved[resolved.length-1],FALLBACK_SCALE_HI,this.ownerDocument);return this.cachedRamp={key:key2,colors:colors2,loRgb:loRgb2,hiRgb:hiRgb2},this.cachedRamp}const[scaleLo,scaleHi]=this.scaleEndpoints(cs),normalizedBucketCount=normalizeBucketCount(bucketCount),key=`${scaleLo}\0${scaleHi}\0${normalizedBucketCount}`;if(this.cachedRamp?.key===key)return this.cachedRamp;const loRgb=resolveRgb(scaleLo,FALLBACK_SCALE_LO,this.ownerDocument),hiRgb=resolveRgb(scaleHi,FALLBACK_SCALE_HI,this.ownerDocument),colors=Array.from({length:normalizedBucketCount},(_,i)=>mixRgb(loRgb,hiRgb,i/(normalizedBucketCount-1)));return this.cachedRamp={key,colors,loRgb,hiRgb},this.cachedRamp}calendarCellSize(){const{weekCount}=this.cachedCalendarGrid;let size;if(this.fitToWidth&&weekCount>0){const hostWidth=this.clientWidth||CAL_PAD_LEFT+weekCount*(this.cellSize+CAL_GAP);size=this.clampFitCellSize((hostWidth-CAL_PAD_LEFT)/weekCount-CAL_GAP)}else size=this.cellSize;return this.accessibleCells?Math.max(size,this.accessibleTargetSizePx):size}clampFitCellSize(size){const floored=finiteRange(size,FIT_MIN_CELL,Math.max(FIT_MIN_CELL,this.minCellSize??FIT_MIN_CELL));return this.maxCellSize==null?floored:Math.min(floored,this.maxCellSize)}columnXFor(week){return this.calendarColumnPositions()[week]??CAL_PAD_LEFT}rowYFor(weekday){return this.calendarRowPositions()[weekday]??CAL_LABEL_H}calendarColumnPositions(){const cellSize=this.calendarCellSize(),weekCount=this.cachedCalendarGrid.weekCount,callback=this.calendarColumnX,cached=this.cachedColumnGeometry;if(cached!==void 0&&cached.callback===callback&&cached.cellSize===cellSize&&cached.weekCount===weekCount)return cached.positions;const positions=[];for(let index=0;index<=weekCount;index++){const fallback=index===0?CAL_PAD_LEFT:positions[index-1]+cellSize+CAL_GAP;let candidate=fallback;if(callback)try{const supplied=callback(index);Number.isFinite(supplied)&&supplied>=0&&(index===0||supplied>=positions[index-1]+cellSize)&&(candidate=supplied)}catch{candidate=fallback}positions.push(candidate)}return this.cachedColumnGeometry={callback,cellSize,weekCount,positions},positions}calendarRowPositions(){const cellSize=this.calendarCellSize(),callback=this.calendarRowY,cached=this.cachedRowGeometry;if(cached!==void 0&&cached.callback===callback&&cached.cellSize===cellSize)return cached.positions;const positions=[];for(let index=0;index<=7;index++){const fallback=index===0?CAL_LABEL_H:positions[index-1]+cellSize+CAL_GAP;let candidate=fallback;if(callback)try{const supplied=callback(index);Number.isFinite(supplied)&&supplied>=0&&(index===0||supplied>=positions[index-1]+cellSize)&&(candidate=supplied)}catch{candidate=fallback}positions.push(candidate)}return this.cachedRowGeometry={callback,cellSize,positions},positions}weekAtX(x,weekCount){const positions=this.calendarColumnPositions(),cellSize=this.calendarCellSize();for(let week=0;week<weekCount;week++){const start=positions[week];if(x>=start&&x<start+cellSize)return week}return null}weekdayAtY(y){const positions=this.calendarRowPositions(),cellSize=this.calendarCellSize();for(let weekday=0;weekday<7;weekday++){const start=positions[weekday];if(y>=start&&y<start+cellSize)return weekday}return null}weekdayLabels(firstWeekStart){const formatter=getDateTimeFormat(this.effectiveLocale||void 0,{weekday:"short",timeZone:"UTC"}),labels=["","","","","","",""];for(const weekday of[1,3,5]){const row=(weekday-this.normalizedFirstDayOfWeek+7)%7;labels[row]=this.calendarWeekdayLabelText?.(weekday)??formatter.format(new Date(firstWeekStart.getTime()+row*MS_PER_DAY))}return labels}drawCalendar(){if(!this.canvas)return;const{weekCount,firstWeekStart,monthLabels}=this.cachedCalendarGrid,cellSize=this.calendarCellSize(),w=this.columnXFor(Math.max(1,weekCount)),h=this.rowYFor(7),dpr=this.ownerDocument.defaultView?.devicePixelRatio||1;this.canvas.width=w*dpr,this.canvas.height=h*dpr,this.canvas.style.width=`${w}px`,this.canvas.style.height=`${h}px`;const ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.scale(dpr,dpr),ctx.clearRect(0,0,w,h);const cs=this.ownerDocument.defaultView?.getComputedStyle(this);if(!cs)return;const buckets=normalizeBucketCount(this.bucketCount),ramp=this.colorRamp(buckets,cs).colors,noDataFill=this.noDataFill(cs);this.canvasColorCache.clear();const bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1;for(let week=0;week<weekCount;week++)for(let weekday=0;weekday<7;weekday++){const value=this.cachedCalendarCellsByPos.get(`${week}:${weekday}`)?.value??-1,x=this.columnXFor(week),y=this.rowYFor(weekday),override=this.cellColor?.(this.calendarPos(week,weekday),value);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(this.isNoData(value))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(value,hi,ramp.length);ctx.fillStyle=step<0?noDataFill:ramp[step]}else if(this.cachedColorSteps.length>=2){const step=this.rampBucket(value,lo,hi,ramp.length);ctx.fillStyle=ramp[step]}else ctx.fillStyle=ramp[quartileBucket(value,this.cachedCalendarSortedValues,buckets)];ctx.fillRect(x,y,cellSize,cellSize)}if(this.cachedAnnotations.length)for(const ann of this.cachedAnnotations){if(ann.date==null)continue;const match=this.cachedCalendarCellsByDate.get(ann.date);if(!match)continue;const x=this.columnXFor(match.week),y=this.rowYFor(match.weekday);this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs))}if(this.selectedCell?.date!=null){const match=this.cachedCalendarCellsByDate.get(this.selectedCell.date);if(match){const x=this.columnXFor(match.week),y=this.rowYFor(match.weekday);this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs))}}if(this.focusedCell&&"week"in this.focusedCell){const{week,weekday}=this.focusedCell;if(week<weekCount&&weekday<7){const x=this.columnXFor(week),y=this.rowYFor(weekday);this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}}ctx.fillStyle=this.labelColor(cs),ctx.font=this.labelFont(cs);for(const m of monthLabels)ctx.fillText(m.label,this.columnXFor(m.week),CAL_LABEL_H-4);this.weekdayLabels(firstWeekStart).forEach((label,weekday)=>{label&&ctx.fillText(label,2,this.rowYFor(weekday)+cellSize-1)}),this.canvasHasContent=!0}matrixCellSize(cols){let size;if(this.fitToWidth&&cols>0){const padLeft=this.matrixPadLeft,hostWidth=this.clientWidth||padLeft+cols*this.cellSize;size=this.clampFitCellSize((hostWidth-padLeft)/cols)}else size=this.cellSize;return this.accessibleCells?Math.max(size,this.accessibleTargetSizePx):size}paintMatrixCell(ctx,row,col,cellSize,cs,rampData,noDataFill){const value=this.matrixValues[row]?.[col]??Number.NaN,bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1,override=this.cellColor?.({row,col},value);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(this.isNoData(value))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(value,hi,rampData.colors.length);ctx.fillStyle=step<0?noDataFill:rampData.colors[step]}else this.cachedColorSteps.length>=2?ctx.fillStyle=rampData.colors[this.rampBucket(value,lo,hi,rampData.colors.length)]:ctx.fillStyle=mixRgb(rampData.loRgb,rampData.hiRgb,this.rampAlpha(value,lo,hi));ctx.fillRect(this.matrixPadLeft+col*cellSize,this.matrixPadTop+row*cellSize,cellSize-1,cellSize-1)}paintMatrixFocusOverlays(ctx,row,col,cellSize,cs){const x=this.matrixPadLeft+col*cellSize,y=this.matrixPadTop+row*cellSize;this.cachedMatrixAnnotationPositions.has(`${row}:${col}`)&&this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs)),this.selectedCell?.row===row&&this.selectedCell.col===col&&this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs)),this.focusedCell&&"row"in this.focusedCell&&this.focusedCell.row===row&&this.focusedCell.col===col&&this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}repaintMatrixFocusCell(pos){if(!pos||!this.canvas)return;const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(pos.row<0||pos.row>=rows||pos.col<0||pos.col>=cols)return;const cellSize=this.matrixCellSize(cols),x=this.matrixPadLeft+pos.col*cellSize,y=this.matrixPadTop+pos.row*cellSize,ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.clearRect(x-RING_LINE_WIDTH-1,y-RING_LINE_WIDTH-1,cellSize+2*(RING_LINE_WIDTH+1),cellSize+2*(RING_LINE_WIDTH+1));const cs=this.ownerDocument.defaultView?.getComputedStyle(this);cs&&(this.paintMatrixCell(ctx,pos.row,pos.col,cellSize,cs,this.colorRamp(RAMP_STEPS,cs),this.noDataFill(cs)),this.paintMatrixFocusOverlays(ctx,pos.row,pos.col,cellSize,cs))}paintCalendarCell(ctx,week,weekday,cellSize,cs,ramp,noDataFill){const value=this.cachedCalendarCellsByPos.get(`${week}:${weekday}`)?.value??-1,bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1,override=this.cellColor?.(this.calendarPos(week,weekday),value);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(this.isNoData(value))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(value,hi,ramp.length);ctx.fillStyle=step<0?noDataFill:ramp[step]}else this.cachedColorSteps.length>=2?ctx.fillStyle=ramp[this.rampBucket(value,lo,hi,ramp.length)]:ctx.fillStyle=ramp[quartileBucket(value,this.cachedCalendarSortedValues,ramp.length)];ctx.fillRect(this.columnXFor(week),this.rowYFor(weekday),cellSize,cellSize)}paintCalendarFocusOverlays(ctx,week,weekday,cellSize,cs){const date=this.calendarDateAt(week,weekday),x=this.columnXFor(week),y=this.rowYFor(weekday),matches=candidate=>candidate?.date===date;this.cachedCalendarAnnotationDates.has(date)&&this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs)),matches(this.selectedCell??void 0)&&this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs)),this.focusedCell&&"week"in this.focusedCell&&this.focusedCell.week===week&&this.focusedCell.weekday===weekday&&this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}repaintCalendarFocusCell(pos){if(!pos||!this.canvas)return;const{weekCount,firstWeekStart}=this.cachedCalendarGrid;if(pos.week<0||pos.week>=weekCount||pos.weekday<0||pos.weekday>=7)return;const cellSize=this.calendarCellSize(),x=this.columnXFor(pos.week),y=this.rowYFor(pos.weekday),ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.clearRect(x-RING_LINE_WIDTH-1,y-RING_LINE_WIDTH-1,cellSize+2*(RING_LINE_WIDTH+1),cellSize+2*(RING_LINE_WIDTH+1));const cs=this.ownerDocument.defaultView?.getComputedStyle(this);if(!cs)return;const ramp=this.colorRamp(normalizeBucketCount(this.bucketCount),cs).colors;this.paintCalendarCell(ctx,pos.week,pos.weekday,cellSize,cs,ramp,this.noDataFill(cs)),this.paintCalendarFocusOverlays(ctx,pos.week,pos.weekday,cellSize,cs),ctx.fillStyle=this.labelColor(cs),ctx.font=this.labelFont(cs);for(const month of this.cachedCalendarGrid.monthLabels)ctx.fillText(month.label,this.columnXFor(month.week),CAL_LABEL_H-4);this.weekdayLabels(firstWeekStart).forEach((label,weekday)=>{label&&ctx.fillText(label,2,this.rowYFor(weekday)+cellSize-1)})}drawMatrix(){if(!this.canvas)return;const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(this.rowLabelWidth==="auto"||this.colLabelHeight==="auto"){const measureStyle=getComputedStyle(this);this.rowLabelWidth==="auto"&&(this.resolvedRowLabelWidth=this.measureRowLabelWidth(measureStyle)),this.colLabelHeight==="auto"&&(this.resolvedColLabelHeight=this.measureColLabelHeight(measureStyle))}const padLeft=this.matrixPadLeft,padTop=this.matrixPadTop,cellSize=this.matrixCellSize(cols),w=padLeft+cols*cellSize,h=padTop+rows*cellSize,dpr=this.ownerDocument.defaultView?.devicePixelRatio||1;this.canvas.width=w*dpr,this.canvas.height=h*dpr,this.canvas.style.width=`${w}px`,this.canvas.style.height=`${h}px`;const ctx=this.canvas.getContext("2d");if(!ctx)return;ctx.scale(dpr,dpr),ctx.clearRect(0,0,w,h);const cs=this.ownerDocument.defaultView?.getComputedStyle(this);if(!cs)return;const bounds=this.cachedValueRange,lo=bounds?bounds[0]:0,hi=bounds?bounds[1]:1,rampData=this.colorRamp(RAMP_STEPS,cs),ramp=rampData.colors,{loRgb,hiRgb}=rampData,noDataFill=this.noDataFill(cs);this.canvasColorCache.clear();for(let r=0;r<rows;r++)for(let c=0;c<cols;c++){const v=this.matrixValues[r]?.[c]??Number.NaN,x=padLeft+c*cellSize,y=padTop+r*cellSize,override=this.cellColor?.({row:r,col:c},v);if(override!=null)ctx.fillStyle=this.resolveCanvasColor(override,cs);else if(this.isNoData(v))ctx.fillStyle=noDataFill;else if(this.scale==="sqrt"){const step=sqrtStep(v,hi,ramp.length);ctx.fillStyle=step<0?noDataFill:ramp[step]}else if(this.cachedColorSteps.length>=2){const step=this.rampBucket(v,lo,hi,ramp.length);ctx.fillStyle=ramp[step]}else{const t=this.rampAlpha(v,lo,hi);ctx.fillStyle=mixRgb(loRgb,hiRgb,t)}ctx.fillRect(x,y,cellSize-1,cellSize-1)}if(this.cachedAnnotations.length)for(const ann of this.cachedAnnotations){if(ann.row==null||ann.col==null||ann.row<0||ann.row>=rows||ann.col<0||ann.col>=cols)continue;const x=padLeft+ann.col*cellSize,y=padTop+ann.row*cellSize;this.strokeCellState(ctx,x,y,cellSize,"annotation",this.annotationColor(cs))}if(this.selectedCell?.row!=null&&this.selectedCell.col!=null){const{row,col}=this.selectedCell;if(row>=0&&row<rows&&col>=0&&col<cols){const x=padLeft+col*cellSize,y=padTop+row*cellSize;this.strokeCellState(ctx,x,y,cellSize,"selected",this.selectedColor(cs))}}if(this.focusedCell&&"row"in this.focusedCell){const{row,col}=this.focusedCell;if(row<rows&&col<cols){const x=padLeft+col*cellSize,y=padTop+row*cellSize;this.strokeCellState(ctx,x,y,cellSize,"focus",this.focusRingColor(cs))}}ctx.fillStyle=this.labelColor(cs),ctx.font=this.labelFont(cs);const rowLabelSpace=padLeft-ROW_LABEL_INSET*2;this.matrixRowLabels.forEach((label,r)=>{const shown=this.ellipsize(ctx,label,rowLabelSpace);shown&&ctx.fillText(shown,ROW_LABEL_INSET,padTop+r*cellSize+cellSize/2+3)});const colRotation=this.effectiveColLabelRotation;if(colRotation===0)this.matrixColLabels.forEach((label,c)=>{ctx.fillText(label,padLeft+c*cellSize+2,padTop-COL_LABEL_INSET)});else{const radians=colRotation*Math.PI/180,previousAlign=ctx.textAlign;ctx.textAlign="right",this.matrixColLabels.forEach((label,c)=>{ctx.save(),ctx.translate(padLeft+c*cellSize+cellSize/2,padTop-COL_LABEL_INSET),ctx.rotate(radians),ctx.fillText(label,0,0),ctx.restore()}),ctx.textAlign=previousAlign}this.canvasHasContent=!0}hitTest(x,y){return this.effectiveMode==="calendar"?this.hitTestCalendar(x,y):this.hitTestMatrix(x,y)}hitTestMatrix(x,y){const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(rows===0||cols===0)return null;const cellSize=this.matrixCellSize(cols),col=Math.floor((x-this.matrixPadLeft)/cellSize),row=Math.floor((y-this.matrixPadTop)/cellSize);if(row<0||row>=rows||col<0||col>=cols)return null;const pos={row,col};return this.isCellInteractive(pos)?pos:null}firstInteractiveMatrixCell(rows,cols){for(let r=0;r<rows;r++)for(let c=0;c<cols;c++)if(this.isCellInteractive({row:r,col:c}))return{row:r,col:c};return null}nextInteractiveMatrixCell(row,col,dRow,dCol,rows,cols){let r=row,c=col;for(;;){const nr=Math.min(rows-1,Math.max(0,r+dRow)),nc=Math.min(cols-1,Math.max(0,c+dCol));if(nr===r&&nc===c)return{row,col};if(r=nr,c=nc,this.isCellInteractive({row:r,col:c}))return{row:r,col:c}}}firstInteractiveCalendarCell(weekCount){for(let week=0;week<weekCount;week++)for(let weekday=0;weekday<7;weekday++){const pos=this.calendarPos(week,weekday);if(this.isCellInteractive(pos))return pos}return null}nextInteractiveCalendarCell(week,weekday,dWeek,dWeekday,weekCount){let w=week,d=weekday;for(;;){const nw=Math.min(weekCount-1,Math.max(0,w+dWeek)),nd=Math.min(6,Math.max(0,d+dWeekday));if(nw===w&&nd===d)return this.calendarPos(week,weekday);w=nw,d=nd;const pos=this.calendarPos(w,d);if(this.isCellInteractive(pos))return pos}}hitTestCalendar(x,y){const{weekCount}=this.cachedCalendarGrid;if(weekCount===0)return null;const week=this.weekAtX(x,weekCount),weekday=this.weekdayAtY(y);if(week===null||weekday===null)return null;const pos=this.calendarPos(week,weekday);return this.isCellInteractive(pos)?pos:null}calendarCellAt(pos){const match=this.cachedCalendarCellsByPos.get(`${pos.week}:${pos.weekday}`);return match?{date:match.date,value:match.value}:{date:this.calendarDateAt(pos.week,pos.weekday),value:-1}}calendarDateAt(week,weekday){const index=week*7+weekday;return this.cachedCalendarDateByPos[index]??isoDateAtOffset(this.cachedCalendarGrid.firstWeekStart,index)}calendarPos(week,weekday){return{week,weekday,date:this.calendarDateAt(week,weekday)}}cellRect(pos){if("week"in pos){const cellSize2=this.calendarCellSize();return{x:this.columnXFor(pos.week),y:this.rowYFor(pos.weekday),w:cellSize2,h:cellSize2}}const cellSize=this.matrixCellSize(this.matrixColLabels.length);return{x:this.matrixPadLeft+pos.col*cellSize,y:this.matrixPadTop+pos.row*cellSize,w:cellSize-1,h:cellSize-1}}defaultCellText(pos){return"week"in pos?this.calendarCellText(pos):this.matrixCellText(pos)}matrixCellText(pos){const rowLabel=this.matrixRowLabels[pos.row]??this.localize("heatmapDefaultRowLabel",void 0,{n:this.formatCount(pos.row+1)}),colLabel=this.matrixColLabels[pos.col]??this.localize("heatmapDefaultColLabel",void 0,{n:this.formatCount(pos.col+1)}),v=this.matrixValues[pos.row]?.[pos.col],valueText=v==null||this.isNoData(v)?this.localize("heatmapNoDataValue"):this.formatNumericValue(v);return this.localize("heatmapMatrixCellLabel",void 0,{row:rowLabel,col:colLabel,value:valueText})}calendarCellText(pos){const{date,value}=this.calendarCellAt(pos),label=parseIsoDate(date).toLocaleString(this.effectiveLocale||void 0,{month:"short",day:"numeric",timeZone:"UTC"}),valueText=this.isNoData(value)?this.localize("heatmapNoDataValue"):this.formatNumericValue(value);return this.localize("heatmapCalendarCellLabel",void 0,{date:label,value:valueText})}valueAt(pos){return"week"in pos?this.calendarCellAt(pos).value:this.matrixValues[pos.row]?.[pos.col]??-1}resolveCellText(pos){return this.cellText?this.cellText(pos,this.valueAt(pos)):this.defaultCellText(pos)}isCellInteractive(pos){return this.cellInteractive?.(pos,this.valueAt(pos))??!0}announce(pos){const text=this.resolveCellText(pos),announcement=this.isSelectedPos(pos)?this.localize("heatmapSelectedCellLabel",void 0,{cell:text}):text;this.liveText=announcement,this.announcementSink?.announce(announcement)}emitCellClick(pos){if(this.isCellInteractive(pos))if("week"in pos){const{date,value}=this.calendarCellAt(pos);this.emit("lr-cell-click",{date,value})}else{const value=this.matrixValues[pos.row]?.[pos.col]??-1;this.emit("lr-cell-click",{row:pos.row,col:pos.col,value})}}tooltipStyle(pos){const rect=this.cellRect(pos);return{left:`${rect.x+rect.w/2}px`,top:`${rect.y}px`}}samePos(a,b){return a===b?!0:!a||!b?!1:"week"in a&&"week"in b?a.week===b.week&&a.weekday===b.weekday:"row"in a&&"row"in b?a.row===b.row&&a.col===b.col:!1}onMatrixKeyDown(e){const rows=this.matrixRowLabels.length,cols=this.matrixColLabels.length;if(rows===0||cols===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedCell&&this.emitCellClick(this.focusedCell);return}if(!ARROW_KEYS.has(e.key))return;if(e.preventDefault(),!this.focusedCell||!("row"in this.focusedCell)){const next2=this.firstInteractiveMatrixCell(rows,cols);if(!next2)return;this.focusedCell=next2,this.announce(next2);return}const{row,col}=this.focusedCell;let dRow=0,dCol=0;e.key==="ArrowUp"?dRow=-1:e.key==="ArrowDown"?dRow=1:e.key==="ArrowLeft"?dCol=-1:e.key==="ArrowRight"&&(dCol=1);const next=this.nextInteractiveMatrixCell(row,col,dRow,dCol,rows,cols);this.focusedCell=next,this.announce(next)}onCalendarKeyDown(e){const{weekCount}=this.cachedCalendarGrid;if(weekCount===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedCell&&this.emitCellClick(this.focusedCell);return}if(!ARROW_KEYS.has(e.key))return;if(e.preventDefault(),!this.focusedCell||!("week"in this.focusedCell)){const next2=this.firstInteractiveCalendarCell(weekCount);if(!next2)return;this.focusedCell=next2,this.announce(next2);return}const{week,weekday}=this.focusedCell;let dWeek=0,dWeekday=0;e.key==="ArrowUp"?dWeekday=-1:e.key==="ArrowDown"?dWeekday=1:e.key==="ArrowLeft"?dWeek=-1:e.key==="ArrowRight"&&(dWeek=1);const next=this.nextInteractiveCalendarCell(week,weekday,dWeek,dWeekday,weekCount);this.focusedCell=next,this.announce(next)}resolveCanvasColor(value,cs){const cached=this.canvasColorCache.get(value);if(cached!==void 0)return cached;const fallback=this.noDataFill(cs);let candidate=value;if(value.includes("var(")){if(this.colorProbe||(this.colorProbe=this.ownerDocument.createElement("span"),this.colorProbe.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none;",this.shadowRoot.appendChild(this.colorProbe)),this.colorProbe.style.color="",this.colorProbe.style.color=value,!this.colorProbe.style.color)return this.canvasColorCache.set(value,fallback),fallback;candidate=this.ownerDocument.defaultView?.getComputedStyle(this.colorProbe).color||fallback}const ctx=getScratchCtx(this.ownerDocument);if(!ctx)return fallback;ctx.fillStyle="rgb(1, 2, 3)";const firstSentinel=ctx.fillStyle;ctx.fillStyle=candidate;let resolved=ctx.fillStyle;if(resolved===firstSentinel){ctx.fillStyle="rgb(4, 5, 6)";const secondSentinel=ctx.fillStyle;ctx.fillStyle=candidate,resolved=ctx.fillStyle,resolved===secondSentinel&&(resolved=fallback)}return this.canvasColorCache.set(value,resolved),resolved}rebuildAccessiblePositions(){const positions=[];if(this.effectiveMode==="calendar"){const{weekCount}=this.cachedCalendarGrid;for(let week=0;week<weekCount;week++)for(let weekday=0;weekday<7;weekday++){const pos=this.calendarPos(week,weekday);this.isCellInteractive(pos)&&positions.push(pos)}}else for(let row=0;row<this.matrixRowLabels.length;row++)for(let col=0;col<this.matrixColLabels.length;col++){const pos={row,col};this.isCellInteractive(pos)&&positions.push(pos)}this.cachedAccessiblePositions=positions,this.cachedAccessiblePositionsByKey=new Map(positions.map(position=>[this.accessibleCellKey(position),position])),this.cachedAccessiblePositionIndexByKey=new Map(positions.map((position,index)=>[this.accessibleCellKey(position),index]))}accessibleCellPositions(){return this.cachedAccessiblePositions}accessibleCellKey(pos){return"week"in pos?`calendar-${pos.week}-${pos.weekday}`:`matrix-${pos.row}-${pos.col}`}accessibleCellIdentity(pos){return"week"in pos?pos.date:this.accessibleCellKey(pos)}accessibleCellAtKey(key){return this.cachedAccessiblePositionsByKey.get(key)??null}focusAccessibleCell(pos){pos&&this.updateComplete.then(()=>{[...this.shadowRoot?.querySelectorAll('[part="cell"]')??[]].find(candidate=>candidate.dataset.cellKey===this.accessibleCellKey(pos))?.focus()})}renderAccessibleCells(){if(!this.accessibleCells)return html``;const positions=this.accessibleCellPositions(),tabStop=this.focusedCell??positions[0]??null,focusIndex=tabStop?this.cachedAccessiblePositionIndexByKey.get(this.accessibleCellKey(tabStop))??0:0,start=Math.max(0,Math.min(Math.max(0,positions.length-MAX_ACCESSIBLE_HEATMAP_CELLS),focusIndex-Math.floor(MAX_ACCESSIBLE_HEATMAP_CELLS/2))),renderedPositions=positions.slice(start,start+MAX_ACCESSIBLE_HEATMAP_CELLS),renderedRows=new Map;for(const pos of renderedPositions){const rowIndex="week"in pos?pos.weekday+1:pos.row+1,row=renderedRows.get(rowIndex);row?row.push(pos):renderedRows.set(rowIndex,[pos])}const rowCount=this.effectiveMode==="calendar"?7:this.matrixRowLabels.length,colCount=this.effectiveMode==="calendar"?this.cachedCalendarGrid.weekCount:this.matrixColLabels.length;return html`
2
2
  <div
3
3
  part="cells"
4
4
  role="grid"
@@ -92,4 +92,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
92
92
  >`)}
93
93
  </div>
94
94
  </div>
95
- `}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}}__decorate([property({attribute:!1})],LyraHeatmap.prototype,"data",void 0),__decorate([property({type:Number,attribute:"cell-size",converter:optionalCellSizeConverter})],LyraHeatmap.prototype,"cellSize",null),__decorate([property({attribute:"value-label"})],LyraHeatmap.prototype,"valueLabel",void 0),__decorate([property()],LyraHeatmap.prototype,"scale",void 0),__decorate([property({type:Boolean,attribute:"fit-to-width"})],LyraHeatmap.prototype,"fitToWidth",void 0),__decorate([property({type:Number,attribute:"max-cell-size",converter:optionalCellSizeConverter})],LyraHeatmap.prototype,"maxCellSize",null),__decorate([property({type:Number,attribute:"min-cell-size",converter:optionalCellSizeConverter})],LyraHeatmap.prototype,"minCellSize",null),__decorate([property({attribute:"bucket-count",converter:bucketCountConverter})],LyraHeatmap.prototype,"bucketCount",null),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"annotations",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"legendStops",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"selectedCell",void 0),__decorate([property({type:Boolean,attribute:"accessible-cells"})],LyraHeatmap.prototype,"accessibleCells",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"cellText",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"cellInteractive",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"cellColor",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"colorSteps",void 0),__decorate([query("canvas")],LyraHeatmap.prototype,"canvas",void 0),__decorate([state()],LyraHeatmap.prototype,"hoverCell",void 0),__decorate([state()],LyraHeatmap.prototype,"focusedCell",void 0),__decorate([state()],LyraHeatmap.prototype,"liveText",void 0),__decorate([state()],LyraHeatmap.prototype,"accessibleTargetSizePx",void 0);export{LyraHeatmap,MAX_ACCESSIBLE_HEATMAP_CELLS,MAX_BUCKET_COUNT,MAX_HEATMAP_CELLS,MAX_HEATMAP_DECORATIONS,hexToRgb,normalizeBucketCount,resolveRgb};
95
+ `}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}}__decorate([property({attribute:!1})],LyraHeatmap.prototype,"data",void 0),__decorate([property({converter:labelExtentConverter,attribute:"row-label-width",reflect:!0})],LyraHeatmap.prototype,"rowLabelWidth",void 0),__decorate([property({converter:labelExtentConverter,attribute:"col-label-height"})],LyraHeatmap.prototype,"colLabelHeight",void 0),__decorate([property({type:Number,attribute:"col-label-rotation"})],LyraHeatmap.prototype,"colLabelRotation",void 0),__decorate([property({type:Number,attribute:"cell-size",converter:optionalCellSizeConverter})],LyraHeatmap.prototype,"cellSize",null),__decorate([property({attribute:"value-label"})],LyraHeatmap.prototype,"valueLabel",void 0),__decorate([property()],LyraHeatmap.prototype,"scale",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"domain",void 0),__decorate([property({type:Number})],LyraHeatmap.prototype,"midpoint",void 0),__decorate([property({type:Boolean,attribute:"fit-to-width"})],LyraHeatmap.prototype,"fitToWidth",void 0),__decorate([property({type:Number,attribute:"max-cell-size",converter:optionalCellSizeConverter})],LyraHeatmap.prototype,"maxCellSize",null),__decorate([property({type:Number,attribute:"min-cell-size",converter:optionalCellSizeConverter})],LyraHeatmap.prototype,"minCellSize",null),__decorate([property({attribute:"bucket-count",converter:bucketCountConverter})],LyraHeatmap.prototype,"bucketCount",null),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"annotations",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"legendStops",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"selectedCell",void 0),__decorate([property({type:Boolean,attribute:"accessible-cells"})],LyraHeatmap.prototype,"accessibleCells",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"cellText",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"cellInteractive",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"cellColor",void 0),__decorate([property({attribute:!1})],LyraHeatmap.prototype,"colorSteps",void 0),__decorate([query("canvas")],LyraHeatmap.prototype,"canvas",void 0),__decorate([state()],LyraHeatmap.prototype,"hoverCell",void 0),__decorate([state()],LyraHeatmap.prototype,"focusedCell",void 0),__decorate([state()],LyraHeatmap.prototype,"liveText",void 0),__decorate([state()],LyraHeatmap.prototype,"accessibleTargetSizePx",void 0);export{LyraHeatmap,MAX_ACCESSIBLE_HEATMAP_CELLS,MAX_BUCKET_COUNT,MAX_HEATMAP_CELLS,MAX_HEATMAP_DECORATIONS,hexToRgb,normalizeBucketCount,resolveRgb};