@aceshooting/lyra-ui 29.0.2 → 29.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +19 -26
  3. package/design-tokens.json +1 -1
  4. package/dist/cli/migrate-wa.mjs +2 -0
  5. package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +5 -3
  6. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +4 -3
  7. package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +1 -1
  8. package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +21 -5
  9. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +14 -11
  10. package/dist/components/agent-tools/agent-trace/agent-trace.styles.js +1 -1
  11. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
  12. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.d.ts +34 -7
  13. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +25 -11
  14. package/dist/components/agent-tools/eval-result/eval-result-source.js +1 -0
  15. package/dist/components/agent-tools/eval-result/eval-result.class.d.ts +31 -11
  16. package/dist/components/agent-tools/eval-result/eval-result.class.js +29 -15
  17. package/dist/components/agent-tools/eval-result/eval-result.styles.js +1 -1
  18. package/dist/components/agent-tools/eval-result/eval-run-result.d.ts +10 -0
  19. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.d.ts +26 -5
  20. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +16 -6
  21. package/dist/components/agent-tools/span-waterfall/span-waterfall.d.ts +1 -1
  22. package/dist/components/agent-tools/span-waterfall/span-waterfall.js +1 -1
  23. package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +1 -1
  24. package/dist/components/agent-tools/task-list/task-list.class.d.ts +29 -6
  25. package/dist/components/agent-tools/task-list/task-list.class.js +13 -7
  26. package/dist/components/agent-tools/task-list/task-list.d.ts +1 -1
  27. package/dist/components/agent-tools/task-list/task-list.js +1 -1
  28. package/dist/components/agent-tools/task-list/task-list.styles.js +1 -1
  29. package/dist/components/agent-tools/terminal/terminal.class.d.ts +9 -5
  30. package/dist/components/agent-tools/terminal/terminal.class.js +8 -8
  31. package/dist/components/agent-tools/test-results/test-results.class.d.ts +16 -4
  32. package/dist/components/agent-tools/test-results/test-results.class.js +15 -6
  33. package/dist/components/agent-tools/test-results/test-results.d.ts +1 -0
  34. package/dist/components/agent-tools/test-results/test-results.js +1 -1
  35. package/dist/components/agent-tools/test-results/test-results.styles.js +1 -1
  36. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +7 -4
  37. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +2 -1
  38. package/dist/components/agent-tools/trace-tree/span-projection.js +1 -0
  39. package/dist/components/agent-tools/trace-tree/span-shared.d.ts +29 -0
  40. package/dist/components/agent-tools/trace-tree/span-shared.js +1 -0
  41. package/dist/components/agent-tools/trace-tree/span.d.ts +5 -35
  42. package/dist/components/agent-tools/trace-tree/span.js +1 -1
  43. package/dist/components/agent-tools/trace-tree/trace-tree.class.d.ts +27 -5
  44. package/dist/components/agent-tools/trace-tree/trace-tree.class.js +19 -9
  45. package/dist/components/agent-tools/trace-tree/trace-tree.d.ts +1 -1
  46. package/dist/components/agent-tools/trace-tree/trace-tree.js +1 -1
  47. package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +1 -1
  48. package/dist/components/charts/chart/bar-chart.class.d.ts +5 -1
  49. package/dist/components/charts/chart/box-plot.class.d.ts +2 -2
  50. package/dist/components/charts/chart/box-plot.class.js +3 -3
  51. package/dist/components/charts/chart/bubble-chart.class.d.ts +5 -1
  52. package/dist/components/charts/chart/chart-prepared-data.d.ts +9 -0
  53. package/dist/components/charts/chart/chart-prepared-data.js +1 -0
  54. package/dist/components/charts/chart/chart-spatial-data.js +2 -0
  55. package/dist/components/charts/chart/chart-sync.js +1 -1
  56. package/dist/components/charts/chart/chart-table-sampling.js +1 -1
  57. package/dist/components/charts/chart/chart.class.d.ts +56 -6
  58. package/dist/components/charts/chart/chart.class.js +18 -8
  59. package/dist/components/charts/chart/chart.styles.js +1 -1
  60. package/dist/components/charts/chart/doughnut-chart.class.d.ts +5 -1
  61. package/dist/components/charts/chart/histogram-buckets.d.ts +1 -1
  62. package/dist/components/charts/chart/histogram-buckets.js +1 -1
  63. package/dist/components/charts/chart/histogram.class.d.ts +19 -4
  64. package/dist/components/charts/chart/histogram.class.js +1 -1
  65. package/dist/components/charts/chart/line-chart.class.d.ts +5 -1
  66. package/dist/components/charts/chart/lite-chart.class.d.ts +51 -11
  67. package/dist/components/charts/chart/lite-chart.class.js +33 -27
  68. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  69. package/dist/components/charts/chart/pie-chart.class.d.ts +5 -1
  70. package/dist/components/charts/chart/polar-area-chart.class.d.ts +5 -1
  71. package/dist/components/charts/chart/radar-chart.class.d.ts +5 -1
  72. package/dist/components/charts/chart/scatter-chart.class.d.ts +5 -1
  73. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +6 -3
  74. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +6 -5
  75. package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +1 -1
  76. package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +8 -0
  77. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  78. package/dist/components/conversation/code-block/code-block-base.class.d.ts +5 -3
  79. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  80. package/dist/components/conversation/code-block/code-block-core.class.d.ts +4 -1
  81. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  82. package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -4
  83. package/dist/components/conversation/code-block/code-block-shared.js +3 -2
  84. package/dist/components/conversation/code-block/code-block.class.d.ts +11 -4
  85. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  86. package/dist/components/conversation/code-block/code-block.d.ts +1 -1
  87. package/dist/components/conversation/code-block/code-block.styles.js +1 -1
  88. package/dist/components/conversation/code-block/shiki-types.d.ts +2 -0
  89. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  90. package/dist/components/conversation/markdown/markdown-base.class.d.ts +6 -4
  91. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  92. package/dist/components/conversation/markdown/markdown-code-header.d.ts +2 -2
  93. package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
  94. package/dist/components/conversation/markdown/markdown-core.class.d.ts +8 -3
  95. package/dist/components/conversation/markdown/markdown-progressive.js +2 -2
  96. package/dist/components/conversation/markdown/markdown-shared.d.ts +5 -10
  97. package/dist/components/conversation/markdown/markdown-shared.js +5 -5
  98. package/dist/components/conversation/markdown/markdown-streaming-tail.js +1 -1
  99. package/dist/components/conversation/markdown/markdown.class.d.ts +17 -10
  100. package/dist/components/conversation/markdown/markdown.class.js +1 -1
  101. package/dist/components/conversation/markdown/markdown.styles.js +1 -1
  102. package/dist/components/conversation/model-select/model-select.class.d.ts +4 -3
  103. package/dist/components/conversation/model-select/model-select.class.js +3 -2
  104. package/dist/components/conversation/model-select/model-select.styles.js +1 -1
  105. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.d.ts +2 -1
  106. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +2 -1
  107. package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +1 -1
  108. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -2
  109. package/dist/components/conversation/prompt-input/prompt-input.class.js +2 -1
  110. package/dist/components/conversation/prompt-input/prompt-input.styles.js +1 -1
  111. package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +10 -2
  112. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +15 -6
  113. package/dist/components/conversation/prompt-queue/prompt-queue.styles.js +1 -1
  114. package/dist/components/conversation/realtime-session/realtime-session.class.d.ts +3 -1
  115. package/dist/components/conversation/realtime-session/realtime-session.class.js +2 -1
  116. package/dist/components/conversation/realtime-session/realtime-session.styles.js +1 -1
  117. package/dist/components/conversation/streaming-text/markdown-detection.d.ts +2 -0
  118. package/dist/components/conversation/streaming-text/markdown-detection.js +4 -1
  119. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +6 -2
  120. package/dist/components/conversation/streaming-text/streaming-text-base.class.js +3 -3
  121. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -1
  122. package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
  123. package/dist/components/conversation/thread-list/thread-list.class.d.ts +34 -4
  124. package/dist/components/conversation/thread-list/thread-list.class.js +22 -15
  125. package/dist/components/conversation/thread-list/thread-list.d.ts +1 -1
  126. package/dist/components/conversation/thread-list/thread-list.js +1 -1
  127. package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
  128. package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +6 -2
  129. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +3 -2
  130. package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +1 -1
  131. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +3 -2
  132. package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -2
  133. package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
  134. package/dist/components/data/calendar/calendar.class.d.ts +5 -2
  135. package/dist/components/data/calendar/calendar.class.js +1 -1
  136. package/dist/components/data/data-grid/data-grid-processing.js +2 -2
  137. package/dist/components/data/data-grid/data-grid.class.d.ts +22 -8
  138. package/dist/components/data/data-grid/data-grid.class.js +20 -19
  139. package/dist/components/data/data-grid/data-grid.styles.js +1 -1
  140. package/dist/components/data/document-library/document-library.class.d.ts +31 -4
  141. package/dist/components/data/document-library/document-library.class.js +25 -12
  142. package/dist/components/data/document-library/document-library.styles.js +1 -1
  143. package/dist/components/data/file-tree/file-tree.class.d.ts +30 -6
  144. package/dist/components/data/file-tree/file-tree.class.js +4 -3
  145. package/dist/components/data/file-tree/file-tree.d.ts +1 -0
  146. package/dist/components/data/file-tree/file-tree.js +1 -1
  147. package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +31 -6
  148. package/dist/components/data/flow-canvas/flow-canvas.class.js +40 -19
  149. package/dist/components/data/flow-canvas/flow-canvas.styles.js +1 -1
  150. package/dist/components/data/flow-canvas/flow-model.js +1 -1
  151. package/dist/components/data/flow-canvas/flow-source.js +1 -0
  152. package/dist/components/data/flow-canvas/flow-types.d.ts +4 -2
  153. package/dist/components/data/flow-canvas/flow-viewport-index.js +1 -0
  154. package/dist/components/data/flow-minimap/flow-minimap.class.d.ts +9 -3
  155. package/dist/components/data/flow-minimap/flow-minimap.class.js +11 -2
  156. package/dist/components/data/flow-minimap/flow-minimap.styles.js +1 -1
  157. package/dist/components/data/funnel/funnel.class.d.ts +7 -3
  158. package/dist/components/data/funnel/funnel.class.js +2 -2
  159. package/dist/components/data/heatmap/calendar-grid.d.ts +1 -1
  160. package/dist/components/data/heatmap/calendar-grid.js +1 -1
  161. package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -1
  162. package/dist/components/data/heatmap/heatmap-limits.d.ts +1 -1
  163. package/dist/components/data/heatmap/heatmap-matrix-source-controller.js +1 -0
  164. package/dist/components/data/heatmap/heatmap-matrix-source.d.ts +5 -0
  165. package/dist/components/data/heatmap/heatmap-matrix-source.js +1 -0
  166. package/dist/components/data/heatmap/heatmap-scale.d.ts +0 -16
  167. package/dist/components/data/heatmap/heatmap-scale.js +1 -1
  168. package/dist/components/data/heatmap/heatmap.class.d.ts +40 -11
  169. package/dist/components/data/heatmap/heatmap.class.js +26 -6
  170. package/dist/components/data/heatmap/heatmap.styles.js +1 -1
  171. package/dist/components/data/pagination/pagination.class.js +1 -1
  172. package/dist/components/data/sequence-strip/sequence-strip-item.d.ts +17 -0
  173. package/dist/components/data/sequence-strip/sequence-strip-source-controller.js +1 -0
  174. package/dist/components/data/sequence-strip/sequence-strip-source.d.ts +5 -0
  175. package/dist/components/data/sequence-strip/sequence-strip-source.js +1 -0
  176. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +24 -19
  177. package/dist/components/data/sequence-strip/sequence-strip.class.js +23 -4
  178. package/dist/components/data/sequence-strip/sequence-strip.styles.js +1 -1
  179. package/dist/components/data/sparkline/sparkline.class.d.ts +17 -4
  180. package/dist/components/data/sparkline/sparkline.class.js +3 -3
  181. package/dist/components/data/sparkline/sparkline.styles.js +1 -1
  182. package/dist/components/data/table/table.class.d.ts +14 -10
  183. package/dist/components/data/table/table.class.js +17 -16
  184. package/dist/components/data/timeline/timeline.class.d.ts +5 -2
  185. package/dist/components/data/timeline/timeline.class.js +1 -1
  186. package/dist/components/data/tree/tree-item.class.js +1 -1
  187. package/dist/components/data/tree/tree-owner-controller.js +1 -1
  188. package/dist/components/data/tree/tree.class.d.ts +28 -6
  189. package/dist/components/data/tree/tree.class.js +3 -3
  190. package/dist/components/data/tree/tree.d.ts +1 -0
  191. package/dist/components/data/tree/tree.js +1 -1
  192. package/dist/components/data/word-cloud/word-cloud.class.d.ts +17 -7
  193. package/dist/components/data/word-cloud/word-cloud.class.js +6 -4
  194. package/dist/components/data/word-cloud/word-cloud.styles.js +1 -1
  195. package/dist/components/forms/catalog-picker-base.d.ts +1 -1
  196. package/dist/components/forms/catalog-picker-base.js +6 -6
  197. package/dist/components/forms/catalog-picker-base.styles.js +1 -1
  198. package/dist/components/forms/combobox/combobox.class.d.ts +7 -3
  199. package/dist/components/forms/combobox/combobox.class.js +1 -1
  200. package/dist/components/forms/combobox/option.class.d.ts +4 -2
  201. package/dist/components/forms/combobox/option.class.js +2 -2
  202. package/dist/components/forms/country-picker/country-picker.class.d.ts +3 -1
  203. package/dist/components/forms/country-picker/country-picker.class.js +1 -1
  204. package/dist/components/forms/currency-picker/currency-picker.class.d.ts +2 -0
  205. package/dist/components/forms/currency-picker/currency-picker.class.js +1 -1
  206. package/dist/components/forms/currency-picker/currency-presentation.js +1 -1
  207. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +6 -2
  208. package/dist/components/forms/emoji-picker/emoji-picker.class.js +3 -2
  209. package/dist/components/forms/emoji-picker/emoji-picker.styles.js +1 -1
  210. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +8 -2
  211. package/dist/components/forms/locale-picker/locale-picker.class.js +5 -4
  212. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
  213. package/dist/components/forms/select/select.class.d.ts +11 -3
  214. package/dist/components/forms/select/select.class.js +4 -4
  215. package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +2 -0
  216. package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -1
  217. package/dist/components/forms/token-input/token-input.class.d.ts +6 -1
  218. package/dist/components/forms/token-input/token-input.class.js +15 -13
  219. package/dist/components/forms/unit-picker/unit-picker.class.d.ts +2 -0
  220. package/dist/components/forms/unit-picker/unit-picker.class.js +1 -1
  221. package/dist/components/layout/app-rail/app-rail.class.d.ts +1 -1
  222. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  223. package/dist/components/layout/command-palette/command-palette.class.d.ts +5 -2
  224. package/dist/components/layout/command-palette/command-palette.class.js +2 -1
  225. package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
  226. package/dist/components/layout/menu/menu-item.class.d.ts +2 -2
  227. package/dist/components/layout/menu/menu-item.class.js +2 -2
  228. package/dist/components/layout/menu/menu.class.d.ts +1 -1
  229. package/dist/components/layout/menu/menu.class.js +1 -1
  230. package/dist/components/layout/menubar/menubar.class.d.ts +1 -1
  231. package/dist/components/layout/menubar/menubar.class.js +1 -1
  232. package/dist/components/layout/reorder-list/reorder-item.class.d.ts +2 -2
  233. package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
  234. package/dist/components/layout/reorder-list/reorder-list.class.d.ts +1 -1
  235. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  236. package/dist/components/layout/virtual-list/virtual-list.class.d.ts +13 -9
  237. package/dist/components/layout/virtual-list/virtual-list.class.js +21 -17
  238. package/dist/components/media/av-player/av-cue-index.js +1 -0
  239. package/dist/components/media/av-player/av-cue-source.d.ts +13 -0
  240. package/dist/components/media/av-player/av-cue-source.js +1 -0
  241. package/dist/components/media/av-player/av-metadata.d.ts +2 -2
  242. package/dist/components/media/av-player/av-metadata.js +1 -1
  243. package/dist/components/media/av-player/av-player-cue-source-controller.js +1 -0
  244. package/dist/components/media/av-player/av-player.class.d.ts +34 -12
  245. package/dist/components/media/av-player/av-player.class.js +15 -10
  246. package/dist/components/media/flag/flag.class.js +1 -1
  247. package/dist/components/media/flag/language-map.js +1 -1
  248. package/dist/components/media/lightbox/lightbox-source.js +1 -0
  249. package/dist/components/media/lightbox/lightbox-types.d.ts +15 -0
  250. package/dist/components/media/lightbox/lightbox.class.d.ts +22 -21
  251. package/dist/components/media/lightbox/lightbox.class.js +6 -4
  252. package/dist/components/media/lightbox/lightbox.styles.js +1 -1
  253. package/dist/components/media/map/map-geojson-diff.d.ts +6 -6
  254. package/dist/components/media/map/map-geojson-diff.js +1 -1
  255. package/dist/components/media/map/map-loader.d.ts +5 -1
  256. package/dist/components/media/map/map.class.d.ts +24 -6
  257. package/dist/components/media/map/map.class.js +2 -2
  258. package/dist/components/media/map/map.styles.js +1 -1
  259. package/dist/components/media/video-playlist/video-playlist.class.d.ts +2 -1
  260. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  261. package/dist/components/overlays/chip/chip.class.d.ts +1 -1
  262. package/dist/components/overlays/chip/chip.class.js +1 -1
  263. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +30 -8
  264. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +22 -8
  265. package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +1 -1
  266. package/dist/components/retrieval/graph/graph-canvas.js +1 -1
  267. package/dist/components/retrieval/graph/graph-source-composition.js +1 -0
  268. package/dist/components/retrieval/graph/graph-source-controller.js +1 -0
  269. package/dist/components/retrieval/graph/graph-spatial-controller.js +2 -2
  270. package/dist/components/retrieval/graph/graph-spatial-model.js +1 -0
  271. package/dist/components/retrieval/graph/graph-spatial.js +1 -1
  272. package/dist/components/retrieval/graph/graph.class.d.ts +31 -6
  273. package/dist/components/retrieval/graph/graph.class.js +26 -5
  274. package/dist/components/retrieval/graph/graph.d.ts +1 -1
  275. package/dist/components/retrieval/graph/graph.js +1 -1
  276. package/dist/components/retrieval/graph/graph.styles.js +1 -1
  277. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +33 -4
  278. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +27 -17
  279. package/dist/components/retrieval/ingestion-queue/ingestion-queue.d.ts +1 -1
  280. package/dist/components/retrieval/ingestion-queue/ingestion-queue.js +1 -1
  281. package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
  282. package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +27 -4
  283. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +29 -14
  284. package/dist/components/retrieval/knowledge-base/knowledge-base.styles.js +1 -1
  285. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +17 -3
  286. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +15 -10
  287. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +1 -1
  288. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +24 -5
  289. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +17 -10
  290. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.d.ts +1 -1
  291. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.js +1 -1
  292. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +1 -1
  293. package/dist/components/retrieval/mind-map/mind-map-layout.js +1 -1
  294. package/dist/components/retrieval/mind-map/mind-map-model.js +1 -0
  295. package/dist/components/retrieval/mind-map/mind-map.class.d.ts +27 -4
  296. package/dist/components/retrieval/mind-map/mind-map.class.js +11 -7
  297. package/dist/components/retrieval/mind-map/mind-map.d.ts +1 -0
  298. package/dist/components/retrieval/mind-map/mind-map.js +1 -1
  299. package/dist/components/retrieval/mind-map/mind-map.styles.js +1 -1
  300. package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +24 -2
  301. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +17 -3
  302. package/dist/components/retrieval/neighbor-list/neighbor-list.d.ts +1 -1
  303. package/dist/components/retrieval/neighbor-list/neighbor-list.js +1 -1
  304. package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +1 -1
  305. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +8 -4
  306. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +11 -7
  307. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.styles.js +1 -1
  308. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.d.ts +12 -6
  309. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +30 -17
  310. package/dist/components/retrieval/retrieval-compare/retrieval-compare.styles.js +1 -1
  311. package/dist/components/retrieval/retrieval-results/retrieval-results-model.js +1 -0
  312. package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +46 -5
  313. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +31 -9
  314. package/dist/components/retrieval/retrieval-results/retrieval-results.d.ts +1 -1
  315. package/dist/components/retrieval/retrieval-results/retrieval-results.js +1 -1
  316. package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +1 -1
  317. package/dist/components/utility/diff-view/diff-view.class.d.ts +16 -8
  318. package/dist/components/utility/diff-view/diff-view.class.js +3 -2
  319. package/dist/components/utility/diff-view/diff-view.styles.js +1 -1
  320. package/dist/components/utility/json-viewer/json-viewer.class.d.ts +31 -3
  321. package/dist/components/utility/json-viewer/json-viewer.class.js +13 -4
  322. package/dist/components/utility/json-viewer/json-viewer.d.ts +1 -0
  323. package/dist/components/utility/json-viewer/json-viewer.js +1 -1
  324. package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
  325. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +6 -4
  326. package/dist/components/utility/mention-popover/mention-popover.class.js +6 -5
  327. package/dist/components/viewers/csv-viewer/csv-viewer.class.d.ts +34 -7
  328. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +9 -7
  329. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.d.ts +28 -4
  330. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +12 -11
  331. package/dist/components/viewers/geojson-view/geojson-viewer.class.d.ts +3 -1
  332. package/dist/components/viewers/geojson-view/geojson-viewer.class.js +17 -16
  333. package/dist/components/viewers/geojson-view/geojson-viewer.d.ts +1 -1
  334. package/dist/components/viewers/geojson-view/geojson-viewer.js +1 -1
  335. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.d.ts +31 -5
  336. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +11 -8
  337. package/dist/components/viewers/table-viewer-shared.js +19 -3
  338. package/dist/components/viewers/viewer-search-limits.js +1 -1
  339. package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +35 -3
  340. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +20 -5
  341. package/dist/components/viewers/xml-viewer/xml-viewer.d.ts +1 -1
  342. package/dist/components/viewers/xml-viewer/xml-viewer.js +1 -1
  343. package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +1 -1
  344. package/dist/countries.js +1 -1
  345. package/dist/data-sources.d.ts +34 -0
  346. package/dist/data-sources.js +1 -0
  347. package/dist/events.d.ts +51 -7
  348. package/dist/framework-types.d.ts +1 -1
  349. package/dist/internal/accessibility-visibility.d.ts +4 -2
  350. package/dist/internal/accessibility-visibility.js +1 -1
  351. package/dist/internal/accessible-text-controller.js +1 -1
  352. package/dist/internal/anchor-target.js +2 -2
  353. package/dist/internal/catalog-picker.d.ts +1 -7
  354. package/dist/internal/catalog-picker.js +1 -1
  355. package/dist/internal/collection-snapshot.js +1 -1
  356. package/dist/internal/default-strings/agent-tools.generated.js +1 -1
  357. package/dist/internal/default-strings/charts.generated.js +1 -1
  358. package/dist/internal/default-strings/conversation.generated.js +1 -1
  359. package/dist/internal/default-strings/data.generated.js +1 -1
  360. package/dist/internal/default-strings/forms.generated.js +1 -1
  361. package/dist/internal/default-strings/layout.generated.js +1 -1
  362. package/dist/internal/default-strings/media.generated.js +1 -1
  363. package/dist/internal/default-strings/retrieval.generated.js +1 -1
  364. package/dist/internal/default-strings/shared.generated.js +1 -1
  365. package/dist/internal/default-strings/utility.generated.js +1 -1
  366. package/dist/internal/delimited-data.js +1 -1
  367. package/dist/internal/fixed-containing-block.js +1 -1
  368. package/dist/internal/flow-scene-envelope.js +1 -0
  369. package/dist/internal/graph-scene-controller.js +1 -0
  370. package/dist/internal/hierarchy-source-controller.js +1 -0
  371. package/dist/internal/hierarchy-source-view.js +29 -0
  372. package/dist/internal/hierarchy-source-view.styles.js +1 -0
  373. package/dist/internal/inherited-attribute-hub.d.ts +6 -0
  374. package/dist/internal/inherited-attribute-hub.js +1 -1
  375. package/dist/internal/intl-cache.js +1 -1
  376. package/dist/internal/keyed-index.js +1 -0
  377. package/dist/internal/localization-types.d.ts +1 -1
  378. package/dist/internal/localization.js +2 -2
  379. package/dist/internal/lyra-element.d.ts +2 -2
  380. package/dist/internal/lyra-element.js +3 -2
  381. package/dist/internal/native-modal-context.js +1 -1
  382. package/dist/internal/option-selection.js +1 -1
  383. package/dist/internal/package-metadata.js +1 -1
  384. package/dist/internal/positioner.js +1 -1
  385. package/dist/internal/resource-loader.d.ts +2 -0
  386. package/dist/internal/resource-loader.js +1 -1
  387. package/dist/internal/scoped-definitions.generated.js +1 -1
  388. package/dist/internal/search-haystack.js +1 -0
  389. package/dist/internal/selection-catalog.d.ts +5 -0
  390. package/dist/internal/selection-catalog.js +1 -1
  391. package/dist/internal/shiki-language-sources.js +1 -0
  392. package/dist/internal/source-page-controller.js +1 -0
  393. package/dist/internal/source-page-scope.js +1 -0
  394. package/dist/internal/source-request-controller.js +1 -0
  395. package/dist/internal/source-window-controller.js +1 -0
  396. package/dist/internal/spatial-source-controller.js +1 -0
  397. package/dist/internal/text-quote.d.ts +2 -6
  398. package/dist/internal/text-quote.js +1 -1
  399. package/dist/internal/theme-watcher.js +1 -1
  400. package/dist/internal/virtual-list-composition.js +1 -0
  401. package/dist/lyra.d.ts +1 -1
  402. package/dist/lyra.js +1 -1
  403. package/dist/testing/interaction-drivers.js +1 -1
  404. package/dist/testing/lyra-tag-event-map.js +1 -1
  405. package/dist/units.js +1 -1
  406. package/dist/utilities/data-preparation.d.ts +56 -0
  407. package/dist/utilities/data-preparation.js +1 -0
  408. package/dist/utilities/data-spatial.d.ts +26 -0
  409. package/dist/utilities/data-spatial.js +1 -0
  410. package/dist/utilities/index.d.ts +1 -1
  411. package/dist/utilities/index.js +1 -1
  412. package/llms/components/lr-activity-feed.md +7 -2
  413. package/llms/components/lr-agent-trace.md +49 -9
  414. package/llms/components/lr-agent-workspace.md +15 -8
  415. package/llms/components/lr-av-player.md +180 -10
  416. package/llms/components/lr-bar-chart.md +1 -1
  417. package/llms/components/lr-box-plot.md +8 -0
  418. package/llms/components/lr-bubble-chart.md +1 -1
  419. package/llms/components/lr-calendar.md +26 -3
  420. package/llms/components/lr-chart.md +310 -23
  421. package/llms/components/lr-chat-viewport.md +6 -0
  422. package/llms/components/lr-code-block-core.md +12 -7
  423. package/llms/components/lr-code-block.md +23 -9
  424. package/llms/components/lr-combobox.md +27 -15
  425. package/llms/components/lr-command-palette.md +16 -3
  426. package/llms/components/lr-country-picker.md +23 -6
  427. package/llms/components/lr-csv-viewer.md +95 -12
  428. package/llms/components/lr-currency-picker.md +23 -3
  429. package/llms/components/lr-data-grid.md +24 -6
  430. package/llms/components/lr-dataset-viewer.md +92 -11
  431. package/llms/components/lr-dialog.md +1 -1
  432. package/llms/components/lr-diff-view.md +19 -6
  433. package/llms/components/lr-document-library.md +60 -5
  434. package/llms/components/lr-doughnut-chart.md +1 -1
  435. package/llms/components/lr-embedding-explorer.md +89 -9
  436. package/llms/components/lr-emoji-picker.md +7 -2
  437. package/llms/components/lr-eval-dataset.md +56 -7
  438. package/llms/components/lr-eval-result.md +89 -4
  439. package/llms/components/lr-export-button.md +1 -1
  440. package/llms/components/lr-file-tree.md +60 -6
  441. package/llms/components/lr-flag.md +5 -2
  442. package/llms/components/lr-flow-canvas.md +152 -14
  443. package/llms/components/lr-flow-minimap.md +32 -4
  444. package/llms/components/lr-funnel.md +14 -0
  445. package/llms/components/lr-geojson-viewer.md +27 -10
  446. package/llms/components/lr-graph.md +43 -7
  447. package/llms/components/lr-heatmap.md +161 -5
  448. package/llms/components/lr-histogram.md +55 -9
  449. package/llms/components/lr-ingestion-queue.md +54 -3
  450. package/llms/components/lr-json-viewer.md +87 -7
  451. package/llms/components/lr-knowledge-base-admin.md +60 -4
  452. package/llms/components/lr-knowledge-base.md +121 -9
  453. package/llms/components/lr-knowledge-graph-explorer.md +106 -11
  454. package/llms/components/lr-lightbox.md +42 -6
  455. package/llms/components/lr-line-chart.md +28 -5
  456. package/llms/components/lr-lite-chart.md +96 -31
  457. package/llms/components/lr-locale-picker.md +6 -4
  458. package/llms/components/lr-map.md +67 -8
  459. package/llms/components/lr-markdown-core.md +10 -5
  460. package/llms/components/lr-markdown.md +23 -6
  461. package/llms/components/lr-mention-popover.md +11 -6
  462. package/llms/components/lr-mind-map.md +91 -10
  463. package/llms/components/lr-model-select.md +8 -4
  464. package/llms/components/lr-model-settings-panel.md +10 -2
  465. package/llms/components/lr-navigation-menu.md +1 -1
  466. package/llms/components/lr-neighbor-list.md +69 -2
  467. package/llms/components/lr-pie-chart.md +1 -1
  468. package/llms/components/lr-polar-area-chart.md +1 -1
  469. package/llms/components/lr-prompt-input.md +9 -2
  470. package/llms/components/lr-prompt-queue.md +11 -3
  471. package/llms/components/lr-radar-chart.md +1 -1
  472. package/llms/components/lr-rag-eval-dashboard.md +9 -2
  473. package/llms/components/lr-realtime-session.md +6 -2
  474. package/llms/components/lr-reorder-list.md +4 -0
  475. package/llms/components/lr-retrieval-compare.md +9 -4
  476. package/llms/components/lr-retrieval-results.md +104 -6
  477. package/llms/components/lr-scatter-chart.md +1 -1
  478. package/llms/components/lr-select.md +20 -10
  479. package/llms/components/lr-sequence-strip.md +92 -2
  480. package/llms/components/lr-span-waterfall.md +78 -8
  481. package/llms/components/lr-sparkline.md +42 -11
  482. package/llms/components/lr-spreadsheet-viewer.md +109 -14
  483. package/llms/components/lr-streaming-text-core.md +4 -2
  484. package/llms/components/lr-streaming-text.md +5 -1
  485. package/llms/components/lr-table.md +96 -115
  486. package/llms/components/lr-task-list.md +93 -9
  487. package/llms/components/lr-terminal.md +9 -0
  488. package/llms/components/lr-test-results.md +77 -3
  489. package/llms/components/lr-thread-list.md +86 -1
  490. package/llms/components/lr-time-zone-picker.md +8 -3
  491. package/llms/components/lr-timeline.md +5 -0
  492. package/llms/components/lr-token-input.md +7 -2
  493. package/llms/components/lr-tool-timeline.md +13 -4
  494. package/llms/components/lr-trace-tree.md +96 -10
  495. package/llms/components/lr-transcript-feed.md +9 -2
  496. package/llms/components/lr-tree.md +87 -15
  497. package/llms/components/lr-unit-picker.md +8 -3
  498. package/llms/components/lr-video-playlist.md +2 -0
  499. package/llms/components/lr-virtual-list.md +17 -8
  500. package/llms/components/lr-voice-picker.md +8 -3
  501. package/llms/components/lr-word-cloud.md +128 -12
  502. package/llms/components/lr-xml-viewer.md +106 -9
  503. package/llms/index.md +1 -1
  504. package/llms/peers.md +1 -1
  505. package/llms/shared/events-and-types.md +725 -264
  506. package/llms/shared/forms-and-accessibility.md +3 -17
  507. package/llms/shared/imports-and-registration.md +3 -17
  508. package/llms/shared/localization-and-rtl.md +0 -2
  509. package/llms/shared/styles-and-tokens.md +27 -36
  510. package/llms/shared/testing-and-utilities.md +4 -5
  511. package/llms/shared.md +770 -349
  512. package/llms.txt +1 -2
  513. package/locales.json +139 -139
  514. package/package.json +13 -4
  515. package/registrations.json +1 -1
  516. package/skills/compose-lyra-interfaces/SKILL.md +6 -8
  517. package/skills/lyra-ui/SKILL.md +20 -51
  518. package/skills/lyra-ui/commands/review.md +16 -33
  519. package/skills/lyra-ui/commands/update.md +6 -5
  520. package/skills/lyra-ui/online-api.md +15 -0
  521. package/skills/lyra-ui/reporting.md +2 -1
