@aceshooting/lyra-ui 10.0.1 → 11.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 (83) hide show
  1. package/CHANGELOG.md +271 -0
  2. package/custom-elements.json +1 -1
  3. package/design-tokens.json +13 -0
  4. package/dist/cli/migrate-wa.mjs +164 -1
  5. package/dist/cli/migration-contract.json +1 -1
  6. package/dist/components/charts/chart/box-plot.class.d.ts +27 -0
  7. package/dist/components/charts/chart/box-plot.class.js +14 -4
  8. package/dist/components/charts/chart/box-plot.styles.js +28 -0
  9. package/dist/components/charts/chart/chart.class.d.ts +27 -0
  10. package/dist/components/charts/chart/chart.class.js +15 -5
  11. package/dist/components/charts/chart/chart.styles.js +28 -0
  12. package/dist/components/charts/chart/lite-chart.class.d.ts +32 -0
  13. package/dist/components/charts/chart/lite-chart.class.js +17 -4
  14. package/dist/components/charts/chart/lite-chart.styles.js +29 -0
  15. package/dist/components/data/heatmap/heatmap.class.d.ts +35 -2
  16. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  17. package/dist/components/data/table/table.class.d.ts +19 -0
  18. package/dist/components/data/table/table.class.js +3 -3
  19. package/dist/components/forms/combobox/combobox.class.d.ts +71 -3
  20. package/dist/components/forms/combobox/combobox.class.js +4 -2
  21. package/dist/components/forms/combobox/combobox.styles.js +9 -0
  22. package/dist/components/forms/date-picker/date-input.class.d.ts +12 -1
  23. package/dist/components/forms/date-picker/date-input.class.js +4 -2
  24. package/dist/components/forms/date-picker/date-picker.class.d.ts +72 -0
  25. package/dist/components/forms/date-picker/date-picker.class.js +15 -3
  26. package/dist/components/forms/date-picker/date-picker.styles.js +46 -0
  27. package/dist/components/media/flag/flag.class.d.ts +3 -1
  28. package/dist/components/media/flag/flag.class.js +1 -1
  29. package/dist/components/media/map/map.class.d.ts +39 -2
  30. package/dist/components/media/map/map.class.js +1 -1
  31. package/dist/components/overlays/dialog/dialog.class.d.ts +20 -0
  32. package/dist/components/overlays/overlay/popover.class.d.ts +19 -3
  33. package/dist/components/overlays/overlay/popover.class.js +1 -1
  34. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
  35. package/dist/custom-elements-jsx.d.ts +31 -16
  36. package/dist/internal/canvas.js +1 -1
  37. package/dist/internal/package-metadata.d.ts +1 -1
  38. package/dist/internal/package-metadata.js +1 -1
  39. package/dist/internal/tokens.styles.js +1 -0
  40. package/dist/lyra.d.ts +1 -1
  41. package/dist/svelte.d.ts +31 -16
  42. package/dist/theme.css +32 -0
  43. package/dist/vue.d.ts +31 -16
  44. package/llms/components/lr-agent-eval-dashboard.md +1 -1
  45. package/llms/components/lr-agent-workspace.md +1 -1
  46. package/llms/components/lr-bar-chart.md +4 -3
  47. package/llms/components/lr-box-plot.md +15 -4
  48. package/llms/components/lr-bubble-chart.md +4 -3
  49. package/llms/components/lr-chart.md +13 -3
  50. package/llms/components/lr-chunk-inspector.md +1 -1
  51. package/llms/components/lr-combobox.md +42 -6
  52. package/llms/components/lr-date-input.md +40 -4
  53. package/llms/components/lr-date-picker.md +40 -4
  54. package/llms/components/lr-dialog.md +2 -1
  55. package/llms/components/lr-doughnut-chart.md +4 -3
  56. package/llms/components/lr-entity-dossier.md +1 -1
  57. package/llms/components/lr-eval-run.md +1 -1
  58. package/llms/components/lr-flag.md +10 -3
  59. package/llms/components/lr-grounding-summary.md +1 -1
  60. package/llms/components/lr-heatmap.md +20 -2
  61. package/llms/components/lr-histogram.md +4 -3
  62. package/llms/components/lr-line-chart.md +4 -3
  63. package/llms/components/lr-lite-chart.md +19 -3
  64. package/llms/components/lr-map.md +21 -4
  65. package/llms/components/lr-memory-panel.md +1 -1
  66. package/llms/components/lr-option.md +41 -5
  67. package/llms/components/lr-pie-chart.md +4 -3
  68. package/llms/components/lr-polar-area-chart.md +4 -3
  69. package/llms/components/lr-popover.md +20 -1
  70. package/llms/components/lr-provenance-panel.md +1 -1
  71. package/llms/components/lr-radar-chart.md +4 -3
  72. package/llms/components/lr-rag-answer.md +1 -1
  73. package/llms/components/lr-rag-eval-dashboard.md +1 -1
  74. package/llms/components/lr-retrieval-results.md +1 -1
  75. package/llms/components/lr-retrieval-trace.md +1 -1
  76. package/llms/components/lr-scatter-chart.md +4 -3
  77. package/llms/peers.md +8 -8
  78. package/llms/tokens.md +27 -1
  79. package/llms-full.txt +231 -28
  80. package/package.json +1 -1
  81. package/vscode-css-data.json +70 -0
  82. package/vscode-html-data.json +131 -20
  83. package/web-types.json +190 -23
