@aceshooting/lyra-ui 30.9.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +236 -339
- package/dist/ai/adapters/ag-ui.js +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
- package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
- package/dist/components/charts/chart/box-plot.class.js +2 -2
- package/dist/components/charts/chart/chart-sync.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +1 -1
- package/dist/components/charts/chart/chart.class.js +4 -4
- package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -1
- package/dist/components/charts/chart/lite-chart.class.js +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +9 -4
- package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
- package/dist/components/conversation/chat-message/chat-message.class.d.ts +27 -3
- package/dist/components/conversation/chat-message/chat-message.class.js +14 -12
- package/dist/components/conversation/chat-message/chat-message.styles.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +29 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +2 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.js +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +10 -0
- package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-shared.d.ts +7 -2
- package/dist/components/conversation/markdown/markdown-shared.js +3 -3
- package/dist/components/conversation/markdown/markdown.class.d.ts +10 -0
- package/dist/components/conversation/markdown/markdown.class.js +1 -1
- package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
- package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +2 -1
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +4 -0
- package/dist/components/conversation/streaming-text/streaming-text-base.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -0
- package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +17 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +3 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.d.ts +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.js +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.js +2 -2
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
- package/dist/components/data/data-grid/data-grid.class.d.ts +10 -10
- package/dist/components/data/data-grid/data-grid.class.js +1 -1
- package/dist/components/data/file-tree/file-tree.class.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +1 -1
- package/dist/components/data/heatmap/heatmap.class.js +1 -1
- package/dist/components/data/pagination/pagination.class.js +1 -1
- package/dist/components/data/table/table.class.d.ts +31 -2
- package/dist/components/data/table/table.class.js +3 -3
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/data/timeline/timeline-cluster.js +1 -1
- package/dist/components/data/timeline/timeline-item.class.d.ts +10 -3
- package/dist/components/data/timeline/timeline-item.class.js +16 -12
- package/dist/components/data/timeline/timeline-item.styles.js +1 -1
- package/dist/components/data/timeline/timeline.class.d.ts +14 -2
- package/dist/components/data/timeline/timeline.class.js +9 -5
- package/dist/components/data/tree/tree-item.class.js +1 -1
- package/dist/components/data/tree/tree.class.d.ts +2 -0
- package/dist/components/data/tree/tree.class.js +1 -1
- package/dist/components/forms/button/button.class.d.ts +8 -6
- package/dist/components/forms/button/button.class.js +2 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/color-picker/color-core.js +1 -1
- package/dist/components/forms/date-picker/date-input.class.d.ts +1 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
- package/dist/components/forms/icon-button/icon-button.class.js +2 -2
- package/dist/components/forms/input/input-shared.js +2 -2
- package/dist/components/forms/input/number-input-locale.js +1 -0
- package/dist/components/forms/input/number-input.class.d.ts +19 -2
- package/dist/components/forms/input/number-input.class.js +2 -2
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +3 -3
- package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
- package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
- package/dist/components/layout/details/accordion-item.class.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
- package/dist/components/layout/tab-group/tab-group.class.d.ts +8 -1
- package/dist/components/layout/tab-group/tab-group.class.js +1 -1
- package/dist/components/layout/tab-group/tab.class.d.ts +7 -1
- package/dist/components/layout/tab-group/tab.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +2 -2
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/media/animated-image/animated-image.class.js +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +21 -14
- package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +36 -12
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
- package/dist/components/media/drop-zone/drop-zone.class.d.ts +23 -5
- package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
- package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/flag/flag-url-resolver.js +1 -1
- package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -2
- package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
- package/dist/components/media/map/map-owned-features.js +1 -1
- package/dist/components/media/map/map-scene-elevated-lines.js +2 -2
- package/dist/components/media/map/map-scene-render-controller.js +1 -1
- package/dist/components/media/map/map.class.d.ts +5 -5
- package/dist/components/media/map/map.class.js +3 -3
- package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
- package/dist/components/media/video/video.class.d.ts +3 -3
- package/dist/components/media/video/video.class.js +3 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/overlays/chip/chip.class.js +1 -1
- package/dist/components/overlays/overlay/dropdown.class.js +1 -1
- package/dist/components/overlays/overlay/tooltip.class.d.ts +5 -1
- package/dist/components/overlays/overlay/tooltip.class.js +3 -3
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
- package/dist/components/retrieval/graph/graph-node-renderer.js +1 -1
- package/dist/components/retrieval/graph/graph-spatial-controller.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +1 -1
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +3 -3
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.class.d.ts +16 -1
- package/dist/components/utility/json-viewer/json-viewer.class.js +4 -4
- package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
- package/dist/components/utility/known-date/known-date.class.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
- package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
- package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
- package/dist/components/viewers/include/include.class.js +1 -1
- package/dist/components/viewers/model-viewer/model-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/table-viewer-shared.js +4 -4
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/anchored-overlay-runtime.js +1 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/document-tokens.js +2 -2
- package/dist/internal/drop-session-controller.js +1 -1
- package/dist/internal/engine-3d.js +1 -1
- package/dist/internal/icon-only-content.js +1 -1
- package/dist/internal/layered-layout.js +1 -1
- package/dist/internal/map-custom-layer-controller.js +1 -1
- package/dist/internal/media-panorama.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/safe-url.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/scroll-overflow.js +1 -1
- package/dist/internal/source-window-controller.js +1 -1
- package/dist/internal/text-quote.js +1 -1
- package/dist/internal/viewer-search.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/sequence-time-binding.js +1 -1
- package/dist/simulation-clock.js +1 -1
- package/dist/styles/reservations.css +1 -1
- package/dist/styles/reservations.styles.js +1 -1
- package/dist/testing/happy-dom-shims.js +1 -1
- package/dist/theme/theme.js +1 -1
- package/llms/components/lr-attachment-chip.md +27 -12
- package/llms/components/lr-attachment-trigger.md +27 -7
- package/llms/components/lr-button.md +6 -4
- package/llms/components/lr-chat-composer.md +13 -7
- package/llms/components/lr-chat-message.md +44 -3
- package/llms/components/lr-chat-viewport.md +39 -2
- package/llms/components/lr-data-grid.md +2 -0
- package/llms/components/lr-dialog.md +10 -0
- package/llms/components/lr-drop-zone.md +26 -2
- package/llms/components/lr-icon-button.md +2 -1
- package/llms/components/lr-json-viewer.md +17 -0
- package/llms/components/lr-locale-picker.md +5 -0
- package/llms/components/lr-markdown-core.md +2 -1
- package/llms/components/lr-markdown.md +20 -4
- package/llms/components/lr-menu.md +3 -1
- package/llms/components/lr-number-input.md +28 -1
- package/llms/components/lr-prompt-input.md +1 -1
- package/llms/components/lr-streaming-text-core.md +3 -2
- package/llms/components/lr-streaming-text.md +4 -1
- package/llms/components/lr-suggestion-chips.md +28 -5
- package/llms/components/lr-tab-group.md +13 -1
- package/llms/components/lr-tab.md +5 -0
- package/llms/components/lr-table.md +25 -4
- package/llms/components/lr-timeline-item.md +1 -1
- package/llms/components/lr-timeline.md +38 -4
- package/llms/components/lr-tooltip.md +3 -1
- package/llms/components/lr-tree.md +4 -0
- package/llms/components/lr-virtual-list.md +1 -0
- package/llms/peers.md +2 -2
- package/llms/shared/forms-and-accessibility.md +21 -4
- package/llms/shared.md +21 -4
- package/package.json +21 -20
- package/registrations.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{SpatialSourceController,spatialContains}from"../../../internal/spatial-source-controller.js";import{spatialCoordinate,spatialOriginal,spatialPaintRadius,spatialCsv}from"./chart-spatial-data.js";import{SourceRequestController}from"../../../internal/source-request-controller.js";import{prepareChartModel,revealPreparedSourcePoint}from"./chart-prepared-data.js";import{snapshotStructuredData,admitSnapshotArray,snapshotArrayStillAdmitted as chartArrayIsStillAdmitted,projectSnapshotArray}from"../../../internal/structured-snapshot.js";import{LazyChartSyncController}from"./chart-sync-lazy.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";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-host-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{createReducedMotionWatch}from"./chart-surface-shared.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{onAnnotationPluginRegistered}from"../../../internal/chart-annotation-registration.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult,loadChartJsWithAnnotationResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import{chartSurfaceStyles}from"./chart-surface.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{formatChartValue}from"./chart-number-format.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{showChartActiveDatum}from"./chart-active-datum.js";import{devWarnOnce}from"../../../internal/dev-warning.js";import{getOwnDataDescriptor,readOwnDataValue,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{FALLBACK_GRID_COLOR,FALLBACK_LEGEND_COLOR,FALLBACK_TICK_COLOR,FALLBACK_TICK_FONT_SIZE,FALLBACK_TOOLTIP_BG,FALLBACK_TOOLTIP_TEXT}from"./chart-colors.js";import{ChartTokenCache}from"./chart-token-cache.js";import{chartDataTableVisible,hasSlottedChartDataTable}from"./chart-data-table.js";import{normalizeSize}from"../../../internal/variants.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes,normalizeChartRecordLimit}from"./chart-table-sampling.js";import{canvasSentence,canvasTextDirection,isolateCanvasLabel,isolateCanvasText,isolatedMessage,isolateScaleTickLabels,tooltipIsolationHook,bidiStyles,isolateHtml}from"./chart-bidi.js";import{CSS_NUMBER_SOURCE}from"../../../internal/css-number.js";import{LYRA_DEFAULT_chartAnnotationsUnavailable,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartInputLimit,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPlotSampled,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPreparedSummaryZoom,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartRenderUnavailable,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartSpatialBin,LYRA_DEFAULT_chartSpatialDensityLegend,LYRA_DEFAULT_chartSpatialHidden,LYRA_DEFAULT_chartSpatialPoint,LYRA_DEFAULT_chartSpatialRadiusDomain,LYRA_DEFAULT_chartSpatialSummary,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,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_chartValuePercentageLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_liteChartMarkSummary}from"../../../internal/default-strings/charts.generated.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartPreparedSummary,LYRA_DEFAULT_chartPreparedUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_loading,LYRA_DEFAULT_noData,LYRA_DEFAULT_resetZoom}from"../../../internal/default-strings/shared.generated.js";const DIRECT_PIXEL_NUMBER=new RegExp(`^(${CSS_NUMBER_SOURCE})(?:px)?$`,"i");import{seriesPalette}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]);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"?value:projectLegendPosition(value)??"top"}function isArcDatasetType(datasetType){return datasetType==="pie"||datasetType==="doughnut"||datasetType==="polarArea"}function isPointDatasetType(datasetType){return datasetType==="line"||datasetType==="radar"||datasetType==="scatter"||datasetType==="bubble"}function isChartRecord(value){try{return typeof value=="object"&&value!==null&&!Array.isArray(value)}catch{return!1}}const MAX_CHART_INPUT_ENTRIES=1e4,CHART_INPUT_CAP_WARNING_KEY="lr-chart-input-cap",MAX_CHART_CONFIGURATION_DEPTH=32,OMIT_CHART_CONFIGURATION_VALUE=Symbol("omit-chart-configuration-value");function warnChartInputCap(){devWarnOnce(CHART_INPUT_CAP_WARNING_KEY,"lr-chart: an input array exceeded 10,000 entries; only the first 10,000 are used.")}const truncatedChartInputs=new WeakSet;function retainChartInputLimit(source,value){typeof source=="object"&&source!==null&&truncatedChartInputs.has(source)&&typeof value=="object"&&value!==null&&truncatedChartInputs.add(value)}function admitChartArray(value){let truncated=!1;const admitted=admitSnapshotArray(value,()=>{truncated=!0,warnChartInputCap()});return admitted&&truncated&&truncatedChartInputs.add(admitted.source),admitted}function copyChartArrayEntries(admission){const value=projectSnapshotArray(admission,value2=>value2,{missing:void 0})??Object.freeze([]);return retainChartInputLimit(admission.source,value),value}function chartEnumerableKeys(value){try{return Object.keys(value)}catch{return}}const canonicalChartSeriesSnapshots=new WeakMap,admittedChartPlugins=new WeakSet,canonicalChartDatasetValues=new WeakMap,canonicalChartDatasetDataValues=new WeakMap,canonicalChartDataSnapshots=new WeakSet;function canonicalChartSeries(value){if(isChartRecord(value))return canonicalChartSeriesSnapshots.has(value)?value:projectChartSeries(value)}function canonicalSeriesData(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.data??[]:[]}function canonicalSeriesPoints(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.points:void 0}function chartRecordValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectChartNumberData(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:null,{missing:null})}function projectChartPoint(value){if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label");return x===MISSING_OWN_DATA_DESCRIPTOR||x===UNSAFE_OWN_DATA_DESCRIPTOR||y===MISSING_OWN_DATA_DESCRIPTOR||y===UNSAFE_OWN_DATA_DESCRIPTOR||r===UNSAFE_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||typeof x.value!="number"||!Number.isFinite(x.value)||typeof y.value!="number"||!Number.isFinite(y.value)?null:Object.freeze({x:x.value,y:y.value,...r!==MISSING_OWN_DATA_DESCRIPTOR&&typeof r.value=="number"&&Number.isFinite(r.value)&&r.value>=0?{r:r.value}:{},...id!==MISSING_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))?{id:id.value}:{},...label!==MISSING_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?{label:label.value}:{}})}function projectChartDatum(value){if(typeof value=="number")return Number.isFinite(value)?value:null;if(typeof value=="string"||typeof value=="bigint")return value;if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label"),output={};let hasValue=!1;for(const[property2,descriptor]of[["x",x],["y",y],["r",r]])descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value)||(output[property2]=descriptor.value,hasValue=!0);return label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"&&(output.label=label.value,hasValue=!0),id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))&&(output.id=id.value,hasValue=!0),hasValue?Object.freeze(output):null}function projectChartDatasetValues(admission){return projectSnapshotArray(admission,projectChartDatum,{missing:null})??Object.freeze([])}function projectChartPoints(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartPoint,{missing:null})}function projectChartStrings(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="string"?entry:"",{missing:""})}function projectChartPointRadii(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:Number.NaN,{missing:Number.NaN})}function projectHiddenDatasetIndexes(value){if(value!==void 0)return projectSnapshotArray(admitChartArray(value),entry=>typeof entry=="number"&&Number.isInteger(entry)?entry:void 0,{compact:!0})??Object.freeze([])}const CHART_ANNOTATION_TONES=new Set(["neutral","brand","success","warning","danger"]);function projectChartAnnotations(value){if(!Array.isArray(value))return Object.freeze([]);const output=[];for(const annotation of value){if(!isChartRecord(annotation))continue;const own=key=>Object.hasOwn(annotation,key)?annotation[key]:void 0,axis=own("axis"),line=own("value"),from=own("from"),to=own("to"),label=own("label"),tone=own("tone");if(axis!==void 0&&axis!=="x"&&axis!=="y"||label!==void 0&&typeof label!="string"||tone!==void 0&&(typeof tone!="string"||!CHART_ANNOTATION_TONES.has(tone)))continue;const common={...axis==="x"||axis==="y"?{axis}:{},...typeof label=="string"?{label}:{},...typeof tone=="string"?{tone}:{}};typeof line=="number"&&Number.isFinite(line)?output.push(Object.freeze({...common,value:line})):typeof from=="number"&&Number.isFinite(from)&&typeof to=="number"&&Number.isFinite(to)&&output.push(Object.freeze({...common,from:Math.min(from,to),to:Math.max(from,to)}))}return Object.freeze(output)}const CHART_SERIES_PROPERTIES=["label","data","points","color","fill","width","dash","noTooltip","axis","stack","pointColors","pointRadius","segmentColors","type"];function projectChartSeries(value){if(typeof value=="object"&&value!==null&&canonicalChartSeriesSnapshots.has(value))return value;if(!isChartRecord(value))return;const descriptors=new Map;for(const property2 of CHART_SERIES_PROPERTIES){const descriptor=chartRecordValue(value,property2);if(descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)return;descriptors.set(property2,descriptor)}const valueAt=property2=>{const descriptor=descriptors.get(property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||descriptor===void 0?void 0:descriptor.value},label=valueAt("label");if(label!==void 0&&typeof label!="string")return;const output={label:label??""},rawData=valueAt("data"),rawDataAdmission=admitChartArray(rawData),data=projectChartNumberData(rawData,rawDataAdmission),rawPoints=valueAt("points"),rawPointsAdmission=admitChartArray(rawPoints),points=projectChartPoints(rawPoints,rawPointsAdmission),color=valueAt("color"),fill=valueAt("fill"),width=valueAt("width"),dash=valueAt("dash"),noTooltip=valueAt("noTooltip"),axis=valueAt("axis"),stack=valueAt("stack"),pointColors=projectChartStrings(valueAt("pointColors")),pointRadius=valueAt("pointRadius"),segmentColors=projectChartStrings(valueAt("segmentColors")),type=valueAt("type");if(data&&rawDataAdmission&&(output.data=rawDataAdmission.source),points&&rawPointsAdmission&&(output.points=rawPointsAdmission.source),typeof color=="string")output.color=color;else{const colors=projectChartStrings(color);colors&&(output.color=colors)}if(typeof fill=="boolean"&&(output.fill=fill),typeof width=="number"&&Number.isFinite(width)&&(output.width=width),typeof dash=="boolean"&&(output.dash=dash),typeof noTooltip=="boolean"&&(output.noTooltip=noTooltip),(axis==="y"||axis==="y2")&&(output.axis=axis),typeof stack=="string"&&(output.stack=stack),pointColors&&(output.pointColors=pointColors),typeof pointRadius=="number"&&Number.isFinite(pointRadius))output.pointRadius=pointRadius;else{const radii=projectChartPointRadii(pointRadius);radii&&(output.pointRadius=radii)}segmentColors&&(output.segmentColors=segmentColors),(type==="line"||type==="bar")&&(output.type=type);const series=Object.freeze(output);return retainChartInputLimit(rawData,series),retainChartInputLimit(rawPoints,series),canonicalChartSeriesSnapshots.set(series,{data:data??Object.freeze([]),...points?{points}:{}}),series}function appendChartSeries(series,data){const values=Object.freeze(data),result=Object.freeze({...series,data:values});return canonicalChartSeriesSnapshots.set(result,{data:values}),result}function normalizeChartSeries(value){const result=projectSnapshotArray(admitChartArray(value),canonicalChartSeries,{compact:!0})??Object.freeze([]);return retainChartInputLimit(value,result),result.some(series=>truncatedChartInputs.has(series))&&truncatedChartInputs.add(result),result}function isSafeChartConfigurationRecord(value){if(!isChartRecord(value))return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype}catch{return!1}}function projectLegendPosition(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output={};for(const key of keys){if(UNSAFE_KEYS.has(key))return;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value))return;output[key]=descriptor.value}return Object.freeze(output)}function copyChartConfigurationValue(value,profile="chart"){const snapshot=snapshotStructuredData(value,{profile,omitKeys:UNSAFE_KEYS,onArrayTruncate:warnChartInputCap,onClone:(source,copied)=>{retainChartInputLimit(source,copied);const canonical=canonicalChartDatasetDataValues.get(source);canonical&&canonicalChartDatasetDataValues.set(copied,canonical)}});return snapshot.truncated&&typeof snapshot.value=="object"&&snapshot.value!==null&&truncatedChartInputs.add(snapshot.value),snapshot.value===void 0&&value!==void 0?OMIT_CHART_CONFIGURATION_VALUE:snapshot.value}function projectChartPlugins(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,candidate=>{if(candidate===null||typeof candidate!="object"&&typeof candidate!="function")return;const plugin=candidate;if(admittedChartPlugins.has(plugin))return plugin;const id=chartRecordValue(plugin,"id");if(!(id===MISSING_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||typeof id.value!="string"||id.value.trim()===""))return admittedChartPlugins.add(plugin),plugin},{compact:!0})??Object.freeze([])}function projectChartDatasetConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null),priorCanonicalValues=canonicalChartDatasetValues.get(value);let canonicalValues;for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const candidate=descriptor.value,array=admitChartArray(candidate);if(key==="data"){if(array){const copied=copyChartArrayEntries(array);output[key]=copied;const canonical=priorCanonicalValues??canonicalChartDatasetDataValues.get(array.source)??projectChartDatasetValues(array);canonicalValues=canonical,canonicalChartDatasetDataValues.set(copied,canonical)}continue}if(key==="label"){typeof candidate=="string"||typeof candidate=="number"||typeof candidate=="boolean"||typeof candidate=="bigint"?output[key]=candidate:array&&(output[key]=copyChartArrayEntries(array));continue}if(key==="hidden"||key==="noTooltip"){typeof candidate=="boolean"&&(output[key]=candidate);continue}if(key==="axis"||key==="yAxisID"||key==="type"||key==="stack"){typeof candidate=="string"&&(output[key]=candidate);continue}output[key]=array?copyChartArrayEntries(array):candidate}const dataset=Object.freeze(output);return canonicalValues&&canonicalChartDatasetValues.set(dataset,canonicalValues),dataset}function projectChartDatasetConfigurations(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartDatasetConfiguration,{compact:!0})??Object.freeze([])}function projectChartDataConfiguration(value){if(typeof value=="object"&&value!==null&&canonicalChartDataSnapshots.has(value))return value;if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)){if(key==="labels"){const labels=admitChartArray(descriptor.value);output[key]=labels?copyChartArrayEntries(labels):Object.freeze([]);continue}if(key==="datasets"){output[key]=projectChartDatasetConfigurations(descriptor.value);continue}output[key]=descriptor.value}}return retainChartInputLimit(value,output),canonicalChartDataSnapshots.add(output),Object.freeze(output)}function projectChartConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const output=Object.create(null),type=chartRecordValue(value,"type"),data=chartRecordValue(value,"data"),options=chartRecordValue(value,"options"),plugins=chartRecordValue(value,"plugins");type!==MISSING_OWN_DATA_DESCRIPTOR&&type!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof type.value=="string"&&(output.type=type.value);for(const[property2,descriptor]of[["data",data],["options",options]]){if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const copied=copyChartConfigurationValue(descriptor.value,property2==="data"?"chartData":"chart");if(copied!==OMIT_CHART_CONFIGURATION_VALUE){if(property2==="data"){const projected=projectChartDataConfiguration(copied);output[property2]=projected??copied,retainChartInputLimit(copied,output);continue}output[property2]=copied}}if(plugins!==MISSING_OWN_DATA_DESCRIPTOR&&plugins!==UNSAFE_OWN_DATA_DESCRIPTOR){const pluginArray=admitChartArray(plugins.value);if(pluginArray)output.plugins=projectChartPlugins(plugins.value,pluginArray);else{const copied=copyChartConfigurationValue(plugins.value);copied!==OMIT_CHART_CONFIGURATION_VALUE&&(output.plugins=copied)}}return Object.freeze(output)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]);function deepMerge(base,override,seen=new WeakMap){if(!isSafeChartConfigurationRecord(base)||!isSafeChartConfigurationRecord(override))return override===void 0?base:override;const baseRecord=base,overrideRecord=override,baseKeys=chartEnumerableKeys(baseRecord),overrideKeys=chartEnumerableKeys(overrideRecord);if(!baseKeys||!overrideKeys)return override;const previous=seen.get(overrideRecord);if(previous!==void 0)return previous;const result={};for(const key of baseKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(baseRecord,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(result[key]=descriptor.value)}seen.set(overrideRecord,result);try{for(const key of overrideKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(overrideRecord,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const baseDescriptor=chartRecordValue(baseRecord,key),baseValue=baseDescriptor===MISSING_OWN_DATA_DESCRIPTOR||baseDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:baseDescriptor.value;result[key]=deepMerge(baseValue,descriptor.value,seen)}}finally{seen.delete(overrideRecord)}return result}function normalizedChartPoint(value){return projectChartPoint(projectChartDatum(value))}function chartNumericValue(value){const numeric=typeof value=="number"?value:typeof value=="string"||typeof value=="bigint"?Number(value):Number.NaN;return Number.isFinite(numeric)?numeric:void 0}function chartDatumNumericValue(value){const projected=projectChartDatum(value);if(isChartRecord(projected))for(const property2 of["y","r","x"]){const descriptor=chartRecordValue(projected,property2);if(descriptor!==MISSING_OWN_DATA_DESCRIPTOR&&descriptor!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof descriptor.value=="number"&&Number.isFinite(descriptor.value))return descriptor.value}return chartNumericValue(projected)}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value,depth=0){if(value==null)return"";if(typeof value=="string"||typeof value=="number"||typeof value=="boolean"||typeof value=="bigint")return String(value);const admission=admitChartArray(value);if(depth<MAX_CHART_CONFIGURATION_DEPTH&&admission){const values=[];for(let index=0;index<admission.length;index+=1)values.push(labelText(readOwnDataValue(admission.source,String(index)),depth+1));return values.join(" ")}return""}function chartDatasetValue(dataset,property2){if(!isChartRecord(dataset))return;const descriptor=chartRecordValue(dataset,property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function chartDatasetLabel(dataset){return labelText(chartDatasetValue(dataset,"label"))}function chartDatasetValues(dataset){if(isChartRecord(dataset)){const snapshot=canonicalChartDatasetValues.get(dataset);if(snapshot)return snapshot}const data=chartDatasetValue(dataset,"data"),admission=admitChartArray(data);return admission?canonicalChartDatasetDataValues.get(admission.source)??copyChartArrayEntries(admission):Object.freeze([])}function chartDatasetPeerValues(dataset){const data=chartDatasetValue(dataset,"data");return typeof data=="object"&&data!==null&&canonicalChartDatasetDataValues.has(data)?data:Object.freeze([])}function chartIndex(value){return typeof value=="number"&&Number.isSafeInteger(value)&&value>=0?value:void 0}function chartCallbackDatasetIndex(value){return chartIndex(chartDatasetValue(value,"datasetIndex"))}function chartCallbackIndexes(value){const datasetIndex=chartCallbackDatasetIndex(value),index=chartIndex(chartDatasetValue(value,"index"))??chartIndex(chartDatasetValue(value,"dataIndex"));return datasetIndex===void 0||index===void 0?void 0:{datasetIndex,index}}function projectChartLegendItem(value){if(!isChartRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(output[key]=descriptor.value)}return output}function projectChartLegendItems(value){const admission=admitChartArray(value);if(!admission||!chartArrayIsStillAdmitted(admission))return;const output=[];for(let index=0;index<admission.length;index+=1){const descriptor=chartRecordValue(admission.source,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectChartLegendItem(descriptor.value);item&&output.push(item)}return Object.freeze(output)}function chartDatasetBoolean(dataset,property2){const value=chartDatasetValue(dataset,property2);return typeof value=="boolean"?value:void 0}function chartDatasetAxis(dataset){return chartDatasetValue(dataset,"yAxisID")==="y2"||chartDatasetValue(dataset,"axis")==="y2"?"y2":"y"}function chartDatasetStack(dataset){const value=chartDatasetValue(dataset,"stack");return typeof value=="string"?value:void 0}function isDenseChartSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAnnotationsUnavailable:LYRA_DEFAULT_chartAnnotationsUnavailable,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartInputLimit:LYRA_DEFAULT_chartInputLimit,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPlotSampled:LYRA_DEFAULT_chartPlotSampled,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPreparedSummary:LYRA_DEFAULT_chartPreparedSummary,chartPreparedSummaryZoom:LYRA_DEFAULT_chartPreparedSummaryZoom,chartPreparedUnavailable:LYRA_DEFAULT_chartPreparedUnavailable,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartRenderUnavailable:LYRA_DEFAULT_chartRenderUnavailable,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartSpatialBin:LYRA_DEFAULT_chartSpatialBin,chartSpatialDensityLegend:LYRA_DEFAULT_chartSpatialDensityLegend,chartSpatialHidden:LYRA_DEFAULT_chartSpatialHidden,chartSpatialPoint:LYRA_DEFAULT_chartSpatialPoint,chartSpatialRadiusDomain:LYRA_DEFAULT_chartSpatialRadiusDomain,chartSpatialSummary:LYRA_DEFAULT_chartSpatialSummary,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,chartValuePercentageLabel:LYRA_DEFAULT_chartValuePercentageLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,noData:LYRA_DEFAULT_noData,resetZoom:LYRA_DEFAULT_resetZoom}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-legend-visibility-change-request","lr-legend-visibility-change","lr-datum-visibility-change-request","lr-datum-visibility-change"])}static{this.ownedCollectionProperties=Object.freeze(["annotations","hiddenDatasets"])}static{this.styles=[LyraElement.styles,specialistTokens,chartSurfaceStyles,styles,srOnly,bidiStyles]}constructor(){super(),this.canvasTokens=new ChartTokenCache(this),this.type="bar",this._preparedData=null,this.viewport=null,this.selectedPointId="",this.spatialActive=!1,this.spatial=new SpatialSourceController(this,()=>this.spatialChanged(),()=>this.effectiveLocale),this.spatialWaiters=new Set,this.spatialRevealToken={},this.preparedGeneration={},this.spatialKeyboardIndex=0,this.preparedDirty=!0,this.preparedActive=!1,this.preparedChanged=!1,this.preparedInvalid=!1,this.preparedPending=!1,this.preparedRequestFailed=!1,this.announcedPreparedInvalid=!1,this.preparedRequests=new SourceRequestController(this,{channels:["point"],onReset:()=>{this.preparedPending=!1}}),this.labels=[],this.maxRecords=1e3,this.samplingWidth=0,this._datasets=Object.freeze([]),this.datasetsSource=this._datasets,this._hiddenDatums=Object.freeze([]),this.hiddenDatumsSource=this._hiddenDatums,this.legendMode="auto",this.legendDisplay="auto",this.description=null,this.grid="both",this.axes="both",this.size="m",this.indexAxis="x",this.label=null,this.legendPosition="top",this.scaleType="linear",this.annotations=[],this.max=null,this.min=null,this._plugins=Object.freeze([]),this.pluginsSource=this._plugins,this.area=!1,this.zoomable=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.withoutZeroBaseline=!1,this.withDataTable=!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.configSource=void 0,this.loading=!0,this.loadFailed=!1,this.canvasUnavailable=!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.annotationFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.reducedMotionWatch=createReducedMotionWatch(this,()=>this.drawIfVisible()),this.scaledSliceDatasets=new Set,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.chartAreaPlugin={id:"lyra-chart-area",afterLayout:chart=>this.updateChartArea(chart),beforeTooltipDraw:tooltipIsolationHook(()=>this.effectiveDirection)},this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.announcements=new AnnouncementSinkController(this),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.syncGroup="",this.chartSync=new LazyChartSyncController(this,(label,index)=>this.syncPresentation(label,index),()=>this.resetSyncTooltip(),target=>target===this.canvasEl),this.forcedColorPatterns=new Map,this.visualPositions=new WeakMap,this.keyboardDatumShown=!1,this.onCanvasBlur=()=>{this.showKeyboardDatum(void 0)},this.seriesSummaryMemo=new WeakMap,this.streamingTableUpdate=!1,new ThemeWatcher(this,()=>{this.chart&&this.canvasTokens.hasThemeChanged()&&this.refreshTheme()})}get preparedData(){return this._preparedData}set preparedData(value){const previous=this._preparedData;this._preparedData=value,this.requestUpdate("preparedData",previous),value===previous&&this.requestUpdate()}preparedDataInput(){return this._preparedData}spatialChanged(){this.preparedChanged=!0,this.preparedPending=this.spatial?.loading??!1,this.preparedRequestFailed=this.spatial?.error??!1,this.descriptionMemo=void 0,this.dataTableRows=void 0,super.requestUpdate("spatialView",null),(!this.spatial?.loading||this.spatial.error)&&this.wakeSpatialWaiters()}wakeSpatialWaiters(){for(const resolve of this.spatialWaiters??[])resolve();this.spatialWaiters?.clear()}spatialPoints(){return this.spatial.points()}spatialSeriesPoints(visible=!1){const points=this.spatialPoints(),view=this.spatial.view,series=this.spatial.binding?.chart?.series??[],groups=series.map(()=>[]),indices=new Map(series.map((entry,index)=>[entry.id,index]));for(const point of points){const index=indices.get(point.seriesId);index!==void 0&&(!visible||view&&spatialContains(view,point))&&groups[index].push(point)}return groups}spatialGuard(member=()=>!0){const binding=this.spatial.binding,result=this.spatial.result,owner=this.ownerDocument,epoch=this.spatial.authority.epoch,generation=this.preparedGeneration;return event=>{const target=event?.currentTarget;return this.isConnected&&this.ownerDocument===owner&&this.spatialActive&&generation===this.preparedGeneration&&binding===this.spatial.binding&&result===this.spatial.result&&epoch===this.spatial.authority.epoch&&!this.spatial.loading&&!this.spatial.error&&member()&&(!event||!!target?.isConnected&&target.getRootNode()===this.renderRoot&&target.ownerDocument===owner)}}spatialPointText(point){const series=this.spatial.binding.chart.series,datasetIndex=series.findIndex(series2=>series2.id===point.seriesId),coordinates=this.datumDisplayValue({x:point.x,y:point.y,...point.radius===void 0?{}:{r:point.radius}},{surface:"table",datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[datasetIndex].label});return this.localize("chartSpatialPoint",void 0,{series:series[datasetIndex].label,id:point.id,sourceIndex:this.formatSummaryValue(point.sourceIndex),coordinates,hidden:this.canonicalHiddenDatasets()?.includes(datasetIndex)?this.localize("chartSpatialHidden"):""})}spatialBinText(bin){const format=value=>this.formatSummaryValue(value);return this.localize("chartSpatialBin",void 0,{count:format(bin.count),minX:format(bin.bounds.minX),maxX:format(bin.bounds.maxX),minY:format(bin.bounds.minY),maxY:format(bin.bounds.maxY)})}activateSpatialPoint(point){const current=this.spatialGuard(()=>this.spatialPoints().includes(point));if(!current())return;const binding=this.spatial.binding,result=this.spatial.result;if(this.emit("lr-spatial-point-select",Object.freeze({revision:binding.revision,point})),!current()||!result.points.includes(point))return;const datasetIndex=this.spatial.binding.chart.series.findIndex(series=>series.id===point.seriesId),index=this.spatialSeriesPoints(!0)[datasetIndex].indexOf(point);if(index<0)return;const datum={datasetIndex,index,label:point.label,value:Object.freeze({x:point.x,y:point.y,...point.radius===void 0?{}:{r:point.radius},...point.label===void 0?{}:{label:point.label}})};this.emit("lr-point-activate",datum),current()&&this.emit("lr-datum-activate",{...datum,kind:"point"})}activateSpatialBin(bin){this.spatialGuard(()=>this.spatial.result?.bins.includes(bin)===!0)()&&this.emit("lr-spatial-bin-select",Object.freeze({revision:this.spatial.binding.revision,bounds:bin.bounds,count:bin.count}))}async revealSpatialPoint(id){const token=this.spatialRevealToken={};this.wakeSpatialWaiters(),this.preparedDirty&&await this.updateComplete;const epoch=this.spatial.authority.epoch,binding=this.spatial.binding,owner=this.ownerDocument,current=()=>token===this.spatialRevealToken&&this.spatialActive&&this.isConnected&&owner===this.ownerDocument&&binding===this.spatial.binding&&epoch===this.spatial.authority.epoch;if(!current()||this.spatial.error)return!1;const point=await this.spatial.reveal(id);if(!point||!current())return!1;const series=this.spatial.binding.chart.series.findIndex(series2=>series2.id===point.seriesId);if(this.canonicalHiddenDatasets()?.includes(series))return!1;const viewport=this.spatial.panTo(point);if(viewport===void 0||(viewport!==this.viewport&&(this.viewport=viewport),await this.updateComplete,!current())||(this.spatial.loading&&await new Promise(resolve=>this.spatialWaiters.add(resolve)),!current()||this.spatial.error)||(await this.updateComplete,!current()))return!1;const index=this.spatialKeyboardItems().findIndex(item=>"id"in item&&item.id===id),canvas=this.canvasEl;return index<0||!canvas?!1:(this.spatialKeyboardIndex=index,canvas.focus(),current()&&!this.spatial.error&&!this.spatial.loading&&this.canvasEl===canvas&&this.spatialKeyboardItems().includes(point)&&this.renderRoot.querySelector(":focus")===canvas)}spatialKeyboardItems(){const hidden=this.canonicalHiddenDatasets()??[];return[...this.spatialSeriesPoints(!0).flatMap((points,index)=>hidden.includes(index)?[]:points),...this.spatial.result?.bins??[]]}spatialKeyDown(event){if(!this.spatialGuard()())return;const items=this.spatialKeyboardItems();if(!items.length)return;let next=Math.min(this.spatialKeyboardIndex,items.length-1);if(event.key==="Enter"||event.key===" "){if(event.preventDefault(),event.repeat)return;const item2=items[next];"id"in item2?this.activateSpatialPoint(item2):this.activateSpatialBin(item2);return}const rtl=this.effectiveDirection==="rtl";if(event.key==="Home")next=0;else if(event.key==="End")next=items.length-1;else if(event.key===(rtl?"ArrowLeft":"ArrowRight")||event.key==="ArrowDown")next=Math.min(items.length-1,next+1);else if(event.key===(rtl?"ArrowRight":"ArrowLeft")||event.key==="ArrowUp")next=Math.max(0,next-1);else return;event.preventDefault(),this.spatialKeyboardIndex=next;const item=items[next];this.keyboardDatumAnnouncement="id"in item?this.spatialPointText(item):this.spatialBinText(item)}renderSpatialTable(){return html`<table class=${this.dataTableVisible?nothing:"sr-only"}><caption>${this.accessibleName(this.localize("chartData"))}</caption>
|
|
1
|
+
import{__decorate}from"tslib";import{SpatialSourceController,spatialContains}from"../../../internal/spatial-source-controller.js";import{spatialCoordinate,spatialOriginal,spatialPaintRadius,spatialCsv}from"./chart-spatial-data.js";import{SourceRequestController}from"../../../internal/source-request-controller.js";import{prepareChartModel,revealPreparedSourcePoint}from"./chart-prepared-data.js";import{snapshotStructuredData,admitSnapshotArray,snapshotArrayStillAdmitted as chartArrayIsStillAdmitted,projectSnapshotArray}from"../../../internal/structured-snapshot.js";import{LazyChartSyncController}from"./chart-sync-lazy.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";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-host-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{createReducedMotionWatch}from"./chart-surface-shared.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{onAnnotationPluginRegistered}from"../../../internal/chart-annotation-registration.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult,loadChartJsWithAnnotationResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import{chartSurfaceStyles}from"./chart-surface.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{formatChartValue}from"./chart-number-format.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{showChartActiveDatum}from"./chart-active-datum.js";import{devWarnOnce}from"../../../internal/dev-warning.js";import{getOwnDataDescriptor,readOwnDataValue,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{FALLBACK_GRID_COLOR,FALLBACK_LEGEND_COLOR,FALLBACK_TICK_COLOR,FALLBACK_TICK_FONT_SIZE,FALLBACK_TOOLTIP_BG,FALLBACK_TOOLTIP_TEXT}from"./chart-colors.js";import{ChartTokenCache}from"./chart-token-cache.js";import{chartDataTableVisible,hasSlottedChartDataTable}from"./chart-data-table.js";import{normalizeSize}from"../../../internal/variants.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes,normalizeChartRecordLimit}from"./chart-table-sampling.js";import{canvasSentence,canvasTextDirection,isolateCanvasLabel,isolateCanvasText,isolatedMessage,isolateScaleTickLabels,tooltipIsolationHook,bidiStyles,isolateHtml}from"./chart-bidi.js";import{CSS_NUMBER_SOURCE}from"../../../internal/css-number.js";import{LYRA_DEFAULT_chartAnnotationsUnavailable,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartInputLimit,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPlotSampled,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPreparedSummaryZoom,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartRenderUnavailable,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartSpatialBin,LYRA_DEFAULT_chartSpatialDensityLegend,LYRA_DEFAULT_chartSpatialHidden,LYRA_DEFAULT_chartSpatialPoint,LYRA_DEFAULT_chartSpatialRadiusDomain,LYRA_DEFAULT_chartSpatialSummary,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,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_chartValuePercentageLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_liteChartMarkSummary}from"../../../internal/default-strings/charts.generated.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartPreparedSummary,LYRA_DEFAULT_chartPreparedUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_loading,LYRA_DEFAULT_noData,LYRA_DEFAULT_resetZoom}from"../../../internal/default-strings/shared.generated.js";const DIRECT_PIXEL_NUMBER=new RegExp(`^(${CSS_NUMBER_SOURCE})(?:px)?$`,"i");import{seriesPalette}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]);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"?value:projectLegendPosition(value)??"top"}function isArcDatasetType(datasetType){return datasetType==="pie"||datasetType==="doughnut"||datasetType==="polarArea"}function isPointDatasetType(datasetType){return datasetType==="line"||datasetType==="radar"||datasetType==="scatter"||datasetType==="bubble"}function isChartRecord(value){try{return typeof value=="object"&&value!==null&&!Array.isArray(value)}catch{return!1}}const MAX_CHART_INPUT_ENTRIES=1e4,CHART_INPUT_CAP_WARNING_KEY="lr-chart-input-cap",MAX_CHART_CONFIGURATION_DEPTH=32,OMIT_CHART_CONFIGURATION_VALUE=Symbol("omit-chart-configuration-value");function warnChartInputCap(){devWarnOnce(CHART_INPUT_CAP_WARNING_KEY,"lr-chart: an input array exceeded 10,000 entries; only the first 10,000 are used.")}const truncatedChartInputs=new WeakSet;function retainChartInputLimit(source,value){typeof source=="object"&&source!==null&&truncatedChartInputs.has(source)&&typeof value=="object"&&value!==null&&truncatedChartInputs.add(value)}function admitChartArray(value){let truncated=!1;const admitted=admitSnapshotArray(value,()=>{truncated=!0,warnChartInputCap()});return admitted&&truncated&&truncatedChartInputs.add(admitted.source),admitted}function copyChartArrayEntries(admission){const value=projectSnapshotArray(admission,value2=>value2,{missing:void 0})??Object.freeze([]);return retainChartInputLimit(admission.source,value),value}function chartEnumerableKeys(value){try{return Object.keys(value)}catch{return}}const canonicalChartSeriesSnapshots=new WeakMap,admittedChartPlugins=new WeakSet,canonicalChartDatasetValues=new WeakMap,canonicalChartDatasetDataValues=new WeakMap,canonicalChartDataSnapshots=new WeakSet;function canonicalChartSeries(value){if(isChartRecord(value))return canonicalChartSeriesSnapshots.has(value)?value:projectChartSeries(value)}function canonicalSeriesData(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.data??[]:[]}function canonicalSeriesPoints(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.points:void 0}function chartRecordValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectChartNumberData(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:null,{missing:null})}function projectChartPoint(value){if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label");return x===MISSING_OWN_DATA_DESCRIPTOR||x===UNSAFE_OWN_DATA_DESCRIPTOR||y===MISSING_OWN_DATA_DESCRIPTOR||y===UNSAFE_OWN_DATA_DESCRIPTOR||r===UNSAFE_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||typeof x.value!="number"||!Number.isFinite(x.value)||typeof y.value!="number"||!Number.isFinite(y.value)?null:Object.freeze({x:x.value,y:y.value,...r!==MISSING_OWN_DATA_DESCRIPTOR&&typeof r.value=="number"&&Number.isFinite(r.value)&&r.value>=0?{r:r.value}:{},...id!==MISSING_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))?{id:id.value}:{},...label!==MISSING_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?{label:label.value}:{}})}function projectChartDatum(value){if(typeof value=="number")return Number.isFinite(value)?value:null;if(typeof value=="string"||typeof value=="bigint")return value;if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label"),output={};let hasValue=!1;for(const[property2,descriptor]of[["x",x],["y",y],["r",r]])descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value)||(output[property2]=descriptor.value,hasValue=!0);return label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"&&(output.label=label.value,hasValue=!0),id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))&&(output.id=id.value,hasValue=!0),hasValue?Object.freeze(output):null}function projectChartDatasetValues(admission){return projectSnapshotArray(admission,projectChartDatum,{missing:null})??Object.freeze([])}function projectChartPoints(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartPoint,{missing:null})}function projectChartStrings(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="string"?entry:"",{missing:""})}function projectChartPointRadii(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:Number.NaN,{missing:Number.NaN})}function projectHiddenDatasetIndexes(value){if(value!==void 0)return projectSnapshotArray(admitChartArray(value),entry=>typeof entry=="number"&&Number.isInteger(entry)?entry:void 0,{compact:!0})??Object.freeze([])}const CHART_ANNOTATION_TONES=new Set(["neutral","brand","success","warning","danger"]);function projectChartAnnotations(value){if(!Array.isArray(value))return Object.freeze([]);const output=[];for(const annotation of value){if(!isChartRecord(annotation))continue;const own=key=>Object.hasOwn(annotation,key)?annotation[key]:void 0,axis=own("axis"),line=own("value"),from=own("from"),to=own("to"),label=own("label"),tone=own("tone");if(axis!==void 0&&axis!=="x"&&axis!=="y"||label!==void 0&&typeof label!="string"||tone!==void 0&&(typeof tone!="string"||!CHART_ANNOTATION_TONES.has(tone)))continue;const common={...axis==="x"||axis==="y"?{axis}:{},...typeof label=="string"?{label}:{},...typeof tone=="string"?{tone}:{}};typeof line=="number"&&Number.isFinite(line)?output.push(Object.freeze({...common,value:line})):typeof from=="number"&&Number.isFinite(from)&&typeof to=="number"&&Number.isFinite(to)&&output.push(Object.freeze({...common,from:Math.min(from,to),to:Math.max(from,to)}))}return Object.freeze(output)}const CHART_SERIES_PROPERTIES=["label","data","points","color","fill","width","dash","noTooltip","axis","stack","pointColors","pointRadius","segmentColors","type"];function projectChartSeries(value){if(typeof value=="object"&&value!==null&&canonicalChartSeriesSnapshots.has(value))return value;if(!isChartRecord(value))return;const descriptors=new Map;for(const property2 of CHART_SERIES_PROPERTIES){const descriptor=chartRecordValue(value,property2);if(descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)return;descriptors.set(property2,descriptor)}const valueAt=property2=>{const descriptor=descriptors.get(property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||descriptor===void 0?void 0:descriptor.value},label=valueAt("label");if(label!==void 0&&typeof label!="string")return;const output={label:label??""},rawData=valueAt("data"),rawDataAdmission=admitChartArray(rawData),data=projectChartNumberData(rawData,rawDataAdmission),rawPoints=valueAt("points"),rawPointsAdmission=admitChartArray(rawPoints),points=projectChartPoints(rawPoints,rawPointsAdmission),color=valueAt("color"),fill=valueAt("fill"),width=valueAt("width"),dash=valueAt("dash"),noTooltip=valueAt("noTooltip"),axis=valueAt("axis"),stack=valueAt("stack"),pointColors=projectChartStrings(valueAt("pointColors")),pointRadius=valueAt("pointRadius"),segmentColors=projectChartStrings(valueAt("segmentColors")),type=valueAt("type");if(data&&rawDataAdmission&&(output.data=rawDataAdmission.source),points&&rawPointsAdmission&&(output.points=rawPointsAdmission.source),typeof color=="string")output.color=color;else{const colors=projectChartStrings(color);colors&&(output.color=colors)}if(typeof fill=="boolean"&&(output.fill=fill),typeof width=="number"&&Number.isFinite(width)&&(output.width=width),typeof dash=="boolean"&&(output.dash=dash),typeof noTooltip=="boolean"&&(output.noTooltip=noTooltip),(axis==="y"||axis==="y2")&&(output.axis=axis),typeof stack=="string"&&(output.stack=stack),pointColors&&(output.pointColors=pointColors),typeof pointRadius=="number"&&Number.isFinite(pointRadius))output.pointRadius=pointRadius;else{const radii=projectChartPointRadii(pointRadius);radii&&(output.pointRadius=radii)}segmentColors&&(output.segmentColors=segmentColors),(type==="line"||type==="bar")&&(output.type=type);const series=Object.freeze(output);return retainChartInputLimit(rawData,series),retainChartInputLimit(rawPoints,series),canonicalChartSeriesSnapshots.set(series,{data:data??Object.freeze([]),...points?{points}:{}}),series}function appendChartSeries(series,data){const values=Object.freeze(data),result=Object.freeze({...series,data:values});return canonicalChartSeriesSnapshots.set(result,{data:values}),result}function normalizeChartSeries(value){const result=projectSnapshotArray(admitChartArray(value),canonicalChartSeries,{compact:!0})??Object.freeze([]);return retainChartInputLimit(value,result),result.some(series=>truncatedChartInputs.has(series))&&truncatedChartInputs.add(result),result}function isSafeChartConfigurationRecord(value){if(!isChartRecord(value))return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype}catch{return!1}}function projectLegendPosition(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output={};for(const key of keys){if(UNSAFE_KEYS.has(key))return;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value))return;output[key]=descriptor.value}return Object.freeze(output)}function copyChartConfigurationValue(value,profile="chart"){const snapshot=snapshotStructuredData(value,{profile,omitKeys:UNSAFE_KEYS,onArrayTruncate:warnChartInputCap,onClone:(source,copied)=>{retainChartInputLimit(source,copied);const canonical=canonicalChartDatasetDataValues.get(source);canonical&&canonicalChartDatasetDataValues.set(copied,canonical)}});return snapshot.truncated&&typeof snapshot.value=="object"&&snapshot.value!==null&&truncatedChartInputs.add(snapshot.value),snapshot.value===void 0&&value!==void 0?OMIT_CHART_CONFIGURATION_VALUE:snapshot.value}function projectChartPlugins(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,candidate=>{if(candidate===null||typeof candidate!="object"&&typeof candidate!="function")return;const plugin=candidate;if(admittedChartPlugins.has(plugin))return plugin;const id=chartRecordValue(plugin,"id");if(!(id===MISSING_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||typeof id.value!="string"||id.value.trim()===""))return admittedChartPlugins.add(plugin),plugin},{compact:!0})??Object.freeze([])}function projectChartDatasetConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null),priorCanonicalValues=canonicalChartDatasetValues.get(value);let canonicalValues;for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const candidate=descriptor.value,array=admitChartArray(candidate);if(key==="data"){if(array){const copied=copyChartArrayEntries(array);output[key]=copied;const canonical=priorCanonicalValues??canonicalChartDatasetDataValues.get(array.source)??projectChartDatasetValues(array);canonicalValues=canonical,canonicalChartDatasetDataValues.set(copied,canonical)}continue}if(key==="label"){typeof candidate=="string"||typeof candidate=="number"||typeof candidate=="boolean"||typeof candidate=="bigint"?output[key]=candidate:array&&(output[key]=copyChartArrayEntries(array));continue}if(key==="hidden"||key==="noTooltip"){typeof candidate=="boolean"&&(output[key]=candidate);continue}if(key==="axis"||key==="yAxisID"||key==="type"||key==="stack"){typeof candidate=="string"&&(output[key]=candidate);continue}output[key]=array?copyChartArrayEntries(array):candidate}const dataset=Object.freeze(output);return canonicalValues&&canonicalChartDatasetValues.set(dataset,canonicalValues),dataset}function projectChartDatasetConfigurations(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartDatasetConfiguration,{compact:!0})??Object.freeze([])}function projectChartDataConfiguration(value){if(typeof value=="object"&&value!==null&&canonicalChartDataSnapshots.has(value))return value;if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)){if(key==="labels"){const labels=admitChartArray(descriptor.value);output[key]=labels?copyChartArrayEntries(labels):Object.freeze([]);continue}if(key==="datasets"){output[key]=projectChartDatasetConfigurations(descriptor.value);continue}output[key]=descriptor.value}}return retainChartInputLimit(value,output),canonicalChartDataSnapshots.add(output),Object.freeze(output)}function projectChartConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const output=Object.create(null),type=chartRecordValue(value,"type"),data=chartRecordValue(value,"data"),options=chartRecordValue(value,"options"),plugins=chartRecordValue(value,"plugins");type!==MISSING_OWN_DATA_DESCRIPTOR&&type!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof type.value=="string"&&(output.type=type.value);for(const[property2,descriptor]of[["data",data],["options",options]]){if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const copied=copyChartConfigurationValue(descriptor.value,property2==="data"?"chartData":"chart");if(copied!==OMIT_CHART_CONFIGURATION_VALUE){if(property2==="data"){const projected=projectChartDataConfiguration(copied);output[property2]=projected??copied,retainChartInputLimit(copied,output);continue}output[property2]=copied}}if(plugins!==MISSING_OWN_DATA_DESCRIPTOR&&plugins!==UNSAFE_OWN_DATA_DESCRIPTOR){const pluginArray=admitChartArray(plugins.value);if(pluginArray)output.plugins=projectChartPlugins(plugins.value,pluginArray);else{const copied=copyChartConfigurationValue(plugins.value);copied!==OMIT_CHART_CONFIGURATION_VALUE&&(output.plugins=copied)}}return Object.freeze(output)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]);function deepMerge(base,override,seen=new WeakMap){if(!isSafeChartConfigurationRecord(base)||!isSafeChartConfigurationRecord(override))return override===void 0?base:override;const baseRecord=base,overrideRecord=override,baseKeys=chartEnumerableKeys(baseRecord),overrideKeys=chartEnumerableKeys(overrideRecord);if(!baseKeys||!overrideKeys)return override;const previous=seen.get(overrideRecord);if(previous!==void 0)return previous;const result={};for(const key of baseKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(baseRecord,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(result[key]=descriptor.value)}seen.set(overrideRecord,result);try{for(const key of overrideKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(overrideRecord,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const baseDescriptor=chartRecordValue(baseRecord,key),baseValue=baseDescriptor===MISSING_OWN_DATA_DESCRIPTOR||baseDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:baseDescriptor.value;result[key]=deepMerge(baseValue,descriptor.value,seen)}}finally{seen.delete(overrideRecord)}return result}function normalizedChartPoint(value){return projectChartPoint(projectChartDatum(value))}function chartNumericValue(value){const numeric=typeof value=="number"?value:typeof value=="string"||typeof value=="bigint"?Number(value):Number.NaN;return Number.isFinite(numeric)?numeric:void 0}function chartDatumNumericValue(value){const projected=projectChartDatum(value);if(isChartRecord(projected))for(const property2 of["y","r","x"]){const descriptor=chartRecordValue(projected,property2);if(descriptor!==MISSING_OWN_DATA_DESCRIPTOR&&descriptor!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof descriptor.value=="number"&&Number.isFinite(descriptor.value))return descriptor.value}return chartNumericValue(projected)}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value,depth=0){if(value==null)return"";if(typeof value=="string"||typeof value=="number"||typeof value=="boolean"||typeof value=="bigint")return String(value);const admission=admitChartArray(value);if(depth<MAX_CHART_CONFIGURATION_DEPTH&&admission){const values=[];for(let index=0;index<admission.length;index+=1)values.push(labelText(readOwnDataValue(admission.source,String(index)),depth+1));return values.join(" ")}return""}function chartDatasetValue(dataset,property2){if(!isChartRecord(dataset))return;const descriptor=chartRecordValue(dataset,property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function chartDatasetLabel(dataset){return labelText(chartDatasetValue(dataset,"label"))}function chartDatasetValues(dataset){if(isChartRecord(dataset)){const snapshot=canonicalChartDatasetValues.get(dataset);if(snapshot)return snapshot}const data=chartDatasetValue(dataset,"data"),admission=admitChartArray(data);return admission?canonicalChartDatasetDataValues.get(admission.source)??copyChartArrayEntries(admission):Object.freeze([])}function chartDatasetPeerValues(dataset){const data=chartDatasetValue(dataset,"data");return typeof data=="object"&&data!==null&&canonicalChartDatasetDataValues.has(data)?data:Object.freeze([])}function chartIndex(value){return typeof value=="number"&&Number.isSafeInteger(value)&&value>=0?value:void 0}function chartCallbackDatasetIndex(value){return chartIndex(chartDatasetValue(value,"datasetIndex"))}function chartCallbackIndexes(value){const datasetIndex=chartCallbackDatasetIndex(value),index=chartIndex(chartDatasetValue(value,"index"))??chartIndex(chartDatasetValue(value,"dataIndex"));return datasetIndex===void 0||index===void 0?void 0:{datasetIndex,index}}function projectChartLegendItem(value){if(!isChartRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(output[key]=descriptor.value)}return output}function projectChartLegendItems(value){const admission=admitChartArray(value);if(!admission||!chartArrayIsStillAdmitted(admission))return;const output=[];for(let index=0;index<admission.length;index+=1){const descriptor=chartRecordValue(admission.source,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectChartLegendItem(descriptor.value);item&&output.push(item)}return Object.freeze(output)}function chartDatasetBoolean(dataset,property2){const value=chartDatasetValue(dataset,property2);return typeof value=="boolean"?value:void 0}function chartDatasetAxis(dataset){return chartDatasetValue(dataset,"yAxisID")==="y2"||chartDatasetValue(dataset,"axis")==="y2"?"y2":"y"}function chartDatasetStack(dataset){const value=chartDatasetValue(dataset,"stack");return typeof value=="string"?value:void 0}function isDenseChartSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAnnotationsUnavailable:LYRA_DEFAULT_chartAnnotationsUnavailable,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartInputLimit:LYRA_DEFAULT_chartInputLimit,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPlotSampled:LYRA_DEFAULT_chartPlotSampled,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPreparedSummary:LYRA_DEFAULT_chartPreparedSummary,chartPreparedSummaryZoom:LYRA_DEFAULT_chartPreparedSummaryZoom,chartPreparedUnavailable:LYRA_DEFAULT_chartPreparedUnavailable,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartRenderUnavailable:LYRA_DEFAULT_chartRenderUnavailable,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartSpatialBin:LYRA_DEFAULT_chartSpatialBin,chartSpatialDensityLegend:LYRA_DEFAULT_chartSpatialDensityLegend,chartSpatialHidden:LYRA_DEFAULT_chartSpatialHidden,chartSpatialPoint:LYRA_DEFAULT_chartSpatialPoint,chartSpatialRadiusDomain:LYRA_DEFAULT_chartSpatialRadiusDomain,chartSpatialSummary:LYRA_DEFAULT_chartSpatialSummary,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,chartValuePercentageLabel:LYRA_DEFAULT_chartValuePercentageLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,noData:LYRA_DEFAULT_noData,resetZoom:LYRA_DEFAULT_resetZoom}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-legend-visibility-change-request","lr-legend-visibility-change","lr-datum-visibility-change-request","lr-datum-visibility-change"])}static{this.ownedCollectionProperties=Object.freeze(["annotations","hiddenDatasets"])}static{this.styles=[LyraElement.styles,specialistTokens,chartSurfaceStyles,styles,srOnly,bidiStyles]}constructor(){super(),this.canvasTokens=new ChartTokenCache(this),this.type="bar",this._preparedData=null,this.viewport=null,this.selectedPointId="",this.spatialActive=!1,this.spatial=new SpatialSourceController(this,()=>this.spatialChanged(),()=>this.effectiveLocale),this.spatialWaiters=new Set,this.spatialRevealToken={},this.preparedGeneration={},this.legendDataGeneration={},this.spatialKeyboardIndex=0,this.preparedDirty=!0,this.preparedActive=!1,this.preparedChanged=!1,this.preparedInvalid=!1,this.preparedPending=!1,this.preparedRequestFailed=!1,this.announcedPreparedInvalid=!1,this.preparedRequests=new SourceRequestController(this,{channels:["point"],onReset:()=>{this.preparedPending=!1}}),this.labels=[],this.maxRecords=1e3,this.samplingWidth=0,this._datasets=Object.freeze([]),this.datasetsSource=this._datasets,this._hiddenDatums=Object.freeze([]),this.hiddenDatumsSource=this._hiddenDatums,this.legendMode="auto",this.legendDisplay="auto",this.description=null,this.grid="both",this.axes="both",this.size="m",this.indexAxis="x",this.label=null,this.legendPosition="top",this.scaleType="linear",this.annotations=[],this.max=null,this.min=null,this._plugins=Object.freeze([]),this.pluginsSource=this._plugins,this.area=!1,this.zoomable=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.withoutZeroBaseline=!1,this.withDataTable=!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.configSource=void 0,this.loading=!0,this.loadFailed=!1,this.canvasUnavailable=!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.annotationFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.reducedMotionWatch=createReducedMotionWatch(this,()=>this.drawIfVisible()),this.scaledSliceDatasets=new Set,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.chartAreaPlugin={id:"lyra-chart-area",afterLayout:chart=>this.updateChartArea(chart),beforeTooltipDraw:tooltipIsolationHook(()=>this.effectiveDirection)},this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.announcements=new AnnouncementSinkController(this),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.syncGroup="",this.chartSync=new LazyChartSyncController(this,(label,index)=>this.syncPresentation(label,index),()=>this.resetSyncTooltip(),target=>target===this.canvasEl),this.forcedColorPatterns=new Map,this.visualPositions=new WeakMap,this.keyboardDatumShown=!1,this.onCanvasBlur=()=>{this.showKeyboardDatum(void 0)},this.seriesSummaryMemo=new WeakMap,this.streamingTableUpdate=!1,new ThemeWatcher(this,()=>{this.chart&&this.canvasTokens.hasThemeChanged()&&this.refreshTheme()})}get preparedData(){return this._preparedData}set preparedData(value){const previous=this._preparedData;this._preparedData=value,this.requestUpdate("preparedData",previous),value===previous&&this.requestUpdate()}preparedDataInput(){return this._preparedData}spatialChanged(){this.preparedChanged=!0,this.preparedPending=this.spatial?.loading??!1,this.preparedRequestFailed=this.spatial?.error??!1,this.descriptionMemo=void 0,this.dataTableRows=void 0,super.requestUpdate("spatialView",null),(!this.spatial?.loading||this.spatial.error)&&this.wakeSpatialWaiters()}wakeSpatialWaiters(){for(const resolve of this.spatialWaiters??[])resolve();this.spatialWaiters?.clear()}spatialPoints(){return this.spatial.points()}spatialSeriesPoints(visible=!1){const points=this.spatialPoints(),view=this.spatial.view,series=this.spatial.binding?.chart?.series??[],groups=series.map(()=>[]),indices=new Map(series.map((entry,index)=>[entry.id,index]));for(const point of points){const index=indices.get(point.seriesId);index!==void 0&&(!visible||view&&spatialContains(view,point))&&groups[index].push(point)}return groups}spatialGuard(member=()=>!0){const binding=this.spatial.binding,result=this.spatial.result,owner=this.ownerDocument,epoch=this.spatial.authority.epoch,generation=this.preparedGeneration;return event=>{const target=event?.currentTarget;return this.isConnected&&this.ownerDocument===owner&&this.spatialActive&&generation===this.preparedGeneration&&binding===this.spatial.binding&&result===this.spatial.result&&epoch===this.spatial.authority.epoch&&!this.spatial.loading&&!this.spatial.error&&member()&&(!event||!!target?.isConnected&&target.getRootNode()===this.renderRoot&&target.ownerDocument===owner)}}spatialPointText(point){const series=this.spatial.binding.chart.series,datasetIndex=series.findIndex(series2=>series2.id===point.seriesId),coordinates=this.datumDisplayValue({x:point.x,y:point.y,...point.radius===void 0?{}:{r:point.radius}},{surface:"table",datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[datasetIndex].label});return this.localize("chartSpatialPoint",void 0,{series:series[datasetIndex].label,id:point.id,sourceIndex:this.formatSummaryValue(point.sourceIndex),coordinates,hidden:this.canonicalHiddenDatasets()?.includes(datasetIndex)?this.localize("chartSpatialHidden"):""})}spatialBinText(bin){const format=value=>this.formatSummaryValue(value);return this.localize("chartSpatialBin",void 0,{count:format(bin.count),minX:format(bin.bounds.minX),maxX:format(bin.bounds.maxX),minY:format(bin.bounds.minY),maxY:format(bin.bounds.maxY)})}activateSpatialPoint(point){const current=this.spatialGuard(()=>this.spatialPoints().includes(point));if(!current())return;const binding=this.spatial.binding,result=this.spatial.result;if(this.emit("lr-spatial-point-select",Object.freeze({revision:binding.revision,point})),!current()||!result.points.includes(point))return;const datasetIndex=this.spatial.binding.chart.series.findIndex(series=>series.id===point.seriesId),index=this.spatialSeriesPoints(!0)[datasetIndex].indexOf(point);if(index<0)return;const datum={datasetIndex,index,label:point.label,value:Object.freeze({x:point.x,y:point.y,...point.radius===void 0?{}:{r:point.radius},...point.label===void 0?{}:{label:point.label}})};this.emit("lr-point-activate",datum),current()&&this.emit("lr-datum-activate",{...datum,kind:"point"})}activateSpatialBin(bin){this.spatialGuard(()=>this.spatial.result?.bins.includes(bin)===!0)()&&this.emit("lr-spatial-bin-select",Object.freeze({revision:this.spatial.binding.revision,bounds:bin.bounds,count:bin.count}))}async revealSpatialPoint(id){const token=this.spatialRevealToken={};this.wakeSpatialWaiters(),this.preparedDirty&&await this.updateComplete;const epoch=this.spatial.authority.epoch,binding=this.spatial.binding,owner=this.ownerDocument,current=()=>token===this.spatialRevealToken&&this.spatialActive&&this.isConnected&&owner===this.ownerDocument&&binding===this.spatial.binding&&epoch===this.spatial.authority.epoch;if(!current()||this.spatial.error)return!1;const point=await this.spatial.reveal(id);if(!point||!current())return!1;const series=this.spatial.binding.chart.series.findIndex(series2=>series2.id===point.seriesId);if(this.canonicalHiddenDatasets()?.includes(series))return!1;const viewport=this.spatial.panTo(point);if(viewport===void 0||(viewport!==this.viewport&&(this.viewport=viewport),await this.updateComplete,!current())||(this.spatial.loading&&await new Promise(resolve=>this.spatialWaiters.add(resolve)),!current()||this.spatial.error)||(await this.updateComplete,!current()))return!1;const index=this.spatialKeyboardItems().findIndex(item=>"id"in item&&item.id===id),canvas=this.canvasEl;return index<0||!canvas?!1:(this.spatialKeyboardIndex=index,canvas.focus(),current()&&!this.spatial.error&&!this.spatial.loading&&this.canvasEl===canvas&&this.spatialKeyboardItems().includes(point)&&this.renderRoot.querySelector(":focus")===canvas)}spatialKeyboardItems(){const hidden=this.canonicalHiddenDatasets()??[];return[...this.spatialSeriesPoints(!0).flatMap((points,index)=>hidden.includes(index)?[]:points),...this.spatial.result?.bins??[]]}spatialKeyDown(event){if(!this.spatialGuard()())return;const items=this.spatialKeyboardItems();if(!items.length)return;let next=Math.min(this.spatialKeyboardIndex,items.length-1);if(event.key==="Enter"||event.key===" "){if(event.preventDefault(),event.repeat)return;const item2=items[next];"id"in item2?this.activateSpatialPoint(item2):this.activateSpatialBin(item2);return}const rtl=this.effectiveDirection==="rtl";if(event.key==="Home")next=0;else if(event.key==="End")next=items.length-1;else if(event.key===(rtl?"ArrowLeft":"ArrowRight")||event.key==="ArrowDown")next=Math.min(items.length-1,next+1);else if(event.key===(rtl?"ArrowRight":"ArrowLeft")||event.key==="ArrowUp")next=Math.max(0,next-1);else return;event.preventDefault(),this.spatialKeyboardIndex=next;const item=items[next];this.keyboardDatumAnnouncement="id"in item?this.spatialPointText(item):this.spatialBinText(item)}renderSpatialTable(){return html`<table class=${this.dataTableVisible?nothing:"sr-only"}><caption>${this.accessibleName(this.localize("chartData"))}</caption>
|
|
2
2
|
<thead><tr><th scope="col">${this.localize("chartCategory")}</th><th scope="col">${this.localize("chartData")}</th></tr></thead><tbody>
|
|
3
3
|
${this.spatialPoints().map(point=>{const current=this.spatialGuard(()=>this.spatialPoints().includes(point));return html`<tr><th scope="row">${point.label??point.id}</th><td><button type="button" tabindex=${this.dataTableVisible?"0":"-1"} data-spatial-id=${point.id}
|
|
4
4
|
@click=${event=>{current(event)&&this.activateSpatialPoint(point)}}>${this.spatialPointText(point)}</button></td></tr>`})}
|
|
@@ -9,7 +9,7 @@ import{__decorate}from"tslib";import{SpatialSourceController,spatialContains}fro
|
|
|
9
9
|
${background}
|
|
10
10
|
${surface}`;let pattern=this.forcedColorPatterns.get(key);return pattern||(pattern=createForcedColorPattern(this.ownerDocument,index,background,surface),this.forcedColorPatterns.set(key,pattern)),pattern}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(){return this.canonicalAnnotations()}annotationColor(tone){const token=`--lr-color-${tone??"neutral"}`,raw=this.computedStyle().getPropertyValue(token).trim();return this.canvasTokens.resolve(raw,FALLBACK_TICK_COLOR)}annotationOptions(tick){const entries={},direction=this.effectiveDirection==="rtl"?"rtl":"ltr";return this.normalizedAnnotations().forEach((entry,index)=>{const axis=entry.axis==="x"?"x":"y",color=this.annotationColor(entry.tone),label=entry.label?{content:isolateCanvasText(entry.label,direction),display:!0,color: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:this.canvasTokens.translucent(color),borderColor:color,borderWidth:0,...label?{label}:{}}}),entries}datalabelsOptions(theme,effectiveType){if(!this.needsDataLabels)return{display:!1};const effective=this.effectiveData(),datasets=effective.datasets,stackTotalsPossible=this.stackTotals&&(effectiveType==="bar"||effectiveType==="line"),sourceDatasetIndex=visualIndex=>this.visualDatasetSourceIndexes?.[visualIndex]??visualIndex,sourceRowIndex=visualIndex=>this.visualRowSourceIndexes?.[visualIndex]??visualIndex,topDatasetIndexByGroup=new Map;if(stackTotalsPossible){const visualDatasetCount=this.visualDatasetSourceIndexes?.length??datasets.length;for(let visualIndex=0;visualIndex<visualDatasetCount;visualIndex+=1){const dataset=datasets[sourceDatasetIndex(visualIndex)],axis=chartDatasetAxis(dataset);if(!this.axisStacked(axis))continue;let byGroup=topDatasetIndexByGroup.get(axis);byGroup||(byGroup=new Map,topDatasetIndexByGroup.set(axis,byGroup)),byGroup.set(chartDatasetStack(dataset),visualIndex)}}const totalsByGroup=new Map,totalsFor=(axis,stack)=>{let byGroup=totalsByGroup.get(axis);byGroup||(byGroup=new Map,totalsByGroup.set(axis,byGroup));let totals=byGroup.get(stack);return totals||(totals=this.computeStackTotals(axis,stack),byGroup.set(stack,totals)),totals},stackTotalsActive=[...topDatasetIndexByGroup.values()].some(byGroup=>byGroup.size>0),direction=this.effectiveDirection==="rtl"?"rtl":"ltr",isolate=text=>text.split(`
|
|
11
11
|
`).map(line=>isolateCanvasText(line,direction)).join(`
|
|
12
|
-
`);return{color:theme.tick,align:stackTotalsActive?"end":"center",anchor:stackTotalsActive?"end":"center",display:context=>{const indexes=this.callbackIndexes(context,effective);if(!indexes)return!1;const{datasetIndex,index}=indexes,dataset=datasets[sourceDatasetIndex(datasetIndex)],axis=chartDatasetAxis(dataset),stack=chartDatasetStack(dataset);return stackTotalsPossible&&this.axisStacked(axis)?topDatasetIndexByGroup.get(axis)?.get(stack)!==datasetIndex?this.dataLabels:totalsFor(axis,stack)[sourceRowIndex(index)]==null?this.dataLabels:!0:this.dataLabels},formatter:(value,context)=>{const indexes=this.callbackIndexes(context,effective);if(!indexes)return"";const{datasetIndex,index}=indexes,dataset=datasets[sourceDatasetIndex(datasetIndex)],axis=chartDatasetAxis(dataset),stack=chartDatasetStack(dataset),metadata=this.datumFormatterMetadata(datasetIndex,index,effective);if(stackTotalsPossible&&this.axisStacked(axis)&&topDatasetIndexByGroup.get(axis)?.get(stack)===datasetIndex){const total=totalsFor(axis,stack)[sourceRowIndex(index)];if(total!=null)return isolate(this.formatDataLabel(total,this.stackTotalMetadata(metadata)))}const numeric=chartDatumNumericValue(this.scaledSliceDatasets.has(datasetIndex)?this.datasetValues(dataset)[sourceRowIndex(index)]:value);return numeric===void 0?"":isolate(this.formatDataLabel(numeric,metadata))}}}formatDataLabel(value,metadata={}){if(this.formatter||this.valueFormatter){const formatted=this.formatter?.({value,surface:"visual",...metadata})??this.valueFormatter?.(value,"tooltip");if(formatted!=null)return String(formatted)}return formatChartValue(value,this.effectiveLocale)}computeStackTotals(axisId="y",stackGroup){const effective=this.effectiveData(),members=effective.datasets.filter(dataset=>chartDatasetAxis(dataset)===axisId&&chartDatasetStack(dataset)===stackGroup),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=chartDatumNumericValue(value);numeric!==void 0&&(sum=finiteAdd(sum,numeric),any=!0)}totals.push(any?sum:null)}return totals}seriesPalette(){return this.canvasTokens.palette()}tickLabelIsolation(direction){return{afterTickToLabelConversion:scale=>isolateScaleTickLabels(scale,direction)}}tickOptions(theme,kind="value",axis="y"){return{color:theme.tick,font:{size:theme.tickFontSize},...(this.formatter||this.valueFormatter)&&kind==="value"?{callback:value=>this.formatValue(value,"tick",{axis})}:{}}}effectiveIndexAxis(){return this.indexAxis==="y"?"y":"x"}valueScaleType(){return this.scaleType==="logarithmic"?"logarithmic":"linear"}valueBeginAtZero(){return this.valueScaleType()==="logarithmic"?void 0:!this.withoutZeroBaseline}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}axisVisible(axis){const axes=normalizeChartGrid(this.axes);return!this.compactPlot&&(axes==="both"||axes===axis)}axisStacked(axisId){return axisId==="y2"?this.stackedAxes?.y2??this.stacked:this.stackedAxes?.y??this.stacked}buildScales(effectiveType,theme,chartStyle){if(effectiveType==="pie"||effectiveType==="doughnut")return{};const direction=this.effectiveDirection==="rtl"?"rtl":"ltr";if(effectiveType==="radar"||effectiveType==="polarArea"){const explicitPointLabelFontSize=this.explicitTickFontSize();return{r:{...this.tickLabelIsolation(direction),beginAtZero:!this.withoutZeroBaseline,...this.scaleBounds(),ticks:{...this.tickOptions(theme,"value","r"),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,callback:label=>isolateCanvasLabel(label,direction),...explicitPointLabelFontSize!==void 0?{font:{size:explicitPointLabelFontSize}}:{}}}}}const hasY2=this.effectiveData().datasets.some(dataset=>chartDatasetAxis(dataset)==="y2"),rtl=this.effectiveDirection==="rtl",stackableType=effectiveType==="bar"||effectiveType==="line",stackedX=stackableType&&this.axisStacked("x"),stackedY=stackableType&&this.axisStacked("y"),stackedY2=stackableType&&this.axisStacked("y2"),horizontalCategorical=(effectiveType==="bar"||effectiveType==="line")&&this.effectiveIndexAxis()==="y",xKind=this.preparedModel?.kind==="series"||effectiveType==="scatter"||effectiveType==="bubble"||horizontalCategorical?"value":"category",yKind=this.preparedModel?.kind==="series"?"value":horizontalCategorical?"category":"value",valueAxis=horizontalCategorical?"x":"y",bounds=this.scaleBounds(),prepared=this.preparedModel,fullBounds=axis=>{const domains=prepared?.kind==="series"?prepared.series.flatMap(series=>series[axis]?[series[axis]]:[]):[];return domains.length?{min:Math.min(...domains.map(domain=>domain.min)),max:Math.max(...domains.map(domain=>domain.max))}:{}};return{x:{...this.tickLabelIsolation(direction),display:this.axisVisible("x"),type:xKind==="value"?this.valueScaleType():"category",beginAtZero:xKind==="value"?this.valueBeginAtZero():void 0,...fullBounds("xDomain"),...valueAxis==="x"?bounds:{},title:{display:!!this.xLabel,text:isolateCanvasLabel(this.xLabel,direction),color:theme.tick},ticks:this.tickOptions(theme,xKind,"x"),grid:{color:theme.grid,display:this.gridAxisVisible("x"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked:stackedX},y:{...this.tickLabelIsolation(direction),display:this.axisVisible("y"),type:yKind==="value"?this.valueScaleType():"category",position:rtl?"right":"left",beginAtZero:yKind==="value"?this.valueBeginAtZero():void 0,...fullBounds("yDomain"),...valueAxis==="y"?bounds:{},title:{display:!!this.yLabel,text:isolateCanvasLabel(this.yLabel,direction),color:theme.tick},ticks:this.tickOptions(theme,yKind,"y"),grid:{color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked:stackedY},...hasY2?{y2:{...this.tickLabelIsolation(direction),display:this.axisVisible("y"),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:isolateCanvasLabel(this.y2Label,direction),color:theme.tick},ticks:this.tickOptions(theme,"value","y2"),stacked:stackedY2}}:{}}}handlePointClick(event,chart){if(!this.isConnected||chart!==this.chart)return;let elements;try{elements=chart.getElementsAtEventForMode(event,"nearest",{intersect:!0},!0)}catch{return}const admission=admitChartArray(elements);if(!admission||!chartArrayIsStillAdmitted(admission))return;const first=chartRecordValue(admission.source,"0");if(first===MISSING_OWN_DATA_DESCRIPTOR||first===UNSAFE_OWN_DATA_DESCRIPTOR)return;const effective=this.effectiveData(),hit=this.callbackIndexes(first.value,effective);if(!hit)return;const datasetIndex=this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex,index=this.visualRowSourceIndexes?.[hit.index]??hit.index,value=this.datasetValues(effective.datasets[datasetIndex])[index]??null,label=normalizedChartPoint(value)?.label??(labelText(effective.labels[index])||void 0);this.activateDatum({datasetIndex,index,label,value})}chartDatums(){const effective=this.effectiveData(),plan=this.dataTableSample(effective),memo=this.chartDatumsMemo;if(memo?.effective===effective&&memo.plan===plan&&memo.datasets===this.visualDatasetSourceIndexes&&memo.rows===this.visualRowSourceIndexes)return memo.value;const datasetIndexes=this.visualDatasetSourceIndexes??this.dataTableSample(effective).seriesIndexes,datasets=datasetIndexes.map(index=>effective.datasets[index]);let rowIndexes=this.visualRowSourceIndexes;rowIndexes||(rowIndexes=this.dataTableSample(effective).rowIndexes);const labels=rowIndexes.map(index=>effective.labels[index]),rowCount=rowIndexes.length,sample=this.preparedModel?{rowIndexes:Array.from({length:rowCount},(_,index)=>index),seriesIndexes:Array.from({length:datasets.length},(_,index)=>index)}:sampleChartTableIndexes(rowCount,datasets.length),datums=[];return sample.seriesIndexes.forEach(datasetIndex=>{const dataset=datasets[datasetIndex];if(!dataset)return;const values=chartDatasetValues(dataset);sample.rowIndexes.forEach(localIndex=>{const sourceIndex=rowIndexes[localIndex]??localIndex,value=values[sourceIndex];value!=null&&(typeof value=="number"&&!Number.isFinite(value)||datums.push({datasetIndex:datasetIndexes[datasetIndex]??datasetIndex,index:sourceIndex,label:normalizedChartPoint(value)?.label??(labelText(labels[localIndex])||void 0),value}))})}),this.chartDatumsMemo={plan,effective,datasets:this.visualDatasetSourceIndexes,rows:this.visualRowSourceIndexes,value:datums},datums}datumDisplayValue(value,context={surface:"spoken"}){const{surface,...metadata}=context,format=(numeric2,statistic)=>surface==="table"?this.formatTableValue(numeric2,{...metadata,statistic}):this.formatSpokenValue(numeric2,{...metadata,statistic}),point=normalizedChartPoint(value);if(point){const x=format(point.x,"x"),y=format(point.y,"y"),coordinates=point.r==null?this.localize("chartPointCoordinates",void 0,{x,y}):this.localize("chartBubblePointCoordinates",void 0,{x,y,radius:format(point.r,"r")});return point.label!==void 0?this.localize("chartLabeledPoint",void 0,{label:point.label,coordinates}):coordinates}const numeric=chartDatumNumericValue(value);return numeric===void 0?labelText(value):format(numeric)}datumAnnouncement(datum,position,total){const dataset=this.effectiveData().datasets[datum.datasetIndex],series=chartDatasetLabel(dataset)||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,{surface:"spoken",datasetIndex:datum.datasetIndex,index:datum.index,label:datum.label,seriesLabel:series,...this.datasetValueAxis(dataset)===void 0?{}:{axis:this.datasetValueAxis(dataset)}}),index:getNumberFormat(this.effectiveLocale).format(position+1),total:getNumberFormat(this.effectiveLocale).format(total)})}emitPreparedSourceSelection(datasetIndex,index){const model=this.preparedModel,series=model?.series[datasetIndex];if(model&&series)if(model.kind==="series"){const point=series.samples[index];point&&this.emit("lr-source-point-select",{revision:model.revision,seriesId:series.id,sourceIndex:point.sourceIndex,point:Object.freeze({x:point.x,y:point.y})})}else{const categoryId=model.categoryIds[index],value=series.values[index];categoryId!==void 0&&value!==void 0&&this.emit("lr-source-category-select",{revision:model.revision,seriesId:series.id,categoryId,value,observationCount:model.categoryCounts[index]})}}preparedSummary(){}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.emitPreparedSourceSelection(datum.datasetIndex,datum.index),this.emit("lr-datum-activate",{...datum,kind}),this.emit("lr-point-activate",{...datum})}resetSyncTooltip(){const chart=this.chart;chart?.tooltip?.setActiveElements([],{x:0,y:0}),chart?.render?.()}syncCompatible(){const chart=this.chart;if(!chart)return!1;const type=this.effectiveType();return type!=="bar"&&type!=="line"||chart.options.indexAxis==="y"?!1:chart.scales?.x?.type==="category"&&Array.isArray(chart.data?.datasets)&&chart.data.datasets.every(dataset=>dataset.type===void 0||dataset.type==="bar"||dataset.type==="line")}visualPosition(sources,source){if(!sources)return source;let positions=this.visualPositions.get(sources);return positions||(positions=new Map(sources.map((value,index)=>[value,index])),this.visualPositions.set(sources,positions)),positions.get(source)??-1}indexedSyncDatums(){const datums=this.chartDatums();if(this.syncDatumIndex?.datums===datums)return this.syncDatumIndex;const byAddress=new Map,byCategory=new Map;for(const datum of datums){byAddress.set(`${datum.datasetIndex}:${datum.index}`,datum);let category=byCategory.get(datum.index);category||(category=[],byCategory.set(datum.index,category)),category.push(datum)}const labels=this.effectiveData().labels,labelCategories=new Map;for(const index of[...byCategory.keys()].sort((a,b)=>a-b)){const label=labels[index];if(typeof label!="string")continue;let categories=labelCategories.get(label);categories||(categories=[],labelCategories.set(label,categories)),categories.push(index)}return this.syncDatumIndex={datums,byAddress,byCategory,labelCategories}}syncDatumIsEligible(datum){const chart=this.chart;if(!chart)return!1;const visualDataset=this.visualPosition(this.visualDatasetSourceIndexes,datum.datasetIndex),visualIndex=this.visualPosition(this.visualRowSourceIndexes,datum.index),element=chart.getDatasetMeta?.(visualDataset)?.data?.[visualIndex];return chart.isDatasetVisible(visualDataset)&&!!element&&!element.skip&&Number.isFinite(element.x)&&Number.isFinite(element.y)&&chartDatumNumericValue(datum.value)!==void 0}publishSyncDatum(datum){const label=this.effectiveData().labels[datum.index];typeof label=="string"?this.chartSync.publish(label,datum.index):this.chartSync.clear()}onSyncPointerMove(event){if(!this.chartSync.enabled||!this.chart)return;const hit=this.chart.getElementsAtEventForMode(event,"nearest",{intersect:!0},!0)[0];if(!hit){this.chartSync.clear();return}const datasetIndex=this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex,index=this.visualRowSourceIndexes?.[hit.index]??hit.index,datum=this.indexedSyncDatums().byAddress.get(`${datasetIndex}:${index}`);datum&&this.syncDatumIsEligible(datum)&&this.publishSyncDatum(datum)}syncPresentation(label,sourceIndex){if(!this.syncCompatible()||!this.canvasEl||!this.chart)return;const effective=this.effectiveData();if(sourceIndex!==void 0&&effective.labels[sourceIndex]!==label)return;const indexed=this.indexedSyncDatums(),categories=sourceIndex===void 0?indexed.labelCategories.get(label)??[]:[sourceIndex];let matches=[];for(const index of categories)if(matches=(indexed.byCategory.get(index)??[]).filter(datum=>this.syncDatumIsEligible(datum)),matches.length)break;if(!matches.length)return;const hits=matches.map(datum=>({datasetIndex:this.visualPosition(this.visualDatasetSourceIndexes,datum.datasetIndex),index:this.visualPosition(this.visualRowSourceIndexes,datum.index)})),runtime=this.chart,point=this.chart.getDatasetMeta?.(hits[0].datasetIndex)?.data?.[hits[0].index],area=this.chart.chartArea,container=this.renderRoot.querySelector('[part="plot"]');if(!point||!area||!container)return;const plugins=this.chart.options.plugins,suppressed=this.withoutTooltip||plugins?.tooltip===!1||plugins?.tooltip?.enabled===!1;runtime.tooltip?.setActiveElements(suppressed?[]:hits,{x:point.x,y:point.y}),runtime.render?.();const bounds=container.getBoundingClientRect(),canvasBounds=this.canvasEl.getBoundingClientRect(),categoryX=runtime.scales?.x?.getPixelForValue?.(hits[0].index);return{container,x:canvasBounds.left-bounds.left+(typeof categoryX=="number"&&Number.isFinite(categoryX)?categoryX:point.x),top:canvasBounds.top-bounds.top+area.top,height:area.height}}showKeyboardDatum(datum){!this.chart||this.chartSync.enabled||!datum&&!this.keyboardDatumShown||(this.keyboardDatumShown=showChartActiveDatum(this.chart,datum&&{datasetIndex:this.visualPosition(this.visualDatasetSourceIndexes,datum.datasetIndex),index:this.visualPosition(this.visualRowSourceIndexes,datum.index)}))}onCanvasFocus(event){if(this.spatialActive)return;const datums=this.chartDatums();datums.length&&(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),this.publishSyncDatum(datums[this.keyboardDatumIndex]),isKeyboardFocusEvent(event)&&this.showKeyboardDatum(datums[this.keyboardDatumIndex]),this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[this.keyboardDatumIndex],this.keyboardDatumIndex,datums.length))}onCanvasKeyDown(event){if(this.spatialActive){this.spatialKeyDown(event);return}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.publishSyncDatum(datums[next]),this.showKeyboardDatum(datums[next]),this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[next],next,datums.length)}effectiveType(){return this.effectiveConfig()?.type??normalizeChartType(this.type)}localizedChartType(){const type=this.effectiveType();switch(type){case"line":return this.localize("chartTypeLine");case"bar":return this.localize("chartTypeBar");case"scatter":return this.localize("chartTypeScatter");case"pie":return this.localize("chartTypePie");case"doughnut":return this.localize("chartTypeDoughnut");case"radar":return this.localize("chartTypeRadar");case"polarArea":return this.localize("chartTypePolarArea");case"bubble":return this.localize("chartTypeBubble");default:return String(type)}}formatValue(value,context,metadata={}){const numeric=chartDatumNumericValue(value);return numeric===void 0?value:this.formatter?.({value:numeric,surface:context,...metadata})??this.valueFormatter?.(numeric,context)??value}datasetValueAxis(dataset){const type=this.effectiveType();if(!(type==="pie"||type==="doughnut"))return type==="radar"||type==="polarArea"?"r":(type==="bar"||type==="line")&&this.effectiveIndexAxis()==="y"?"x":dataset===void 0?void 0:chartDatasetAxis(dataset)}datumFormatterMetadata(visualDatasetIndex,visualRowIndex,effective=this.effectiveData()){return this.sourceDatumFormatterMetadata(this.visualDatasetSourceIndexes?.[visualDatasetIndex]??visualDatasetIndex,visualRowIndex===void 0?void 0:this.visualRowSourceIndexes?.[visualRowIndex]??visualRowIndex,effective)}sourceDatumFormatterMetadata(datasetIndex,index,effective=this.effectiveData()){const dataset=effective.datasets[datasetIndex],point=index===void 0?null:normalizedChartPoint(this.datasetValues(dataset)[index]),label=index===void 0?void 0:point?.label??(labelText(effective.labels[index])||void 0),axis=this.datasetValueAxis(dataset);return{datasetIndex,...index===void 0?{}:{index},...label===void 0?{}:{label},seriesLabel:this.datasetLabel(dataset,datasetIndex),...axis===void 0?{}:{axis}}}stackTotalMetadata(metadata){return{...metadata.index===void 0?{}:{index:metadata.index},...metadata.label===void 0?{}:{label:metadata.label},...metadata.axis===void 0?{}:{axis:metadata.axis},statistic:"total"}}legendValue(item,_chart,effective=this.effectiveData()){const datasetIndex=this.callbackDatasetIndex(item,effective);if(datasetIndex===void 0)return;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex,data=this.datasetValues(effective.datasets[sourceDatasetIndex]);if(!data.length)return;const visualRows=this.visualRowSourceIndexes??data.map((_value,index)=>index),indexDescriptor=chartRecordValue(item,"index");if(indexDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR)return;if(indexDescriptor!==MISSING_OWN_DATA_DESCRIPTOR){const itemIndex=chartIndex(indexDescriptor.value);return itemIndex===void 0||itemIndex>=visualRows.length?void 0:chartDatumNumericValue(data[visualRows[itemIndex]]??null)}let sum=0,hasValue=!1;for(const sourceRowIndex of visualRows){const datum=data[sourceRowIndex],value=chartDatumNumericValue(datum);value!==void 0&&(sum=finiteAdd(sum,value),hasValue=!0)}return hasValue?sum:void 0}legendLabels(chart){const generateLabels=this.chartJsModule?.defaults?.plugins?.legend?.labels?.generateLabels;let generated;if(generateLabels)try{generated=projectChartLegendItems(generateLabels(chart))}catch{generated=void 0}const effective=this.effectiveData(),direction=canvasTextDirection(chart.legend,this.effectiveDirection),fallbackDatasets=(this.visualDatasetSourceIndexes??effective.datasets.map((_dataset,index)=>index)).map(sourceIndex=>effective.datasets[sourceIndex]);return(generated??fallbackDatasets.map((dataset,index)=>({text:chartDatasetLabel(dataset)||String(index+1),datasetIndex:index}))).map(item=>{const value=this.legendValue(item,chart,effective);if(value===void 0)return item;const visualDatasetIndex=this.callbackDatasetIndex(item,effective),visualRowIndex=chartIndex(chartDatasetValue(item,"index")),formatted=this.formatValue(value,"legend",this.datumFormatterMetadata(visualDatasetIndex,visualRowIndex,effective));return formatted===value||formatted===void 0?item:{...item,text:this.localize("chartValueLabel",void 0,{label:labelText(chartDatasetValue(item,"text")),value:isolateCanvasText(String(formatted),direction)})}})}tooltipLabel(context,horizontal=!1){const parsed=projectChartDatum(chartDatasetValue(context,"parsed")),raw=projectChartDatum(chartDatasetValue(context,"raw")),parsedPoint=normalizedChartPoint(parsed);let rawValue=(horizontal&&!normalizedChartPoint(raw)?parsedPoint?.x:parsedPoint?.y)??parsed??raw;const scaledSlices=this.scaledSliceDatasets.size>0,effective=scaledSlices||this.formatter!==void 0?this.effectiveData():void 0,hit=effective===void 0?void 0:this.callbackIndexes(context,effective),indexes=scaledSlices?hit:void 0,scaled=indexes!==void 0&&effective!==void 0&&this.scaledSliceDatasets.has(indexes.datasetIndex);if(scaled){const dataset=effective.datasets[this.visualDatasetSourceIndexes?.[indexes.datasetIndex]??indexes.datasetIndex];rawValue=this.datasetValues(dataset)[this.visualRowSourceIndexes?.[indexes.index]??indexes.index]}let formatted=this.formatValue(rawValue,"tooltip",hit===void 0||effective===void 0?{}:this.datumFormatterMetadata(hit.datasetIndex,hit.index,effective));if(!scaled&&formatted===rawValue||formatted===void 0)return;scaled&&typeof formatted=="number"&&(formatted=this.formatSummaryValue(formatted));const label=chartDatasetLabel(chartDatasetValue(context,"dataset"));return label?canvasSentence(value=>this.localize("chartValueLabel",void 0,{label,value}),String(formatted)):String(formatted)}tooltipItemContext(context,horizontal,effective){const parsed=projectChartDatum(chartDatasetValue(context,"parsed")),raw=projectChartDatum(chartDatasetValue(context,"raw")),parsedPoint=normalizedChartPoint(parsed);let rawValue=(horizontal&&!normalizedChartPoint(raw)?parsedPoint?.x:parsedPoint?.y)??parsed??raw;const hit=this.callbackIndexes(context,effective);if(hit!==void 0&&this.scaledSliceDatasets.has(hit.datasetIndex)){const dataset=effective.datasets[this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex];rawValue=this.datasetValues(dataset)[this.visualRowSourceIndexes?.[hit.index]??hit.index]}const numeric=chartDatumNumericValue(rawValue);if(numeric===void 0)return;const metadata=hit===void 0?{}:this.datumFormatterMetadata(hit.datasetIndex,hit.index,effective);return{value:numeric,surface:"tooltip",...metadata}}tooltipGroupText(items,horizontal,formatter){if(!formatter)return;const effective=this.effectiveData(),contexts=items.map(item=>this.tooltipItemContext(item,horizontal,effective)).filter(context=>context!==void 0);if(contexts.length)return formatter(contexts)}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(![next.top,next.left,next.right,next.bottom,next.width,next.height].every(Number.isFinite))return;const previous=this.resolvedChartArea;previous&&previous.top===next.top&&previous.left===next.left&&previous.right===next.right&&previous.bottom===next.bottom&&previous.width===next.width&&previous.height===next.height||(this.resolvedChartArea=next,this.chartAreaUpdateQueued||(this.chartAreaUpdateQueued=!0,queueMicrotask(()=>{this.chartAreaUpdateQueued=!1,this.isConnected&&this.requestUpdate("canvasPresentation",null)})))}get chartArea(){return this.resolvedChartArea}set chartArea(_value){}spatialDescription(){const binding=this.spatial.binding,global=binding?.bounds,view=this.spatial.view;if(!global||!view)return this.localize("noData");const f=value=>this.formatSummaryValue(value),summary=this.localize("chartSpatialSummary",void 0,{count:f(binding.count),matchedCount:f(this.spatial.result?.matchedCount??0),minX:f(global.minX),maxX:f(global.maxX),minY:f(global.minY),maxY:f(global.maxY),viewMinX:f(view.minX),viewMaxX:f(view.maxX),viewMinY:f(view.minY),viewMaxY:f(view.maxY)}),radius=binding.chart?.type==="bubble"&&binding.chart.radiusDomain;return[summary,...radius?[this.localize("chartSpatialRadiusDomain",void 0,{min:f(radius.min),max:f(radius.max)})]:[],this.localize("chartSpatialDensityLegend")].join(this.localize("chartSummarySeparator"))}buildSpatialConfig(){const binding=this.spatial.binding,view=this.spatial.view,series=binding?.chart?.series??[],groups=this.spatialSeriesPoints(!0),bins=this.spatial.result?.bins??[],current=this.spatialGuard(),theme=this.themeColors(),palette=this.seriesPalette(),type=binding?.chart?.type??"scatter",color=index=>this.canvasTokens.resolve(series[index]?.color??palette[index%palette.length]??theme.tick,theme.tick),datasets=series.map((entry,index)=>({label:entry.label,borderColor:color(index),backgroundColor:color(index),borderWidth:groups[index].map(point=>point.id===this.selectedPointId?3:1),data:groups[index].map(point=>({x:spatialCoordinate(point.x,view.minX,view.maxX),y:spatialCoordinate(point.y,view.minY,view.maxY),...type==="bubble"?{r:spatialPaintRadius(point.radius,this.canvasEl?.clientWidth??0,this.canvasEl?.clientHeight??0)}:{}}))})),toPixel=(chart,x,y)=>{const area=chart.chartArea,normalizedX=spatialCoordinate(x,view.minX,view.maxX);return{x:area.left+(this.effectiveDirection==="rtl"?1-normalizedX:normalizedX)*area.width,y:area.bottom-spatialCoordinate(y,view.minY,view.maxY)*area.height}},density={id:"lyra-spatial-density",beforeDatasetsUpdate:chart=>{!current()||type!=="bubble"||!chart.chartArea||chart.data.datasets.forEach((dataset,index)=>dataset.data?.forEach((raw,pointIndex)=>{const point=groups[index]?.[pointIndex];point&&raw&&typeof raw=="object"&&Reflect.set(raw,"r",spatialPaintRadius(point.radius,chart.chartArea.width,chart.chartArea.height))}))},beforeDatasetsDraw:chart=>{if(!current()||!view||!chart.chartArea)return;const context=chart.ctx,area=chart.chartArea;context.save(),context.beginPath(),context.rect(area.left,area.top,area.width,area.height),context.clip(),context.fillStyle=color(0),context.strokeStyle=color(0);for(const bin of bins){const a=toPixel(chart,bin.bounds.minX,bin.bounds.maxY),b=toPixel(chart,bin.bounds.maxX,bin.bounds.minY);context.globalAlpha=.15+.65*bin.count/Math.max(1,this.spatial.result.matchedCount),a.x===b.x&&a.y===b.y?context.fillRect(a.x-.5,a.y-.5,1,1):a.x===b.x||a.y===b.y?(context.beginPath(),context.moveTo(a.x,a.y),context.lineTo(b.x,b.y),context.stroke()):context.fillRect(Math.min(a.x,b.x),a.y,Math.abs(b.x-a.x),b.y-a.y)}context.restore()}},pointFor=context=>{if(!current()||!Number.isSafeInteger(context.datasetIndex)||!Number.isSafeInteger(context.dataIndex))return;const point=groups[context.datasetIndex]?.[context.dataIndex];return current()&&point&&this.spatialPoints().includes(point)?point:void 0},axis=name=>{const min=name==="x"?view?.minX:view?.minY,max=name==="x"?view?.maxX:view?.maxY;return{type:"linear",min:0,max:1,reverse:name==="x"&&this.effectiveDirection==="rtl",title:{display:!!(name==="x"?this.xLabel:this.yLabel),text:name==="x"?this.xLabel:this.yLabel,color:theme.tick},...min===max?{afterBuildTicks:scale=>{scale.ticks=[{value:.5}]}}:{},ticks:{color:theme.tick,callback:value=>{if(!current()||min===void 0||max===void 0||value<0||value>1)return"";const original=spatialOriginal(value,min,max),formatted=this.formatValue(original,"tick",{axis:name});return typeof formatted=="string"?formatted:this.formatSummaryValue(original)}}}},generated={type,data:{labels:[],datasets},plugins:[density,...this.plugins],options:{responsive:!0,maintainAspectRatio:!1,animation:this.withoutAnimation||prefersReducedMotion(this)?!1:void 0,locale:this.effectiveLocale,indexAxis:"x",parsing:!1,scales:{x:axis("x"),y:axis("y")},onResize:chart=>{current()&&this.updateChartArea(chart)},onClick:(event,_hits,chart)=>{if(!current()||!view)return;const hit=chart.getElementsAtEventForMode(event.native??event,"nearest",{intersect:!0},!0)[0],point=hit&&groups[hit.datasetIndex]?.[hit.index];if(point&&!this.canonicalHiddenDatasets()?.includes(hit.datasetIndex)){this.activateSpatialPoint(point);return}if(!chart.chartArea||typeof event.x!="number"||typeof event.y!="number")return;const bin=bins.find(bin2=>{const a=toPixel(chart,bin2.bounds.minX,bin2.bounds.maxY),b=toPixel(chart,bin2.bounds.maxX,bin2.bounds.minY);return event.x>=Math.min(a.x,b.x)-(a.x===b.x?2:0)&&event.x<=Math.max(a.x,b.x)+(a.x===b.x?2:0)&&event.y>=a.y-(a.y===b.y?2:0)&&event.y<=b.y+(a.y===b.y?2:0)});bin&&this.activateSpatialBin(bin)},plugins:{legend:{display:!1},tooltip:{enabled:!this.withoutTooltip,backgroundColor:theme.tooltipBg,titleColor:theme.tooltipText,bodyColor:theme.tooltipText,callbacks:{title:contexts=>{const point=contexts[0]&&pointFor(contexts[0]);if(!point)return"";const metadata={value:point.y,surface:"tooltip",datasetIndex:contexts[0].datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[contexts[0].datasetIndex].label,axis:"y"};return this.tooltipTitleFormatter?.([metadata])??point.label??point.id},footer:contexts=>{const point=contexts[0]&&pointFor(contexts[0]);return point?this.tooltipFooterFormatter?.([{value:point.y,surface:"tooltip",datasetIndex:contexts[0].datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[contexts[0].datasetIndex].label,axis:"y"}])??"":""},label:context=>{const point=pointFor(context);if(!point)return"";const datasetIndex=context.datasetIndex,metadata={datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[datasetIndex].label,axis:"y"};return this.formatter?.({value:point.y,surface:"tooltip",...metadata})??this.valueFormatter?.(point.y,"tooltip")??this.spatialPointText(point)}}},zoom:this.zoomable&&this.zoomFeatureState!=="unavailable"?{pan:{enabled:!1},zoom:{wheel:{enabled:!0},drag:{enabled:!0},pinch:{enabled:!0},mode:"x",onZoomComplete:({chart})=>{if(!current()||!view||this.suppressZoomComplete||view.minX===view.maxX)return;const lo=Math.max(0,chart.scales.x.min),hi=Math.min(1,chart.scales.x.max);!Number.isFinite(lo)||!Number.isFinite(hi)||lo>=hi||(this.viewport=Object.freeze({...view,minX:spatialOriginal(lo,view.minX,view.maxX),maxX:spatialOriginal(hi,view.minX,view.maxX)}),this.zoomed=!0,this.emit("lr-zoom",{zoomed:!0}))}},limits:{x:{min:0,max:1}}}:void 0,datalabels:{display:!1}}}},config=this.effectiveConfig();if(!config)return generated;const merged=deepMerge(generated,config);return merged.type=generated.type,merged.data=generated.data,merged.plugins=[...(merged.plugins??[]).filter(plugin=>plugin.id!==density.id),density],merged.options={...merged.options,scales:generated.options.scales,indexAxis:"x",parsing:!1,onClick:generated.options.onClick,onResize:generated.options.onResize,plugins:generated.options.plugins},merged}buildConfig(){if(this.spatialActive)return this.buildSpatialConfig();this.forcedColorPatterns=new Map;const theme=this.themeColors(),effectiveType=this.effectiveType();let tooltipIndexAxis=this.effectiveIndexAxis();const palette=this.seriesPalette(),chartStyle=this.chartStyleOptions(palette),rawDataEscapeHatch=this.hasExplicitConfigData(),wantsTooltipLabelCallback=!!(this.formatter||this.valueFormatter)||(effectiveType==="pie"||effectiveType==="doughnut")&&!rawDataEscapeHatch,prepared=this.preparedModel,labels=prepared?this.effectiveData().labels:this.canonicalLabels(),inputSeries=prepared?prepared.series.map(series=>({label:series.label,data:series.values})):this.datasets;let visualRows,visualSeries;const sample=this.dataTableSample();visualRows=!prepared&&sample.rowIndexes.length<sample.rowCount?sample.rowIndexes:void 0,visualSeries=!prepared&&sample.seriesIndexes.length<sample.seriesCount?sample.seriesIndexes:void 0,this.visualRowSourceIndexes=visualRows,this.visualDatasetSourceIndexes=visualSeries;const generated={type:effectiveType,data:{labels:!rawDataEscapeHatch&&visualRows?visualRows.map(index=>labels[index]??""):[...labels],datasets:!rawDataEscapeHatch&&visualSeries?visualSeries.map(sourceIndex=>this.seriesToDataset(inputSeries[sourceIndex],sourceIndex,palette,effectiveType,chartStyle,visualRows)):inputSeries.map((s,i)=>this.seriesToDataset(s,i,palette,effectiveType,chartStyle,rawDataEscapeHatch?void 0: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,...this.compactPlot&&!["pie","doughnut","radar","polarArea"].includes(effectiveType)?{layout:{padding:0,autoPadding:!1}}:{},indexAxis:this.effectiveIndexAxis(),animation:this.withoutAnimation||prefersReducedMotion(this)?!1:void 0,interaction:{intersect:!1,mode:effectiveType==="scatter"?"nearest":"index"},onClick:(event,_elements,chart)=>{prepared===this.preparedModel&&this.handlePointClick(event,chart)},plugins:{...this.needsAnnotations&&this.annotationPlugin?{annotation:{annotations:this.annotationOptions(theme.tick)}}:{},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,...wantsTooltipLabelCallback||this.tooltipTitleFormatter||this.tooltipFooterFormatter?{callbacks:{...wantsTooltipLabelCallback?{label:context=>this.tooltipLabel(context,tooltipIndexAxis==="y")}:{},...this.tooltipTitleFormatter?{title:items=>this.tooltipGroupText(items,tooltipIndexAxis==="y",this.tooltipTitleFormatter)}:{},...this.tooltipFooterFormatter?{footer:items=>this.tooltipGroupText(items,tooltipIndexAxis==="y",this.tooltipFooterFormatter)}:{}}}:{},filter:item=>{const effective=this.effectiveData(),datasetIndex=this.callbackDatasetIndex(item,effective);if(datasetIndex===void 0)return!1;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex;return chartDatasetBoolean(effective.datasets[sourceDatasetIndex],"noTooltip")!==!0}},zoom:this.zoomable&&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)}};if(prepared){const effective=this.effectiveData();generated.data.labels=[...effective.labels],generated.data.datasets.forEach((dataset,index)=>{const values=this.datasetValues(effective.datasets[index]);dataset.data=values.map((value,row)=>value??{x:prepared.series[index].samples[row+1]?.x??0,y:null}),prepared.kind==="series"&&Reflect.set(dataset,"spanGaps",!1)})}const effectiveConfig=this.effectiveConfig();if(!effectiveConfig)return generated;const merged=deepMerge(generated,effectiveConfig);if(rawDataEscapeHatch&&(visualRows||visualSeries)){const sourceDatasets=merged.data.datasets,sourceLabels=merged.data.labels;merged.data={...merged.data,labels:visualRows?visualRows.map(index=>sourceLabels[index]??""):sourceLabels,datasets:(visualSeries??sourceDatasets.map((_dataset,index)=>index)).map(index=>{const dataset=sourceDatasets[index],values=chartDatasetPeerValues(dataset),sampled={...dataset,data:visualRows?visualRows.map(row=>values[row]??null):[...values]};if(visualRows){const controller=chartDatasetValue(dataset,"type")??merged.type,doughnut=controller==="doughnut"||controller==="pie";for(const key of["backgroundColor","borderColor","borderWidth","hoverBackgroundColor","hoverBorderColor","hoverBorderWidth","pointBackgroundColor","pointBorderColor","pointBorderWidth","pointHitRadius","pointRadius","pointRotation","pointStyle","pointHoverBackgroundColor","pointHoverBorderColor","pointHoverBorderWidth","pointHoverRadius","radius","hitRadius","rotation","hoverRadius","drawActiveElementsOnTop","base","borderSkipped","borderRadius","hoverBorderRadius","inflateAmount","selfJoin","borderAlign","borderDashOffset","borderJoinStyle","offset","circular","spacing","hoverBorderDashOffset","hoverOffset","borderCapStyle","hoverBorderCapStyle","hoverBorderJoinStyle"]){if(doughnut&&(key==="spacing"||key.startsWith("borderDash")||key.startsWith("hoverBorderDash")))continue;const source=chartDatasetValue(dataset,key);Array.isArray(source)&&source.length&&Reflect.set(sampled,key,visualRows.map(row=>source[row%source.length]))}}return sampled})}}tooltipIndexAxis=merged.options.indexAxis==="y"?"y":"x";const requiredPlugins=[...this.plugins,...this.needsDataLabels&&this.dataLabelsPlugin?[this.dataLabelsPlugin]:[]],mergedPluginAdmission=admitChartArray(merged.plugins),mergedPlugins=projectChartPlugins(merged.plugins,mergedPluginAdmission);return mergedPluginAdmission||requiredPlugins.length?merged.plugins=[...mergedPlugins,...requiredPlugins.filter(plugin=>!mergedPlugins.includes(plugin))]:merged.plugins!==void 0&&(merged.plugins=[]),merged}scaleExtremeSlices(config){if(this.scaledSliceDatasets.clear(),!(config.type!=="pie"&&config.type!=="doughnut"||this.hasExplicitConfigData()))for(const[index,dataset]of config.data.datasets.entries()){const source=this.datasetValues(dataset),maximum=source.reduce((largest,value)=>{const number=chartDatumNumericValue(value);return number===void 0?largest:Math.max(largest,Math.abs(number))},0);maximum<=Number.MAX_SAFE_INTEGER||(dataset.data=source.map(value=>{const number=chartDatumNumericValue(value);return number===void 0?value:number/maximum}),this.scaledSliceDatasets.add(index))}}draw(){if(this.preparedInvalid||this.spatialActive&&this.spatial.error){this.discardChart(!1);return}if(this.spatialActive&&this.spatial.loading&&this.chart||!this.chartJsModule||!this.canvasEl)return;if(!this.chart&&!this.canvasEl.getContext("2d")){this.setCanvasUnavailable(!0);return}this.canvasTokens.beginThemeDraw();const config=this.buildConfig();this.scaleExtremeSlices(config);const effectiveType=config.type,nextPlugins=projectChartPlugins(config.plugins),samePlugins=nextPlugins.length===this.builtPlugins.length&&nextPlugins.every((plugin,index)=>plugin===this.builtPlugins[index]);if(this.chart&&this.builtType===effectiveType&&samePlugins){const zoomedBounds=this.zoomed?this.chart.getZoomedScaleBounds?.():void 0;this.chart.data=config.data,this.chart.options=config.options??{},this.applyDatasetVisibility(),this.chart.update("none"),this.restoreZoomedBounds(this.chart,zoomedBounds),this.applyDatumVisibility()&&this.chart.update("none"),this.updateChartArea(this.chart),this.chartSync.update(this.syncGroup,typeof this.syncGroup=="string"&&this.syncGroup.trim()!==""&&this.syncCompatible()),this.canvasTokens.rememberTheme();return}this.discardChart(!this.spatialActive,this.spatialActive&&this.viewport!==null);const candidate=new this.chartJsModule.Chart(this.canvasEl,{...config,plugins:[...nextPlugins,this.chartAreaPlugin]}),context=candidate;if(context.canvas===null||context.ctx===null){candidate.destroy(),this.setCanvasUnavailable(!0);return}this.chart=candidate,this.setCanvasUnavailable(!1),this.builtType=effectiveType,this.builtPlugins=[...nextPlugins];const datasetsControlled=this.canonicalHiddenDatasets()!==void 0;datasetsControlled&&this.applyDatasetVisibility(),(this.applyDatumVisibility()||datasetsControlled)&&this.chart.update("none"),this.updateChartArea(this.chart),this.chartSync.update(this.syncGroup,typeof this.syncGroup=="string"&&this.syncGroup.trim()!==""&&this.syncCompatible()),this.canvasTokens.rememberTheme()}setCanvasUnavailable(unavailable){this.canvasUnavailable!==unavailable&&(this.canvasUnavailable=unavailable,queueMicrotask(()=>{this.isConnected&&this.requestUpdate("canvasPresentation",null)}),unavailable&&this.announcements.announceAssertive(this.localize("chartRenderUnavailable")))}drawIfVisible(){!this.isConnected||!this.visible||this.draw()}restoreZoomedBounds(chart,bounds){if(!(this.spatialActive||!bounds||typeof chart.zoomScale!="function"))for(const[id,range]of Object.entries(bounds))range&&Number.isFinite(range.min)&&Number.isFinite(range.max)&&chart.zoomScale(id,{min:range.min,max:range.max},"none")}discardChart(announceZoomReset,preserveZoom=!1){this.appliedLegendVisibility=void 0,this.chartSync.disconnect(),this.chart?.destroy(),this.chart=void 0,this.resolvedChartArea=void 0,!(preserveZoom||!this.zoomed)&&(this.zoomed=!1,announceZoomReset&&this.emit("lr-zoom",{zoomed:!1}))}renderChart(){this.drawIfVisible()}resetZoom(){this.spatialActive&&(this.viewport=null),this.suppressZoomComplete=!0;try{this.chart?.resetZoom?.()}finally{this.suppressZoomComplete=!1}this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1})}refreshTheme(){this.canvasTokens.clear(),this.drawIfVisible(),this.showsLegend&&this.requestUpdate("canvasPresentation",null)}summarizeSeries(dataset){if(this.seriesSummaryMemo.has(dataset))return this.seriesSummaryMemo.get(dataset);const value=this.summarizeSeriesValues(dataset);return this.seriesSummaryMemo.set(dataset,value),value}summarizeSeriesValues(dataset){let count=0,first=0,last=0,min=0,minIndex=0,max=0,maxIndex=0;for(const[index,datum]of this.datasetValues(dataset).entries()){const value=chartDatumNumericValue(datum);value!==void 0&&(count===0&&(first=value,min=value,minIndex=index,max=value,maxIndex=index),last=value,value<min&&(min=value,minIndex=index),value>max&&(max=value,maxIndex=index),count++)}return count?{count,first,last,min,minIndex,max,maxIndex}:void 0}formatSummaryValue(value){return formatChartValue(value,this.effectiveLocale)}formatTableValue(value,metadata={}){return this.formatter?.({value,surface:"table",...metadata})??this.valueFormatter?.(value,"table")??this.formatSummaryValue(value)}formatExportValue(value,metadata={}){return this.formatter?.({value,surface:"export",...metadata})??this.valueFormatter?.(value,"table")}formatSpokenValue(value,metadata={}){return this.formatter?.({value,surface:"spoken",...metadata})??this.valueFormatter?.(value,"table")??this.formatSummaryValue(value)}tableStackAxes(){const type=this.effectiveType();if(!this.stackTotals||type!=="bar"&&type!=="line")return[];const present=new Set;for(const dataset of this.effectiveData().datasets){const axis=chartDatasetAxis(dataset);this.axisStacked(axis)&&present.add(axis)}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(),keys=[effective,this.dataTableSample(effective),this.effectiveLocale,this.strings,this.effectiveType(),this.effectiveIndexAxis(),this.effectiveDirection,this.formatter,this.valueFormatter,this.annotations,this.hasCustomDataTable()];if(this.descriptionMemo?.keys.every((key,index)=>key===keys[index]))return this.descriptionMemo.value;const value=this.buildChartDescription(effective);return this.descriptionMemo={keys,value},value}buildChartDescription(effective){if(this.spatialActive)return this.spatialDescription();if(this.preparedModel){const specialized=this.preparedSummary();if(specialized!==void 0)return specialized;const model=this.preparedModel,summary=this.localize("chartPreparedSummary",void 0,{validCount:this.formatSummaryValue(model.validCount),invalidCount:this.formatSummaryValue(model.invalidCount),displayedCount:this.formatSummaryValue(model.displayedCount)});return[...model.series.flatMap((series,index)=>{const original=this.preparedBaseModel?.series[index]??series;if(!original.yDomain)return[];const first=original.samples[0]?.y??0,last=original.samples.at(-1)?.y??0;return[this.localize("chartSummary",void 0,{label:original.label,count:this.formatSummaryValue(original.counts.validCount),min:this.formatSummaryValue(original.yDomain.min),max:this.formatSummaryValue(original.yDomain.max),trend:this.localize(last>first?"chartTrendIncreasing":last<first?"chartTrendDecreasing":"chartTrendFlat")})]}),summary].join(this.localize("chartSummarySeparator"))}const 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"),rawValues=this.datasetValues(dataset),datumLabelAt=rowIndex=>{const datum=rawValues[rowIndex];return normalizedChartPoint(datum)?.label??(labelText(effective.labels[rowIndex])||void 0)},summary=this.localize("chartSummary",void 0,{label:seriesLabel,count:this.formatSummaryValue(values.count),min:this.formatSpokenValue(values.min,{datasetIndex:index,index:values.minIndex,label:datumLabelAt(values.minIndex),seriesLabel,statistic:"min"}),max:this.formatSpokenValue(values.max,{datasetIndex:index,index:values.maxIndex,label:datumLabelAt(values.maxIndex),seriesLabel,statistic:"max"}),trend}),pointDetails=includePointDetails?sample.rowIndexes.flatMap(rowIndex=>{const point=rawValues[rowIndex];return normalizedChartPoint(point)?[this.datumDisplayValue(point,{surface:"spoken",datasetIndex:index,index:rowIndex,label:datumLabelAt(rowIndex),seriesLabel})]:[]}):[];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()){const maxRecords=normalizeChartRecordLimit(this.maxRecords),width=this.samplingWidth;if(this.dataTableSampleMemo?.effective===effective&&this.dataTableSampleMemo.maxRecords===maxRecords&&this.dataTableSampleMemo.width===width)return this.dataTableSampleMemo.value;let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const values=effective.datasets.map(dataset=>this.datasetValues(dataset)),indexes=this.preparedModel||this.spatialActive?{rowIndexes:Array.from({length:rowCount},(_,index)=>index).filter(index=>values.some(series=>series[index]!=null)),seriesIndexes:Array.from({length:effective.datasets.length},(_,index)=>index)}:sampleChartTableIndexes(rowCount,effective.datasets.length,{maxRecords,width,valueAt:(row,series)=>chartDatumNumericValue(values[series]?.[row])}),value={rowCount,seriesCount:effective.datasets.length,...indexes};return this.dataTableSampleMemo={effective,maxRecords,width,value},value}generatedDataIsSampled(){if(this.spatialActive)return!1;const sample=this.dataTableSample();return sample.rowCount===0||sample.seriesCount===0?!1:sample.rowIndexes.length<sample.rowCount||sample.seriesIndexes.length<sample.seriesCount}inputLimitMessage(){return this.preparedActive?"":(this.canonicalLabels(),[this.labels,this.datasets,this.config??this.slottedConfig].some(value=>typeof value=="object"&&value!==null&&truncatedChartInputs.has(value))?this.localize("chartInputLimit"):"")}dataTruncationMessage(){return this.preparedModel?this.zoomable&&this.preparedModel.kind==="series"&&!Object.getOwnPropertyDescriptor(this.preparedModel.source,"queryRange")?this.localize("chartPreparedSummaryZoom"):"":this.generatedDataIsSampled()?this.hasCustomDataTable()?this.localize("chartPlotSampled"):this.localize("chartDataSampled"):""}renderDataTable(){if(this.spatialActive)return this.renderSpatialTable();const effective=this.effectiveData(),direction=this.effectiveDirection==="rtl"?"rtl":"ltr",sample=this.dataTableSample(effective),stackAxes=this.tableStackAxes();return html`
|
|
12
|
+
`);return{color:theme.tick,align:stackTotalsActive?"end":"center",anchor:stackTotalsActive?"end":"center",display:context=>{const indexes=this.callbackIndexes(context,effective);if(!indexes)return!1;const{datasetIndex,index}=indexes,dataset=datasets[sourceDatasetIndex(datasetIndex)],axis=chartDatasetAxis(dataset),stack=chartDatasetStack(dataset);return stackTotalsPossible&&this.axisStacked(axis)?topDatasetIndexByGroup.get(axis)?.get(stack)!==datasetIndex?this.dataLabels:totalsFor(axis,stack)[sourceRowIndex(index)]==null?this.dataLabels:!0:this.dataLabels},formatter:(value,context)=>{const indexes=this.callbackIndexes(context,effective);if(!indexes)return"";const{datasetIndex,index}=indexes,dataset=datasets[sourceDatasetIndex(datasetIndex)],axis=chartDatasetAxis(dataset),stack=chartDatasetStack(dataset),metadata=this.datumFormatterMetadata(datasetIndex,index,effective);if(stackTotalsPossible&&this.axisStacked(axis)&&topDatasetIndexByGroup.get(axis)?.get(stack)===datasetIndex){const total=totalsFor(axis,stack)[sourceRowIndex(index)];if(total!=null)return isolate(this.formatDataLabel(total,this.stackTotalMetadata(metadata)))}const numeric=chartDatumNumericValue(this.scaledSliceDatasets.has(datasetIndex)?this.datasetValues(dataset)[sourceRowIndex(index)]:value);return numeric===void 0?"":isolate(this.formatDataLabel(numeric,metadata))}}}formatDataLabel(value,metadata={}){if(this.formatter||this.valueFormatter){const formatted=this.formatter?.({value,surface:"visual",...metadata})??this.valueFormatter?.(value,"tooltip");if(formatted!=null)return String(formatted)}return formatChartValue(value,this.effectiveLocale)}computeStackTotals(axisId="y",stackGroup){const effective=this.effectiveData(),members=effective.datasets.filter(dataset=>chartDatasetAxis(dataset)===axisId&&chartDatasetStack(dataset)===stackGroup),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=chartDatumNumericValue(value);numeric!==void 0&&(sum=finiteAdd(sum,numeric),any=!0)}totals.push(any?sum:null)}return totals}seriesPalette(){return this.canvasTokens.palette()}tickLabelIsolation(direction){return{afterTickToLabelConversion:scale=>isolateScaleTickLabels(scale,direction)}}tickOptions(theme,kind="value",axis="y"){return{color:theme.tick,font:{size:theme.tickFontSize},...(this.formatter||this.valueFormatter)&&kind==="value"?{callback:value=>this.formatValue(value,"tick",{axis})}:{}}}effectiveIndexAxis(){return this.indexAxis==="y"?"y":"x"}valueScaleType(){return this.scaleType==="logarithmic"?"logarithmic":"linear"}valueBeginAtZero(){return this.valueScaleType()==="logarithmic"?void 0:!this.withoutZeroBaseline}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}axisVisible(axis){const axes=normalizeChartGrid(this.axes);return!this.compactPlot&&(axes==="both"||axes===axis)}axisStacked(axisId){return axisId==="y2"?this.stackedAxes?.y2??this.stacked:this.stackedAxes?.y??this.stacked}buildScales(effectiveType,theme,chartStyle){if(effectiveType==="pie"||effectiveType==="doughnut")return{};const direction=this.effectiveDirection==="rtl"?"rtl":"ltr";if(effectiveType==="radar"||effectiveType==="polarArea"){const explicitPointLabelFontSize=this.explicitTickFontSize();return{r:{...this.tickLabelIsolation(direction),beginAtZero:!this.withoutZeroBaseline,...this.scaleBounds(),ticks:{...this.tickOptions(theme,"value","r"),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,callback:label=>isolateCanvasLabel(label,direction),...explicitPointLabelFontSize!==void 0?{font:{size:explicitPointLabelFontSize}}:{}}}}}const hasY2=this.effectiveData().datasets.some(dataset=>chartDatasetAxis(dataset)==="y2"),rtl=this.effectiveDirection==="rtl",stackableType=effectiveType==="bar"||effectiveType==="line",stackedX=stackableType&&this.axisStacked("x"),stackedY=stackableType&&this.axisStacked("y"),stackedY2=stackableType&&this.axisStacked("y2"),horizontalCategorical=(effectiveType==="bar"||effectiveType==="line")&&this.effectiveIndexAxis()==="y",xKind=this.preparedModel?.kind==="series"||effectiveType==="scatter"||effectiveType==="bubble"||horizontalCategorical?"value":"category",yKind=this.preparedModel?.kind==="series"?"value":horizontalCategorical?"category":"value",valueAxis=horizontalCategorical?"x":"y",bounds=this.scaleBounds(),prepared=this.preparedModel,fullBounds=axis=>{const domains=prepared?.kind==="series"?prepared.series.flatMap(series=>series[axis]?[series[axis]]:[]):[];return domains.length?{min:Math.min(...domains.map(domain=>domain.min)),max:Math.max(...domains.map(domain=>domain.max))}:{}};return{x:{...this.tickLabelIsolation(direction),display:this.axisVisible("x"),type:xKind==="value"?this.valueScaleType():"category",beginAtZero:xKind==="value"?this.valueBeginAtZero():void 0,...fullBounds("xDomain"),...valueAxis==="x"?bounds:{},title:{display:!!this.xLabel,text:isolateCanvasLabel(this.xLabel,direction),color:theme.tick},ticks:this.tickOptions(theme,xKind,"x"),grid:{color:theme.grid,display:this.gridAxisVisible("x"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked:stackedX},y:{...this.tickLabelIsolation(direction),display:this.axisVisible("y"),type:yKind==="value"?this.valueScaleType():"category",position:rtl?"right":"left",beginAtZero:yKind==="value"?this.valueBeginAtZero():void 0,...fullBounds("yDomain"),...valueAxis==="y"?bounds:{},title:{display:!!this.yLabel,text:isolateCanvasLabel(this.yLabel,direction),color:theme.tick},ticks:this.tickOptions(theme,yKind,"y"),grid:{color:theme.grid,display:this.gridAxisVisible("y"),lineWidth:chartStyle.gridBorderWidth},border:{width:chartStyle.gridBorderWidth},stacked:stackedY},...hasY2?{y2:{...this.tickLabelIsolation(direction),display:this.axisVisible("y"),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:isolateCanvasLabel(this.y2Label,direction),color:theme.tick},ticks:this.tickOptions(theme,"value","y2"),stacked:stackedY2}}:{}}}handlePointClick(event,chart){if(!this.isConnected||chart!==this.chart)return;const effective=this.effectiveData(),type=this.effectiveType(),datasets=this.visualDatasetSourceIndexes,rows=this.visualRowSourceIndexes,current=()=>this.isConnected&&chart===this.chart&&this.effectiveData()===effective&&this.effectiveType()===type&&this.visualDatasetSourceIndexes===datasets&&this.visualRowSourceIndexes===rows;let elements;try{elements=chart.getElementsAtEventForMode(event,"nearest",{intersect:!0},!0)}catch{return}if(!current())return;const admission=admitChartArray(elements);if(!admission||!current()||!chartArrayIsStillAdmitted(admission)||!current())return;const first=chartRecordValue(admission.source,"0");if(first===MISSING_OWN_DATA_DESCRIPTOR||first===UNSAFE_OWN_DATA_DESCRIPTOR||!current())return;const hit=this.callbackIndexes(first.value,effective);if(!hit||!current())return;const datasetIndex=datasets?.[hit.datasetIndex]??hit.datasetIndex,index=rows?.[hit.index]??hit.index,value=this.datasetValues(effective.datasets[datasetIndex])[index]??null,label=normalizedChartPoint(value)?.label??(labelText(effective.labels[index])||void 0);this.activateDatum({datasetIndex,index,label,value})}chartDatums(){const effective=this.effectiveData(),plan=this.dataTableSample(effective),memo=this.chartDatumsMemo;if(memo?.effective===effective&&memo.plan===plan&&memo.datasets===this.visualDatasetSourceIndexes&&memo.rows===this.visualRowSourceIndexes)return memo.value;const datasetIndexes=this.visualDatasetSourceIndexes??this.dataTableSample(effective).seriesIndexes,datasets=datasetIndexes.map(index=>effective.datasets[index]);let rowIndexes=this.visualRowSourceIndexes;rowIndexes||(rowIndexes=this.dataTableSample(effective).rowIndexes);const labels=rowIndexes.map(index=>effective.labels[index]),rowCount=rowIndexes.length,sample=this.preparedModel?{rowIndexes:Array.from({length:rowCount},(_,index)=>index),seriesIndexes:Array.from({length:datasets.length},(_,index)=>index)}:sampleChartTableIndexes(rowCount,datasets.length),datums=[];return sample.seriesIndexes.forEach(datasetIndex=>{const dataset=datasets[datasetIndex];if(!dataset)return;const values=chartDatasetValues(dataset);sample.rowIndexes.forEach(localIndex=>{const sourceIndex=rowIndexes[localIndex]??localIndex,value=values[sourceIndex];value!=null&&(typeof value=="number"&&!Number.isFinite(value)||datums.push({datasetIndex:datasetIndexes[datasetIndex]??datasetIndex,index:sourceIndex,label:normalizedChartPoint(value)?.label??(labelText(labels[localIndex])||void 0),value}))})}),this.chartDatumsMemo={plan,effective,datasets:this.visualDatasetSourceIndexes,rows:this.visualRowSourceIndexes,value:datums},datums}datumDisplayValue(value,context={surface:"spoken"}){const{surface,...metadata}=context,format=(numeric2,statistic)=>surface==="table"?this.formatTableValue(numeric2,{...metadata,statistic}):this.formatSpokenValue(numeric2,{...metadata,statistic}),point=normalizedChartPoint(value);if(point){const x=format(point.x,"x"),y=format(point.y,"y"),coordinates=point.r==null?this.localize("chartPointCoordinates",void 0,{x,y}):this.localize("chartBubblePointCoordinates",void 0,{x,y,radius:format(point.r,"r")});return point.label!==void 0?this.localize("chartLabeledPoint",void 0,{label:point.label,coordinates}):coordinates}const numeric=chartDatumNumericValue(value);return numeric===void 0?labelText(value):format(numeric)}datumAnnouncement(datum,position,total){const dataset=this.effectiveData().datasets[datum.datasetIndex],series=chartDatasetLabel(dataset)||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,{surface:"spoken",datasetIndex:datum.datasetIndex,index:datum.index,label:datum.label,seriesLabel:series,...this.datasetValueAxis(dataset)===void 0?{}:{axis:this.datasetValueAxis(dataset)}}),index:getNumberFormat(this.effectiveLocale).format(position+1),total:getNumberFormat(this.effectiveLocale).format(total)})}emitPreparedSourceSelection(datasetIndex,index){const model=this.preparedModel,series=model?.series[datasetIndex];if(model&&series)if(model.kind==="series"){const point=series.samples[index];point&&this.emit("lr-source-point-select",{revision:model.revision,seriesId:series.id,sourceIndex:point.sourceIndex,point:Object.freeze({x:point.x,y:point.y})})}else{const categoryId=model.categoryIds[index],value=series.values[index];categoryId!==void 0&&value!==void 0&&this.emit("lr-source-category-select",{revision:model.revision,seriesId:series.id,categoryId,value,observationCount:model.categoryCounts[index]})}}preparedSummary(){}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.emitPreparedSourceSelection(datum.datasetIndex,datum.index),this.emit("lr-datum-activate",{...datum,kind}),this.emit("lr-point-activate",{...datum})}resetSyncTooltip(){const chart=this.chart;chart?.tooltip?.setActiveElements([],{x:0,y:0}),chart?.render?.()}syncCompatible(){const chart=this.chart;if(!chart)return!1;const type=this.effectiveType();return type!=="bar"&&type!=="line"||chart.options.indexAxis==="y"?!1:chart.scales?.x?.type==="category"&&Array.isArray(chart.data?.datasets)&&chart.data.datasets.every(dataset=>dataset.type===void 0||dataset.type==="bar"||dataset.type==="line")}visualPosition(sources,source){if(!sources)return source;let positions=this.visualPositions.get(sources);return positions||(positions=new Map(sources.map((value,index)=>[value,index])),this.visualPositions.set(sources,positions)),positions.get(source)??-1}indexedSyncDatums(){const datums=this.chartDatums();if(this.syncDatumIndex?.datums===datums)return this.syncDatumIndex;const byAddress=new Map,byCategory=new Map;for(const datum of datums){byAddress.set(`${datum.datasetIndex}:${datum.index}`,datum);let category=byCategory.get(datum.index);category||(category=[],byCategory.set(datum.index,category)),category.push(datum)}const labels=this.effectiveData().labels,labelCategories=new Map;for(const index of[...byCategory.keys()].sort((a,b)=>a-b)){const label=labels[index];if(typeof label!="string")continue;let categories=labelCategories.get(label);categories||(categories=[],labelCategories.set(label,categories)),categories.push(index)}return this.syncDatumIndex={datums,byAddress,byCategory,labelCategories}}syncDatumIsEligible(datum){const chart=this.chart;if(!chart)return!1;const visualDataset=this.visualPosition(this.visualDatasetSourceIndexes,datum.datasetIndex),visualIndex=this.visualPosition(this.visualRowSourceIndexes,datum.index),element=chart.getDatasetMeta?.(visualDataset)?.data?.[visualIndex];return chart.isDatasetVisible(visualDataset)&&!!element&&!element.skip&&Number.isFinite(element.x)&&Number.isFinite(element.y)&&chartDatumNumericValue(datum.value)!==void 0}publishSyncDatum(datum){const label=this.effectiveData().labels[datum.index];typeof label=="string"?this.chartSync.publish(label,datum.index):this.chartSync.clear()}onSyncPointerMove(event){const chart=this.chart;if(!this.chartSync.enabled||!chart)return;const group=this.syncGroup,effective=this.effectiveData(),datasets=this.visualDatasetSourceIndexes,rows=this.visualRowSourceIndexes,current=()=>this.isConnected&&this.chart===chart&&this.chartSync.enabled&&this.syncGroup===group&&this.effectiveData()===effective&&this.visualDatasetSourceIndexes===datasets&&this.visualRowSourceIndexes===rows,readDatum=()=>{const elements=chart.getElementsAtEventForMode(event,"nearest",{intersect:!0},!0);if(!current())return;const admission=admitChartArray(elements);if(!admission||!current()||!chartArrayIsStillAdmitted(admission)||!current())return;const first=chartRecordValue(admission.source,"0");if(first===MISSING_OWN_DATA_DESCRIPTOR||first===UNSAFE_OWN_DATA_DESCRIPTOR||!current())return;const hit=this.callbackIndexes(first.value,effective);if(!hit||!current())return;const datasetIndex=datasets?.[hit.datasetIndex]??hit.datasetIndex,index=rows?.[hit.index]??hit.index,datum2=this.indexedSyncDatums().byAddress.get(`${datasetIndex}:${index}`);return datum2&&this.syncDatumIsEligible(datum2)?datum2:void 0};let datum;try{datum=readDatum()}catch{}current()&&(datum?this.publishSyncDatum(datum):this.chartSync.clear())}syncPresentation(label,sourceIndex){if(!this.syncCompatible()||!this.canvasEl||!this.chart)return;const effective=this.effectiveData();if(sourceIndex!==void 0&&effective.labels[sourceIndex]!==label)return;const indexed=this.indexedSyncDatums(),categories=sourceIndex===void 0?indexed.labelCategories.get(label)??[]:[sourceIndex];let matches=[];for(const index of categories)if(matches=(indexed.byCategory.get(index)??[]).filter(datum=>this.syncDatumIsEligible(datum)),matches.length)break;if(!matches.length)return;const hits=matches.map(datum=>({datasetIndex:this.visualPosition(this.visualDatasetSourceIndexes,datum.datasetIndex),index:this.visualPosition(this.visualRowSourceIndexes,datum.index)})),runtime=this.chart,point=this.chart.getDatasetMeta?.(hits[0].datasetIndex)?.data?.[hits[0].index],area=this.chart.chartArea,container=this.renderRoot.querySelector('[part="plot"]');if(!point||!area||!container)return;const plugins=this.chart.options.plugins,suppressed=this.withoutTooltip||plugins?.tooltip===!1||plugins?.tooltip?.enabled===!1;runtime.tooltip?.setActiveElements(suppressed?[]:hits,{x:point.x,y:point.y}),runtime.render?.();const bounds=container.getBoundingClientRect(),canvasBounds=this.canvasEl.getBoundingClientRect(),categoryX=runtime.scales?.x?.getPixelForValue?.(hits[0].index);return{container,x:canvasBounds.left-bounds.left+(typeof categoryX=="number"&&Number.isFinite(categoryX)?categoryX:point.x),top:canvasBounds.top-bounds.top+area.top,height:area.height}}showKeyboardDatum(datum){!this.chart||this.chartSync.enabled||!datum&&!this.keyboardDatumShown||(this.keyboardDatumShown=showChartActiveDatum(this.chart,datum&&{datasetIndex:this.visualPosition(this.visualDatasetSourceIndexes,datum.datasetIndex),index:this.visualPosition(this.visualRowSourceIndexes,datum.index)}))}onCanvasFocus(event){if(this.spatialActive)return;const datums=this.chartDatums();datums.length&&(this.keyboardDatumIndex=Math.min(this.keyboardDatumIndex,datums.length-1),this.publishSyncDatum(datums[this.keyboardDatumIndex]),isKeyboardFocusEvent(event)&&this.showKeyboardDatum(datums[this.keyboardDatumIndex]),this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[this.keyboardDatumIndex],this.keyboardDatumIndex,datums.length))}onCanvasKeyDown(event){if(this.spatialActive){this.spatialKeyDown(event);return}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.publishSyncDatum(datums[next]),this.showKeyboardDatum(datums[next]),this.keyboardDatumAnnouncement=this.datumAnnouncement(datums[next],next,datums.length)}effectiveType(){return this.effectiveConfig()?.type??normalizeChartType(this.type)}localizedChartType(){const type=this.effectiveType();switch(type){case"line":return this.localize("chartTypeLine");case"bar":return this.localize("chartTypeBar");case"scatter":return this.localize("chartTypeScatter");case"pie":return this.localize("chartTypePie");case"doughnut":return this.localize("chartTypeDoughnut");case"radar":return this.localize("chartTypeRadar");case"polarArea":return this.localize("chartTypePolarArea");case"bubble":return this.localize("chartTypeBubble");default:return String(type)}}formatValue(value,context,metadata={}){const numeric=chartDatumNumericValue(value);return numeric===void 0?value:this.formatter?.({value:numeric,surface:context,...metadata})??this.valueFormatter?.(numeric,context)??value}datasetValueAxis(dataset){const type=this.effectiveType();if(!(type==="pie"||type==="doughnut"))return type==="radar"||type==="polarArea"?"r":(type==="bar"||type==="line")&&this.effectiveIndexAxis()==="y"?"x":dataset===void 0?void 0:chartDatasetAxis(dataset)}datumFormatterMetadata(visualDatasetIndex,visualRowIndex,effective=this.effectiveData()){return this.sourceDatumFormatterMetadata(this.visualDatasetSourceIndexes?.[visualDatasetIndex]??visualDatasetIndex,visualRowIndex===void 0?void 0:this.visualRowSourceIndexes?.[visualRowIndex]??visualRowIndex,effective)}sourceDatumFormatterMetadata(datasetIndex,index,effective=this.effectiveData()){const dataset=effective.datasets[datasetIndex],point=index===void 0?null:normalizedChartPoint(this.datasetValues(dataset)[index]),label=index===void 0?void 0:point?.label??(labelText(effective.labels[index])||void 0),axis=this.datasetValueAxis(dataset);return{datasetIndex,...index===void 0?{}:{index},...label===void 0?{}:{label},seriesLabel:this.datasetLabel(dataset,datasetIndex),...axis===void 0?{}:{axis}}}stackTotalMetadata(metadata){return{...metadata.index===void 0?{}:{index:metadata.index},...metadata.label===void 0?{}:{label:metadata.label},...metadata.axis===void 0?{}:{axis:metadata.axis},statistic:"total"}}legendValue(item,_chart,effective=this.effectiveData()){const datasetIndex=this.callbackDatasetIndex(item,effective);if(datasetIndex===void 0)return;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex,data=this.datasetValues(effective.datasets[sourceDatasetIndex]);if(!data.length)return;const visualRows=this.visualRowSourceIndexes??data.map((_value,index)=>index),indexDescriptor=chartRecordValue(item,"index");if(indexDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR)return;if(indexDescriptor!==MISSING_OWN_DATA_DESCRIPTOR){const itemIndex=chartIndex(indexDescriptor.value);return itemIndex===void 0||itemIndex>=visualRows.length?void 0:chartDatumNumericValue(data[visualRows[itemIndex]]??null)}let sum=0,hasValue=!1;for(const sourceRowIndex of visualRows){const datum=data[sourceRowIndex],value=chartDatumNumericValue(datum);value!==void 0&&(sum=finiteAdd(sum,value),hasValue=!0)}return hasValue?sum:void 0}legendLabels(chart){const generateLabels=this.chartJsModule?.defaults?.plugins?.legend?.labels?.generateLabels;let generated;if(generateLabels)try{generated=projectChartLegendItems(generateLabels(chart))}catch{generated=void 0}const effective=this.effectiveData(),direction=canvasTextDirection(chart.legend,this.effectiveDirection),fallbackDatasets=(this.visualDatasetSourceIndexes??effective.datasets.map((_dataset,index)=>index)).map(sourceIndex=>effective.datasets[sourceIndex]);return(generated??fallbackDatasets.map((dataset,index)=>({text:chartDatasetLabel(dataset)||String(index+1),datasetIndex:index}))).map(item=>{const value=this.legendValue(item,chart,effective);if(value===void 0)return item;const visualDatasetIndex=this.callbackDatasetIndex(item,effective),visualRowIndex=chartIndex(chartDatasetValue(item,"index")),formatted=this.formatValue(value,"legend",this.datumFormatterMetadata(visualDatasetIndex,visualRowIndex,effective));return formatted===value||formatted===void 0?item:{...item,text:this.localize("chartValueLabel",void 0,{label:labelText(chartDatasetValue(item,"text")),value:isolateCanvasText(String(formatted),direction)})}})}tooltipLabel(context,horizontal=!1){const parsed=projectChartDatum(chartDatasetValue(context,"parsed")),raw=projectChartDatum(chartDatasetValue(context,"raw")),parsedPoint=normalizedChartPoint(parsed);let rawValue=(horizontal&&!normalizedChartPoint(raw)?parsedPoint?.x:parsedPoint?.y)??parsed??raw;const scaledSlices=this.scaledSliceDatasets.size>0,effective=scaledSlices||this.formatter!==void 0?this.effectiveData():void 0,hit=effective===void 0?void 0:this.callbackIndexes(context,effective),indexes=scaledSlices?hit:void 0,scaled=indexes!==void 0&&effective!==void 0&&this.scaledSliceDatasets.has(indexes.datasetIndex);if(scaled){const dataset=effective.datasets[this.visualDatasetSourceIndexes?.[indexes.datasetIndex]??indexes.datasetIndex];rawValue=this.datasetValues(dataset)[this.visualRowSourceIndexes?.[indexes.index]??indexes.index]}let formatted=this.formatValue(rawValue,"tooltip",hit===void 0||effective===void 0?{}:this.datumFormatterMetadata(hit.datasetIndex,hit.index,effective));if(!scaled&&formatted===rawValue||formatted===void 0)return;scaled&&typeof formatted=="number"&&(formatted=this.formatSummaryValue(formatted));const label=chartDatasetLabel(chartDatasetValue(context,"dataset"));return label?canvasSentence(value=>this.localize("chartValueLabel",void 0,{label,value}),String(formatted)):String(formatted)}tooltipItemContext(context,horizontal,effective){const parsed=projectChartDatum(chartDatasetValue(context,"parsed")),raw=projectChartDatum(chartDatasetValue(context,"raw")),parsedPoint=normalizedChartPoint(parsed);let rawValue=(horizontal&&!normalizedChartPoint(raw)?parsedPoint?.x:parsedPoint?.y)??parsed??raw;const hit=this.callbackIndexes(context,effective);if(hit!==void 0&&this.scaledSliceDatasets.has(hit.datasetIndex)){const dataset=effective.datasets[this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex];rawValue=this.datasetValues(dataset)[this.visualRowSourceIndexes?.[hit.index]??hit.index]}const numeric=chartDatumNumericValue(rawValue);if(numeric===void 0)return;const metadata=hit===void 0?{}:this.datumFormatterMetadata(hit.datasetIndex,hit.index,effective);return{value:numeric,surface:"tooltip",...metadata}}tooltipGroupText(items,horizontal,formatter){if(!formatter)return;const effective=this.effectiveData(),contexts=items.map(item=>this.tooltipItemContext(item,horizontal,effective)).filter(context=>context!==void 0);if(contexts.length)return formatter(contexts)}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(![next.top,next.left,next.right,next.bottom,next.width,next.height].every(Number.isFinite))return;const previous=this.resolvedChartArea;previous&&previous.top===next.top&&previous.left===next.left&&previous.right===next.right&&previous.bottom===next.bottom&&previous.width===next.width&&previous.height===next.height||(this.resolvedChartArea=next,this.chartAreaUpdateQueued||(this.chartAreaUpdateQueued=!0,queueMicrotask(()=>{this.chartAreaUpdateQueued=!1,this.isConnected&&this.requestUpdate("canvasPresentation",null)})))}get chartArea(){return this.resolvedChartArea}set chartArea(_value){}spatialDescription(){const binding=this.spatial.binding,global=binding?.bounds,view=this.spatial.view;if(!global||!view)return this.localize("noData");const f=value=>this.formatSummaryValue(value),summary=this.localize("chartSpatialSummary",void 0,{count:f(binding.count),matchedCount:f(this.spatial.result?.matchedCount??0),minX:f(global.minX),maxX:f(global.maxX),minY:f(global.minY),maxY:f(global.maxY),viewMinX:f(view.minX),viewMaxX:f(view.maxX),viewMinY:f(view.minY),viewMaxY:f(view.maxY)}),radius=binding.chart?.type==="bubble"&&binding.chart.radiusDomain;return[summary,...radius?[this.localize("chartSpatialRadiusDomain",void 0,{min:f(radius.min),max:f(radius.max)})]:[],this.localize("chartSpatialDensityLegend")].join(this.localize("chartSummarySeparator"))}buildSpatialConfig(){const binding=this.spatial.binding,view=this.spatial.view,series=binding?.chart?.series??[],groups=this.spatialSeriesPoints(!0),bins=this.spatial.result?.bins??[],current=this.spatialGuard(),theme=this.themeColors(),palette=this.seriesPalette(),type=binding?.chart?.type??"scatter",color=index=>this.canvasTokens.resolve(series[index]?.color??palette[index%palette.length]??theme.tick,theme.tick),datasets=series.map((entry,index)=>({label:entry.label,borderColor:color(index),backgroundColor:color(index),borderWidth:groups[index].map(point=>point.id===this.selectedPointId?3:1),data:groups[index].map(point=>({x:spatialCoordinate(point.x,view.minX,view.maxX),y:spatialCoordinate(point.y,view.minY,view.maxY),...type==="bubble"?{r:spatialPaintRadius(point.radius,this.canvasEl?.clientWidth??0,this.canvasEl?.clientHeight??0)}:{}}))})),toPixel=(chart,x,y)=>{const area=chart.chartArea,normalizedX=spatialCoordinate(x,view.minX,view.maxX);return{x:area.left+(this.effectiveDirection==="rtl"?1-normalizedX:normalizedX)*area.width,y:area.bottom-spatialCoordinate(y,view.minY,view.maxY)*area.height}},density={id:"lyra-spatial-density",beforeDatasetsUpdate:chart=>{!current()||type!=="bubble"||!chart.chartArea||chart.data.datasets.forEach((dataset,index)=>dataset.data?.forEach((raw,pointIndex)=>{const point=groups[index]?.[pointIndex];point&&raw&&typeof raw=="object"&&Reflect.set(raw,"r",spatialPaintRadius(point.radius,chart.chartArea.width,chart.chartArea.height))}))},beforeDatasetsDraw:chart=>{if(!current()||!view||!chart.chartArea)return;const context=chart.ctx,area=chart.chartArea;context.save(),context.beginPath(),context.rect(area.left,area.top,area.width,area.height),context.clip(),context.fillStyle=color(0),context.strokeStyle=color(0);for(const bin of bins){const a=toPixel(chart,bin.bounds.minX,bin.bounds.maxY),b=toPixel(chart,bin.bounds.maxX,bin.bounds.minY);context.globalAlpha=.15+.65*bin.count/Math.max(1,this.spatial.result.matchedCount),a.x===b.x&&a.y===b.y?context.fillRect(a.x-.5,a.y-.5,1,1):a.x===b.x||a.y===b.y?(context.beginPath(),context.moveTo(a.x,a.y),context.lineTo(b.x,b.y),context.stroke()):context.fillRect(Math.min(a.x,b.x),a.y,Math.abs(b.x-a.x),b.y-a.y)}context.restore()}},pointFor=context=>{if(!current()||!Number.isSafeInteger(context.datasetIndex)||!Number.isSafeInteger(context.dataIndex))return;const point=groups[context.datasetIndex]?.[context.dataIndex];return current()&&point&&this.spatialPoints().includes(point)?point:void 0},axis=name=>{const min=name==="x"?view?.minX:view?.minY,max=name==="x"?view?.maxX:view?.maxY;return{type:"linear",min:0,max:1,reverse:name==="x"&&this.effectiveDirection==="rtl",title:{display:!!(name==="x"?this.xLabel:this.yLabel),text:name==="x"?this.xLabel:this.yLabel,color:theme.tick},...min===max?{afterBuildTicks:scale=>{scale.ticks=[{value:.5}]}}:{},ticks:{color:theme.tick,callback:value=>{if(!current()||min===void 0||max===void 0||value<0||value>1)return"";const original=spatialOriginal(value,min,max),formatted=this.formatValue(original,"tick",{axis:name});return typeof formatted=="string"?formatted:this.formatSummaryValue(original)}}}},generated={type,data:{labels:[],datasets},plugins:[density,...this.plugins],options:{responsive:!0,maintainAspectRatio:!1,animation:this.withoutAnimation||prefersReducedMotion(this)?!1:void 0,locale:this.effectiveLocale,indexAxis:"x",parsing:!1,scales:{x:axis("x"),y:axis("y")},onResize:chart=>{current()&&this.updateChartArea(chart)},onClick:(event,_hits,chart)=>{if(!current()||!view)return;let hits;try{hits=chart.getElementsAtEventForMode(event.native??event,"nearest",{intersect:!0},!0)}catch{return}if(!current())return;const admission=admitChartArray(hits);if(!admission||!current()||!chartArrayIsStillAdmitted(admission)||!current())return;let hit;if(admission.length){const first=chartRecordValue(admission.source,"0");if(first===MISSING_OWN_DATA_DESCRIPTOR||first===UNSAFE_OWN_DATA_DESCRIPTOR||!current()||(hit=chartCallbackIndexes(first.value),!hit||!current()))return}const point=hit&&groups[hit.datasetIndex]?.[hit.index];if(point&&!this.canonicalHiddenDatasets()?.includes(hit.datasetIndex)){this.activateSpatialPoint(point);return}if(!chart.chartArea||typeof event.x!="number"||typeof event.y!="number")return;const bin=bins.find(bin2=>{const a=toPixel(chart,bin2.bounds.minX,bin2.bounds.maxY),b=toPixel(chart,bin2.bounds.maxX,bin2.bounds.minY);return event.x>=Math.min(a.x,b.x)-(a.x===b.x?2:0)&&event.x<=Math.max(a.x,b.x)+(a.x===b.x?2:0)&&event.y>=a.y-(a.y===b.y?2:0)&&event.y<=b.y+(a.y===b.y?2:0)});bin&&this.activateSpatialBin(bin)},plugins:{legend:{display:!1},tooltip:{enabled:!this.withoutTooltip,backgroundColor:theme.tooltipBg,titleColor:theme.tooltipText,bodyColor:theme.tooltipText,callbacks:{title:contexts=>{const point=contexts[0]&&pointFor(contexts[0]);if(!point)return"";const metadata={value:point.y,surface:"tooltip",datasetIndex:contexts[0].datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[contexts[0].datasetIndex].label,axis:"y"};return this.tooltipTitleFormatter?.([metadata])??point.label??point.id},footer:contexts=>{const point=contexts[0]&&pointFor(contexts[0]);return point?this.tooltipFooterFormatter?.([{value:point.y,surface:"tooltip",datasetIndex:contexts[0].datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[contexts[0].datasetIndex].label,axis:"y"}])??"":""},label:context=>{const point=pointFor(context);if(!point)return"";const datasetIndex=context.datasetIndex,metadata={datasetIndex,index:point.sourceIndex,label:point.label,seriesLabel:series[datasetIndex].label,axis:"y"};return this.formatter?.({value:point.y,surface:"tooltip",...metadata})??this.valueFormatter?.(point.y,"tooltip")??this.spatialPointText(point)}}},zoom:this.zoomable&&this.zoomFeatureState!=="unavailable"?{pan:{enabled:!1},zoom:{wheel:{enabled:!0},drag:{enabled:!0},pinch:{enabled:!0},mode:"x",onZoomComplete:({chart})=>{if(!current()||!view||this.suppressZoomComplete||view.minX===view.maxX)return;const lo=Math.max(0,chart.scales.x.min),hi=Math.min(1,chart.scales.x.max);!Number.isFinite(lo)||!Number.isFinite(hi)||lo>=hi||(this.viewport=Object.freeze({...view,minX:spatialOriginal(lo,view.minX,view.maxX),maxX:spatialOriginal(hi,view.minX,view.maxX)}),this.zoomed=!0,this.emit("lr-zoom",{zoomed:!0}))}},limits:{x:{min:0,max:1}}}:void 0,datalabels:{display:!1}}}},config=this.effectiveConfig();if(!config)return generated;const merged=deepMerge(generated,config);return merged.type=generated.type,merged.data=generated.data,merged.plugins=[...(merged.plugins??[]).filter(plugin=>plugin.id!==density.id),density],merged.options={...merged.options,scales:generated.options.scales,indexAxis:"x",parsing:!1,onClick:generated.options.onClick,onResize:generated.options.onResize,plugins:generated.options.plugins},merged}buildConfig(){if(this.spatialActive)return this.buildSpatialConfig();this.forcedColorPatterns=new Map;const theme=this.themeColors(),effectiveType=this.effectiveType();let tooltipIndexAxis=this.effectiveIndexAxis();const palette=this.seriesPalette(),chartStyle=this.chartStyleOptions(palette),rawDataEscapeHatch=this.hasExplicitConfigData(),wantsTooltipLabelCallback=!!(this.formatter||this.valueFormatter)||(effectiveType==="pie"||effectiveType==="doughnut")&&!rawDataEscapeHatch,prepared=this.preparedModel,labels=prepared?this.effectiveData().labels:this.canonicalLabels(),inputSeries=prepared?prepared.series.map(series=>({label:series.label,data:series.values})):this.datasets;let visualRows,visualSeries;const sample=this.dataTableSample();visualRows=!prepared&&sample.rowIndexes.length<sample.rowCount?sample.rowIndexes:void 0,visualSeries=!prepared&&sample.seriesIndexes.length<sample.seriesCount?sample.seriesIndexes:void 0,this.visualRowSourceIndexes=visualRows,this.visualDatasetSourceIndexes=visualSeries;const generated={type:effectiveType,data:{labels:!rawDataEscapeHatch&&visualRows?visualRows.map(index=>labels[index]??""):[...labels],datasets:!rawDataEscapeHatch&&visualSeries?visualSeries.map(sourceIndex=>this.seriesToDataset(inputSeries[sourceIndex],sourceIndex,palette,effectiveType,chartStyle,visualRows)):inputSeries.map((s,i)=>this.seriesToDataset(s,i,palette,effectiveType,chartStyle,rawDataEscapeHatch?void 0: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,...this.compactPlot&&!["pie","doughnut","radar","polarArea"].includes(effectiveType)?{layout:{padding:0,autoPadding:!1}}:{},indexAxis:this.effectiveIndexAxis(),animation:this.withoutAnimation||prefersReducedMotion(this)?!1:void 0,interaction:{intersect:!1,mode:effectiveType==="scatter"?"nearest":"index"},onClick:(event,_elements,chart)=>{prepared===this.preparedModel&&this.handlePointClick(event,chart)},plugins:{...this.needsAnnotations&&this.annotationPlugin?{annotation:{annotations:this.annotationOptions(theme.tick)}}:{},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,...wantsTooltipLabelCallback||this.tooltipTitleFormatter||this.tooltipFooterFormatter?{callbacks:{...wantsTooltipLabelCallback?{label:context=>this.tooltipLabel(context,tooltipIndexAxis==="y")}:{},...this.tooltipTitleFormatter?{title:items=>this.tooltipGroupText(items,tooltipIndexAxis==="y",this.tooltipTitleFormatter)}:{},...this.tooltipFooterFormatter?{footer:items=>this.tooltipGroupText(items,tooltipIndexAxis==="y",this.tooltipFooterFormatter)}:{}}}:{},filter:item=>{const effective=this.effectiveData(),datasetIndex=this.callbackDatasetIndex(item,effective);if(datasetIndex===void 0)return!1;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex;return chartDatasetBoolean(effective.datasets[sourceDatasetIndex],"noTooltip")!==!0}},zoom:this.zoomable&&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)}};if(prepared){const effective=this.effectiveData();generated.data.labels=[...effective.labels],generated.data.datasets.forEach((dataset,index)=>{const values=this.datasetValues(effective.datasets[index]);dataset.data=values.map((value,row)=>value??{x:prepared.series[index].samples[row+1]?.x??0,y:null}),prepared.kind==="series"&&Reflect.set(dataset,"spanGaps",!1)})}const effectiveConfig=this.effectiveConfig();if(!effectiveConfig)return generated;const merged=deepMerge(generated,effectiveConfig);if(rawDataEscapeHatch&&(visualRows||visualSeries)){const sourceDatasets=merged.data.datasets,sourceLabels=merged.data.labels;merged.data={...merged.data,labels:visualRows?visualRows.map(index=>sourceLabels[index]??""):sourceLabels,datasets:(visualSeries??sourceDatasets.map((_dataset,index)=>index)).map(index=>{const dataset=sourceDatasets[index],values=chartDatasetPeerValues(dataset),sampled={...dataset,data:visualRows?visualRows.map(row=>values[row]??null):[...values]};if(visualRows){const controller=chartDatasetValue(dataset,"type")??merged.type,doughnut=controller==="doughnut"||controller==="pie";for(const key of["backgroundColor","borderColor","borderWidth","hoverBackgroundColor","hoverBorderColor","hoverBorderWidth","pointBackgroundColor","pointBorderColor","pointBorderWidth","pointHitRadius","pointRadius","pointRotation","pointStyle","pointHoverBackgroundColor","pointHoverBorderColor","pointHoverBorderWidth","pointHoverRadius","radius","hitRadius","rotation","hoverRadius","drawActiveElementsOnTop","base","borderSkipped","borderRadius","hoverBorderRadius","inflateAmount","selfJoin","borderAlign","borderDashOffset","borderJoinStyle","offset","circular","spacing","hoverBorderDashOffset","hoverOffset","borderCapStyle","hoverBorderCapStyle","hoverBorderJoinStyle"]){if(doughnut&&(key==="spacing"||key.startsWith("borderDash")||key.startsWith("hoverBorderDash")))continue;const source=chartDatasetValue(dataset,key);Array.isArray(source)&&source.length&&Reflect.set(sampled,key,visualRows.map(row=>source[row%source.length]))}}return sampled})}}tooltipIndexAxis=merged.options.indexAxis==="y"?"y":"x";const requiredPlugins=[...this.plugins,...this.needsDataLabels&&this.dataLabelsPlugin?[this.dataLabelsPlugin]:[]],mergedPluginAdmission=admitChartArray(merged.plugins),mergedPlugins=projectChartPlugins(merged.plugins,mergedPluginAdmission);return mergedPluginAdmission||requiredPlugins.length?merged.plugins=[...mergedPlugins,...requiredPlugins.filter(plugin=>!mergedPlugins.includes(plugin))]:merged.plugins!==void 0&&(merged.plugins=[]),merged}scaleExtremeSlices(config){if(this.scaledSliceDatasets.clear(),!(config.type!=="pie"&&config.type!=="doughnut"||this.hasExplicitConfigData()))for(const[index,dataset]of config.data.datasets.entries()){const source=this.datasetValues(dataset),maximum=source.reduce((largest,value)=>{const number=chartDatumNumericValue(value);return number===void 0?largest:Math.max(largest,Math.abs(number))},0);maximum<=Number.MAX_SAFE_INTEGER||(dataset.data=source.map(value=>{const number=chartDatumNumericValue(value);return number===void 0?value:number/maximum}),this.scaledSliceDatasets.add(index))}}draw(){if(this.preparedInvalid||this.spatialActive&&this.spatial.error){this.discardChart(!1);return}if(this.spatialActive&&this.spatial.loading&&this.chart||!this.chartJsModule||!this.canvasEl||!this.ownerWindow)return;if(!this.chart&&!this.canvasEl.getContext("2d")){this.setCanvasUnavailable(!0);return}this.canvasTokens.beginThemeDraw();const config=this.buildConfig();this.scaleExtremeSlices(config);const effectiveType=config.type,nextPlugins=projectChartPlugins(config.plugins),samePlugins=nextPlugins.length===this.builtPlugins.length&&nextPlugins.every((plugin,index)=>plugin===this.builtPlugins[index]);if(this.chart&&this.builtType===effectiveType&&samePlugins){const zoomedBounds=this.zoomed?this.chart.getZoomedScaleBounds?.():void 0;this.chart.data=config.data,this.chart.options=config.options??{},this.applyDatasetVisibility(),this.chart.update("none"),this.restoreZoomedBounds(this.chart,zoomedBounds),this.applyDatumVisibility()&&this.chart.update("none"),this.updateChartArea(this.chart),this.chartSync.update(this.syncGroup,typeof this.syncGroup=="string"&&this.syncGroup.trim()!==""&&this.syncCompatible()),this.canvasTokens.rememberTheme();return}this.discardChart(!this.spatialActive,this.spatialActive&&this.viewport!==null);const candidate=new this.chartJsModule.Chart(this.canvasEl,{...config,plugins:[...nextPlugins,this.chartAreaPlugin]}),context=candidate;if(context.canvas===null||context.ctx===null){candidate.destroy(),this.setCanvasUnavailable(!0);return}this.chart=candidate,this.setCanvasUnavailable(!1),this.builtType=effectiveType,this.builtPlugins=[...nextPlugins];const datasetsControlled=this.canonicalHiddenDatasets()!==void 0;datasetsControlled&&this.applyDatasetVisibility(),(this.applyDatumVisibility()||datasetsControlled)&&this.chart.update("none"),this.updateChartArea(this.chart),this.chartSync.update(this.syncGroup,typeof this.syncGroup=="string"&&this.syncGroup.trim()!==""&&this.syncCompatible()),this.canvasTokens.rememberTheme()}setCanvasUnavailable(unavailable){this.canvasUnavailable!==unavailable&&(this.canvasUnavailable=unavailable,queueMicrotask(()=>{this.isConnected&&this.requestUpdate("canvasPresentation",null)}),unavailable&&this.announcements.announceAssertive(this.localize("chartRenderUnavailable")))}drawIfVisible(){!this.isConnected||!this.visible||this.draw()}restoreZoomedBounds(chart,bounds){if(!(this.spatialActive||!bounds||typeof chart.zoomScale!="function"))for(const[id,range]of Object.entries(bounds))range&&Number.isFinite(range.min)&&Number.isFinite(range.max)&&chart.zoomScale(id,{min:range.min,max:range.max},"none")}discardChart(announceZoomReset,preserveZoom=!1){this.appliedLegendVisibility=void 0,this.chartSync.disconnect(),this.chart?.destroy(),this.chart=void 0,this.resolvedChartArea=void 0,!(preserveZoom||!this.zoomed)&&(this.zoomed=!1,announceZoomReset&&this.emit("lr-zoom",{zoomed:!1}))}renderChart(){this.drawIfVisible()}resetZoom(){this.spatialActive&&(this.viewport=null),this.suppressZoomComplete=!0;try{this.chart?.resetZoom?.()}finally{this.suppressZoomComplete=!1}this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1})}refreshTheme(){this.canvasTokens.clear(),this.drawIfVisible(),this.showsLegend&&this.requestUpdate("canvasPresentation",null)}summarizeSeries(dataset){if(this.seriesSummaryMemo.has(dataset))return this.seriesSummaryMemo.get(dataset);const value=this.summarizeSeriesValues(dataset);return this.seriesSummaryMemo.set(dataset,value),value}summarizeSeriesValues(dataset){let count=0,first=0,last=0,min=0,minIndex=0,max=0,maxIndex=0;for(const[index,datum]of this.datasetValues(dataset).entries()){const value=chartDatumNumericValue(datum);value!==void 0&&(count===0&&(first=value,min=value,minIndex=index,max=value,maxIndex=index),last=value,value<min&&(min=value,minIndex=index),value>max&&(max=value,maxIndex=index),count++)}return count?{count,first,last,min,minIndex,max,maxIndex}:void 0}formatSummaryValue(value){return formatChartValue(value,this.effectiveLocale)}formatTableValue(value,metadata={}){return this.formatter?.({value,surface:"table",...metadata})??this.valueFormatter?.(value,"table")??this.formatSummaryValue(value)}formatExportValue(value,metadata={}){return this.formatter?.({value,surface:"export",...metadata})??this.valueFormatter?.(value,"table")}formatSpokenValue(value,metadata={}){return this.formatter?.({value,surface:"spoken",...metadata})??this.valueFormatter?.(value,"table")??this.formatSummaryValue(value)}tableStackAxes(){const type=this.effectiveType();if(!this.stackTotals||type!=="bar"&&type!=="line")return[];const present=new Set;for(const dataset of this.effectiveData().datasets){const axis=chartDatasetAxis(dataset);this.axisStacked(axis)&&present.add(axis)}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(),keys=[effective,this.dataTableSample(effective),this.effectiveLocale,this.strings,this.effectiveType(),this.effectiveIndexAxis(),this.effectiveDirection,this.formatter,this.valueFormatter,this.annotations,this.hasCustomDataTable()];if(this.descriptionMemo?.keys.every((key,index)=>key===keys[index]))return this.descriptionMemo.value;const value=this.buildChartDescription(effective);return this.descriptionMemo={keys,value},value}buildChartDescription(effective){if(this.spatialActive)return this.spatialDescription();if(this.preparedModel){const specialized=this.preparedSummary();if(specialized!==void 0)return specialized;const model=this.preparedModel,summary=this.localize("chartPreparedSummary",void 0,{validCount:this.formatSummaryValue(model.validCount),invalidCount:this.formatSummaryValue(model.invalidCount),displayedCount:this.formatSummaryValue(model.displayedCount)});return[...model.series.flatMap((series,index)=>{const original=this.preparedBaseModel?.series[index]??series;if(!original.yDomain)return[];const first=original.samples[0]?.y??0,last=original.samples.at(-1)?.y??0;return[this.localize("chartSummary",void 0,{label:original.label,count:this.formatSummaryValue(original.counts.validCount),min:this.formatSummaryValue(original.yDomain.min),max:this.formatSummaryValue(original.yDomain.max),trend:this.localize(last>first?"chartTrendIncreasing":last<first?"chartTrendDecreasing":"chartTrendFlat")})]}),summary].join(this.localize("chartSummarySeparator"))}const 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"),rawValues=this.datasetValues(dataset),datumLabelAt=rowIndex=>{const datum=rawValues[rowIndex];return normalizedChartPoint(datum)?.label??(labelText(effective.labels[rowIndex])||void 0)},summary=this.localize("chartSummary",void 0,{label:seriesLabel,count:this.formatSummaryValue(values.count),min:this.formatSpokenValue(values.min,{datasetIndex:index,index:values.minIndex,label:datumLabelAt(values.minIndex),seriesLabel,statistic:"min"}),max:this.formatSpokenValue(values.max,{datasetIndex:index,index:values.maxIndex,label:datumLabelAt(values.maxIndex),seriesLabel,statistic:"max"}),trend}),pointDetails=includePointDetails?sample.rowIndexes.flatMap(rowIndex=>{const point=rawValues[rowIndex];return normalizedChartPoint(point)?[this.datumDisplayValue(point,{surface:"spoken",datasetIndex:index,index:rowIndex,label:datumLabelAt(rowIndex),seriesLabel})]:[]}):[];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()){const maxRecords=normalizeChartRecordLimit(this.maxRecords),width=this.samplingWidth;if(this.dataTableSampleMemo?.effective===effective&&this.dataTableSampleMemo.maxRecords===maxRecords&&this.dataTableSampleMemo.width===width)return this.dataTableSampleMemo.value;let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const values=effective.datasets.map(dataset=>this.datasetValues(dataset)),indexes=this.preparedModel||this.spatialActive?{rowIndexes:Array.from({length:rowCount},(_,index)=>index).filter(index=>values.some(series=>series[index]!=null)),seriesIndexes:Array.from({length:effective.datasets.length},(_,index)=>index)}:sampleChartTableIndexes(rowCount,effective.datasets.length,{maxRecords,width,valueAt:(row,series)=>chartDatumNumericValue(values[series]?.[row])}),value={rowCount,seriesCount:effective.datasets.length,...indexes};return this.dataTableSampleMemo={effective,maxRecords,width,value},value}generatedDataIsSampled(){if(this.spatialActive)return!1;const sample=this.dataTableSample();return sample.rowCount===0||sample.seriesCount===0?!1:sample.rowIndexes.length<sample.rowCount||sample.seriesIndexes.length<sample.seriesCount}inputLimitMessage(){return this.preparedActive?"":(this.canonicalLabels(),[this.labels,this.datasets,this.config??this.slottedConfig].some(value=>typeof value=="object"&&value!==null&&truncatedChartInputs.has(value))?this.localize("chartInputLimit"):"")}dataTruncationMessage(){return this.preparedModel?this.zoomable&&this.preparedModel.kind==="series"&&!Object.getOwnPropertyDescriptor(this.preparedModel.source,"queryRange")?this.localize("chartPreparedSummaryZoom"):"":this.generatedDataIsSampled()?this.hasCustomDataTable()?this.localize("chartPlotSampled"):this.localize("chartDataSampled"):""}renderDataTable(){if(this.spatialActive)return this.renderSpatialTable();const effective=this.effectiveData(),direction=this.effectiveDirection==="rtl"?"rtl":"ltr",sample=this.dataTableSample(effective),stackAxes=this.tableStackAxes();return html`
|
|
13
13
|
<table class=${this.dataTableVisible?nothing:"sr-only"}>
|
|
14
14
|
<caption>${this.accessibleName(this.localize("chartData"))}</caption>
|
|
15
15
|
<thead>
|
|
@@ -23,7 +23,7 @@ ${surface}`;let pattern=this.forcedColorPatterns.get(key);return pattern||(patte
|
|
|
23
23
|
${this.renderDataTableRows()}
|
|
24
24
|
</tbody>
|
|
25
25
|
</table>
|
|
26
|
-
`}withStreamedTableUpdate(update){this.deferStreamedTable(),this.streamingTableUpdate=!0;try{update()}finally{this.streamingTableUpdate=!1}}clearDeferredTable(){this.cancelDeferredTable?.(),this.cancelDeferredTable=void 0,this.deferredTableRows=void 0}deferStreamedTable(){if(this.dataTableVisible||this.canvasUnavailable){this.clearDeferredTable();return}const view=this.ownerWindow;if(!this.isConnected||!view||this.dataTableVisible||this.cancelDeferredTable||!this.dataTableRows)return;this.deferredTableRows=this.dataTableRows;const rows=this.deferredTableRows,refresh=()=>{this.deferredTableRows===rows&&(this.cancelDeferredTable=void 0,this.deferredTableRows=void 0,this.dataTableRows=void 0,this.isConnected&&this.requestUpdate("dataTableIdleRefresh",null))};if(view.requestIdleCallback&&view.cancelIdleCallback){const handle=view.requestIdleCallback(refresh,{timeout:250});this.cancelDeferredTable=()=>view.cancelIdleCallback?.(handle)}else{const handle=view.setTimeout(refresh,0);this.cancelDeferredTable=()=>view.clearTimeout(handle)}}requestUpdate(...args){const key=args[0];(key===void 0||["preparedData","maxRecords","type","config","slottedConfig","scaleType"].includes(String(key)))&&(this.preparedGeneration={},this.spatialRevealToken={},this.spatial?.reset(),this.wakeSpatialWaiters(),this.preparedDirty=!0,this.preparedRequests?.refresh(),this.descriptionMemo=void 0),this.spatialActive&&this.spatial&&(key==="viewport"&&this.spatial.configure(this.viewport,normalizeChartRecordLimit(this.maxRecords)),key==="selectedPointId"&&this.spatial.setSelected(this.selectedPointId)),key===void 0&&(this.descriptionMemo=void 0),(key===void 0||["preparedData","preparedView","spatialView","viewport","selectedPointId","datasets","labels","values","bins","seriesLabel","config","slottedConfig","type","indexAxis","formatter","valueFormatter","locale","strings","stacked","stackedAxes","stackTotals","xLabel","yLabel","y2Label","withDataTable","dataTableToggle","dataTableExpandedOverride","maxRecords","samplingWidth","canvasUnavailable"].includes(String(key)))&&(this.dataTableRows=void 0,(!this.streamingTableUpdate||this.dataTableVisible||this.canvasUnavailable)&&this.clearDeferredTable()),super.requestUpdate(...args)}renderDataTableRows(){if(!this.dataTableVisible&&!this.canvasUnavailable&&this.deferredTableRows)return this.deferredTableRows;if(this.dataTableRows)return this.dataTableRows;const effective=this.effectiveData(),direction=this.effectiveDirection==="rtl"?"rtl":"ltr",sample=this.dataTableSample(effective),valuesBySeries=new Map(sample.seriesIndexes.map(index=>[index,this.datasetValues(effective.datasets[index])])),stackAxes=this.tableStackAxes(),stackTotals=new Map(stackAxes.map(axis=>[axis,this.computeStackTotals(axis)])),stackValueAxes=new Map(stackAxes.map(axis=>[axis,this.datasetValueAxis(effective.datasets.find(dataset=>chartDatasetAxis(dataset)===axis))]));return this.dataTableRows=sample.rowIndexes.map(index=>html`
|
|
26
|
+
`}withStreamedTableUpdate(update){this.deferStreamedTable(),this.streamingTableUpdate=!0;try{update()}finally{this.streamingTableUpdate=!1}}clearDeferredTable(){this.cancelDeferredTable?.(),this.cancelDeferredTable=void 0,this.deferredTableRows=void 0}deferStreamedTable(){if(this.dataTableVisible||this.canvasUnavailable){this.clearDeferredTable();return}const view=this.ownerWindow;if(!this.isConnected||!view||this.dataTableVisible||this.cancelDeferredTable||!this.dataTableRows)return;this.deferredTableRows=this.dataTableRows;const rows=this.deferredTableRows,refresh=()=>{this.deferredTableRows===rows&&(this.cancelDeferredTable=void 0,this.deferredTableRows=void 0,this.dataTableRows=void 0,this.isConnected&&this.requestUpdate("dataTableIdleRefresh",null))};if(view.requestIdleCallback&&view.cancelIdleCallback){const handle=view.requestIdleCallback(refresh,{timeout:250});this.cancelDeferredTable=()=>view.cancelIdleCallback?.(handle)}else{const handle=view.setTimeout(refresh,0);this.cancelDeferredTable=()=>view.clearTimeout(handle)}}requestUpdate(...args){const key=args[0];(key===void 0||["preparedData","maxRecords","type","config","slottedConfig","scaleType"].includes(String(key)))&&(this.preparedGeneration={},this.spatialRevealToken={},this.spatial?.reset(),this.wakeSpatialWaiters(),this.preparedDirty=!0,this.preparedRequests?.refresh(),this.descriptionMemo=void 0),this.spatialActive&&this.spatial&&(key==="viewport"&&this.spatial.configure(this.viewport,normalizeChartRecordLimit(this.maxRecords)),key==="selectedPointId"&&this.spatial.setSelected(this.selectedPointId)),key===void 0&&(this.descriptionMemo=void 0),(key===void 0||["preparedData","preparedView","spatialView","viewport","selectedPointId","datasets","labels","values","bins","seriesLabel","config","slottedConfig","type","indexAxis","formatter","valueFormatter","locale","strings","stacked","stackedAxes","stackTotals","xLabel","yLabel","y2Label","withDataTable","dataTableToggle","dataTableExpandedOverride","maxRecords","samplingWidth","canvasUnavailable"].includes(String(key)))&&(this.legendDataGeneration={},this.dataTableRows=void 0,(!this.streamingTableUpdate||this.dataTableVisible||this.canvasUnavailable)&&this.clearDeferredTable()),super.requestUpdate(...args)}renderDataTableRows(){if(!this.dataTableVisible&&!this.canvasUnavailable&&this.deferredTableRows)return this.deferredTableRows;if(this.dataTableRows)return this.dataTableRows;const effective=this.effectiveData(),direction=this.effectiveDirection==="rtl"?"rtl":"ltr",sample=this.dataTableSample(effective),valuesBySeries=new Map(sample.seriesIndexes.map(index=>[index,this.datasetValues(effective.datasets[index])])),stackAxes=this.tableStackAxes(),stackTotals=new Map(stackAxes.map(axis=>[axis,this.computeStackTotals(axis)])),stackValueAxes=new Map(stackAxes.map(axis=>[axis,this.datasetValueAxis(effective.datasets.find(dataset=>chartDatasetAxis(dataset)===axis))]));return this.dataTableRows=sample.rowIndexes.map(index=>html`
|
|
27
27
|
<tr>
|
|
28
28
|
<th scope="row">${isolateHtml(labelText(effective.labels[index])||sample.seriesIndexes.map(datasetIndex=>normalizedChartPoint(valuesBySeries.get(datasetIndex)[index])).find(point=>point!==null)?.label||this.localize("chartPointLabel",void 0,{n:this.formatSummaryValue(index+1)}),direction)}</th>
|
|
29
29
|
${sample.seriesIndexes.map(datasetIndex=>{const dataset=effective.datasets[datasetIndex],datum=valuesBySeries.get(datasetIndex)[index],point=normalizedChartPoint(datum),value=point?.y??chartDatumNumericValue(datum);if(value===void 0)return html`<td>${this.localize("noData")}</td>`;const detail={datasetIndex,index,label:point?.label??(labelText(effective.labels[index])||void 0),value:datum},axis=this.datasetValueAxis(dataset),metadata={datasetIndex,index,label:detail.label,seriesLabel:this.datasetLabel(dataset,datasetIndex),...axis===void 0?{}:{axis}};return html`<td><button
|
|
@@ -33,7 +33,7 @@ ${surface}`;let pattern=this.forcedColorPatterns.get(key);return pattern||(patte
|
|
|
33
33
|
>${isolateHtml(point?this.datumDisplayValue(datum,{surface:"table",...metadata}):this.formatTableValue(value,metadata),direction)}</button></td>`})}
|
|
34
34
|
${stackAxes.map(axis=>{const total=stackTotals.get(axis)?.[index];return html`<td>${isolateHtml(total==null?this.localize("noData"):this.formatTableValue(total,this.stackTotalMetadata({index,label:labelText(effective.labels[index])||void 0,axis:stackValueAxes.get(axis)})),direction)}</td>`})}
|
|
35
35
|
</tr>
|
|
36
|
-
`)}hasCustomDataTable(){return hasSlottedChartDataTable(this)}legendMessage(label,value,percentage,metadata={}){if(this.legendDisplay==="label"||value===void 0)return label;const enriched={...metadata,percentage};if(this.legendDisplay==="value-percentage"){const formatted2=this.formatValue(value,"legend",enriched),percentageText=getNumberFormat(this.effectiveLocale,{style:"percent",maximumFractionDigits:1}).format(percentage);return{format:values=>this.localize("chartValuePercentageLabel",void 0,values),values:{label,value:typeof formatted2=="number"?this.formatSummaryValue(formatted2):String(formatted2),percentage:percentageText},isolated:["label","value","percentage"]}}const explicit=this.legendDisplay==="value"||this.legendDisplay==="percentage",formatted=this.legendDisplay==="percentage"?getNumberFormat(this.effectiveLocale,{style:"percent",maximumFractionDigits:1}).format(percentage):this.formatValue(value,"legend",enriched);return!explicit&&formatted===value||formatted===void 0?label:{format:values=>this.localize("chartValueLabel",void 0,values),values:{label,value:typeof formatted=="number"?this.formatSummaryValue(formatted):String(formatted)},isolated:["label","value"]}}legendTextContent(label,value,percentage,metadata={}){const message=this.legendMessage(label,value,percentage,metadata);return typeof message=="string"?message:isolatedMessage(message.format,message.values,message.isolated)}legendColor(dataset,datasetIndex,palette=this.seriesPalette(),datumIndex,colorCache=new Map){const fallback=palette[(datumIndex??datasetIndex)%palette.length]??"transparent",rawCandidate=chartDatasetValue(dataset,"backgroundColor")??chartDatasetValue(dataset,"borderColor")??chartDatasetValue(dataset,"color"),array=admitChartArray(rawCandidate),first=array?.length?chartRecordValue(array.source,String((datumIndex??0)%array.length)):void 0,candidate=typeof first=="object"?first.value??rawCandidate:rawCandidate;if(typeof candidate!="string")return fallback;let cached=colorCache.get(candidate);cached||(cached=new Map,colorCache.set(candidate,cached));const resolved=cached.get(fallback)??this.canvasTokens.resolve(candidate,fallback);return cached.set(fallback,resolved),resolved}toggleDataset(datasetIndex){if(!
|
|
36
|
+
`)}hasCustomDataTable(){return hasSlottedChartDataTable(this)}legendMessage(label,value,percentage,metadata={}){if(this.legendDisplay==="label"||value===void 0)return label;const enriched={...metadata,percentage};if(this.legendDisplay==="value-percentage"){const formatted2=this.formatValue(value,"legend",enriched),percentageText=getNumberFormat(this.effectiveLocale,{style:"percent",maximumFractionDigits:1}).format(percentage);return{format:values=>this.localize("chartValuePercentageLabel",void 0,values),values:{label,value:typeof formatted2=="number"?this.formatSummaryValue(formatted2):String(formatted2),percentage:percentageText},isolated:["label","value","percentage"]}}const explicit=this.legendDisplay==="value"||this.legendDisplay==="percentage",formatted=this.legendDisplay==="percentage"?getNumberFormat(this.effectiveLocale,{style:"percent",maximumFractionDigits:1}).format(percentage):this.formatValue(value,"legend",enriched);return!explicit&&formatted===value||formatted===void 0?label:{format:values=>this.localize("chartValueLabel",void 0,values),values:{label,value:typeof formatted=="number"?this.formatSummaryValue(formatted):String(formatted)},isolated:["label","value"]}}legendTextContent(label,value,percentage,metadata={}){const message=this.legendMessage(label,value,percentage,metadata);return typeof message=="string"?message:isolatedMessage(message.format,message.values,message.isolated)}legendColor(dataset,datasetIndex,palette=this.seriesPalette(),datumIndex,colorCache=new Map){const fallback=palette[(datumIndex??datasetIndex)%palette.length]??"transparent",rawCandidate=chartDatasetValue(dataset,"backgroundColor")??chartDatasetValue(dataset,"borderColor")??chartDatasetValue(dataset,"color"),array=admitChartArray(rawCandidate),first=array?.length?chartRecordValue(array.source,String((datumIndex??0)%array.length)):void 0,candidate=typeof first=="object"?first.value??rawCandidate:rawCandidate;if(typeof candidate!="string")return fallback;let cached=colorCache.get(candidate);cached||(cached=new Map,colorCache.set(candidate,cached));const resolved=cached.get(fallback)??this.canvasTokens.resolve(candidate,fallback);return cached.set(fallback,resolved),resolved}toggleDataset(datasetIndex){const chart=this.chart,generation=this.legendDataGeneration;if(!chart)return;const datasetCount=this.effectiveData().datasets.length;if(datasetIndex<0||datasetIndex>=datasetCount)return;const hidden=this.effectiveHiddenDatasetIndexes(),wasHidden=hidden.includes(datasetIndex),nextHidden=wasHidden?hidden.filter(index=>index!==datasetIndex):[...hidden,datasetIndex].sort((left,right)=>left-right),visible=wasHidden;if(this.emit("lr-legend-visibility-change-request",legendVisibilityDetail(datasetIndex,visible,nextHidden),{cancelable:!0}).defaultPrevented||this.chart!==chart||generation!==this.legendDataGeneration)return;this.hiddenDatasets=nextHidden;const appliedVisibility={chart,hidden:this.canonicalHiddenDatasets()};this.applyDatasetVisibility(),chart.update("none"),this.appliedLegendVisibility=appliedVisibility,this.requestUpdate("canvasPresentation",null),this.emit("lr-legend-visibility-change",legendVisibilityDetail(datasetIndex,visible,nextHidden))}toggleDatum(index){const chart=this.chart,generation=this.legendDataGeneration;if(!chart||!this.isSliceChart())return;const count=this.dataTableSample().rowCount;if(index<0||index>=count)return;const hidden=normalizeHiddenDatasets(this.hiddenDatums,count)??[],visible=hidden.includes(index),next=visible?hidden.filter(item=>item!==index):[...hidden,index].sort((a,b)=>a-b),detail={index,visible,hiddenDatums:next};this.emit("lr-datum-visibility-change-request",detail,{cancelable:!0}).defaultPrevented||this.chart!==chart||generation!==this.legendDataGeneration||(this.hiddenDatums=next,this.applyDatumVisibility(),chart.update("none"),this.emit("lr-datum-visibility-change",detail))}renderLegend(){if(!this.showsLegend)return nothing;const effective=this.effectiveData();if(!effective.datasets.length)return nothing;const sample=this.dataTableSample(effective);let palette=this.seriesPalette();const datumMode=this.legendMode!=="dataset"&&this.isSliceChart();datumMode&&(palette=palette.map((fallback,index)=>index<6?this.styleColor(`--fill-color-${index+1}`,fallback):fallback));const forcedColors=forcedColorsActive(this.ownerWindow),hiddenDatums=new Set(normalizeHiddenDatasets(this.hiddenDatums,sample.rowCount)),needValues=!this.spatialActive&&this.legendDisplay!=="label"&&(this.legendDisplay==="value"||this.legendDisplay==="percentage"||this.legendDisplay==="value-percentage"||this.formatter||this.valueFormatter),sources=new Map,colorCache=new Map,entries=(datumMode?sample.rowIndexes:sample.seriesIndexes).map(index=>{const datasetIndex=datumMode?0:index,dataset=effective.datasets[datasetIndex];let value,valueScale=0,scaledValue=0;if(needValues){let source=sources.get(datasetIndex);source||(source=this.datasetValues(dataset),sources.set(datasetIndex,source));for(const row of datumMode?[index]:sample.rowIndexes){const number=chartDatumNumericValue(source[row]);if(number!==void 0){value=finiteAdd(value??0,number);const nextScale=Math.max(valueScale,Math.abs(number));nextScale&&(scaledValue=scaledValue*(valueScale/nextScale)+number/nextScale),valueScale=nextScale}}}const label=datumMode?labelText(effective.labels[index])||this.localize("chartPointLabel",void 0,{n:this.formatSummaryValue(index+1)}):this.datasetLabel(dataset,datasetIndex);return{index,datasetIndex,dataset,label,value,valueScale,scaledValue}}),maximum=entries.reduce((largest,entry)=>Math.max(largest,entry.valueScale),0),total=maximum?entries.reduce((sum,entry)=>sum+Math.abs(entry.scaledValue)*(entry.valueScale/maximum),0):0,controlledHidden=normalizeHiddenDatasets(this.canonicalHiddenDatasets(),effective.datasets.length),controlledHiddenSet=controlledHidden===void 0?void 0:new Set(controlledHidden);return html`
|
|
37
37
|
<div
|
|
38
38
|
part="legend"
|
|
39
39
|
role="group"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{finiteCount,finiteRange}from"../../../internal/numbers.js";function hasCategoryLabelText(label){return(label??"").trim()!==""}function categoryLabelGrowth(index,count){return count<=1?"middle":index===0?"right":index===count-1?"left":"middle"}function anchorAwareCategoryLabelPicks(positions,width,gap,firstGrowth,lastGrowth){const count=positions.length;if(count<=2)return;const last=count-1,leftEdge=candidate=>{const growth=candidate===0?firstGrowth:candidate===last?lastGrowth:"middle",x=positions[candidate];return growth==="right"?x:growth==="left"?x-width:x-width/2},clears=(before,after)=>leftEdge(after)-(leftEdge(before)+width)>=gap-1e-6;let everyCandidateFits=!0;for(let candidate=1;candidate<count&&everyCandidateFits;candidate++)everyCandidateFits=clears(candidate-1,candidate);if(everyCandidateFits)return;const firstCenter=leftEdge(0)+width/2,span=leftEdge(last)+width/2-firstCenter,densest=Math.min(last,Math.floor(span/(width+gap)+1e-9)+1);for(let labels=densest;labels>2;labels--){const picks=[0];let candidate=1,fits=!0;for(let slot=1;slot<labels-1&&fits;slot++){const center=firstCenter+slot*span/(labels-1),latest=last-(labels-1-slot);for(;candidate<latest&&Math.abs(positions[candidate+1]-center)<=Math.abs(positions[candidate]-center);)candidate++;fits=clears(picks[picks.length-1],candidate),picks.push(candidate++)}if(fits&&clears(picks[picks.length-1],last))return[...picks,last]}return[0,last]}function widestEstimatedCategoryLabel(labels,renderedIndexes,characterWidth){let widest=0;for(const index of renderedIndexes)widest=Math.max(widest,(labels[index]??"").length*characterWidth);return widest}function automaticMaxCategoryLabels(count,plotWidth,
|
|
1
|
+
import{finiteCount,finiteRange}from"../../../internal/numbers.js";function hasCategoryLabelText(label){return(label??"").trim()!==""}function categoryLabelGrowth(index,count){return count<=1?"middle":index===0?"right":index===count-1?"left":"middle"}function anchorAwareCategoryLabelPicks(positions,width,gap,firstGrowth,lastGrowth){const count=positions.length;if(count<=2)return;const last=count-1,leftEdge=candidate=>{const growth=candidate===0?firstGrowth:candidate===last?lastGrowth:"middle",x=positions[candidate];return growth==="right"?x:growth==="left"?x-width:x-width/2},clears=(before,after)=>leftEdge(after)-(leftEdge(before)+width)>=gap-1e-6;let everyCandidateFits=!0;for(let candidate=1;candidate<count&&everyCandidateFits;candidate++)everyCandidateFits=clears(candidate-1,candidate);if(everyCandidateFits)return;const firstCenter=leftEdge(0)+width/2,span=leftEdge(last)+width/2-firstCenter,densest=Math.min(last,Math.floor(span/(width+gap)+1e-9)+1);for(let labels=densest;labels>2;labels--){const picks=[0];let candidate=1,fits=!0;for(let slot=1;slot<labels-1&&fits;slot++){const center=firstCenter+slot*span/(labels-1),latest=last-(labels-1-slot);for(;candidate<latest&&Math.abs(positions[candidate+1]-center)<=Math.abs(positions[candidate]-center);)candidate++;fits=clears(picks[picks.length-1],candidate),picks.push(candidate++)}if(fits&&clears(picks[picks.length-1],last))return[...picks,last]}return[0,last]}function widestEstimatedCategoryLabel(labels,renderedIndexes,characterWidth){let widest=0;for(const index of renderedIndexes)widest=Math.max(widest,(labels[index]??"").length*characterWidth);return widest}function automaticMaxCategoryLabels(count,plotWidth,bounds,widest){const lane=widest+bounds.laneInset,fits=Math.floor(finiteRange(plotWidth,0,0,bounds.maxContentWidth)/lane);return Math.min(count,Math.max(2,fits))}function automaticCategoryLabelIndexes(count,renderedIndexes,positions,labels,bounds,estimatedWidth){if(count<=1)return;const widest=estimatedWidth??widestEstimatedCategoryLabel(labels,renderedIndexes,bounds.characterWidth);if(widest===0)return;for(let candidate=1;candidate<positions.length;candidate++)if(!(positions[candidate]>=positions[candidate-1]))return null;const picks=anchorAwareCategoryLabelPicks(positions,widest,bounds.laneInset,categoryLabelGrowth(renderedIndexes[0],count),categoryLabelGrowth(renderedIndexes[renderedIndexes.length-1],count));return picks&&new Set(picks.map(candidate=>renderedIndexes[candidate]))}function visibleCategoryLabelIndexes(count,plotWidth,renderedIndexes,labels,maxLabels,positions,bounds,estimatedWidth){if(maxLabels==null)return;let requested=maxLabels;if(maxLabels==="auto"){const widest=count>1?estimatedWidth??widestEstimatedCategoryLabel(labels,renderedIndexes,bounds.characterWidth):0;if(widest===0)return;if(positions){const automatic=automaticCategoryLabelIndexes(count,renderedIndexes,positions,labels,bounds,widest);if(automatic!==null)return automatic}requested=automaticMaxCategoryLabels(count,plotWidth,bounds,widest)}if(typeof requested!="number")return;const max=finiteCount(requested,count);if(count<=max)return;const renderedCount=renderedIndexes.length,selectedCount=Math.min(renderedCount,bounds.maxRenderedRecords,Math.max(2,max));return selectedCount<=1?new Set(selectedCount===1?[renderedIndexes[0]]:[]):new Set(Array.from({length:selectedCount},(_,index)=>renderedIndexes[Math.round(index*(renderedCount-1)/(selectedCount-1))]))}function sparseCategoryLabelExtent(labels,xs,position,grow,pitch,width,margin,maxContentWidth){if(!hasCategoryLabelText(labels[position]))return width;const emptyBefore=position>0&&!hasCategoryLabelText(labels[position-1]),emptyAfter=position<labels.length-1&&!hasCategoryLabelText(labels[position+1]);if(!emptyBefore&&!emptyAfter)return width;const x=xs[position],halfToward=step=>{let outermost=-1;for(let index=position+step;index>=0&&index<labels.length;index+=step){if(hasCategoryLabelText(labels[index]))return Math.abs(x-xs[index])/2;outermost=index}return outermost<0?Number.POSITIVE_INFINITY:Math.abs(x-xs[outermost])+pitch/2},extent=grow==="middle"?2*Math.min(halfToward(-1),halfToward(1))-margin:halfToward(grow==="right"?1:-1)-margin;return finiteRange(Math.max(width,extent),width,width,maxContentWidth)}export{automaticCategoryLabelIndexes,categoryLabelGrowth,hasCategoryLabelText,sparseCategoryLabelExtent,visibleCategoryLabelIndexes,widestEstimatedCategoryLabel};
|