@@ -1,15 +1,15 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{ref}from"lit/directives/ref.js";import{literalSetConverter}from"../../../internal/converters.js";import{tag}from"../../../internal/prefix.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DocumentAnchorTarget}from"../../../internal/anchor-target.js";import{MAX_NATIVE_PLAYBACK_RATE as MAX_PLAYBACK_RATE,MIN_NATIVE_PLAYBACK_RATE as MIN_PLAYBACK_RATE,NativeMediaController,safeNativeMediaSource as safeMediaSrc}from"../../../internal/media-controller.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{finiteNumber,finiteRange}from"../../../internal/numbers.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{resolveCanvasColor}from"../../../internal/canvas-color.js";import{chevronIcon}from"../../../internal/icons.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatMediaTime}from"../../../internal/media-time.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./av-player.styles.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{EMPTY_LYRA_AV_CUES,EMPTY_LYRA_AV_TRACKS,snapshotLyraAvCues,snapshotLyraAvTracks}from"./av-metadata.js";import{LYRA_DEFAULT_avPlayerFailedToLoad,LYRA_DEFAULT_avPlayerLabel,LYRA_DEFAULT_avPlayerPlaybackRate,LYRA_DEFAULT_avPlayerPosition,LYRA_DEFAULT_avPlayerRateOption,LYRA_DEFAULT_avPlayerTimeline,LYRA_DEFAULT_avPlayerTranscript,LYRA_DEFAULT_viewerHighlightLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound}from"../../../internal/default-strings/shared.generated.js";const CONTROLS_SURFACE=literalSetConverter(["regular","clear"],"regular"),TIME_CHANGE_THROTTLE_MS=250,MAX_AV_RATES=32,MAX_AV_PEAKS=65536,MAX_CANVAS_DIMENSION=4096,MAX_CANVAS_PIXELS=8388608,OWNED_AV_COLLECTIONS=new WeakSet,NO_REPORTED_ERROR=Symbol("no-reported-av-error");function ownedSnapshot(values){const snapshot=Object.freeze(values);return OWNED_AV_COLLECTIONS.add(snapshot),snapshot}const EMPTY_RATES=ownedSnapshot([]),DEFAULT_RATES=ownedSnapshot([.75,1,1.25,1.5,2]),EMPTY_CUES=EMPTY_LYRA_AV_CUES,EMPTY_PEAKS=ownedSnapshot([]),EMPTY_TRACKS=EMPTY_LYRA_AV_TRACKS;function normalizeArray(value,limit,normalize,fallback){try{if(!Array.isArray(value))return fallback;if(OWNED_AV_COLLECTIONS.has(value))return value;const result=[],length=Math.min(value.length,limit);for(let index=0;index<length;index++)try{const normalized=normalize(value[index],index);normalized!==void 0&&result.push(normalized)}catch{}return ownedSnapshot(result)}catch{return fallback}}function normalizeRates(value){const seen=new Set;return normalizeArray(value,MAX_AV_RATES,candidate=>{if(!(typeof candidate!="number"||!Number.isFinite(candidate)||candidate<MIN_PLAYBACK_RATE||candidate>MAX_PLAYBACK_RATE||seen.has(candidate)))return seen.add(candidate),candidate},EMPTY_RATES)}function normalizePeaks(value){return normalizeArray(value,MAX_AV_PEAKS,candidate=>typeof candidate=="number"?finiteRange(candidate,0,0,1):void 0,EMPTY_PEAKS)}function positiveFinite(value){const finite=finiteNumber(value,1);return finite>0?finite:1}function waveformPaintPeaks(peaks,maxBars){const barCount=Math.max(1,Math.floor(finiteNumber(maxBars,1)));if(peaks.length<=barCount)return peaks;const finalIndex=peaks.length-1;if(barCount===1)return[finiteRange(peaks[finalIndex],0,0,1)];const result=new Array(barCount),preEndpointBars=barCount-1;for(let barIndex=0;barIndex<preEndpointBars;barIndex+=1){const start=Math.floor(barIndex*finalIndex/preEndpointBars),end=Math.floor((barIndex+1)*finalIndex/preEndpointBars);let peak=0;for(let sampleIndex=start;sampleIndex<end;sampleIndex+=1)peak=Math.max(peak,finiteRange(peaks[sampleIndex],0,0,1));result[barIndex]=peak}return result[preEndpointBars]=finiteRange(peaks[finalIndex],0,0,1),result}class LyraAvPlayerBase extends LyraElement{}class LyraAvPlayer extends DocumentAnchorTarget(LyraAvPlayerBase){static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,avPlayerFailedToLoad:LYRA_DEFAULT_avPlayerFailedToLoad,avPlayerLabel:LYRA_DEFAULT_avPlayerLabel,avPlayerPlaybackRate:LYRA_DEFAULT_avPlayerPlaybackRate,avPlayerPosition:LYRA_DEFAULT_avPlayerPosition,avPlayerRateOption:LYRA_DEFAULT_avPlayerRateOption,avPlayerTimeline:LYRA_DEFAULT_avPlayerTimeline,avPlayerTranscript:LYRA_DEFAULT_avPlayerTranscript,viewerHighlightLabel:LYRA_DEFAULT_viewerHighlightLabel}}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.properties={playbackRate:{type:Number,attribute:"playback-rate",reflect:!0,noAccessor:!0},volume:{type:Number,reflect:!0,noAccessor:!0}}}get playbackRate(){return this._playbackRate}set playbackRate(next){const old=this._playbackRate;this._playbackRate=finiteRange(next,1,MIN_PLAYBACK_RATE,MAX_PLAYBACK_RATE),this.requestUpdate("playbackRate",old)}get volume(){return this._volume}set volume(next){const old=this._volume;this._volume=finiteRange(next,1,0,1),this.requestUpdate("volume",old)}get rates(){return this._rates}set rates(value){if(value===this.inputs.rates)return;this.inputs.rates=value;const previous=this._rates;this._rates=normalizeRates(value),this.requestUpdate("rates",previous)}get cues(){return this._cues}set cues(value){if(value===this.inputs.cues)return;this.inputs.cues=value;const previous=this._cues;if(this._cues=snapshotLyraAvCues(value),this._cues!==previous){const starts=[...new Set(this._cues.map(cue=>cue.start))].sort((a,b)=>a-b);this.nextCueStarts=new Map;for(let index=0;index<starts.length;index+=1)this.nextCueStarts.set(starts[index],starts[index+1]??1/0)}this.requestUpdate("cues",previous)}get peaks(){return this._peaks}set peaks(value){if(value===this.inputs.peaks)return;this.inputs.peaks=value;const previous=this._peaks;this._peaks=normalizePeaks(value),this.requestUpdate("peaks",previous)}get tracks(){return this._tracks}set tracks(value){if(value===this.inputs.tracks)return;this.inputs.tracks=value;const previous=this._tracks;this._tracks=snapshotLyraAvTracks(value),this.requestUpdate("tracks",previous)}constructor(){super(),this.src="",this.name="",this.mimeType="",this.poster="",this.loop=!1,this.muted=!1,this.preload="metadata",this._playbackRate=1,this._volume=1,this.controlsSurface="regular",this.inputs={},this._rates=DEFAULT_RATES,this._cues=EMPTY_CUES,this.nextCueStarts=new Map,this._peaks=EMPTY_PEAKS,this._tracks=EMPTY_TRACKS,this.anchorKinds=["time-range"],this.duration=0,this.currentTimeState=0,this.activeCueId=null,this.activeCueIndex=-1,this.searchQuery="",this.searchMatches=[],this.activeSearchIndex=-1,this.metadataLoaded=!1,this.sourceError=!1,this.playbackError=!1,this.mediaController=new NativeMediaController(this,{onEvent:event=>this.onNativeMediaEvent(event)}),this.semanticInternals=attachInternalsSafely(this),this.lastTimeChangeAt=0,this.searchLocale="",this.transcriptLocale="",this.searchMatchIndices=new Set,this.cueKeys=[],this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.waveformVisible=!1,this.waveformDirty=!1,this.pendingSeekEmission=null,this.lastEmittedTime=null,this.lastReportedSourceError=NO_REPORTED_ERROR,this.connectionEventBaselinePending=!0,this.onMediaFocus=event=>{relayNativeEvent(this,event)},this.onMediaBlur=event=>{relayNativeEvent(this,event)},this.onWindowResize=()=>this.drawWaveform(),this.canvasRef=el=>{if(!el){this.unbindWaveformResizeObserver();return}this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.drawWaveform()},this.mediaRef=el=>{const media=el?.localName==="audio"||el?.localName==="video"?el:void 0;this.mediaController.attach(media)},this.onPlaybackFailure=error=>{this.playbackError=!0,this.announceRenderError(),this.emit("lr-render-error",{error})},this.onHighlightActivate=(id,start)=>{this.activeHighlightId=id,this.seek(start),this.emit("lr-highlight-activate",{highlightId:id})},this.onTimelineClick=event=>{if(!this.duration)return;const rect=event.currentTarget.getBoundingClientRect();if(rect.width<=0)return;const ratio=Math.min(1,Math.max(0,(event.clientX-rect.left)/rect.width));this.seek(ratio*this.duration)},this.onTimelineKeyDown=event=>{if(!(this.duration>0))return;const delta=event.shiftKey?15:5;switch(event.key){case"ArrowLeft":event.preventDefault(),this.seek(Math.max(0,this.currentTime-delta));break;case"ArrowRight":event.preventDefault(),this.seek(Math.min(this.duration,this.currentTime+delta));break;case"Home":event.preventDefault(),this.seek(0);break;case"End":event.preventDefault(),this.seek(this.duration);break;case" ":event.preventDefault(),this.toggle();break;default:return}},this.cueKey=(_cue,index)=>this.cueKeys[index]??`index:${index}`,this.renderCue=(cue,index)=>{const c=cue,start=this.safeCueStart(c),isActive=this.activeCueIndex===index,isMatch=this.searchMatchIndices.has(index),isActiveMatch=index===this.searchMatches[this.activeSearchIndex],part=["cue",isActive?"cue-current":"",isMatch?"cue-match":"",isActiveMatch?"cue-active-match":""].filter(Boolean).join(" ");return html`<button
1
+ import{__decorate}from"tslib";import{AvCueSourceController}from"./av-player-cue-source-controller.js";import{AvCueIndex}from"./av-cue-index.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{ref}from"lit/directives/ref.js";import{literalSetConverter}from"../../../internal/converters.js";import{tag}from"../../../internal/prefix.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DocumentAnchorTarget}from"../../../internal/anchor-target.js";import{MAX_NATIVE_PLAYBACK_RATE as MAX_PLAYBACK_RATE,MIN_NATIVE_PLAYBACK_RATE as MIN_PLAYBACK_RATE,NativeMediaController,safeNativeMediaSource as safeMediaSrc}from"../../../internal/media-controller.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{finiteNumber,finiteRange}from"../../../internal/numbers.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{resolveCanvasColor}from"../../../internal/canvas-color.js";import{chevronIcon}from"../../../internal/icons.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatMediaTime}from"../../../internal/media-time.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./av-player.styles.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{sourceCount,sourceRevision}from"../../../internal/source-request-controller.js";import{EMPTY_LYRA_AV_CUES,EMPTY_LYRA_AV_TRACKS,snapshotLyraAvCues,snapshotLyraAvTracks}from"./av-metadata.js";import{LYRA_DEFAULT_avPlayerFailedToLoad,LYRA_DEFAULT_avPlayerLabel,LYRA_DEFAULT_avPlayerPlaybackRate,LYRA_DEFAULT_avPlayerPosition,LYRA_DEFAULT_avPlayerRateOption,LYRA_DEFAULT_avPlayerTimeline,LYRA_DEFAULT_avPlayerTranscript,LYRA_DEFAULT_avPlayerTranscriptUnavailable,LYRA_DEFAULT_avPlayerWaveformUnavailable,LYRA_DEFAULT_viewerHighlightLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_loading,LYRA_DEFAULT_sourceSearchUnavailable}from"../../../internal/default-strings/shared.generated.js";const CONTROLS_SURFACE=literalSetConverter(["regular","clear"],"regular"),TIME_CHANGE_THROTTLE_MS=250,MAX_AV_RATES=32,MAX_AV_PEAKS=65536,MAX_CANVAS_DIMENSION=4096,MAX_CANVAS_PIXELS=8388608,OWNED_AV_COLLECTIONS=new WeakSet,NO_REPORTED_ERROR=Symbol("no-reported-av-error");function ownedSnapshot(values){const snapshot=Object.freeze(values);return OWNED_AV_COLLECTIONS.add(snapshot),snapshot}const EMPTY_RATES=ownedSnapshot([]),DEFAULT_RATES=ownedSnapshot([.75,1,1.25,1.5,2]),EMPTY_CUES=EMPTY_LYRA_AV_CUES,EMPTY_PEAKS=ownedSnapshot([]),EMPTY_TRACKS=EMPTY_LYRA_AV_TRACKS;function normalizeArray(value,limit,normalize,fallback){try{if(!Array.isArray(value))return fallback;if(OWNED_AV_COLLECTIONS.has(value))return value;const result=[],length=Math.min(value.length,limit);for(let index=0;index<length;index++)try{const normalized=normalize(value[index],index);normalized!==void 0&&result.push(normalized)}catch{}return ownedSnapshot(result)}catch{return fallback}}function normalizeRates(value){const seen=new Set;return normalizeArray(value,MAX_AV_RATES,candidate=>{if(!(typeof candidate!="number"||!Number.isFinite(candidate)||candidate<MIN_PLAYBACK_RATE||candidate>MAX_PLAYBACK_RATE||seen.has(candidate)))return seen.add(candidate),candidate},EMPTY_RATES)}function normalizePeaks(value){return normalizeArray(value,MAX_AV_PEAKS,candidate=>typeof candidate=="number"?finiteRange(candidate,0,0,1):void 0,EMPTY_PEAKS)}function waveformField(value,name){if(!value||typeof value!="object")throw new TypeError("Invalid waveform record");const field=Object.getOwnPropertyDescriptor(value,name);if(!field||!("value"in field))throw new TypeError("Invalid waveform field");return field.value}function waveformAmplitude(value){if(typeof value!="number"||!Number.isFinite(value)||value<0||value>1)throw new RangeError("Invalid waveform amplitude");return value}function snapshotWaveform(value){const revision=sourceRevision(waveformField(value,"revision")),sampleCount=sourceCount(waveformField(value,"sampleCount")),duration=waveformField(value,"duration");if(typeof duration!="number"||!Number.isFinite(duration)||duration<0)throw new RangeError("Invalid waveform duration");const counts=waveformField(value,"counts"),source=sourceCount(waveformField(counts,"sourceCount")),valid=sourceCount(waveformField(counts,"validCount")),invalid=sourceCount(waveformField(counts,"invalidCount"));if(source!==sampleCount||valid>source||invalid!==source-valid)throw new RangeError("Invalid waveform counts");const input=waveformField(value,"buckets");if(!Array.isArray(input))throw new TypeError("Invalid waveform buckets");const length=sourceCount(waveformField(input,"length"));if(length>MAX_AV_PEAKS)throw new RangeError("Invalid waveform buckets");const buckets=[];let next=0;for(let index=0;index<length;index++){const bucket=waveformField(input,index),startIndex=sourceCount(waveformField(bucket,"startIndex")),endIndex=sourceCount(waveformField(bucket,"endIndex")),maxAmplitude=waveformAmplitude(waveformField(bucket,"maxAmplitude"));if(startIndex!==next||endIndex<=startIndex||endIndex>sampleCount||!valid&&maxAmplitude!==0)throw new RangeError("Invalid waveform interval");buckets.push(Object.freeze({startIndex,endIndex,maxAmplitude})),next=endIndex}if(next!==sampleCount)throw new RangeError("Incomplete waveform coverage");const first=waveformField(value,"firstAmplitude"),last=waveformField(value,"lastAmplitude"),firstAmplitude=first===null?null:waveformAmplitude(first),lastAmplitude=last===null?null:waveformAmplitude(last);if(!valid&&(firstAmplitude!==null||lastAmplitude!==null)||firstAmplitude!==null&&firstAmplitude>buckets[0].maxAmplitude||lastAmplitude!==null&&lastAmplitude>buckets.at(-1).maxAmplitude)throw new RangeError("Invalid waveform endpoints");return Object.freeze({revision,sampleCount,duration,counts:Object.freeze({sourceCount:source,validCount:valid,invalidCount:invalid}),buckets:Object.freeze(buckets),firstAmplitude,lastAmplitude})}function preparedWaveformPeaks(waveform,maxBars){const barCount=Math.max(1,Math.min(MAX_CANVAS_DIMENSION,Math.floor(finiteNumber(maxBars,1)))),peaks=new Array(barCount).fill(0);let bucketIndex=0,bar=0;for(;bucketIndex<waveform.buckets.length&&bar<barCount;){const bucket=waveform.buckets[bucketIndex];peaks[bar]=Math.max(peaks[bar],bucket.maxAmplitude);const bucketEnd=bucket.endIndex/waveform.sampleCount,barEnd=(bar+1)/barCount;bucketEnd<=barEnd&&bucketIndex++,barEnd<=bucketEnd&&bar++}return peaks}function positiveFinite(value){const finite=finiteNumber(value,1);return finite>0?finite:1}function waveformPaintPeaks(peaks,maxBars){const barCount=Math.max(1,Math.floor(finiteNumber(maxBars,1)));if(peaks.length<=barCount)return peaks;const finalIndex=peaks.length-1;if(barCount===1)return[finiteRange(peaks[finalIndex],0,0,1)];const result=new Array(barCount),preEndpointBars=barCount-1;for(let barIndex=0;barIndex<preEndpointBars;barIndex+=1){const start=Math.floor(barIndex*finalIndex/preEndpointBars),end=Math.floor((barIndex+1)*finalIndex/preEndpointBars);let peak=0;for(let sampleIndex=start;sampleIndex<end;sampleIndex+=1)peak=Math.max(peak,finiteRange(peaks[sampleIndex],0,0,1));result[barIndex]=peak}return result[preEndpointBars]=finiteRange(peaks[finalIndex],0,0,1),result}class LyraAvPlayerBase extends LyraElement{}class LyraAvPlayer extends DocumentAnchorTarget(LyraAvPlayerBase){static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,avPlayerFailedToLoad:LYRA_DEFAULT_avPlayerFailedToLoad,avPlayerLabel:LYRA_DEFAULT_avPlayerLabel,avPlayerPlaybackRate:LYRA_DEFAULT_avPlayerPlaybackRate,avPlayerPosition:LYRA_DEFAULT_avPlayerPosition,avPlayerRateOption:LYRA_DEFAULT_avPlayerRateOption,avPlayerTimeline:LYRA_DEFAULT_avPlayerTimeline,avPlayerTranscript:LYRA_DEFAULT_avPlayerTranscript,avPlayerTranscriptUnavailable:LYRA_DEFAULT_avPlayerTranscriptUnavailable,avPlayerWaveformUnavailable:LYRA_DEFAULT_avPlayerWaveformUnavailable,loading:LYRA_DEFAULT_loading,sourceSearchUnavailable:LYRA_DEFAULT_sourceSearchUnavailable,viewerHighlightLabel:LYRA_DEFAULT_viewerHighlightLabel}}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.properties={playbackRate:{type:Number,attribute:"playback-rate",reflect:!0,noAccessor:!0},volume:{type:Number,reflect:!0,noAccessor:!0}}}get playbackRate(){return this._playbackRate}set playbackRate(next){const old=this._playbackRate;this._playbackRate=finiteRange(next,1,MIN_PLAYBACK_RATE,MAX_PLAYBACK_RATE),this.requestUpdate("playbackRate",old)}get volume(){return this._volume}set volume(next){const old=this._volume;this._volume=finiteRange(next,1,0,1),this.requestUpdate("volume",old)}get rates(){return this._rates}set rates(value){if(value===this.inputs.rates)return;this.inputs.rates=value;const previous=this._rates;this._rates=normalizeRates(value),this.requestUpdate("rates",previous)}get cues(){return this._cues}set cues(value){if(value===this.inputs.cues)return;this.inputs.cues=value;const previous=this._cues;this._cueSource===null&&(this._cues=snapshotLyraAvCues(value)),this.requestUpdate("cues",previous)}get cueSource(){return this._cueSource}set cueSource(value){const previous=this._cueSource;this._cueSource=value,this.requestUpdate("cueSource",previous),value===previous&&this.requestUpdate("cueSourceRebind",null)}captureCueSource(){if(!this.cueSourceDirty)return;this.cueSourceDirty=!1;const generation=this.cueSourceGeneration,input=this._cueSource;if(input!==null){if(this.cueSourceController.bind(input,()=>generation===this.cueSourceGeneration&&input===this._cueSource),generation!==this.cueSourceGeneration||input!==this._cueSource)return;this.searchLocale="",this.cueIndex=void 0,this.indexedCues=void 0,this.cueKeys=[],this.searchMatches=[],this.searchMatchIndices=new Set,this.cueSourceController.updateTime(this.currentTime)}else this.searchLocale="",this._cues=snapshotLyraAvCues(this.inputs.cues??EMPTY_CUES),this.rebuildCueKeys(),this.metadataLoaded&&this.reconcileActiveCue();this.refreshTranscriptRenderItem()}get peaks(){return this._peaks}set peaks(value){if(value===this.inputs.peaks)return;this.inputs.peaks=value;const previous=this._peaks,previousInvalid=this.peaksInvalid;try{this.peaksInvalid=Array.isArray(value)&&sourceCount(waveformField(value,"length"))>MAX_AV_PEAKS}catch{this.peaksInvalid=!0}this._peaks=this.peaksInvalid?EMPTY_PEAKS:normalizePeaks(value),this.requestUpdate("peaks",previous),previousInvalid!==this.peaksInvalid&&this.requestUpdate("waveformValidity",previousInvalid)}get waveform(){return this._waveform}set waveform(value){const old=this._waveform;this._waveform=value,this.requestUpdate("waveform",old),value===old&&this.requestUpdate()}requestUpdate(...args){(args[0]===void 0||args[0]==="cueSource"||args[0]==="cueSourceRebind")&&(this.cueSourceDirty=!0,this.cueSourceGeneration=(this.cueSourceGeneration??0)+1,this.cueSourceController&&(this.cueSourceController.revoke(),(this._cueSource!==null||args[0]==="cueSource"&&args[1]!==null)&&this.setActiveCue(null,-1))),(args[0]===void 0||args[0]==="waveform")&&(this.waveformInputDirty=!0,this.waveformInputGeneration=(this.waveformInputGeneration??0)+1),super.requestUpdate(...args)}captureWaveform(){if(!this.waveformInputDirty)return;this.waveformInputDirty=!1;const generation=this.waveformInputGeneration,input=this._waveform;let snapshot,invalid=!1;if(input!==null)try{snapshot=snapshotWaveform(input)}catch{invalid=!0}generation!==this.waveformInputGeneration||input!==this._waveform||(this.waveformInputChanged=!0,this.waveformSnapshot=snapshot,this.waveformInvalid=invalid)}get waveformUnavailable(){if(this._waveform===null)return this.peaksInvalid;if(this.waveformInvalid)return!0;const waveform=this.waveformSnapshot;if(!waveform||!this.metadataLoaded||!(this.duration>0))return!1;const tolerance=.001+Number.EPSILON*Math.max(this.duration,waveform.duration)*4;return Math.abs(this.duration-waveform.duration)>tolerance}get hasWaveform(){return!this.waveformUnavailable&&(this._waveform!==null?(this.waveformSnapshot?.buckets.length??0)>0:this.peaks.length>0)}get tracks(){return this._tracks}set tracks(value){if(value===this.inputs.tracks)return;this.inputs.tracks=value;const previous=this._tracks;this._tracks=snapshotLyraAvTracks(value),this.requestUpdate("tracks",previous)}constructor(){super(),this.src="",this.name="",this.mimeType="",this.poster="",this.loop=!1,this.muted=!1,this.preload="metadata",this._playbackRate=1,this._volume=1,this.controlsSurface="regular",this.inputs={},this._rates=DEFAULT_RATES,this._cues=EMPTY_CUES,this.indexedCueDuration=-1,this._cueSource=null,this.cueSourceDirty=!0,this.cueSourceGeneration=0,this.cueSourceContinuationQueued=!1,this.transcriptFailureAnnounced=!1,this.searchFailureAnnounced=!1,this.cueSourceController=new AvCueSourceController(this,{locale:()=>this.effectiveLocale,changed:()=>{this.refreshTranscriptRenderItem(),this.requestUpdate("cueSourceState",null)},searchChanged:detail=>this.emit("lr-search-change",detail),reveal:(index,current)=>this.revealSourceCue(index,this.cueSourceController.epoch,current),activeChanged:(cueId,index)=>{const epoch=this.cueSourceController.epoch;this.setActiveCue(cueId,index),index>=0&&this.cueSourceController.isCurrent(epoch)&&this.revealSourceCue(index,epoch)}}),this._peaks=EMPTY_PEAKS,this.peaksInvalid=!1,this._waveform=null,this.waveformInputDirty=!0,this.waveformInputGeneration=0,this.waveformContinuationQueued=!1,this.waveformInputChanged=!1,this.waveformInvalid=!1,this.waveformFailureAnnounced=!1,this._tracks=EMPTY_TRACKS,this.anchorKinds=["time-range"],this.duration=0,this.currentTimeState=0,this.activeCueId=null,this.activeCueIndex=-1,this.searchQuery="",this.searchMatches=[],this.activeSearchIndex=-1,this.metadataLoaded=!1,this.sourceError=!1,this.playbackError=!1,this.mediaController=new NativeMediaController(this,{onEvent:event=>this.onNativeMediaEvent(event)}),this.semanticInternals=attachInternalsSafely(this),this.lastTimeChangeAt=0,this.searchLocale="",this.transcriptLocale="",this.searchMatchIndices=new Set,this.cueKeys=[],this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.waveformVisible=!1,this.waveformDirty=!1,this.pendingSeekEmission=null,this.lastEmittedTime=null,this.lastReportedSourceError=NO_REPORTED_ERROR,this.connectionEventBaselinePending=!0,this.onMediaFocus=event=>{relayNativeEvent(this,event)},this.onMediaBlur=event=>{relayNativeEvent(this,event)},this.onWindowResize=()=>this.drawWaveform(),this.canvasRef=el=>{if(!el){this.unbindWaveformResizeObserver();return}this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.drawWaveform()},this.mediaRef=el=>{const media=el?.localName==="audio"||el?.localName==="video"?el:void 0;this.mediaController.attach(media)},this.onPlaybackFailure=error=>{this.playbackError=!0,this.announceRenderError(),this.emit("lr-render-error",{error})},this.onHighlightActivate=(id,start)=>{this.activeHighlightId=id,this.seek(start),this.emit("lr-highlight-activate",{highlightId:id})},this.onTimelineClick=event=>{if(!this.duration)return;const rect=event.currentTarget.getBoundingClientRect();if(rect.width<=0)return;const ratio=Math.min(1,Math.max(0,(event.clientX-rect.left)/rect.width));this.seek(ratio*this.duration)},this.onTimelineKeyDown=event=>{if(!(this.duration>0))return;const delta=event.shiftKey?15:5;switch(event.key){case"ArrowLeft":event.preventDefault(),this.seek(Math.max(0,this.currentTime-delta));break;case"ArrowRight":event.preventDefault(),this.seek(Math.min(this.duration,this.currentTime+delta));break;case"Home":event.preventDefault(),this.seek(0);break;case"End":event.preventDefault(),this.seek(this.duration);break;case" ":event.preventDefault(),this.toggle();break;default:return}},this.cueKey=(_cue,index)=>this.cueKeys[index]??`index:${index}`,this.renderCue=(cue,index)=>{const sourceMode=this._cueSource!==null,slot=sourceMode?cue:void 0;if(slot&&slot.state!=="ready")return html`<div part="cue" aria-disabled="true">${slot.state==="loading"?this.localize("loading"):this.localize("avPlayerTranscriptUnavailable")}</div>`;const c=slot?.state==="ready"?slot.value:cue,epoch=this.cueSourceController.epoch,start=sourceMode?c.start:this.safeCueStart(c),isActive=this.activeCueIndex===index,isMatch=sourceMode?this.cueSourceController.matches(c):this.searchMatchIndices.has(index),isActiveMatch=sourceMode?this.cueSourceController.selected?.index===index&&this.cueSourceController.selected.cue.cueId===c.cueId:index===this.searchMatches[this.activeSearchIndex],part=["cue",isActive?"cue-current":"",isMatch?"cue-match":"",isActiveMatch?"cue-active-match":""].filter(Boolean).join(" ");return html`<button
2
2
  part=${part}
3
3
  type="button"
4
4
  aria-current=${isActive?"true":"false"}
5
5
  ?data-match=${isMatch}
6
6
  ?data-active-match=${isActiveMatch}
7
- @click=${()=>this.seek(start)}
7
+ @click=${()=>{(sourceMode?this.cueSourceController.isCurrent(epoch):this._cueSource===null)&&this.seek(start)}}
8
8
  >
9
9
  <span part="cue-time">${formatMediaTime(start,this.effectiveLocale)}</span>
10
10
  ${c.speaker?html`<span part="cue-speaker">${c.speaker}</span>`:nothing}
11
11
  <span part="cue-text">${c.text}</span>
12
- </button>`},this.transcriptRenderItem=this.renderCue,new ThemeWatcher(this,()=>{this.peaks.length>0&&this.drawWaveform()})}get mediaEl(){return this.mediaController.element}focus(options){this.mediaEl?.focus(options)}blur(){this.mediaEl?.blur()}click(){this.mediaEl?.click()}get currentTime(){return this.mediaController.currentTime}set currentTime(value){this.mediaController.currentTime=value,this.currentTimeState=this.mediaController.currentTime}detectedKind(){return this.kind==="audio"||this.kind==="video"?this.kind:(this.mimeType??"").startsWith("audio/")?"audio":"video"}get effectivePreload(){return this.preload==="none"||this.preload==="auto"?this.preload:"metadata"}willUpdate(changed){super.willUpdate(changed),changed.has("controlsSurface")&&(this.controlsSurface=CONTROLS_SURFACE.normalizeReflected(this,"controls-surface",this.controlsSurface)),this.semanticInternals.role=hostAriaLabel(this)!==null?"region":null;const mayEmitConnectionTransition=this.isConnected&&!this.connectionEventBaselinePending,locale=this.effectiveLocale;let refreshTranscript=!1;if(changed.has("kind")&&this.kind!==void 0&&this.kind!=="audio"&&this.kind!=="video"&&(this.kind=void 0),changed.has("preload")&&this.preload!==this.effectivePreload&&(this.preload=this.effectivePreload),changed.has("cues")&&(this.rebuildCueKeys(),this.metadataLoaded&&this.reconcileActiveCue()),this.transcriptLocale!==locale&&(this.transcriptLocale=locale,refreshTranscript=!0),this.hasUpdated&&(changed.has("src")||changed.has("kind")||changed.has("mimeType"))&&(this.duration=0,this.currentTimeState=0,this.activeCueId=null,this.activeCueIndex=-1,this.metadataLoaded=!1,this.sourceError=!1,this.playbackError=!1,this.lastTimeChangeAt=0,this.pendingSeekEmission=null,this.lastEmittedTime=null,this.lastReportedSourceError=NO_REPORTED_ERROR,this.mediaController.startGeneration(),changed.has("src")&&this.src&&!safeMediaSrc(this.src))){const error=new TypeError("The media source URL is not allowed.");mayEmitConnectionTransition&&(this.announceRenderError(),this.emit("lr-render-error",{error}))}this.searchQuery&&(changed.has("cues")||this.searchLocale!==locale)&&(this.reconcileSearchMatches(changed.get("cues")),refreshTranscript=!0),refreshTranscript&&this.refreshTranscriptRenderItem()}updated(changed){super.updated(changed),changed.has("playbackRate")&&(this.mediaController.playbackRate=this.playbackRate,changed.get("playbackRate")!==void 0&&this.emit("lr-rate-change",{rate:this.playbackRate})),changed.has("volume")&&(this.mediaController.volume=this.volume),changed.has("muted")&&(this.mediaController.muted=this.muted),changed.has("peaks")&&(this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.drawWaveform()),this.isConnected&&(this.connectionEventBaselinePending=!1)}connectedCallback(){super.connectedCallback(),this.connectionEventBaselinePending=!0,this.mediaController.reconnect(),this.bindResizeWindow(),this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.waveformDirty&&this.drawWaveform(),this.requestUpdate()}firstUpdated(changed){super.firstUpdated(changed),this.drawWaveform()}disconnectedCallback(){this.connectionEventBaselinePending=!0,this.mediaController.disconnect(),this.unbindResizeWindow(),this.unbindWaveformResizeObserver(),this.cancelWaveformDrawFrame(),this.waveformDetachedObserverWindow=this.waveformObserverWindow,this.unbindWaveformVisibilityObserver(),this.waveformDirty=this.peaks.length>0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted(),this.bindResizeWindow(),this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.isConnected&&this.waveformDirty&&this.drawWaveform()}announceRenderError(){this.announcements.announceAssertive(this.localize("avPlayerFailedToLoad"))}bindResizeWindow(){const nextWindow=this.isConnected?this.ownerDocument.defaultView:null;this.resizeWindow!==nextWindow&&(this.unbindResizeWindow(),this.resizeWindow=nextWindow??void 0,this.resizeWindow?.addEventListener("resize",this.onWindowResize))}unbindResizeWindow(){this.resizeWindow?.removeEventListener("resize",this.onWindowResize),this.resizeWindow=void 0}syncWaveformVisibilityObserver(){const owner=this.isConnected&&this.peaks.length>0?this.ownerDocument.defaultView:null;if(this.waveformIntersectionObserver&&this.waveformObserverWindow===owner)return;const needsFreshSameRealmVisibility=owner!==null&&this.waveformDetachedObserverWindow===owner;if(owner!==null&&(this.waveformDetachedObserverWindow=void 0),this.cancelWaveformDrawFrame(),this.unbindWaveformVisibilityObserver(),!owner)return;const IntersectionObserverCtor=owner.IntersectionObserver;if(!IntersectionObserverCtor){this.waveformVisible=!0;return}needsFreshSameRealmVisibility&&(this.waveformVisible=!1),this.waveformDirty=!0;let observer;observer=new IntersectionObserverCtor(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==owner||this.waveformIntersectionObserver!==observer)return;const entry=entries.find(candidate=>candidate.target===this);!entry||entry.isIntersecting===this.waveformVisible||(this.waveformVisible=entry.isIntersecting,this.waveformVisible?this.waveformDirty&&this.scheduleWaveformDraw():this.cancelWaveformDrawFrame())}),this.waveformObserverWindow=owner,this.waveformIntersectionObserver=observer,observer.observe(this)}unbindWaveformVisibilityObserver(){this.waveformIntersectionObserver?.disconnect(),this.waveformIntersectionObserver=void 0,this.waveformObserverWindow=void 0}syncWaveformResizeObserver(){const target=this.isConnected&&this.peaks.length>0?this.canvasEl:void 0,owner=target?.ownerDocument.defaultView;if(target&&owner&&this.waveformResizeObserver&&this.waveformResizeObserverWindow===owner&&this.waveformResizeTarget===target||(this.unbindWaveformResizeObserver(),!target||!owner||typeof owner.ResizeObserver!="function"))return;let observer;observer=new owner.ResizeObserver(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==owner||this.waveformResizeObserver!==observer||this.waveformResizeTarget!==target||!entries.some(entry=>entry.target===target))return;const width=positiveFinite(target.clientWidth),height=positiveFinite(target.clientHeight),dpr=positiveFinite(owner.devicePixelRatio),previous=this.lastWaveformAllocation;previous?.target===target&&previous.width===width&&previous.height===height&&previous.dpr===dpr||this.drawWaveform()}),this.waveformResizeObserver=observer,this.waveformResizeObserverWindow=owner,this.waveformResizeTarget=target,observer.observe(target)}unbindWaveformResizeObserver(){this.waveformResizeObserver?.disconnect(),this.waveformResizeObserver=void 0,this.waveformResizeObserverWindow=void 0,this.waveformResizeTarget=void 0,this.lastWaveformAllocation=void 0}play(){return this.mediaController.play()}pause(){this.mediaController.pause()}toggle(){const media=this.mediaEl;if(media?.paused){const generation=this.mediaController.generation;this.play().catch(error=>{!this.isConnected||!this.mediaController.isCurrentGeneration(generation,media)||this.onPlaybackFailure(error)})}else this.pause()}seek(seconds){this.currentTime=seconds,this.emitTimeChange(!0,!0),this.pendingSeekEmission=this.currentTimeState,this.reconcileActiveCue()}async applyAnchor(anchor){return anchor.kind!=="time-range"||!this.metadataLoaded?!1:(this.seek(anchor.start),!0)}onLoadedMetadata(){this.metadataLoaded=!0,this.duration=this.mediaController.duration,this.currentTimeState=this.mediaController.currentTime,this.sourceError=!1,this.playbackError=!1,this.lastReportedSourceError=NO_REPORTED_ERROR,this.reconcileActiveCue(),this.emit("lr-load",{duration:this.duration,kind:this.detectedKind()})}onPlay(){this.playbackError=!1,this.emit("lr-play",null)}onPause(){this.emit("lr-pause",null)}onMediaError(){const error=this.mediaEl?.error??null,identity=error??"native-media-error-without-detail";identity!==this.lastReportedSourceError&&(this.lastReportedSourceError=identity,this.sourceError=!0,this.playbackError=!1,this.announceRenderError(),this.emit("lr-render-error",{error:error??new Error("The media failed to load.")}))}onNativeMediaEvent(event){switch(event.type){case"loadedmetadata":this.onLoadedMetadata();break;case"durationchange":this.duration=this.mediaController.duration,this.reconcileActiveCue();break;case"play":this.onPlay();break;case"pause":this.onPause();break;case"error":this.onMediaError();break;case"volumechange":{const nextVolume=this.mediaController.volume,nextMuted=this.mediaController.muted;this.volume!==nextVolume&&(this.volume=nextVolume),this.muted!==nextMuted&&(this.muted=nextMuted);break}case"ratechange":{const nextRate=this.mediaController.playbackRate;this.playbackRate!==nextRate&&(this.playbackRate=nextRate);break}case"timeupdate":this.onTimeUpdate();break;case"seeked":this.onSeeked();break;default:break}}emitTimeChange(force,allowDuplicate=!1){const now=Date.now();if(!force&&now-this.lastTimeChangeAt<TIME_CHANGE_THROTTLE_MS)return;const nextTime=this.currentTime;this.currentTimeState=nextTime,!(!allowDuplicate&&nextTime===this.lastEmittedTime)&&(this.lastTimeChangeAt=now,this.lastEmittedTime=nextTime,this.emit("lr-time-change",{currentTime:this.currentTimeState}))}onTimeUpdate(){this.emitTimeChange(!1),this.reconcileActiveCue()}reconcileActiveCue(){const time=this.currentTime;let active,activeIndex=-1;this.cues.forEach((cue,index)=>{const start=this.safeCueStart(cue),end=this.safeCueEnd(cue,start);time>=start&&time<end&&(!active||start>=this.safeCueStart(active))&&(active=cue,activeIndex=index)});const nextId=active?.cueId??null;this.setActiveCue(nextId,activeIndex)}setActiveCue(nextId,activeIndex){(nextId!==this.activeCueId||activeIndex!==this.activeCueIndex)&&(this.activeCueId=nextId,this.activeCueIndex=activeIndex,this.emit("lr-cue-change",Object.freeze({cueId:nextId,index:activeIndex})))}onSeeked(){const completedTime=this.currentTime;this.pendingSeekEmission===null||completedTime!==this.pendingSeekEmission?this.emitTimeChange(!0):this.currentTimeState=completedTime,this.pendingSeekEmission=null,this.reconcileActiveCue()}async search(query2){return this.searchQuery=query2,this.reconcileSearchMatches(),this.activeSearchIndex=this.searchMatches.length?0:-1,this.refreshTranscriptRenderItem(),this.emitSearchChange(),await this.revealActiveSearchMatch(),this.searchMatches.length}reconcileSearchMatches(previousCues){const locale=this.effectiveLocale,q=this.searchQuery.trim().toLocaleLowerCase(locale),previousMatchIndex=this.searchMatches[this.activeSearchIndex],previousActiveId=previousCues&&previousMatchIndex!==void 0?previousCues[previousMatchIndex]?.cueId:void 0;if(this.searchMatches=q?this.cues.reduce((acc,cue,index)=>((cue.text.toLocaleLowerCase(locale).includes(q)||(cue.speaker??"").toLocaleLowerCase(locale).includes(q))&&acc.push(index),acc),[]):[],this.searchMatchIndices=new Set(this.searchMatches),this.searchLocale=locale,!this.searchMatches.length){this.activeSearchIndex=-1;return}const retainedPosition=previousActiveId?this.searchMatches.findIndex(index=>this.cues[index]?.cueId===previousActiveId):-1;this.activeSearchIndex=retainedPosition>=0?retainedPosition:Math.min(Math.max(0,this.activeSearchIndex),this.searchMatches.length-1)}async searchNext(){return this.searchMatches.length?(this.activeSearchIndex=(this.activeSearchIndex+1)%this.searchMatches.length,this.refreshTranscriptRenderItem(),this.emitSearchChange(),await this.revealActiveSearchMatch(),!0):!1}async searchPrevious(){return this.searchMatches.length?(this.activeSearchIndex=(this.activeSearchIndex-1+this.searchMatches.length)%this.searchMatches.length,this.refreshTranscriptRenderItem(),this.emitSearchChange(),await this.revealActiveSearchMatch(),!0):!1}clearSearch(){this.searchQuery="",this.searchMatches=[],this.searchMatchIndices=new Set,this.activeSearchIndex=-1,this.refreshTranscriptRenderItem(),this.emitSearchChange()}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:!0,activeIndex:this.activeSearchIndex})}async revealActiveSearchMatch(){await this.updateComplete;const list=this.renderRoot.querySelector(tag("virtual-list"));if(!list)return;await list.updateComplete;const index=this.searchMatches[this.activeSearchIndex];index!==void 0&&list.scrollToIndex(index,{align:"auto",behavior:"auto"})}drawWaveform(){const canvas=this.canvasEl,ownerWindow=this.ownerDocument.defaultView;if(!this.peaks.length){this.waveformDirty=!1;return}if(!this.isConnected||!canvas||!ownerWindow||!this.waveformVisible){this.waveformDirty=!0;return}this.cancelWaveformDrawFrame(),this.waveformDirty=!1,this.paintWaveform()}paintWaveform(){const canvas=this.canvasEl;if(!canvas||!this.peaks.length)return;const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow)return;const dpr=positiveFinite(ownerWindow.devicePixelRatio),width=positiveFinite(canvas.clientWidth),height=positiveFinite(canvas.clientHeight),allocation=resolveBoundedCanvasAllocation({cssWidth:width,cssHeight:height,desiredScale:dpr,maxDimension:MAX_CANVAS_DIMENSION,maxPixels:MAX_CANVAS_PIXELS});this.lastWaveformAllocation={target:canvas,width,height,dpr},canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight;const ctx=canvas.getContext("2d");if(!ctx)return;const scaleX=allocation.scaleX,scaleY=allocation.scaleY;ctx.setTransform(scaleX,0,0,scaleY,0,0),ctx.clearRect(0,0,width,height),ctx.fillStyle=resolveCanvasColor(this,"var(--lr-color-brand)",ownerWindow.getComputedStyle(this).color);const peaks=waveformPaintPeaks(this.peaks,canvas.width),barWidth=width/peaks.length,physicalPixel=Math.min(barWidth,finiteNumber(1/scaleX,barWidth)),paintedBarWidth=Math.max(physicalPixel,barWidth-physicalPixel);peaks.forEach((peak,i)=>{const barHeight=Math.max(1,finiteRange(peak,0,0,1)*height);ctx.fillRect(i*barWidth,(height-barHeight)/2,paintedBarWidth,barHeight)})}scheduleWaveformDraw(){if(this.waveformDrawFrame)return;const owner=this.ownerDocument.defaultView;if(!owner||!this.isConnected)return;const request={owner,handle:0};request.handle=owner.requestAnimationFrame(()=>{this.waveformDrawFrame===request&&(this.waveformDrawFrame=void 0,this.isConnected&&this.ownerDocument.defaultView===owner&&this.drawWaveform())}),this.waveformDrawFrame=request}cancelWaveformDrawFrame(){const request=this.waveformDrawFrame;request&&request.owner.cancelAnimationFrame(request.handle),this.waveformDrawFrame=void 0}renderMarkers(){if(!this.duration)return nothing;const ranged=this.highlights.filter(h=>h.anchor.kind==="time-range");return ranged.length?html`${ranged.map(h=>{const startSeconds=finiteRange(h.anchor.start,0,0,this.duration),endSeconds=h.anchor.end==null?startSeconds:finiteRange(h.anchor.end,startSeconds,startSeconds,this.duration),start=startSeconds/this.duration*100,end=endSeconds/this.duration*100;return html`<button
12
+ </button>`},this.transcriptRenderItem=this.renderCue,new ThemeWatcher(this,()=>{this.hasWaveform&&this.drawWaveform()})}get mediaEl(){return this.mediaController.element}focus(options){this.mediaEl?.focus(options)}blur(){this.mediaEl?.blur()}click(){this.mediaEl?.click()}get currentTime(){return this.mediaController.currentTime}set currentTime(value){this.mediaController.currentTime=value,this.currentTimeState=this.mediaController.currentTime}detectedKind(){return this.kind==="audio"||this.kind==="video"?this.kind:(this.mimeType??"").startsWith("audio/")?"audio":"video"}get effectivePreload(){return this.preload==="none"||this.preload==="auto"?this.preload:"metadata"}willUpdate(changed){super.willUpdate(changed),this.captureWaveform(),this.captureCueSource(),changed.has("controlsSurface")&&(this.controlsSurface=CONTROLS_SURFACE.normalizeReflected(this,"controls-surface",this.controlsSurface)),this.semanticInternals.role=hostAriaLabel(this)!==null?"region":null;const mayEmitConnectionTransition=this.isConnected&&!this.connectionEventBaselinePending,locale=this.effectiveLocale;let refreshTranscript=!1;if(changed.has("kind")&&this.kind!==void 0&&this.kind!=="audio"&&this.kind!=="video"&&(this.kind=void 0),changed.has("preload")&&this.preload!==this.effectivePreload&&(this.preload=this.effectivePreload),this._cueSource===null&&changed.has("cues")&&(this.rebuildCueKeys(),this.metadataLoaded&&this.reconcileActiveCue()),this.transcriptLocale!==locale&&(this.transcriptLocale=locale,refreshTranscript=!0),this.hasUpdated&&(changed.has("src")||changed.has("kind")||changed.has("mimeType"))&&(this.duration=0,this.currentTimeState=0,this.activeCueId=null,this.activeCueIndex=-1,this.metadataLoaded=!1,this.sourceError=!1,this.playbackError=!1,this.lastTimeChangeAt=0,this.pendingSeekEmission=null,this.lastEmittedTime=null,this.lastReportedSourceError=NO_REPORTED_ERROR,this.mediaController.startGeneration(),changed.has("src")&&this.src&&!safeMediaSrc(this.src))){const error=new TypeError("The media source URL is not allowed.");mayEmitConnectionTransition&&(this.announceRenderError(),this.emit("lr-render-error",{error}))}this._cueSource===null&&this.searchQuery&&(changed.has("cues")||this.searchLocale!==locale)&&(this.reconcileSearchMatches(changed.get("cues")),refreshTranscript=!0),this._cueSource!==null&&this.searchQuery&&this.searchLocale!==locale&&this.search(this.searchQuery),refreshTranscript&&this.refreshTranscriptRenderItem()}updated(changed){super.updated(changed),changed.has("playbackRate")&&(this.mediaController.playbackRate=this.playbackRate,changed.get("playbackRate")!==void 0&&this.emit("lr-rate-change",{rate:this.playbackRate})),changed.has("volume")&&(this.mediaController.volume=this.volume),changed.has("muted")&&(this.mediaController.muted=this.muted),(this.waveformInputChanged||["peaks","duration","metadataLoaded","src","kind","mimeType"].some(key=>changed.has(key)))&&(this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.drawWaveform()),this.waveformInputChanged=!1;const unavailable=this.waveformUnavailable;unavailable&&!this.waveformFailureAnnounced&&!this.connectionEventBaselinePending&&this.announcements.announceAssertive(this.localize("avPlayerWaveformUnavailable")),this.waveformFailureAnnounced=unavailable;const transcriptUnavailable=this._cueSource!==null&&this.cueSourceController.unavailable;transcriptUnavailable&&!this.transcriptFailureAnnounced&&!this.connectionEventBaselinePending&&this.announcements.announceAssertive(this.localize("avPlayerTranscriptUnavailable")),this.transcriptFailureAnnounced=transcriptUnavailable;const searchUnavailable=this._cueSource!==null&&this.cueSourceController.searchUnavailable;searchUnavailable&&!this.searchFailureAnnounced&&!this.connectionEventBaselinePending&&this.announcements.announceAssertive(this.localize("sourceSearchUnavailable")),this.searchFailureAnnounced=searchUnavailable,this.cueSourceDirty&&this.isConnected&&!this.cueSourceContinuationQueued&&(this.cueSourceContinuationQueued=!0,queueMicrotask(()=>{this.cueSourceContinuationQueued=!1,this.cueSourceDirty&&this.isConnected&&this.requestUpdate("cueSourceContinuation",null)})),this.isConnected&&(this.connectionEventBaselinePending=!1),this.waveformInputDirty&&this.isConnected&&!this.waveformContinuationQueued&&(this.waveformContinuationQueued=!0,queueMicrotask(()=>{this.waveformContinuationQueued=!1,this.waveformInputDirty&&this.isConnected&&this.requestUpdate("waveformContinuation",null)}))}connectedCallback(){super.connectedCallback(),this.connectionEventBaselinePending=!0,this.mediaController.reconnect(),this.bindResizeWindow(),this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.waveformDirty&&this.drawWaveform(),this.requestUpdate()}firstUpdated(changed){super.firstUpdated(changed),this.drawWaveform()}disconnectedCallback(){this.cueSourceController.revoke(),this.cueSourceDirty=!0,this.activeCueId=null,this.activeCueIndex=-1,this.connectionEventBaselinePending=!0,this.mediaController.disconnect(),this.unbindResizeWindow(),this.unbindWaveformResizeObserver(),this.cancelWaveformDrawFrame(),this.waveformDetachedObserverWindow=this.waveformObserverWindow,this.unbindWaveformVisibilityObserver(),this.waveformDirty=this.hasWaveform,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted(),this.cueSourceController.adopted(),this.cueSourceDirty=!0,this.requestUpdate("cueSourceAdopted",null),this.bindResizeWindow(),this.syncWaveformVisibilityObserver(),this.syncWaveformResizeObserver(),this.isConnected&&this.waveformDirty&&this.drawWaveform()}announceRenderError(){this.announcements.announceAssertive(this.localize("avPlayerFailedToLoad"))}bindResizeWindow(){const nextWindow=this.isConnected?this.ownerDocument.defaultView:null;this.resizeWindow!==nextWindow&&(this.unbindResizeWindow(),this.resizeWindow=nextWindow??void 0,this.resizeWindow?.addEventListener("resize",this.onWindowResize))}unbindResizeWindow(){this.resizeWindow?.removeEventListener("resize",this.onWindowResize),this.resizeWindow=void 0}syncWaveformVisibilityObserver(){const owner=this.isConnected&&this.hasWaveform?this.ownerDocument.defaultView:null;if(this.waveformIntersectionObserver&&this.waveformObserverWindow===owner)return;const needsFreshSameRealmVisibility=owner!==null&&this.waveformDetachedObserverWindow===owner;if(owner!==null&&(this.waveformDetachedObserverWindow=void 0),this.cancelWaveformDrawFrame(),this.unbindWaveformVisibilityObserver(),!owner)return;const IntersectionObserverCtor=owner.IntersectionObserver;if(!IntersectionObserverCtor){this.waveformVisible=!0;return}needsFreshSameRealmVisibility&&(this.waveformVisible=!1),this.waveformDirty=!0;let observer;observer=new IntersectionObserverCtor(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==owner||this.waveformIntersectionObserver!==observer)return;const entry=entries.find(candidate=>candidate.target===this);!entry||entry.isIntersecting===this.waveformVisible||(this.waveformVisible=entry.isIntersecting,this.waveformVisible?this.waveformDirty&&this.scheduleWaveformDraw():this.cancelWaveformDrawFrame())}),this.waveformObserverWindow=owner,this.waveformIntersectionObserver=observer,observer.observe(this)}unbindWaveformVisibilityObserver(){this.waveformIntersectionObserver?.disconnect(),this.waveformIntersectionObserver=void 0,this.waveformObserverWindow=void 0}syncWaveformResizeObserver(){const target=this.isConnected&&this.hasWaveform?this.canvasEl:void 0,owner=target?.ownerDocument.defaultView;if(target&&owner&&this.waveformResizeObserver&&this.waveformResizeObserverWindow===owner&&this.waveformResizeTarget===target||(this.unbindWaveformResizeObserver(),!target||!owner||typeof owner.ResizeObserver!="function"))return;let observer;observer=new owner.ResizeObserver(entries=>{if(!this.isConnected||this.ownerDocument.defaultView!==owner||this.waveformResizeObserver!==observer||this.waveformResizeTarget!==target||!entries.some(entry=>entry.target===target))return;const width=positiveFinite(target.clientWidth),height=positiveFinite(target.clientHeight),dpr=positiveFinite(owner.devicePixelRatio),previous=this.lastWaveformAllocation;previous?.target===target&&previous.width===width&&previous.height===height&&previous.dpr===dpr||this.drawWaveform()}),this.waveformResizeObserver=observer,this.waveformResizeObserverWindow=owner,this.waveformResizeTarget=target,observer.observe(target)}unbindWaveformResizeObserver(){this.waveformResizeObserver?.disconnect(),this.waveformResizeObserver=void 0,this.waveformResizeObserverWindow=void 0,this.waveformResizeTarget=void 0,this.lastWaveformAllocation=void 0}play(){return this.mediaController.play()}pause(){this.mediaController.pause()}toggle(){const media=this.mediaEl;if(media?.paused){const generation=this.mediaController.generation;this.play().catch(error=>{!this.isConnected||!this.mediaController.isCurrentGeneration(generation,media)||this.onPlaybackFailure(error)})}else this.pause()}seek(seconds){this.currentTime=seconds,this.emitTimeChange(!0,!0),this.pendingSeekEmission=this.currentTimeState,this.reconcileActiveCue(!0)}async applyAnchor(anchor){return anchor.kind!=="time-range"||!this.metadataLoaded?!1:(this.seek(anchor.start),!0)}onLoadedMetadata(){this.metadataLoaded=!0,this.duration=this.mediaController.duration,this.currentTimeState=this.mediaController.currentTime,this.sourceError=!1,this.playbackError=!1,this.lastReportedSourceError=NO_REPORTED_ERROR,this.reconcileActiveCue(),this.emit("lr-load",{duration:this.duration,kind:this.detectedKind()})}onPlay(){this.playbackError=!1,this.emit("lr-play",null)}onPause(){this.emit("lr-pause",null)}onMediaError(){const error=this.mediaEl?.error??null,identity=error??"native-media-error-without-detail";identity!==this.lastReportedSourceError&&(this.lastReportedSourceError=identity,this.sourceError=!0,this.playbackError=!1,this.announceRenderError(),this.emit("lr-render-error",{error:error??new Error("The media failed to load.")}))}onNativeMediaEvent(event){switch(event.type){case"loadedmetadata":this.onLoadedMetadata();break;case"durationchange":this.duration=this.mediaController.duration,this.reconcileActiveCue();break;case"play":this.onPlay();break;case"pause":this.onPause();break;case"error":this.onMediaError();break;case"volumechange":{const nextVolume=this.mediaController.volume,nextMuted=this.mediaController.muted;this.volume!==nextVolume&&(this.volume=nextVolume),this.muted!==nextMuted&&(this.muted=nextMuted);break}case"ratechange":{const nextRate=this.mediaController.playbackRate;this.playbackRate!==nextRate&&(this.playbackRate=nextRate);break}case"timeupdate":this.onTimeUpdate();break;case"seeked":this.onSeeked();break;default:break}}emitTimeChange(force,allowDuplicate=!1){const now=Date.now();if(!force&&now-this.lastTimeChangeAt<TIME_CHANGE_THROTTLE_MS)return;const nextTime=this.currentTime;this.currentTimeState=nextTime,!(!allowDuplicate&&nextTime===this.lastEmittedTime)&&(this.lastTimeChangeAt=now,this.lastEmittedTime=nextTime,this.emit("lr-time-change",{currentTime:this.currentTimeState}))}onTimeUpdate(){this.emitTimeChange(!1),this.reconcileActiveCue()}reconcileActiveCue(discontinuity=!1){const time=this.currentTime;if(this._cueSource!==null){this.cueSourceController.updateTime(time,discontinuity);return}const cues=this.cues,duration=this.duration>0?this.duration:0;(!this.cueIndex||this.indexedCues!==cues||this.indexedCueDuration!==duration)&&(this.cueIndex=new AvCueIndex(cues,duration),this.indexedCues=cues,this.indexedCueDuration=duration);const activeIndex=this.cueIndex.at(time),nextId=cues[activeIndex]?.cueId??null;this.setActiveCue(nextId,activeIndex)}setActiveCue(nextId,activeIndex){(nextId!==this.activeCueId||activeIndex!==this.activeCueIndex)&&(this.activeCueId=nextId,this.activeCueIndex=activeIndex,this.emit("lr-cue-change",Object.freeze({cueId:nextId,index:activeIndex})))}onSeeked(){const completedTime=this.currentTime;this.pendingSeekEmission===null||completedTime!==this.pendingSeekEmission?this.emitTimeChange(!0):this.currentTimeState=completedTime,this.pendingSeekEmission=null,this.reconcileActiveCue(!0)}async search(query2){return this._cueSource!==null?(this.captureCueSource(),this.searchQuery=query2.trim(),this.searchLocale=this.effectiveLocale,this.cueSourceController.search(this.searchQuery,this.searchLocale)):(this.searchQuery=query2,this.reconcileSearchMatches(),this.activeSearchIndex=this.searchMatches.length?0:-1,this.refreshTranscriptRenderItem(),this.emitSearchChange(),await this.revealActiveSearchMatch(),this.searchMatches.length)}reconcileSearchMatches(previousCues){const locale=this.effectiveLocale,q=this.searchQuery.trim().toLocaleLowerCase(locale),previousMatchIndex=this.searchMatches[this.activeSearchIndex],previousActiveId=previousCues&&previousMatchIndex!==void 0?previousCues[previousMatchIndex]?.cueId:void 0;if(this.searchMatches=q?this.cues.reduce((acc,cue,index)=>((cue.text.toLocaleLowerCase(locale).includes(q)||(cue.speaker??"").toLocaleLowerCase(locale).includes(q))&&acc.push(index),acc),[]):[],this.searchMatchIndices=new Set(this.searchMatches),this.searchLocale=locale,!this.searchMatches.length){this.activeSearchIndex=-1;return}const retainedPosition=previousActiveId?this.searchMatches.findIndex(index=>this.cues[index]?.cueId===previousActiveId):-1;this.activeSearchIndex=retainedPosition>=0?retainedPosition:Math.min(Math.max(0,this.activeSearchIndex),this.searchMatches.length-1)}async searchNext(){return this._cueSource!==null?this.cueSourceController.navigate(1):this.searchMatches.length?(this.activeSearchIndex=(this.activeSearchIndex+1)%this.searchMatches.length,this.refreshTranscriptRenderItem(),this.emitSearchChange(),await this.revealActiveSearchMatch(),!0):!1}async searchPrevious(){return this._cueSource!==null?this.cueSourceController.navigate(-1):this.searchMatches.length?(this.activeSearchIndex=(this.activeSearchIndex-1+this.searchMatches.length)%this.searchMatches.length,this.refreshTranscriptRenderItem(),this.emitSearchChange(),await this.revealActiveSearchMatch(),!0):!1}clearSearch(){if(this.searchQuery="",this._cueSource!==null){this.cueSourceController.clearSearch();return}this.searchMatches=[],this.searchMatchIndices=new Set,this.activeSearchIndex=-1,this.refreshTranscriptRenderItem(),this.emitSearchChange()}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:!0,activeIndex:this.activeSearchIndex})}async revealSourceCue(index,epoch,authoritative=()=>!0){const current=()=>authoritative()&&this.cueSourceController.isCurrent(epoch);if(!current()||!await this.cueSourceController.window.ensure(index)||!current()||(await this.updateComplete,!current()))return!1;const list=this.renderRoot.querySelector(tag("virtual-list"));return!list||(await list.updateComplete,!current())?!1:(list.scrollToIndex(index,{align:"auto",behavior:"auto"}),current())}async revealActiveSearchMatch(){await this.updateComplete;const list=this.renderRoot.querySelector(tag("virtual-list"));if(!list)return;await list.updateComplete;const index=this.searchMatches[this.activeSearchIndex];index!==void 0&&list.scrollToIndex(index,{align:"auto",behavior:"auto"})}drawWaveform(){const canvas=this.canvasEl,ownerWindow=this.ownerDocument.defaultView;if(!this.hasWaveform){this.waveformDirty=!1;return}if(!this.isConnected||!canvas||!ownerWindow||!this.waveformVisible){this.waveformDirty=!0;return}this.cancelWaveformDrawFrame(),this.waveformDirty=!1,this.paintWaveform()}paintWaveform(){const canvas=this.canvasEl;if(!canvas||!this.hasWaveform)return;const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow)return;const dpr=positiveFinite(ownerWindow.devicePixelRatio),width=positiveFinite(canvas.clientWidth),height=positiveFinite(canvas.clientHeight),allocation=resolveBoundedCanvasAllocation({cssWidth:width,cssHeight:height,desiredScale:dpr,maxDimension:MAX_CANVAS_DIMENSION,maxPixels:MAX_CANVAS_PIXELS});this.lastWaveformAllocation={target:canvas,width,height,dpr},canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight;const ctx=canvas.getContext("2d");if(!ctx)return;const scaleX=allocation.scaleX,scaleY=allocation.scaleY;ctx.setTransform(scaleX,0,0,scaleY,0,0),ctx.clearRect(0,0,width,height),ctx.fillStyle=resolveCanvasColor(this,"var(--lr-color-brand)",ownerWindow.getComputedStyle(this).color);const peaks=this._waveform!==null&&this.waveformSnapshot?preparedWaveformPeaks(this.waveformSnapshot,canvas.width):waveformPaintPeaks(this.peaks,canvas.width),barWidth=width/peaks.length,physicalPixel=Math.min(barWidth,finiteNumber(1/scaleX,barWidth)),paintedBarWidth=Math.max(physicalPixel,barWidth-physicalPixel);peaks.forEach((peak,i)=>{const barHeight=Math.max(1,finiteRange(peak,0,0,1)*height);ctx.fillRect(i*barWidth,(height-barHeight)/2,paintedBarWidth,barHeight)})}scheduleWaveformDraw(){if(this.waveformDrawFrame)return;const owner=this.ownerDocument.defaultView;if(!owner||!this.isConnected)return;const request={owner,handle:0};request.handle=owner.requestAnimationFrame(()=>{this.waveformDrawFrame===request&&(this.waveformDrawFrame=void 0,this.isConnected&&this.ownerDocument.defaultView===owner&&this.drawWaveform())}),this.waveformDrawFrame=request}cancelWaveformDrawFrame(){const request=this.waveformDrawFrame;request&&request.owner.cancelAnimationFrame(request.handle),this.waveformDrawFrame=void 0}renderMarkers(){if(!this.duration)return nothing;const ranged=this.highlights.filter(h=>h.anchor.kind==="time-range");return ranged.length?html`${ranged.map(h=>{const startSeconds=finiteRange(h.anchor.start,0,0,this.duration),endSeconds=h.anchor.end==null?startSeconds:finiteRange(h.anchor.end,startSeconds,startSeconds,this.duration),start=startSeconds/this.duration*100,end=endSeconds/this.duration*100;return html`<button
13
13
  part="timeline-marker"
14
14
  type="button"
15
15
  data-tone=${h.tone??"accent"}
@@ -17,7 +17,7 @@ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,quer
17
17
  style="inset-inline-start:${start}%;inline-size:${Math.max(.5,end-start)}%"
18
18
  aria-label=${h.label||this.localize("viewerHighlightLabel")}
19
19
  @click=${event=>{event.stopPropagation(),this.onHighlightActivate(h.id,h.anchor.start)}}
20
- ></button>`})}`:nothing}rateOptions(){return this.rates.includes(this.playbackRate)?this.rates:[...this.rates,this.playbackRate].sort((a,b)=>a-b)}safeCueStart(cue){const max=this.duration>0?this.duration:1/0;return finiteRange(cue.start,0,0,max)}safeCueEnd(cue,start){const max=this.duration>0?this.duration:1/0;if(cue.end==null){const nextStart=this.nextCueStarts.get(cue.start)??1/0;return start>=max||nextStart===1/0?1/0:Math.min(nextStart,max)}return finiteRange(cue.end,start,start,max)}rebuildCueKeys(){this.cueKeys=this.cues.map(cue=>`cue:${cue.cueId.length}:${cue.cueId}`)}refreshTranscriptRenderItem(){this.transcriptRenderItem=(cue,index)=>this.renderCue(cue,index)}renderTracks(){return this.tracks.map(t=>{const trackSrc=safeMediaSrc(t.src);return trackSrc?html`<track src=${trackSrc} kind=${t.kind} srclang=${t.srclang} label=${t.label} ?default=${t.default} />`:nothing})}render(){const explicitHostLabel=hostAriaLabel(this),aggregateLabel=explicitHostLabel??(this.name||this.localize("avPlayerLabel")),safeSrc=this.src?safeMediaSrc(this.src):null,safePoster=this.poster?safeMediaSrc(this.poster):null,kind=this.detectedKind(),baseOwnsAggregate=explicitHostLabel===null&&!!(this.name||!safeSrc&&this.src),rateFormat=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:2});return!safeSrc&&this.src?html`<div
20
+ ></button>`})}`:nothing}rateOptions(){return this.rates.includes(this.playbackRate)?this.rates:[...this.rates,this.playbackRate].sort((a,b)=>a-b)}safeCueStart(cue){const max=this.duration>0?this.duration:1/0;return finiteRange(cue.start,0,0,max)}rebuildCueKeys(){this.cueKeys=this.cues.map(cue=>`cue:${cue.cueId.length}:${cue.cueId}`)}refreshTranscriptRenderItem(){this.transcriptRenderItem=(cue,index)=>this.renderCue(cue,index)}renderTracks(){return this.tracks.map(t=>{const trackSrc=safeMediaSrc(t.src);return trackSrc?html`<track src=${trackSrc} kind=${t.kind} srclang=${t.srclang} label=${t.label} ?default=${t.default} />`:nothing})}render(){const explicitHostLabel=hostAriaLabel(this),aggregateLabel=explicitHostLabel??(this.name||this.localize("avPlayerLabel")),safeSrc=this.src?safeMediaSrc(this.src):null,safePoster=this.poster?safeMediaSrc(this.poster):null,kind=this.detectedKind(),baseOwnsAggregate=explicitHostLabel===null&&!!(this.name||!safeSrc&&this.src),rateFormat=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:2});return!safeSrc&&this.src?html`<div
21
21
  part="base"
22
22
  role=${baseOwnsAggregate?"region":nothing}
23
23
  aria-label=${baseOwnsAggregate?aggregateLabel:nothing}
@@ -58,6 +58,7 @@ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,quer
58
58
  >${this.renderTracks()}</video
59
59
  >`)}