@@ -49,6 +49,12 @@ export interface LyraBoxPlotEventMap {
49
49
  * @csspart legend-swatch - The resolved series-color swatch in a legend item.
50
50
  * @csspart description - The accessible box-plot summary.
51
51
  * @csspart data-table - The optional generated or slotted data table.
52
+ * @csspart data-table-toggle - The disclosure button rendered by `dataTableToggle`.
53
+ * @cssprop [--lr-box-plot-data-table-toggle-hover-bg=var(--lr-color-brand-quiet)] - Hover
54
+ * background of the `dataTableToggle` disclosure button.
55
+ * @cssprop --lr-box-plot-data-table-toggle-active-bg - Pressed background of the `dataTableToggle`
56
+ * disclosure button; defaults to a mix of the hover background with the shared active mix
57
+ * partner.
52
58
  * @csspart error - Static visible error shown instead of the canvas when the optional box-plot
53
59
  * peer fails to load; its transition is announced through a shared light-DOM alert.
54
60
  * @csspart data-truncation - Explanation shown when the generated accessible alternative samples
@@ -104,6 +110,27 @@ export declare class LyraBoxPlot extends LyraElement<LyraBoxPlotEventMap> {
104
110
  description: string | null;
105
111
  /** Makes the generated data table visible; it remains screen-reader available when false. */
106
112
  showDataTable: boolean;
113
+ /**
114
+ * Render a disclosure button above the accessible data table so a sighted reader can reveal the
115
+ * numbers behind the plot on demand. `showDataTable` alone is all-or-nothing -- the table is
116
+ * either permanently screen-reader-only or permanently visible -- which left a consumer wrapping
117
+ * a duplicated table in their own `<details>`.
118
+ *
119
+ * With this set, `showDataTable` becomes the disclosure's *initial* state rather than its whole
120
+ * behavior. The table stays in the DOM in both states, so assistive technology never loses it.
121
+ * @default false
122
+ */
123
+ dataTableToggle: boolean;
124
+ /**
125
+ * Live disclosure state. Null until the reader actually toggles, so an untouched control keeps
126
+ * following `showDataTable` (including a later change to it) instead of freezing a seeded copy.
127
+ */
128
+ private dataTableExpandedOverride;
129
+ private readonly dataTableId;
130
+ /** Whether the data table is currently visible. Identical to `showDataTable` whenever
131
+ * `dataTableToggle` is off, which is what keeps the unset path byte-identical to before. */
132
+ private get dataTableVisible();
133
+ private toggleDataTable;
107
134
  /** Formats numeric axes, tooltips, generated table cells, summaries, and CSV export. */
108
135
  valueFormatter?: LyraChartValueFormatter;
109
136
  /** Unified context-object formatter shared with the other chart surfaces. */
@@ -1,6 +1,6 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{loadChartJs}from"./chart-core-loader.js";import{styles}from"./box-plot.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{resolveCanvasColor,seriesPalette}from"./chart-colors.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{resolveOptionalPeerCapability,unwrapOptionalPeerDefault}from"../../../internal/optional-peer-capabilities.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{chartChromeLegendPlacement,normalizeChartChromeLegendPosition}from"./chart-chrome.js";import{LYRA_DEFAULT_boxPlot,LYRA_DEFAULT_boxPlotData,LYRA_DEFAULT_boxPlotMax,LYRA_DEFAULT_boxPlotMedian,LYRA_DEFAULT_boxPlotMin,LYRA_DEFAULT_boxPlotMissingLibrary,LYRA_DEFAULT_boxPlotQ1,LYRA_DEFAULT_boxPlotQ3,LYRA_DEFAULT_boxPlotSeriesSummary,LYRA_DEFAULT_boxPlotSummaryEmpty,LYRA_DEFAULT_boxPlotSummaryWithData,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_liteChartMarkSummary,LYRA_DEFAULT_loading}from"../../../internal/default-strings.generated.js";const FALLBACK_GRID_COLOR="#8a8a90",FALLBACK_TICK_COLOR="#6b7280",FALLBACK_LEGEND_COLOR="#1a1a1a",FALLBACK_TOOLTIP_BG="#fff",FALLBACK_TOOLTIP_TEXT="#1a1a1a";function summaryOf(point){return{min:point.min,q1:point.q1,median:point.median,q3:point.q3,max:point.max}}let boxPlotPlugin;function isConstructor(value){if(typeof value!="function")return!1;try{return Reflect.construct(Object,[],value),!0}catch{return!1}}function missingBoxPlotCapability(candidate){if(typeof candidate!="object"&&typeof candidate!="function"||candidate===null)return"module namespace";const module=candidate;if(!isConstructor(module.BoxPlotController))return"BoxPlotController";if(!isConstructor(module.BoxAndWiskers))return"BoxAndWiskers"}function isBoxPlotModule(candidate){return missingBoxPlotCapability(candidate)===void 0}function resolveBoxPlotModule(value){const module=resolveOptionalPeerCapability(value,isBoxPlotModule);if(module)return module;const candidate=unwrapOptionalPeerDefault(value),missing=missingBoxPlotCapability(candidate)??"module namespace";throw new Error(`Invalid optional peer \`@sgratzl/chartjs-chart-boxplot\`: missing or invalid \`${missing}\` constructor.`)}async function loadBoxPlotAndRegister(loadChart=loadChartJs,importBoxPlot=()=>import("@sgratzl/chartjs-chart-boxplot")){try{const[chartMod,imported]=await Promise.all([loadChart(),importBoxPlot()]);if(!chartMod)return null;const boxMod=resolveBoxPlotModule(imported);return chartMod.Chart.register(boxMod.BoxPlotController,boxMod.BoxAndWiskers),boxMod}catch(error){return console.warn("<lr-box-plot> needs the optional peer dependency `@sgratzl/chartjs-chart-boxplot` \u2014 install it with `pnpm add @sgratzl/chartjs-chart-boxplot`.",error),null}}function loadBoxPlotPlugin(){return boxPlotPlugin||(boxPlotPlugin=loadBoxPlotAndRegister()),boxPlotPlugin}class LyraBoxPlot extends LyraElement{static{this.defaultStrings={...super.defaultStrings,boxPlot:LYRA_DEFAULT_boxPlot,boxPlotData:LYRA_DEFAULT_boxPlotData,boxPlotMax:LYRA_DEFAULT_boxPlotMax,boxPlotMedian:LYRA_DEFAULT_boxPlotMedian,boxPlotMin:LYRA_DEFAULT_boxPlotMin,boxPlotMissingLibrary:LYRA_DEFAULT_boxPlotMissingLibrary,boxPlotQ1:LYRA_DEFAULT_boxPlotQ1,boxPlotQ3:LYRA_DEFAULT_boxPlotQ3,boxPlotSeriesSummary:LYRA_DEFAULT_boxPlotSeriesSummary,boxPlotSummaryEmpty:LYRA_DEFAULT_boxPlotSummaryEmpty,boxPlotSummaryWithData:LYRA_DEFAULT_boxPlotSummaryWithData,chartCategory:LYRA_DEFAULT_chartCategory,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartValueLabel:LYRA_DEFAULT_chartValueLabel,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading}}static{this.ownedCollectionProperties=Object.freeze(["labels","datasets","hiddenDatasets"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-before-legend-visibility-change","lr-legend-visibility-change"])}constructor(){super(),this.labels=[],this.datasets=[],this.legend=!1,this.legendPosition="bottom",this.height="280px",this.yLabel="",this.beginAtZero=!0,this.label=null,this.description=null,this.showDataTable=!1,this.loading=!0,this.loadFailed=!1,this.visible=!0,this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.intersectionGeneration=0,this.loadGeneration=0,this.descriptionId=nextId("box-plot-description"),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.onReducedMotionChange=()=>{!this.isConnected||this.ownerWindow!==this.reducedMotionWindow||this.drawIfVisible()},new ThemeWatcher(this,()=>{this.chart&&this.refreshTheme()})}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSinks(),this.visible=!0,this.armReducedMotionWatcher();const generation=++this.loadGeneration;loadBoxPlotPlugin().then(boxMod=>this.onBoxPlotPluginLoaded(boxMod,generation));const IntersectionObserverCtor=this.ownerWindow?.IntersectionObserver;if(IntersectionObserverCtor){const ownerWindow=this.ownerWindow,observerGeneration=++this.intersectionGeneration,observer=new IntersectionObserverCtor(entries=>{if(observerGeneration!==this.intersectionGeneration||this.intersectionObserver!==observer||!this.isConnected||this.ownerWindow!==ownerWindow)return;const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.drawIfVisible()});this.intersectionObserver=observer,observer.observe(this)}}async onBoxPlotPluginLoaded(boxMod,generation=this.loadGeneration){if(generation!==this.loadGeneration||!this.isConnected)return;try{await this.updateComplete}catch{return}if(await new Promise(resolve=>this.updateBrowserDerivedState(resolve)),generation!==this.loadGeneration||!this.isConnected)return;if(this.loading=!1,!boxMod){this.loadFailed=!0,this.chart?.destroy(),this.chart=void 0,this.chartJsModule=void 0;return}this.loadFailed=!1;const chartMod=await loadChartJs();generation!==this.loadGeneration||!this.isConnected||(this.chartJsModule=chartMod??void 0,this.drawIfVisible())}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSinks(),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.loadGeneration+=1,this.chart?.destroy(),this.chart=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.intersectionGeneration+=1,this.visible=!0,this.disarmReducedMotionWatcher()}adoptedCallback(){super.adoptedCallback(),this.releaseAnnouncementSinks(),this.syncAnnouncementSinks(),this.armReducedMotionWatcher()}armReducedMotionWatcher(){const ownerWindow=this.ownerWindow;ownerWindow?.matchMedia&&(this.reducedMotionWindow===ownerWindow&&this.reducedMotionQuery||(this.disarmReducedMotionWatcher(),this.reducedMotionWindow=ownerWindow,this.reducedMotionQuery=ownerWindow.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedMotionQuery.addEventListener("change",this.onReducedMotionChange)))}disarmReducedMotionWatcher(){this.reducedMotionQuery?.removeEventListener("change",this.onReducedMotionChange),this.reducedMotionQuery=void 0,this.reducedMotionWindow=void 0}syncAnnouncementSinks(){this.isConnected&&(this.politeAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.assertiveAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.releaseAnnouncementSinks(),this.politeAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})))}releaseAnnouncementSinks(){this.politeAnnouncementSink?.release(),this.politeAnnouncementSink=void 0,this.assertiveAnnouncementSink?.release(),this.assertiveAnnouncementSink=void 0}get ownerWindow(){return this.ownerDocument?.defaultView??void 0}effectiveHiddenDatasetIndexes(){return normalizeHiddenDatasets(this.hiddenDatasets,this.datasets.length)??[]}applyDatasetVisibility(){if(!this.chart)return!1;const datasetCount=this.chart.data.datasets?.length??0,sourceSeriesIndexes=this.dataTableSample().seriesIndexes,controlled=normalizeHiddenDatasets(this.hiddenDatasets,this.datasets.length);if(controlled===void 0){for(let index=0;index<datasetCount;index++){const metadata=this.chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++)this.chart.setDatasetVisibility(index,!hidden.has(sourceSeriesIndexes[index]??index));return datasetCount>0}updated(changed){if(super.updated(changed),!this.isConnected)return;const wasMounting=this.isMounting;this.isMounting=!1,changed.has("keyboardDatumAnnouncement")&&changed.get("keyboardDatumAnnouncement")!==void 0&&this.keyboardDatumAnnouncement!==""&&this.politeAnnouncementSink?.announce(this.keyboardDatumAnnouncement),changed.has("loadFailed")&&changed.get("loadFailed")!==void 0&&this.loadFailed&&this.assertiveAnnouncementSink?.announce(this.localize("boxPlotMissingLibrary"));const dataTruncation=this.dataTruncationMessage();if(wasMounting&&(this.lastDataTruncationAnnouncement=dataTruncation),!this.loading&&!this.loadFailed&&!wasMounting&&dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.politeAnnouncementSink?.announce(dataTruncation)),this.setAttribute("aria-busy",String(this.loading)),changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}if(this.loading)return;const contentChanged=["labels","datasets","hiddenDatasets","legend","legendPosition","height","yLabel","beginAtZero","label","description","valueFormatter","formatter","locale","strings","loading"].some(name=>changed.has(name)),direction=this.effectiveDirection,locale=this.effectiveLocale,contextChanged=this.lastDrawnDirection!==void 0&&this.lastDrawnDirection!==direction||this.lastDrawnLocale!==void 0&&this.lastDrawnLocale!==locale;this.lastDrawnDirection=direction,this.lastDrawnLocale=locale,!(!contentChanged&&!contextChanged)&&this.drawIfVisible()}themeColors(){const view=this.ownerWindow,cs=view?view.getComputedStyle(this):this.style;return{grid:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-grid-color").trim()||cs.getPropertyValue("--_lr-chart-grid-color").trim(),FALLBACK_GRID_COLOR),tick:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-tick-color").trim()||cs.getPropertyValue("--_lr-chart-tick-color").trim(),FALLBACK_TICK_COLOR),legend:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-legend-color").trim()||cs.getPropertyValue("--_lr-chart-legend-color").trim(),FALLBACK_LEGEND_COLOR),tooltipBg:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-tooltip-bg").trim()||cs.getPropertyValue("--_lr-chart-tooltip-bg").trim(),FALLBACK_TOOLTIP_BG),tooltipText:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-tooltip-text").trim()||cs.getPropertyValue("--_lr-chart-tooltip-text").trim(),FALLBACK_TOOLTIP_TEXT)}}seriesColor(index,palette=seriesPalette(this)){const fallback=palette[index%palette.length]??"transparent",series=this.datasets[index];return series?.color?resolveCanvasColor(this,series.color,fallback):fallback}forcedColorFill(index,background){return!this.ownerWindow||!forcedColorsActive(this.ownerWindow)?background:createForcedColorPattern(this.ownerDocument,index,background,this.styleColor("--lr-color-surface",FALLBACK_TOOLTIP_BG))}styleColor(name,fallback){const view=this.ownerWindow,value=(view?view.getComputedStyle(this):this.style).getPropertyValue(name).trim();return value?resolveCanvasColor(this,value,fallback):fallback}buildConfig(){const theme=this.themeColors(),palette=seriesPalette(this),sample=this.dataTableSample();return{type:"boxplot",data:{labels:sample.rowIndexes.map(index=>this.labels[index]??""),datasets:sample.seriesIndexes.map(sourceIndex=>{const s=this.datasets[sourceIndex],color=this.seriesColor(sourceIndex,palette);return{label:s.label,data:sample.rowIndexes.map(index=>{const point=s.data[index];return this.validPoint(point)?summaryOf(point):null}),backgroundColor:this.forcedColorFill(sourceIndex,color),borderColor:color}})},options:{locale:this.effectiveLocale,responsive:!0,maintainAspectRatio:!1,animation:prefersReducedMotion(this.ownerWindow)?!1:void 0,onClick:(event,_elements,chart)=>this.handlePointClick(event,chart),plugins:{legend:{display:!1,labels:{color:theme.legend}},tooltip:{backgroundColor:theme.tooltipBg,titleColor:theme.tooltipText,bodyColor:theme.tooltipText,...this.formatter||this.valueFormatter?{callbacks:{label:context=>{const raw=context.raw,point=this.validPoint(raw)?raw:void 0;if(!point)return;const value=this.formatValue(point.median,"tooltip"),label=String(context.dataset?.label??"");return label?this.localize("chartValueLabel",void 0,{label,value}):value}}}:{}}},scales:{y:{position:this.effectiveDirection==="rtl"?"right":"left",beginAtZero:this.beginAtZero,title:{display:!!this.yLabel,text:this.yLabel,color:theme.tick},ticks:{color:theme.tick,...this.formatter||this.valueFormatter?{callback:value=>this.formatValue(Number(value),"tick")}:{}},grid:{color:theme.grid}}}}}}draw(){if(!this.chartJsModule||!this.canvasEl)return;const config=this.buildConfig();if(this.chart){this.chart.data=config.data,this.chart.options=config.options??{},this.applyDatasetVisibility(),this.chart.update("none");return}this.chart=new this.chartJsModule.Chart(this.canvasEl,config),this.hiddenDatasets!==void 0&&(this.applyDatasetVisibility(),this.chart.update("none"))}drawIfVisible(){!this.isConnected||!this.visible||this.draw()}refreshTheme(){this.drawIfVisible(),this.legend&&this.requestUpdate()}formatValue(value,context){return this.formatter?.({value,surface:context})??this.valueFormatter?.(value,context)??getNumberFormat(this.effectiveLocale).format(value)}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const header=["category","series","min","q1","median","q3","max"].map(escapeCsvField).join(","),rows=[];return this.datasets.forEach(series=>{series.data.forEach((point,index)=>{this.validPoint(point)&&rows.push([this.labels[index]??"",series.label,this.formatValue(point.min,"table"),this.formatValue(point.q1,"table"),this.formatValue(point.median,"table"),this.formatValue(point.q3,"table"),this.formatValue(point.max,"table")].map(escapeCsvField).join(","))})}),[header,...rows].join(`\r
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{loadChartJs}from"./chart-core-loader.js";import{styles}from"./box-plot.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{resolveCanvasColor,seriesPalette}from"./chart-colors.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{resolveOptionalPeerCapability,unwrapOptionalPeerDefault}from"../../../internal/optional-peer-capabilities.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{chartChromeLegendPlacement,normalizeChartChromeLegendPosition}from"./chart-chrome.js";import{LYRA_DEFAULT_boxPlot,LYRA_DEFAULT_boxPlotData,LYRA_DEFAULT_boxPlotMax,LYRA_DEFAULT_boxPlotMedian,LYRA_DEFAULT_boxPlotMin,LYRA_DEFAULT_boxPlotMissingLibrary,LYRA_DEFAULT_boxPlotQ1,LYRA_DEFAULT_boxPlotQ3,LYRA_DEFAULT_boxPlotSeriesSummary,LYRA_DEFAULT_boxPlotSummaryEmpty,LYRA_DEFAULT_boxPlotSummaryWithData,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_liteChartMarkSummary,LYRA_DEFAULT_loading}from"../../../internal/default-strings.generated.js";const FALLBACK_GRID_COLOR="#8a8a90",FALLBACK_TICK_COLOR="#6b7280",FALLBACK_LEGEND_COLOR="#1a1a1a",FALLBACK_TOOLTIP_BG="#fff",FALLBACK_TOOLTIP_TEXT="#1a1a1a";function summaryOf(point){return{min:point.min,q1:point.q1,median:point.median,q3:point.q3,max:point.max}}let boxPlotPlugin;function isConstructor(value){if(typeof value!="function")return!1;try{return Reflect.construct(Object,[],value),!0}catch{return!1}}function missingBoxPlotCapability(candidate){if(typeof candidate!="object"&&typeof candidate!="function"||candidate===null)return"module namespace";const module=candidate;if(!isConstructor(module.BoxPlotController))return"BoxPlotController";if(!isConstructor(module.BoxAndWiskers))return"BoxAndWiskers"}function isBoxPlotModule(candidate){return missingBoxPlotCapability(candidate)===void 0}function resolveBoxPlotModule(value){const module=resolveOptionalPeerCapability(value,isBoxPlotModule);if(module)return module;const candidate=unwrapOptionalPeerDefault(value),missing=missingBoxPlotCapability(candidate)??"module namespace";throw new Error(`Invalid optional peer \`@sgratzl/chartjs-chart-boxplot\`: missing or invalid \`${missing}\` constructor.`)}async function loadBoxPlotAndRegister(loadChart=loadChartJs,importBoxPlot=()=>import("@sgratzl/chartjs-chart-boxplot")){try{const[chartMod,imported]=await Promise.all([loadChart(),importBoxPlot()]);if(!chartMod)return null;const boxMod=resolveBoxPlotModule(imported);return chartMod.Chart.register(boxMod.BoxPlotController,boxMod.BoxAndWiskers),boxMod}catch(error){return console.warn("<lr-box-plot> needs the optional peer dependency `@sgratzl/chartjs-chart-boxplot` \u2014 install it with `pnpm add @sgratzl/chartjs-chart-boxplot`.",error),null}}function loadBoxPlotPlugin(){return boxPlotPlugin||(boxPlotPlugin=loadBoxPlotAndRegister()),boxPlotPlugin}class LyraBoxPlot extends LyraElement{static{this.defaultStrings={...super.defaultStrings,boxPlot:LYRA_DEFAULT_boxPlot,boxPlotData:LYRA_DEFAULT_boxPlotData,boxPlotMax:LYRA_DEFAULT_boxPlotMax,boxPlotMedian:LYRA_DEFAULT_boxPlotMedian,boxPlotMin:LYRA_DEFAULT_boxPlotMin,boxPlotMissingLibrary:LYRA_DEFAULT_boxPlotMissingLibrary,boxPlotQ1:LYRA_DEFAULT_boxPlotQ1,boxPlotQ3:LYRA_DEFAULT_boxPlotQ3,boxPlotSeriesSummary:LYRA_DEFAULT_boxPlotSeriesSummary,boxPlotSummaryEmpty:LYRA_DEFAULT_boxPlotSummaryEmpty,boxPlotSummaryWithData:LYRA_DEFAULT_boxPlotSummaryWithData,chartCategory:LYRA_DEFAULT_chartCategory,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartValueLabel:LYRA_DEFAULT_chartValueLabel,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading}}static{this.ownedCollectionProperties=Object.freeze(["labels","datasets","hiddenDatasets"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-before-legend-visibility-change","lr-legend-visibility-change"])}constructor(){super(),this.labels=[],this.datasets=[],this.legend=!1,this.legendPosition="bottom",this.height="280px",this.yLabel="",this.beginAtZero=!0,this.label=null,this.description=null,this.showDataTable=!1,this.dataTableToggle=!1,this.dataTableExpandedOverride=null,this.dataTableId=nextId("box-plot-data-table"),this.loading=!0,this.loadFailed=!1,this.visible=!0,this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.intersectionGeneration=0,this.loadGeneration=0,this.descriptionId=nextId("box-plot-description"),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.onReducedMotionChange=()=>{!this.isConnected||this.ownerWindow!==this.reducedMotionWindow||this.drawIfVisible()},new ThemeWatcher(this,()=>{this.chart&&this.refreshTheme()})}get dataTableVisible(){return this.dataTableToggle?this.dataTableExpandedOverride??this.showDataTable:this.showDataTable}toggleDataTable(){this.dataTableExpandedOverride=!this.dataTableVisible}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSinks(),this.visible=!0,this.armReducedMotionWatcher();const generation=++this.loadGeneration;loadBoxPlotPlugin().then(boxMod=>this.onBoxPlotPluginLoaded(boxMod,generation));const IntersectionObserverCtor=this.ownerWindow?.IntersectionObserver;if(IntersectionObserverCtor){const ownerWindow=this.ownerWindow,observerGeneration=++this.intersectionGeneration,observer=new IntersectionObserverCtor(entries=>{if(observerGeneration!==this.intersectionGeneration||this.intersectionObserver!==observer||!this.isConnected||this.ownerWindow!==ownerWindow)return;const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.drawIfVisible()});this.intersectionObserver=observer,observer.observe(this)}}async onBoxPlotPluginLoaded(boxMod,generation=this.loadGeneration){if(generation!==this.loadGeneration||!this.isConnected)return;try{await this.updateComplete}catch{return}if(await new Promise(resolve=>this.updateBrowserDerivedState(resolve)),generation!==this.loadGeneration||!this.isConnected)return;if(this.loading=!1,!boxMod){this.loadFailed=!0,this.chart?.destroy(),this.chart=void 0,this.chartJsModule=void 0;return}this.loadFailed=!1;const chartMod=await loadChartJs();generation!==this.loadGeneration||!this.isConnected||(this.chartJsModule=chartMod??void 0,this.drawIfVisible())}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSinks(),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.loadGeneration+=1,this.chart?.destroy(),this.chart=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.intersectionGeneration+=1,this.visible=!0,this.disarmReducedMotionWatcher()}adoptedCallback(){super.adoptedCallback(),this.releaseAnnouncementSinks(),this.syncAnnouncementSinks(),this.armReducedMotionWatcher()}armReducedMotionWatcher(){const ownerWindow=this.ownerWindow;ownerWindow?.matchMedia&&(this.reducedMotionWindow===ownerWindow&&this.reducedMotionQuery||(this.disarmReducedMotionWatcher(),this.reducedMotionWindow=ownerWindow,this.reducedMotionQuery=ownerWindow.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedMotionQuery.addEventListener("change",this.onReducedMotionChange)))}disarmReducedMotionWatcher(){this.reducedMotionQuery?.removeEventListener("change",this.onReducedMotionChange),this.reducedMotionQuery=void 0,this.reducedMotionWindow=void 0}syncAnnouncementSinks(){this.isConnected&&(this.politeAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.assertiveAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.releaseAnnouncementSinks(),this.politeAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})))}releaseAnnouncementSinks(){this.politeAnnouncementSink?.release(),this.politeAnnouncementSink=void 0,this.assertiveAnnouncementSink?.release(),this.assertiveAnnouncementSink=void 0}get ownerWindow(){return this.ownerDocument?.defaultView??void 0}effectiveHiddenDatasetIndexes(){return normalizeHiddenDatasets(this.hiddenDatasets,this.datasets.length)??[]}applyDatasetVisibility(){if(!this.chart)return!1;const datasetCount=this.chart.data.datasets?.length??0,sourceSeriesIndexes=this.dataTableSample().seriesIndexes,controlled=normalizeHiddenDatasets(this.hiddenDatasets,this.datasets.length);if(controlled===void 0){for(let index=0;index<datasetCount;index++){const metadata=this.chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++)this.chart.setDatasetVisibility(index,!hidden.has(sourceSeriesIndexes[index]??index));return datasetCount>0}updated(changed){if(super.updated(changed),!this.isConnected)return;const wasMounting=this.isMounting;this.isMounting=!1,changed.has("keyboardDatumAnnouncement")&&changed.get("keyboardDatumAnnouncement")!==void 0&&this.keyboardDatumAnnouncement!==""&&this.politeAnnouncementSink?.announce(this.keyboardDatumAnnouncement),changed.has("loadFailed")&&changed.get("loadFailed")!==void 0&&this.loadFailed&&this.assertiveAnnouncementSink?.announce(this.localize("boxPlotMissingLibrary"));const dataTruncation=this.dataTruncationMessage();if(wasMounting&&(this.lastDataTruncationAnnouncement=dataTruncation),!this.loading&&!this.loadFailed&&!wasMounting&&dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.politeAnnouncementSink?.announce(dataTruncation)),this.setAttribute("aria-busy",String(this.loading)),changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}if(this.loading)return;const contentChanged=["labels","datasets","hiddenDatasets","legend","legendPosition","height","yLabel","beginAtZero","label","description","valueFormatter","formatter","locale","strings","loading"].some(name=>changed.has(name)),direction=this.effectiveDirection,locale=this.effectiveLocale,contextChanged=this.lastDrawnDirection!==void 0&&this.lastDrawnDirection!==direction||this.lastDrawnLocale!==void 0&&this.lastDrawnLocale!==locale;this.lastDrawnDirection=direction,this.lastDrawnLocale=locale,!(!contentChanged&&!contextChanged)&&this.drawIfVisible()}themeColors(){const view=this.ownerWindow,cs=view?view.getComputedStyle(this):this.style;return{grid:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-grid-color").trim()||cs.getPropertyValue("--_lr-chart-grid-color").trim(),FALLBACK_GRID_COLOR),tick:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-tick-color").trim()||cs.getPropertyValue("--_lr-chart-tick-color").trim(),FALLBACK_TICK_COLOR),legend:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-legend-color").trim()||cs.getPropertyValue("--_lr-chart-legend-color").trim(),FALLBACK_LEGEND_COLOR),tooltipBg:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-tooltip-bg").trim()||cs.getPropertyValue("--_lr-chart-tooltip-bg").trim(),FALLBACK_TOOLTIP_BG),tooltipText:resolveCanvasColor(this,cs.getPropertyValue("--lr-chart-tooltip-text").trim()||cs.getPropertyValue("--_lr-chart-tooltip-text").trim(),FALLBACK_TOOLTIP_TEXT)}}seriesColor(index,palette=seriesPalette(this)){const fallback=palette[index%palette.length]??"transparent",series=this.datasets[index];return series?.color?resolveCanvasColor(this,series.color,fallback):fallback}forcedColorFill(index,background){return!this.ownerWindow||!forcedColorsActive(this.ownerWindow)?background:createForcedColorPattern(this.ownerDocument,index,background,this.styleColor("--lr-color-surface",FALLBACK_TOOLTIP_BG))}styleColor(name,fallback){const view=this.ownerWindow,value=(view?view.getComputedStyle(this):this.style).getPropertyValue(name).trim();return value?resolveCanvasColor(this,value,fallback):fallback}buildConfig(){const theme=this.themeColors(),palette=seriesPalette(this),sample=this.dataTableSample();return{type:"boxplot",data:{labels:sample.rowIndexes.map(index=>this.labels[index]??""),datasets:sample.seriesIndexes.map(sourceIndex=>{const s=this.datasets[sourceIndex],color=this.seriesColor(sourceIndex,palette);return{label:s.label,data:sample.rowIndexes.map(index=>{const point=s.data[index];return this.validPoint(point)?summaryOf(point):null}),backgroundColor:this.forcedColorFill(sourceIndex,color),borderColor:color}})},options:{locale:this.effectiveLocale,responsive:!0,maintainAspectRatio:!1,animation:prefersReducedMotion(this.ownerWindow)?!1:void 0,onClick:(event,_elements,chart)=>this.handlePointClick(event,chart),plugins:{legend:{display:!1,labels:{color:theme.legend}},tooltip:{backgroundColor:theme.tooltipBg,titleColor:theme.tooltipText,bodyColor:theme.tooltipText,...this.formatter||this.valueFormatter?{callbacks:{label:context=>{const raw=context.raw,point=this.validPoint(raw)?raw:void 0;if(!point)return;const value=this.formatValue(point.median,"tooltip"),label=String(context.dataset?.label??"");return label?this.localize("chartValueLabel",void 0,{label,value}):value}}}:{}}},scales:{y:{position:this.effectiveDirection==="rtl"?"right":"left",beginAtZero:this.beginAtZero,title:{display:!!this.yLabel,text:this.yLabel,color:theme.tick},ticks:{color:theme.tick,...this.formatter||this.valueFormatter?{callback:value=>this.formatValue(Number(value),"tick")}:{}},grid:{color:theme.grid}}}}}}draw(){if(!this.chartJsModule||!this.canvasEl)return;const config=this.buildConfig();if(this.chart){this.chart.data=config.data,this.chart.options=config.options??{},this.applyDatasetVisibility(),this.chart.update("none");return}this.chart=new this.chartJsModule.Chart(this.canvasEl,config),this.hiddenDatasets!==void 0&&(this.applyDatasetVisibility(),this.chart.update("none"))}drawIfVisible(){!this.isConnected||!this.visible||this.draw()}refreshTheme(){this.drawIfVisible(),this.legend&&this.requestUpdate()}formatValue(value,context){return this.formatter?.({value,surface:context})??this.valueFormatter?.(value,context)??getNumberFormat(this.effectiveLocale).format(value)}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const header=["category","series","min","q1","median","q3","max"].map(escapeCsvField).join(","),rows=[];return this.datasets.forEach(series=>{series.data.forEach((point,index)=>{this.validPoint(point)&&rows.push([this.labels[index]??"",series.label,this.formatValue(point.min,"table"),this.formatValue(point.q1,"table"),this.formatValue(point.median,"table"),this.formatValue(point.q3,"table"),this.formatValue(point.max,"table")].map(escapeCsvField).join(","))})}),[header,...rows].join(`\r
2
2
  `)}boxPlotDescription(){if(this.description)return this.description;const summaries=this.dataTableSample().seriesIndexes.map(index=>{const series=this.datasets[index];let count=0,first=0,last=0,min=0,max=0;for(const point of series.data)this.validPoint(point)&&(count===0&&(first=point.median,min=point.median,max=point.median),last=point.median,min=Math.min(min,point.median),max=Math.max(max,point.median),count++);if(count===0)return this.localize("chartSeriesNoData",void 0,{label:series.label});const trend=last>first?this.localize("chartTrendIncreasing"):last<first?this.localize("chartTrendDecreasing"):this.localize("chartTrendFlat");return this.localize("boxPlotSeriesSummary",void 0,{label:series.label,count:getNumberFormat(this.effectiveLocale).format(count),min:this.formatValue(min,"table"),max:this.formatValue(max,"table"),trend})});return summaries.length?this.localize("boxPlotSummaryWithData",void 0,{summaries:summaries.join(this.localize("chartSummarySeparator"))}):this.localize("boxPlotSummaryEmpty")}boxDatums(){const sample=this.dataTableSample(),datums=[];for(const datasetIndex of sample.seriesIndexes){const series=this.datasets[datasetIndex];if(series)for(const index of sample.rowIndexes){const point=series.data[index];this.validPoint(point)&&datums.push({datasetIndex,index,label:this.labels[index]||void 0,value:summaryOf(point)})}}return datums}boxAnnouncement(datum,position,total){const numberFormat=getNumberFormat(this.effectiveLocale),point=datum.value,summary=(point?[[this.localize("boxPlotMin"),point.min],[this.localize("boxPlotQ1"),point.q1],[this.localize("boxPlotMedian"),point.median],[this.localize("boxPlotQ3"),point.q3],[this.localize("boxPlotMax"),point.max]]:[]).filter(([,value])=>Number.isFinite(value)).map(([label,value])=>this.localize("chartValueLabel",void 0,{label,value:numberFormat.format(value)})).join(this.localize("chartSummarySeparator"));return this.localize("liteChartMarkSummary",void 0,{series:this.datasets[datum.datasetIndex]?.label||this.localize("chartSeriesLabel"),label:datum.label??this.localize("chartPointLabel",void 0,{n:numberFormat.format(datum.index+1)}),value:summary,index:numberFormat.format(position+1),total:numberFormat.format(total)})}activateBox(datum){const datums=this.boxDatums(),position=datums.findIndex(candidate=>candidate.datasetIndex===datum.datasetIndex&&candidate.index===datum.index);position>=0&&(this.keyboardDatumIndex=position,this.keyboardDatumAnnouncement=this.boxAnnouncement(datum,position,datums.length)),this.emit("lr-datum-activate",{...datum,kind:"box"}),this.emit("lr-point-click",datum)}handlePointClick(event,chart){const hit=chart.getElementsAtEventForMode?.(event,"nearest",{intersect:!0},!0)?.[0];if(!hit)return;const sample=this.dataTableSample(),datasetIndex=sample.seriesIndexes[hit.datasetIndex],index=sample.rowIndexes[hit.index];if(datasetIndex===void 0||index===void 0)return;const point=this.datasets[datasetIndex]?.data[index];this.activateBox({datasetIndex,index,label:this.labels[index]||void 0,value:this.validPoint(point)?summaryOf(point):null})}onCanvasFocus(){const datums=this.boxDatums();datums.length&&(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),this.keyboardDatumAnnouncement=this.boxAnnouncement(datums[this.keyboardDatumIndex],this.keyboardDatumIndex,datums.length))}onCanvasKeyDown(event){const datums=this.boxDatums();if(!datums.length)return;if(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),event.key==="Enter"||event.key===" "){event.preventDefault(),this.activateBox(datums[this.keyboardDatumIndex]);return}const rtl=this.effectiveDirection==="rtl",forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft";let next=this.keyboardDatumIndex;if(event.key===forward||event.key==="ArrowDown")next=Math.min(datums.length-1,next+1);else if(event.key===backward||event.key==="ArrowUp")next=Math.max(0,next-1);else if(event.key==="Home")next=0;else if(event.key==="End")next=datums.length-1;else return;event.preventDefault(),this.keyboardDatumIndex=next,this.keyboardDatumAnnouncement=this.boxAnnouncement(datums[next],next,datums.length)}validPoint(point){return!!point&&[point.min,point.q1,point.median,point.q3,point.max].every(Number.isFinite)&&point.min<=point.q1&&point.q1<=point.median&&point.median<=point.q3&&point.q3<=point.max}accessibleName(fallback){return this.getAttribute("aria-label")??this.label??fallback}dataTableSample(){let rowCount=this.labels.length;for(const series of this.datasets)rowCount=Math.max(rowCount,series.data.length);const indexes=sampleChartTableIndexes(rowCount,this.datasets.length);return{rowCount,seriesCount:this.datasets.length,...indexes}}generatedDataIsSampled(){if(this.hasCustomDataTable())return!1;const sample=this.dataTableSample();return sample.rowCount===0||sample.seriesCount===0?!1:sample.rowIndexes.length<sample.rowCount||sample.seriesIndexes.length<sample.seriesCount}dataTruncationMessage(){return this.generatedDataIsSampled()?this.localize("chartDataSampled"):""}renderDataTable(){const numberFormat=getNumberFormat(this.effectiveLocale),sample=this.dataTableSample();return html`
3
- <table class=${this.showDataTable?"":"sr-only"}>
3
+ <table class=${this.dataTableVisible?"":"sr-only"}>
4
4
  <caption>${this.accessibleName(this.localize("boxPlotData"))}</caption>
5
5
  <thead>
6
6
  <tr>
@@ -75,12 +75,22 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
75
75
  <p part="description" id=${this.descriptionId} class="sr-only">${description}</p>
76
76
  <p class="sr-only" aria-hidden="true">${this.keyboardDatumAnnouncement}</p>
77
77
  ${this.dataTruncationMessage()?html`<p part="data-truncation">${this.dataTruncationMessage()}</p>`:nothing}
78
+ ${this.dataTableToggle?html`<button
79
+ part="data-table-toggle"
80
+ type="button"
81
+ aria-expanded=${this.dataTableVisible?"true":"false"}
82
+ aria-controls=${this.dataTableId}
83
+ @click=${()=>this.toggleDataTable()}
84
+ >
85
+ ${this.localize("boxPlotData")}
86
+ </button>`:nothing}
78
87
  <div
88
+ id=${this.dataTableId}
79
89
  part="data-table"
80
- ?data-visually-hidden=${!hasCustomDataTable&&!this.showDataTable}
90
+ ?data-visually-hidden=${!hasCustomDataTable&&!this.dataTableVisible}
81
91
  >
82
92
  <slot name="data-table" @slotchange=${()=>this.requestUpdate()}></slot>
83
93
  ${hasCustomDataTable?nothing:this.renderDataTable()}
84
94
  </div>
85
95
  </div>
86
- `}}__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"labels",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"datasets",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"hiddenDatasets",void 0),__decorate([property({type:Boolean})],LyraBoxPlot.prototype,"legend",void 0),__decorate([property({attribute:"legend-position",converter:{fromAttribute:normalizeChartChromeLegendPosition}})],LyraBoxPlot.prototype,"legendPosition",void 0),__decorate([property()],LyraBoxPlot.prototype,"height",void 0),__decorate([property({attribute:"y-label"})],LyraBoxPlot.prototype,"yLabel",void 0),__decorate([property({type:Boolean,attribute:"begin-at-zero",converter:trueDefaultBooleanConverter})],LyraBoxPlot.prototype,"beginAtZero",void 0),__decorate([property()],LyraBoxPlot.prototype,"label",void 0),__decorate([property()],LyraBoxPlot.prototype,"description",void 0),__decorate([property({type:Boolean,attribute:"show-data-table"})],LyraBoxPlot.prototype,"showDataTable",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"valueFormatter",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"formatter",void 0),__decorate([state()],LyraBoxPlot.prototype,"loading",void 0),__decorate([state()],LyraBoxPlot.prototype,"loadFailed",void 0),__decorate([state()],LyraBoxPlot.prototype,"visible",void 0),__decorate([state()],LyraBoxPlot.prototype,"keyboardDatumAnnouncement",void 0),__decorate([query("canvas")],LyraBoxPlot.prototype,"canvasEl",void 0);export{LyraBoxPlot,loadBoxPlotAndRegister};
96
+ `}}__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"labels",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"datasets",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"hiddenDatasets",void 0),__decorate([property({type:Boolean})],LyraBoxPlot.prototype,"legend",void 0),__decorate([property({attribute:"legend-position",converter:{fromAttribute:normalizeChartChromeLegendPosition}})],LyraBoxPlot.prototype,"legendPosition",void 0),__decorate([property()],LyraBoxPlot.prototype,"height",void 0),__decorate([property({attribute:"y-label"})],LyraBoxPlot.prototype,"yLabel",void 0),__decorate([property({type:Boolean,attribute:"begin-at-zero",converter:trueDefaultBooleanConverter})],LyraBoxPlot.prototype,"beginAtZero",void 0),__decorate([property()],LyraBoxPlot.prototype,"label",void 0),__decorate([property()],LyraBoxPlot.prototype,"description",void 0),__decorate([property({type:Boolean,attribute:"show-data-table"})],LyraBoxPlot.prototype,"showDataTable",void 0),__decorate([property({type:Boolean,attribute:"data-table-toggle"})],LyraBoxPlot.prototype,"dataTableToggle",void 0),__decorate([state()],LyraBoxPlot.prototype,"dataTableExpandedOverride",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"valueFormatter",void 0),__decorate([property({attribute:!1})],LyraBoxPlot.prototype,"formatter",void 0),__decorate([state()],LyraBoxPlot.prototype,"loading",void 0),__decorate([state()],LyraBoxPlot.prototype,"loadFailed",void 0),__decorate([state()],LyraBoxPlot.prototype,"visible",void 0),__decorate([state()],LyraBoxPlot.prototype,"keyboardDatumAnnouncement",void 0),__decorate([query("canvas")],LyraBoxPlot.prototype,"canvasEl",void 0);export{LyraBoxPlot,loadBoxPlotAndRegister};
@@ -177,4 +177,32 @@ import{css}from"lit";import{forcedColorLegendSwatchStyles}from"./chart-forced-co
177
177
  max-inline-size: 100%;