60
60
  ${this.sourceError||this.playbackError?html`<div part="error">${this.localize("avPlayerFailedToLoad")}</div>`:nothing}
61
+ ${this.waveformUnavailable?html`<div part="error">${this.localize("avPlayerWaveformUnavailable")}</div>`:nothing}
61
62
  <div part="toolbar">
62
63
  <span class="rate-select-wrapper">
63
64
  <select
@@ -86,18 +87,22 @@ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,quer
86
87
  @click=${this.onTimelineClick}
87
88
  @keydown=${this.onTimelineKeyDown}
88
89
  >
89
- ${this.peaks.length?html`<canvas ${ref(this.canvasRef)}></canvas>`:nothing}
90
+ ${this.hasWaveform?html`<canvas ${ref(this.canvasRef)}></canvas>`:nothing}
90
91
  </div>
91
92
  <div class="timeline-markers">${this.renderMarkers()}</div>
92
93
  </div>
93
- ${this.cues.length?html`<lr-virtual-list
94
+ ${this._cueSource!==null&&this.cueSourceController.unavailable?html`<div part="error">${this.localize("avPlayerTranscriptUnavailable")}</div>`:nothing}
95
+ ${this._cueSource!==null&&this.cueSourceController.searchUnavailable?html`<div part="error">${this.localize("sourceSearchUnavailable")}</div>`:this._cueSource!==null&&this.cueSourceController.searchLoading?html`<div>${this.localize("loading")}</div>`:nothing}
96
+ ${(this._cueSource!==null?this.cueSourceController.count:this.cues.length)?html`<lr-virtual-list
94
97
  part="transcript"
95
98
  exportparts="cue:cue, cue-current:cue-current, cue-match:cue-match, cue-active-match:cue-active-match, cue-time:cue-time, cue-speaker:cue-speaker, cue-text:cue-text"
96
99
  aria-label=${this.localize("avPlayerTranscript")}
97
- .items=${this.cues}
100
+ .items=${this._cueSource!==null?EMPTY_CUES:this.cues}
101
+ .source=${this._cueSource!==null?this.cueSourceController.window.source:void 0}
102
+ @lr-visible-range-change=${event=>{this._cueSource!==null&&this.cueSourceController.window.requestRange(event.detail.start,event.detail.end)}}
98
103
  .renderItem=${this.transcriptRenderItem}
99
- .keyFunction=${this.cueKey}
100
- .activeItemId=${this.activeCueIndex>=0&&this.cues[this.activeCueIndex]?this.cueKey(this.cues[this.activeCueIndex],this.activeCueIndex):""}
104
+ .keyFunction=${this._cueSource!==null?void 0:this.cueKey}
105
+ .activeItemId=${this._cueSource!==null?this.cueSourceController.active?.cue.cueId??"":this.activeCueIndex>=0&&this.cues[this.activeCueIndex]?this.cueKey(this.cues[this.activeCueIndex],this.activeCueIndex):""}
101
106
  ></lr-virtual-list>`:nothing}
102
107
  ${this.renderAnchorLiveRegion()}
103
- </div>`}}__decorate([property()],LyraAvPlayer.prototype,"src",void 0),__decorate([property()],LyraAvPlayer.prototype,"name",void 0),__decorate([property()],LyraAvPlayer.prototype,"kind",void 0),__decorate([property({attribute:"mime-type"})],LyraAvPlayer.prototype,"mimeType",void 0),__decorate([property()],LyraAvPlayer.prototype,"poster",void 0),__decorate([property({type:Boolean})],LyraAvPlayer.prototype,"loop",void 0),__decorate([property({type:Boolean})],LyraAvPlayer.prototype,"muted",void 0),__decorate([property()],LyraAvPlayer.prototype,"preload",void 0),__decorate([property({attribute:"controls-surface",reflect:!0,converter:CONTROLS_SURFACE})],LyraAvPlayer.prototype,"controlsSurface",void 0),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"rates",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"cues",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"peaks",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"tracks",null),__decorate([state()],LyraAvPlayer.prototype,"duration",void 0),__decorate([state()],LyraAvPlayer.prototype,"currentTimeState",void 0),__decorate([state()],LyraAvPlayer.prototype,"activeCueId",void 0),__decorate([state()],LyraAvPlayer.prototype,"activeCueIndex",void 0),__decorate([state()],LyraAvPlayer.prototype,"searchQuery",void 0),__decorate([state()],LyraAvPlayer.prototype,"searchMatches",void 0),__decorate([state()],LyraAvPlayer.prototype,"activeSearchIndex",void 0),__decorate([state()],LyraAvPlayer.prototype,"metadataLoaded",void 0),__decorate([state()],LyraAvPlayer.prototype,"sourceError",void 0),__decorate([state()],LyraAvPlayer.prototype,"playbackError",void 0),__decorate([query('[part="timeline"] canvas')],LyraAvPlayer.prototype,"canvasEl",void 0);export{LyraAvPlayer};
108
+ </div>`}}__decorate([property()],LyraAvPlayer.prototype,"src",void 0),__decorate([property()],LyraAvPlayer.prototype,"name",void 0),__decorate([property()],LyraAvPlayer.prototype,"kind",void 0),__decorate([property({attribute:"mime-type"})],LyraAvPlayer.prototype,"mimeType",void 0),__decorate([property()],LyraAvPlayer.prototype,"poster",void 0),__decorate([property({type:Boolean})],LyraAvPlayer.prototype,"loop",void 0),__decorate([property({type:Boolean})],LyraAvPlayer.prototype,"muted",void 0),__decorate([property()],LyraAvPlayer.prototype,"preload",void 0),__decorate([property({attribute:"controls-surface",reflect:!0,converter:CONTROLS_SURFACE})],LyraAvPlayer.prototype,"controlsSurface",void 0),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"rates",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"cues",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"cueSource",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"peaks",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"waveform",null),__decorate([property({attribute:!1})],LyraAvPlayer.prototype,"tracks",null),__decorate([state()],LyraAvPlayer.prototype,"duration",void 0),__decorate([state()],LyraAvPlayer.prototype,"currentTimeState",void 0),__decorate([state()],LyraAvPlayer.prototype,"activeCueId",void 0),__decorate([state()],LyraAvPlayer.prototype,"activeCueIndex",void 0),__decorate([state()],LyraAvPlayer.prototype,"searchQuery",void 0),__decorate([state()],LyraAvPlayer.prototype,"searchMatches",void 0),__decorate([state()],LyraAvPlayer.prototype,"activeSearchIndex",void 0),__decorate([state()],LyraAvPlayer.prototype,"metadataLoaded",void 0),__decorate([state()],LyraAvPlayer.prototype,"sourceError",void 0),__decorate([state()],LyraAvPlayer.prototype,"playbackError",void 0),__decorate([query('[part="timeline"] canvas')],LyraAvPlayer.prototype,"canvasEl",void 0);export{LyraAvPlayer};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getDisplayNames}from"../../../internal/intl-cache.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./flag.styles.js";import{ALPHA2_RE,alpha3ToAlpha2,languageToCountry}from"./language-map.js";import"../../overlays/skeleton/skeleton.class.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{getFlagResolverGeneration,subscribeFlagResolver,loadFlagUrlResolver,warnMissingFlagResolver}from"./flag-url-resolver.js";import{LYRA_DEFAULT_flagLoadError}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";import{loadFlagUrl,loadBulkFlagUrl,setFlagUrlResolver}from"./flag-url-resolver.js";const FLAG_LOAD_ERROR_KEY="flagLoadError",FLAG_FIDELITIES=new Set(["compact","standard","detailed"]),FLAG_SHAPES=new Set(["rect","circle"]);function normalizeFlagFidelity(value){return FLAG_FIDELITIES.has(value)?value:"standard"}function normalizeFlagShape(value){return FLAG_SHAPES.has(value)?value:"rect"}function displayNameFor(code,locale){try{return getDisplayNames(locale,{type:"region"}).of(code.toUpperCase())??code.toUpperCase()}catch{return code.toUpperCase()}}class LyraFlag extends LyraElement{constructor(){super(...arguments),this._shape="rect",this._fidelity="standard",this.sourceState=Object.freeze({status:"idle",identity:"idle"}),this.resolverGeneration=getFlagResolverGeneration(),this.announcements=new AnnouncementSinkController(this),this.sourceRestartPending=!0,this.activeSourceRequest=0,this.resolveToken=0,this.onResolverGeneration=generation=>{!this.isConnected||generation===this.resolverGeneration||(this.resolverGeneration=generation)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,flagLoadError:LYRA_DEFAULT_flagLoadError,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles,srOnly]}get shape(){return this._shape}set shape(value){const old=this._shape;this._shape=normalizeFlagShape(value),this.requestUpdate("shape",old)}get fidelity(){return this._fidelity}set fidelity(value){const old=this._fidelity;this._fidelity=normalizeFlagFidelity(value),this.requestUpdate("fidelity",old)}get effectiveFidelity(){return normalizeFlagFidelity(this.fidelity)}get loading(){return this.sourceState.status==="loading"}get code(){if(this.country)return ALPHA2_RE.test(this.country)?this.country.toLowerCase():alpha3ToAlpha2(this.country);if(this.language)return languageToCountry(this.language)}get unresolved(){return this.src||!this.country&&!this.language?!1:this.code===void 0}connectedCallback(){super.connectedCallback(),this.sourceRestartPending=!0,this.stopFlagResolverSubscription=subscribeFlagResolver(this.onResolverGeneration),this.resolverGeneration!==getFlagResolverGeneration()&&(this.resolverGeneration=getFlagResolverGeneration()),this.requestUpdate()}disconnectedCallback(){this.resolveToken++,this.sourceRestartPending=!0,this.stopFlagResolverSubscription?.(),this.stopFlagResolverSubscription=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resolveToken++,this.sourceRestartPending=!0,this.announcements.adopted(),this.requestUpdate()}announceLoadError(){this.announcements.announceAssertive(this.localize(FLAG_LOAD_ERROR_KEY))}setSourceState(state2,announceError=!1){this.sourceState=Object.freeze(state2),this.toggleAttribute("data-error",state2.status==="error"),this.toggleAttribute("data-unresolved",this.unresolved),this.setAttribute("aria-busy",String(state2.status==="loading")),announceError&&this.isConnected&&this.announceLoadError()}failSource(identity,announce=!0){this.setSourceState({status:"error",identity},announce)}onImageLoad(event,identity,url,request){const image=event.currentTarget;!this.isConnected||request!==this.activeSourceRequest||!image||image!==this.renderRoot.querySelector('[part="image"]')||this.sourceState.status!=="loading"||this.sourceState.identity!==identity||this.sourceState.url!==url||this.setSourceState({status:"loaded",identity,url})}onImageError(event,identity,request){const image=event.currentTarget;!this.isConnected||request!==this.activeSourceRequest||!image||image!==this.renderRoot.querySelector('[part="image"]')||this.sourceState.status!=="loading"||this.sourceState.identity!==identity||this.failSource(identity)}willUpdate(changed){super.willUpdate(changed);const sourceChanged=changed.has("country")||changed.has("language")||changed.has("src")||changed.has("fidelity")||changed.has("resolverGeneration");if(typeof Node<"u"&&!this.isConnected){sourceChanged&&(this.resolveToken++,this.sourceRestartPending=!0);return}if(this.hasUpdated&&!sourceChanged&&!this.sourceRestartPending)return;const connectionBaseline=this.sourceRestartPending;this.sourceRestartPending=!1;const token=++this.resolveToken,request=++this.activeSourceRequest,URLCtor=this.ownerDocument?.defaultView?.URL??globalThis.URL,directValue=typeof this.src=="string"?this.src.trim():"";if((directValue||this.code)&&this.announcements.current("assertive"),directValue){const identity2=`direct:${directValue}`,url=safeMediaSrc(directValue,URLCtor);if(!url){this.failSource(identity2,!connectionBaseline);return}this.setSourceState({status:"loading",identity:identity2,url});return}const code=this.code;if(!code){this.setSourceState({status:"idle",identity:"idle"});return}const fidelity=this.effectiveFidelity,identity=`peer:${code}:${fidelity}:${this.resolverGeneration}`;this.setSourceState({status:"loading",identity}),loadFlagUrlResolver().then(async resolve=>{if(token!==this.resolveToken||request!==this.activeSourceRequest||!this.isConnected)return;if(typeof resolve!="function"){warnMissingFlagResolver(code),this.failSource(identity);return}const candidate=await resolve(code,fidelity==="standard"?void 0:{variant:fidelity});if(token!==this.resolveToken||request!==this.activeSourceRequest||!this.isConnected)return;if(candidate===void 0){this.setSourceState({status:"idle",identity});return}const url=safeMediaSrc(candidate,URLCtor);if(!url){this.failSource(identity);return}this.setSourceState({status:"loading",identity,url})}).catch(err=>{token!==this.resolveToken||request!==this.activeSourceRequest||!this.isConnected||(devWarnOnce("lyra-flag-resolve-failed",`<lr-flag> failed to resolve a flag URL for "${code}": ${err}`),this.failSource(identity))})}updated(changed){super.updated(changed),this.setAttribute("aria-busy",String(this.sourceState.status==="loading")),this.toggleAttribute("data-unresolved",this.unresolved)}render(){const state2=this.sourceState,request=this.activeSourceRequest;if(this.unresolved){const fallbackUrl=this.fallback?safeMediaSrc(this.fallback,this.ownerDocument?.defaultView?.URL??globalThis.URL):null,fallbackAlt=hostAriaLabel(this)??this.label??"";return html`<slot name="fallback"
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getDisplayNames}from"../../../internal/intl-cache.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./flag.styles.js";import{ALPHA2_RE,alpha3ToAlpha2,languageToCountry}from"./language-map.js";import"../../overlays/skeleton/skeleton.class.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{getFlagResolverGeneration,subscribeFlagResolver,loadFlagUrlResolver,warnMissingFlagResolver}from"./flag-url-resolver.js";import{LYRA_DEFAULT_flagLoadError}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";import{loadFlagUrl,loadBulkFlagUrl,setFlagUrlResolver}from"./flag-url-resolver.js";const FLAG_LOAD_ERROR_KEY="flagLoadError",FLAG_FIDELITIES=new Set(["compact","standard","detailed"]),FLAG_SHAPES=new Set(["rect","circle"]);function normalizeFlagFidelity(value){return FLAG_FIDELITIES.has(value)?value:"standard"}function normalizeFlagShape(value){return FLAG_SHAPES.has(value)?value:"rect"}const pendingFlagUrls=new Map;let pendingFlagGeneration=-1;function sharedFlagUrl(resolve,code,fidelity,generation){pendingFlagGeneration!==generation&&(pendingFlagUrls.clear(),pendingFlagGeneration=generation);const key=`${code}:${fidelity}`,cached=pendingFlagUrls.get(key);if(cached)return cached;let request;try{request=Promise.resolve(resolve(code,fidelity==="standard"?void 0:{variant:fidelity}))}catch(error){return Promise.reject(error)}pendingFlagUrls.size>=256&&pendingFlagUrls.delete(pendingFlagUrls.keys().next().value),pendingFlagUrls.set(key,request);const release=()=>{pendingFlagUrls.get(key)===request&&pendingFlagUrls.delete(key)};return request.then(release,release),request}function displayNameFor(code,locale){try{return getDisplayNames(locale,{type:"region"}).of(code.toUpperCase())??code.toUpperCase()}catch{return code.toUpperCase()}}class LyraFlag extends LyraElement{constructor(){super(...arguments),this._shape="rect",this._fidelity="standard",this.sourceState=Object.freeze({status:"idle",identity:"idle"}),this.resolverGeneration=getFlagResolverGeneration(),this.announcements=new AnnouncementSinkController(this),this.sourceRestartPending=!0,this.activeSourceRequest=0,this.resolveToken=0,this.onResolverGeneration=generation=>{!this.isConnected||generation===this.resolverGeneration||(this.resolverGeneration=generation)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,flagLoadError:LYRA_DEFAULT_flagLoadError,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles,srOnly]}get shape(){return this._shape}set shape(value){const old=this._shape;this._shape=normalizeFlagShape(value),this.requestUpdate("shape",old)}get fidelity(){return this._fidelity}set fidelity(value){const old=this._fidelity;this._fidelity=normalizeFlagFidelity(value),this.requestUpdate("fidelity",old)}get effectiveFidelity(){return normalizeFlagFidelity(this.fidelity)}get loading(){return this.sourceState.status==="loading"}get code(){if(this.country)return ALPHA2_RE.test(this.country)?this.country.toLowerCase():alpha3ToAlpha2(this.country);if(this.language)return languageToCountry(this.language)}get unresolved(){return this.src||!this.country&&!this.language?!1:this.code===void 0}connectedCallback(){super.connectedCallback(),this.sourceRestartPending=!0,this.stopFlagResolverSubscription=subscribeFlagResolver(this.onResolverGeneration),this.resolverGeneration!==getFlagResolverGeneration()&&(this.resolverGeneration=getFlagResolverGeneration()),this.requestUpdate()}disconnectedCallback(){this.resolveToken++,this.sourceRestartPending=!0,this.stopFlagResolverSubscription?.(),this.stopFlagResolverSubscription=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resolveToken++,this.sourceRestartPending=!0,this.announcements.adopted(),this.requestUpdate()}announceLoadError(){this.announcements.announceAssertive(this.localize(FLAG_LOAD_ERROR_KEY))}setSourceState(state2,announceError=!1){this.sourceState=Object.freeze(state2),this.toggleAttribute("data-error",state2.status==="error"),this.toggleAttribute("data-unresolved",this.unresolved),this.setAttribute("aria-busy",String(state2.status==="loading")),announceError&&this.isConnected&&this.announceLoadError()}failSource(identity,announce=!0){this.setSourceState({status:"error",identity},announce)}onImageLoad(event,identity,url,request){const image=event.currentTarget;!this.isConnected||request!==this.activeSourceRequest||!image||image!==this.renderRoot.querySelector('[part="image"]')||this.sourceState.status!=="loading"||this.sourceState.identity!==identity||this.sourceState.url!==url||this.setSourceState({status:"loaded",identity,url})}onImageError(event,identity,request){const image=event.currentTarget;!this.isConnected||request!==this.activeSourceRequest||!image||image!==this.renderRoot.querySelector('[part="image"]')||this.sourceState.status!=="loading"||this.sourceState.identity!==identity||this.failSource(identity)}willUpdate(changed){super.willUpdate(changed);const sourceChanged=changed.has("country")||changed.has("language")||changed.has("src")||changed.has("fidelity")||changed.has("resolverGeneration");if(typeof Node<"u"&&!this.isConnected){sourceChanged&&(this.resolveToken++,this.sourceRestartPending=!0);return}if(this.hasUpdated&&!sourceChanged&&!this.sourceRestartPending)return;const connectionBaseline=this.sourceRestartPending;this.sourceRestartPending=!1;const token=++this.resolveToken,request=++this.activeSourceRequest,URLCtor=this.ownerDocument?.defaultView?.URL??globalThis.URL,directValue=typeof this.src=="string"?this.src.trim():"";if((directValue||this.code)&&this.announcements.current("assertive"),directValue){const identity2=`direct:${directValue}`,url=safeMediaSrc(directValue,URLCtor);if(!url){this.failSource(identity2,!connectionBaseline);return}this.setSourceState({status:"loading",identity:identity2,url});return}const code=this.code;if(!code){this.setSourceState({status:"idle",identity:"idle"});return}const fidelity=this.effectiveFidelity,identity=`peer:${code}:${fidelity}:${this.resolverGeneration}`;this.setSourceState({status:"loading",identity}),loadFlagUrlResolver().then(async resolve=>{if(token!==this.resolveToken||request!==this.activeSourceRequest||!this.isConnected)return;if(typeof resolve!="function"){warnMissingFlagResolver(code),this.failSource(identity);return}const candidate=await sharedFlagUrl(resolve,code,fidelity,this.resolverGeneration);if(token!==this.resolveToken||request!==this.activeSourceRequest||!this.isConnected)return;if(candidate===void 0){this.setSourceState({status:"idle",identity});return}const url=safeMediaSrc(candidate,URLCtor);if(!url){this.failSource(identity);return}this.setSourceState({status:"loading",identity,url})}).catch(err=>{token!==this.resolveToken||request!==this.activeSourceRequest||!this.isConnected||(devWarnOnce("lyra-flag-resolve-failed",`<lr-flag> failed to resolve a flag URL for "${code}": ${err}`),this.failSource(identity))})}updated(changed){super.updated(changed),this.setAttribute("aria-busy",String(this.sourceState.status==="loading")),this.toggleAttribute("data-unresolved",this.unresolved)}render(){const state2=this.sourceState,request=this.activeSourceRequest;if(this.unresolved){const fallbackUrl=this.fallback?safeMediaSrc(this.fallback,this.ownerDocument?.defaultView?.URL??globalThis.URL):null,fallbackAlt=hostAriaLabel(this)??this.label??"";return html`<slot name="fallback"
2
2
  >${fallbackUrl?html`<img part="fallback-image" src=${fallbackUrl} alt=${fallbackAlt} />`:nothing}</slot
3
3
  >`}if(state2.status==="error")return html`<span part="error">${this.localize(FLAG_LOAD_ERROR_KEY)}</span>`;const url=state2.status==="loading"||state2.status==="loaded"?state2.url:void 0;if(!url&&state2.status!=="loading")return html``;const code=this.code,alt=hostAriaLabel(this)??this.label??(code?displayNameFor(code,this.effectiveLocale):"");return html`
4
4
  ${state2.status==="loading"?html`
@@ -1 +1 @@
1
- import{getDisplayNames}from"../../../internal/intl-cache.js";const ALPHA2_RE=/^[a-z]{2}$/i,ALPHA3_RE=/^[a-z]{3}$/i,ALPHA3_TO_ALPHA2_PACKED="abwawafgafagoaoaiaaialaaxalbalandadareaeargararmamasmasataaqatftfatgagausauautatazeazbdibibelbebenbjbesbqbfabfbgdbdbgrbgbhrbhbhsbsbihbablmblblrbyblzbzbmubmbolbobrabrbrbbbbrnbnbtnbtbvtbvbwabwcafcfcancacckccchechchlclchncncivcicmrcmcodcdcogcgcokckcolcocomkmcpvcvcricrcubcucuwcwcxrcxcymkycypcyczeczdeudedjidjdmadmdnkdkdomdodzadzecuecegyegeriereshehespesesteeethetfinfifjifjflkfkfrafrfrofofsmfmgabgagbrgbgeogeggyggghaghgibgigingnglpgpgmbgmgnbgwgnqgqgrcgrgrdgdgrlglgtmgtgufgfgumguguygyhkghkhmdhmhndhnhrvhrhtihthunhuidnidimnimindiniotioirlieirnirirqiqislisisrilitaitjamjmjeyjejorjojpnjpkazkzkenkekgzkgkhmkhkirkiknaknkorkrkwtkwlaolalbnlblbrlrlbylylcalclielilkalklsolsltultluxlulvalvmacmomafmfmarmamcomcmdamdmdgmgmdvmvmexmxmhlmhmkdmkmlimlmltmtmmrmmmnememngmnmnpmpmozmzmrtmrmsrmsmtqmqmusmumwimwmysmymytytnamnanclncnernenfknfngangnicniniununldnlnornonplnpnrunrnzlnzomnompakpkpanpapcnpnperpephlphplwpwpngpgpolplpriprprkkpprtptprypypsepspyfpfqatqareurerourorusrurwarwsausasdnsdsensnsgpsgsgsgsshnshsjmsjslbsbsleslslvsvsmrsmsomsospmpmsrbrsssdssstpstsursrsvksksvnsisweseswzszsxmsxsycscsyrsytcatctcdtdtgotgthathtjktjtkltktkmtmtlstltontottotttuntnturtrtuvtvtwntwtzatzugaugukruaumiumuryuyusausuzbuzvatvavctvcvenvevgbvgvirvivnmvnvutvuwlfwfwsmwsyemyezafzazmbzmzwezw";let alpha3Lookup;function alpha3ToAlpha2(code){if(ALPHA3_RE.test(code)){if(!alpha3Lookup){alpha3Lookup=new Map;for(let index=0;index<ALPHA3_TO_ALPHA2_PACKED.length;index+=5)alpha3Lookup.set(ALPHA3_TO_ALPHA2_PACKED.slice(index,index+3),ALPHA3_TO_ALPHA2_PACKED.slice(index+3,index+5))}return alpha3Lookup.get(code.toLowerCase())}}const LANGUAGE_TO_COUNTRY={en:"gb",fr:"fr",de:"de",es:"es",it:"it",pt:"pt",nl:"nl",ar:"sa",zh:"cn",ja:"jp",ko:"kr",ru:"ru",pl:"pl",tr:"tr",sv:"se",da:"dk",fi:"fi",no:"no",nb:"no",nn:"no",cs:"cz",sk:"sk",el:"gr",he:"il",hi:"in",th:"th",vi:"vn",id:"id",ms:"my",uk:"ua",kk:"kz",lah:"pk",ro:"ro",hu:"hu",bg:"bg",hr:"hr",sr:"rs",sl:"si",et:"ee",lv:"lv",lt:"lt",fa:"ir",ur:"pk",bn:"bd",ta:"in",am:"et",bho:"in",gu:"in",ha:"ng",ig:"ng",jv:"id",kn:"in",ln:"cd",ml:"in",mr:"in",my:"mm",ne:"np",om:"et",or:"in",pa:"in",pcm:"ng",pnb:"pk",ps:"af",sd:"pk",su:"id",sw:"tz",te:"in",tl:"ph",uz:"uz",yo:"ng",zu:"za",ca:"es",lb:"lu",fil:"ph"};function mappedCountry(language){return Object.hasOwn(LANGUAGE_TO_COUNTRY,language)?LANGUAGE_TO_COUNTRY[language]:void 0}function scriptImpliedRegion(locale){if(!locale.script)return;const scriptRegion=locale.maximize().region,languageRegion=new Intl.Locale(locale.language).maximize().region;return scriptRegion&&ALPHA2_RE.test(scriptRegion)&&scriptRegion!==languageRegion?scriptRegion.toLowerCase():void 0}function languageToCountry(language){if(typeof language!="string")return;const normalized=language.trim().replaceAll("_","-");if(!normalized)return;try{const locale=new Intl.Locale(normalized);if(locale.region&&/^\d{3}$/.test(locale.region))return;if(locale.region&&ALPHA2_RE.test(locale.region))return locale.region.toLowerCase();const mapped=mappedCountry(locale.language.toLowerCase());return mapped===void 0?void 0:scriptImpliedRegion(locale)??mapped}catch{}const parts=normalized.toLowerCase().split("-").slice(0,16),base=parts[0];if(base.length!==1){for(const part of parts.slice(1)){if(!/^[a-z0-9]{1,8}$/.test(part)||part.length===1)break;if(/^\d{3}$/.test(part))return;if(ALPHA2_RE.test(part))return part}return mappedCountry(base)}}function localeNativeName(tag){try{return getDisplayNames(tag,{type:"language"}).of(tag)??tag}catch{return tag}}export{ALPHA2_RE,ALPHA3_RE,LANGUAGE_TO_COUNTRY,alpha3ToAlpha2,languageToCountry,localeNativeName};
1
+ import{getDisplayNames}from"../../../internal/intl-cache.js";const nativeNames=new Map;let nativeNameMethod,nativeNameConstructor;const ALPHA2_RE=/^[a-z]{2}$/i,ALPHA3_RE=/^[a-z]{3}$/i,ALPHA3_TO_ALPHA2_PACKED="abwawafgafagoaoaiaaialaaxalbalandadareaeargararmamasmasataaqatftfatgagausauautatazeazbdibibelbebenbjbesbqbfabfbgdbdbgrbgbhrbhbhsbsbihbablmblblrbyblzbzbmubmbolbobrabrbrbbbbrnbnbtnbtbvtbvbwabwcafcfcancacckccchechchlclchncncivcicmrcmcodcdcogcgcokckcolcocomkmcpvcvcricrcubcucuwcwcxrcxcymkycypcyczeczdeudedjidjdmadmdnkdkdomdodzadzecuecegyegeriereshehespesesteeethetfinfifjifjflkfkfrafrfrofofsmfmgabgagbrgbgeogeggyggghaghgibgigingnglpgpgmbgmgnbgwgnqgqgrcgrgrdgdgrlglgtmgtgufgfgumguguygyhkghkhmdhmhndhnhrvhrhtihthunhuidnidimnimindiniotioirlieirnirirqiqislisisrilitaitjamjmjeyjejorjojpnjpkazkzkenkekgzkgkhmkhkirkiknaknkorkrkwtkwlaolalbnlblbrlrlbylylcalclielilkalklsolsltultluxlulvalvmacmomafmfmarmamcomcmdamdmdgmgmdvmvmexmxmhlmhmkdmkmlimlmltmtmmrmmmnememngmnmnpmpmozmzmrtmrmsrmsmtqmqmusmumwimwmysmymytytnamnanclncnernenfknfngangnicniniununldnlnornonplnpnrunrnzlnzomnompakpkpanpapcnpnperpephlphplwpwpngpgpolplpriprprkkpprtptprypypsepspyfpfqatqareurerourorusrurwarwsausasdnsdsensnsgpsgsgsgsshnshsjmsjslbsbsleslslvsvsmrsmsomsospmpmsrbrsssdssstpstsursrsvksksvnsisweseswzszsxmsxsycscsyrsytcatctcdtdtgotgthathtjktjtkltktkmtmtlstltontottotttuntnturtrtuvtvtwntwtzatzugaugukruaumiumuryuyusausuzbuzvatvavctvcvenvevgbvgvirvivnmvnvutvuwlfwfwsmwsyemyezafzazmbzmzwezw";let alpha3Lookup;function alpha3ToAlpha2(code){if(ALPHA3_RE.test(code)){if(!alpha3Lookup){alpha3Lookup=new Map;for(let index=0;index<ALPHA3_TO_ALPHA2_PACKED.length;index+=5)alpha3Lookup.set(ALPHA3_TO_ALPHA2_PACKED.slice(index,index+3),ALPHA3_TO_ALPHA2_PACKED.slice(index+3,index+5))}return alpha3Lookup.get(code.toLowerCase())}}const LANGUAGE_TO_COUNTRY={en:"gb",fr:"fr",de:"de",es:"es",it:"it",pt:"pt",nl:"nl",ar:"sa",zh:"cn",ja:"jp",ko:"kr",ru:"ru",pl:"pl",tr:"tr",sv:"se",da:"dk",fi:"fi",no:"no",nb:"no",nn:"no",cs:"cz",sk:"sk",el:"gr",he:"il",hi:"in",th:"th",vi:"vn",id:"id",ms:"my",uk:"ua",kk:"kz",lah:"pk",ro:"ro",hu:"hu",bg:"bg",hr:"hr",sr:"rs",sl:"si",et:"ee",lv:"lv",lt:"lt",fa:"ir",ur:"pk",bn:"bd",ta:"in",am:"et",bho:"in",gu:"in",ha:"ng",ig:"ng",jv:"id",kn:"in",ln:"cd",ml:"in",mr:"in",my:"mm",ne:"np",om:"et",or:"in",pa:"in",pcm:"ng",pnb:"pk",ps:"af",sd:"pk",su:"id",sw:"tz",te:"in",tl:"ph",uz:"uz",yo:"ng",zu:"za",ca:"es",lb:"lu",fil:"ph"};function mappedCountry(language){return Object.hasOwn(LANGUAGE_TO_COUNTRY,language)?LANGUAGE_TO_COUNTRY[language]:void 0}function scriptImpliedRegion(locale){if(!locale.script)return;const scriptRegion=locale.maximize().region,languageRegion=new Intl.Locale(locale.language).maximize().region;return scriptRegion&&ALPHA2_RE.test(scriptRegion)&&scriptRegion!==languageRegion?scriptRegion.toLowerCase():void 0}function languageToCountry(language){if(typeof language!="string")return;const normalized=language.trim().replaceAll("_","-");if(!normalized)return;try{const locale=new Intl.Locale(normalized);if(locale.region&&/^\d{3}$/.test(locale.region))return;if(locale.region&&ALPHA2_RE.test(locale.region))return locale.region.toLowerCase();const mapped=mappedCountry(locale.language.toLowerCase());return mapped===void 0?void 0:scriptImpliedRegion(locale)??mapped}catch{}const parts=normalized.toLowerCase().split("-").slice(0,16),base=parts[0];if(base.length!==1){for(const part of parts.slice(1)){if(!/^[a-z0-9]{1,8}$/.test(part)||part.length===1)break;if(/^\d{3}$/.test(part))return;if(ALPHA2_RE.test(part))return part}return mappedCountry(base)}}function localeNativeName(tag){try{(nativeNameMethod!==Intl.DisplayNames.prototype.of||nativeNameConstructor!==Intl.DisplayNames)&&(nativeNames.clear(),nativeNameMethod=Intl.DisplayNames.prototype.of,nativeNameConstructor=Intl.DisplayNames);const cached=nativeNames.get(tag);if(cached!==void 0)return cached;const name=getDisplayNames(tag,{type:"language"}).of(tag)??tag;return nativeNames.size>=1024&&nativeNames.delete(nativeNames.keys().next().value),nativeNames.set(tag,name),name}catch{return tag}}export{ALPHA2_RE,ALPHA3_RE,LANGUAGE_TO_COUNTRY,alpha3ToAlpha2,languageToCountry,localeNativeName};
@@ -0,0 +1 @@
1
+ import{SourceRequestController,sourceCount,sourceRevision}from"../../../internal/source-request-controller.js";import{SourceWindowController}from"../../../internal/source-window-controller.js";import{safeMediaSrc}from"../../../internal/safe-url.js";const MAX_FIELD_UNITS=65536;function field(value,key){if(value===null||typeof value!="object")throw new TypeError("Invalid image record");const descriptor=Object.getOwnPropertyDescriptor(value,key);if(descriptor&&!("value"in descriptor))throw new TypeError("Invalid image field");return descriptor?.value}function text(value,optional=!1){if(!(optional&&value===void 0)){if(typeof value!="string"||value.length>MAX_FIELD_UNITS)throw new TypeError("Invalid image text");return value}}function normalize(value){const key=text(field(value,"key"));if(!key.length)throw new TypeError("Invalid image key");const order=sourceCount(field(value,"order")),image=field(value,"value"),src=text(field(image,"src")),alt=text(field(image,"alt"),!0),caption=text(field(image,"caption"),!0);return Object.freeze({key,order,value:Object.freeze({src,...alt===void 0?{}:{alt},...caption===void 0?{}:{caption}})})}class LightboxSourceController{constructor(host,repaint){this.host=host,this.repaint=repaint,this.locale="",this.dirty=!0,this.transaction=0,this.requestedIndex=-1,this.count=0,this.state="empty",this.requests=new SourceRequestController(host,{channels:["image"],onReset:()=>this.clearImage()}),this.window=new SourceWindowController(host,{pageSize:1,maxRows:3,maxPages:3,maxConcurrent:1,keyOf:record=>record.key,normalize,onChange:repaint}),host.addController(this)}clearImage(){this.requestedIndex=-1,this.pendingImage&&(this.pendingImage.onload=null,this.pendingImage.onerror=null,this.pendingImage.removeAttribute("src"),this.pendingImage=void 0),this.image=void 0,this.state=this.count?"loading":"empty"}refresh(){this.dirty=!0,this.transaction++,this.requests.refresh(),this.window.bind(void 0),this.repaint()}update(input,locale){if(!this.dirty&&input===this.input&&locale===this.locale)return!0;const transaction=++this.transaction;if(this.input=input,this.locale=locale,this.dirty=!1,this.requests.refresh(),transaction!==this.transaction||(this.window.bind(void 0),transaction!==this.transaction))return!1;try{if(input!==void 0){if(input===null||typeof input!="object")throw new TypeError("Invalid image source");const revision=sourceRevision(input.revision);if(transaction!==this.transaction)return!1;const view=input.images;if(transaction!==this.transaction)return!1;const count=sourceCount(view.count);if(transaction!==this.transaction||(this.requests.setSource(input,revision),transaction!==this.transaction)||(this.window.bind({owner:input,revision,epoch:this.requests.epoch,locale,view}),transaction!==this.transaction))return!1;this.count=count}else{if(this.requests.setSource(void 0,void 0),transaction!==this.transaction)return!1;this.count=0}this.state=this.count?"loading":"empty"}catch{if(transaction!==this.transaction||(this.requests.setSource(void 0,void 0),transaction!==this.transaction)||(this.window.bind(void 0),transaction!==this.transaction))return!1;this.count=0,this.state=input===void 0?"empty":"error"}return!0}select(index){if(this.dirty||!this.count||index===this.requestedIndex||!this.host.isConnected)return;this.requests.invalidate("image"),this.clearImage(),this.requestedIndex=index,this.state="loading";const lease=this.requests.begin("image",this.locale);lease&&(this.window.requestRange(index,index+1),this.window.ensure(index).then(ready=>{if(!lease.isCurrent())return;const slot=ready?this.window.source.itemAt(index):void 0;if(slot?.state!=="ready"){this.state="error",this.repaint();return}const value=slot.value.value,src=safeMediaSrc(value.src);if(!src){this.state="error",this.repaint();return}const image=this.host.ownerDocument.createElement("img");this.pendingImage=image;const settle=loaded=>{!lease.isCurrent()||this.pendingImage!==image||(image.onload=null,image.onerror=null,this.pendingImage=void 0,this.image=loaded?Object.freeze({...value,src}):void 0,this.state=loaded?"ready":"error",this.repaint())};image.onload=()=>settle(!0),image.onerror=()=>settle(!1),image.src=src}))}retry(index){if(this.count===0){this.refresh();return}this.requestedIndex=-1,this.select(index),this.repaint()}adopted(){this.requests.adopted(),this.window.adopted(),this.refresh()}hostConnected(){this.dirty=!0,this.repaint()}hostDisconnected(){this.dirty=!0,this.clearImage()}}export{LightboxSourceController};
@@ -0,0 +1,15 @@
1
+ import type{LyraIndexedView,LyraSourceRecord,LyraSourceRevision}from'../../../data-sources.js';
2
+ /** One image in the set `<lr-lightbox>` browses. `alt`/`caption` are caller-supplied data
3
+ * (like a filename), not routed through `localize()` -- only the component's own chrome
4
+ * strings are. */
5
+ export interface LyraLightboxImage{
6
+ /** Full-resolution URL. Passed straight through to the embedded `<lr-pan-zoom>`'s own
7
+ * `src`, which already runs it through `safeMediaSrc()` -- no separate validation needed here. */
8
+ readonly src:string;
9
+ /** Accessible alt text. Defaults to `''` (decorative) when omitted; consumers should supply
10
+ * real alt text for meaningful images. */
11
+ readonly alt?:string;
12
+ /** Optional visible caption for this image, rendered in `part="caption"` below the stage. */
13
+ readonly caption?:string;}
14
+ /** Host-owned access to the complete ordered image collection. */
15
+ export interface LyraLightboxSource{readonly revision:LyraSourceRevision;readonly images:LyraIndexedView<LyraSourceRecord<LyraLightboxImage>>;}
@@ -1,16 +1,4 @@
1
- import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraImageFit}from'../../../internal/image-fit.js';import'../pan-zoom/pan-zoom.class.js';export type{LyraImageFit}from'../../../internal/image-fit.js';
2
- /** One image in the set `<lr-lightbox>` browses. `alt`/`caption` are caller-supplied data
3
- * (like a filename), not routed through `localize()` -- only the component's own chrome
4
- * strings are. */
5
- export interface LyraLightboxImage{
6
- /** Full-resolution URL. Passed straight through to the embedded `<lr-pan-zoom>`'s own
7
- * `src`, which already runs it through `safeMediaSrc()` -- no separate validation needed here. */
8
- readonly src:string;
9
- /** Accessible alt text. Defaults to `''` (decorative) when omitted; consumers should supply
10
- * real alt text for meaningful images. */
11
- readonly alt?:string;
12
- /** Optional visible caption for this image, rendered in `part="caption"` below the stage. */
13
- readonly caption?:string;}
1
+ import type{LyraLightboxImage,LyraLightboxSource}from'./lightbox-types.js';export type{LyraLightboxImage,LyraLightboxSource}from'./lightbox-types.js';import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraImageFit}from'../../../internal/image-fit.js';import'../pan-zoom/pan-zoom.class.js';export type{LyraImageFit}from'../../../internal/image-fit.js';
14
2
  /**
15
3
  * Reason a lightbox was dismissed, forwarded as the `lr-close-request` and `lr-close` event detail --
16
4
  * 1:1 copy of `<lr-dialog>`'s own `DialogCloseReason` contract. `'escape'` and `'backdrop'`
@@ -67,7 +55,7 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
67
55
  * reason `unmount`, and `lr-after-hide`; removal cannot be vetoed.
68
56
  *
69
57
  * **Scope for v1 (deliberate, not oversights):** no default slot / no arbitrary slotted content
70
- * per image (data-driven via `images` only); no dot-style indicators (a textual counter scales
58
+ * per image (data-driven via `images` or `imageSource`); no dot-style indicators (a textual counter scales
71
59
  * better to photo-set sizes); no visual open/close animation (`show()`/`hide()` still expose the
72
60
  * shared before/after lifecycle contract); no
73
61
  * click-on-image-to-navigate (the image is already meaningfully interactive -- it focuses the
@@ -92,7 +80,8 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
92
80
  * @event lr-after-hide - Fired after a successful `hide()`/`close()` has rendered closed.
93
81
  * @event lr-index-change - Fired for `next()`/`previous()`/`goTo()` navigation, including the
94
82
  * built-in button and keyboard paths, and when a shrinking `images` moves the shown image. Not
95
- * fired when a consumer sets `index` directly. `detail: { index }` is always the rendered
83
+ * fired when a consumer sets `index` directly. Source mode uses the complete logical count
84
+ * and emits the requested index before asynchronous image resolution. `detail: { index }` is always the rendered
96
85
  * integer index.
97
86
  * @event lr-zoom-change - Not emitted by `LyraLightbox` itself -- see the interface doc above.
98
87
  * `detail: { zoom }`.
@@ -114,6 +103,9 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
114
103
  * `closable`, a full-screen lightbox has no other built-in chrome, so this is not optional.
115
104
  * @csspart stage - Houses the embedded `<lr-pan-zoom>` plus the floating
116
105
  * `previous-button`/`next-button`.
106
+ * @csspart source-loading - Source-mode loading message.
107
+ * @csspart source-error - Source descriptor or image loading error.
108
+ * @csspart source-retry - Retry the current source image after an error.
117
109
  * @csspart frame - The embedded `<lr-pan-zoom>` element itself.
118
110
  * @csspart frame-viewport - The embedded pan-zoom's scrollable viewport.
119
111
  * @csspart frame-content - The embedded pan-zoom's transformed content wrapper.
@@ -134,13 +126,22 @@ export interface LyraLightboxCloseDetail{reason:LyraLightboxCloseReason;}export
134
126
  export declare class LyraLightbox extends LyraElement<LyraLightboxEventMap>{static styles:import("lit").CSSResultGroup[];private readonly hostDescription;adoptedCallback():void;private _open;
135
127
  /** Whether the lightbox is open. Post-render writes run the same cancelable lifecycle as
136
128
  * `show()`/`hide()`/`close()`; initial markup is state and emits nothing. */
137
- get open():boolean;set open(next:boolean);private _images;private _imagesSource?;private _fit;
129
+ get open():boolean;set open(next:boolean);protected static readonly identityCollectionObjectProperties:readonly string[];private _imageSource?;private navigationIntent;private sourceBindingCurrent;private sourceState;private readonly sourceController;
130
+ /** Optional host-owned full image collection. Takes precedence over images; undefined restores
131
+ * legacy input. Reassign, including the same source, or call requestUpdate() after mutation.
132
+ * Only the current image loads; at most three descriptors are retained. Each key/src/alt/caption
133
+ * is limited to 65,536 UTF-16 units. Invalid defined sources fail closed with a retry action.
134
+ * index remains the requested logical index while its image loads. */
135
+ get imageSource():LyraLightboxSource|undefined;set imageSource(value:LyraLightboxSource|undefined);requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;private imageCount;private _images;private _imagesSource?;private _fit;
138
136
  /** The ordered, bounded, immutable set of images being browsed. Assign a new collection to
139
137
  * update it; malformed records are omitted and at most 10,000 candidates are inspected. */
140
- get images():readonly LyraLightboxImage[];set images(value:readonly LyraLightboxImage[]);
141
- /** The currently displayed image. Clamped defensively for rendering (out-of-range/negative/
142
- * non-integer never throws) and re-synced onto this property when `images` shrinks. */
143
- index:number;
138
+ get images():readonly LyraLightboxImage[];set images(value:readonly LyraLightboxImage[]);private _index;
139
+ /** The current logical image index. Clamped defensively for rendering (out-of-range/negative/
140
+ * non-integer never throws) and re-synced when the active collection shrinks.
141
+ * Source mode retains the requested index while loading.
142
+ * @default 0
143
+ */
144
+ get index():number;set index(value:number);
144
145
  /** Wraps prev/next past the ends. Mirrors `<lr-carousel>`'s `loop` 1:1. */