178
178
  overflow-wrap: anywhere;
179
179
  }
180
+ [part='data-table-toggle'] {
181
+ align-self: flex-start;
182
+ font: inherit;
183
+ font-size: var(--lr-font-size-xs);
184
+ min-block-size: var(--lr-icon-button-size);
185
+ padding: var(--lr-size-0-15rem) var(--lr-size-0-5rem);
186
+ border: var(--lr-border-width-thin) solid var(--lr-color-border);
187
+ border-radius: var(--lr-radius);
188
+ background: var(--lr-color-surface);
189
+ color: var(--lr-color-text);
190
+ max-inline-size: 100%;
191
+ white-space: normal;
192
+ overflow-wrap: break-word;
193
+ cursor: pointer;
194
+ }
195
+ [part='data-table-toggle']:hover {
196
+ background: var(--lr-box-plot-data-table-toggle-hover-bg, var(--lr-color-brand-quiet));
197
+ }
198
+ [part='data-table-toggle']:active {
199
+ background: var(
200
+ --lr-box-plot-data-table-toggle-active-bg,
201
+ color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active))
202
+ );
203
+ }
204
+ [part='data-table-toggle']:focus-visible {
205
+ outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
206
+ outline-offset: var(--lr-focus-ring-offset);
207
+ }
180
208
  `;export{styles};
@@ -231,6 +231,7 @@ export interface LyraChartEventMap {
231
231
  * @csspart reset-zoom-button - The reset-zoom control when zoom is active.
232
232
  * @csspart description - The accessible chart summary.
233
233
  * @csspart data-table - The optional generated or slotted data table.
234
+ * @csspart data-table-toggle - The disclosure button rendered by `dataTableToggle`.
234
235
  * @csspart center - The chart-area-centered overlay wrapper for the `center` slot.
235
236
  * @csspart error - Static visible error shown instead of `canvas` when the optional `chart.js`
236
237
  * peer dependency is not installed; its transition is announced through a shared light-DOM alert.
@@ -260,6 +261,11 @@ export interface LyraChartEventMap {
260
261
  * of an actionable generated-table value.
261
262
  * @cssprop --lr-chart-data-table-button-active-bg - Pressed background of an actionable generated-
262
263
  * table value; defaults to the standard active mix of `--lr-color-brand-quiet`.
264
+ * @cssprop [--lr-chart-data-table-toggle-hover-bg=var(--lr-color-brand-quiet)] - Hover background
265
+ * of the `dataTableToggle` disclosure button.
266
+ * @cssprop --lr-chart-data-table-toggle-active-bg - Pressed background of the `dataTableToggle`
267
+ * disclosure button; defaults to a mix of the hover background with the shared active mix
268
+ * partner.
263
269
  * @cssprop [--lr-chart-reset-zoom-button-hover-bg=var(--lr-color-brand-quiet)] - Hover background
264
270
  * of the reset-zoom button.
265
271
  * @cssprop --lr-chart-reset-zoom-button-active-bg - Pressed background of the reset-zoom button;
@@ -380,6 +386,27 @@ export declare class LyraChart extends LyraElement<LyraChartEventMap> {
380
386
  beginAtZero: boolean;
381
387
  /** Makes the generated data table visible; it remains screen-reader available when false. */
382
388
  showDataTable: boolean;
389
+ /**
390
+ * Render a disclosure button above the accessible data table so a sighted reader can reveal the
391
+ * numbers behind the chart on demand. `showDataTable` alone is all-or-nothing -- the table is
392
+ * either permanently screen-reader-only or permanently visible -- which left a consumer wrapping
393
+ * a duplicated table in their own `<details>`.
394
+ *
395
+ * With this set, `showDataTable` becomes the disclosure's *initial* state rather than its whole
396
+ * behavior. The table stays in the DOM in both states, so assistive technology never loses it.
397
+ * @default false
398
+ */
399
+ dataTableToggle: boolean;
400
+ /**
401
+ * Live disclosure state. Null until the reader actually toggles, so an untouched control keeps
402
+ * following `showDataTable` (including a later change to it) instead of freezing a seeded copy.
403
+ */
404
+ private dataTableExpandedOverride;
405
+ private readonly dataTableId;
406
+ /** Whether the data table is currently visible. Identical to `showDataTable` whenever
407
+ * `dataTableToggle` is off, which is what keeps the unset path byte-identical to before. */
408
+ private get dataTableVisible();
409
+ private toggleDataTable;
383
410
  /** Stacks the `x`/`y`(/`y2`) scale entries `buildScales()` returns; only meaningful for `bar` and `line` types. */
384
411
  stacked: boolean;
385
412
  /** Disables Chart.js animation. */
@@ -1,6 +1,6 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult,loadChartJsWithAnnotationResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{resolveCanvasColor,resolveCanvasColors,seriesPalette,translucentAreaColor}from"./chart-colors.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartTypeBar,LYRA_DEFAULT_chartTypeBubble,LYRA_DEFAULT_chartTypeDoughnut,LYRA_DEFAULT_chartTypeLine,LYRA_DEFAULT_chartTypePie,LYRA_DEFAULT_chartTypePolarArea,LYRA_DEFAULT_chartTypeRadar,LYRA_DEFAULT_chartTypeScatter,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_liteChartMarkSummary,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_resetZoom,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";import{seriesPalette as seriesPalette2}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]),CHART_TYPE_MESSAGE_KEYS={line:"chartTypeLine",bar:"chartTypeBar",scatter:"chartTypeScatter",pie:"chartTypePie",doughnut:"chartTypeDoughnut",radar:"chartTypeRadar",polarArea:"chartTypePolarArea",bubble:"chartTypeBubble"};function normalizeChartType(value){return typeof value=="string"&&CHART_TYPES.has(value)?value:"bar"}function normalizeChartGrid(value){return value==="x"||value==="y"||value==="none"||value==="both"?value:"both"}function normalizeLegendPosition(value){return value==="left"||value==="top"||value==="right"||value==="bottom"||value==="center"||value==="chartArea"||value==="start"||value==="end"||value==="auto"||isPlainObject(value)&&Object.values(value).every(candidate=>typeof candidate=="number"&&Number.isFinite(candidate))?value:"top"}function isPlainObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]),FALLBACK_GRID_COLOR="#8a8a90",FALLBACK_TICK_COLOR="#6b7280",FALLBACK_LEGEND_COLOR="#1a1a1a",FALLBACK_TOOLTIP_BG="#fff",FALLBACK_TOOLTIP_TEXT="#1a1a1a";function deepMerge(base,override,seen=new WeakMap){if(typeof override=="object"&&override!==null){const previous=seen.get(override);if(previous!==void 0)return previous}if(!isPlainObject(base)||!isPlainObject(override))return override===void 0?base:override;const result={...base};seen.set(override,result);try{for(const key of Object.keys(override))UNSAFE_KEYS.has(key)||(result[key]=deepMerge(base[key],override[key],seen))}finally{seen.delete(override)}return result}function isChartPoint(value){return isPlainObject(value)?Number.isFinite(value.x)&&Number.isFinite(value.y):!1}function normalizedChartPoint(value){if(!isChartPoint(value))return null;const radius=value.r;return{x:value.x,y:value.y,...typeof radius=="number"&&Number.isFinite(radius)&&radius>=0?{r:radius}:{},...typeof value.label=="string"?{label:value.label}:{}}}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value){return value==null?"":Array.isArray(value)?value.map(labelText).join(" "):String(value)}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartStackTotalsUnavailable:LYRA_DEFAULT_chartStackTotalsUnavailable,chartSummary:LYRA_DEFAULT_chartSummary,chartSummaryEmpty:LYRA_DEFAULT_chartSummaryEmpty,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartSummaryWithData:LYRA_DEFAULT_chartSummaryWithData,chartTotal:LYRA_DEFAULT_chartTotal,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartTypeBar:LYRA_DEFAULT_chartTypeBar,chartTypeBubble:LYRA_DEFAULT_chartTypeBubble,chartTypeDoughnut:LYRA_DEFAULT_chartTypeDoughnut,chartTypeLine:LYRA_DEFAULT_chartTypeLine,chartTypePie:LYRA_DEFAULT_chartTypePie,chartTypePolarArea:LYRA_DEFAULT_chartTypePolarArea,chartTypeRadar:LYRA_DEFAULT_chartTypeRadar,chartTypeScatter:LYRA_DEFAULT_chartTypeScatter,chartValueLabel:LYRA_DEFAULT_chartValueLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,resetZoom:LYRA_DEFAULT_resetZoom,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.immutableEventDetails=Object.freeze(["lr-before-legend-visibility-change","lr-legend-visibility-change"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}constructor(){super(),this.type="bar",this.labels=[],this.datasets=[],this.description=null,this.grid="both",this.indexAxis="x",this.label=null,this.legendPosition="top",this.scaleType="linear",this.annotations=[],this.max=null,this.min=null,this.plugins=[],this.area=!1,this.zoom=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.beginAtZero=!0,this.showDataTable=!1,this.stacked=!1,this.withoutAnimation=!1,this.withoutLegend=!1,this.withoutTooltip=!1,this.dataLabels=!1,this.stackTotals=!1,this.loading=!0,this.loadFailed=!1,this.loadLibrary=withZoom=>withZoom?loadChartJsWithZoom():loadChartJs(),this.loadZoomFeature=()=>loadChartJsWithZoomResult(),this.loadDataLabelsFeature=()=>loadChartJsWithDataLabelsResult(),this.loadAnnotationFeature=()=>loadChartJsWithAnnotationResult(),this.loadGeneration=0,this.zoomLoadGeneration=0,this.dataLabelsLoadGeneration=0,this.annotationLoadGeneration=0,this.zoomFeatureState="idle",this.dataLabelsFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.onReducedMotionChange=()=>{!this.isConnected||this.ownerWindow!==this.reducedMotionWindow||this.drawIfVisible()},new ThemeWatcher(this,()=>{this.chart&&this.refreshTheme()})}normalizeEffectiveConfig(config){return config}effectiveConfig(){return this.normalizeEffectiveConfig(this.config??this.slottedConfig)}onConfigSlotChange(event){const script=event.currentTarget.assignedElements({flatten:!0}).find(element=>element.localName==="script"&&element.type.trim().toLowerCase()==="application/json");let next;if(script)try{const parsed=JSON.parse(script.textContent??"");isPlainObject(parsed)&&(next=parsed)}catch{next=void 0}this.slottedConfig=next}effectiveData(){const generated={labels:this.labels,datasets:this.datasets.map(series=>({...series,data:[...series.points??series.data??[]],yAxisID:series.axis==="y2"?"y2":"y"}))},override=this.effectiveConfig()?.data,merged=isPlainObject(override)?deepMerge(generated,override):generated;return{labels:Array.isArray(merged.labels)?merged.labels:[],datasets:Array.isArray(merged.datasets)?merged.datasets.filter(isPlainObject):[]}}effectiveHiddenDatasetIndexes(){const effective=this.effectiveData(),controlled=normalizeHiddenDatasets(this.hiddenDatasets,effective.datasets.length);return controlled!==void 0?controlled:effective.datasets.flatMap((dataset,index)=>dataset.hidden===!0?[index]:[])}applyDatasetVisibility(){if(!this.chart)return!1;const datasetCount=this.chart.data.datasets?.length??0,sourceDatasetCount=this.effectiveData().datasets.length,controlled=normalizeHiddenDatasets(this.hiddenDatasets,sourceDatasetCount);if(controlled===void 0){for(let index=0;index<datasetCount;index++){const metadata=this.chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++){const sourceIndex=this.visualDatasetSourceIndexes?.[index]??index;this.chart.setDatasetVisibility(index,!hidden.has(sourceIndex))}return datasetCount>0}hasExplicitConfigData(){const config=this.effectiveConfig();return isPlainObject(config)&&Object.prototype.hasOwnProperty.call(config,"data")}datasetLabel(dataset,index){return labelText(dataset.label)||this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(index+1)})}datasetValues(dataset){return Array.isArray(dataset.data)?dataset.data:[]}isPointDataset(dataset){const values=this.datasetValues(dataset);return this.effectiveType()==="scatter"||this.effectiveType()==="bubble"||values.some(isChartPoint)}appendData(label,values,maxPoints=0){const limit=Number.isFinite(maxPoints)?Math.max(0,Math.floor(maxPoints)):0;if(this.hasExplicitConfigData()){const effective=this.effectiveData();let domainLength2=effective.labels.length;for(const dataset of effective.datasets)this.isPointDataset(dataset)||(domainLength2=Math.max(domainLength2,this.datasetValues(dataset).length));const labels2=[...effective.labels,...Array.from({length:Math.max(0,domainLength2-effective.labels.length)},()=>""),label],effectiveConfig=this.effectiveConfig(),currentData=isPlainObject(effectiveConfig?.data)?effectiveConfig.data:{},explicitLabels=Array.isArray(currentData.labels),explicitDatasets=Array.isArray(currentData.datasets),nextLabels=limit>0?labels2.slice(-limit):labels2;if(explicitLabels||(this.labels=nextLabels.map(labelText)),!explicitDatasets){const datasets2=this.datasets.map((series,index)=>{if(series.points)return series;const current=series.data??[],data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...series,data:limit>0?data.slice(-limit):data}});this.datasets=datasets2}if(explicitLabels||explicitDatasets){const nextData={...currentData};explicitLabels&&(nextData.labels=nextLabels),explicitDatasets&&(nextData.datasets=effective.datasets.map((dataset,index)=>{if(this.isPointDataset(dataset))return dataset;const current=this.datasetValues(dataset),data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...dataset,data:limit>0?data.slice(-limit):data}})),this.config={...effectiveConfig,data:nextData}}return}let domainLength=this.labels.length;for(const series of this.datasets)series.points||(domainLength=Math.max(domainLength,series.data?.length??0));const labels=[...this.labels,...Array.from({length:Math.max(0,domainLength-this.labels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>series.points?series:{...series,data:[...series.data??[],...Array.from({length:Math.max(0,domainLength-(series.data?.length??0))},()=>null),values[index]??null]});this.labels=limit>0?labels.slice(-limit):labels,this.datasets=limit>0?datasets.map(series=>series.points?series:{...series,data:series.data?.slice(-limit)}):datasets}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const effective=this.effectiveData(),columns=effective.datasets.map((dataset,datasetIndex)=>{const values=this.datasetValues(dataset),label=this.datasetLabel(dataset,datasetIndex),points=values.filter(isChartPoint);return{dataset,label,point:this.isPointDataset(dataset),radius:points.some(point=>point.r!=null),pointLabel:points.some(point=>point.label!=null)}}),header=["label",...columns.flatMap(column=>column.point?[`${column.label} x`,`${column.label} y`,...column.radius?[`${column.label} r`]:[],...column.pointLabel?[`${column.label} label`]:[]]:[column.label])].map(escapeCsvField).join(",");let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const exportCell=value=>typeof value!="number"||!Number.isFinite(value)?value??"":this.formatExportValue(value)??value,rows=Array.from({length:rowCount},(_,index)=>{const firstPoint=effective.datasets.map(dataset=>this.datasetValues(dataset)[index]).find(isChartPoint);return[labelText(effective.labels[index])||firstPoint?.label||"",...columns.flatMap(column=>{const value=this.datasetValues(column.dataset)[index];return column.point?isChartPoint(value)?[exportCell(value.x),exportCell(value.y),...column.radius?[value.r==null?"":exportCell(value.r)]:[],...column.pointLabel?[value.label??""]:[]]:["","",...column.radius?[""]:[],...column.pointLabel?[""]:[]]:[exportCell(value)]})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult,loadChartJsWithAnnotationResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{trueDefaultBooleanFromAttributeConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{resolveCanvasColor,resolveCanvasColors,seriesPalette,translucentAreaColor}from"./chart-colors.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartTypeBar,LYRA_DEFAULT_chartTypeBubble,LYRA_DEFAULT_chartTypeDoughnut,LYRA_DEFAULT_chartTypeLine,LYRA_DEFAULT_chartTypePie,LYRA_DEFAULT_chartTypePolarArea,LYRA_DEFAULT_chartTypeRadar,LYRA_DEFAULT_chartTypeScatter,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_liteChartMarkSummary,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_resetZoom,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";import{seriesPalette as seriesPalette2}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]),CHART_TYPE_MESSAGE_KEYS={line:"chartTypeLine",bar:"chartTypeBar",scatter:"chartTypeScatter",pie:"chartTypePie",doughnut:"chartTypeDoughnut",radar:"chartTypeRadar",polarArea:"chartTypePolarArea",bubble:"chartTypeBubble"};function normalizeChartType(value){return typeof value=="string"&&CHART_TYPES.has(value)?value:"bar"}function normalizeChartGrid(value){return value==="x"||value==="y"||value==="none"||value==="both"?value:"both"}function normalizeLegendPosition(value){return value==="left"||value==="top"||value==="right"||value==="bottom"||value==="center"||value==="chartArea"||value==="start"||value==="end"||value==="auto"||isPlainObject(value)&&Object.values(value).every(candidate=>typeof candidate=="number"&&Number.isFinite(candidate))?value:"top"}function isPlainObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]),FALLBACK_GRID_COLOR="#8a8a90",FALLBACK_TICK_COLOR="#6b7280",FALLBACK_LEGEND_COLOR="#1a1a1a",FALLBACK_TOOLTIP_BG="#fff",FALLBACK_TOOLTIP_TEXT="#1a1a1a";function deepMerge(base,override,seen=new WeakMap){if(typeof override=="object"&&override!==null){const previous=seen.get(override);if(previous!==void 0)return previous}if(!isPlainObject(base)||!isPlainObject(override))return override===void 0?base:override;const result={...base};seen.set(override,result);try{for(const key of Object.keys(override))UNSAFE_KEYS.has(key)||(result[key]=deepMerge(base[key],override[key],seen))}finally{seen.delete(override)}return result}function isChartPoint(value){return isPlainObject(value)?Number.isFinite(value.x)&&Number.isFinite(value.y):!1}function normalizedChartPoint(value){if(!isChartPoint(value))return null;const radius=value.r;return{x:value.x,y:value.y,...typeof radius=="number"&&Number.isFinite(radius)&&radius>=0?{r:radius}:{},...typeof value.label=="string"?{label:value.label}:{}}}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value){return value==null?"":Array.isArray(value)?value.map(labelText).join(" "):String(value)}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartStackTotalsUnavailable:LYRA_DEFAULT_chartStackTotalsUnavailable,chartSummary:LYRA_DEFAULT_chartSummary,chartSummaryEmpty:LYRA_DEFAULT_chartSummaryEmpty,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartSummaryWithData:LYRA_DEFAULT_chartSummaryWithData,chartTotal:LYRA_DEFAULT_chartTotal,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartTypeBar:LYRA_DEFAULT_chartTypeBar,chartTypeBubble:LYRA_DEFAULT_chartTypeBubble,chartTypeDoughnut:LYRA_DEFAULT_chartTypeDoughnut,chartTypeLine:LYRA_DEFAULT_chartTypeLine,chartTypePie:LYRA_DEFAULT_chartTypePie,chartTypePolarArea:LYRA_DEFAULT_chartTypePolarArea,chartTypeRadar:LYRA_DEFAULT_chartTypeRadar,chartTypeScatter:LYRA_DEFAULT_chartTypeScatter,chartValueLabel:LYRA_DEFAULT_chartValueLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,resetZoom:LYRA_DEFAULT_resetZoom,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.immutableEventDetails=Object.freeze(["lr-before-legend-visibility-change","lr-legend-visibility-change"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}constructor(){super(),this.type="bar",this.labels=[],this.datasets=[],this.description=null,this.grid="both",this.indexAxis="x",this.label=null,this.legendPosition="top",this.scaleType="linear",this.annotations=[],this.max=null,this.min=null,this.plugins=[],this.area=!1,this.zoom=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.beginAtZero=!0,this.showDataTable=!1,this.dataTableToggle=!1,this.dataTableExpandedOverride=null,this.dataTableId=nextId("chart-data-table"),this.stacked=!1,this.withoutAnimation=!1,this.withoutLegend=!1,this.withoutTooltip=!1,this.dataLabels=!1,this.stackTotals=!1,this.loading=!0,this.loadFailed=!1,this.loadLibrary=withZoom=>withZoom?loadChartJsWithZoom():loadChartJs(),this.loadZoomFeature=()=>loadChartJsWithZoomResult(),this.loadDataLabelsFeature=()=>loadChartJsWithDataLabelsResult(),this.loadAnnotationFeature=()=>loadChartJsWithAnnotationResult(),this.loadGeneration=0,this.zoomLoadGeneration=0,this.dataLabelsLoadGeneration=0,this.annotationLoadGeneration=0,this.zoomFeatureState="idle",this.dataLabelsFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.onReducedMotionChange=()=>{!this.isConnected||this.ownerWindow!==this.reducedMotionWindow||this.drawIfVisible()},new ThemeWatcher(this,()=>{this.chart&&this.refreshTheme()})}get dataTableVisible(){return this.dataTableToggle?this.dataTableExpandedOverride??this.showDataTable:this.showDataTable}toggleDataTable(){this.dataTableExpandedOverride=!this.dataTableVisible}normalizeEffectiveConfig(config){return config}effectiveConfig(){return this.normalizeEffectiveConfig(this.config??this.slottedConfig)}onConfigSlotChange(event){const script=event.currentTarget.assignedElements({flatten:!0}).find(element=>element.localName==="script"&&element.type.trim().toLowerCase()==="application/json");let next;if(script)try{const parsed=JSON.parse(script.textContent??"");isPlainObject(parsed)&&(next=parsed)}catch{next=void 0}this.slottedConfig=next}effectiveData(){const generated={labels:this.labels,datasets:this.datasets.map(series=>({...series,data:[...series.points??series.data??[]],yAxisID:series.axis==="y2"?"y2":"y"}))},override=this.effectiveConfig()?.data,merged=isPlainObject(override)?deepMerge(generated,override):generated;return{labels:Array.isArray(merged.labels)?merged.labels:[],datasets:Array.isArray(merged.datasets)?merged.datasets.filter(isPlainObject):[]}}effectiveHiddenDatasetIndexes(){const effective=this.effectiveData(),controlled=normalizeHiddenDatasets(this.hiddenDatasets,effective.datasets.length);return controlled!==void 0?controlled:effective.datasets.flatMap((dataset,index)=>dataset.hidden===!0?[index]:[])}applyDatasetVisibility(){if(!this.chart)return!1;const datasetCount=this.chart.data.datasets?.length??0,sourceDatasetCount=this.effectiveData().datasets.length,controlled=normalizeHiddenDatasets(this.hiddenDatasets,sourceDatasetCount);if(controlled===void 0){for(let index=0;index<datasetCount;index++){const metadata=this.chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++){const sourceIndex=this.visualDatasetSourceIndexes?.[index]??index;this.chart.setDatasetVisibility(index,!hidden.has(sourceIndex))}return datasetCount>0}hasExplicitConfigData(){const config=this.effectiveConfig();return isPlainObject(config)&&Object.prototype.hasOwnProperty.call(config,"data")}datasetLabel(dataset,index){return labelText(dataset.label)||this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(index+1)})}datasetValues(dataset){return Array.isArray(dataset.data)?dataset.data:[]}isPointDataset(dataset){const values=this.datasetValues(dataset);return this.effectiveType()==="scatter"||this.effectiveType()==="bubble"||values.some(isChartPoint)}appendData(label,values,maxPoints=0){const limit=Number.isFinite(maxPoints)?Math.max(0,Math.floor(maxPoints)):0;if(this.hasExplicitConfigData()){const effective=this.effectiveData();let domainLength2=effective.labels.length;for(const dataset of effective.datasets)this.isPointDataset(dataset)||(domainLength2=Math.max(domainLength2,this.datasetValues(dataset).length));const labels2=[...effective.labels,...Array.from({length:Math.max(0,domainLength2-effective.labels.length)},()=>""),label],effectiveConfig=this.effectiveConfig(),currentData=isPlainObject(effectiveConfig?.data)?effectiveConfig.data:{},explicitLabels=Array.isArray(currentData.labels),explicitDatasets=Array.isArray(currentData.datasets),nextLabels=limit>0?labels2.slice(-limit):labels2;if(explicitLabels||(this.labels=nextLabels.map(labelText)),!explicitDatasets){const datasets2=this.datasets.map((series,index)=>{if(series.points)return series;const current=series.data??[],data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...series,data:limit>0?data.slice(-limit):data}});this.datasets=datasets2}if(explicitLabels||explicitDatasets){const nextData={...currentData};explicitLabels&&(nextData.labels=nextLabels),explicitDatasets&&(nextData.datasets=effective.datasets.map((dataset,index)=>{if(this.isPointDataset(dataset))return dataset;const current=this.datasetValues(dataset),data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),values[index]??null];return{...dataset,data:limit>0?data.slice(-limit):data}})),this.config={...effectiveConfig,data:nextData}}return}let domainLength=this.labels.length;for(const series of this.datasets)series.points||(domainLength=Math.max(domainLength,series.data?.length??0));const labels=[...this.labels,...Array.from({length:Math.max(0,domainLength-this.labels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>series.points?series:{...series,data:[...series.data??[],...Array.from({length:Math.max(0,domainLength-(series.data?.length??0))},()=>null),values[index]??null]});this.labels=limit>0?labels.slice(-limit):labels,this.datasets=limit>0?datasets.map(series=>series.points?series:{...series,data:series.data?.slice(-limit)}):datasets}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const effective=this.effectiveData(),columns=effective.datasets.map((dataset,datasetIndex)=>{const values=this.datasetValues(dataset),label=this.datasetLabel(dataset,datasetIndex),points=values.filter(isChartPoint);return{dataset,label,point:this.isPointDataset(dataset),radius:points.some(point=>point.r!=null),pointLabel:points.some(point=>point.label!=null)}}),header=["label",...columns.flatMap(column=>column.point?[`${column.label} x`,`${column.label} y`,...column.radius?[`${column.label} r`]:[],...column.pointLabel?[`${column.label} label`]:[]]:[column.label])].map(escapeCsvField).join(",");let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const exportCell=value=>typeof value!="number"||!Number.isFinite(value)?value??"":this.formatExportValue(value)??value,rows=Array.from({length:rowCount},(_,index)=>{const firstPoint=effective.datasets.map(dataset=>this.datasetValues(dataset)[index]).find(isChartPoint);return[labelText(effective.labels[index])||firstPoint?.label||"",...columns.flatMap(column=>{const value=this.datasetValues(column.dataset)[index];return column.point?isChartPoint(value)?[exportCell(value.x),exportCell(value.y),...column.radius?[value.r==null?"":exportCell(value.r)]:[],...column.pointLabel?[value.label??""]:[]]:["","",...column.radius?[""]:[],...column.pointLabel?[""]:[]]:[exportCell(value)]})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
2
2
  `)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSinks(),this.visible=!0,this.armReducedMotionWatcher();const ownerWindow=this.ownerWindow,ResizeObserverCtor=ownerWindow?.ResizeObserver;ResizeObserverCtor&&(this.resizeObserver=new ResizeObserverCtor(entries=>{const width=entries[0]?.contentRect.width??this.getBoundingClientRect().width;if(Number.isFinite(width)&&this.lastObservedInlineSize!==void 0&&Math.abs(width-this.lastObservedInlineSize)<.5||(this.lastObservedInlineSize=width,this.resizeDrawFrame!==void 0))return;const frameOwner=this.ownerWindow;frameOwner&&(this.resizeDrawFrameOwner=frameOwner,this.resizeDrawFrame=frameOwner.requestAnimationFrame(()=>{this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,!(!this.isConnected||this.ownerWindow!==frameOwner)&&(this.updateAutoLegendPosition()||this.drawIfVisible())}))}),this.resizeObserver.observe(this)),this.updateAutoLegendPosition();const generation=++this.loadGeneration;this.zoom&&this.requestZoomFeature(),this.loadLibrary(this.zoom).then(async mod=>{try{await this.updateComplete}catch{return}if(await new Promise(resolve=>this.updateBrowserDerivedState(resolve)),!(generation!==this.loadGeneration||!this.isConnected)){if(this.loading=!1,!mod){this.loadFailed=!0;return}this.loadFailed=!1,this.chartJsModule=mod,this.drawIfVisible()}}),this.needsDataLabels&&this.requestDataLabelsFeature(),this.needsAnnotations&&this.requestAnnotationFeature();const IntersectionObserverCtor=ownerWindow?.IntersectionObserver;if(IntersectionObserverCtor){const observerGeneration=++this.intersectionGeneration,observer=new IntersectionObserverCtor(entries=>{if(observerGeneration!==this.intersectionGeneration||this.intersectionObserver!==observer||!this.isConnected||this.ownerWindow!==ownerWindow)return;const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.drawIfVisible()});this.intersectionObserver=observer,observer.observe(this)}}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSinks(),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings.clear(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.resizeDrawFrame!==void 0&&this.resizeDrawFrameOwner?.cancelAnimationFrame(this.resizeDrawFrame),this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,this.lastObservedInlineSize=void 0,this.loadGeneration+=1,this.zoomLoadGeneration+=1,this.dataLabelsLoadGeneration+=1,this.discardChart(!1),this.builtPlugins=[],this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.intersectionGeneration+=1,this.visible=!0,this.disarmReducedMotionWatcher()}adoptedCallback(){super.adoptedCallback(),this.releaseAnnouncementSinks(),this.syncAnnouncementSinks(),this.armReducedMotionWatcher()}armReducedMotionWatcher(){const ownerWindow=this.ownerWindow;ownerWindow?.matchMedia&&(this.reducedMotionWindow===ownerWindow&&this.reducedMotionQuery||(this.disarmReducedMotionWatcher(),this.reducedMotionWindow=ownerWindow,this.reducedMotionQuery=ownerWindow.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedMotionQuery.addEventListener("change",this.onReducedMotionChange)))}disarmReducedMotionWatcher(){this.reducedMotionQuery?.removeEventListener("change",this.onReducedMotionChange),this.reducedMotionQuery=void 0,this.reducedMotionWindow=void 0}syncAnnouncementSinks(){!this.isConnected||this.politeAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.assertiveAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.releaseAnnouncementSinks(),this.politeAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}))}releaseAnnouncementSinks(){this.politeAnnouncementSink?.release(),this.politeAnnouncementSink=void 0,this.assertiveAnnouncementSink?.release(),this.assertiveAnnouncementSink=void 0}get ownerWindow(){return this.ownerDocument?.defaultView??void 0}computedStyle(element=this){const view=this.ownerWindow;return view?view.getComputedStyle(element):"style"in element?element.style:this.style}applyDataLabelsPlugin(plugin){this.dataLabelsPlugin=plugin;let rebuilt=!1;plugin&&this.needsDataLabels&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[],rebuilt=!0),this.drawIfVisible(),rebuilt&&this.showsLegend&&this.requestUpdate()}get zoomFeatureAvailable(){return this.zoom&&this.zoomFeatureState==="available"}featureWarningMessages(){if(this.loading||this.loadFailed)return[];const messages=[];return this.zoom&&this.zoomFeatureState==="unavailable"&&messages.push(this.localize("chartZoomUnavailable")),this.dataLabelsFeatureState==="unavailable"&&(this.dataLabels&&messages.push(this.localize("chartDataLabelsUnavailable")),this.stackTotals&&messages.push(this.localize("chartStackTotalsUnavailable"))),messages}requestZoomFeature(){const generation=++this.zoomLoadGeneration;if(!this.zoom){this.zoomFeatureState="idle";return}this.zoomFeatureState="loading",this.loadZoomFeature().then(result=>{generation!==this.zoomLoadGeneration||!this.isConnected||!this.zoom||(this.zoomFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.drawIfVisible(),this.requestUpdate())})}requestAnnotationFeature(){const generation=++this.annotationLoadGeneration;this.needsAnnotations&&this.loadAnnotationFeature().then(result=>{generation!==this.annotationLoadGeneration||!this.isConnected||!this.needsAnnotations||(result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.applyAnnotationPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}applyAnnotationPlugin(plugin){this.annotationPlugin=plugin,plugin&&this.needsAnnotations&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[]),this.drawIfVisible()}requestDataLabelsFeature(){const generation=++this.dataLabelsLoadGeneration;if(!this.needsDataLabels){this.dataLabelsFeatureState="idle";return}this.dataLabelsFeatureState="loading",this.loadDataLabelsFeature().then(result=>{generation!==this.dataLabelsLoadGeneration||!this.isConnected||!this.needsDataLabels||(this.dataLabelsFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.applyDataLabelsPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}willUpdate(changed){super.willUpdate(changed),this.zoomed&&this.effectiveType()!==this.builtType&&(this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1}))}updated(changed){if(super.updated(changed),!this.isConnected)return;const wasMounting=this.isMounting;this.isMounting=!1,changed.has("keyboardDatumAnnouncement")&&changed.get("keyboardDatumAnnouncement")!==void 0&&this.keyboardDatumAnnouncement!==""&&this.politeAnnouncementSink?.announce(this.keyboardDatumAnnouncement),changed.has("loadFailed")&&changed.get("loadFailed")!==void 0&&this.loadFailed&&this.assertiveAnnouncementSink?.announce(this.localize("chartMissingLibrary"));const dataTruncation=this.dataTruncationMessage();if(wasMounting&&(this.lastDataTruncationAnnouncement=dataTruncation),!this.loading&&!this.loadFailed){const featureWarnings=this.featureWarningMessages();for(const warning of featureWarnings)this.announcedFeatureWarnings.has(warning)||this.assertiveAnnouncementSink?.announce(warning);this.announcedFeatureWarnings=new Set(featureWarnings),!wasMounting&&dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.politeAnnouncementSink?.announce(dataTruncation))}if(this.setAttribute("aria-busy",String(this.loading)),changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}if(this.loading)return;changed.has("zoom")&&this.requestZoomFeature(),(changed.has("dataLabels")||changed.has("stackTotals"))&&this.requestDataLabelsFeature(),changed.has("annotations")&&this.requestAnnotationFeature();const contentChanged=this.chartContentChanged(changed),effectiveDirection=this.effectiveDirection,effectiveLocale=this.effectiveLocale,contextChanged=this.lastDrawnDirection!==void 0&&this.lastDrawnDirection!==effectiveDirection||this.lastDrawnLocale!==void 0&&this.lastDrawnLocale!==effectiveLocale;this.lastDrawnDirection=effectiveDirection,this.lastDrawnLocale=effectiveLocale,!(!contentChanged&&!contextChanged)&&this.drawIfVisible()}chartContentChanged(changed){return["type","labels","datasets","hiddenDatasets","description","grid","indexAxis","label","legendPosition","min","max","plugins","autoLegendPosition","valueFormatter","formatter","area","height","xLabel","yLabel","y2Label","beginAtZero","stacked","withoutAnimation","withoutLegend","withoutTooltip","dataLabels","stackTotals","config","slottedConfig","zoom","locale","strings","loading"].some(name=>changed.has(name))}seriesToDataset(s,index,palette,effectiveType,chartStyle=this.chartStyleOptions(palette),rowIndexes){const fullNormalizedData=s.points?s.points.map(normalizedChartPoint):(s.data??[]).map(value=>typeof value=="number"&&Number.isFinite(value)?value:null),normalizedData=rowIndexes?rowIndexes.map(rowIndex=>fullNormalizedData[rowIndex]??null):fullNormalizedData,borderFallback=chartStyle.borderColors[index%chartStyle.borderColors.length]??palette[index%palette.length],fillFallback=chartStyle.fillColors[index%chartStyle.fillColors.length]??palette[index%palette.length],authoredColors=Array.isArray(s.color)&&rowIndexes?rowIndexes.map(rowIndex=>s.color[rowIndex]??""):s.color,colors=typeof authoredColors=="string"?[resolveCanvasColor(this,authoredColors,borderFallback??"transparent")]:authoredColors?resolveCanvasColors(this,authoredColors,borderFallback??"transparent"):void 0,sliceChart=effectiveType==="pie"||effectiveType==="doughnut"||effectiveType==="polarArea",sliceFillColors=sliceChart&&chartStyle.fillColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.fillColors[sourceIndex%chartStyle.fillColors.length]}):void 0,sliceBorderColors=sliceChart&&chartStyle.borderColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.borderColors[sourceIndex%chartStyle.borderColors.length]}):void 0,fill=s.fill??this.area,backgroundColor=colors??sliceFillColors??fillFallback,datasetType=s.type??effectiveType,authoredSegmentColors=s.segmentColors&&rowIndexes?rowIndexes.map(rowIndex=>s.segmentColors[rowIndex]??""):s.segmentColors,segmentColors=authoredSegmentColors?resolveCanvasColors(this,authoredSegmentColors,colors?.[0]??borderFallback??"transparent"):void 0,authoredPointColors=s.pointColors&&rowIndexes?rowIndexes.map(rowIndex=>s.pointColors[rowIndex]??""):s.pointColors,resolvedBackgroundColor=datasetType==="line"&&fill&&(colors||!chartStyle.authoredFillColors[index%chartStyle.authoredFillColors.length])?Array.isArray(backgroundColor)?backgroundColor.map(color=>translucentAreaColor(this,color)):backgroundColor&&translucentAreaColor(this,backgroundColor):backgroundColor,encoding=forcedColorEncoding(index),encodedBackgroundColor=chartStyle.forcedColors?Array.isArray(resolvedBackgroundColor)?resolvedBackgroundColor.map((color,itemIndex)=>this.forcedColorPattern(sliceChart?itemIndex:index,color)):resolvedBackgroundColor&&this.forcedColorPattern(index,resolvedBackgroundColor):resolvedBackgroundColor,pointRadii=Array.isArray(s.pointRadius)?s.pointRadius:void 0;return{label:s.label,data:normalizedData,type:s.type,fill,borderRadius:chartStyle.borderRadius,borderWidth:nonNegativeFinite(s.width,datasetType==="line"?chartStyle.lineBorderWidth:chartStyle.borderWidth),borderDash:s.dash?[4,4]:chartStyle.forcedColors?[...encoding.dash]:void 0,pointStyle:chartStyle.forcedColors?encoding.pointStyle:void 0,backgroundColor:encodedBackgroundColor,borderColor:colors?.[0]??sliceBorderColors??borderFallback,pointBackgroundColor:authoredPointColors?resolveCanvasColors(this,authoredPointColors,colors?.[0]??borderFallback??"transparent"):void 0,pointRadius:pointRadii?(rowIndexes?rowIndexes.map(rowIndex=>pointRadii[rowIndex]):pointRadii).map(radius=>nonNegativeFinite(radius,chartStyle.pointRadius)):nonNegativeFinite(s.pointRadius,chartStyle.pointRadius),...segmentColors?.length?{segment:{borderColor:ctx=>segmentColors[ctx.p0DataIndex%segmentColors.length]}}:{},yAxisID:s.axis==="y2"?"y2":"y"}}themeColors(){const cs=this.computedStyle(),grid=cs.getPropertyValue("--grid-color").trim()||cs.getPropertyValue("--lr-chart-grid-color").trim()||cs.getPropertyValue("--_lr-chart-grid-color").trim(),tick=cs.getPropertyValue("--lr-chart-tick-color").trim()||cs.getPropertyValue("--_lr-chart-tick-color").trim(),legend=cs.getPropertyValue("--lr-chart-legend-color").trim()||cs.getPropertyValue("--_lr-chart-legend-color").trim(),tooltipBg=cs.getPropertyValue("--lr-chart-tooltip-bg").trim()||cs.getPropertyValue("--_lr-chart-tooltip-bg").trim(),tooltipText=cs.getPropertyValue("--lr-chart-tooltip-text").trim()||cs.getPropertyValue("--_lr-chart-tooltip-text").trim();return{grid:resolveCanvasColor(this,grid,FALLBACK_GRID_COLOR),tick:resolveCanvasColor(this,tick,FALLBACK_TICK_COLOR),legend:resolveCanvasColor(this,legend,FALLBACK_LEGEND_COLOR),tooltipBg:resolveCanvasColor(this,tooltipBg,FALLBACK_TOOLTIP_BG),tooltipText:resolveCanvasColor(this,tooltipText,FALLBACK_TOOLTIP_TEXT)}}styleColor(name,fallback){const value=this.computedStyle().getPropertyValue(name).trim();return value?resolveCanvasColor(this,value,fallback):fallback}styleNumber(name,fallbackToken,fallback){const computed=this.computedStyle(),value=computed.getPropertyValue(name).trim()||computed.getPropertyValue(fallbackToken).trim(),direct=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(?:px)?$/i.exec(value);if(direct){const resolved=Number.parseFloat(direct[1]);if(Number.isFinite(resolved)&&resolved>=0)return resolved}if(!value||!this.ownerWindow)return fallback;const probe=this.ownerDocument.createElement("span");probe.hidden=!0,probe.setAttribute("aria-hidden","true"),probe.style.inlineSize=value,(this.shadowRoot??this).append(probe);try{const resolved=Number.parseFloat(this.computedStyle(probe).inlineSize);return Number.isFinite(resolved)&&resolved>=0?resolved:fallback}finally{probe.remove()}}forcedColorPattern(index,background){return this.ownerWindow?createForcedColorPattern(this.ownerDocument,index,background,this.styleColor("--lr-color-surface",FALLBACK_TOOLTIP_BG)):background}chartStyleOptions(palette){const computed=this.computedStyle(),authoredFillColors=palette.map((_,index)=>index<6&&!!computed.getPropertyValue(`--fill-color-${index+1}`).trim()),borderColors=palette.map((fallback,index)=>index<6?this.styleColor(`--border-color-${index+1}`,fallback):fallback),fillColors=palette.map((fallback,index)=>index<6?this.styleColor(`--fill-color-${index+1}`,fallback):fallback);return{borderColors,fillColors,authoredFillColors,borderRadius:this.styleNumber("--border-radius","--lr-radius",6),borderWidth:this.styleNumber("--border-width","--lr-border-width-thin",1),gridBorderWidth:this.styleNumber("--grid-border-width","--lr-border-width-thin",1),lineBorderWidth:this.styleNumber("--line-border-width","--lr-border-width-medium",2),pointRadius:this.styleNumber("--point-radius","--lr-space-2xs",4),forcedColors:forcedColorsActive(this.ownerWindow)}}get needsDataLabels(){return this.dataLabels||this.stackTotals}get needsAnnotations(){return this.normalizedAnnotations().length>0}normalizedAnnotations(){const source=Array.isArray(this.annotations)?this.annotations:[],usable=[];for(const entry of source){if(!entry||typeof entry!="object")continue;const{value,from,to}=entry;if(typeof value=="number"&&Number.isFinite(value)){usable.push(entry);continue}typeof from=="number"&&Number.isFinite(from)&&typeof to=="number"&&Number.isFinite(to)&&usable.push(from<=to?entry:{...entry,from:to,to:from})}return usable}annotationColor(tone){const token=`--lr-color-${tone??"neutral"}`,raw=this.computedStyle().getPropertyValue(token).trim();return resolveCanvasColor(this,raw,FALLBACK_TICK_COLOR)}annotationOptions(){const entries={};return this.normalizedAnnotations().forEach((entry,index)=>{const axis=entry.axis==="x"?"x":"y",color=this.annotationColor(entry.tone),label=entry.label?{content:entry.label,display:!0,color:this.themeColors().tick}:void 0;if(typeof entry.value=="number"){entries[`lr-annotation-${index}`]={type:"line",scaleID:axis,value:entry.value,borderColor:color,borderWidth:2,...label?{label}:{}};return}const bounds=axis==="y"?{yMin:entry.from,yMax:entry.to}:{xMin:entry.from,xMax:entry.to};entries[`lr-annotation-${index}`]={type:"box",...bounds,backgroundColor:translucentAreaColor(this,color),borderColor:color,borderWidth:0,...label?{label}:{}}}),entries}datalabelsOptions(theme,effectiveType){if(!this.needsDataLabels)return{display:!1};const datasets=this.effectiveData().datasets,stackTotalsActive=this.stackTotals&&this.stacked&&(effectiveType==="bar"||effectiveType==="line"),topDatasetIndexByAxis=new Map;stackTotalsActive&&datasets.forEach((dataset,index)=>topDatasetIndexByAxis.set(dataset.yAxisID==="y2"||dataset.axis==="y2"?"y2":"y",index));const totalsByAxis=stackTotalsActive?{y:this.computeStackTotals("y"),y2:this.computeStackTotals("y2")}:void 0;return{color:theme.tick,align:stackTotalsActive?"end":"center",anchor:stackTotalsActive?"end":"center",display:context=>{const datasetIndex=context.datasetIndex,dataset=datasets[datasetIndex],axis=dataset?.yAxisID==="y2"||dataset?.axis==="y2"?"y2":"y";return stackTotalsActive?topDatasetIndexByAxis.get(axis)!==datasetIndex?this.dataLabels:totalsByAxis?.[axis][context.dataIndex]==null?this.dataLabels:!0:this.dataLabels},formatter:(value,context)=>{const datasetIndex=context.datasetIndex,dataset=datasets[datasetIndex],axis=dataset?.yAxisID==="y2"||dataset?.axis==="y2"?"y2":"y";if(stackTotalsActive&&topDatasetIndexByAxis.get(axis)===datasetIndex){const total=totalsByAxis?.[axis][context.dataIndex];if(total!=null)return this.formatDataLabel(total)}const numeric=typeof value=="number"?value:Number(value?.y??value);return numeric==null||!Number.isFinite(numeric)?"":this.formatDataLabel(numeric)}}}formatDataLabel(value){if(this.formatter||this.valueFormatter){const formatted=this.formatter?.({value,surface:"visual"})??this.valueFormatter?.(value,"tooltip");if(formatted!=null)return String(formatted)}return value.toLocaleString(this.effectiveLocale)}computeStackTotals(axisId="y"){const effective=this.effectiveData(),members=effective.datasets.filter(dataset=>(dataset.yAxisID==="y2"||dataset.axis==="y2"?"y2":"y")===axisId),categoryCount=members.reduce((max,dataset)=>Math.max(max,this.datasetValues(dataset).length),effective.labels.length),totals=[];for(let i=0;i<categoryCount;i++){let sum=0,any=!1;for(const dataset of members){const value=this.datasetValues(dataset)[i],numeric=isChartPoint(value)?value.y:value;numeric==null||!Number.isFinite(numeric)||(sum=finiteAdd(sum,numeric),any=!0)}totals.push(any?sum:null)}return totals}seriesPalette(){return seriesPalette(this)}tickOptions(theme,kind="value"){return{color:theme.tick,...(this.formatter||this.valueFormatter)&&kind==="value"?{callback:value=>this.formatValue(value,"tick")}:{}}}effectiveIndexAxis(){return this.indexAxis==="y"?"y":"x"}valueScaleType(){return this.scaleType==="logarithmic"?"logarithmic":"linear"}valueBeginAtZero(){return this.valueScaleType()==="logarithmic"?void 0:this.beginAtZero}scaleBounds(){const min=this.min!==null&&Number.isFinite(this.min)?finiteNumber(this.min,0):void 0,max=this.max!==null&&Number.isFinite(this.max)?finiteNumber(this.max,0):void 0;return{...min!==void 0?{min}:{},...max!==void 0?{max}:{}}}gridAxisVisible(axis){const grid=normalizeChartGrid(this.grid);return grid==="both"||grid===axis}buildScales(effectiveType,theme,chartStyle){if(effectiveType==="pie"||effectiveType==="doughnut")return{};if(effectiveType==="radar"||effectiveType==="polarArea")return{r:{beginAtZero:this.beginAtZero,...this.scaleBounds(),ticks:{...this.tickOptions(theme),showLabelBackdrop:!1,z:1},grid:{color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},angleLines:{color:theme.grid,display:this.gridAxisVisible("x"),lineWidth:chartStyle.gridBorderWidth},pointLabels:{color:theme.tick}}};const hasY2=this.effectiveData().datasets.some(dataset=>dataset.yAxisID==="y2"||dataset.axis==="y2"),rtl=this.effectiveDirection==="rtl",stacked=this.stacked&&(effectiveType==="bar"||effectiveType==="line"),horizontalCategorical=(effectiveType==="bar"||effectiveType==="line")&&this.effectiveIndexAxis()==="y",xKind=effectiveType==="scatter"||effectiveType==="bubble"||horizontalCategorical?"value":"category",yKind=horizontalCategorical?"category":"value",valueAxis=horizontalCategorical?"x":"y",bounds=this.scaleBounds();return{x:{type:xKind==="value"?this.valueScaleType():"category",beginAtZero:xKind==="value"?this.valueBeginAtZero():void 0,...valueAxis==="x"?bounds:{},title:{display:!!this.xLabel,text:this.xLabel,color:theme.tick},ticks:this.tickOptions(theme,xKind),grid:{color:theme.grid,display:this.gridAxisVisible("x"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked},y:{type:yKind==="value"?this.valueScaleType():"category",position:rtl?"right":"left",beginAtZero:yKind==="value"?this.valueBeginAtZero():void 0,...valueAxis==="y"?bounds:{},title:{display:!!this.yLabel,text:this.yLabel,color:theme.tick},ticks:this.tickOptions(theme,yKind),grid:{color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked},...hasY2?{y2:{type:this.valueScaleType(),position:rtl?"left":"right",...valueAxis==="y"?bounds:{},grid:{drawOnChartArea:!1,color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},title:{display:!!this.y2Label,text:this.y2Label,color:theme.tick},ticks:this.tickOptions(theme),stacked}}:{}}}handlePointClick(event,chart){const hit=chart.getElementsAtEventForMode(event,"nearest",{intersect:!0},!0)[0];if(!hit)return;const datasetIndex=this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex,index=this.visualRowSourceIndexes?.[hit.index]??hit.index,effective=this.effectiveData(),value=this.datasetValues(effective.datasets[datasetIndex])[index]??null,label=isChartPoint(value)&&value.label!==void 0?value.label:labelText(effective.labels[index])||void 0;this.activateDatum({datasetIndex,index,label,value})}chartDatums(){const chartData=this.chart?.data,labels=chartData?.labels??this.labels,datasets=chartData?.datasets??this.datasets.map(series=>({data:series.points??series.data??[]}));let rowCount=labels.length;for(const dataset of datasets)rowCount=Math.max(rowCount,dataset.data?.length??0);const sample=sampleChartTableIndexes(rowCount,datasets.length),datums=[];return sample.seriesIndexes.forEach(datasetIndex=>{const dataset=datasets[datasetIndex];if(!dataset)return;const values=dataset.data??[];sample.rowIndexes.forEach(index=>{const value=values[index];value!=null&&(typeof value=="number"&&!Number.isFinite(value)||datums.push({datasetIndex:this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex,index:this.visualRowSourceIndexes?.[index]??index,label:isChartPoint(value)&&value.label!==void 0?value.label:labelText(labels[index])||void 0,value}))})}),datums}datumDisplayValue(value){if(isChartPoint(value)){const numberFormat=getNumberFormat(this.effectiveLocale),x=numberFormat.format(value.x),y=numberFormat.format(value.y),coordinates=value.r==null?this.localize("chartPointCoordinates",void 0,{x,y}):this.localize("chartBubblePointCoordinates",void 0,{x,y,radius:numberFormat.format(value.r)});return typeof value.label=="string"?this.localize("chartLabeledPoint",void 0,{label:value.label,coordinates}):coordinates}const numeric=typeof value=="number"?value:Number(typeof value=="object"&&value!==null?value.y??value.r??value.x:value);return Number.isFinite(numeric)?this.formatSpokenValue(numeric):String(value)}datumAnnouncement(datum,position,total){const series=String(this.effectiveData().datasets[datum.datasetIndex]?.label??"")||this.localize("chartSeriesLabel");return this.localize("liteChartMarkSummary",void 0,{series,label:datum.label??this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(datum.index+1)}),value:this.datumDisplayValue(datum.value),index:getNumberFormat(this.effectiveLocale).format(position+1),total:getNumberFormat(this.effectiveLocale).format(total)})}activateDatum(datum){const datums=this.chartDatums(),position=datums.findIndex(candidate=>candidate.datasetIndex===datum.datasetIndex&&candidate.index===datum.index);position>=0&&(this.keyboardDatumIndex=position,this.keyboardDatumAnnouncement=this.datumAnnouncement(datum,position,datums.length));const type=this.effectiveType(),kind=type==="bar"?"bar":type==="pie"||type==="doughnut"||type==="polarArea"?"slice":type==="line"?"segment":"point";this.emit("lr-datum-activate",{...datum,kind}),this.emit("lr-point-click",datum)}onCanvasFocus(){const datums=this.chartDatums();datums.length&&(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[this.keyboardDatumIndex],this.keyboardDatumIndex,datums.length))}onCanvasKeyDown(event){const datums=this.chartDatums();if(!datums.length)return;if(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),event.key==="Enter"||event.key===" "){event.preventDefault(),this.activateDatum(datums[this.keyboardDatumIndex]);return}const rtl=this.effectiveDirection==="rtl",forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft";let next=this.keyboardDatumIndex;if(event.key===forward||event.key==="ArrowDown")next=Math.min(datums.length-1,next+1);else if(event.key===backward||event.key==="ArrowUp")next=Math.max(0,next-1);else if(event.key==="Home")next=0;else if(event.key==="End")next=datums.length-1;else return;event.preventDefault(),this.keyboardDatumIndex=next,this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[next],next,datums.length)}effectiveType(){return this.effectiveConfig()?.type??normalizeChartType(this.type)}localizedChartType(){const type=this.effectiveType(),key=CHART_TYPE_MESSAGE_KEYS[type];return key?this.localize(key):String(type)}formatValue(value,context){const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)?this.formatter?.({value:numeric,surface:context})??this.valueFormatter?.(numeric,context)??value:value}legendValue(item,chart){const datasetIndex=item.datasetIndex;if(datasetIndex===void 0)return;const data=chart.data.datasets?.[datasetIndex]?.data;if(!data)return;const indexed=typeof item.index=="number"&&Number.isInteger(item.index)?Number(data[item.index]):NaN;if(Number.isFinite(indexed))return indexed;let sum=0,hasValue=!1;for(const datum of data){const value=Number(datum);Number.isFinite(value)&&(sum=finiteAdd(sum,value),hasValue=!0)}return hasValue?sum:void 0}legendLabels(chart){const generateLabels=this.chartJsModule?.defaults?.plugins?.legend?.labels?.generateLabels;return((generateLabels&&chart.legend&&chart.options?generateLabels(chart):void 0)??(chart.data.datasets??[]).map((dataset,index)=>({text:labelText(dataset.label)||String(index+1),datasetIndex:index}))).map(item=>{const value=this.legendValue(item,chart),formatted=this.formatValue(value,"legend");return formatted===value||formatted===void 0?item:{...item,text:this.localize("chartValueLabel",void 0,{label:String(item.text),value:String(formatted)})}})}tooltipLabel(context){const parsed=context.parsed,rawValue=isPlainObject(parsed)?parsed.y??parsed.r??parsed.x:parsed??context.raw,formatted=this.formatValue(rawValue,"tooltip");if(!(formatted===rawValue||formatted===void 0))return context.dataset?.label?this.localize("chartValueLabel",void 0,{label:String(context.dataset.label),value:String(formatted)}):String(formatted)}updateAutoLegendPosition(){const width=this.getBoundingClientRect().width||this.clientWidth,next=width>0&&width<480?"bottom":"right";return next===this.autoLegendPosition?!1:(this.autoLegendPosition=next,!0)}legendPositionForConfig(){const position=normalizeLegendPosition(this.legendPosition);return position==="auto"?this.autoLegendPosition:position==="start"?this.effectiveDirection==="rtl"?"right":"left":position==="end"?this.effectiveDirection==="rtl"?"left":"right":position}legendPositionForLayout(){const position=this.legendPositionForConfig();return position==="top"||position==="right"||position==="left"?position:"bottom"}legendGridPlacement(){const position=normalizeLegendPosition(this.legendPosition);if(position==="auto")return this.autoLegendPosition==="right"?"inline-end":"bottom";if(position==="start")return"inline-start";if(position==="end")return"inline-end";if(position==="top")return"top";const rtl=this.effectiveDirection==="rtl";return position==="left"?rtl?"inline-end":"inline-start":position==="right"?rtl?"inline-start":"inline-end":"bottom"}updateChartArea(chart=this.chart){const area=chart?.chartArea;if(!area)return;const next={top:Number(area.top),left:Number(area.left),right:Number(area.right),bottom:Number(area.bottom),width:Number(area.width),height:Number(area.height)};if(Object.values(next).some(value=>!Number.isFinite(value)))return;const previous=this.resolvedChartArea;previous&&Object.keys(next).every(key=>previous[key]===next[key])||(this.resolvedChartArea=next,this.chartAreaUpdateQueued||(this.chartAreaUpdateQueued=!0,queueMicrotask(()=>{this.chartAreaUpdateQueued=!1,this.isConnected&&this.requestUpdate()})))}get chartArea(){return this.resolvedChartArea}buildConfig(){const theme=this.themeColors(),effectiveType=this.effectiveType(),palette=this.seriesPalette(),chartStyle=this.chartStyleOptions(palette),rawDataEscapeHatch=this.hasExplicitConfigData();let visualRows,visualSeries;if(rawDataEscapeHatch)this.visualRowSourceIndexes=void 0,this.visualDatasetSourceIndexes=void 0;else{let rowCount=this.labels.length;for(const series of this.datasets)rowCount=Math.max(rowCount,(series.points??series.data??[]).length);const sample=sampleChartTableIndexes(rowCount,this.datasets.length);visualRows=sample.rowIndexes.length<rowCount?sample.rowIndexes:void 0,visualSeries=sample.seriesIndexes.length<this.datasets.length?sample.seriesIndexes:void 0,this.visualRowSourceIndexes=visualRows,this.visualDatasetSourceIndexes=visualSeries}const generated={type:effectiveType,data:{labels:visualRows?visualRows.map(index=>this.labels[index]??""):this.labels,datasets:visualSeries?visualSeries.map(sourceIndex=>this.seriesToDataset(this.datasets[sourceIndex],sourceIndex,palette,effectiveType,chartStyle,visualRows)):this.datasets.map((s,i)=>this.seriesToDataset(s,i,palette,effectiveType,chartStyle,visualRows))},...this.plugins.length||this.needsDataLabels&&this.dataLabelsPlugin?{plugins:[...this.plugins,...this.needsDataLabels&&this.dataLabelsPlugin?[this.dataLabelsPlugin]:[]]}:{},options:{locale:this.effectiveLocale,responsive:!0,maintainAspectRatio:!1,indexAxis:this.effectiveIndexAxis(),animation:this.withoutAnimation||prefersReducedMotion(this.ownerWindow)?!1:void 0,interaction:{intersect:!1,mode:effectiveType==="scatter"?"nearest":"index"},onClick:(event,_elements,chart)=>this.handlePointClick(event,chart),plugins:{...this.needsAnnotations&&this.annotationPlugin?{annotation:{annotations:this.annotationOptions()}}:{},legend:{display:!1,position:this.legendPositionForConfig(),labels:{color:theme.legend,...this.formatter||this.valueFormatter?{generateLabels:chart=>this.legendLabels(chart)}:{}}},tooltip:{enabled:!this.withoutTooltip,backgroundColor:theme.tooltipBg,titleColor:theme.tooltipText,bodyColor:theme.tooltipText,...this.formatter||this.valueFormatter?{callbacks:{label:context=>this.tooltipLabel(context)}}:{},filter:item=>!this.effectiveData().datasets[item.datasetIndex]?.noTooltip},zoom:this.zoom&&this.zoomFeatureState!=="unavailable"?{pan:{enabled:!1},zoom:{wheel:{enabled:!0},drag:{enabled:!0},pinch:{enabled:!0},mode:"x",onZoomComplete:()=>{this.suppressZoomComplete||(this.zoomed=!0,this.emit("lr-zoom",{zoomed:!0}))}},limits:{x:{min:"original",max:"original"}}}:void 0,datalabels:this.datalabelsOptions(theme,effectiveType)},onResize:chart=>this.updateChartArea(chart),scales:this.buildScales(effectiveType,theme,chartStyle)}},effectiveConfig=this.effectiveConfig();if(!effectiveConfig)return generated;const merged=deepMerge(generated,effectiveConfig),requiredPlugins=[...this.plugins,...this.needsDataLabels&&this.dataLabelsPlugin?[this.dataLabelsPlugin]:[]];if(requiredPlugins.length){const mergedPlugins=Array.isArray(merged.plugins)?merged.plugins:[];merged.plugins=[...mergedPlugins,...requiredPlugins.filter(plugin=>!mergedPlugins.includes(plugin))]}return merged}draw(){if(!this.chartJsModule||!this.canvasEl)return;const config=this.buildConfig(),effectiveType=config.type,nextPlugins=Array.isArray(config.plugins)?config.plugins:[],samePlugins=nextPlugins.length===this.builtPlugins.length&&nextPlugins.every((plugin,index)=>plugin===this.builtPlugins[index]);if(this.chart&&this.builtType===effectiveType&&samePlugins){this.chart.data=config.data,this.chart.options=config.options??{},this.applyDatasetVisibility(),this.chart.update("none"),this.updateChartArea(this.chart);return}this.discardChart(!0),this.chart=new this.chartJsModule.Chart(this.canvasEl,config),this.builtType=effectiveType,this.builtPlugins=[...nextPlugins],this.hiddenDatasets!==void 0&&(this.applyDatasetVisibility(),this.chart.update("none")),this.updateChartArea(this.chart)}drawIfVisible(){!this.isConnected||!this.visible||this.draw()}discardChart(announceZoomReset){this.chart?.destroy(),this.chart=void 0,this.resolvedChartArea=void 0,this.zoomed&&(this.zoomed=!1,announceZoomReset&&this.emit("lr-zoom",{zoomed:!1}))}renderChart(){this.drawIfVisible()}resetZoom(){this.suppressZoomComplete=!0;try{this.chart?.resetZoom?.()}finally{this.suppressZoomComplete=!1}this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1})}refreshTheme(){this.drawIfVisible(),this.showsLegend&&this.requestUpdate()}summarizeSeries(dataset){let count=0,first=0,last=0,min=0,max=0;for(const datum of this.datasetValues(dataset)){const value=isChartPoint(datum)?datum.y:datum;typeof value!="number"||!Number.isFinite(value)||(count===0&&(first=value,min=value,max=value),last=value,min=Math.min(min,value),max=Math.max(max,value),count++)}return count?{count,first,last,min,max}:void 0}formatSummaryValue(value){return getNumberFormat(this.effectiveLocale).format(value)}formatTableValue(value){return this.formatter?.({value,surface:"table"})??this.valueFormatter?.(value,"table")??this.formatSummaryValue(value)}formatExportValue(value){return this.formatter?.({value,surface:"export"})??this.valueFormatter?.(value,"table")}formatSpokenValue(value){return this.formatter?.({value,surface:"spoken"})??this.formatSummaryValue(value)}tableStackAxes(){const type=this.effectiveType();if(!this.stackTotals||!this.stacked||type!=="bar"&&type!=="line")return[];const present=new Set;for(const dataset of this.effectiveData().datasets)present.add(dataset.yAxisID==="y2"||dataset.axis==="y2"?"y2":"y");return["y","y2"].filter(axis=>present.has(axis))}tableStackTotalLabel(axis,axisCount){if(axisCount===1)return this.localize("chartTotal");const axisLabel=axis==="y2"?this.y2Label||this.localize("chartSecondaryAxis"):this.yLabel||this.localize("chartPrimaryAxis");return this.localize("chartAxisTotal",void 0,{axis:axisLabel})}accessibleName(fallback){return this.getAttribute("aria-label")??this.label??fallback}chartDescription(){if(this.description)return this.description;const effective=this.effectiveData(),sample=this.dataTableSample(effective),includePointDetails=!this.hasCustomDataTable(),summaries=sample.seriesIndexes.map(index=>{const dataset=effective.datasets[index],seriesLabel=this.datasetLabel(dataset,index),values=this.summarizeSeries(dataset);if(!values)return this.localize("chartSeriesNoData",void 0,{label:seriesLabel});const trend=values.last>values.first?this.localize("chartTrendIncreasing"):values.last<values.first?this.localize("chartTrendDecreasing"):this.localize("chartTrendFlat"),summary=this.localize("chartSummary",void 0,{label:seriesLabel,count:this.formatSummaryValue(values.count),min:this.formatSummaryValue(values.min),max:this.formatSummaryValue(values.max),trend}),rawValues=this.datasetValues(dataset),pointDetails=includePointDetails?sample.rowIndexes.flatMap(rowIndex=>{const point=rawValues[rowIndex];return isChartPoint(point)?[this.datumDisplayValue(point)]:[]}):[];return pointDetails.length?[summary,...pointDetails].join(this.localize("chartSummarySeparator")):summary}),base=summaries.length?this.localize("chartSummaryWithData",void 0,{type:this.localizedChartType(),summaries:summaries.join(this.localize("chartSummarySeparator"))}):this.localize("chartSummaryEmpty",void 0,{type:this.localizedChartType()}),annotationLabels=this.normalizedAnnotations().map(entry=>entry.label?.trim()).filter(label=>!!label);return annotationLabels.length?[base,...annotationLabels].join(this.localize("chartSummarySeparator")):base}dataTableSample(effective=this.effectiveData()){let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const indexes=sampleChartTableIndexes(rowCount,effective.datasets.length);return{rowCount,seriesCount:effective.datasets.length,...indexes}}generatedDataIsSampled(){if(this.hasCustomDataTable())return!1;const sample=this.dataTableSample();return sample.rowCount===0||sample.seriesCount===0?!1:sample.rowIndexes.length<sample.rowCount||sample.seriesIndexes.length<sample.seriesCount}dataTruncationMessage(){return this.generatedDataIsSampled()?this.localize("chartDataSampled"):""}renderDataTable(){const effective=this.effectiveData(),sample=this.dataTableSample(effective),stackAxes=this.tableStackAxes(),stackTotals=new Map(stackAxes.map(axis=>[axis,this.computeStackTotals(axis)]));return html`