145
146
  loop:boolean;
146
147
  /** Dismisses the lightbox on a backdrop click. Opt-in and `false` by default -- mirrors
@@ -167,7 +168,7 @@ zoomStep:number;
167
168
  /** Host-level `aria-label` override for the panel's accessible name -- wins over the
168
169
  * localized `lightboxLabel` default. Exactly `<lr-pan-zoom>`'s own `accessibleLabel`
169
170
  * pattern (no other label source to arbitrate against here). */
170
- accessibleLabel:string|null;private readonly slotPresence;private liveText;private frameEl?;private overlay?;private readonly nativeModal;private readonly modalSurface;private announcementSink?;private announcementBaseline?;private connectionGeneration;private transitionGeneration;private openRequestTarget?;private openRequestDuringPreflight?;private readonly captionId;private currentIndex;private syncImages;private changeTo;
171
+ accessibleLabel:string|null;private readonly slotPresence;private liveText;private frameEl?;private overlay?;private readonly nativeModal;private readonly modalSurface;private announcementSink?;private sourceErrorAnnounced;private sourceHasRendered;private lastSourceImage?;private announcementBaseline?;private connectionGeneration;private transitionGeneration;private openRequestTarget?;private openRequestDuringPreflight?;private readonly captionId;private currentIndex;private syncImages;private changeTo;
171
172
  /** Advances to the next image, respecting `loop`. */
172
173
  next():void;
173
174
  /** Moves to the previous image, respecting `loop`. */
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{isAccessibilityVisible,nextId,srOnly}from"../../../internal/a11y.js";import{closeIcon,chevronIcon}from"../../../internal/icons.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount,finiteInteger}from"../../../internal/numbers.js";import{normalizeImageFit}from"../../../internal/image-fit.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{styles}from"./lightbox.styles.js";import"../pan-zoom/pan-zoom.class.js";import{keyEventOwnedByInnerControl}from"../../../internal/hotkey.js";import{LYRA_DEFAULT_lightboxImagePosition,LYRA_DEFAULT_lightboxLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_next,LYRA_DEFAULT_previous}from"../../../internal/default-strings/shared.generated.js";const MAX_LIGHTBOX_IMAGES=1e4,EMPTY_LIGHTBOX_IMAGES=Object.freeze([]);function snapshotLightboxImages(value){try{if(!Array.isArray(value))return EMPTY_LIGHTBOX_IMAGES;const count=Math.min(value.length,MAX_LIGHTBOX_IMAGES),images=[];for(let index=0;index<count;index++)try{const candidate=value[index];if(typeof candidate!="object"||candidate===null)continue;const src=candidate.src;if(typeof src!="string")continue;const alt=candidate.alt,caption=candidate.caption;images.push(Object.freeze({src,...typeof alt=="string"?{alt}:{},...typeof caption=="string"?{caption}:{}}))}catch{}return images.length?Object.freeze(images):EMPTY_LIGHTBOX_IMAGES}catch{return EMPTY_LIGHTBOX_IMAGES}}function queueDocumentMicrotask(ownerDocument,callback){const ownerWindow=ownerDocument.defaultView;if(ownerWindow){ownerWindow.queueMicrotask(callback);return}Promise.resolve().then(callback)}class LyraLightbox extends LyraElement{constructor(){super(...arguments),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector(this.nativeModal.requested?"dialog[data-native-modal-carrier]":'[part="panel"][role="dialog"]')),this._open=!1,this._images=EMPTY_LIGHTBOX_IMAGES,this._fit="actual",this.index=0,this.loop=!1,this.lightDismiss=!1,this.withoutCounter=!1,this.minZoom=.5,this.maxZoom=4,this.zoomStep=.25,this.accessibleLabel=null,this.slotPresence=new SlotPresenceController(this),this.liveText="",this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlay?.isTopmost()&&this.closeFrom("escape",this.renderRoot.querySelector('[part="panel"]')??this)},onUnexpectedClose:()=>{this.hide().then(()=>{this.open&&this.modalSurface.show()})}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal),this.connectionGeneration=0,this.transitionGeneration=0,this.captionId=nextId("lightbox-caption"),this.onBackdropClick=()=>{this.lightDismiss&&this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{const button=this.renderRoot.querySelector('[part="close-button"]')??this;this.closeFrom("close-button",button)},this.onPanelKeyDown=event=>{for(const target of event.composedPath()){if(target===this)break;if(target instanceof Element&&target.getRootNode()!==this.shadowRoot&&target.matches('a[href], button, [role="button"], [role="link"]'))return}if(keyEventOwnedByInnerControl(event,{container:this,ownerTag:"lr-pan-zoom"}))return;const rtl=this.effectiveDirection==="rtl",forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";event.key===forwardKey?(event.preventDefault(),this.next()):event.key===backwardKey?(event.preventDefault(),this.previous()):event.key==="Home"?(event.preventDefault(),this.goTo(0)):event.key==="End"&&(event.preventDefault(),this.goTo(this.images.length-1))}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,lightboxImagePosition:LYRA_DEFAULT_lightboxImagePosition,lightboxLabel:LYRA_DEFAULT_lightboxLabel,next:LYRA_DEFAULT_next,previous:LYRA_DEFAULT_previous}}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,srOnly,styles]}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}get open(){return this._open}set open(next){const normalized=!!next;if(!this.coalesceOpenRequest(normalized)&&normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.close("api")}}get images(){return this._images}set images(value){if(value===this._imagesSource||value===this._images)return;this._imagesSource=value;const old=this._images;this._images=snapshotLightboxImages(value),this.requestUpdate("images",old)}get fit(){return this._fit}set fit(value){const old=this._fit;this._fit=normalizeImageFit(value,"actual"),this.requestUpdate("fit",old)}currentIndex(){const count=this.images.length;return count===0?0:finiteCount(this.index,0,count-1)}syncImages(){const current=this.currentIndex();this.index!==current&&(this.index=current)}changeTo(index){const count=this.images.length;if(count===0||!Number.isFinite(index))return;const requested=finiteInteger(index,0),next=this.loop?(requested%count+count)%count:Math.min(count-1,Math.max(0,requested));next!==this.currentIndex()&&(this.index=next,this.emit("lr-index-change",{index:next}))}next(){this.changeTo(this.currentIndex()+1)}previous(){this.changeTo(this.currentIndex()-1)}goTo(index){this.changeTo(index)}async show(){if(this.coalesceOpenRequest(!0)||this._open)return;this.beginOpenRequest(!0);const prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,superseded=this.openRequestWasSuperseded(!0);if(this.finishOpenRequest(),prevented||superseded){this.syncOpenAttribute();return}this.applyOpenState(!0);const generation=++this.transitionGeneration;await this.updateComplete,generation===this.transitionGeneration&&this._open&&this.emit("lr-after-show",null)}hide(){return this.close("api")}async close(reason="api"){return this.closeFrom(reason,this)}async closeFrom(reason,source){if(this.coalesceOpenRequest(!1)||!this._open)return;if(this.beginOpenRequest(!1),this.emit("lr-hide",{source},{cancelable:!0}).defaultPrevented||this.openRequestWasSuperseded(!1)){this.finishOpenRequest(),this.syncOpenAttribute();return}if(this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented||this.openRequestWasSuperseded(!1)){this.finishOpenRequest(),this.syncOpenAttribute();return}this.finishOpenRequest(),this.applyOpenState(!1);const generation=++this.transitionGeneration;this.emit("lr-close",{reason}),await this.updateComplete,generation===this.transitionGeneration&&!this._open&&this.emit("lr-after-hide",null)}coalesceOpenRequest(next){return this.openRequestTarget===void 0?!1:(this.openRequestDuringPreflight=next,!0)}beginOpenRequest(next){this.openRequestTarget=next,this.openRequestDuringPreflight=void 0}openRequestWasSuperseded(next){return this.openRequestDuringPreflight!==void 0&&this.openRequestDuringPreflight!==next}finishOpenRequest(){this.openRequestTarget=void 0,this.openRequestDuringPreflight=void 0}applyOpenState(next){const old=this._open;this._open=next,this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}updateLiveRegion(){const count=this.images.length,formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1});this.liveText=count===0?"":this.localize("lightboxImagePosition",void 0,{index:formatter.format(this.currentIndex()+1),total:formatter.format(count)})}captureAnnouncementBaseline(){this.announcementBaseline={index:this.currentIndex(),images:this.images}}willUpdate(changed){if(super.willUpdate(changed),changed.has("images")||changed.has("index")){const index=changed.has("index")?void 0:this.index;this.syncImages(),index!==void 0&&this.index!==index&&this.emit("lr-index-change",{index:this.index})}if((changed.has("index")||changed.has("images")||changed.has("strings")||changed.has("locale"))&&this.updateLiveRegion(),changed.has("open"))if(this.open)this.modalSurface.open(()=>this.activateOverlay());else{const hadOverlay=this.overlay!==void 0;this.modalSurface.close(hadOverlay,()=>this.deactivateOverlay(),()=>!this.open)}}updated(changed){super.updated(changed),!(this.announcementBaseline?.index===this.currentIndex()&&this.announcementBaseline.images===this.images)&&this.open&&this.liveText!==""&&isAccessibilityVisible(this)&&(changed.has("index")||changed.has("images"))&&this.announcementSink?.announce(this.liveText),this.isConnected&&this.captureAnnouncementBaseline(),changed.has("open")&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial());let currentSourceChanged=!1;if(changed.has("images")){const previousImages=changed.get("images"),previousIndex=changed.has("index")?changed.get("index")??0:this.index;currentSourceChanged=previousImages?.[previousImages.length>0?finiteCount(previousIndex,0,previousImages.length-1):0]?.src!==this.images[this.currentIndex()]?.src}this.open&&(changed.has("index")||currentSourceChanged)&&this.frameEl?.resetView()}connectedCallback(){super.connectedCallback();const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.announcementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.captureAnnouncementBaseline(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&this.isConnected&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.announcementSink?.release(),this.announcementSink=void 0,this.announcementBaseline=void 0,super.disconnectedCallback(),this.modalSurface.disconnect(),this.overlay?.suspend(),this.open&&queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&!this.isConnected&&this.open&&(this.transitionGeneration++,this.emit("lr-hide",{source:this}),this.applyOpenState(!1),this.emit("lr-close",{reason:"unmount"}),this.emit("lr-after-hide",null))})}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>{const panel=this.renderRoot.querySelector('[part="panel"]')??this;this.closeFrom("escape",panel)},onBackdrop:()=>{const backdrop=this.renderRoot.querySelector('[part="backdrop"]')??this;this.closeFrom("backdrop",backdrop)},preferredInitialFocus:()=>this.shadowRoot?.querySelector('[part="close-button"]')??null,lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}render(){const count=this.images.length,current=this.currentIndex(),image=count>0?this.images[current]:void 0,label=this.accessibleLabel??this.localize("lightboxLabel"),hasCaption=!!image?.caption,formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1}),positionText=count>0?this.localize("lightboxImagePosition",void 0,{index:formatter.format(current+1),total:formatter.format(count)}):"";return this.nativeModal.render(html`
1
+ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{live}from"lit/directives/live.js";import{property,query,state}from"lit/decorators.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{isAccessibilityVisible,nextId,srOnly}from"../../../internal/a11y.js";import{closeIcon,chevronIcon}from"../../../internal/icons.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount,finiteInteger}from"../../../internal/numbers.js";import{normalizeImageFit}from"../../../internal/image-fit.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{styles}from"./lightbox.styles.js";import{LightboxSourceController}from"./lightbox-source.js";import"../pan-zoom/pan-zoom.class.js";import{keyEventOwnedByInnerControl}from"../../../internal/hotkey.js";import{LYRA_DEFAULT_imageViewerFailedToLoad,LYRA_DEFAULT_lightboxImagePosition,LYRA_DEFAULT_lightboxLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_previous,LYRA_DEFAULT_retry}from"../../../internal/default-strings/shared.generated.js";const MAX_LIGHTBOX_IMAGES=1e4,EMPTY_LIGHTBOX_IMAGES=Object.freeze([]);function snapshotLightboxImages(value){try{if(!Array.isArray(value))return EMPTY_LIGHTBOX_IMAGES;const count=Math.min(value.length,MAX_LIGHTBOX_IMAGES),images=[];for(let index=0;index<count;index++)try{const candidate=value[index];if(typeof candidate!="object"||candidate===null)continue;const src=candidate.src;if(typeof src!="string")continue;const alt=candidate.alt,caption=candidate.caption;images.push(Object.freeze({src,...typeof alt=="string"?{alt}:{},...typeof caption=="string"?{caption}:{}}))}catch{}return images.length?Object.freeze(images):EMPTY_LIGHTBOX_IMAGES}catch{return EMPTY_LIGHTBOX_IMAGES}}function queueDocumentMicrotask(ownerDocument,callback){const ownerWindow=ownerDocument.defaultView;if(ownerWindow){ownerWindow.queueMicrotask(callback);return}Promise.resolve().then(callback)}class LyraLightbox extends LyraElement{constructor(){super(...arguments),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector(this.nativeModal.requested?"dialog[data-native-modal-carrier]":'[part="panel"][role="dialog"]')),this._open=!1,this.navigationIntent=0,this.sourceBindingCurrent=!0,this.sourceState=0,this.sourceController=new LightboxSourceController(this,()=>{this.sourceState++}),this._images=EMPTY_LIGHTBOX_IMAGES,this._fit="actual",this._index=0,this.loop=!1,this.lightDismiss=!1,this.withoutCounter=!1,this.minZoom=.5,this.maxZoom=4,this.zoomStep=.25,this.accessibleLabel=null,this.slotPresence=new SlotPresenceController(this),this.liveText="",this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{this.overlay?.isTopmost()&&this.closeFrom("escape",this.renderRoot.querySelector('[part="panel"]')??this)},onUnexpectedClose:()=>{this.hide().then(()=>{this.open&&this.modalSurface.show()})}}),this.modalSurface=new ModalSurfaceController(this,this.nativeModal),this.sourceErrorAnnounced=!1,this.sourceHasRendered=!1,this.connectionGeneration=0,this.transitionGeneration=0,this.captionId=nextId("lightbox-caption"),this.onBackdropClick=()=>{this.lightDismiss&&this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{const button=this.renderRoot.querySelector('[part="close-button"]')??this;this.closeFrom("close-button",button)},this.onPanelKeyDown=event=>{for(const target of event.composedPath()){if(target===this)break;if(target instanceof Element&&target.getRootNode()!==this.shadowRoot&&target.matches('a[href], button, [role="button"], [role="link"]'))return}if(keyEventOwnedByInnerControl(event,{container:this,ownerTag:"lr-pan-zoom"}))return;const rtl=this.effectiveDirection==="rtl",forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";event.key===forwardKey?(event.preventDefault(),this.next()):event.key===backwardKey?(event.preventDefault(),this.previous()):event.key==="Home"?(event.preventDefault(),this.goTo(0)):event.key==="End"&&(event.preventDefault(),this.goTo(this.imageCount()-1))}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,imageViewerFailedToLoad:LYRA_DEFAULT_imageViewerFailedToLoad,lightboxImagePosition:LYRA_DEFAULT_lightboxImagePosition,lightboxLabel:LYRA_DEFAULT_lightboxLabel,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,previous:LYRA_DEFAULT_previous,retry:LYRA_DEFAULT_retry}}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,srOnly,styles]}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.sourceController.adopted()}get open(){return this._open}set open(next){const normalized=!!next;if(!this.coalesceOpenRequest(normalized)&&normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.close("api")}}static{this.identityCollectionObjectProperties=Object.freeze(["imageSource"])}get imageSource(){return this._imageSource}set imageSource(value){const previous=this._imageSource;this.navigationIntent++,this.sourceBindingCurrent=!1,this._imageSource=value,this.sourceController?.refresh(),this.frameEl&&(this.frameEl.src=""),this.requestUpdate("imageSource",previous)}requestUpdate(...args){args[0]===void 0&&this._imageSource!==void 0&&(this.navigationIntent++,this.sourceBindingCurrent=!1,this.sourceController?.refresh(),this.frameEl&&(this.frameEl.src="")),super.requestUpdate(...args)}imageCount(){return this.imageSource===void 0?this.images.length:this.sourceController.count}get images(){return this._images}set images(value){if(value===this._imagesSource||value===this._images)return;this._imagesSource=value;const old=this._images;this._images=snapshotLightboxImages(value),this.requestUpdate("images",old)}get index(){return this._index}set index(value){this.navigationIntent++;const previous=this._index;this._index=value,value!==previous&&this.imageSource!==void 0&&(this.sourceController?.select(this.currentIndex()),this.frameEl&&(this.frameEl.src="")),this.requestUpdate("index",previous)}get fit(){return this._fit}set fit(value){const old=this._fit;this._fit=normalizeImageFit(value,"actual"),this.requestUpdate("fit",old)}currentIndex(){const count=this.imageCount();return count===0?0:finiteCount(this.index,0,count-1)}syncImages(){const current=this.currentIndex();this.index!==current&&(this.index=current)}changeTo(index){const count=this.imageCount();if(count===0||!Number.isFinite(index))return;const requested=finiteInteger(index,0),next=this.loop?(requested%count+count)%count:Math.min(count-1,Math.max(0,requested));if(next===this.currentIndex())return;const intent=this.navigationIntent+1;this.index=next,this.navigationIntent===intent&&this.emit("lr-index-change",{index:next})}next(){this.changeTo(this.currentIndex()+1)}previous(){this.changeTo(this.currentIndex()-1)}goTo(index){this.changeTo(index)}async show(){if(this.coalesceOpenRequest(!0)||this._open)return;this.beginOpenRequest(!0);const prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,superseded=this.openRequestWasSuperseded(!0);if(this.finishOpenRequest(),prevented||superseded){this.syncOpenAttribute();return}this.applyOpenState(!0);const generation=++this.transitionGeneration;await this.updateComplete,generation===this.transitionGeneration&&this._open&&this.emit("lr-after-show",null)}hide(){return this.close("api")}async close(reason="api"){return this.closeFrom(reason,this)}async closeFrom(reason,source){if(this.coalesceOpenRequest(!1)||!this._open)return;if(this.beginOpenRequest(!1),this.emit("lr-hide",{source},{cancelable:!0}).defaultPrevented||this.openRequestWasSuperseded(!1)){this.finishOpenRequest(),this.syncOpenAttribute();return}if(this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented||this.openRequestWasSuperseded(!1)){this.finishOpenRequest(),this.syncOpenAttribute();return}this.finishOpenRequest(),this.applyOpenState(!1);const generation=++this.transitionGeneration;this.emit("lr-close",{reason}),await this.updateComplete,generation===this.transitionGeneration&&!this._open&&this.emit("lr-after-hide",null)}coalesceOpenRequest(next){return this.openRequestTarget===void 0?!1:(this.openRequestDuringPreflight=next,!0)}beginOpenRequest(next){this.openRequestTarget=next,this.openRequestDuringPreflight=void 0}openRequestWasSuperseded(next){return this.openRequestDuringPreflight!==void 0&&this.openRequestDuringPreflight!==next}finishOpenRequest(){this.openRequestTarget=void 0,this.openRequestDuringPreflight=void 0}applyOpenState(next){const old=this._open;this._open=next,this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}updateLiveRegion(){const count=this.imageCount(),formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1});this.liveText=count===0?"":this.localize("lightboxImagePosition",void 0,{index:formatter.format(this.currentIndex()+1),total:formatter.format(count)})}captureAnnouncementBaseline(){this.announcementBaseline={index:this.currentIndex(),images:this.images,source:this.imageSource}}willUpdate(changed){if(super.willUpdate(changed),this.sourceBindingCurrent=this.sourceController.update(this.imageSource,this.effectiveLocale),this.sourceBindingCurrent&&(changed.has("images")||changed.has("index")||changed.has("imageSource")||changed.has("sourceState"))){const index=changed.has("index")?void 0:this.index,intent=this.navigationIntent+1;this.syncImages(),index!==void 0&&this.index!==index&&this.navigationIntent===intent&&this.sourceBindingCurrent&&this.emit("lr-index-change",{index:this.index})}if(this.sourceBindingCurrent&&this.imageSource!==void 0&&this.sourceController.select(this.currentIndex()),this.sourceBindingCurrent||queueDocumentMicrotask(this.ownerDocument,()=>{this.isConnected&&this.sourceState++}),this.sourceBindingCurrent&&(changed.has("index")||changed.has("images")||changed.has("imageSource")||changed.has("sourceState")||changed.has("strings")||changed.has("locale"))&&this.updateLiveRegion(),changed.has("open"))if(this.open)this.modalSurface.open(()=>this.activateOverlay());else{const hadOverlay=this.overlay!==void 0;this.modalSurface.close(hadOverlay,()=>this.deactivateOverlay(),()=>!this.open)}}updated(changed){super.updated(changed),!(this.announcementBaseline?.index===this.currentIndex()&&this.announcementBaseline.images===this.images&&this.announcementBaseline.source===this.imageSource)&&this.sourceBindingCurrent&&this.open&&this.liveText!==""&&isAccessibilityVisible(this)&&(changed.has("index")||changed.has("images")||changed.has("imageSource"))&&this.announcementSink?.announce(this.liveText);const sourceError=this.sourceBindingCurrent&&this.imageSource!==void 0&&this.sourceController.state==="error";sourceError||(this.sourceErrorAnnounced=!1),sourceError&&!this.sourceErrorAnnounced&&this.sourceHasRendered&&this.open&&isAccessibilityVisible(this)&&(this.sourceErrorAnnounced=!0,this.announcementSink?.announce(this.localize("imageViewerFailedToLoad"))),this.sourceHasRendered=!0,this.isConnected&&this.sourceBindingCurrent&&this.captureAnnouncementBaseline(),changed.has("open")&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial());let currentSourceChanged=!1;if(changed.has("images")){const previousImages=changed.get("images"),previousIndex=changed.has("index")?changed.get("index")??0:this.index;currentSourceChanged=previousImages?.[previousImages.length>0?finiteCount(previousIndex,0,previousImages.length-1):0]?.src!==this.images[this.currentIndex()]?.src}const sourceImage=this.imageSource===void 0?void 0:this.sourceController.image;currentSourceChanged||=changed.has("imageSource")||sourceImage!==void 0&&sourceImage!==this.lastSourceImage,this.lastSourceImage=sourceImage,this.open&&(changed.has("index")||currentSourceChanged)&&this.frameEl?.resetView()}connectedCallback(){super.connectedCallback();const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.announcementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.captureAnnouncementBaseline(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&this.isConnected&&this.open&&(this.modalSurface.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){const generation=++this.connectionGeneration,connectionDocument=this.ownerDocument;this.announcementSink?.release(),this.announcementSink=void 0,this.announcementBaseline=void 0,this.sourceErrorAnnounced=!1,this.sourceHasRendered=!1,this.lastSourceImage=void 0,super.disconnectedCallback(),this.modalSurface.disconnect(),this.overlay?.suspend(),this.open&&queueDocumentMicrotask(connectionDocument,()=>{this.connectionGeneration===generation&&this.ownerDocument===connectionDocument&&!this.isConnected&&this.open&&(this.transitionGeneration++,this.emit("lr-hide",{source:this}),this.applyOpenState(!1),this.emit("lr-close",{reason:"unmount"}),this.emit("lr-after-hide",null))})}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>{const panel=this.renderRoot.querySelector('[part="panel"]')??this;this.closeFrom("escape",panel)},onBackdrop:()=>{const backdrop=this.renderRoot.querySelector('[part="backdrop"]')??this;this.closeFrom("backdrop",backdrop)},preferredInitialFocus:()=>this.shadowRoot?.querySelector('[part="close-button"]')??null,lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}render(){const count=this.imageCount(),current=this.currentIndex(),image=this.imageSource===void 0?count>0?this.images[current]:void 0:this.sourceController.image,sourceState=this.imageSource===void 0?void 0:this.sourceController.state,label=this.accessibleLabel??this.localize("lightboxLabel"),hasCaption=!!image?.caption,formatter=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0,useGrouping:!1}),positionText=count>0?this.localize("lightboxImagePosition",void 0,{index:formatter.format(current+1),total:formatter.format(count)}):"";return this.nativeModal.render(html`
2
2
  <div part="backdrop" @click=${this.onBackdropClick}></div>
3
3
  <div
4
4
  part="panel"
@@ -18,7 +18,9 @@ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/n
18
18
  ${closeIcon()}
19
19
  </button>
20
20
  </div>
21
- <div part="stage">
21
+ <div part="stage" aria-busy=${sourceState==="loading"?"true":"false"}>
22
+ ${sourceState==="loading"?html`<p part="source-loading">${this.localize("loading")}</p>`:nothing}
23
+ ${sourceState==="error"?html`<div part="source-error">${this.localize("imageViewerFailedToLoad")}<button part="source-retry" type="button" @click=${()=>this.sourceController.retry(this.currentIndex())}>${this.localize("retry")}</button></div>`:nothing}
22
24
  ${count>1?html`
23
25
  <button
24
26
  part="previous-button"
@@ -33,7 +35,7 @@ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/n
33
35
  <lr-pan-zoom
34
36
  part="frame"
35
37
  exportparts="viewport:frame-viewport,content:frame-content,controls:frame-controls"
36
- src=${image?.src??""}
38
+ .src=${live(image?.src??"")}
37
39
  alt=${image?.alt??""}
38
40
  .fit=${this.fit}
39
41
  .minZoom=${this.minZoom}
@@ -61,4 +63,4 @@ import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/n
61
63
  >
62
64
  ${this.nativeModal.renderHelperSlot()}
63
65
  </div>
64
- `,{label,describedBy:hasCaption?this.captionId:null})}}__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"open",null),__decorate([property({attribute:!1})],LyraLightbox.prototype,"images",null),__decorate([property({type:Number,reflect:!0})],LyraLightbox.prototype,"index",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"loop",void 0),__decorate([property({type:Boolean,attribute:"light-dismiss"})],LyraLightbox.prototype,"lightDismiss",void 0),__decorate([property({type:Boolean,attribute:"without-counter"})],LyraLightbox.prototype,"withoutCounter",void 0),__decorate([property({reflect:!0})],LyraLightbox.prototype,"fit",null),__decorate([property({type:Number,attribute:"min-zoom"})],LyraLightbox.prototype,"minZoom",void 0),__decorate([property({type:Number,attribute:"max-zoom"})],LyraLightbox.prototype,"maxZoom",void 0),__decorate([property({type:Number,attribute:"zoom-step"})],LyraLightbox.prototype,"zoomStep",void 0),__decorate([property({attribute:"aria-label"})],LyraLightbox.prototype,"accessibleLabel",void 0),__decorate([state()],LyraLightbox.prototype,"liveText",void 0),__decorate([query("lr-pan-zoom")],LyraLightbox.prototype,"frameEl",void 0);export{LyraLightbox};
66
+ `,{label,describedBy:hasCaption?this.captionId:null})}}__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"open",null),__decorate([state()],LyraLightbox.prototype,"sourceState",void 0),__decorate([property({attribute:!1,noAccessor:!0,hasChanged:()=>!0})],LyraLightbox.prototype,"imageSource",null),__decorate([property({attribute:!1})],LyraLightbox.prototype,"images",null),__decorate([property({type:Number,reflect:!0,noAccessor:!0})],LyraLightbox.prototype,"index",null),__decorate([property({type:Boolean,reflect:!0})],LyraLightbox.prototype,"loop",void 0),__decorate([property({type:Boolean,attribute:"light-dismiss"})],LyraLightbox.prototype,"lightDismiss",void 0),__decorate([property({type:Boolean,attribute:"without-counter"})],LyraLightbox.prototype,"withoutCounter",void 0),__decorate([property({reflect:!0})],LyraLightbox.prototype,"fit",null),__decorate([property({type:Number,attribute:"min-zoom"})],LyraLightbox.prototype,"minZoom",void 0),__decorate([property({type:Number,attribute:"max-zoom"})],LyraLightbox.prototype,"maxZoom",void 0),__decorate([property({type:Number,attribute:"zoom-step"})],LyraLightbox.prototype,"zoomStep",void 0),__decorate([property({attribute:"aria-label"})],LyraLightbox.prototype,"accessibleLabel",void 0),__decorate([state()],LyraLightbox.prototype,"liveText",void 0),__decorate([query("lr-pan-zoom")],LyraLightbox.prototype,"frameEl",void 0);export{LyraLightbox};
@@ -1 +1 @@
1
- import{iconHitTarget}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{modalHostStyles}from"../../../internal/native-modal-carrier.styles.js";import{compactContainerQuery}from"../../../internal/container-breakpoints.styles.js";const styles=css` :host { --_lr-lightbox-overlay-color: var(--lr-color-overlay-strong); --_lr-lightbox-control-bg: var(--lr-color-neutral); --_lr-lightbox-control-color: var(--lr-color-on-neutral); ${modalHostStyles} max-inline-size: none; max-block-size: none; container-type: inline-size; contain-intrinsic-inline-size: var(--lr-size-20rem); padding-block-start: max(var(--lr-space-l), var(--lr-safe-area-top)); padding-block-end: max(var(--lr-space-l), var(--lr-safe-area-bottom)); padding-inline-start: max( var(--lr-space-l), var(--lr-safe-area-inline-start) ); padding-inline-end: max(var(--lr-space-l), var(--lr-safe-area-inline-end)); } :host([open]) { display: flex; } [part="backdrop"] { position: absolute; inset: 0; background: var( --lr-lightbox-overlay-color, var(--_lr-lightbox-overlay-color) ); } [part="panel"] { position: relative; display: flex; flex-direction: column; gap: var(--lr-space-s); inline-size: 100%; block-size: 100%; min-inline-size: 0; min-block-size: 0; outline: none; } [part="toolbar"] { display: flex; align-items: center; flex: 0 0 auto; flex-wrap: wrap; gap: var(--lr-space-s); } [part="counter"] { display: inline-block; min-inline-size: 0; max-inline-size: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: var(--lr-space-xs) var(--lr-space-s); border-radius: var(--lr-radius); background: var(--lr-lightbox-control-bg, var(--_lr-lightbox-control-bg)); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); font-size: var(--lr-font-size-sm); } [part="actions"] { display: flex; align-items: center; flex: 1 1 0; flex-wrap: wrap; justify-content: flex-end; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-xs); margin-inline-start: auto; } slot[name="actions"]::slotted(*) { box-sizing: border-box; min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; } [part="actions"][hidden] { display: none; } [part="close-button"], [part="previous-button"], [part="next-button"] { font: inherit; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; ${iconHitTarget} border: none; border-radius: var(--lr-radius-pill); background: var(--lr-lightbox-control-bg, var(--_lr-lightbox-control-bg)); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); cursor: pointer; transition: background-color var(--lr-transition-fast), color var(--lr-transition-fast); } [part="close-button"] { margin-inline-start: var(--lr-space-xs); } :where([part="close-button"]):hover, :where([part="previous-button"]):hover:where(:not(:disabled)), :where([part="next-button"]):hover:where(:not(:disabled)) { background: var(--lr-color-brand-quiet); color: var(--lr-color-brand); } :where([part="close-button"]):active, :where([part="previous-button"]):active:where(:not(:disabled)), :where([part="next-button"]):active:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); color: var(--lr-color-brand); } [part="close-button"]:focus-visible, [part="previous-button"]:focus-visible, [part="next-button"]:focus-visible { outline: var(--lr-focus-ring); outline-offset: var(--lr-focus-ring-offset); } [part="previous-button"]:disabled, [part="next-button"]:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="close-button"] svg, [part="previous-glyph"], [part="next-glyph"] { display: block; } [part="stage"] { position: relative; flex: 1 1 auto; min-inline-size: 0; min-block-size: 0; } lr-pan-zoom[part="frame"] { display: block; inline-size: 100%; block-size: 100%; } lr-pan-zoom[part="frame"]::part(base) { block-size: 100%; } lr-pan-zoom[part="frame"]::part(viewport) { block-size: 100%; } [part="previous-button"], [part="next-button"] { position: absolute; inset-block-start: 50%; transform: translateY(-50%); z-index: var(--lr-layer-content); } [part="previous-button"] { inset-inline-start: var(--lr-space-s); } [part="next-button"] { inset-inline-end: var(--lr-space-s); } [part="previous-glyph"] { transform: rotate(180deg); } [part="next-glyph"] { transform: rotate(0deg); } :host(:dir(rtl)) [part="previous-glyph"] { transform: rotate(0deg); } :host(:dir(rtl)) [part="next-glyph"] { transform: rotate(180deg); } [part="caption"] { flex: 0 0 auto; margin: 0; max-inline-size: 100%; max-block-size: var(--lr-size-8rem); overflow-x: hidden; overflow-y: auto; align-self: center; padding: var(--lr-space-xs) var(--lr-space-s); border-radius: var(--lr-radius); background: var(--lr-lightbox-control-bg, var(--_lr-lightbox-control-bg)); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); text-align: center; overflow-wrap: anywhere; } @container ${compactContainerQuery} { [part="counter"] { max-inline-size: 45%; } } `;export{styles};
1
+ import{iconHitTarget}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{modalHostStyles}from"../../../internal/native-modal-carrier.styles.js";import{compactContainerQuery}from"../../../internal/container-breakpoints.styles.js";const styles=css` :host { --_lr-lightbox-overlay-color: var(--lr-color-overlay-strong); --_lr-lightbox-control-bg: var(--lr-color-neutral); --_lr-lightbox-control-color: var(--lr-color-on-neutral); ${modalHostStyles} max-inline-size: none; max-block-size: none; container-type: inline-size; contain-intrinsic-inline-size: var(--lr-size-20rem); padding-block-start: max(var(--lr-space-l), var(--lr-safe-area-top)); padding-block-end: max(var(--lr-space-l), var(--lr-safe-area-bottom)); padding-inline-start: max( var(--lr-space-l), var(--lr-safe-area-inline-start) ); padding-inline-end: max(var(--lr-space-l), var(--lr-safe-area-inline-end)); } :host([open]) { display: flex; } [part="backdrop"] { position: absolute; inset: 0; background: var( --lr-lightbox-overlay-color, var(--_lr-lightbox-overlay-color) ); } [part="panel"] { position: relative; display: flex; flex-direction: column; gap: var(--lr-space-s); inline-size: 100%; block-size: 100%; min-inline-size: 0; min-block-size: 0; outline: none; } [part="toolbar"] { display: flex; align-items: center; flex: 0 0 auto; flex-wrap: wrap; gap: var(--lr-space-s); } [part="counter"] { display: inline-block; min-inline-size: 0; max-inline-size: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: var(--lr-space-xs) var(--lr-space-s); border-radius: var(--lr-radius); background: var(--lr-lightbox-control-bg, var(--_lr-lightbox-control-bg)); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); font-size: var(--lr-font-size-sm); } [part="actions"] { display: flex; align-items: center; flex: 1 1 0; flex-wrap: wrap; justify-content: flex-end; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-xs); margin-inline-start: auto; } slot[name="actions"]::slotted(*) { box-sizing: border-box; min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; } [part="actions"][hidden] { display: none; } [part="source-retry"], [part="close-button"], [part="previous-button"], [part="next-button"] { font: inherit; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; ${iconHitTarget} border: none; border-radius: var(--lr-radius-pill); background: var(--lr-lightbox-control-bg, var(--_lr-lightbox-control-bg)); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); cursor: pointer; transition: background-color var(--lr-transition-fast), color var(--lr-transition-fast); } [part="close-button"] { margin-inline-start: var(--lr-space-xs); } :where([part="source-retry"]):hover, :where([part="close-button"]):hover, :where([part="previous-button"]):hover:where(:not(:disabled)), :where([part="next-button"]):hover:where(:not(:disabled)) { background: var(--lr-color-brand-quiet); color: var(--lr-color-brand); } :where([part="source-retry"]):active, :where([part="close-button"]):active, :where([part="previous-button"]):active:where(:not(:disabled)), :where([part="next-button"]):active:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); color: var(--lr-color-brand); } [part="source-retry"]:focus-visible, [part="close-button"]:focus-visible, [part="previous-button"]:focus-visible, [part="next-button"]:focus-visible { outline: var(--lr-focus-ring); outline-offset: var(--lr-focus-ring-offset); } [part="previous-button"]:disabled, [part="next-button"]:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="close-button"] svg, [part="previous-glyph"], [part="next-glyph"] { display: block; } [part="source-loading"], [part="source-error"] { position: absolute; inset: var(--lr-space-l); z-index: var(--lr-layer-content); display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--lr-space-s); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); overflow-wrap: anywhere; } [part="source-retry"] { padding-inline: var(--lr-space-s); } [part="stage"] { position: relative; flex: 1 1 auto; min-inline-size: 0; min-block-size: 0; } lr-pan-zoom[part="frame"] { display: block; inline-size: 100%; block-size: 100%; } lr-pan-zoom[part="frame"]::part(base) { block-size: 100%; } lr-pan-zoom[part="frame"]::part(viewport) { block-size: 100%; } [part="previous-button"], [part="next-button"] { position: absolute; inset-block-start: 50%; transform: translateY(-50%); z-index: var(--lr-layer-content); } [part="previous-button"] { inset-inline-start: var(--lr-space-s); } [part="next-button"] { inset-inline-end: var(--lr-space-s); } [part="previous-glyph"] { transform: rotate(180deg); } [part="next-glyph"] { transform: rotate(0deg); } :host(:dir(rtl)) [part="previous-glyph"] { transform: rotate(0deg); } :host(:dir(rtl)) [part="next-glyph"] { transform: rotate(180deg); } [part="caption"] { flex: 0 0 auto; margin: 0; max-inline-size: 100%; max-block-size: var(--lr-size-8rem); overflow-x: hidden; overflow-y: auto; align-self: center; padding: var(--lr-space-xs) var(--lr-space-s); border-radius: var(--lr-radius); background: var(--lr-lightbox-control-bg, var(--_lr-lightbox-control-bg)); color: var(--lr-lightbox-control-color, var(--_lr-lightbox-control-color)); text-align: center; overflow-wrap: anywhere; } @container ${compactContainerQuery} { [part="counter"] { max-inline-size: 45%; } } `;export{styles};
@@ -2,14 +2,14 @@ import type{Feature}from'geojson';import type{MapLibreGeoJsonDiff}from'./map-loa
2
2
  /** Own enumerable data descriptors copied in source order; values stay opaque identities. */