3
- <table class=${this.showDataTable?nothing:"sr-only"}>
3
+ <table class=${this.dataTableVisible?nothing:"sr-only"}>
4
4
  <caption>${this.accessibleName(this.localize("chartData"))}</caption>
5
5
  <thead>
6
6
  <tr>
@@ -15,7 +15,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
15
15
  <th scope="row">${labelText(effective.labels[index])||sample.seriesIndexes.map(datasetIndex=>this.datasetValues(effective.datasets[datasetIndex])[index]).find(isChartPoint)?.label||this.localize("chartPointLabel",void 0,{n:this.formatSummaryValue(index+1)})}</th>
16
16
  ${sample.seriesIndexes.map(datasetIndex=>{const dataset=effective.datasets[datasetIndex],datum=this.datasetValues(dataset)[index],value=isChartPoint(datum)?datum.y:datum;if(typeof value!="number"||!Number.isFinite(value))return html`<td>${this.localize("noData")}</td>`;const detail={datasetIndex,index,label:isChartPoint(datum)&&datum.label!==void 0?datum.label:labelText(effective.labels[index])||void 0,value:datum};return html`<td><button
17
17
  type="button"
18
- tabindex=${this.showDataTable?"0":"-1"}
18
+ tabindex=${this.dataTableVisible?"0":"-1"}
19
19
  @click=${()=>this.activateDatum(detail)}
20
20
  >${isChartPoint(datum)?this.datumDisplayValue(datum):this.formatTableValue(value)}</button></td>`})}
21
21
  ${stackAxes.map(axis=>{const total=stackTotals.get(axis)?.[index];return html`<td>${total==null?this.localize("noData"):this.formatTableValue(total)}</td>`})}
@@ -92,12 +92,22 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
92
92
  ${this.featureWarningMessages().map(warning=>html`<p part="feature-warning">${warning}</p>`)}
93
93
  ${this.dataTruncationMessage()?html`<p part="data-truncation">${this.dataTruncationMessage()}</p>`:nothing}
94
94
  </div>
95
+ ${this.dataTableToggle?html`<button
96
+ part="data-table-toggle"
97
+ type="button"
98
+ aria-expanded=${this.dataTableVisible?"true":"false"}
99
+ aria-controls=${this.dataTableId}
100
+ @click=${()=>this.toggleDataTable()}
101
+ >
102
+ ${this.localize("chartData")}
103
+ </button>`:nothing}
95
104
  <div
105
+ id=${this.dataTableId}
96
106
  part="data-table"
97
- ?data-visually-hidden=${!hasCustomDataTable&&!this.showDataTable}
107
+ ?data-visually-hidden=${!hasCustomDataTable&&!this.dataTableVisible}
98
108
  >
99
109
  <slot name="data-table" @slotchange=${()=>this.requestUpdate()}></slot>