3
3
  readonly properties:ReadonlyMap<string,unknown>;}interface CanonicalGeoJsonFeature extends CanonicalGeoJsonDiagnosticFeature{readonly id:string|number;
4
4
  /** The peer-facing feature identity; no component code reads it after this projection. */
5
- readonly feature:Feature;readonly geometry:unknown;readonly bbox:unknown;}interface CanonicalGeoJsonCollection{readonly ordered:readonly CanonicalGeoJsonFeature[];readonly byId:ReadonlyMap<string|number,CanonicalGeoJsonFeature>;}
5
+ readonly feature:Feature;readonly geometry:unknown;readonly bbox:unknown;readonly geometryIdentity:unknown;readonly bboxIdentity:unknown;}interface CanonicalGeoJsonCollection{readonly ordered:readonly CanonicalGeoJsonFeature[];readonly byId:ReadonlyMap<string|number,CanonicalGeoJsonFeature>;}
6
6
  /** Descriptor metadata used internally; the original GeoJSON value remains peer-facing only. */
7
7
  export interface CanonicalGeoJsonProjection{readonly diagnostics:readonly CanonicalGeoJsonDiagnosticFeature[];readonly collection:CanonicalGeoJsonCollection|undefined;}
8
8
  /**
9
- * Captures only the bounded descriptor metadata this component subsequently needs. The original
10
- * GeoJSON value is deliberately absent from the result: callers retain it solely for MapLibre.
9
+ * Captures bounded descriptor metadata and comparable geometry snapshots. Raw geometry/bbox
10
+ * identities are retained only for identity checks; caller data is never read through accessors.
11
11
  */
12
- export declare function projectGeoJson(value:unknown):CanonicalGeoJsonProjection;
12
+ export declare function projectGeoJson(value:unknown,comparableValues?:WeakMap<object,unknown>):CanonicalGeoJsonProjection;
13
13
  /**
14
14
  * Builds a maplibre-gl `updateData()` diff when stable feature ids make the change addressable,
15
15
  * and returns `null` otherwise so the caller replaces the whole source instead. Property changes,
@@ -30,5 +30,5 @@ export declare function projectGeoJson(value:unknown):CanonicalGeoJsonProjection
30
30
  * therefore remain minimal, while a reorder changes only the suffix it invalidated.
31
31
  */
32
32
  export declare function buildProjectedGeoJsonPropertyDiff(previous:CanonicalGeoJsonProjection,next:CanonicalGeoJsonProjection):MapLibreGeoJsonDiff|null;
33
- /** Admitted GeoJSON is never inspected again, so one projection per object suffices. */
34
- export declare function projectAdmittedGeoJson(value:unknown):CanonicalGeoJsonProjection;export declare function buildGeoJsonPropertyDiff(previous:unknown,next:unknown):MapLibreGeoJsonDiff|null;export{};
33
+ /** Reuse admitted immutable GeoJSON, or reproject it after an explicit mutable-source refresh. */
34
+ export declare function projectAdmittedGeoJson(value:unknown,refresh?:boolean):CanonicalGeoJsonProjection;export declare function buildGeoJsonPropertyDiff(previous:unknown,next:unknown):MapLibreGeoJsonDiff|null;export{};