100
110
  ${hasCustomDataTable?nothing:this.renderDataTable()}
101
111
  </div>
102
112
  </div>
103
- `}get showsLegend(){return!this.withoutLegend}}__decorate([property({converter:{fromAttribute:value=>normalizeChartType(value)}})],LyraChart.prototype,"type",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"labels",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"datasets",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"hiddenDatasets",void 0),__decorate([property()],LyraChart.prototype,"description",void 0),__decorate([property({converter:{fromAttribute:value=>normalizeChartGrid(value)}})],LyraChart.prototype,"grid",void 0),__decorate([property({attribute:"index-axis"})],LyraChart.prototype,"indexAxis",void 0),__decorate([property()],LyraChart.prototype,"label",void 0),__decorate([property({attribute:"legend-position",converter:{fromAttribute:value=>normalizeLegendPosition(value)}})],LyraChart.prototype,"legendPosition",void 0),__decorate([property({attribute:"scale-type"})],LyraChart.prototype,"scaleType",void 0),__decorate([property({type:Array})],LyraChart.prototype,"annotations",void 0),__decorate([property({type:Number})],LyraChart.prototype,"max",void 0),__decorate([property({type:Number})],LyraChart.prototype,"min",void 0),__decorate([property({type:Array})],LyraChart.prototype,"plugins",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"valueFormatter",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"formatter",void 0),__decorate([property({type:Boolean})],LyraChart.prototype,"area",void 0),__decorate([property({type:Boolean})],LyraChart.prototype,"zoom",void 0),__decorate([property()],LyraChart.prototype,"height",void 0),__decorate([property({attribute:"x-label"})],LyraChart.prototype,"xLabel",void 0),__decorate([property({attribute:"y-label"})],LyraChart.prototype,"yLabel",void 0),__decorate([property({attribute:"y2-label"})],LyraChart.prototype,"y2Label",void 0),__decorate([property({type:Boolean,attribute:"begin-at-zero",converter:trueDefaultBooleanConverter})],LyraChart.prototype,"beginAtZero",void 0),__decorate([property({type:Boolean,attribute:"show-data-table"})],LyraChart.prototype,"showDataTable",void 0),__decorate([property({type:Boolean})],LyraChart.prototype,"stacked",void 0),__decorate([property({type:Boolean,attribute:"without-animation",reflect:!0})],LyraChart.prototype,"withoutAnimation",void 0),__decorate([property({type:Boolean,attribute:"without-legend",reflect:!0})],LyraChart.prototype,"withoutLegend",void 0),__decorate([property({type:Boolean,attribute:"without-tooltip",reflect:!0})],LyraChart.prototype,"withoutTooltip",void 0),__decorate([property({type:Boolean,attribute:"data-labels"})],LyraChart.prototype,"dataLabels",void 0),__decorate([property({type:Boolean,attribute:"stack-totals"})],LyraChart.prototype,"stackTotals",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"config",void 0),__decorate([state()],LyraChart.prototype,"slottedConfig",void 0),__decorate([state()],LyraChart.prototype,"loading",void 0),__decorate([state()],LyraChart.prototype,"loadFailed",void 0),__decorate([state()],LyraChart.prototype,"zoomed",void 0),__decorate([state()],LyraChart.prototype,"visible",void 0),__decorate([query("canvas")],LyraChart.prototype,"canvasEl",void 0),__decorate([state()],LyraChart.prototype,"autoLegendPosition",void 0),__decorate([state()],LyraChart.prototype,"keyboardDatumAnnouncement",void 0);export{LyraChart,seriesPalette2 as seriesPalette};
113
+ `}get showsLegend(){return!this.withoutLegend}}__decorate([property({converter:{fromAttribute:value=>normalizeChartType(value)}})],LyraChart.prototype,"type",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"labels",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"datasets",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"hiddenDatasets",void 0),__decorate([property()],LyraChart.prototype,"description",void 0),__decorate([property({converter:{fromAttribute:value=>normalizeChartGrid(value)}})],LyraChart.prototype,"grid",void 0),__decorate([property({attribute:"index-axis"})],LyraChart.prototype,"indexAxis",void 0),__decorate([property()],LyraChart.prototype,"label",void 0),__decorate([property({attribute:"legend-position",converter:{fromAttribute:value=>normalizeLegendPosition(value)}})],LyraChart.prototype,"legendPosition",void 0),__decorate([property({attribute:"scale-type"})],LyraChart.prototype,"scaleType",void 0),__decorate([property({type:Array})],LyraChart.prototype,"annotations",void 0),__decorate([property({type:Number})],LyraChart.prototype,"max",void 0),__decorate([property({type:Number})],LyraChart.prototype,"min",void 0),__decorate([property({type:Array})],LyraChart.prototype,"plugins",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"valueFormatter",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"formatter",void 0),__decorate([property({type:Boolean})],LyraChart.prototype,"area",void 0),__decorate([property({type:Boolean})],LyraChart.prototype,"zoom",void 0),__decorate([property()],LyraChart.prototype,"height",void 0),__decorate([property({attribute:"x-label"})],LyraChart.prototype,"xLabel",void 0),__decorate([property({attribute:"y-label"})],LyraChart.prototype,"yLabel",void 0),__decorate([property({attribute:"y2-label"})],LyraChart.prototype,"y2Label",void 0),__decorate([property({type:Boolean,attribute:"begin-at-zero",converter:trueDefaultBooleanConverter})],LyraChart.prototype,"beginAtZero",void 0),__decorate([property({type:Boolean,attribute:"show-data-table"})],LyraChart.prototype,"showDataTable",void 0),__decorate([property({type:Boolean,attribute:"data-table-toggle"})],LyraChart.prototype,"dataTableToggle",void 0),__decorate([state()],LyraChart.prototype,"dataTableExpandedOverride",void 0),__decorate([property({type:Boolean})],LyraChart.prototype,"stacked",void 0),__decorate([property({type:Boolean,attribute:"without-animation",reflect:!0})],LyraChart.prototype,"withoutAnimation",void 0),__decorate([property({type:Boolean,attribute:"without-legend",reflect:!0})],LyraChart.prototype,"withoutLegend",void 0),__decorate([property({type:Boolean,attribute:"without-tooltip",reflect:!0})],LyraChart.prototype,"withoutTooltip",void 0),__decorate([property({type:Boolean,attribute:"data-labels"})],LyraChart.prototype,"dataLabels",void 0),__decorate([property({type:Boolean,attribute:"stack-totals"})],LyraChart.prototype,"stackTotals",void 0),__decorate([property({attribute:!1})],LyraChart.prototype,"config",void 0),__decorate([state()],LyraChart.prototype,"slottedConfig",void 0),__decorate([state()],LyraChart.prototype,"loading",void 0),__decorate([state()],LyraChart.prototype,"loadFailed",void 0),__decorate([state()],LyraChart.prototype,"zoomed",void 0),__decorate([state()],LyraChart.prototype,"visible",void 0),__decorate([query("canvas")],LyraChart.prototype,"canvasEl",void 0),__decorate([state()],LyraChart.prototype,"autoLegendPosition",void 0),__decorate([state()],LyraChart.prototype,"keyboardDatumAnnouncement",void 0);export{LyraChart,seriesPalette2 as seriesPalette};
@@ -234,6 +234,34 @@ import{css}from"lit";import{forcedColorLegendSwatchStyles}from"./chart-forced-co
234
234
  outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
235
235
  outline-offset: var(--lr-focus-ring-offset);
236
236
  }
237
+ [part='data-table-toggle'] {
238
+ align-self: flex-start;
239
+ font: inherit;
240
+ font-size: var(--lr-font-size-xs);
241
+ min-block-size: var(--lr-icon-button-size);
242
+ padding: var(--lr-size-0-15rem) var(--lr-size-0-5rem);
243
+ border: var(--lr-border-width-thin) solid var(--lr-color-border);
244
+ border-radius: var(--lr-radius);
245
+ background: var(--lr-color-surface);
246
+ color: var(--lr-color-text);
247
+ max-inline-size: 100%;
248
+ white-space: normal;
249
+ overflow-wrap: break-word;
250
+ cursor: pointer;
251
+ }
252
+ [part='data-table-toggle']:hover {
253
+ background: var(--lr-chart-data-table-toggle-hover-bg, var(--lr-color-brand-quiet));
254
+ }
255
+ [part='data-table-toggle']:active {
256
+ background: var(
257
+ --lr-chart-data-table-toggle-active-bg,
258
+ color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active))
259
+ );
260
+ }
261
+ [part='data-table-toggle']:focus-visible {
262
+ outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
263
+ outline-offset: var(--lr-focus-ring-offset);
264
+ }
237
265
  [part='error'] {
238
266
  margin: 0;
239
267
  padding: var(--lr-space-l);
@@ -126,6 +126,12 @@ export interface LyraLiteChartEventMap {
126
126
  * @csspart legend-text - Extra per-item text after the series label, rendered only when `legendText` is set.
127
127
  * @csspart live-region - The current mark announcement for keyboard users.
128
128
  * @csspart data-list - A visually hidden sampled list of plotted data points (single-series only).
129
+ * @csspart data-table-toggle - The disclosure button rendered by `dataTableToggle`.
130
+ * @cssprop [--lr-lite-chart-data-table-toggle-hover-bg=var(--lr-color-brand-quiet)] - Hover
131
+ * background of the `dataTableToggle` disclosure button.
132
+ * @cssprop --lr-lite-chart-data-table-toggle-active-bg - Pressed background of the
133
+ * `dataTableToggle` disclosure button; defaults to a mix of the hover background with the shared
134
+ * active mix partner.
129
135
  * @csspart data-table - A visually hidden sampled category×series data table, rendered instead of
130
136
  * `data-list` when there is more than one dataset so a screen-reader user hears series grouping
131
137
  * rather than one flattened N×M sequence.
@@ -186,6 +192,32 @@ export declare class LyraLiteChart extends LyraElement<LyraLiteChartEventMap> {
186
192
  /** Adds a localized total column to the built-in multi-series accessible table for a stacked
187
193
  * bar chart. Ignored for grouped bars and line charts. */
188
194
  tableTotals: boolean;
195
+ /**
196
+ * Makes the generated data table visible; it stays screen-reader available when false. Same
197
+ * meaning as `<lr-chart>`'s property of the same name.
198
+ * @default false
199
+ */
200
+ showDataTable: boolean;
201
+ /**
202
+ * Render a disclosure button above the accessible data table so a sighted reader can reveal the
203
+ * numbers on demand, turning `showDataTable` into the disclosure's INITIAL state rather than its
204
+ * whole behavior. The table stays in the DOM in both states, so assistive technology never loses
205
+ * it.
206
+ *
207
+ * Matters more here than on `<lr-chart>`: this component exists to avoid the Chart.js peers, so
208
+ * without it an app that chose it for that reason had to either hand-roll a `<details>` around a
209
+ * duplicated table or adopt `<lr-chart>` and pull in Chart.js for a button — the cheap component
210
+ * stuck with the expensive workaround.
211
+ * @default false
212
+ */
213
+ dataTableToggle: boolean;
214
+ /** Live disclosure state; null until toggled, so an untouched control follows `showDataTable`. */
215
+ private dataTableExpandedOverride;
216
+ private readonly dataTableId;
217
+ /** Identical to `showDataTable` whenever `dataTableToggle` is off, keeping the unset path
218
+ * byte-identical to before. */
219
+ private get dataTableVisible();
220
+ private toggleDataTable;
189
221
  /** `'fit'` (default) squeezes the plot into the measured host width, unchanged from before this
190
222
  * property existed. `'scroll'` gives every bar a fixed `barWidth` instead, letting the plot's
191
223
  * content width exceed the host's — the host becomes horizontally scrollable